|
|
@ -39,11 +39,11 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* [getDataList 客户list]
|
|
|
|
* [getDataList 客户list]
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param [string] $map [查询条件]
|
|
|
|
* @param [string] $map [查询条件]
|
|
|
|
* @param [number] $page [当前页数]
|
|
|
|
* @param [number] $page [当前页数]
|
|
|
|
* @param [number] $limit [每页数量]
|
|
|
|
* @param [number] $limit [每页数量]
|
|
|
|
* @return [array] [description]
|
|
|
|
* @return [array] [description]
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getDataList($request)
|
|
|
|
public function getDataList($request)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -155,9 +155,15 @@ class Customer extends Common
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 过滤角色
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$groupIds = db('admin_access')->where("user_id", array("eq", $user_id))->column("group_id");
|
|
|
|
|
|
|
|
if (!in_array(1,$groupIds)){
|
|
|
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
}
|
|
|
|
# 代办事项 - 待进入公海
|
|
|
|
# 代办事项 - 待进入公海
|
|
|
|
$remindWhere = [];
|
|
|
|
$remindWhere = [];
|
|
|
|
if ($is_remind) {
|
|
|
|
if ($is_remind) {
|
|
|
@ -250,7 +256,7 @@ class Customer extends Common
|
|
|
|
# 处理数据
|
|
|
|
# 处理数据
|
|
|
|
$list = getFieldData($list, 'crm_customer', $user_id);
|
|
|
|
$list = getFieldData($list, 'crm_customer', $user_id);
|
|
|
|
# 整理数据
|
|
|
|
# 整理数据
|
|
|
|
foreach ($list AS $k => $v) {
|
|
|
|
foreach ($list as $k => $v) {
|
|
|
|
|
|
|
|
|
|
|
|
$list[$k]['create_user_id_info'] = isset($v['create_user_id']) ? $userModel->getUserById($v['create_user_id']) : [];
|
|
|
|
$list[$k]['create_user_id_info'] = isset($v['create_user_id']) ? $userModel->getUserById($v['create_user_id']) : [];
|
|
|
|
$list[$k]['owner_user_id_info'] = isset($v['owner_user_id']) ? $userModel->getUserById($v['owner_user_id']) : [];
|
|
|
|
$list[$k]['owner_user_id_info'] = isset($v['owner_user_id']) ? $userModel->getUserById($v['owner_user_id']) : [];
|
|
|
@ -301,9 +307,9 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 创建客户主表信息
|
|
|
|
* 创建客户主表信息
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function createData($param)
|
|
|
|
public function createData($param)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -363,7 +369,7 @@ class Customer extends Common
|
|
|
|
// 处理日期(date)类型
|
|
|
|
// 处理日期(date)类型
|
|
|
|
$dateField = $fieldModel->getFieldByFormType('crm_customer', 'date');
|
|
|
|
$dateField = $fieldModel->getFieldByFormType('crm_customer', 'date');
|
|
|
|
if (!empty($dateField)) {
|
|
|
|
if (!empty($dateField)) {
|
|
|
|
foreach ($param AS $key => $value) {
|
|
|
|
foreach ($param as $key => $value) {
|
|
|
|
if (in_array($key, $dateField) && empty($value)) $param[$key] = null;
|
|
|
|
if (in_array($key, $dateField) && empty($value)) $param[$key] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -371,7 +377,7 @@ class Customer extends Common
|
|
|
|
// 处理手写签名类型
|
|
|
|
// 处理手写签名类型
|
|
|
|
$handwritingField = $fieldModel->getFieldByFormType('crm_customer', 'handwriting_sign');
|
|
|
|
$handwritingField = $fieldModel->getFieldByFormType('crm_customer', 'handwriting_sign');
|
|
|
|
if (!empty($handwritingField)) {
|
|
|
|
if (!empty($handwritingField)) {
|
|
|
|
foreach ($param AS $key => $value) {
|
|
|
|
foreach ($param as $key => $value) {
|
|
|
|
if (in_array($key, $handwritingField)) {
|
|
|
|
if (in_array($key, $handwritingField)) {
|
|
|
|
$param[$key] = !empty($value['file_id']) ? $value['file_id'] : '';
|
|
|
|
$param[$key] = !empty($value['file_id']) ? $value['file_id'] : '';
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -384,7 +390,7 @@ class Customer extends Common
|
|
|
|
$dateIntervalField = $fieldModel->getFieldByFormType('crm_customer', 'date_interval');
|
|
|
|
$dateIntervalField = $fieldModel->getFieldByFormType('crm_customer', 'date_interval');
|
|
|
|
$detailTableField = $fieldModel->getFieldByFormType('crm_customer', 'detail_table');
|
|
|
|
$detailTableField = $fieldModel->getFieldByFormType('crm_customer', 'detail_table');
|
|
|
|
$dateField = $fieldModel->getFieldByFormType('crm_customer', 'date');
|
|
|
|
$dateField = $fieldModel->getFieldByFormType('crm_customer', 'date');
|
|
|
|
foreach ($param AS $key => $value) {
|
|
|
|
foreach ($param as $key => $value) {
|
|
|
|
// 处理地址类型字段数据
|
|
|
|
// 处理地址类型字段数据
|
|
|
|
if (in_array($key, $positionField)) {
|
|
|
|
if (in_array($key, $positionField)) {
|
|
|
|
if (!empty($value) && is_array($value)) {
|
|
|
|
if (!empty($value) && is_array($value)) {
|
|
|
@ -517,9 +523,9 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 编辑客户主表信息
|
|
|
|
* 编辑客户主表信息
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function updateDataById($param, $customer_id = '')
|
|
|
|
public function updateDataById($param, $customer_id = '')
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -582,7 +588,7 @@ class Customer extends Common
|
|
|
|
// 处理日期(date)类型
|
|
|
|
// 处理日期(date)类型
|
|
|
|
$dateField = $fieldModel->getFieldByFormType('crm_customer', 'date');
|
|
|
|
$dateField = $fieldModel->getFieldByFormType('crm_customer', 'date');
|
|
|
|
if (!empty($dateField)) {
|
|
|
|
if (!empty($dateField)) {
|
|
|
|
foreach ($param AS $key => $value) {
|
|
|
|
foreach ($param as $key => $value) {
|
|
|
|
if (in_array($key, $dateField) && empty($value)) $param[$key] = null;
|
|
|
|
if (in_array($key, $dateField) && empty($value)) $param[$key] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -590,7 +596,7 @@ class Customer extends Common
|
|
|
|
// 处理手写签名类型
|
|
|
|
// 处理手写签名类型
|
|
|
|
$handwritingField = $fieldModel->getFieldByFormType('crm_customer', 'handwriting_sign');
|
|
|
|
$handwritingField = $fieldModel->getFieldByFormType('crm_customer', 'handwriting_sign');
|
|
|
|
if (!empty($handwritingField)) {
|
|
|
|
if (!empty($handwritingField)) {
|
|
|
|
foreach ($param AS $key => $value) {
|
|
|
|
foreach ($param as $key => $value) {
|
|
|
|
if (in_array($key, $handwritingField)) {
|
|
|
|
if (in_array($key, $handwritingField)) {
|
|
|
|
$param[$key] = !empty($value['file_id']) ? $value['file_id'] : '';
|
|
|
|
$param[$key] = !empty($value['file_id']) ? $value['file_id'] : '';
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -602,7 +608,7 @@ class Customer extends Common
|
|
|
|
$locationField = $fieldModel->getFieldByFormType('crm_customer', 'location');
|
|
|
|
$locationField = $fieldModel->getFieldByFormType('crm_customer', 'location');
|
|
|
|
$dateIntervalField = $fieldModel->getFieldByFormType('crm_customer', 'date_interval');
|
|
|
|
$dateIntervalField = $fieldModel->getFieldByFormType('crm_customer', 'date_interval');
|
|
|
|
$detailTableField = $fieldModel->getFieldByFormType('crm_customer', 'detail_table');
|
|
|
|
$detailTableField = $fieldModel->getFieldByFormType('crm_customer', 'detail_table');
|
|
|
|
foreach ($param AS $key => $value) {
|
|
|
|
foreach ($param as $key => $value) {
|
|
|
|
// 处理地址类型字段数据
|
|
|
|
// 处理地址类型字段数据
|
|
|
|
if (in_array($key, $positionField)) {
|
|
|
|
if (in_array($key, $positionField)) {
|
|
|
|
if (!empty($value)) {
|
|
|
|
if (!empty($value)) {
|
|
|
@ -714,7 +720,7 @@ class Customer extends Common
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($fieldGrant AS $key => $val){
|
|
|
|
foreach ($fieldGrant as $key => $val) {
|
|
|
|
//掩码相关类型字段
|
|
|
|
//掩码相关类型字段
|
|
|
|
if ($val['maskType'] != 0 && $val['form_type'] == 'mobile') {
|
|
|
|
if ($val['maskType'] != 0 && $val['form_type'] == 'mobile') {
|
|
|
|
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
|
|
|
|
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
|
|
|
@ -762,7 +768,7 @@ class Customer extends Common
|
|
|
|
if (!empty($userId)) {
|
|
|
|
if (!empty($userId)) {
|
|
|
|
$grantData = getFieldGrantData($userId);
|
|
|
|
$grantData = getFieldGrantData($userId);
|
|
|
|
$userLevel = isSuperAdministrators($userId);
|
|
|
|
$userLevel = isSuperAdministrators($userId);
|
|
|
|
foreach ($dataInfo AS $key => $value) {
|
|
|
|
foreach ($dataInfo as $key => $value) {
|
|
|
|
if (!$userLevel && !empty($grantData['crm_customer'])) {
|
|
|
|
if (!$userLevel && !empty($grantData['crm_customer'])) {
|
|
|
|
$status = getFieldGrantStatus($key, $grantData['crm_customer']);
|
|
|
|
$status = getFieldGrantStatus($key, $grantData['crm_customer']);
|
|
|
|
|
|
|
|
|
|
|
@ -782,9 +788,9 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* [客户统计]
|
|
|
|
* [客户统计]
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getStatistics($request)
|
|
|
|
public function getStatistics($request)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -900,9 +906,9 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* [客户数量]
|
|
|
|
* [客户数量]
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getDataCount($map)
|
|
|
|
public function getDataCount($map)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -914,9 +920,9 @@ class Customer extends Common
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 客户默认条件
|
|
|
|
* 客户默认条件
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author fanqi
|
|
|
|
|
|
|
|
* @since 2021-05-12
|
|
|
|
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
|
|
|
|
* @since 2021-05-12
|
|
|
|
|
|
|
|
* @author fanqi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getWhereByCustomer()
|
|
|
|
public function getWhereByCustomer()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -926,9 +932,9 @@ class Customer extends Common
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 客户公海条件
|
|
|
|
* 客户公海条件
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author fanqi
|
|
|
|
|
|
|
|
* @since 2021-05-12
|
|
|
|
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
|
|
|
|
* @since 2021-05-12
|
|
|
|
|
|
|
|
* @author fanqi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getWhereByPool()
|
|
|
|
public function getWhereByPool()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -937,9 +943,9 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 客户权限判断(是否客户公海)
|
|
|
|
* 客户权限判断(是否客户公海)
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param type 1 是公海返回false,默认是公海返回true
|
|
|
|
* @param type 1 是公海返回false,默认是公海返回true
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function checkData($customer_id, $type = '')
|
|
|
|
public function checkData($customer_id, $type = '')
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -966,9 +972,9 @@ class Customer extends Common
|
|
|
|
* 客户到期天数
|
|
|
|
* 客户到期天数
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param array $customerIds 客户ID
|
|
|
|
* @param array $customerIds 客户ID
|
|
|
|
* @author fanqi
|
|
|
|
|
|
|
|
* @since 2021-04-19
|
|
|
|
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
|
|
|
|
* @since 2021-04-19
|
|
|
|
|
|
|
|
* @author fanqi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getPoolDay($customerIds = [], $userIds = [])
|
|
|
|
public function getPoolDay($customerIds = [], $userIds = [])
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -979,7 +985,7 @@ class Customer extends Common
|
|
|
|
$poolRules = db('crm_customer_pool_rule')->alias('rule')->field(['rule.*', 'pool.remain_day'])->join('__CRM_CUSTOMER_POOL__ pool', 'rule.pool_id = pool.pool_id', 'LEFT')->where($where)->select();
|
|
|
|
$poolRules = db('crm_customer_pool_rule')->alias('rule')->field(['rule.*', 'pool.remain_day'])->join('__CRM_CUSTOMER_POOL__ pool', 'rule.pool_id = pool.pool_id', 'LEFT')->where($where)->select();
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($poolRules)) {
|
|
|
|
if (!empty($poolRules)) {
|
|
|
|
foreach ($poolRules AS $key => $value) {
|
|
|
|
foreach ($poolRules as $key => $value) {
|
|
|
|
if ($value['type'] == 1) $result[] = $this->getFollowUpQueryResult($value['level_conf'], $value['level'], $value['deal_handle'], $value['business_handle'], $value['remain_day'], $customerIds, $userIds);
|
|
|
|
if ($value['type'] == 1) $result[] = $this->getFollowUpQueryResult($value['level_conf'], $value['level'], $value['deal_handle'], $value['business_handle'], $value['remain_day'], $customerIds, $userIds);
|
|
|
|
if ($value['type'] == 2) $result[] = $this->getBusinessQueryResult($value['level_conf'], $value['level'], $value['deal_handle'], $value['remain_day'], $customerIds, $userIds);
|
|
|
|
if ($value['type'] == 2) $result[] = $this->getBusinessQueryResult($value['level_conf'], $value['level'], $value['deal_handle'], $value['remain_day'], $customerIds, $userIds);
|
|
|
|
if ($value['type'] == 3) $result[] = $this->getDealQueryResult($value['level_conf'], $value['level'], $value['business_handle'], $value['remain_day'], $customerIds, $userIds);
|
|
|
|
if ($value['type'] == 3) $result[] = $this->getDealQueryResult($value['level_conf'], $value['level'], $value['business_handle'], $value['remain_day'], $customerIds, $userIds);
|
|
|
@ -993,9 +999,9 @@ class Customer extends Common
|
|
|
|
* 获取每个客户最快进入公海天数
|
|
|
|
* 获取每个客户最快进入公海天数
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param $data
|
|
|
|
* @param $data
|
|
|
|
* @author fanqi
|
|
|
|
|
|
|
|
* @since 2021-04-19
|
|
|
|
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
|
|
|
|
* @since 2021-04-19
|
|
|
|
|
|
|
|
* @author fanqi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getMinIntoPoolDay($data)
|
|
|
|
private function getMinIntoPoolDay($data)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1003,16 +1009,16 @@ class Customer extends Common
|
|
|
|
$temporary = [];
|
|
|
|
$temporary = [];
|
|
|
|
|
|
|
|
|
|
|
|
# 整理数据
|
|
|
|
# 整理数据
|
|
|
|
foreach ($data AS $k1 => $v1) {
|
|
|
|
foreach ($data as $k1 => $v1) {
|
|
|
|
if (empty($v1)) continue;
|
|
|
|
if (empty($v1)) continue;
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($v1 AS $k2 => $v2) {
|
|
|
|
foreach ($v1 as $k2 => $v2) {
|
|
|
|
$temporary[$k2][] = $v2;
|
|
|
|
$temporary[$k2][] = $v2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# 每个客户最快进入公海天数
|
|
|
|
# 每个客户最快进入公海天数
|
|
|
|
foreach ($temporary AS $k1 => $v1) {
|
|
|
|
foreach ($temporary as $k1 => $v1) {
|
|
|
|
$result[$k1] = min($v1);
|
|
|
|
$result[$k1] = min($v1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1023,15 +1029,15 @@ class Customer extends Common
|
|
|
|
* 获取公海规则最小数字(最快进入公海天数)
|
|
|
|
* 获取公海规则最小数字(最快进入公海天数)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param $data
|
|
|
|
* @param $data
|
|
|
|
* @author fanqi
|
|
|
|
|
|
|
|
* @since 2021-04-19
|
|
|
|
|
|
|
|
* @return int
|
|
|
|
* @return int
|
|
|
|
|
|
|
|
* @since 2021-04-19
|
|
|
|
|
|
|
|
* @author fanqi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getMinDay($data)
|
|
|
|
private function getMinDay($data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$number = 1;
|
|
|
|
$number = 1;
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($data AS $k1 => $v1) {
|
|
|
|
foreach ($data as $k1 => $v1) {
|
|
|
|
if (empty($number) || $v1['limit_day'] < $number) $number = $v1['limit_day'];
|
|
|
|
if (empty($number) || $v1['limit_day'] < $number) $number = $v1['limit_day'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1048,9 +1054,9 @@ class Customer extends Common
|
|
|
|
* @param int $remainDay 提前几天提醒
|
|
|
|
* @param int $remainDay 提前几天提醒
|
|
|
|
* @param array $customerIds 客户ID
|
|
|
|
* @param array $customerIds 客户ID
|
|
|
|
* @param array $userIds 员工ID
|
|
|
|
* @param array $userIds 员工ID
|
|
|
|
|
|
|
|
* @return array
|
|
|
|
* @author fanqi
|
|
|
|
* @author fanqi
|
|
|
|
* @since 2021-04-01
|
|
|
|
* @since 2021-04-01
|
|
|
|
* @return array
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus, $remainDay, $customerIds = [], $userIds = [])
|
|
|
|
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus, $remainDay, $customerIds = [], $userIds = [])
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1072,7 +1078,7 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
# 所有用户,不区分级别
|
|
|
|
# 所有用户,不区分级别
|
|
|
|
if ($type == 1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
foreach ($levels AS $k1 => $v1) {
|
|
|
|
foreach ($levels as $k1 => $v1) {
|
|
|
|
if (!empty($v1['limit_day'])) {
|
|
|
|
if (!empty($v1['limit_day'])) {
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$where .= " AND ((`customer`.`last_time` > " . $time . " AND `customer`.`last_time` > `customer`.`obtain_time`) OR (`customer`.`obtain_time` > " . $time . " AND `customer`.`obtain_time` > `customer`.`last_time`) OR (`customer`.`obtain_time` > " . $time . " AND ISNULL(`customer`.`last_time`)))";
|
|
|
|
$where .= " AND ((`customer`.`last_time` > " . $time . " AND `customer`.`last_time` > `customer`.`obtain_time`) OR (`customer`.`obtain_time` > " . $time . " AND `customer`.`obtain_time` > `customer`.`last_time`) OR (`customer`.`obtain_time` > " . $time . " AND ISNULL(`customer`.`last_time`)))";
|
|
|
@ -1084,7 +1090,7 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
# 根据用户级别设置条件
|
|
|
|
# 根据用户级别设置条件
|
|
|
|
if ($type == 2) {
|
|
|
|
if ($type == 2) {
|
|
|
|
foreach ($levels AS $k1 => $v1) {
|
|
|
|
foreach ($levels as $k1 => $v1) {
|
|
|
|
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
|
|
|
|
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
if ($k1 == 0) {
|
|
|
|
if ($k1 == 0) {
|
|
|
@ -1126,7 +1132,7 @@ class Customer extends Common
|
|
|
|
->where($where)->select();
|
|
|
|
->where($where)->select();
|
|
|
|
|
|
|
|
|
|
|
|
# 计算到期天数
|
|
|
|
# 计算到期天数
|
|
|
|
foreach ($data AS $k1 => $v1) {
|
|
|
|
foreach ($data as $k1 => $v1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
$customerTime = !empty($v1['last_time']) && $v1['last_time'] > $v1['obtain_time'] ? $v1['last_time'] : $v1['obtain_time'];
|
|
|
|
$customerTime = !empty($v1['last_time']) && $v1['last_time'] > $v1['obtain_time'] ? $v1['last_time'] : $v1['obtain_time'];
|
|
|
|
$date = date('Y-m-d 00:00:00', ($customerTime + $limitDay['all'] * 86400) - $remainDay * 86400);
|
|
|
|
$date = date('Y-m-d 00:00:00', ($customerTime + $limitDay['all'] * 86400) - $remainDay * 86400);
|
|
|
@ -1160,9 +1166,9 @@ class Customer extends Common
|
|
|
|
* @param int $remainDay 提前几天提醒
|
|
|
|
* @param int $remainDay 提前几天提醒
|
|
|
|
* @param array $customerIds 客户ID
|
|
|
|
* @param array $customerIds 客户ID
|
|
|
|
* @param array $userIds 员工ID
|
|
|
|
* @param array $userIds 员工ID
|
|
|
|
* @author fanqi
|
|
|
|
|
|
|
|
* @since 2021-04-01
|
|
|
|
|
|
|
|
* @return array|false|string
|
|
|
|
* @return array|false|string
|
|
|
|
|
|
|
|
* @since 2021-04-01
|
|
|
|
|
|
|
|
* @author fanqi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getBusinessQueryResult($type, $levels, $dealStatus, $remainDay, $customerIds = [], $userIds = [])
|
|
|
|
private function getBusinessQueryResult($type, $levels, $dealStatus, $remainDay, $customerIds = [], $userIds = [])
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1184,7 +1190,7 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
# 所有用户,不区分级别
|
|
|
|
# 所有用户,不区分级别
|
|
|
|
if ($type == 1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
foreach ($levels AS $k1 => $v1) {
|
|
|
|
foreach ($levels as $k1 => $v1) {
|
|
|
|
if (!empty($v1['limit_day'])) {
|
|
|
|
if (!empty($v1['limit_day'])) {
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$where .= " AND ( (ISNULL(`business`.`customer_id`) AND `customer`.`obtain_time` > " . $time . ") OR (`customer`.`obtain_time` > " . $time . " AND `customer`.`obtain_time` > `business`.`create_time`) OR (`business`.`create_time` > " . $time . " AND `business`.`create_time` > `customer`.`obtain_time`) )";
|
|
|
|
$where .= " AND ( (ISNULL(`business`.`customer_id`) AND `customer`.`obtain_time` > " . $time . ") OR (`customer`.`obtain_time` > " . $time . " AND `customer`.`obtain_time` > `business`.`create_time`) OR (`business`.`create_time` > " . $time . " AND `business`.`create_time` > `customer`.`obtain_time`) )";
|
|
|
@ -1196,7 +1202,7 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
# 根据用户级别设置条件
|
|
|
|
# 根据用户级别设置条件
|
|
|
|
if ($type == 2) {
|
|
|
|
if ($type == 2) {
|
|
|
|
foreach ($levels AS $k1 => $v1) {
|
|
|
|
foreach ($levels as $k1 => $v1) {
|
|
|
|
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
|
|
|
|
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
if ($k1 == 0) {
|
|
|
|
if ($k1 == 0) {
|
|
|
@ -1235,7 +1241,7 @@ class Customer extends Common
|
|
|
|
->where($where)->select();
|
|
|
|
->where($where)->select();
|
|
|
|
|
|
|
|
|
|
|
|
# 计算到期天数
|
|
|
|
# 计算到期天数
|
|
|
|
foreach ($data AS $k1 => $v1) {
|
|
|
|
foreach ($data as $k1 => $v1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
$customerTime = !empty($v1['business_time']) && $v1['business_time'] > $v1['customer_time'] ? $v1['business_time'] : $v1['customer_time'];
|
|
|
|
$customerTime = !empty($v1['business_time']) && $v1['business_time'] > $v1['customer_time'] ? $v1['business_time'] : $v1['customer_time'];
|
|
|
|
$date = date('Y-m-d 00:00:00', ($customerTime + $limitDay['all'] * 86400) - $remainDay * 86400);
|
|
|
|
$date = date('Y-m-d 00:00:00', ($customerTime + $limitDay['all'] * 86400) - $remainDay * 86400);
|
|
|
@ -1269,9 +1275,9 @@ class Customer extends Common
|
|
|
|
* @param int $remainDay 提前几天提醒
|
|
|
|
* @param int $remainDay 提前几天提醒
|
|
|
|
* @param array $customerIds 客户ID
|
|
|
|
* @param array $customerIds 客户ID
|
|
|
|
* @param array $userIds 员工ID
|
|
|
|
* @param array $userIds 员工ID
|
|
|
|
* @author fanqi
|
|
|
|
|
|
|
|
* @since 2021-04-01
|
|
|
|
|
|
|
|
* @return array|false|string
|
|
|
|
* @return array|false|string
|
|
|
|
|
|
|
|
* @since 2021-04-01
|
|
|
|
|
|
|
|
* @author fanqi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getDealQueryResult($type, $levels, $businessStatus, $remainDay, $customerIds = [], $userIds = [])
|
|
|
|
private function getDealQueryResult($type, $levels, $businessStatus, $remainDay, $customerIds = [], $userIds = [])
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1293,7 +1299,7 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
# 所有用户,不区分级别
|
|
|
|
# 所有用户,不区分级别
|
|
|
|
if ($type == 1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
foreach ($levels AS $k1 => $v1) {
|
|
|
|
foreach ($levels as $k1 => $v1) {
|
|
|
|
if (!empty($v1['limit_day'])) {
|
|
|
|
if (!empty($v1['limit_day'])) {
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$where .= " AND ( (ISNULL(`contract`.`customer_id`) AND `customer`.`obtain_time` > " . $time . ") OR (`customer`.`obtain_time` > " . $time . " AND `customer`.`obtain_time` > `contract`.`create_time`) OR (`contract`.`create_time` > " . $time . " AND `contract`.`create_time` > `customer`.`obtain_time`) )";
|
|
|
|
$where .= " AND ( (ISNULL(`contract`.`customer_id`) AND `customer`.`obtain_time` > " . $time . ") OR (`customer`.`obtain_time` > " . $time . " AND `customer`.`obtain_time` > `contract`.`create_time`) OR (`contract`.`create_time` > " . $time . " AND `contract`.`create_time` > `customer`.`obtain_time`) )";
|
|
|
@ -1305,7 +1311,7 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
# 根据用户级别设置条件
|
|
|
|
# 根据用户级别设置条件
|
|
|
|
if ($type == 2) {
|
|
|
|
if ($type == 2) {
|
|
|
|
foreach ($levels AS $k1 => $v1) {
|
|
|
|
foreach ($levels as $k1 => $v1) {
|
|
|
|
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
|
|
|
|
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
$time = strtotime(date('Y-m-d 00:00:00', time() - 86400 * $v1['limit_day']));
|
|
|
|
if ($k1 == 0) {
|
|
|
|
if ($k1 == 0) {
|
|
|
@ -1345,7 +1351,7 @@ class Customer extends Common
|
|
|
|
->where($where)->select();
|
|
|
|
->where($where)->select();
|
|
|
|
|
|
|
|
|
|
|
|
# 计算到期天数
|
|
|
|
# 计算到期天数
|
|
|
|
foreach ($data AS $k1 => $v1) {
|
|
|
|
foreach ($data as $k1 => $v1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
if ($type == 1) {
|
|
|
|
$customerTime = !empty($v1['contract_time']) && $v1['contract_time'] > $v1['customer_time'] ? $v1['contract_time'] : $v1['customer_time'];
|
|
|
|
$customerTime = !empty($v1['contract_time']) && $v1['contract_time'] > $v1['customer_time'] ? $v1['contract_time'] : $v1['customer_time'];
|
|
|
|
$date = date('Y-m-d 00:00:00', ($customerTime + $limitDay['all'] * 86400) - $remainDay * 86400);
|
|
|
|
$date = date('Y-m-d 00:00:00', ($customerTime + $limitDay['all'] * 86400) - $remainDay * 86400);
|
|
|
@ -1372,9 +1378,9 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* [今日进入客户池条件]
|
|
|
|
* [今日进入客户池条件]
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getWhereByToday()
|
|
|
|
public function getWhereByToday()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1438,9 +1444,9 @@ class Customer extends Common
|
|
|
|
* @param int $userId 用户ID
|
|
|
|
* @param int $userId 用户ID
|
|
|
|
* @param int $isDeal 成交客户是否占用拥有客户数条件:1 占用 0 不占用
|
|
|
|
* @param int $isDeal 成交客户是否占用拥有客户数条件:1 占用 0 不占用
|
|
|
|
* @param int $types 类型:1 拥有客户数,2 锁定客户数
|
|
|
|
* @param int $types 类型:1 拥有客户数,2 锁定客户数
|
|
|
|
* @author fanqi
|
|
|
|
|
|
|
|
* @since 2021-04-15
|
|
|
|
|
|
|
|
* @return int
|
|
|
|
* @return int
|
|
|
|
|
|
|
|
* @since 2021-04-15
|
|
|
|
|
|
|
|
* @author fanqi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getCountByHave($userId, $isDeal = 0, $types = 1)
|
|
|
|
public function getCountByHave($userId, $isDeal = 0, $types = 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1539,9 +1545,9 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* [客户成交新增数量]
|
|
|
|
* [客户成交新增数量]
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getAddDealSql($map)
|
|
|
|
public function getAddDealSql($map)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1577,9 +1583,9 @@ class Customer extends Common
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* [客户统计sql]
|
|
|
|
* [客户统计sql]
|
|
|
|
* @author Michael_xu
|
|
|
|
|
|
|
|
* @param
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @author Michael_xu
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getAddressCountBySql($map)
|
|
|
|
public function getAddressCountBySql($map)
|
|
|
|
{
|
|
|
|
{
|
|
|
|