戴余标 2 years ago
commit ae5f35941d

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

Loading…
Cancel
Save