|
|
|
@ -45,7 +45,7 @@ class Message extends ApiCommon
|
|
|
|
|
'alldeal'
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
Hook::listen('check_auth',$action);
|
|
|
|
|
Hook::listen('check_auth', $action);
|
|
|
|
|
$request = Request::instance();
|
|
|
|
|
$a = strtolower($request->action());
|
|
|
|
|
if (!in_array($a, $action['permission'])) {
|
|
|
|
@ -56,8 +56,8 @@ class Message extends ApiCommon
|
|
|
|
|
/**
|
|
|
|
|
* 系统通知
|
|
|
|
|
*
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
@ -83,144 +83,170 @@ class Message extends ApiCommon
|
|
|
|
|
$configData = $configDataModel->getData();
|
|
|
|
|
$data = [];
|
|
|
|
|
# 今日需联系线索
|
|
|
|
|
$todayLeadsTime = cache('todayLeadsTime'.$userInfo['id']);
|
|
|
|
|
$todayLeadsCount = cache('todayLeadsCount'.$userInfo['id']);
|
|
|
|
|
$todayLeadsTime = cache('todayLeadsTime' . $userInfo['id']);
|
|
|
|
|
$todayLeadsCount = cache('todayLeadsCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $todayLeadsTime) {
|
|
|
|
|
$data['todayLeads'] = (int)$todayLeadsCount;
|
|
|
|
|
} else {
|
|
|
|
|
$todayLeads = $this->todayLeads(true);
|
|
|
|
|
$data['todayLeads'] = $todayLeads['dataCount'] ? : 0;
|
|
|
|
|
cache('todayLeadsCount'.$userInfo['id'], $data['todayLeads']);
|
|
|
|
|
cache('todayLeadsTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['todayLeads'] = $todayLeads['dataCount'] ?: 0;
|
|
|
|
|
cache('todayLeadsCount' . $userInfo['id'], $data['todayLeads']);
|
|
|
|
|
cache('todayLeadsTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 今日需联系客户
|
|
|
|
|
$todayCustomerTime = cache('todayCustomerTime'.$userInfo['id']);
|
|
|
|
|
$todayCustomerCount = cache('todayCustomerCount'.$userInfo['id']);
|
|
|
|
|
$todayCustomerTime = cache('todayCustomerTime' . $userInfo['id']);
|
|
|
|
|
$todayCustomerCount = cache('todayCustomerCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $todayCustomerTime) {
|
|
|
|
|
$data['todayCustomer'] = (int)$todayCustomerCount;
|
|
|
|
|
} else {
|
|
|
|
|
$todayCustomer = $this->todayCustomer(true);
|
|
|
|
|
$data['todayCustomer'] = $todayCustomer['dataCount'] ? : 0;
|
|
|
|
|
cache('todayCustomerCount'.$userInfo['id'], $data['todayCustomer']);
|
|
|
|
|
cache('todayCustomerTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['todayCustomer'] = $todayCustomer['dataCount'] ?: 0;
|
|
|
|
|
cache('todayCustomerCount' . $userInfo['id'], $data['todayCustomer']);
|
|
|
|
|
cache('todayCustomerTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 今日需联系商机
|
|
|
|
|
$todayBusinessTime = cache('todayBusinessTime'.$userInfo['id']);
|
|
|
|
|
$todayBusinessCount = cache('todayBusinessCount'.$userInfo['id']);
|
|
|
|
|
$todayBusinessTime = cache('todayBusinessTime' . $userInfo['id']);
|
|
|
|
|
$todayBusinessCount = cache('todayBusinessCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $todayBusinessTime) {
|
|
|
|
|
$data['todayBusiness'] = (int)$todayBusinessCount;
|
|
|
|
|
} else {
|
|
|
|
|
$todayBusiness = $this->todayBusiness(true);
|
|
|
|
|
$data['todayBusiness'] = $todayBusiness['dataCount'] ? : 0;
|
|
|
|
|
cache('todayBusinessCount'.$userInfo['id'], $data['todayBusiness']);
|
|
|
|
|
cache('todayBusinessTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['todayBusiness'] = $todayBusiness['dataCount'] ?: 0;
|
|
|
|
|
cache('todayBusinessCount' . $userInfo['id'], $data['todayBusiness']);
|
|
|
|
|
cache('todayBusinessTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 分配给我的线索
|
|
|
|
|
$followLeadsTime = cache('followLeadsTime'.$userInfo['id']);
|
|
|
|
|
$followLeadsCount = cache('followLeadsCount'.$userInfo['id']);
|
|
|
|
|
$followLeadsTime = cache('followLeadsTime' . $userInfo['id']);
|
|
|
|
|
$followLeadsCount = cache('followLeadsCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $followLeadsTime) {
|
|
|
|
|
$data['followLeads'] = (int)$followLeadsCount;
|
|
|
|
|
} else {
|
|
|
|
|
$followLeads = $this->followLeads(true);
|
|
|
|
|
$data['followLeads'] = $followLeads['dataCount'] ? : 0;
|
|
|
|
|
cache('followLeadsCount'.$userInfo['id'], $data['followLeads']);
|
|
|
|
|
cache('followLeadsTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['followLeads'] = $followLeads['dataCount'] ?: 0;
|
|
|
|
|
cache('followLeadsCount' . $userInfo['id'], $data['followLeads']);
|
|
|
|
|
cache('followLeadsTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 分配给我的客户
|
|
|
|
|
$followCustomerTime = cache('followCustomerTime'.$userInfo['id']);
|
|
|
|
|
$followCustomerCount = cache('followCustomerCount'.$userInfo['id']);
|
|
|
|
|
$followCustomerTime = cache('followCustomerTime' . $userInfo['id']);
|
|
|
|
|
$followCustomerCount = cache('followCustomerCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $followCustomerTime) {
|
|
|
|
|
$data['followCustomer'] = (int)$followCustomerCount;
|
|
|
|
|
} else {
|
|
|
|
|
$followCustomer = $this->followCustomer(true);
|
|
|
|
|
$data['followCustomer'] = $followCustomer['dataCount'] ? : 0;
|
|
|
|
|
cache('followCustomerCount'.$userInfo['id'], $data['followCustomer']);
|
|
|
|
|
cache('followCustomerTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['followCustomer'] = $followCustomer['dataCount'] ?: 0;
|
|
|
|
|
cache('followCustomerCount' . $userInfo['id'], $data['followCustomer']);
|
|
|
|
|
cache('followCustomerTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 待审核合同
|
|
|
|
|
$checkContractTime = cache('checkContractTime'.$userInfo['id']);
|
|
|
|
|
$checkContractCount = cache('checkContractCount'.$userInfo['id']);
|
|
|
|
|
$checkContractTime = cache('checkContractTime' . $userInfo['id']);
|
|
|
|
|
$checkContractCount = cache('checkContractCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $checkContractTime) {
|
|
|
|
|
$data['checkContract'] = (int)$checkContractCount;
|
|
|
|
|
} else {
|
|
|
|
|
$checkContract = $this->checkContract(true);
|
|
|
|
|
$data['checkContract'] = $checkContract['dataCount'] ? : 0;
|
|
|
|
|
cache('checkContractCount'.$userInfo['id'], $data['checkContract']);
|
|
|
|
|
cache('checkContractTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['checkContract'] = $checkContract['dataCount'] ?: 0;
|
|
|
|
|
cache('checkContractCount' . $userInfo['id'], $data['checkContract']);
|
|
|
|
|
cache('checkContractTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 待审核回款
|
|
|
|
|
$checkReceivablesTime = cache('checkReceivablesTime'.$userInfo['id']);
|
|
|
|
|
$checkReceivablesCount = cache('checkReceivablesCount'.$userInfo['id']);
|
|
|
|
|
$checkReceivablesTime = cache('checkReceivablesTime' . $userInfo['id']);
|
|
|
|
|
$checkReceivablesCount = cache('checkReceivablesCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $checkReceivablesTime) {
|
|
|
|
|
$data['checkReceivables'] = (int)$checkReceivablesCount;
|
|
|
|
|
} else {
|
|
|
|
|
$checkReceivables = $this->checkReceivables(true);
|
|
|
|
|
$data['checkReceivables'] = $checkReceivables['dataCount'] ? : 0;
|
|
|
|
|
cache('checkReceivablesCount'.$userInfo['id'], $data['checkReceivables']);
|
|
|
|
|
cache('checkReceivablesTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['checkReceivables'] = $checkReceivables['dataCount'] ?: 0;
|
|
|
|
|
cache('checkReceivablesCount' . $userInfo['id'], $data['checkReceivables']);
|
|
|
|
|
cache('checkReceivablesTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 待审核发票
|
|
|
|
|
$checkInvoiceTime = cache('checkInvoiceTime'.$userInfo['id']);
|
|
|
|
|
$checkInvoiceCount = cache('checkInvoiceCount'.$userInfo['id']);
|
|
|
|
|
$checkInvoiceTime = cache('checkInvoiceTime' . $userInfo['id']);
|
|
|
|
|
$checkInvoiceCount = cache('checkInvoiceCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $checkInvoiceTime) {
|
|
|
|
|
$data['checkInvoice'] = (int)$checkInvoiceCount;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$checkInvoice = $this->checkInvoice(true);
|
|
|
|
|
$data['checkInvoice'] = $checkInvoice['dataCount'] ? : 0;
|
|
|
|
|
$data['checkInvoice'] = $checkInvoice['dataCount'] ?: 0;
|
|
|
|
|
|
|
|
|
|
cache('checkInvoiceCount'.$userInfo['id'], $data['checkInvoice']);
|
|
|
|
|
cache('checkInvoiceTime'.$userInfo['id'], time() );
|
|
|
|
|
cache('checkInvoiceCount' . $userInfo['id'], $data['checkInvoice']);
|
|
|
|
|
cache('checkInvoiceTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 待审核商机
|
|
|
|
|
$checkBusinessTime = cache('checkBusinessTime' . $userInfo['id']);
|
|
|
|
|
$checkBusinessCount = cache('checkBusinessCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $checkBusinessTime) {
|
|
|
|
|
$data['checkBusiness'] = (int)$checkBusinessCount;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$checkBusiness = $this->checkBusiness(true);
|
|
|
|
|
$data['checkBusiness'] = $checkBusiness['dataCount'] ?: 0;
|
|
|
|
|
|
|
|
|
|
cache('checkBusinessCount' . $userInfo['id'], $data['checkBusiness']);
|
|
|
|
|
cache('checkBusinessTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
# 待回款提醒
|
|
|
|
|
$remindReceivablesPlanTime = cache('remindReceivablesPlanTime'.$userInfo['id']);
|
|
|
|
|
$remindReceivablesPlanCount = cache('remindReceivablesPlanCount'.$userInfo['id']);
|
|
|
|
|
$remindReceivablesPlanTime = cache('remindReceivablesPlanTime' . $userInfo['id']);
|
|
|
|
|
$remindReceivablesPlanCount = cache('remindReceivablesPlanCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $remindReceivablesPlanTime) {
|
|
|
|
|
$data['remindReceivablesPlan'] = (int)$remindReceivablesPlanCount;
|
|
|
|
|
} else {
|
|
|
|
|
$remindReceivablesPlan = $this->remindReceivablesPlan(true);
|
|
|
|
|
$data['remindReceivablesPlan'] = $remindReceivablesPlan['dataCount'] ? : 0;
|
|
|
|
|
cache('remindReceivablesPlanCount'.$userInfo['id'], $data['remindReceivablesPlan']);
|
|
|
|
|
cache('remindReceivablesPlanTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['remindReceivablesPlan'] = $remindReceivablesPlan['dataCount'] ?: 0;
|
|
|
|
|
cache('remindReceivablesPlanCount' . $userInfo['id'], $data['remindReceivablesPlan']);
|
|
|
|
|
cache('remindReceivablesPlanTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
if ($configData['visit_config'] == 1) {
|
|
|
|
|
# 待回访合同
|
|
|
|
|
$visitContractTime = cache('visitContractTime'.$userInfo['id']);
|
|
|
|
|
$visitContractCount = cache('visitContractCount'.$userInfo['id']);
|
|
|
|
|
$visitContractTime = cache('visitContractTime' . $userInfo['id']);
|
|
|
|
|
$visitContractCount = cache('visitContractCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $visitContractTime) {
|
|
|
|
|
$data['returnVisitRemind'] = (int)$visitContractCount;
|
|
|
|
|
} else {
|
|
|
|
|
$visitContract = $this->visitContract(true);
|
|
|
|
|
$data['returnVisitRemind'] = $visitContract['dataCount'] ? : 0;
|
|
|
|
|
cache('visitContractCount'.$userInfo['id'], $data['returnVisitRemind']);
|
|
|
|
|
cache('visitContractTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['returnVisitRemind'] = $visitContract['dataCount'] ?: 0;
|
|
|
|
|
cache('visitContractCount' . $userInfo['id'], $data['returnVisitRemind']);
|
|
|
|
|
cache('visitContractTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# 即将到期合同
|
|
|
|
|
if ($configData['contract_config'] == 1) {
|
|
|
|
|
$endContractTime = cache('endContractTime'.$userInfo['id']);
|
|
|
|
|
$endContractCount = cache('endContractCount'.$userInfo['id']);
|
|
|
|
|
$endContractTime = cache('endContractTime' . $userInfo['id']);
|
|
|
|
|
$endContractCount = cache('endContractCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $endContractTime) {
|
|
|
|
|
$data['endContract'] = (int)$endContractCount;
|
|
|
|
|
} else {
|
|
|
|
|
$endContract = $this->endContract(true);
|
|
|
|
|
$data['endContract'] = $endContract['dataCount'] ? : 0;
|
|
|
|
|
cache('endContractCount'.$userInfo['id'], $data['endContract']);
|
|
|
|
|
cache('endContractTime'.$userInfo['id'], time() );
|
|
|
|
|
$data['endContract'] = $endContract['dataCount'] ?: 0;
|
|
|
|
|
cache('endContractCount' . $userInfo['id'], $data['endContract']);
|
|
|
|
|
cache('endContractTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 新增商机
|
|
|
|
|
$newBusinessTime = cache('newBusinessTime' . $userInfo['id']);
|
|
|
|
|
$newBusinessCount = cache('newBusinessCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $newBusinessTime) {
|
|
|
|
|
$data['newBusiness'] = (int)$newBusinessCount;
|
|
|
|
|
} else {
|
|
|
|
|
$newBusiness = $this->newBusiness(true);
|
|
|
|
|
$data['newBusiness'] = $newBusiness['dataCount'] ?: 0;
|
|
|
|
|
cache('newBusinessCount' . $userInfo['id'], $data['newBusiness']);
|
|
|
|
|
cache('newBusinessTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 待进入公海提醒
|
|
|
|
|
$pool = db('crm_customer_pool')->where(['status' => 1, 'remind_conf' => 1])->count();
|
|
|
|
|
if (!empty($pool)) {
|
|
|
|
|
$remindCustomerTime = cache('remindCustomerTime'.$userInfo['id']);
|
|
|
|
|
$remindCustomerCount = cache('remindCustomerCount'.$userInfo['id']);
|
|
|
|
|
$remindCustomerTime = cache('remindCustomerTime' . $userInfo['id']);
|
|
|
|
|
$remindCustomerCount = cache('remindCustomerCount' . $userInfo['id']);
|
|
|
|
|
if (time() <= $remindCustomerTime) {
|
|
|
|
|
$data['putInPoolRemind'] = (int)$remindCustomerCount;
|
|
|
|
|
} else {
|
|
|
|
|
$remindCustomer = $this->remindCustomer(true);
|
|
|
|
|
$data['putInPoolRemind'] = !empty($remindCustomer['dataCount']) ? $remindCustomer['dataCount'] : 0;
|
|
|
|
|
cache('remindCustomerCount'.$userInfo['id'], $data['putInPoolRemind']);
|
|
|
|
|
cache('remindCustomerTime'.$userInfo['id'], time() );
|
|
|
|
|
cache('remindCustomerCount' . $userInfo['id'], $data['putInPoolRemind']);
|
|
|
|
|
cache('remindCustomerTime' . $userInfo['id'], time());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -241,7 +267,7 @@ class Message extends ApiCommon
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
$param['user_id'] = $userId;
|
|
|
|
|
if ($getCount == true) $param['getCount'] = 1;
|
|
|
|
|
$messageLogic= new MessageLogic();
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
|
|
|
|
|
$data = $messageLogic->todayLeads($param);
|
|
|
|
|
|
|
|
|
@ -266,7 +292,7 @@ class Message extends ApiCommon
|
|
|
|
|
}
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
$param['user_id'] = $userId;
|
|
|
|
|
$messageLogic= new MessageLogic();
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
$data = $messageLogic->remindCustomer($param);
|
|
|
|
|
if ($types == 'list') {
|
|
|
|
|
return resultArray(['data' => $data]);
|
|
|
|
@ -290,7 +316,7 @@ class Message extends ApiCommon
|
|
|
|
|
$types = $param['types'];
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
if ($getCount == true) $param['getCount'] = 1;
|
|
|
|
|
$messageLogic= new MessageLogic();
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
$param['user_id'] = $userId;
|
|
|
|
|
$data = $messageLogic->todayBusiness($param);
|
|
|
|
|
|
|
|
|
@ -301,8 +327,8 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分配给我的线索
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function followLeads($getCount = false)
|
|
|
|
|
{
|
|
|
|
@ -312,7 +338,7 @@ class Message extends ApiCommon
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
if ($getCount == true) $param['getCount'] = 1;
|
|
|
|
|
$param['user_id'] = $userInfo['id'];
|
|
|
|
|
$messageLogic=new MessageLogic();
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
$data = $messageLogic->followLeads($param);
|
|
|
|
|
if ($types == 'list') {
|
|
|
|
|
return resultArray(['data' => $data]);
|
|
|
|
@ -322,8 +348,8 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分配给我的客户
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function followCustomer($getCount = false)
|
|
|
|
|
{
|
|
|
|
@ -334,7 +360,7 @@ class Message extends ApiCommon
|
|
|
|
|
$param['getCount'] = 1;
|
|
|
|
|
}
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
$messageLogic=new MessageLogic();
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
$param['user_id'] = $userInfo['id'];
|
|
|
|
|
$data = $messageLogic->followCustomer($param);
|
|
|
|
|
if ($types == 'list') {
|
|
|
|
@ -358,7 +384,7 @@ class Message extends ApiCommon
|
|
|
|
|
if ($getCount == true) {
|
|
|
|
|
$param['getCount'] = 1;
|
|
|
|
|
}
|
|
|
|
|
$messageLogic=new MessageLogic();
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
$param['user_id'] = $userInfo['id'];
|
|
|
|
|
$data = $messageLogic->checkContract($param);
|
|
|
|
|
if ($types == 'list') {
|
|
|
|
@ -369,8 +395,8 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 待审核回款
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function checkReceivables($getCount = false)
|
|
|
|
|
{
|
|
|
|
@ -379,7 +405,7 @@ class Message extends ApiCommon
|
|
|
|
|
$types = $param['types'];
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
if ($getCount == true) $param['getCount'] = 1;
|
|
|
|
|
$messageLogic=new MessageLogic();
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
$param['user_id'] = $userInfo['id'];
|
|
|
|
|
$data = $messageLogic->checkReceivables($param);
|
|
|
|
|
if ($types == 'list') {
|
|
|
|
@ -404,7 +430,7 @@ class Message extends ApiCommon
|
|
|
|
|
# 清除与模型无关的数据
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
$param['user_id'] = $userId;
|
|
|
|
|
$messageLogic=new MessageLogic();
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
$data = $messageLogic->checkInvoice($param);
|
|
|
|
|
|
|
|
|
|
if ($types == 'list') return resultArray(['data' => $data]);
|
|
|
|
@ -412,18 +438,41 @@ class Message extends ApiCommon
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 待审核商机
|
|
|
|
|
*
|
|
|
|
|
* @return array|\think\response\Json
|
|
|
|
|
* @throws \think\exception\DbException
|
|
|
|
|
*/
|
|
|
|
|
public function checkBusiness($getCount = false)
|
|
|
|
|
{
|
|
|
|
|
$param = $this->param;
|
|
|
|
|
$userId = $this->userInfo['id'];
|
|
|
|
|
$types = $param['types'];
|
|
|
|
|
if ($getCount == true) $param['getCount'] = 1;
|
|
|
|
|
# 清除与模型无关的数据
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
$param['user_id'] = $userId;
|
|
|
|
|
$messageLogic = new MessageLogic();
|
|
|
|
|
$data = $messageLogic->checkBusiness($param);
|
|
|
|
|
|
|
|
|
|
if ($types == 'list') return resultArray(['data' => $data]);
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 待回款提醒
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function remindReceivablesPlan($getCount = false)
|
|
|
|
|
{
|
|
|
|
|
$param = $this->param;
|
|
|
|
|
$userInfo = $this->userInfo;
|
|
|
|
|
$types = $param['types'];
|
|
|
|
|
$type = $param['type'] ? : 1;
|
|
|
|
|
$isSub = $param['isSub'] ? : '';
|
|
|
|
|
$type = $param['type'] ?: 1;
|
|
|
|
|
$isSub = $param['isSub'] ?: '';
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
unset($param['type']);
|
|
|
|
|
unset($param['isSub']);
|
|
|
|
@ -463,16 +512,16 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 即将到期合同
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function endContract($getCount = false)
|
|
|
|
|
{
|
|
|
|
|
$param = $this->param;
|
|
|
|
|
$userInfo = $this->userInfo;
|
|
|
|
|
$types = $param['types'];
|
|
|
|
|
$type = $param['type'] ? : 1;
|
|
|
|
|
$isSub = $param['isSub'] ? : '';
|
|
|
|
|
$type = $param['type'] ?: 1;
|
|
|
|
|
$isSub = $param['isSub'] ?: '';
|
|
|
|
|
if ($getCount == true) $param['getCount'] = 1;
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
unset($param['type']);
|
|
|
|
@ -480,19 +529,21 @@ class Message extends ApiCommon
|
|
|
|
|
$contractModel = model('Contract');
|
|
|
|
|
$configModel = new \app\crm\model\ConfigData();
|
|
|
|
|
$configInfo = $configModel->getData();
|
|
|
|
|
$expireDay = $configInfo['contract_day'] ? : '7';
|
|
|
|
|
$expireDay = $configInfo['contract_day'] ?: '7';
|
|
|
|
|
// 合同到期不提醒
|
|
|
|
|
if (empty($configInfo['contract_config'])) return resultArray(['data' => []]);
|
|
|
|
|
$param['owner_user_id'] = $userInfo['id'];
|
|
|
|
|
if ($isSub) {
|
|
|
|
|
$param['owner_user_id'] = array('in',getSubUserId(false));
|
|
|
|
|
$param['owner_user_id'] = array('in', getSubUserId(false));
|
|
|
|
|
}
|
|
|
|
|
switch ($type) {
|
|
|
|
|
case '1' :
|
|
|
|
|
$param['end_time'] = array('between',array(date('Y-m-d',time()),date('Y-m-d',time()+86400*$expireDay)));
|
|
|
|
|
$param['end_time'] = array('between', array(date('Y-m-d', time()), date('Y-m-d', time() + 86400 * $expireDay)));
|
|
|
|
|
$param['expire_remind'] = 0;
|
|
|
|
|
break;
|
|
|
|
|
case '2' : $param['end_time'] = array('lt',date('Y-m-d',time())); break;
|
|
|
|
|
case '2' :
|
|
|
|
|
$param['end_time'] = array('lt', date('Y-m-d', time()));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$data = $contractModel->getDataList($param);
|
|
|
|
|
// p($contractModel->getLastSql());
|
|
|
|
@ -503,9 +554,38 @@ class Message extends ApiCommon
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 待进入客户池
|
|
|
|
|
* 新增商机
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function newBusiness($getCount = false)
|
|
|
|
|
{
|
|
|
|
|
$param = $this->param;
|
|
|
|
|
$userInfo = $this->userInfo;
|
|
|
|
|
$types = $param['types'];
|
|
|
|
|
$type = $param['type'] ?: 1;
|
|
|
|
|
$isSub = $param['isSub'] ?: '';
|
|
|
|
|
if ($getCount == true) $param['getCount'] = 1;
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
unset($param['type']);
|
|
|
|
|
unset($param['isSub']);
|
|
|
|
|
$businessModel = model('Business');
|
|
|
|
|
$param['owner_user_id'] = $userInfo['id'];
|
|
|
|
|
if ($isSub) {
|
|
|
|
|
$param['owner_user_id'] = array('in', getSubUserId(false));
|
|
|
|
|
}
|
|
|
|
|
$data = $businessModel->getDataList($param);
|
|
|
|
|
// p($contractModel->getLastSql());
|
|
|
|
|
if ($types == 'list') {
|
|
|
|
|
return resultArray(['data' => $data]);
|
|
|
|
|
}
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 待进入客户池
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function remindCustomer($getCount = false)
|
|
|
|
|
{
|
|
|
|
@ -514,7 +594,7 @@ class Message extends ApiCommon
|
|
|
|
|
$param = $this->param;
|
|
|
|
|
$userInfo = $this->userInfo;
|
|
|
|
|
$types = $param['types'];
|
|
|
|
|
$isSub = $param['isSub'] ? : '';
|
|
|
|
|
$isSub = $param['isSub'] ?: '';
|
|
|
|
|
if ($getCount == true) $param['getCount'] = 1;
|
|
|
|
|
unset($param['types']);
|
|
|
|
|
unset($param['type']);
|
|
|
|
@ -529,13 +609,13 @@ class Message extends ApiCommon
|
|
|
|
|
$data = [];
|
|
|
|
|
$remind = db('crm_customer_pool')->where(['status' => 1, 'remind_conf' => 1])->count();
|
|
|
|
|
if (!empty($remind)) {
|
|
|
|
|
$whereData = $param ? : [];
|
|
|
|
|
$whereData = $param ?: [];
|
|
|
|
|
$whereData['is_remind'] = 1;
|
|
|
|
|
$whereData['user_id'] = $userInfo['id'];
|
|
|
|
|
$whereData['pool_remain'] = 0;
|
|
|
|
|
$whereData['scene_id'] = db('admin_scene')->where(['types' => 'crm_customer','bydata' => 'me'])->value('scene_id');
|
|
|
|
|
$whereData['scene_id'] = db('admin_scene')->where(['types' => 'crm_customer', 'bydata' => 'me'])->value('scene_id');
|
|
|
|
|
if ($isSub) {
|
|
|
|
|
$whereData['scene_id'] = db('admin_scene')->where(['types' => 'crm_customer','bydata' => 'sub'])->value('scene_id');
|
|
|
|
|
$whereData['scene_id'] = db('admin_scene')->where(['types' => 'crm_customer', 'bydata' => 'sub'])->value('scene_id');
|
|
|
|
|
}
|
|
|
|
|
$data = $customerModel->getDataList($whereData);
|
|
|
|
|
}
|
|
|
|
@ -639,7 +719,7 @@ class Message extends ApiCommon
|
|
|
|
|
# 处理分配给我的线索、客户
|
|
|
|
|
if (in_array($type, ['followLeads', 'followCustomer'])) {
|
|
|
|
|
$where['owner_user_id'] = $userId;
|
|
|
|
|
$where['follow'] = [['neq','已跟进'], null, 'or'];
|
|
|
|
|
$where['follow'] = [['neq', '已跟进'], null, 'or'];
|
|
|
|
|
$where['is_allocation'] = 1;
|
|
|
|
|
|
|
|
|
|
# 线索
|
|
|
|
@ -656,8 +736,8 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
# 处理待审核合同、回款、发票
|
|
|
|
|
if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice'])) {
|
|
|
|
|
$where['check_status'] = ['lt','2'];
|
|
|
|
|
$where['check_user_id'] = ['like',',%' . $userId . '%,'];
|
|
|
|
|
$where['check_status'] = ['lt', '2'];
|
|
|
|
|
$where['check_user_id'] = ['like', ',%' . $userId . '%,'];
|
|
|
|
|
|
|
|
|
|
# 合同
|
|
|
|
|
if ($type == 'checkContract') {
|
|
|
|
@ -681,10 +761,10 @@ class Message extends ApiCommon
|
|
|
|
|
if ($type == 'endContract') {
|
|
|
|
|
$configModel = new \app\crm\model\ConfigData();
|
|
|
|
|
$configInfo = $configModel->getData();
|
|
|
|
|
$expireDay = $configInfo['contract_day'] ? : '7';
|
|
|
|
|
$expireDay = $configInfo['contract_day'] ?: '7';
|
|
|
|
|
|
|
|
|
|
$where['owner_user_id'] = $userId;
|
|
|
|
|
$where['end_time'] = ['between', [date('Y-m-d',time()), date('Y-m-d',time()+86400*$expireDay)]];
|
|
|
|
|
$where['end_time'] = ['between', [date('Y-m-d', time()), date('Y-m-d', time() + 86400 * $expireDay)]];
|
|
|
|
|
$where['expire_remind'] = 1;
|
|
|
|
|
|
|
|
|
|
$contractId = !empty($typeId) ? $typeId : Db::name('crm_contract')->where($where)->column('contract_id');
|
|
|
|
@ -713,11 +793,11 @@ class Message extends ApiCommon
|
|
|
|
|
$whereData['is_remind'] = 1;
|
|
|
|
|
$whereData['user_id'] = $userId;
|
|
|
|
|
$whereData['pool_remain'] = 0;
|
|
|
|
|
$whereData['scene_id'] = db('admin_scene')->where(['types' => 'crm_customer','bydata' => empty($isSub) ? 'me' : 'sub'])->value('scene_id');
|
|
|
|
|
$whereData['scene_id'] = db('admin_scene')->where(['types' => 'crm_customer', 'bydata' => empty($isSub) ? 'me' : 'sub'])->value('scene_id');
|
|
|
|
|
$whereData['owner_user_id'] = !empty($isSub) ? ['in', getSubUserId(false, 0, $userId)] : $userId;
|
|
|
|
|
$poolCustomers = (new \app\crm\model\Customer())->getDataList($whereData);
|
|
|
|
|
$ids = [];
|
|
|
|
|
foreach ($poolCustomers['list'] AS $key => $value) {
|
|
|
|
|
foreach ($poolCustomers['list'] as $key => $value) {
|
|
|
|
|
if (!empty($value['customer_id'])) $ids[] = $value['customer_id'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($ids)) Db::name('crm_customer')->whereIn('customer_id', $ids)->update(['pool_remain' => 1]);
|
|
|
|
@ -731,48 +811,49 @@ class Message extends ApiCommon
|
|
|
|
|
if (!empty($typeId)) {
|
|
|
|
|
$planId = $typeId;
|
|
|
|
|
} else {
|
|
|
|
|
$param['owner_user_id'] = $isSub ? ['in',getSubUserId(false)] : $userId;
|
|
|
|
|
$param['owner_user_id'] = $isSub ? ['in', getSubUserId(false)] : $userId;
|
|
|
|
|
$param['receivables_id'] = 0;
|
|
|
|
|
$param['check_status'] = ['lt', 2];
|
|
|
|
|
$param['remind_date'] = ['elt', date('Y-m-d',time())];
|
|
|
|
|
$param['return_date'] = ['egt', date('Y-m-d',time())];
|
|
|
|
|
$param['remind_date'] = ['elt', date('Y-m-d', time())];
|
|
|
|
|
$param['return_date'] = ['egt', date('Y-m-d', time())];
|
|
|
|
|
$param['types'] = 1;
|
|
|
|
|
$param['page'] = 1;
|
|
|
|
|
$param['limit'] = 1000;
|
|
|
|
|
$receivablesPlanModel = model('ReceivablesPlan');
|
|
|
|
|
$data = $receivablesPlanModel->getDataList($param);
|
|
|
|
|
foreach ($data['list'] AS $key => $value) {
|
|
|
|
|
foreach ($data['list'] as $key => $value) {
|
|
|
|
|
$planId[] = $value['plan_id'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!empty($planId)) db('crm_receivables_plan')->whereIn('plan_id', $planId)->update(['is_dealt' => 1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cache::rm('todayLeadsCount'.$userId);
|
|
|
|
|
cache::rm('todayCustomerCount'.$userId);
|
|
|
|
|
cache::rm('todayBusinessCount'.$userId);
|
|
|
|
|
cache::rm('followLeadsCount'.$userId);
|
|
|
|
|
cache::rm('followCustomerCount'.$userId);
|
|
|
|
|
cache::rm('checkContractCount'.$userId);
|
|
|
|
|
cache::rm('checkReceivablesCount'.$userId);
|
|
|
|
|
cache::rm('checkInvoiceCount'.$userId);
|
|
|
|
|
cache::rm('remindReceivablesPlanCount'.$userId);
|
|
|
|
|
cache::rm('visitContractCount'.$userId);
|
|
|
|
|
cache::rm('endContractCount'.$userId);
|
|
|
|
|
cache::rm('remindCustomerCount'.$userId);
|
|
|
|
|
|
|
|
|
|
cache::rm('todayLeadsTime'.$userId);
|
|
|
|
|
cache::rm('todayCustomerTime'.$userId);
|
|
|
|
|
cache::rm('todayBusinessTime'.$userId);
|
|
|
|
|
cache::rm('followLeadsTime'.$userId);
|
|
|
|
|
cache::rm('followCustomerTime'.$userId);
|
|
|
|
|
cache::rm('checkContractTime'.$userId);
|
|
|
|
|
cache::rm('checkReceivablesTime'.$userId);
|
|
|
|
|
cache::rm('checkInvoiceTime'.$userId);
|
|
|
|
|
cache::rm('remindReceivablesPlanTime'.$userId);
|
|
|
|
|
cache::rm('visitContractTime'.$userId);
|
|
|
|
|
cache::rm('endContractTime'.$userId);
|
|
|
|
|
cache::rm('remindCustomerTime'.$userId);
|
|
|
|
|
cache::rm('todayLeadsCount' . $userId);
|
|
|
|
|
cache::rm('todayCustomerCount' . $userId);
|
|
|
|
|
cache::rm('todayBusinessCount' . $userId);
|
|
|
|
|
cache::rm('followLeadsCount' . $userId);
|
|
|
|
|
cache::rm('followCustomerCount' . $userId);
|
|
|
|
|
cache::rm('checkContractCount' . $userId);
|
|
|
|
|
cache::rm('checkReceivablesCount' . $userId);
|
|
|
|
|
cache::rm('checkInvoiceCount' . $userId);
|
|
|
|
|
cache::rm('remindReceivablesPlanCount' . $userId);
|
|
|
|
|
cache::rm('visitContractCount' . $userId);
|
|
|
|
|
cache::rm('endContractCount' . $userId);
|
|
|
|
|
cache::rm('remindCustomerCount' . $userId);
|
|
|
|
|
|
|
|
|
|
cache::rm('todayLeadsTime' . $userId);
|
|
|
|
|
cache::rm('todayCustomerTime' . $userId);
|
|
|
|
|
cache::rm('todayBusinessTime' . $userId);
|
|
|
|
|
cache::rm('followLeadsTime' . $userId);
|
|
|
|
|
cache::rm('followCustomerTime' . $userId);
|
|
|
|
|
cache::rm('checkContractTime' . $userId);
|
|
|
|
|
cache::rm('checkReceivablesTime' . $userId);
|
|
|
|
|
cache::rm('checkInvoiceTime' . $userId);
|
|
|
|
|
cache::rm('checkBusinessTime' . $userId);
|
|
|
|
|
cache::rm('remindReceivablesPlanTime' . $userId);
|
|
|
|
|
cache::rm('visitContractTime' . $userId);
|
|
|
|
|
cache::rm('endContractTime' . $userId);
|
|
|
|
|
cache::rm('remindCustomerTime' . $userId);
|
|
|
|
|
return resultArray(['data' => '操作成功!']);
|
|
|
|
|
}
|
|
|
|
|
}
|