消息提醒功能优化
This commit is contained in:
@@ -143,8 +143,8 @@ Route::group('v1/', function () {
|
||||
//自动问候
|
||||
Route::group('notice/', function () {
|
||||
Route::get('list', 'app\chukebao\controller\NoticeController@getList');
|
||||
Route::get('readMessage', 'app\chukebao\controller\NoticeController@readMessage');
|
||||
Route::get('readAll', 'app\chukebao\controller\NoticeController@readAll');
|
||||
Route::put('readMessage', 'app\chukebao\controller\NoticeController@readMessage');
|
||||
Route::put('readAll', 'app\chukebao\controller\NoticeController@readAll');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -444,6 +444,16 @@ class ContentController extends BaseController
|
||||
|
||||
|
||||
foreach ($list as $k => &$v){
|
||||
$v['metailGroups'] = json_decode($v['metailGroups'],true);
|
||||
$v['content'] = json_decode($v['content'],true);
|
||||
$v['keywords'] = json_decode($v['keywords'],true);
|
||||
|
||||
$metailData = Material::where(['isDel' => 0,'userId' => $userId,'companyId' => $companyId])
|
||||
->whereIn('id',$v['metailGroups'])
|
||||
->select()->toArray();
|
||||
$v['metailGroupsOptions'] = $metailData;
|
||||
|
||||
|
||||
$user = Db::name('users')->where(['id' => $v['userId']])->field('username,account')->find();
|
||||
if (!empty($user)){
|
||||
$v['userName'] = !empty($user['username']) ? $user['username'] : $user['account'];
|
||||
@@ -467,13 +477,13 @@ class ContentController extends BaseController
|
||||
$keywords = $this->request->param('keywords', '');
|
||||
$replyType = $this->request->param('replyType', 0);
|
||||
$content = $this->request->param('content','');
|
||||
$materialId = $this->request->param('materialId','');
|
||||
$metailGroups = $this->request->param('metailGroups',[]);
|
||||
$status = $this->request->param('status', 0);
|
||||
$level = $this->request->param('level', 50);
|
||||
$userId = $this->getUserInfo('id');
|
||||
$companyId = $this->getUserInfo('companyId');
|
||||
|
||||
if (empty($title) || empty($keywords) || (empty($materialId) && empty($content))){
|
||||
if (empty($title) || empty($keywords) || (empty(metailGroups) && empty($content))){
|
||||
return ResponseHelper::error('参数缺失');
|
||||
}
|
||||
|
||||
@@ -487,7 +497,7 @@ class ContentController extends BaseController
|
||||
$query->keywords = !empty($keywords) ? json_encode($keywords,256) : json_encode([]);
|
||||
$query->replyType = $replyType;
|
||||
$query->content = !empty($content) ? json_encode($content,256) : json_encode([]);;
|
||||
$query->materialId = $materialId;
|
||||
$query->metailGroups = !empty($metailGroups) ? json_encode($metailGroups,256) : json_encode([]);;
|
||||
$query->status = $status;
|
||||
$query->level = $level;
|
||||
$query->userId = $userId;
|
||||
@@ -521,6 +531,13 @@ class ContentController extends BaseController
|
||||
if (empty($data)){
|
||||
return ResponseHelper::error('该素材已被删除或者不存在');
|
||||
}
|
||||
|
||||
$data['metailGroups'] = json_decode($data['metailGroups'],true);
|
||||
$metailData = Material::where(['isDel' => 0,'userId' => $userId,'companyId' => $companyId])
|
||||
->whereIn('id',$data['metailGroups'])
|
||||
->select()->toArray();
|
||||
$data['metailGroupsOptions'] = $metailData;
|
||||
|
||||
$data['content'] = json_decode($data['content'],true);
|
||||
$data['keywords'] = json_decode($data['keywords'],true);
|
||||
$data['keywords'] = implode(',',$data['keywords']);
|
||||
@@ -570,13 +587,13 @@ class ContentController extends BaseController
|
||||
$keywords = $this->request->param('keywords', '');
|
||||
$replyType = $this->request->param('replyType', 0);
|
||||
$content = $this->request->param('content','');
|
||||
$materialId = $this->request->param('materialId','');
|
||||
$metailGroups = $this->request->param('metailGroups','');
|
||||
$status = $this->request->param('status', 0);
|
||||
$level = $this->request->param('level', 50);
|
||||
$userId = $this->getUserInfo('id');
|
||||
$companyId = $this->getUserInfo('companyId');
|
||||
|
||||
if (empty($title) || empty($keywords) || (empty($materialId) && empty($content))){
|
||||
if (empty($title) || empty($keywords) || (empty($metailGroups) && empty($content))){
|
||||
return ResponseHelper::error('参数缺失');
|
||||
}
|
||||
|
||||
@@ -593,7 +610,7 @@ class ContentController extends BaseController
|
||||
$query->keywords = !empty($keywords) ? json_encode($keywords,256) : json_encode([]);
|
||||
$query->replyType = $replyType;
|
||||
$query->content = !empty($content) ? json_encode($content,256) : json_encode([]);;
|
||||
$query->materialId = $materialId;
|
||||
$query->metailGroups = !empty($metailGroups) ? json_encode($metailGroups,256) : json_encode([]);;;
|
||||
$query->status = $status;
|
||||
$query->level = $level;
|
||||
$query->save();
|
||||
|
||||
@@ -27,6 +27,9 @@ class NoticeController extends BaseController
|
||||
if (empty($accountId)) {
|
||||
return ResponseHelper::error('请先登录');
|
||||
}
|
||||
|
||||
$noRead = NoticeModel::where(['userId' => $userId, 'companyId' => $companyId,'isRead' => 0])->count();
|
||||
|
||||
$query = NoticeModel::where(['userId' => $userId, 'companyId' => $companyId])
|
||||
->order('id desc');
|
||||
if (!empty($keyword)) {
|
||||
@@ -52,7 +55,7 @@ class NoticeController extends BaseController
|
||||
$v['readTime'] = !empty($v['readTime']) ? date('Y-m-d H:i:s', $v['readTime']) : '';
|
||||
}
|
||||
unset($v);
|
||||
return ResponseHelper::success(['list' => $list, 'total' => $total]);
|
||||
return ResponseHelper::success(['list' => $list, 'total' => $total,'noRead' => $noRead]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user