diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php
index e0bd2e63..0fb4e0a4 100644
--- a/admin/controllers/receiver/Clues.php
+++ b/admin/controllers/receiver/Clues.php
@@ -30,6 +30,8 @@ class Clues extends HD_Controller
$this->load->model('receiver/receiver_enroll_model');
$this->load->model('biz/biz_car_brand_model');
+ $this->load->model('sys/sys_notice_model');
+ $this->load->model('sys/Sys_admin_model', 'sysAdmin');
$this->log_dir = 'receiver_clues';
}
@@ -563,6 +565,20 @@ class Clues extends HD_Controller
}
return $this->show_json($code, $msg);
}
+ //推送消息给中台客服
+// $noticeAdmins = $this->sysAdmin->select(['role_id' => 2, 'status' => 1], '', 0, 0, 'id');
+// if ($noticeAdmins) {
+// foreach ($noticeAdmins as $noticeAdmin) {
+// $params = [
+// 'platform' => Sys_notice_model::PLAT_FORM_ADMIN,
+// 'uid' => $noticeAdmin['id'],
+// 'content' => "超级车补新增了一条线索,请及时处理.",
+// 'url' => '/receiver/clues/get?id=' . $ret,
+// ];
+// $endPlatform = Sys_notice_model::PLAT_FORM_SYS_ADMIN;
+// $this->sys_notice_model->addNotice($params, $endPlatform, $this->uid);
+// }
+// }
return $this->show_json(SYS_CODE_SUCCESS, '新增成功');
} else {
debug_log("[error]# add fail; " . $this->clues_model->db->last_query(), __FUNCTION__, $this->log_dir);
@@ -602,6 +618,19 @@ class Clues extends HD_Controller
);
$id = $this->mdOplogs->add($addData);
if ($id) {
+ if ($params['notice']) { //推送消息
+ $clues = $this->clues_model->get(['id' => $params['id']]);
+ if ($clues['pingan_user_id'] && $clues['app_id'] == Receiver_clues_model::APP_ID_ACTIVITY) {
+ $params = [
+ 'platform' => Sys_notice_model::PLAT_FORM_PINGAN,
+ 'uid' => $clues['pingan_user_id'],
+ 'content' => $params['log'],
+ 'url' => '/receiver/clues/detail?id=' . $clues['id'],
+ ];
+ $endPlatform = Sys_notice_model::PLAT_FORM_SYS_ADMIN;
+ $this->sys_notice_model->addNotice($params, $endPlatform, $this->uid);
+ }
+ }
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '添加失败');
diff --git a/admin/views/receiver/clues/edit.php b/admin/views/receiver/clues/edit.php
index 794b9394..5b8a0012 100644
--- a/admin/views/receiver/clues/edit.php
+++ b/admin/views/receiver/clues/edit.php
@@ -415,6 +415,12 @@
-->
+
diff --git a/agent/admin/controllers/pingan/receiver/Clues.php b/agent/admin/controllers/pingan/receiver/Clues.php
index 639c1ff7..d7d962b6 100644
--- a/agent/admin/controllers/pingan/receiver/Clues.php
+++ b/agent/admin/controllers/pingan/receiver/Clues.php
@@ -21,6 +21,7 @@ class Clues extends BaseController
$this->load->model('receiver/receiver_call_wechat_model');
$this->load->model('receiver/receiver_enroll_model');
$this->load->model('receiver/receiver_customers_model', 'customers_model');
+ $this->load->model('sys/sys_notice_model');
$this->clues_model->set_db('ssdb');
$this->clues_cfrom_model->set_db('ssdb');
$this->auto_brand_model->set_db('ssdb');
@@ -31,6 +32,7 @@ class Clues extends BaseController
$this->receiver_call_wechat_model->set_db('ssdb');
$this->receiver_enroll_model->set_db('ssdb');
$this->customers_model->set_db('ssdb');
+ $this->sys_notice_model->set_db('ssdb');
$this->load->library('api/callPhone');
}
@@ -116,7 +118,8 @@ class Clues extends BaseController
public function addLog_post()
{
$params = $this->input_param();
- if (!$params['id']) {
+ $clues = $this->clues_model->get(['id' => $params['id']]);
+ if (!$clues) {
$this->return_json('参数错误!');
}
if (!$params['content']) {
@@ -144,6 +147,17 @@ class Clues extends BaseController
);
$id = $this->mdOplogs->add($addData);
if ($id) {
+ //消息推送给管理后台
+ if ($clues['admin_id']) {
+ $params = [
+ 'platform' => Sys_notice_model::PLAT_FORM_ADMIN,
+ 'uid' => $clues['pingan_user_id'],
+ 'content' => $params['log'],
+ 'url' => '/receiver/clues/get?id=' . $clues['id'],
+ ];
+ $endPlatform = Sys_notice_model::PLAT_FORM_SYS_PINGAN;
+ $this->sys_notice_model->addNotice($params, $endPlatform, $_SESSION['id']);
+ }
$this->return_response();
} else {
$this->return_json('添加失败!');
diff --git a/agent/admin/controllers/pingan/user/Notice.php b/agent/admin/controllers/pingan/user/Notice.php
index 744936f3..7f0d0f51 100644
--- a/agent/admin/controllers/pingan/user/Notice.php
+++ b/agent/admin/controllers/pingan/user/Notice.php
@@ -73,11 +73,12 @@ class Notice extends BaseController
{
$ids = $this->input_param('ids');
$type = $this->input_param('type');
+ $isRead = $this->input_param('isRead');
+ $isRead = $isRead ? Sys_notice_model::STATUS_READ : Sys_notice_model::STATUS_UNREAD;
$where = [
'platform' => Sys_notice_model::PLAT_FORM_PINGAN,
'uid' => $_SESSION['id'],
- 'read' => Sys_notice_model::STATUS_UNREAD
];
if ($type != 'all') {
if (!$ids) {
@@ -89,7 +90,7 @@ class Notice extends BaseController
}
}
- $this->sys_notice_model->update(['read' => Sys_notice_model::STATUS_READ], $where);
+ $this->sys_notice_model->update(['read' => $isRead], $where);
$this->return_response();
}
}
\ No newline at end of file
diff --git a/api/controllers/plan/Notice.php b/api/controllers/plan/Notice.php
new file mode 100644
index 00000000..d40c35f7
--- /dev/null
+++ b/api/controllers/plan/Notice.php
@@ -0,0 +1,71 @@
+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 '没有新线索';
+ }
+ }
+}
\ No newline at end of file
diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php
index e26f0e40..ebc2e679 100644
--- a/api/controllers/wxapp/licheb/Customers.php
+++ b/api/controllers/wxapp/licheb/Customers.php
@@ -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);
}
diff --git a/common/libraries/websocket/ValidToken.php b/common/libraries/websocket/ValidToken.php
index 1d9e5eaf..1031b683 100644
--- a/common/libraries/websocket/ValidToken.php
+++ b/common/libraries/websocket/ValidToken.php
@@ -45,6 +45,7 @@ class ValidToken
case Ws_conn_model::PLAT_FORM_SYS_ADMIN:
case Ws_conn_model::PLAT_FORM_SYS_PINGAN:
case Ws_conn_model::PLAT_FORM_SYS_WXAPP:
+ case Ws_conn_model::PLAT_FORM_SYS_H5:
$uid = JWT::decode($token, $this->jwt_key_system, array($this->jwt_algorithm));
if (!$uid) {
throw new Exception('授权失败', WsResponse::CODE_UNAUTHORIZED);
diff --git a/common/models/receiver/Receiver_clues_notice_model.php b/common/models/receiver/Receiver_clues_notice_model.php
new file mode 100644
index 00000000..15ee36b8
--- /dev/null
+++ b/common/models/receiver/Receiver_clues_notice_model.php
@@ -0,0 +1,13 @@
+table_name, 'default');
+ }
+
+}
diff --git a/common/models/sys/Sys_notice_model.php b/common/models/sys/Sys_notice_model.php
index 809a1254..c76013db 100644
--- a/common/models/sys/Sys_notice_model.php
+++ b/common/models/sys/Sys_notice_model.php
@@ -4,9 +4,14 @@ defined('BASEPATH') or exit('No direct script access allowed');
class Sys_notice_model extends HD_Model
{
private $table_name = 'lc_sys_notice';
- const PLAT_FORM_ADMIN = 1; //前端-管理后台
- const PLAT_FORM_PINGAN = 2; //前端-平安
- const PLAT_FORM_WXAPP = 3; //前端-微信小程序
+ const PLAT_FORM_ADMIN = 1; //接收平台-管理后台
+ const PLAT_FORM_PINGAN = 2; //接收平台-平安
+ const PLAT_FORM_WXAPP = 3; //接收平台-微信小程序
+
+ const PLAT_FORM_SYS_ADMIN = 4;//推送平台-管理后台
+ const PLAT_FORM_SYS_PINGAN = 5;//推送平台-平安
+ const PLAT_FORM_SYS_WXAPP = 6;//推送平台-微信小程序
+ const PLAT_FORM_SYS_H5 = 7;//推送平台-h5报名
const TYPE_SYS = 0; //系统通知
const ICON_DEFAULT = 'el-icon-s-comment';//默认图标
@@ -24,6 +29,8 @@ class Sys_notice_model extends HD_Model
self::PLAT_FORM_PINGAN => '平安',
self::PLAT_FORM_WXAPP => '微信小程序',
];
+ // 系统账号
+ const SEND_UID_SYS = 8888888;
public function __construct()
{
@@ -32,12 +39,13 @@ class Sys_notice_model extends HD_Model
/**
* 添加系统通知
- * @param $sendUid 推送消息账号
- * @param $sendPlatform 发消息平台
- * @param $params 其它参数
+ * @param Array $params platform,uid,content,type,url
+ * @param $sendPlatform
+ * @param $sendUid
+ * @param $showWssErr
* @return MyResponse
*/
- public function addNotice($params, $sendPlatform, $sendUid = 8888888, $showWssErr = false)
+ public function addNotice($params, $sendPlatform, $sendUid = self::SEND_UID_SYS, $showWssErr = false)
{
$logPath = 'websocket';
$logFile = 'sendError.txt';
@@ -51,7 +59,9 @@ class Sys_notice_model extends HD_Model
'content' => $params['content'],
'type' => $params['type'] ?: 0,
'url' => $params['url'] ?: '',
- 'c_time' => time()
+ 'c_time' => time(),
+ 'send_platform' => $sendPlatform,
+ 'send_uid' => $sendUid
];
$addData['icon'] = self::ICON_TYPE[$params['type']] ?: self::ICON_DEFAULT;
$req = $this->add($addData);
diff --git a/common/models/ws/Ws_conn_model.php b/common/models/ws/Ws_conn_model.php
index 70c970d2..70ca9b69 100644
--- a/common/models/ws/Ws_conn_model.php
+++ b/common/models/ws/Ws_conn_model.php
@@ -6,13 +6,14 @@ class Ws_conn_model extends HD_Model
private $table_name = 'lc_ws_conn';
//平台类型
- const PLAT_FORM_ADMIN = 1; //前端-管理后台
- const PLAT_FORM_PINGAN = 2; //前端-平安
- const PLAT_FORM_WXAPP = 3; //前端-微信小程序
+ const PLAT_FORM_ADMIN = 1; //接收平台-管理后台
+ const PLAT_FORM_PINGAN = 2; //接收平台-平安
+ const PLAT_FORM_WXAPP = 3; //接收平台-微信小程序
- const PLAT_FORM_SYS_ADMIN = 4;//后端-管理后台
- const PLAT_FORM_SYS_PINGAN = 5;//后端-平安
- const PLAT_FORM_SYS_WXAPP = 6;//后端-微信小程序
+ const PLAT_FORM_SYS_ADMIN = 4;//推送平台-管理后台
+ const PLAT_FORM_SYS_PINGAN = 5;//推送平台-平安
+ const PLAT_FORM_SYS_WXAPP = 6;//推送平台-微信小程序
+ const PLAT_FORM_SYS_H5 = 7;//推送平台-微信小程序
//接收消息平台
const REC_PLAT_FORM = [
self::PLAT_FORM_WXAPP => '小程序',