代码优化
This commit is contained in:
@@ -37,20 +37,19 @@ class NoticeController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
foreach ($list as $k => &$v) {
|
foreach ($list as $k => &$v) {
|
||||||
|
|
||||||
if ($v['type'] == 1) {
|
if ($v['type'] == 1) {
|
||||||
$friendId = ToDo::where(['id' => $v['bindId']])->value('friendId');
|
$friendId = ToDo::where(['id' => $v['bindId']])->value('friendId');
|
||||||
} elseif ($v['type'] == 2) {
|
} elseif ($v['type'] == 2) {
|
||||||
$friendId = FollowUp::where(['id' => $v['bindId']])->value('friendId');
|
$friendId = FollowUp::where(['id' => $v['bindId']])->value('friendId');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($friendId)) {
|
if (!empty($friendId)) {
|
||||||
$friend = Db::table('s2_wechat_friend')->where(['id' => $friendId])->field('nickname,avatar')->find();
|
$friend = Db::table('s2_wechat_friend')->where(['id' => $friendId])->field('nickname,avatar')->find();
|
||||||
} else {
|
} else {
|
||||||
$friend = ['nickname' => '', 'avatar' => ''];
|
$friend = ['nickname' => '', 'avatar' => ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
$v['friendData'] = $friend;
|
$v['friendData'] = $friend;
|
||||||
|
|
||||||
|
$v['readTime'] = !empty($v['readTime']) ? date('Y-m-d H:i:s', $v['readTime']) : '';
|
||||||
}
|
}
|
||||||
unset($v);
|
unset($v);
|
||||||
return ResponseHelper::success(['list' => $list, 'total' => $total]);
|
return ResponseHelper::success(['list' => $list, 'total' => $total]);
|
||||||
@@ -100,6 +99,7 @@ class NoticeController extends BaseController
|
|||||||
if (empty($noticeData)) {
|
if (empty($noticeData)) {
|
||||||
return ResponseHelper::error('暂未有新消息');
|
return ResponseHelper::error('暂未有新消息');
|
||||||
}
|
}
|
||||||
|
NoticeModel::where(['userId' => $userId, 'companyId' => $companyId, 'isRead' => 0])->update(['isRead' => 1, 'readTime' => time()]);
|
||||||
FollowUp::where(['userId' => $userId, 'companyId' => $companyId, 'isProcess' => 0])->update(['isProcess' => 1, 'updateTime' => time()]);
|
FollowUp::where(['userId' => $userId, 'companyId' => $companyId, 'isProcess' => 0])->update(['isProcess' => 1, 'updateTime' => time()]);
|
||||||
ToDo::where(['userId' => $userId, 'companyId' => $companyId, 'isProcess' => 0])->update(['isProcess' => 1, 'updateTime' => time()]);
|
ToDo::where(['userId' => $userId, 'companyId' => $companyId, 'isProcess' => 0])->update(['isProcess' => 1, 'updateTime' => time()]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class KfNoticeCommand extends Command
|
|||||||
$followUp = FollowUp::where($where)->alias('a')
|
$followUp = FollowUp::where($where)->alias('a')
|
||||||
->field('a.*,f.nickname,f.avatar,f.alias,f.wechatId')
|
->field('a.*,f.nickname,f.avatar,f.alias,f.wechatId')
|
||||||
->join(['s2_wechat_friend f'], 'a.friendId = f.id')
|
->join(['s2_wechat_friend f'], 'a.friendId = f.id')
|
||||||
->where('isRemind',0)
|
->where('a.isRemind',0)
|
||||||
->select();
|
->select();
|
||||||
if (!empty($followUp)) {
|
if (!empty($followUp)) {
|
||||||
foreach ($followUp as $k => $v) {
|
foreach ($followUp as $k => $v) {
|
||||||
@@ -81,7 +81,7 @@ class KfNoticeCommand extends Command
|
|||||||
$toDo = ToDo::where($where)->alias('a')
|
$toDo = ToDo::where($where)->alias('a')
|
||||||
->field('a.*,f.nickname,f.avatar,f.alias,f.wechatId')
|
->field('a.*,f.nickname,f.avatar,f.alias,f.wechatId')
|
||||||
->join(['s2_wechat_friend f'], 'a.friendId = f.id')
|
->join(['s2_wechat_friend f'], 'a.friendId = f.id')
|
||||||
->where('isRemind',0)
|
->where('a.isRemind',0)
|
||||||
->select();
|
->select();
|
||||||
if (!empty($toDo)) {
|
if (!empty($toDo)) {
|
||||||
foreach ($toDo as $k => $v) {
|
foreach ($toDo as $k => $v) {
|
||||||
|
|||||||
Reference in New Issue
Block a user