增加消息推送埋点

This commit is contained in:
lccsw
2025-11-29 10:26:26 +08:00
parent 0d2f22738d
commit 7e1a283b06
11 changed files with 193 additions and 27 deletions
+71
View File
@@ -0,0 +1,71 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Notice extends CI_Controller
{
private $log_dir = 'plan_notice';
public function __construct()
{
parent::__construct();
$this->load->model('receiver/receiver_clues_model', 'clues_model');
$this->load->model('receiver/receiver_clues_notice_model', 'clues_notice_model');
$this->load->model('sys/sys_notice_model');
$this->load->model('sys/Sys_admin_model', 'sysAdmin');
}
/**
* 线索通知
* @return void
*/
public function clues()
{
$logPath = "clues.txt";
$cluseNoticeRow = $this->clues_notice_model->select([], 'clue_id desc', 1, 1);
$where = [
'app_id' => Receiver_clues_model::APP_ID_ACTIVITY
];
if ($cluseNoticeRow[0]) {
$where['id>'] = $cluseNoticeRow[0]['clue_id'];
}
$cluesRow = $this->clues_model->select($where, 'id asc', 1, 20);
if ($cluesRow) {
$noticeAdmins = $this->sysAdmin->select(['role_id' => 2, 'status' => 1], '', 0, 0, 'id');
foreach ($cluesRow as $item) {
debug_log("开始处理线: {$item['id']}", $logPath);
$mobile = substr($item['mobile'], -4);
$content = "超级车补新增了一条线索,尾号{$mobile},请及时查看处理。";
//推送消息给中台客服
if ($noticeAdmins) {
foreach ($noticeAdmins as $noticeAdmin) {
$params = [
'platform' => Sys_notice_model::PLAT_FORM_ADMIN,
'uid' => $noticeAdmin['id'],
'content' => $content,
'url' => '/receiver/clues/get?id=' . $item['id'],
];
$sendPlatform = Sys_notice_model::PLAT_FORM_SYS_H5;
$this->sys_notice_model->addNotice($params, $sendPlatform);
}
}
if ($item['pingan_user_id']) {
$params = [
'platform' => Sys_notice_model::PLAT_FORM_PINGAN,
'uid' => $item['pingan_user_id'],
'content' => $content,
'url' => '/receiver/clues/detail?id=' . $item['id'],
];
$sendPlatform = Sys_notice_model::PLAT_FORM_SYS_H5;
$this->sys_notice_model->addNotice($params, $sendPlatform);
}
$this->clues_notice_model->add([
'clue_id' => $item['id'],
'c_time' => time(),
]);
debug_log("处理完成线: {$item['id']}", $logPath);
}
} else {
echo '没有新线索';
}
}
}
+26 -6
View File
@@ -38,6 +38,7 @@ class Customers extends Wxapp
$this->load->library('receiver/clues_entity');
$this->load->model('app/paic/app_paic_users_model');
$this->load->model('biz/biz_visit_log_model');
$this->load->model('sys/sys_notice_model');
$this->biz_id = $this->get_biz_id();
}
@@ -1564,14 +1565,14 @@ class Customers extends Wxapp
$id = $this->input_param('id');
$unlock = $this->input_param('unlock');
$reason = $this->input_param('reason');
$row = $this->customers_model->get(['id' => $id, 'biz_id' => $this->biz_id]);
if (!$row) {
throw new Exception('数据不存在');
}
if ($unlock) { //不解锁
if (!$reason) {
throw new Exception('请选择不解锁理由', ERR_PARAMS_ERROR);
}
$row = $this->customers_model->get(['id' => $id, 'biz_id' => $this->biz_id]);
if (!$row) {
throw new Exception('数据不存在');
}
$updateData = [
'un_lock' => Receiver_customers_model::LOCK_STATUS_2,
'unlock_time' => date('Y-m-d H:i:s')
@@ -1587,15 +1588,34 @@ class Customers extends Wxapp
if ($row['rid']) {
$this->clues_entity->add_log($row['rid'], $this->session['uid'], $uname, $content, Receiver_clue_oplogs_model::TYPE_UNLOCK);
}
throw new Exception('保存成功', API_CODE_SUCCESS);
$msg = "保存成功";
} else {
/** @var MyResponse $result */
$result = $this->customers_model->unlock($id, $this->biz_id);
if (!$result->isSuccess()) {
throw new Exception($result->getMessage(), API_CODE_FAIL);
}
throw new Exception('解锁成功', API_CODE_SUCCESS);
$msg = "解锁成功";
}
//推送消息
$clues = $this->clues_model->get(['id' => $row['rid']]);
if ($clues['pingan_user_id']) {
$biz = $this->get_biz_info();
if ($unlock) {
$content = "您编号{$clues['sid']}的线索{$biz['biz_name']}门店不解锁(点击可跳转到对应【客户】详情)。";
} else {
$content = "您编号{$clues['sid']}的线索已被{$biz['biz_name']}门店解锁(点击可跳转到对应【客户】详情)。";
}
$params = [
'platform' => Sys_notice_model::PLAT_FORM_PINGAN,
'uid' => $clues['pingan_user_id'],
'content' => $content,
'url' => '/receiver/clues/detail?id=' . $clues['id'],
];
$endPlatform = Sys_notice_model::PLAT_FORM_SYS_WXAPP;
$this->sys_notice_model->addNotice($params, $endPlatform, $this->session['uid']);
}
throw new Exception($msg, API_CODE_SUCCESS);
}