|
|
|
@ -56,8 +56,8 @@ class Message extends ApiCommon
|
|
|
|
|
/**
|
|
|
|
|
* 系统通知
|
|
|
|
|
*
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
@ -172,6 +172,19 @@ class Message extends ApiCommon
|
|
|
|
|
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']);
|
|
|
|
@ -209,6 +222,19 @@ class Message extends ApiCommon
|
|
|
|
|
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)) {
|
|
|
|
@ -301,8 +327,8 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分配给我的线索
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function followLeads($getCount = false)
|
|
|
|
|
{
|
|
|
|
@ -322,8 +348,8 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分配给我的客户
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function followCustomer($getCount = false)
|
|
|
|
|
{
|
|
|
|
@ -369,8 +395,8 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 待审核回款
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function checkReceivables($getCount = false)
|
|
|
|
|
{
|
|
|
|
@ -412,10 +438,33 @@ 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)
|
|
|
|
|
{
|
|
|
|
@ -463,8 +512,8 @@ class Message extends ApiCommon
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 即将到期合同
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
* @return
|
|
|
|
|
* @author Michael_xu
|
|
|
|
|
*/
|
|
|
|
|
public function endContract($getCount = false)
|
|
|
|
|
{
|
|
|
|
@ -492,7 +541,9 @@ class Message extends ApiCommon
|
|
|
|
|
$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)
|
|
|
|
|
{
|
|
|
|
@ -717,7 +797,7 @@ class Message extends ApiCommon
|
|
|
|
|
$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]);
|
|
|
|
@ -741,7 +821,7 @@ class Message extends ApiCommon
|
|
|
|
|
$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'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -769,6 +849,7 @@ class Message extends ApiCommon
|
|
|
|
|
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);
|
|
|
|
|