From 8ef22d87a2eb6c1688b721276e391e8f42ee975a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Tue, 13 Jan 2026 09:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9AGive=5FGift=20?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/adminapi/model/Room.php | 8 +- .../api/model/BlindBoxTurntableGift.php | 5 +- application/api/model/Guild.php | 136 +++++++++--------- application/cron/controller/RoomPan.php | 5 +- 4 files changed, 78 insertions(+), 76 deletions(-) diff --git a/application/adminapi/model/Room.php b/application/adminapi/model/Room.php index 21ec9011..713d0fe5 100644 --- a/application/adminapi/model/Room.php +++ b/application/adminapi/model/Room.php @@ -72,9 +72,9 @@ class Room extends Model */ public function getRoomFlow($room_id,$stime='',$etime=''){ $give_where = []; - $give_where['from_id'] = $room_id; + $give_where['room_id'] = $room_id; // $give_where['from'] = ["in",[2,3,6]]; - $give_where['from'] = 2; +// $give_where['from'] = 2; if(!empty($stime)){ $give_where['createtime'] = ['>=',strtotime($stime)]; } @@ -85,8 +85,8 @@ class Room extends Model // $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]]; $give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]]; } - $total_price = db::name('vs_give_gift')->where($give_where) - ->sum('total_price'); + $total_price = db::name('vs_guild_flow')->where($give_where) + ->sum('flow_price'); return $total_price; } diff --git a/application/api/model/BlindBoxTurntableGift.php b/application/api/model/BlindBoxTurntableGift.php index 62c59a9f..6cc14d69 100644 --- a/application/api/model/BlindBoxTurntableGift.php +++ b/application/api/model/BlindBoxTurntableGift.php @@ -182,11 +182,10 @@ class BlindBoxTurntableGift extends Model $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'); + $hot_value = db::name('vs_room')->where('id', $room_id)->value('hot_value'); $text1 = [ 'room_id' => $room_id, - 'hot_value' => $hot_value * 10, + 'hot_value' => $hot_value, 'text' => '房间心动值变化' ]; //聊天室推送系统消息 diff --git a/application/api/model/Guild.php b/application/api/model/Guild.php index 3123bf6b..c2d0a084 100644 --- a/application/api/model/Guild.php +++ b/application/api/model/Guild.php @@ -673,25 +673,29 @@ class Guild extends Model //本周流水 //本周的第一天 $week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday'))); - $guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id])->select(); - $transaction = 0; - foreach ($guild_user as $k => $v){ - $week_start_time_seach = $week; - $week_end_time_seach = time(); - if($v['createtime'] && $week_start_time_seach < $v['createtime']){ - $week_start_time_seach = $v['createtime']; - } - if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){ - $week_end_time_seach = $v['quit_time']; - } - $transaction_one = db::name('vs_give_gift') - ->whereIn('from_id',$v['room_id']) - ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]]) - ->sum('total_price'); - $transaction += $transaction_one; - - } - $total_transaction = $transaction; +// $guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id])->select(); +// $transaction = 0; +// foreach ($guild_user as $k => $v){ +// $week_start_time_seach = $week; +// $week_end_time_seach = time(); +// if($v['createtime'] && $week_start_time_seach < $v['createtime']){ +// $week_start_time_seach = $v['createtime']; +// } +// if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){ +// $week_end_time_seach = $v['quit_time']; +// } +// $transaction_one = db::name('vs_give_gift') +// ->whereIn('from_id',$v['room_id']) +// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]]) +// ->sum('total_price'); +// $transaction += $transaction_one; +// +// } +// $total_transaction = $transaction; + $total_transaction = db::name('vs_guild_flow') + ->where(['guild_id' => $guild_id]) + ->where(['createtime' => ['between', [$week, time()]]]) + ->sum('flow_price'); $ss = 0; if($total_transaction){ //根据工会流水 获取补贴比例 单位% @@ -814,30 +818,31 @@ class Guild extends Model return ['code' => 0, 'msg' => '公会不存在!', 'data' => null]; } //工会总流水 - $all_guild_room = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>0])->select(); - $total_transaction = 0; - foreach ($all_guild_room as $key => $value) { - $start_time = $seach_start_time; - $end_time = $seach_end_time; - if(!$start_time){ - $start_time_all = $value['createtime']; - $end_time_all = time(); - }else{ - $start_time_all = strtotime($start_time." 00:00:00"); - $end_time_all = strtotime($end_time." 23:59:59"); - } - if($value['createtime'] && $start_time_all < $value['createtime']){ - $start_time_all = $value['createtime']; - } - if($value['quit_time'] && ($end_time_all > $value['quit_time'])){ - $end_time_all = $value['quit_time']; - } - $transaction = db::name('vs_give_gift') - ->where('from_id',$value['room_id']) - ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_all, $end_time_all]]]) - ->sum('total_price'); - $total_transaction = $total_transaction+$transaction; - } +// $all_guild_room = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>0])->select(); +// $total_transaction = 0; +// foreach ($all_guild_room as $key => $value) { +// $start_time = $seach_start_time; +// $end_time = $seach_end_time; +// if(!$start_time){ +// $start_time_all = $value['createtime']; +// $end_time_all = time(); +// }else{ +// $start_time_all = strtotime($start_time." 00:00:00"); +// $end_time_all = strtotime($end_time." 23:59:59"); +// } +// if($value['createtime'] && $start_time_all < $value['createtime']){ +// $start_time_all = $value['createtime']; +// } +// if($value['quit_time'] && ($end_time_all > $value['quit_time'])){ +// $end_time_all = $value['quit_time']; +// } +// $transaction = db::name('vs_give_gift') +// ->where('from_id',$value['room_id']) +// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_all, $end_time_all]]]) +// ->sum('total_price'); +// $total_transaction = $total_transaction+$transaction; +// } + //查询工会所有房间流水 $list = db::name('vs_guild_user')->where(['guild_id'=>$guild_id,'delete_time'=>0,'status'=>1,'room_id'=>['<>',0]]) ->order('id asc') @@ -848,31 +853,31 @@ class Guild extends Model $room_data = []; $i=0; foreach ($list as $k=>$v){ - $start_time = $seach_start_time; - $end_time = $seach_end_time; - if(!$start_time){ - $start_time_seach = $value['createtime']; - $end_time_seach = time(); - }else{ - $start_time_seach = strtotime($start_time." 00:00:00"); - $end_time_seach = strtotime($end_time." 23:59:59"); - } - if($value['createtime'] && $start_time_all < $value['createtime']){ - $start_time_seach = $value['createtime']; - } - if($value['quit_time'] && ($end_time_all > $value['quit_time'])){ - $end_time_seach = $value['quit_time']; - } +// $start_time = $seach_start_time; +// $end_time = $seach_end_time; +// if(!$start_time){ +// $start_time_seach = $value['createtime']; +// $end_time_seach = time(); +// }else{ +// $start_time_seach = strtotime($start_time." 00:00:00"); +// $end_time_seach = strtotime($end_time." 23:59:59"); +// } +// if($value['createtime'] && $start_time_all < $value['createtime']){ +// $start_time_seach = $value['createtime']; +// } +// if($value['quit_time'] && ($end_time_all > $value['quit_time'])){ +// $end_time_seach = $value['quit_time']; +// } $room_info = db::name('vs_room')->where(['id'=>$v['room_id'],'room_status'=>1,'delete_time'=>0])->find(); if($room_info){ $room_data[$i]['room_id'] = $room_info['id']; $room_data[$i]['room_number'] = model('Decorate')->user_decorate_detail($room_info['id'],7); $room_data[$i]['room_name'] = $room_info['room_name']; $room_data[$i]['room_cover'] = localpath_to_netpath($room_info['room_cover']); - $room_data[$i]['total_price'] = db::name('vs_give_gift') - ->where('from_id',$v['room_id']) - ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_seach, $end_time_seach]]]) - ->sum('total_price'); + $room_data[$i]['total_price'] = db::name('vs_guild_flow') + ->where('room_id',$v['room_id']) + ->where(['createtime' => ['between', [$seach_start_time, $seach_end_time]]]) + ->sum('flow_price'); $i++; } @@ -882,7 +887,7 @@ class Guild extends Model 'page' => $page, 'limit' => $page_limit, 'count' => $count, - 'total_transaction' => $total_transaction ? $total_transaction : 0, + 'total_transaction' => $guild_info['income'] ? $guild_info['income'] : 0, 'list' => $room_data, ]; return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data]; @@ -1103,10 +1108,9 @@ class Guild extends Model //本周的第一天 $week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday'))); $week_end_time = time(); - $guild_data['week_income'] = db::name('vs_give_gift') - ->whereIn('gift_user',$user_id) + $guild_data['week_income'] = db::name('vs_guild_flow')->where(['guild_id'=>$info['id']]) ->where(['createtime' => ['between', [$week, $week_end_time]]]) - ->sum('total_price'); + ->sum('flow_price'); //厅主收益 $guild_data['room_author_ratio'] = $guild_user['room_id']==0 ? 0 : get_system_config_value('room_author_ratio'); //礼物分成 diff --git a/application/cron/controller/RoomPan.php b/application/cron/controller/RoomPan.php index c5b9755f..afde505c 100644 --- a/application/cron/controller/RoomPan.php +++ b/application/cron/controller/RoomPan.php @@ -196,11 +196,10 @@ class RoomPan $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'); + $hot_value = db::name('vs_room')->where('id', $room_id)->value('hot_value'); $text1 = [ 'room_id' => $room_id, - 'hot_value' => $hot_value * 10, + 'hot_value' => $hot_value, 'text' => '房间心动值变化' ]; //聊天室推送系统消息