新商机提醒

pull/18/head
张萌 2 years ago
parent 063c1a63b5
commit 4a74644a0e

@ -279,17 +279,21 @@ class Message extends Common
*/
const CUSTOMER_CHECK_PASS = 59;
/**
* 客户待审批
* 商机推进待审批
*/
const BUSINESS_ADVANCE_CHECK_TO_DO = 60;
/**
* 客户待审批
* 商机推进待审批
*/
const BUSINESS_ADVANCE_CHECK_REJECT = 61;
/**
* 客户待审批
* 商机推进待审批
*/
const BUSINESS_ADVANCE_CHECK_PASS = 62;
/**
* 新商机
*/
const BUSINESS_NEW = 63;
/**
* 消息类型
@ -401,6 +405,9 @@ class Message extends Common
32 => [
'template' => '{from_user} 将您添加为线索 {title} 的成员。',
],
63 => [
'template' => '{from_user} 创建了新的商机',
]
];
/**
@ -454,6 +461,7 @@ class Message extends Common
self::BUSINESS_ADVANCE_CHECK_TO_DO,
self::BUSINESS_ADVANCE_CHECK_REJECT,
self::BUSINESS_ADVANCE_CHECK_PASS,
self::BUSINESS_NEW,
],
'jxc' => [
self::PURCHASE_TO_DO,
@ -627,6 +635,7 @@ class Message extends Common
case self::BUSINESS_ADVANCE_CHECK_TO_DO:
case self::BUSINESS_ADVANCE_CHECK_REJECT:
case self::BUSINESS_ADVANCE_CHECK_PASS:
case self::BUSINESS_NEW:
return BusinessModel::where(['business_id' => $data['action_id']])->value('name') ?: '';
// 采购单

@ -613,6 +613,8 @@ class Message extends ApiCommon
if ($isSub) {
$param['owner_user_id'] = array('in', getSubUserId(false));
}
$businessIdArray = db('crm_dealt_relation')->where(['types' => ['eq', 'crm_business_new'], 'user_id' => ['eq', $param['user_id']]])->column('types_id');
$param['businessIdArray'] = !empty($businessIdArray) ? $businessIdArray : -1;
$data = $businessModel->getDataList($param);
// p($contractModel->getLastSql());
if ($types == 'list') {
@ -774,7 +776,7 @@ class Message extends ApiCommon
}
# 处理待审核合同、回款、发票
if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice', 'checkBusiness'])) {
if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice', 'checkBusiness','checkCustomerCheck','new_business'])) {
$where['check_status'] = ['lt', '2'];
$where['check_user_id'] = ['like', ',%' . $userId . '%,'];
@ -795,8 +797,19 @@ class Message extends ApiCommon
}
# 商机
if ($type == 'checkBusiness') {
$invoiceId = !empty($typeId) ? $typeId : Db::name('crm_business')->where($where)->column('business_id');
db('crm_dealt_relation')->where('user_id', $userId)->where('types', 'crm_business')->whereIn('types_id', $invoiceId)->delete();
$businessId = !empty($typeId) ? $typeId : Db::name('crm_business')->where($where)->column('business_id');
db('crm_dealt_relation')->where('user_id', $userId)->where('types', 'crm_business')->whereIn('types_id', $businessId)->delete();
}
# 客户捞取
if ($type == 'checkCustomerCheck') {
$customerCheckId = !empty($typeId) ? $typeId : Db::name('crm_customer_check')->where($where)->column('customer_check_id');
db('crm_dealt_relation')->where('user_id', $userId)->where('types', 'crm_customer_check')->whereIn('types_id', $customerCheckId)->delete();
}
# 新商机
if ($type == 'new_business') {
$newBusinessId = !empty($typeId) ? $typeId : Db::name('crm_business')->where($where)->column('business_id');
db('crm_dealt_relation')->where('user_id', $userId)->where('types', 'crm_business_new')->whereIn('types_id', $newBusinessId)->delete();
}
}
@ -884,6 +897,9 @@ class Message extends ApiCommon
cache::rm('visitContractCount' . $userId);
cache::rm('endContractCount' . $userId);
cache::rm('remindCustomerCount' . $userId);
cache::rm('checkCustomerCheckCount' . $userId);
cache::rm('checkBusinessCount' . $userId);
cache::rm('newBusinessCount' . $userId);
cache::rm('todayLeadsTime' . $userId);
cache::rm('todayCustomerTime' . $userId);
@ -898,6 +914,9 @@ class Message extends ApiCommon
cache::rm('visitContractTime' . $userId);
cache::rm('endContractTime' . $userId);
cache::rm('remindCustomerTime' . $userId);
cache::rm('checkCustomerCheckTime' . $userId);
cache::rm('checkBusinessTime' . $userId);
cache::rm('newBusinessTime' . $userId);
return resultArray(['data' => '操作成功!']);
}
}

@ -6,6 +6,7 @@
// +----------------------------------------------------------------------
namespace app\crm\model;
use app\admin\model\Message;
use app\admin\traits\FieldVerificationTrait;
use think\Db;
use app\admin\model\Common;
@ -394,6 +395,30 @@ class Business extends Common
}
}
//站内信
$send_user_id = stringToArray(getUserSuperior($param['create_user_id']));
(new Message())->send(
Message::CUSTOMER_CHECK_TO_DO,
[
'title' => $param['name'],
'action_id' => $this->business_id
],
$send_user_id
);
$data = [];
$data['business_id'] = $this->business_id;
# 创建待办事项的关联数据
$dealtData = [];
foreach ($send_user_id as $kk => $vv) {
$dealtData[] = [
'types' => 'crm_business_new',
'types_id' => $data['business_id'],
'user_id' => $vv
];
}
if (!empty($dealtData)) db('crm_dealt_relation')->insertAll($dealtData);
# 设置今日需联系商机
if (!empty($param['next_time']) && $param['next_time'] >= strtotime(date('Y-m-d 00:00:00'))) $param['is_dealt'] = 0;

Loading…
Cancel
Save