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

@ -100,7 +100,7 @@ class PoolCommand extends Command
'into_pool_time' => time()
]);
}
$this->updateInfo($ruleList,$customerWhere);
$this->updateInfo($ruleList, $customerWhere);
# 删除联系人的负责人
Db::name('crm_contacts')->whereIn('customer_id', $customerWhere)->update(['owner_user_id' => '']);
@ -112,6 +112,7 @@ class PoolCommand extends Command
}
});
}
/**
* 自动入公海操作记录
* @param $ruleList
@ -142,7 +143,6 @@ class PoolCommand extends Command
}
protected function execute(Input $input, Output $output)
{
# 动态修改运行时参数
@ -227,9 +227,9 @@ class PoolCommand extends Command
foreach ($rules as $k => $v) {
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'] == 2) $result[$v['pool_id']] = array_merge($result[$v['pool_id']], $this->getBusinessQueryResult($v['level_conf'], $v['level'], $v['deal_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']));
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'], $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'], $v['customer_type']));
}
return $result;
@ -246,7 +246,7 @@ class PoolCommand extends Command
* @since 2021-04-01
* @author fanqi
*/
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus)
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus, $customerType)
{
# 转换格式
$levels = json_decode($levels, true);
@ -293,6 +293,12 @@ class PoolCommand extends Command
# 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;
}
# 查询符合条件的客户
return db('crm_customer')
->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
* @author fanqi
*/
private function getBusinessQueryResult($type, $levels, $dealStatus)
private function getBusinessQueryResult($type, $levels, $dealStatus, $customerType)
{
# 转换格式
$levels = json_decode($levels, true);
@ -353,6 +359,10 @@ class PoolCommand extends Command
# 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;
}
# 查询匹配条件的客户
return db('crm_customer')->alias('customer')
->join('__CRM_BUSINESS__ business', 'business.customer_id = customer.customer_id', 'LEFT')
@ -369,7 +379,7 @@ class PoolCommand extends Command
* @since 2021-04-01
* @author fanqi
*/
private function getDealQueryResult($type, $levels, $businessStatus)
private function getDealQueryResult($type, $levels, $businessStatus, $customerType)
{
# 转换格式
$levels = json_decode($levels, true);
@ -413,6 +423,10 @@ class PoolCommand extends Command
# 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;
}
# 查询符合条件的客户
return db('crm_customer')->alias('customer')
->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();
if (!empty($customerCheck)) {
$data['flow_id'] = $customerCheck['flow_id'];
$data['owner_user_id']=$customerCheck['user_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['owner_user_id'] = $customerCheck['user_id'];
$data['customer_check_id'] = $customerCheck['customer_check_id'];
$data['apply_user_name'] = db('admin_user')->where('id', $customerCheck['create_user_id'])->column("username");
}
return resultArray(['data' => $data]);
}
@ -1175,4 +1175,20 @@ class Customer extends ApiCommon
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)
{
$where=['pool_id' => $param['pool_id'], 'is_hidden' => 0,
'field_name' => ['not in', ['deal_status','create_user_id']]];
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', 'create_user_id']]];
if ($param['is_excel'] == 1) {
$where = ['pool_id' => $param['pool_id'], 'is_hidden' => 0,
'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();
$fieldParam['types'] = 'crm_customer';
$fieldParam['action'] = 'excel';
$setting = [];
$list=[];
$list = [];
foreach ($pool_list as $k => &$v) {
switch ($v['field']) {
case 'address':
if($param['is_excel']!=1){
if ($param['is_excel'] != 1) {
$v['field'] = 'customer_address';
$v['form_type'] = 'map_address';
$list[]=$v;
$list[] = $v;
unset($pool_list[$k]);
}
break;
case 'detail_address':
if($param['is_excel']!=1){
if ($param['is_excel'] != 1) {
unset($pool_list[$k]);
}
break;
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']);
break;
default :
if($param['is_excel']!=1){
if ($param['is_excel'] != 1) {
$pool_list[$k]['setting'] = [];
}
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;
}
@ -440,7 +440,7 @@ class CustomerPool extends ApiCommon
$checkData['check_time'] = time();
$checkData['content'] = $param['content'];
$checkData['flow_id'] = $dataInfo['flow_id'];
$checkData['order_id'] = $dataInfo['order_id'] ? : 1;
$checkData['order_id'] = $dataInfo['order_id'] ?: 1;
$checkData['status'] = $status;
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);
$next_user_ids = $nextStepData['next_user_ids'] ? : [];
$customerCheckData['order_id'] = $nextStepData['order_id'] ? : '';
$next_user_ids = $nextStepData['next_user_ids'] ?: [];
$customerCheckData['order_id'] = $nextStepData['order_id'] ?: '';
if (!$next_user_ids) {
$is_end = 1;
//审批结束
@ -462,7 +462,7 @@ class CustomerPool extends ApiCommon
} else {
//自选流程
$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)) {
return resultArray(['error' => '请选择下一审批人']);
}
@ -481,7 +481,7 @@ class CustomerPool extends ApiCommon
// $examineRecordModel->setEnd(['types' => 'crm_contract','types_id' => $param['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);
if ($resCustomerCheck) {
//审批记录
@ -499,8 +499,8 @@ class CustomerPool extends ApiCommon
);
$customerData = [];
$customerData['user_id']=$dataInfo['user_id'];
$customerData['customer_id']=$dataInfo['customer_id'];
$customerData['user_id'] = $dataInfo['user_id'];
$customerData['customer_id'] = $dataInfo['customer_id'];
$result = (new CustomerPoolLogic())->receiveCustomers($customerData);
@ -536,4 +536,20 @@ class CustomerPool extends ApiCommon
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");
if ($groupNameArray)
$map['customer.crm_role'] = array('in', $groupNameArray);
$map['customer.crm_roziuw'] = array('in', $groupNameArray);
}
# 代办事项 - 待进入公海
$remindWhere = [];

@ -56,6 +56,8 @@ return [
'crm/customer/poolAuthority' => ['crm/customer/poolAuthority', ['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']],
@ -89,6 +91,8 @@ return [
'crm/customerPool/setFieldWidth' => ['crm/customerPool/setFieldWidth', ['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']],

Loading…
Cancel
Save