diff --git a/application/admin/logic/PoolConfigLogic.php b/application/admin/logic/PoolConfigLogic.php index a3019db..02d1f79 100644 --- a/application/admin/logic/PoolConfigLogic.php +++ b/application/admin/logic/PoolConfigLogic.php @@ -97,6 +97,11 @@ class PoolConfigLogic return false; } + if (!empty($param['customer_type'])) { + $this->error = '请设置客户类型!'; + return false; + } + $repeatWhere['pool_name'] = $param['pool_name']; if (!empty($param['pool_id'])) $repeatWhere['pool_id'] = ['neq', $param['pool_id']]; if (db('crm_customer_pool')->where($repeatWhere)->value('pool_id')) { @@ -118,7 +123,8 @@ class PoolConfigLogic 'remain_day' => $param['remain_day'], 'recycle_conf' => $param['recycle_conf'], 'create_user_id' => $param['user_id'], - 'create_time' => time() + 'create_time' => time(), + 'customer_type' => $param['customer_type'], ]; Db::startTrans(); @@ -468,7 +474,6 @@ class PoolConfigLogic 'level_conf' => $value['level_conf'], 'level' => json_encode($value['level']), 'limit_day' => !empty($value['limit_day']) ? $value['limit_day'] : 0, - 'customer_type'=>$value['customer_type'], ]; } diff --git a/application/common/command/PoolCommand.php b/application/common/command/PoolCommand.php index 3621fde..3677338 100644 --- a/application/common/command/PoolCommand.php +++ b/application/common/command/PoolCommand.php @@ -74,8 +74,7 @@ class PoolCommand extends Command if ((int)date('H') >= 0 && (int)date('H') < 6) { # 公海规则 $ruleList = db('crm_customer_pool_rule')->alias('rule')->field('rule.*') - ->join('__CRM_CUSTOMER_POOL__ pool', 'pool.pool_id = rule.pool_id', 'LEFT')->where('pool.status', 1)->select(); - + ->join('__CRM_CUSTOMER_POOL__ pool', 'pool.pool_id = rule.pool_id', 'LEFT')->field("pool.customer_type")->where('pool.status', 1)->select(); if (!empty($ruleList)) { # 符合公海条件的客户IDS $customerIds = $this->getQueryCondition($ruleList); diff --git a/application/crm/controller/Customer.php b/application/crm/controller/Customer.php index a29eba9..b913b08 100644 --- a/application/crm/controller/Customer.php +++ b/application/crm/controller/Customer.php @@ -425,11 +425,21 @@ class Customer extends ApiCommon # 获取客户数据 $customerData = []; - $customerList = db('crm_customer')->field(['customer_id', 'owner_user_id', 'name'])->whereIn('customer_id', $customerIds)->select(); + $customerList = db('crm_customer')->field(['customer_id', 'owner_user_id', 'name', 'crm_lthugd'])->whereIn('customer_id', $customerIds)->select(); foreach ($customerList as $key => $value) { $customerData[$value['customer_id']] = $value; } + # 获取公海规则数据 + $customerPoolData = db('crm_customer_pool')->field(['customer_type'])->where('pool_id=' . $poolId)->find(); + + # 判断客户类型是否符合公海池客户类型 + if (!in_array($customerData['crm_lthugd'], $customerPoolData)) { + $message[] = '客户类型与公海池类型不匹配!'; + return resultArray(['error' => $message]); + } + + # 整理数据 $ip = request()->ip(); $poolRelationData = [];