|
|
|
@ -447,9 +447,9 @@ class CustomerPoolLogic extends Common
|
|
|
|
|
* 领取公海客户
|
|
|
|
|
*
|
|
|
|
|
* @param array $param user_id 领取人ID,customer_id 要领取的客户ID
|
|
|
|
|
* @return array
|
|
|
|
|
* @since 2021-04-15
|
|
|
|
|
* @author fanqi
|
|
|
|
|
* @since 2021-04-15
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function receiveCustomers($param)
|
|
|
|
|
{
|
|
|
|
@ -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'] . '》领取失败,失败原因:持有客户数达到上限!';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -503,7 +503,7 @@ class CustomerPoolLogic extends Common
|
|
|
|
|
|
|
|
|
|
# 前负责人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'];
|
|
|
|
@ -536,8 +536,7 @@ class CustomerPoolLogic extends Common
|
|
|
|
|
'owner_user_id' => $userId,
|
|
|
|
|
'before_owner_user_id' => 0,
|
|
|
|
|
'into_pool_time' => 0,
|
|
|
|
|
'obtain_time' => time(),
|
|
|
|
|
'is_allocation' => 1,
|
|
|
|
|
'obtain_time' => time()
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
# 整理字段操作记录和数据日志的数据
|
|
|
|
@ -545,7 +544,7 @@ class CustomerPoolLogic extends Common
|
|
|
|
|
$addActionRecordData = [];
|
|
|
|
|
$addOperationLogData = [];
|
|
|
|
|
$addReceiveData = [];
|
|
|
|
|
foreach ($addCustomerId as $key => $value) {
|
|
|
|
|
foreach ($addCustomerId AS $key => $value) {
|
|
|
|
|
$addActionRecordData[] = [
|
|
|
|
|
'user_id' => $userId,
|
|
|
|
|
'types' => 'crm_customer',
|
|
|
|
@ -1144,8 +1143,7 @@ class CustomerPoolLogic extends Common
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dataInfo = db('crm_customer_check')->where('customer_id', 'in', $param['customer_id'])->find();
|
|
|
|
|
|
|
|
|
|
if (!empty($dataInfo)&& $dataInfo['check_status'] < 2) {
|
|
|
|
|
if ($dataInfo) {
|
|
|
|
|
return '客户已被领取待审批,请联系管理员';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|