diff --git a/application/api/model/Room.php b/application/api/model/Room.php index c09e8f5..939d175 100644 --- a/application/api/model/Room.php +++ b/application/api/model/Room.php @@ -1269,11 +1269,11 @@ class Room extends Model //$from_type 来源 1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼 //$type 1金币购买 2送背包礼物 //送礼人,接收者(群),礼物id,礼物数量,来源,类型,来源id(房间id),麦位 - $res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number); + $res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,$give_gift_ext); return $res; }elseif (($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4) && $label_type['data']['label_id'] == 2)//K歌,type_id = 1,label_id = 2 { - $res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number); + $res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,$give_gift_ext); if($res['code'] == 1){ $room_pits = model('RoomSong')->get_charm_rank($room_id); if($room_pits['code'] == 1){ diff --git a/application/cron/controller/RoomPan.php b/application/cron/controller/RoomPan.php index 26ea560..aa29f12 100644 --- a/application/cron/controller/RoomPan.php +++ b/application/cron/controller/RoomPan.php @@ -26,30 +26,72 @@ class RoomPan } /* - * 盲盒转盘礼物补发 + * 盲盒转盘礼物推送补发 */ public function blind_box_turntable_gift_send(){ - $blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['is_sued'=>0,'createtime'=>['>=',time()-60*30]])->limit(50)->select(); - if(empty($blind_box_turntable_log)){ + $blind_box_turntable = db('vs_blind_box_turntable_log')->where(['is_sued'=>0,'createtime'=>['>=',time()-60*30]])->limit(1000)->select(); + if(empty($blind_box_turntable)){ echo "没有需要发放的礼物 \n"; } - echo "开始发放".count($blind_box_turntable_log)." \n"; - foreach ($blind_box_turntable_log as $key => $value) { - $blind_box_turntable = db('vs_blind_box_turntable_log')->field('user_id,room_id')->where('id',$value['tid'])->find(); - $give_gift_ext['gift_id'] = $value['gift_id']; - $give_gift_ext['count'] = $value['count']; - $give_gift_ext['gift_price'] = $value['gift_price']; - $give_gift_ext['all_gift_price'] = $value['all_gift_price']; - $give_gift_ext['is_draw_gift'] = 1; - echo "发放Id:".$value['id']." 补发用户Id:".$value['gift_user_id']." 礼物Id:".$value['gift_id']." 礼物数量:".$value['count']."\n"; -// $res = model('GiveGift')->give_gift($blind_box_turntable['user_id'], $value['gift_user_id'], $value['gift_id'], $value['count'],2,1, $blind_box_turntable['room_id'],0,0,$give_gift_ext); - $res = model('Room')->room_gift($blind_box_turntable['user_id'], $value['gift_user_id'], $value['gift_id'], $value['count'], 1, $blind_box_turntable['room_id'], 0,$value['heart_id'],$give_gift_ext); - if (isset($res) && $res['code'] != 1) { - echo "礼物发放失败".$res['msg']."\n"; + echo "开始发放".count($blind_box_turntable)." \n"; + foreach ($blind_box_turntable as $k => $v) { + $blind_box_turntable_results_log = db('vs_blind_box_turntable_results_log')->where('tid',$v['id'])->find(); + if(empty($blind_box_turntable_results_log)){ + echo $v['id']." 没有需要发放的礼物 \n"; continue; } - db('vs_blind_box_turntable_results_log')->where('id', $value['id'])->update(['is_sued' => 1, 'updatetime' => time()]); - echo "补发成功 \n"; + $room_id = $v['room_id']; + $room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name'); + $FromUserInfo = Db::name('user')->where(['id'=>$v['user_id']])->find(); + $user_nickname = $FromUserInfo['nickname']; + $textMessage = $user_nickname; + $text_message = $user_nickname; + foreach ($blind_box_turntable_results_log as $key => $value) { + $ToUserInfo = Db::name('user')->where(['id'=>$value['gift_user_id']])->find(); + $draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find(); + $textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n"; + $play_image[] = $draw_gift['play_image']; + + $text_message = $text_message . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n"; + $text_list_new[] = [ + 'text' => $text_message, + 'gift_picture' => $draw_gift['base_image'], + 'room_id' => $room_id, + 'fromUserName' => $FromUserInfo['nickname'], + 'toUserName' => $ToUserInfo['nickname'], + 'giftName' => $draw_gift['gift_name'], + 'roomId' => $room_id, + 'number' => $value['count'], + ]; + } + $text = [ + 'GiftInfo' => [ + 'play_image' => implode(',',$play_image), + ], + 'text' => $textMessage + ]; + //聊天室推送系统消息 + model('Chat')->sendMsg(1005,$room_id,$text); + $roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id'); + if($roomtype == 6){ + //推送消息 + $hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6) + ->sum('total_price'); + $text1 = [ + 'room_id' => $room_id, + 'hot_value' => $hot_value * 10, + 'text' => '房间心动值变化' + ]; + //聊天室推送系统消息 + model('Chat')->sendMsg(1028,$room_id,$text1); + }else{ + if($draw_gift['is_public_server'] == 1){ + //推送礼物横幅 + $push = new Push($v['user_id'], $room_id); + $push->giftBanner($text_list_new); + } + } + db::name('vs_blind_box_turntable_log')->where('id', $v['id'])->update(['is_sued' => 1, 'updatetime' => time()]); } }