Merge pull request '客户类型公海设置' (#33) from zm into master

Reviewed-on: mengfucius/wkcrm#33
pull/40/head
张萌 2 years ago
commit fa411cad4d

@ -14,9 +14,9 @@ class PoolConfigLogic
* 公海配置列表 * 公海配置列表
* *
* @param array $param page 页码limit 每页条数 * @param array $param page 页码limit 每页条数
* @author fanqi
* @since 2021-03-30
* @return array * @return array
* @since 2021-03-30
* @author fanqi
*/ */
public function getPoolList($param) public function getPoolList($param)
{ {
@ -33,11 +33,11 @@ class PoolConfigLogic
# 统计公海下的客户数量 # 统计公海下的客户数量
$customerData = []; $customerData = [];
$customerList = db('crm_customer_pool_relation')->field(['pool_id', 'count(customer_id) AS customer_count'])->group('pool_id')->select(); $customerList = db('crm_customer_pool_relation')->field(['pool_id', 'count(customer_id) AS customer_count'])->group('pool_id')->select();
foreach ($customerList AS $key => $value) { foreach ($customerList as $key => $value) {
$customerData[$value['pool_id']] = $value['customer_count']; $customerData[$value['pool_id']] = $value['customer_count'];
} }
foreach ($list AS $key => $value) { foreach ($list as $key => $value) {
# 公海管理员 # 公海管理员
$adminUserIds = trim($value['admin_user_ids'], ','); $adminUserIds = trim($value['admin_user_ids'], ',');
$adminUserNames = db('admin_user')->whereIn('id', $adminUserIds)->column('realname'); $adminUserNames = db('admin_user')->whereIn('id', $adminUserIds)->column('realname');
@ -66,9 +66,9 @@ class PoolConfigLogic
* 设置多公海配置 * 设置多公海配置
* *
* @param $param * @param $param
* @author fanqi
* @since 2021-03-30
* @return bool * @return bool
* @since 2021-03-30
* @author fanqi
*/ */
public function setPoolConfig($param) public function setPoolConfig($param)
{ {
@ -111,7 +111,7 @@ class PoolConfigLogic
'department_ids' => !empty($param['department_ids']) ? ',' . $param['department_ids'] . ',' : '', 'department_ids' => !empty($param['department_ids']) ? ',' . $param['department_ids'] . ',' : '',
'status' => 1, 'status' => 1,
'before_owner_conf' => $param['before_owner_conf'], 'before_owner_conf' => $param['before_owner_conf'],
'before_owner_day' => $param['before_owner_day'], 'before_owner_day' => $param['before_owner_day'],
'receive_conf' => $param['receive_conf'], 'receive_conf' => $param['receive_conf'],
'receive_count' => $param['receive_count'], 'receive_count' => $param['receive_count'],
'remind_conf' => $param['remind_conf'], 'remind_conf' => $param['remind_conf'],
@ -161,9 +161,9 @@ class PoolConfigLogic
* 公海配置详情 * 公海配置详情
* *
* @param int $poolId 公海ID * @param int $poolId 公海ID
* @author fanqi
* @since 2021-03-30
* @return array|bool * @return array|bool
* @since 2021-03-30
* @author fanqi
*/ */
public function readPool($poolId) public function readPool($poolId)
{ {
@ -181,7 +181,7 @@ class PoolConfigLogic
$adminUserIds = trim($data['admin_user_ids'], ','); $adminUserIds = trim($data['admin_user_ids'], ',');
$data['admin_user_ids'] = $adminUserIds; $data['admin_user_ids'] = $adminUserIds;
$data['admin_user_info'] = db('admin_user')->field(['id', 'realname', 'thumb_img'])->whereIn('id', $adminUserIds)->select(); $data['admin_user_info'] = db('admin_user')->field(['id', 'realname', 'thumb_img'])->whereIn('id', $adminUserIds)->select();
foreach ($data['admin_user_info'] AS $key => $value) { foreach ($data['admin_user_info'] as $key => $value) {
$data['admin_user_info'][$key]['thumb_img'] = getFullPath($value['thumb_img']); $data['admin_user_info'][$key]['thumb_img'] = getFullPath($value['thumb_img']);
} }
@ -189,7 +189,7 @@ class PoolConfigLogic
$userIds = trim($data['user_ids'], ','); $userIds = trim($data['user_ids'], ',');
$data['user_ids'] = $userIds; $data['user_ids'] = $userIds;
$data['user_info'] = db('admin_user')->field(['id', 'realname', 'thumb_img'])->whereIn('id', $userIds)->select(); $data['user_info'] = db('admin_user')->field(['id', 'realname', 'thumb_img'])->whereIn('id', $userIds)->select();
foreach ($data['user_info'] AS $key => $value) { foreach ($data['user_info'] as $key => $value) {
$data['user_info'][$key]['thumb_img'] = getFullPath($value['thumb_img']); $data['user_info'][$key]['thumb_img'] = getFullPath($value['thumb_img']);
} }
@ -203,7 +203,7 @@ class PoolConfigLogic
# 公海规则 # 公海规则
$data['rule'] = db('crm_customer_pool_rule')->where('pool_id', $data['pool_id'])->select(); $data['rule'] = db('crm_customer_pool_rule')->where('pool_id', $data['pool_id'])->select();
foreach ($data['rule'] AS $key => $value) { foreach ($data['rule'] as $key => $value) {
if (!empty($value['level'])) { if (!empty($value['level'])) {
$data['rule'][$key]['level'] = json_decode($value['level'], true); $data['rule'][$key]['level'] = json_decode($value['level'], true);
$data['rule'][$key]['level_setting'] = json_decode($value['level'], true); $data['rule'][$key]['level_setting'] = json_decode($value['level'], true);
@ -220,9 +220,9 @@ class PoolConfigLogic
* 变更公海配置状态 * 变更公海配置状态
* *
* @param array $param pool_id 公海ID, status 状态1启用、0停用 * @param array $param pool_id 公海ID, status 状态1启用、0停用
* @author fanqi
* @since 2021-03-30
* @return false|int|string * @return false|int|string
* @since 2021-03-30
* @author fanqi
*/ */
public function changePoolStatus($param) public function changePoolStatus($param)
{ {
@ -246,9 +246,9 @@ class PoolConfigLogic
* 删除公海配置 * 删除公海配置
* *
* @param int $poolId 公海ID * @param int $poolId 公海ID
* @author fanqi
* @since 2021-03-30
* @return bool * @return bool
* @since 2021-03-30
* @author fanqi
*/ */
public function deletePool($poolId) public function deletePool($poolId)
{ {
@ -294,9 +294,9 @@ class PoolConfigLogic
* 转移公海客户 * 转移公海客户
* *
* @param array $param source_pool_id 源公海IDtarget_pool_id 目标公海ID * @param array $param source_pool_id 源公海IDtarget_pool_id 目标公海ID
* @author fanqi
* @since 2021-03-30
* @return bool * @return bool
* @since 2021-03-30
* @author fanqi
*/ */
public function transferPool($param) public function transferPool($param)
{ {
@ -313,7 +313,7 @@ class PoolConfigLogic
$diffCustomerIds = array_diff($sourceCustomerIds, $targetCustomerIds); $diffCustomerIds = array_diff($sourceCustomerIds, $targetCustomerIds);
$data = []; $data = [];
foreach ($diffCustomerIds AS $key => $value) { foreach ($diffCustomerIds as $key => $value) {
$data[] = [ $data[] = [
'customer_id' => $value, 'customer_id' => $value,
'pool_id' => $param['target_pool_id'] 'pool_id' => $param['target_pool_id']
@ -340,9 +340,9 @@ class PoolConfigLogic
/** /**
* 获取客户级别列表 * 获取客户级别列表
* *
* @author fanqi
* @since 2021-04-22
* @return array * @return array
* @since 2021-04-22
* @author fanqi
*/ */
public function getCustomerLevel() public function getCustomerLevel()
{ {
@ -357,9 +357,9 @@ class PoolConfigLogic
* 获取公海字段列表 * 获取公海字段列表
* *
* @param array $param pool_id 公海ID * @param array $param pool_id 公海ID
* @author fanqi
* @since 2021-04-29
* @return bool|PDOStatement|string|Collection * @return bool|PDOStatement|string|Collection
* @since 2021-04-29
* @author fanqi
*/ */
public function getPoolFieldList($param) public function getPoolFieldList($param)
{ {
@ -369,75 +369,75 @@ class PoolConfigLogic
$data = db('admin_field')->field(['field', 'name', 'form_type', 'is_hidden', 'is_null', 'is_unique'])->where(['types' => 'crm_customer'])->select(); $data = db('admin_field')->field(['field', 'name', 'form_type', 'is_hidden', 'is_null', 'is_unique'])->where(['types' => 'crm_customer'])->select();
$address = [ $address = [
'field' => 'address', 'field' => 'address',
'name' => '省、市、区/县', 'name' => '省、市、区/县',
'form_type' => 'customer_address', 'form_type' => 'customer_address',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
$detailAddress = [ $detailAddress = [
'field' => 'detail_address', 'field' => 'detail_address',
'name' => '详细地址', 'name' => '详细地址',
'form_type' => 'text', 'form_type' => 'text',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
$lastRecord = [ $lastRecord = [
'field' => 'last_record', 'field' => 'last_record',
'name' => '最后跟进记录', 'name' => '最后跟进记录',
'form_type' => 'text', 'form_type' => 'text',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
$lastTime = [ $lastTime = [
'field' => 'last_time', 'field' => 'last_time',
'name' => '最后跟进时间', 'name' => '最后跟进时间',
'form_type' => 'datetime', 'form_type' => 'datetime',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
$beforeOwnerUser = [ $beforeOwnerUser = [
'field' => 'before_owner_user_id', 'field' => 'before_owner_user_id',
'name' => '前负责人', 'name' => '前负责人',
'form_type' => 'user', 'form_type' => 'user',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
$intoPoolTime = [ $intoPoolTime = [
'field' => 'into_pool_time', 'field' => 'into_pool_time',
'name' => '进入公海时间', 'name' => '进入公海时间',
'form_type' => 'datetime', 'form_type' => 'datetime',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
$createTime = [ $createTime = [
'field' => 'create_time', 'field' => 'create_time',
'name' => '创建时间', 'name' => '创建时间',
'form_type' => 'datetime', 'form_type' => 'datetime',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
$updateTime = [ $updateTime = [
'field' => 'update_time', 'field' => 'update_time',
'name' => '更新时间', 'name' => '更新时间',
'form_type' => 'datetime', 'form_type' => 'datetime',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
$createUser = [ $createUser = [
'field' => 'create_user_id', 'field' => 'create_user_id',
'name' => '创建人', 'name' => '创建人',
'form_type' => 'user', 'form_type' => 'user',
'is_hidden' => 0, 'is_hidden' => 0,
'is_null' => 0, 'is_null' => 0,
'is_unique' => 0, 'is_unique' => 0,
]; ];
array_push($data, $address, $detailAddress, $lastRecord, $lastTime, $createTime, $updateTime, $createUser, $beforeOwnerUser, $intoPoolTime); array_push($data, $address, $detailAddress, $lastRecord, $lastTime, $createTime, $updateTime, $createUser, $beforeOwnerUser, $intoPoolTime);
@ -451,15 +451,15 @@ class PoolConfigLogic
* *
* @param array $rules 规则数据 * @param array $rules 规则数据
* @param int $poolId 公海ID * @param int $poolId 公海ID
* @author fanqi
* @since 2021-03-30
* @return array * @return array
* @since 2021-03-30
* @author fanqi
*/ */
private function getPoolRule($rules, $poolId) private function getPoolRule($rules, $poolId)
{ {
$result = []; $result = [];
foreach ($rules AS $key => $value) { foreach ($rules as $key => $value) {
$result[] = [ $result[] = [
'pool_id' => $poolId, 'pool_id' => $poolId,
'type' => $value['type'], 'type' => $value['type'],
@ -467,7 +467,8 @@ class PoolConfigLogic
'business_handle' => $value['business_handle'], 'business_handle' => $value['business_handle'],
'level_conf' => $value['level_conf'], 'level_conf' => $value['level_conf'],
'level' => json_encode($value['level']), 'level' => json_encode($value['level']),
'limit_day' => !empty($value['limit_day']) ? $value['limit_day'] : 0 'limit_day' => !empty($value['limit_day']) ? $value['limit_day'] : 0,
'customer_type'=>$value['customer_type'],
]; ];
} }
@ -479,23 +480,23 @@ class PoolConfigLogic
* *
* @param array $fields 字段列表 * @param array $fields 字段列表
* @param int $poolId 公海ID * @param int $poolId 公海ID
* @author fanqi
* @since 2021-03-30
* @return array * @return array
* @since 2021-03-30
* @author fanqi
*/ */
private function getPoolField($fields, $poolId) private function getPoolField($fields, $poolId)
{ {
$result = []; $result = [];
foreach ($fields AS $key => $value) { foreach ($fields as $key => $value) {
$result[] = [ $result[] = [
'pool_id' => $poolId, 'pool_id' => $poolId,
'name' => $value['name'], 'name' => $value['name'],
'field_name' => $value['field'], 'field_name' => $value['field'],
'form_type' => $value['form_type'], 'form_type' => $value['form_type'],
'is_hidden' => $value['is_hidden'], 'is_hidden' => $value['is_hidden'],
'is_null' => $value['is_null'], 'is_null' => $value['is_null'],
'is_unique' => $value['is_unique'] 'is_unique' => $value['is_unique']
]; ];
} }

@ -100,7 +100,7 @@ class PoolCommand extends Command
'into_pool_time' => time() 'into_pool_time' => time()
]); ]);
} }
$this->updateInfo($ruleList,$customerWhere); $this->updateInfo($ruleList, $customerWhere);
# 删除联系人的负责人 # 删除联系人的负责人
Db::name('crm_contacts')->whereIn('customer_id', $customerWhere)->update(['owner_user_id' => '']); Db::name('crm_contacts')->whereIn('customer_id', $customerWhere)->update(['owner_user_id' => '']);
@ -112,6 +112,7 @@ class PoolCommand extends Command
} }
}); });
} }
/** /**
* 自动入公海操作记录 * 自动入公海操作记录
* @param $ruleList * @param $ruleList
@ -142,7 +143,6 @@ class PoolCommand extends Command
} }
protected function execute(Input $input, Output $output) protected function execute(Input $input, Output $output)
{ {
# 动态修改运行时参数 # 动态修改运行时参数
@ -227,9 +227,9 @@ class PoolCommand extends Command
foreach ($rules as $k => $v) { foreach ($rules as $k => $v) {
if (!isset($result[$v['pool_id']])) $result[$v['pool_id']] = []; if (!isset($result[$v['pool_id']])) $result[$v['pool_id']] = [];
if ($v['type'] == 1) $result[$v['pool_id']] = array_merge($result[$v['pool_id']], $this->getFollowUpQueryResult($v['level_conf'], $v['level'], $v['deal_handle'], $v['business_handle'])); if ($v['type'] == 1) $result[$v['pool_id']] = array_merge($result[$v['pool_id']], $this->getFollowUpQueryResult($v['level_conf'], $v['level'], $v['deal_handle'], $v['business_handle'], $v['customer_type']));
if ($v['type'] == 2) $result[$v['pool_id']] = array_merge($result[$v['pool_id']], $this->getBusinessQueryResult($v['level_conf'], $v['level'], $v['deal_handle'])); if ($v['type'] == 2) $result[$v['pool_id']] = array_merge($result[$v['pool_id']], $this->getBusinessQueryResult($v['level_conf'], $v['level'], $v['deal_handle'], $v['customer_type']));
if ($v['type'] == 3) $result[$v['pool_id']] = array_merge($result[$v['pool_id']], $this->getDealQueryResult($v['level_conf'], $v['level'], $v['business_handle'])); if ($v['type'] == 3) $result[$v['pool_id']] = array_merge($result[$v['pool_id']], $this->getDealQueryResult($v['level_conf'], $v['level'], $v['business_handle'], $v['customer_type']));
} }
return $result; return $result;
@ -246,7 +246,7 @@ class PoolCommand extends Command
* @since 2021-04-01 * @since 2021-04-01
* @author fanqi * @author fanqi
*/ */
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus) private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus, $customerType)
{ {
# 转换格式 # 转换格式
$levels = json_decode($levels, true); $levels = json_decode($levels, true);
@ -293,6 +293,12 @@ class PoolCommand extends Command
# 锁定的客户不提醒 # 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0"; $where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;
}
# 查询符合条件的客户 # 查询符合条件的客户
return db('crm_customer') return db('crm_customer')
->alias('customer')->join('__CRM_BUSINESS__ business', 'business.customer_id = customer.customer_id', 'LEFT') ->alias('customer')->join('__CRM_BUSINESS__ business', 'business.customer_id = customer.customer_id', 'LEFT')
@ -309,7 +315,7 @@ class PoolCommand extends Command
* @since 2021-04-01 * @since 2021-04-01
* @author fanqi * @author fanqi
*/ */
private function getBusinessQueryResult($type, $levels, $dealStatus) private function getBusinessQueryResult($type, $levels, $dealStatus, $customerType)
{ {
# 转换格式 # 转换格式
$levels = json_decode($levels, true); $levels = json_decode($levels, true);
@ -353,6 +359,10 @@ class PoolCommand extends Command
# 锁定的客户不提醒 # 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0"; $where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;
}
# 查询匹配条件的客户 # 查询匹配条件的客户
return db('crm_customer')->alias('customer') return db('crm_customer')->alias('customer')
->join('__CRM_BUSINESS__ business', 'business.customer_id = customer.customer_id', 'LEFT') ->join('__CRM_BUSINESS__ business', 'business.customer_id = customer.customer_id', 'LEFT')
@ -369,7 +379,7 @@ class PoolCommand extends Command
* @since 2021-04-01 * @since 2021-04-01
* @author fanqi * @author fanqi
*/ */
private function getDealQueryResult($type, $levels, $businessStatus) private function getDealQueryResult($type, $levels, $businessStatus, $customerType)
{ {
# 转换格式 # 转换格式
$levels = json_decode($levels, true); $levels = json_decode($levels, true);
@ -413,6 +423,10 @@ class PoolCommand extends Command
# 锁定的客户不提醒 # 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0"; $where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;
}
# 查询符合条件的客户 # 查询符合条件的客户
return db('crm_customer')->alias('customer') return db('crm_customer')->alias('customer')
->join('__CRM_BUSINESS__ business', 'business.customer_id = customer.customer_id', 'LEFT') ->join('__CRM_BUSINESS__ business', 'business.customer_id = customer.customer_id', 'LEFT')

@ -127,9 +127,9 @@ class Customer extends ApiCommon
$customerCheck = db('crm_customer_check')->where(['customer_id' => $param['id']])->where(['check_status' => 0])->find(); $customerCheck = db('crm_customer_check')->where(['customer_id' => $param['id']])->where(['check_status' => 0])->find();
if (!empty($customerCheck)) { if (!empty($customerCheck)) {
$data['flow_id'] = $customerCheck['flow_id']; $data['flow_id'] = $customerCheck['flow_id'];
$data['owner_user_id']=$customerCheck['user_id']; $data['owner_user_id'] = $customerCheck['user_id'];
$data['customer_check_id']=$customerCheck['customer_check_id']; $data['customer_check_id'] = $customerCheck['customer_check_id'];
$data['apply_user_name']=db('admin_user')->where('id', $customerCheck['create_user_id'])->column("username"); $data['apply_user_name'] = db('admin_user')->where('id', $customerCheck['create_user_id'])->column("username");
} }
return resultArray(['data' => $data]); return resultArray(['data' => $data]);
} }
@ -1175,4 +1175,20 @@ class Customer extends ApiCommon
return resultArray(['data' => $data]); return resultArray(['data' => $data]);
} }
/**
* 客户类型列表
*
* @return \think\response\Json
* @since 2021-03-29
* @author fanqi
*/
public function Type()
{
$data = db('admin_field')->where(['types' => 'crm_customer', 'field' => 'crm_lthugd'])->value('options');
$data = explode(',', $data);
return resultArray(['data' => $data]);
}
} }

@ -352,38 +352,38 @@ class CustomerPool extends ApiCommon
*/ */
public function fieldsData($param) public function fieldsData($param)
{ {
$where=['pool_id' => $param['pool_id'], 'is_hidden' => 0, $where = ['pool_id' => $param['pool_id'], 'is_hidden' => 0,
'field_name' => ['not in', ['deal_status','create_user_id']]]; 'field_name' => ['not in', ['deal_status', 'create_user_id']]];
if($param['is_excel']==1){ if ($param['is_excel'] == 1) {
$where=['pool_id' => $param['pool_id'], 'is_hidden' => 0, $where = ['pool_id' => $param['pool_id'], 'is_hidden' => 0,
'field_name' => ['not in', ['deal_status']]]; 'field_name' => ['not in', ['deal_status']]];
} }
$pool_list = db('crm_customer_pool_field_setting')->where($where)->field('field_name as field,form_type,name')->select(); $pool_list = db('crm_customer_pool_field_setting')->where($where)->field('field_name as field,form_type,name')->select();
$fieldParam['types'] = 'crm_customer'; $fieldParam['types'] = 'crm_customer';
$fieldParam['action'] = 'excel'; $fieldParam['action'] = 'excel';
$setting = []; $setting = [];
$list=[]; $list = [];
foreach ($pool_list as $k => &$v) { foreach ($pool_list as $k => &$v) {
switch ($v['field']) { switch ($v['field']) {
case 'address': case 'address':
if($param['is_excel']!=1){ if ($param['is_excel'] != 1) {
$v['field'] = 'customer_address'; $v['field'] = 'customer_address';
$v['form_type'] = 'map_address'; $v['form_type'] = 'map_address';
$list[]=$v; $list[] = $v;
unset($pool_list[$k]); unset($pool_list[$k]);
} }
break; break;
case 'detail_address': case 'detail_address':
if($param['is_excel']!=1){ if ($param['is_excel'] != 1) {
unset($pool_list[$k]); unset($pool_list[$k]);
} }
break; break;
case ($v['form_type'] == 'select') || ($v['form_type'] == 'checkbox') : case ($v['form_type'] == 'select') || ($v['form_type'] == 'checkbox') :
$set= db('admin_field')->where(['types' => 'crm_customer', 'field' => $v['field']])->find(); $set = db('admin_field')->where(['types' => 'crm_customer', 'field' => $v['field']])->find();
$pool_list[$k]['setting'] = explode(chr(10), $set['setting']); $pool_list[$k]['setting'] = explode(chr(10), $set['setting']);
break; break;
default : default :
if($param['is_excel']!=1){ if ($param['is_excel'] != 1) {
$pool_list[$k]['setting'] = []; $pool_list[$k]['setting'] = [];
} }
break; break;
@ -398,7 +398,7 @@ class CustomerPool extends ApiCommon
// } // }
// } // }
} }
$pool_list=array_merge($pool_list,$list); $pool_list = array_merge($pool_list, $list);
return $pool_list; return $pool_list;
} }
@ -440,7 +440,7 @@ class CustomerPool extends ApiCommon
$checkData['check_time'] = time(); $checkData['check_time'] = time();
$checkData['content'] = $param['content']; $checkData['content'] = $param['content'];
$checkData['flow_id'] = $dataInfo['flow_id']; $checkData['flow_id'] = $dataInfo['flow_id'];
$checkData['order_id'] = $dataInfo['order_id'] ? : 1; $checkData['order_id'] = $dataInfo['order_id'] ?: 1;
$checkData['status'] = $status; $checkData['status'] = $status;
if ($status == 1) { if ($status == 1) {
@ -448,8 +448,8 @@ class CustomerPool extends ApiCommon
//固定流程 //固定流程
//获取下一审批信息 //获取下一审批信息
$nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $dataInfo['flow_id'], 'crm_customer_check', $param['id'], $dataInfo['order_id'], $user_id); $nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $dataInfo['flow_id'], 'crm_customer_check', $param['id'], $dataInfo['order_id'], $user_id);
$next_user_ids = $nextStepData['next_user_ids'] ? : []; $next_user_ids = $nextStepData['next_user_ids'] ?: [];
$customerCheckData['order_id'] = $nextStepData['order_id'] ? : ''; $customerCheckData['order_id'] = $nextStepData['order_id'] ?: '';
if (!$next_user_ids) { if (!$next_user_ids) {
$is_end = 1; $is_end = 1;
//审批结束 //审批结束
@ -462,7 +462,7 @@ class CustomerPool extends ApiCommon
} else { } else {
//自选流程 //自选流程
$is_end = $param['is_end'] ? 1 : ''; $is_end = $param['is_end'] ? 1 : '';
$check_user_id = $param['check_user_id'] ? : ''; $check_user_id = $param['check_user_id'] ?: '';
if ($is_end !== 1 && empty($check_user_id)) { if ($is_end !== 1 && empty($check_user_id)) {
return resultArray(['error' => '请选择下一审批人']); return resultArray(['error' => '请选择下一审批人']);
} }
@ -481,7 +481,7 @@ class CustomerPool extends ApiCommon
// $examineRecordModel->setEnd(['types' => 'crm_contract','types_id' => $param['id']]); // $examineRecordModel->setEnd(['types' => 'crm_contract','types_id' => $param['id']]);
} }
//已审批人ID //已审批人ID
$customerCheckData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']),[$user_id])) : arrayToString([$user_id]); $customerCheckData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']), [$user_id])) : arrayToString([$user_id]);
$resCustomerCheck = db('crm_customer_check')->where(['customer_check_id' => $param['id']])->update($customerCheckData); $resCustomerCheck = db('crm_customer_check')->where(['customer_check_id' => $param['id']])->update($customerCheckData);
if ($resCustomerCheck) { if ($resCustomerCheck) {
//审批记录 //审批记录
@ -499,8 +499,8 @@ class CustomerPool extends ApiCommon
); );
$customerData = []; $customerData = [];
$customerData['user_id']=$dataInfo['user_id']; $customerData['user_id'] = $dataInfo['user_id'];
$customerData['customer_id']=$dataInfo['customer_id']; $customerData['customer_id'] = $dataInfo['customer_id'];
$result = (new CustomerPoolLogic())->receiveCustomers($customerData); $result = (new CustomerPoolLogic())->receiveCustomers($customerData);
@ -536,4 +536,20 @@ class CustomerPool extends ApiCommon
return resultArray(['error' => '审批失败,请重试!']); return resultArray(['error' => '审批失败,请重试!']);
} }
} }
/**
* 总经理公海池消息提醒
*
* @return Json
* @since 2021-04-14
* @author fanqi
*/
public function num()
{
$customerPoolCount = db('crm_customer_pool_relation')->where("pool_id",array('eq',3))
->count();
return resultArray(['data' => $customerPoolCount]);
}
} }

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

@ -56,6 +56,8 @@ return [
'crm/customer/poolAuthority' => ['crm/customer/poolAuthority', ['method' => 'POST']], 'crm/customer/poolAuthority' => ['crm/customer/poolAuthority', ['method' => 'POST']],
// 【客户】级别列表 // 【客户】级别列表
'crm/customer/level' => ['crm/customer/level', ['method' => 'POST']], 'crm/customer/level' => ['crm/customer/level', ['method' => 'POST']],
// 【客户】类型列表
'crm/customer/type' => ['crm/customer/type', ['method' => 'POST']],
// 【客户】公海列表 // 【客户】公海列表
'crm/customerPool/index' => ['crm/customerPool/index', ['method' => 'POST']], 'crm/customerPool/index' => ['crm/customerPool/index', ['method' => 'POST']],
@ -89,6 +91,8 @@ return [
'crm/customerPool/setFieldWidth' => ['crm/customerPool/setFieldWidth', ['method' => 'POST']], 'crm/customerPool/setFieldWidth' => ['crm/customerPool/setFieldWidth', ['method' => 'POST']],
// 【客户】设置公海字段配置 // 【客户】设置公海字段配置
'crm/customerPool/setFieldConfig' => ['crm/customerPool/setFieldConfig', ['method' => 'POST']], 'crm/customerPool/setFieldConfig' => ['crm/customerPool/setFieldConfig', ['method' => 'POST']],
// 【客户】总经理客户公海池消息
'crm/customerPool/num' => ['crm/customerPool/num', ['method' => 'POST']],
// 【客户】回访 // 【客户】回访
'crm/visit/index' => ['crm/visit/index', ['method' => 'POST']], 'crm/visit/index' => ['crm/visit/index', ['method' => 'POST']],

Loading…
Cancel
Save