diff --git a/application/api/model/BlindBoxTurntableGift.php b/application/api/model/BlindBoxTurntableGift.php index 4b28e43..f349112 100644 --- a/application/api/model/BlindBoxTurntableGift.php +++ b/application/api/model/BlindBoxTurntableGift.php @@ -382,6 +382,19 @@ class BlindBoxTurntableGift extends Model db::rollback(); return ['code' => 0, 'msg' => '添加盲盒转盘结果记录失败', 'data' => null]; } + + //给接收礼物的人送礼物 + $give_gift_ext['gift_id'] = $user_gift['gift_id']; + $give_gift_ext['count'] = $user_gift['count']; + $give_gift_ext['gift_price'] = $user_gift['gift_price']; + $give_gift_ext['all_gift_price'] = $user_gift['gift_price'] * $user_gift['count']; + $give_gift_ext['is_draw_gift'] = 1; + $res = model('Room')->room_gift($user_id, $user_gift['gift_user_id'], $user_gift['gift_id'], $user_gift['count'], 1, $room_id, 0,$heart_id,$give_gift_ext); + if (isset($res) && $res['code'] != 1) { + db::rollback(); + return ['code' => 0, 'msg' => $res['msg'], 'data' => null]; + } + } // 扣除抽奖消耗的金币 @@ -602,35 +615,72 @@ class BlindBoxTurntableGift extends Model } /* - * 礼物发放 + * 礼物特效播放 */ public function gift_send($send_id){ - $blind_box_turntable = db('vs_blind_box_turntable_log')->where('id',$send_id)->find(); + $blind_box_turntable = db('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find(); if(!$blind_box_turntable){ - return ['code' => 0, 'msg' => '数据不存在','data' => null]; - } - $blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id,'is_sued'=>0])->select(); - if(!$blind_box_turntable_log){ return ['code' => 1, 'msg' => '成功', 'data' => null]; } - //获取盲盒配置 - foreach ($blind_box_turntable_log as $key => $value) { - if($value['is_sued'] == 1){ //礼物已发放就不再重复发放 - continue; - } - $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; -// $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) { -// return V(0, $res['msg']); - continue; - } - db('vs_blind_box_turntable_results_log')->where('id', $value['id'])->update(['is_sued' => 1, 'updatetime' => time()]); + $room_id = $blind_box_turntable['room_id']; + $blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id])->select(); + if(!$blind_box_turntable_log){ + return ['code' => 0, 'msg' => '数据不存在','data' => null]; } + $room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name'); + $FromUserInfo = Db::name('user')->where(['id'=>$blind_box_turntable['user_id']])->find(); + $user_nickname = $FromUserInfo['nickname']; + $textMessage = $user_nickname; + $text_message = []; + foreach ($blind_box_turntable_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 = $user_nickname . '在' . $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 = [ + 'FromUserInfo' => $FromUserInfo, + '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($blind_box_turntable['user_id'], $room_id); + $push->giftBanner($text_list_new); + } + } + db::name('vs_blind_box_turntable_log')->where('id', $send_id)->update(['is_sued' => 1, 'updatetime' => time()]); return ['code' => 1, 'msg' => '成功', 'data' => null]; } diff --git a/application/api/model/GiveGift.php b/application/api/model/GiveGift.php index eb9f9d8..e11d7f5 100644 --- a/application/api/model/GiveGift.php +++ b/application/api/model/GiveGift.php @@ -383,52 +383,8 @@ class GiveGift extends Model } } //推送礼物特效 - if($gift_info['label'] == 2){ - if(isset($ext['is_draw_gift']) && $ext['is_draw_gift'] == 1){ - $draw_gift = Db::name('vs_gift')->where(['gid'=>$ext['gift_id']])->find(); - $textMessage = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$ext['count']; - $text = [ - 'FromUserInfo' => $FromUserInfo, - 'ToUserInfo' => $ToUserInfo, - 'GiftInfo' => $draw_gift, - 'GiftNum' => $draw_gift['gift_name'], - 'text' => $textMessage - ]; - //聊天室推送系统消息 - model('Chat')->sendMsg(1005,$from_id,$text); - $roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id'); - if($roomtype == 6){ - //推送消息 - $hot_value = db::name('vs_give_gift')->where('from_id', $from_id)->where('from',6) - ->sum('total_price'); - $text1 = [ - 'room_id' => $from_id, - 'hot_value' => $hot_value * 10, - 'text' => '房间心动值变化' - ]; - //聊天室推送系统消息 - model('Chat')->sendMsg(1028,$from_id,$text1); - }else{ - if($draw_gift['is_public_server'] == 1){ - //推送礼物横幅 - $push = new Push(UID, $from_id); - $room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name'); - $text = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $num; - $text_list_new = [ - 'text' => $text, - 'gift_picture' => $draw_gift['base_image'], - 'room_id' => $from_id, - 'fromUserName' => $FromUserInfo['nickname'], - 'toUserName' => $ToUserInfo['nickname'], - 'giftName' => $draw_gift['gift_name'], - 'roomId' => $from_id, - 'number' => $num, - ]; - $push->giftBanner($text_list_new); - } - - } - }else{ + if(!isset($ext['is_draw_gift']) || $ext['is_draw_gift'] != 1){// 非盲盒转盘 推送 + if($gift_info['label'] == 2){ //循环开出来的盲盒,相同的礼物只推送一次,消息推送为$FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' .$gift_inf['gift_name'].' x 多少'; if($gift_box){ // 统计相同礼物的数量 @@ -457,9 +413,9 @@ class GiveGift extends Model $textMessage = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' . implode(',', $giftTextList); $textData = [ 'FromUserInfo' => $FromUserInfo, -// 'ToUserInfo' => $ToUserInfo, -// 'GiftInfo' => $gift_info, -// 'GiftNum' => $num, + // 'ToUserInfo' => $ToUserInfo, + // 'GiftInfo' => $gift_info, + // 'GiftNum' => $num, 'text' => $textMessage ]; // 聊天室推送文字消息 @@ -508,7 +464,7 @@ class GiveGift extends Model $push = new Push(UID, $from_id); $room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name'); $bannerText = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_inf['gift_name'] . 'X' . $count; - $text_list_new = [ + $text_list_new[] = [ 'text' => $bannerText, 'gift_picture' => $gift_inf['base_image'], 'room_id' => $from_id, @@ -523,51 +479,51 @@ class GiveGift extends Model } } } - } - }else{ - $text = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 礼物 ' .$gift_info['gift_name'].' x ' .$num; - $text = [ - 'FromUserInfo' => $FromUserInfo, - 'ToUserInfo' => $ToUserInfo, - 'GiftInfo' => $gift_info, - 'GiftNum' => $num, - 'text' => $text - ]; - //聊天室推送系统消息 - model('Chat')->sendMsg(1005,$from_id,$text); - $roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id'); - if($roomtype == 6){ - //推送消息 - $hot_value = db::name('vs_give_gift')->where('from_id', $from_id)->where('from',6) - ->sum('total_price'); - $text1 = [ - 'room_id' => $from_id, - 'hot_value' => $hot_value * 10, - 'text' => '房间心动值变化' + }else{ + $text = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 礼物 ' .$gift_info['gift_name'].' x ' .$num; + $text = [ + 'FromUserInfo' => $FromUserInfo, + 'ToUserInfo' => $ToUserInfo, + 'GiftInfo' => $gift_info, + 'GiftNum' => $num, + 'text' => $text ]; //聊天室推送系统消息 - model('Chat')->sendMsg(1028,$from_id,$text1); - }else{ - if($gift_info['is_public_server'] == 1){ - //推送礼物横幅 - $push = new Push($uid, $from_id); - $room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name'); - $text = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_info['gift_name'] . 'X' . $num; - $text_list_new = [ - 'text' => $text, - 'gift_picture' => $gift_info['base_image'], + model('Chat')->sendMsg(1005,$from_id,$text); + $roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id'); + if($roomtype == 6){ + //推送消息 + $hot_value = db::name('vs_give_gift')->where('from_id', $from_id)->where('from',6) + ->sum('total_price'); + $text1 = [ 'room_id' => $from_id, - 'fromUserName' => $FromUserInfo['nickname'], - 'toUserName' => $ToUserInfo['nickname'], - 'giftName' => $gift_info['gift_name'], - 'roomId' => $from_id, - 'number' => $num, + 'hot_value' => $hot_value * 10, + 'text' => '房间心动值变化' ]; - $push->giftBanner($text_list_new); - } + //聊天室推送系统消息 + model('Chat')->sendMsg(1028,$from_id,$text1); + }else{ + if($gift_info['is_public_server'] == 1){ + //推送礼物横幅 + $push = new Push($uid, $from_id); + $room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name'); + $text = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_info['gift_name'] . 'X' . $num; + $text_list_new[] = [ + 'text' => $text, + 'gift_picture' => $gift_info['base_image'], + 'room_id' => $from_id, + 'fromUserName' => $FromUserInfo['nickname'], + 'toUserName' => $ToUserInfo['nickname'], + 'giftName' => $gift_info['gift_name'], + 'roomId' => $from_id, + 'number' => $num, + ]; + $push->giftBanner($text_list_new); + } + } + } } - } //直播间送礼物 每日任务 model('DailyTasks')->tasks_complete($uid,3); } @@ -701,7 +657,7 @@ class GiveGift extends Model } }elseif(in_array($change_type,$out_types)){ //减少用户金币 - $res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setDec('coin',$money); + $res1 = Db::name('user_wallet')->where(['user_id'=>$user_id,'coin'=>['>=',$money]])->setDec('coin',$money); if(!$res1){ return false; }