diff --git a/app/chat/controller/MessageController.php b/app/chat/controller/MessageController.php index 95f4ca4..f3093d5 100644 --- a/app/chat/controller/MessageController.php +++ b/app/chat/controller/MessageController.php @@ -58,7 +58,7 @@ class MessageController extends ApiController $total = $query->count(); $messages = $query->alias('msg')->order('send_time', 'desc') ->leftJoin('chat_user user', 'msg.from_id = user.user_id') - ->field('msg.id,from_id,to_id,chat_type,msg_type,content,image_url,order_id,is_read,send_time,session_id,nick_name,user_id,avatar,type,coupon') + ->field('msg.id,from_id,to_id,chat_type,msg_type,content,image_url,order_id,is_read,send_time,session_id,nick_name,user_id,avatar,type,coupon,coupon_claim,chat_coupon_id') ->page($page, $size) ->select()->toArray(); diff --git a/extend/chat/model/Base.php b/extend/chat/model/Base.php index 25838c1..8f937f8 100644 --- a/extend/chat/model/Base.php +++ b/extend/chat/model/Base.php @@ -210,6 +210,8 @@ namespace extend\chat\model; 'from_id' => self::$user_info['uid'], 'to_id' => $message['to_id'], 'group_id' => $group_id, + 'shop_id' => !empty($message['shop_id'])?$message['shop_id']:null, + 'chat_coupon_id' => !empty($message['chat_coupon_id'])?$message['chat_coupon_id']:null, 'chat_type' => $message['chat_type'], 'msg_type' => $message['msg_type'], 'content' => !empty($message['content'])?$message['content']:null, @@ -267,6 +269,22 @@ namespace extend\chat\model; if($grep['user_id'] != self::$user_info['uid']) { $user_type = $grep['role']==1?2:1; $str_uid = self::getUid($grep['user_id'], $user_type); + + // 如果发送的是优惠券,检查这个人有没有领取过 + if($message['msg_type'] == 4 && !empty($message['coupon']) && !empty($message['chat_coupon_id'])) { + // 查询有没有领取过优惠券 + $mk_shop_coupon_record = Db::name('mk_shop_coupon_record')->where([ + 'source' => '群聊发放', + 'source_id ' => $message['chat_coupon_id'], + 'user_id' => $grep['user_id'], + 'shop_id' => $message['shop_id'], + ])->find(); + if($mk_shop_coupon_record) { + $notice_data['coupon_claim'] = 1; + }else { + $notice_data['coupon_claim'] = 0; + } + } // 群成员是否在线,在线发 不在线存起来等上线了发 免打扰也不发消息 if($grep['is_dist'] == 0) { if(Gateway::isUidOnline($str_uid)) {