Compare commits

..

2 Commits

@ -447,9 +447,9 @@ class CustomerPoolLogic extends Common
* 领取公海客户
*
* @param array $param user_id 领取人IDcustomer_id 要领取的客户ID
* @author fanqi
* @since 2021-04-15
* @return array
* @since 2021-04-15
* @author fanqi
*/
public function receiveCustomers($param)
{
@ -457,7 +457,7 @@ class CustomerPoolLogic extends Common
if (empty($param['user_id'])) return ['缺少员工ID'];
# 查询参数
$userId = $param['user_id'];
$userId = $param['user_id'];
$customerId = $param['customer_id'];
# 消息数据
@ -467,7 +467,7 @@ class CustomerPoolLogic extends Common
$customerData = $this->getCustomerList($customerId);
# 剔除非公海客户
foreach ($customerId AS $key => $value) {
foreach ($customerId as $key => $value) {
if (!empty($customerData[$value]['owner_user_id'])) {
$message[] = '客户《' . $customerData[$value]['name'] . '》领取失败,失败原因:不是公海客户!';
@ -487,7 +487,7 @@ class CustomerPoolLogic extends Common
$failCustomer = [];
if (!is_bool($exceedCount) && !empty($exceedCount) && $exceedCount > 0) {
$failCustomer = array_slice($customerId, count($customerId) - $exceedCount);
foreach ($failCustomer AS $key => $value) {
foreach ($failCustomer as $key => $value) {
$message[] = '客户《' . $customerData[$value]['name'] . '》领取失败,失败原因:持有客户数达到上限!';
}
}
@ -497,18 +497,18 @@ class CustomerPoolLogic extends Common
# 检查是否还有要领取的客户
if (empty($addCustomerId)) return $message;
# 查询领取客户的公海id
$poolId=db('crm_customer_pool_relation')->whereIn('customer_id',$customerId)->value('pool_id');
$poolId = db('crm_customer_pool_relation')->whereIn('customer_id', $customerId)->value('pool_id');
# 公海配置
$poolConfig = db('crm_customer_pool')->field(['before_owner_conf', 'before_owner_day', 'receive_conf', 'receive_count'])->where('pool_id', $poolId)->find();
# 前负责人N天内不能领取客户
if (!empty($poolConfig['before_owner_conf'])) {
foreach ($addCustomerId AS $key => $value) {
foreach ($addCustomerId as $key => $value) {
# 是前负责人,检查前负责人是否能够领取。
if ($userId == $customerData[$value]['before_owner_user_id']) {
$restrictDay = $customerData[$value]['into_pool_time'] + 86400 * $poolConfig['before_owner_day'];
if (time() < $restrictDay) {
$message[] = '客户《' . $customerData[$value]['name'] . '》领取失败,失败原因:进入公海后,'.$poolConfig['before_owner_day'].'天内不能领取!';
$message[] = '客户《' . $customerData[$value]['name'] . '》领取失败,失败原因:进入公海后,' . $poolConfig['before_owner_day'] . '天内不能领取!';
unset($addCustomerId[(int)$key]);
}
@ -527,46 +527,47 @@ class CustomerPoolLogic extends Common
$receiveCount = db('crm_customer_pool_record')->where($countWhere)->count();
if (!empty($poolConfig['receive_conf']) && $receiveCount + count($addCustomerId) > $poolConfig['receive_count']) {
$overQuantity = ($receiveCount + count($addCustomerId)) - $poolConfig['receive_count'];
$message[] = '领取客户失败,失败原因:超出当日可领取数量,超出'.$overQuantity.'个!';
$message[] = '领取客户失败,失败原因:超出当日可领取数量,超出' . $overQuantity . '个!';
return $message;
}
# 整理客户更新数据
$addCustomerData = [
'owner_user_id' => $userId,
'owner_user_id' => $userId,
'before_owner_user_id' => 0,
'into_pool_time' => 0,
'obtain_time' => time()
'into_pool_time' => 0,
'obtain_time' => time(),
'is_allocation' => 1,
];
# 整理字段操作记录和数据日志的数据
$ip = request()->ip();
$addActionRecordData = [];
$addOperationLogData = [];
$addReceiveData = [];
foreach ($addCustomerId AS $key => $value) {
$addReceiveData = [];
foreach ($addCustomerId as $key => $value) {
$addActionRecordData[] = [
'user_id' => $userId,
'types' => 'crm_customer',
'action_id' => $value,
'content' => '领取了客户',
'user_id' => $userId,
'types' => 'crm_customer',
'action_id' => $value,
'content' => '领取了客户',
'create_time' => time()
];
$addOperationLogData[] = [
'user_id' => $userId,
'client_ip' => $ip,
'module' => 'crm_customer',
'action_id' => $value,
'content' => '领取了客户',
'user_id' => $userId,
'client_ip' => $ip,
'module' => 'crm_customer',
'action_id' => $value,
'content' => '领取了客户',
'create_time' => time(),
'action_name' => 'update',
'target_name' => $customerData[$value]['name']
];
$addReceiveData[] = [
'customer_id' => $value,
'user_id' => $userId,
'pool_id' => $poolId,
'type' => 1,
'user_id' => $userId,
'pool_id' => $poolId,
'type' => 1,
'create_time' => time()
];
}
@ -1143,7 +1144,8 @@ class CustomerPoolLogic extends Common
$dataInfo = db('crm_customer_check')->where('customer_id', 'in', $param['customer_id'])->find();
if ($dataInfo) {
if (!empty($dataInfo)&& $dataInfo['check_status'] < 2) {
return '客户已被领取待审批,请联系管理员';
}

@ -162,7 +162,7 @@ class Customer extends Common
$groupNameArray = db('admin_group')->where("pid", array("eq", 2))->where("id", array("in", $groupIds))->column("title");
if ($groupNameArray)
$map['customer.crm_roziuw'] = array('in', $groupNameArray);
$map['customer.crm_lthugd'] = array('in', $groupNameArray);
}
# 代办事项 - 待进入公海
$remindWhere = [];

Loading…
Cancel
Save