diff --git a/application/api/model/BlindBoxTurntableGift.php b/application/api/model/BlindBoxTurntableGift.php index 2dbccb7..2046c3f 100644 --- a/application/api/model/BlindBoxTurntableGift.php +++ b/application/api/model/BlindBoxTurntableGift.php @@ -82,6 +82,31 @@ class BlindBoxTurntableGift extends Model $ext = json_decode($bag_data['ext'],true); $bag_gift = db::name("vs_gift")->where(['gid'=>$ext['gift_id']])->find();// 获取盲盒信息 $toarray = explode(',',$gift_user_ids); + + //巡乐会 + $is_xlh = 0; + $xlh_box = db::name('vs_gift_bag')->where('id',13)->find(); + $xlh_ext = json_decode($xlh_box['ext'],true); + $xlh = []; + if($xlh_ext['inlet_bag_id'] == $bag_gift['id']){ + $is_xlh = 1; + $xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数 + $xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数 + //本期总次数 + $total_number = db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->sum('quantity')??0; + //本期剩余次数 + $remaining_number = db::name('vs_room_pan')->where(['room_id'=>$room_id,'gift_bag_id'=>$gift_bag_id])->sum('remaining_number')??'0'; + //当前抽奖次数 + $xlh['current_num'] = $total_number - $remaining_number; + //状态 + if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){ + $xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + } elseif($xlh['current_num'] >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh['current_num'] < $xlh_ext['open_condition']['start_num']){ + $xlh['status'] = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + }else{ + $xlh['status'] = 0; + } + } //判断是否有足够的金币 $user_waller = db::name('user_wallet')->where(['user_id'=>$user_id])->find(); if ($user_waller['coin'] < $bag_gift['gift_price'] * $num) { @@ -145,6 +170,19 @@ class BlindBoxTurntableGift extends Model 'all_gift_price' => $value['gift_price'] * $value['count'], 'createtime' => time() ]); + if($is_xlh ==1){ + //推送 + $FromUserInfoNickname = db::name('user')->where(['id'=>$user_id])->value('nickname'); + $ToUserInfoNickname = db::name('user')->where(['id'=>$value['gift_user_id']])->value('nickname'); + $gift_name = db::name('vs_gift')->where(['id'=>$value['gift_id']])->value('gift_name'); + $text = $FromUserInfoNickname . ' 送给 ' . $ToUserInfoNickname.' 盲盒转盘礼物得到 ' .$gift_name.' x ' .$value['count']; + $text = [ + 'xlh_data' => $xlh, + 'text' => $text + ]; + //聊天室推送系统消息 + model('Chat')->sendMsg(1056,$room_id,$text); + } } $reslut = []; $reslut['blind_box_turntable_id'] = $box_turntable_log; @@ -593,6 +631,19 @@ class BlindBoxTurntableGift extends Model 'createtime' => time(), 'updatetime' => time() ]); + //推送 + $FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id'=>$user_id])->find(); + $room_name = db::name('vs_room')->where(['id'=>$room_id])->value('name'); + $gift_name = db::name('vs_gift')->where(['id'=>$value['gift_id']])->value('gift_name'); + $text = $FromUserInfo['nickname'] . ' 用户在 ' . $room_name.' 房间巡乐会中 ' .$gift_name.'礼物 x ' .$value['count']." 已收入背包"; + $text = [ + 'gift_num' => $pan_xlh['num']+1, + 'userInfo' => $FromUserInfo, + 'text' => $text + ]; + //聊天室推送系统消息 + model('Chat')->sendMsg(1057,$room_id,$text); + return ['code' => 1, 'msg' => '成功', 'data' => $result_data]; } diff --git a/application/api/model/Chat.php b/application/api/model/Chat.php index e895e57..a6750d6 100644 --- a/application/api/model/Chat.php +++ b/application/api/model/Chat.php @@ -106,6 +106,12 @@ class Chat extends Model //交友 退出小房间 // FriendRoomQuit = 1055, + //盲盒转盘相关推送 + //巡乐会进度推送 + // BlindBoxTurnTableProgress = 1056, + //巡乐会抽奖结果推送 + // BlindBoxTurnTableResult = 1057, +