待办事项

pull/6/head
张萌 2 years ago
parent 8a89f22b5a
commit d02ff850de

@ -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);

@ -167,6 +167,25 @@ class MessageLogic extends Common
$data = (new InvoiceLogic())->index($request);
return $data;
}
/**
*待审核商机
*
* @author alvin guogaobo
* @version 1.0 版本号
* @since 2021/5/26 0026 13:35
*/
public function checkBusiness($param){
$type = !empty($param['type']) ? $param['type'] : 1;
$isSub = 1;
unset($param['type']);
$businessModel = model('Business');
$request = $this->whereCheck($param, $type,$isSub);
$request['isMessage'] = true;
$data = $businessModel->getDataList($request);
return $data;
}
/**
* 审批查询条件
* @param $param

@ -49,6 +49,7 @@ class Business extends Common
$businessTypeId = $request['typesId']; // 针对mobile
$businessStatusId = $request['statusId']; // 针对mobile
$overdue = $request['overdue']; // 待办事项下需联系商机(逾期)
$isMessage = !empty($request['isMessage']);
unset($request['scene_id']);
unset($request['search']);
unset($request['user_id']);
@ -60,6 +61,7 @@ class Business extends Common
unset($request['typesId']);
unset($request['statusId']);
unset($request['overdue']);
unset($request['isMessage']);
$request = $this->fmtRequest($request);
$requestMap = $request['map'] ?: [];
$sceneModel = new \app\admin\model\Scene();
@ -126,6 +128,7 @@ class Business extends Common
$auth_user_ids = array_merge(array_unique(array_filter($auth_user_ids))) ?: ['-1'];
$authMap['business.owner_user_id'] = array('in', $auth_user_ids);
} else {
if (!$isMessage) {
$authMapData = [];
$authMapData['auth_user_ids'] = $auth_user_ids;
$authMapData['user_id'] = $user_id;
@ -135,6 +138,7 @@ class Business extends Common
->whereOr('business.rw_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'));
};
}
}
//联系人商机
if ($contacts_id) {
@ -310,14 +314,14 @@ class Business extends Common
// 处理日期date类型
$dateField = $fieldModel->getFieldByFormType('crm_business', 'date');
if (!empty($dateField)) {
foreach ($param AS $key => $value) {
foreach ($param as $key => $value) {
if (in_array($key, $dateField) && empty($value)) $param[$key] = null;
}
}
// 处理手写签名类型
$handwritingField = $fieldModel->getFieldByFormType('crm_business', 'handwriting_sign');
if (!empty($handwritingField)) {
foreach ($param AS $key => $value) {
foreach ($param as $key => $value) {
if (in_array($key, $handwritingField)) {
$param[$key] = !empty($value['file_id']) ? $value['file_id'] : '';
}
@ -328,7 +332,7 @@ class Business extends Common
$locationField = $fieldModel->getFieldByFormType($this->name, 'location');
$dateIntervalField = $fieldModel->getFieldByFormType($this->name, 'date_interval');
$detailTableField = $fieldModel->getFieldByFormType($this->name, 'detail_table');
foreach ($param AS $key => $value) {
foreach ($param as $key => $value) {
// 处理地址类型字段数据
if (in_array($key, $positionField)) {
if (!empty($value)) {
@ -480,14 +484,14 @@ class Business extends Common
// 处理日期date类型
$dateField = $fieldModel->getFieldByFormType('crm_business', 'date');
if (!empty($dateField)) {
foreach ($param AS $key => $value) {
foreach ($param as $key => $value) {
if (in_array($key, $dateField) && empty($value)) $param[$key] = null;
}
}
// 处理手写签名类型
$handwritingField = $fieldModel->getFieldByFormType('crm_business', 'handwriting_sign');
if (!empty($handwritingField)) {
foreach ($param AS $key => $value) {
foreach ($param as $key => $value) {
if (in_array($key, $handwritingField)) {
$param[$key] = !empty($value['file_id']) ? $value['file_id'] : '';
}
@ -498,7 +502,7 @@ class Business extends Common
$locationField = $fieldModel->getFieldByFormType($this->name, 'location');
$dateIntervalField = $fieldModel->getFieldByFormType($this->name, 'date_interval');
$detailTableField = $fieldModel->getFieldByFormType($this->name, 'detail_table');
foreach ($param AS $key => $value) {
foreach ($param as $key => $value) {
// 处理地址类型字段数据
if (in_array($key, $positionField)) {
if (!empty($value)) {
@ -616,7 +620,7 @@ class Business extends Common
}
}
}
foreach ($fieldGrant AS $key => $val){
foreach ($fieldGrant as $key => $val) {
//掩码相关类型字段
if ($val['maskType'] != 0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
@ -665,7 +669,7 @@ class Business extends Common
if (!empty($userId)) {
$grantData = getFieldGrantData($userId);
$userLevel = isSuperAdministrators($userId);
foreach ($dataInfo AS $key => $value) {
foreach ($dataInfo as $key => $value) {
if (!$userLevel && !empty($grantData['crm_business'])) {
$status = getFieldGrantStatus($key, $grantData['crm_business']);

@ -189,6 +189,8 @@ return [
'crm/business/count' => ['crm/business/count', ['method' => 'POST']],
// 【商机】菜单数量
'crm/business/setPrimary' => ['crm/business/setPrimary', ['method' => 'POST']],
// 【商机】审批
'crm/business/check' => ['crm/business/check', ['method' => 'POST']],
// 【合同】列表
'crm/contract/index' => ['crm/contract/index', ['method' => 'POST']],
@ -406,6 +408,8 @@ return [
'crm/message/endContract' => ['crm/message/endContract', ['method' => 'POST']],
'crm/message/remindCustomer' => ['crm/message/remindCustomer', ['method' => 'POST']],
'crm/message/checkInvoice' => ['crm/message/checkInvoice', ['method' => 'POST']],
'crm/message/checkBusiness' => ['crm/message/checkBusiness', ['method' => 'POST']],
'crm/message/newBusiness' => ['crm/message/newBusiness', ['method' => 'POST']],
'crm/message/visitContract' => ['crm/message/visitContract', ['method' => 'POST']],
'crm/message/allDeal' => ['crm/message/allDeal', ['method' => 'POST']],

Loading…
Cancel
Save