Commit 2f415eae by 朱继来

Merge branch 'zjl_crm_v3_20210903'

parents 05e9a79d 09d8a582
......@@ -180,6 +180,15 @@ Class AddOrderController extends Controller
// return ['errcode' => -1, 'errmsg' => '该客户由 '.$sale_name.' 跟进,请联系主管重新指派'];
// }
// 获取当前销售 已成交的用户上限
$order_user_limit = $CrmModel->getOrderUserLimit($request->user->userId);
if ($order_user_limit) {
$count = $CrmModel->getSaleOrderUserCount($request->user->userId);
if ($count > $order_user_limit) return ['errcode'=>11001, 'errmsg'=>'你已达到成交用户上限,请先释放你跟进的已下单用户或联系主管重新分配当前用户'];
}
$res = $CrmModel->isBind($user->user_id, $operator_id);
if (!$res) {
// 检查当前用户是否有人跟进
......
......@@ -26,6 +26,7 @@ use App\Model\PayExtendModel;
use App\Model\OrderPurPriceModel;
use App\Model\OrderServiceModel;
use App\Model\OrderServiceItemsModel;
use App\Model\CrmModel;
use Session;
use Hprose\Http\Client;
......@@ -926,6 +927,16 @@ Class OrderController extends Controller
return ['errcode'=>-1, 'errmsg'=>'此订单已被'.$name.'锁定,不能提交审单!'];
}
// 获取当前销售 已成交的用户上限
$CrmModel = new CrmModel;
$order_user_limit = $CrmModel->getOrderUserLimit($request->user->userId);
if ($order_user_limit) {
$count = $CrmModel->getSaleOrderUserCount($request->user->userId);
if ($count > $order_user_limit) return ['errcode'=>11001, 'errmsg'=>'你已达到成交用户上限,请先释放你跟进的已下单用户或联系主管重新分配当前用户'];
}
$perm = new PermController;
$OrderModel = new OrderModel;
$relation_id = [];
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use App\Model\OrderModel;
class CrmModel extends Model
{
......@@ -38,4 +39,21 @@ class CrmModel extends Model
return $this->from('invoice_com_user')->where('user_id', $user_id)->value('sale_id');
}
// 获取当前销售的成交用户上限
public function getOrderUserLimit($sale_id)
{
return $this->from('employee_card')->where('sale_id', $sale_id)->value('order_user_limit');
}
// 获取当前销售 已下单用户数量
public function getSaleOrderUserCount($sale_id)
{
$users = $this->from('invoice_com_user')->where('user_id', '<>', 0)->where('sale_id', $sale_id)->lists('user_id');
if (empty($users)) return 0;
return OrderModel::whereIn('user_id', $users)->where('status', '<>', -1)->where('sale_id', $sale_id)->groupBy('user_id')->get()->count(); // 去重+统计 laravel需要先get()
}
}
\ No newline at end of file
......@@ -98,6 +98,10 @@
loading.lists(data.user.user_id, goods_type, is_online); // 加载该用户购物车
return false;
} else if (resp.errcode == 11001) {
$('.search-user').val('');
layer.alert(resp.errmsg)
return false;
}
layer.msg(resp.errmsg)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment