|
@@ -208,25 +208,20 @@ class Message extends Api
|
|
public function getUnRead(){
|
|
public function getUnRead(){
|
|
$post=$this->request->post();
|
|
$post=$this->request->post();
|
|
$user = User::getByUserId($post['user_id']);
|
|
$user = User::getByUserId($post['user_id']);
|
|
- $count=0;
|
|
|
|
|
|
+ $count1=0;
|
|
|
|
+ $count2=0;
|
|
if($user){
|
|
if($user){
|
|
- $wheres['m.status']=2;
|
|
|
|
- $user_id=$post['user_id'];
|
|
|
|
- $list =Db::name('message')->alias('m')
|
|
|
|
- ->field('m.id,mr.message_id')
|
|
|
|
- ->join('message_read mr',"m.id =mr.message_id and mr.user_id='{$user_id}'",'left')
|
|
|
|
- ->where($wheres)
|
|
|
|
- ->where("group_id=3 or group_id={$user->group_id}")
|
|
|
|
- ->select();
|
|
|
|
-
|
|
|
|
- if($list){
|
|
|
|
- foreach ($list as $k => $v){
|
|
|
|
- if(empty($v['message_id'])){
|
|
|
|
- $count++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ $where['status']=2;
|
|
|
|
+ $count1 =Db::name('message')
|
|
|
|
+ ->where($where)
|
|
|
|
+ ->count();
|
|
|
|
+ if($count1){
|
|
|
|
+ unset($where);
|
|
|
|
+ $where['user_id']=$post['user_id'];
|
|
|
|
+ $count2 = Db('message_read')->where($where)->count();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ $count=$count1-$count2;
|
|
$data['unread']=$count;
|
|
$data['unread']=$count;
|
|
$this->success('',$data);
|
|
$this->success('',$data);
|
|
}
|
|
}
|