|
|
|
@ -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 源公海ID,target_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']
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|