作者 lishaoshuai
1 个管道 的构建 通过 耗费 0 秒

留言板需求变动,准备测试

... ... @@ -88,9 +88,12 @@ class LeaveController extends RestBaseController
$field = 'l.id,l.to_uid,to.avatar,c.name,content,l.create_time';
} elseif ($this->userId && $this->userType == 3) {//信贷员
$condition['l.to_uid|l.from_uid'] = $this->userId;
$field = 'l.id,l.to_uid,from.avatar,from.user_nickname name,content,from_uid,l.create_time';
$field = 'l.id,l.to_uid,from.avatar,from.user_nickname name,content,l.create_time';
//将该业务员的 留言都改为已读状态
Db::name('leave')->where(['to_uid|from_uid' => $this->userId,'parent_id' => 0])->update(['is_read' => 1]);
Db::name('leave')->where(['to_uid' => $this->userId,'parent_id' => 0])->update(['is_read' => 1]);
$condition2['parent_id'] = ['>',0];
$condition2['to_uid'] = $this->userId;
Db::name('leave')->where($condition2)->update(['is_read' => 1]);
}
$result = Db::name('leave')
->alias('l')
... ... @@ -106,8 +109,14 @@ class LeaveController extends RestBaseController
}
if (count($result) > 0) {
foreach ($result as $k => $v) {
$reply = Db::name('leave')->where(['parent_id' => $v['id']])->column('content');
$result[$k]['reply_info'] = $reply;
$reply = Db::name('leave')
->alias('l')
->join('user from','l.from_uid = from.id')
->where(['parent_id' => $v['id']])
->field('l.content,u.id from_uid')
->find();
$result[$k]['reply_info'] = isset($reply['content']) ? $reply['content'] : '';
$result[$k]['from_uid'] = isset($reply['from_uid']) ? $reply['from_uid'] : '';
$result[$k]['create_time'] = date('Y-m-d',strtotime($v['create_time']));
}
}
... ... @@ -127,20 +136,31 @@ class LeaveController extends RestBaseController
* @return is_unread:1未读 0已读
*/
public function getUnread() {
//被留言
$condition['parent_id'] = 0;
$condition['to_uid|from_uid'] = $this->userId;
$condition['is_read'] = 0;
$condition['to_uid'] = $this->userId;
$check = Db::name('leave')->where($condition)->field('is_read')->find();
if($check) {
$condition['is_read'] = 0;
$result = Db::name('leave')->where($condition)->field('is_read')->find();
if($result) {
$is_unread = 1;
} else {
$is_unread = 0;
}
$is_unread = true;
} else {
$is_unread = false;
}
//被回复
$condition2['parent_id'] = ['>',0];
$condition2['is_read'] = 0;
$condition2['to_uid'] = $this->userId;
$result = Db::name('leave')->where($condition2)->field('is_read')->find();
if($result) {
$is_unread2 = true;
} else {
$is_unread2 = false;
}
if($is_unread === true || $is_unread2 === true) {
$mark = 1;
} else {
$is_unread = 0;
$mark = 0;
}
$this->success('获取成功',1);
$this->success('获取成功',$mark);
}
}
\ No newline at end of file
... ...