|
|
|
@ -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)
|
|
|
|
|
{
|
|
|
|
@ -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)
|
|
|
|
|
{
|
|
|
|
@ -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,15 +480,15 @@ 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'],
|
|
|
|
|