|
|
@ -447,9 +447,9 @@ class CustomerPoolLogic extends Common
|
|
|
|
* 领取公海客户
|
|
|
|
* 领取公海客户
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param array $param user_id 领取人ID,customer_id 要领取的客户ID
|
|
|
|
* @param array $param user_id 领取人ID,customer_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'] . '》领取失败,失败原因:持有客户数达到上限!';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -503,7 +503,7 @@ class CustomerPoolLogic extends Common
|
|
|
|
|
|
|
|
|
|
|
|
# 前负责人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'];
|
|
|
@ -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 '客户已被领取待审批,请联系管理员';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|