From 7edce6b41471d0cbaa0d2d42faa12e8e2390f023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Fri, 29 Aug 2025 16:29:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A1=E4=B9=90=E4=BC=9A=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8F=90=E4=BA=A4.-=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/adminapi/controller/BlindBox.php | 145 +++++++++++++++++++ application/api/controller/Gift.php | 3 +- application/api/model/Gift.php | 13 +- 3 files changed, 158 insertions(+), 3 deletions(-) diff --git a/application/adminapi/controller/BlindBox.php b/application/adminapi/controller/BlindBox.php index ca301bb..24279c0 100644 --- a/application/adminapi/controller/BlindBox.php +++ b/application/adminapi/controller/BlindBox.php @@ -332,6 +332,8 @@ class BlindBox extends adminApi } if($gift_bag_id){ $where['gift_bag_id'] = $gift_bag_id; + }else{ + $where['gift_bag_id'] = ['in',[7,8,9]]; } if($periods){ $where['periods'] = $periods; @@ -604,4 +606,147 @@ class BlindBox extends adminApi ]; return V(1,"成功", $return_data); } + /* + * 盲盒转盘开奖记录 + * + */ + public function blind_box_turntable_open_record(){ + $page = input('page', 1); + $page_limit = input('page_limit', 30); + $gift_id = input('gift_id', ''); + $user_id = input('user_id', ''); + $room_id = input('room_id', ''); + $gift_bag_id = input('gift_bag_id', ''); + $periods = input('periods', ''); + $stime = input('stime', ''); + $etime = input('etime', ''); + $where = []; + $where['room_id'] = $room_id; + if($gift_id){ + $where['gift_id'] = $gift_id; + } + if($user_id){ + $user_id = db::name('user')->where('user_code', $user_id)->value('id'); + $where['user_id'] = $user_id; + } + if($gift_bag_id){ + $where['gift_bag_id'] = $gift_bag_id; + }else{ + $where['gift_bag_id'] = ['in',[10,11,12]]; + } + if($periods){ + $where['periods'] = $periods; + } + if($stime!==""){ + $where['createtime'] = ['>=', strtotime($stime)]; + } + if($etime!==""){ + $where['createtime'] = ['<=', strtotime($etime.'23:59:59')]; + } + if($stime!=="" && $etime!==""){ + $where['createtime'] = ['between', [strtotime($stime), strtotime($etime.'23:59:59')]]; + } + $count = db::name('vs_gift_bag_receive_log')->where($where)->count(); + $lists_data = db::name('vs_gift_bag_receive_log')->where($where)->page($page, $page_limit)->order("id desc")->select(); + $lists = []; + foreach ($lists_data as $key => $value) { + $lists[$key]['id'] = $value['id']; + $lists[$key]['user_id'] = $value['user_id']; + $user = db::name('user')->where('id',$value['user_id'])->find(); + $lists[$key]['user_name'] = ""; + if($user){ + $lists[$key]['user_name'] = $user['user_code'].'-'.$user['nickname']; + } + + $lists[$key]['gift_user_id'] = $value['gift_user_id']; + $gift_user = db::name('user')->where('id',$value['gift_user_id'])->find(); + $lists[$key]['gift_user_name'] = ""; + if($gift_user){ + $lists[$key]['gift_user_name'] = $gift_user['user_code'].'-'.$gift_user['nickname']; + } + $lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name'); + $lists[$key]['periods'] = $value['periods']; + $room = db::name('vs_room')->where('id',$value['room_id'])->find(); + $lists[$key]['room_name'] = ""; + if($room){ + $lists[$key]['room_name'] = $room['room_number']."-".$room['room_name']; + } + $lists[$key]['bag_price'] = $value['bag_price']; + $lists[$key]['gift_id'] = $value['gift_id']; + $lists[$key]['gift_name'] = db::name('vs_gift')->where('gid',$value['gift_id'])->value('gift_name'); + $lists[$key]['gift_price'] = $value['gift_price']; + $lists[$key]['gift_num'] = $value['num']; + $lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']); + } + //总抽奖次数 + $total = $count; + //总抽奖金额(支出) + $total_money = db::name('vs_gift_bag_receive_log')->where($where)->sum('bag_price'); + //总礼物价值(收入) + $total_gift_money = db::name('vs_gift_bag_receive_log')->where($where)->sum('gift_price'); + //统计 + if($total_gift_money==0 || $total_money==0){ + $ratio = 0; + }else{ + $ratio =round(($total_gift_money / $total_money),3); + } + //盈亏 + $profit_loss = $total_gift_money - $total_money; + if($profit_loss==0 || $total_money==0){ + $profit_loss_ratio = 0; + }else{ + // 盈亏比 + $profit_loss_ratio = round(($profit_loss / $total_money),3); + } + $return_data = [ + 'page' =>$page, + 'page_limit' => $page_limit, + 'count' => $count, + 'lists' => $lists, + 'total_data' => [ + 'total' => $total, + 'total_money' => $total_money, + 'total_gift_money' => $total_gift_money, + 'ratio' => $ratio, + 'profit_loss' => $profit_loss, + 'profit_loss_ratio' => $profit_loss_ratio, + ] + ]; + return V(1,"成功", $return_data); + } + /* + * 寻乐会锁定记录 + * + */ + public function xlh_lock_record(){ + $page = input('page', 1); + $page_limit = input('page_limit', 30); + $gift_id = input('gift_id', ''); + $user_id = input('user_id', ''); + $room_id = input('room_id', ''); + $periods = input('periods', ''); + $where = []; + $where['room_id'] = $room_id; + if($gift_id){ + $where['gift_id'] = $gift_id; + } + if($user_id){ + $user_id = db::name('user')->where('user_code', $user_id)->value('id'); + $where['user_id'] = $user_id; + } + if($periods){ + $where['periods'] = $periods; + } + $count = db::name('vs_room_pan_xlh_log') + ->alias('a') + ->join('vs_room_pan_xlh b', 'a.xlh_id = b.id', 'left') + + ->where($where)->count(); + $lists_data = db::name('vs_room_pan_xlh_log') + ->where($where) + ->page($page, $page_limit) + ->order("id desc") + ->select(); + $lists = []; + } } \ No newline at end of file diff --git a/application/api/controller/Gift.php b/application/api/controller/Gift.php index 105babf..7c3b000 100644 --- a/application/api/controller/Gift.php +++ b/application/api/controller/Gift.php @@ -25,7 +25,8 @@ class Gift extends BaseCom public function get_gift_list() { $label = input('label',0); - $reslut = model('Gift')->get_gift_list($label); + $room_id = input('room_id',0); + $reslut = model('Gift')->get_gift_list($label,$room_id); return V($reslut['code'],$reslut['msg'], $reslut['data']); } //聊天送礼物 (音信) diff --git a/application/api/model/Gift.php b/application/api/model/Gift.php index e76cbfc..ee25cec 100644 --- a/application/api/model/Gift.php +++ b/application/api/model/Gift.php @@ -28,7 +28,7 @@ class Gift extends Model } //拉去礼物列表 - public function get_gift_list($label=0) + public function get_gift_list($label=0,$room_id=0) { $map['delete_time'] = 0; $where['is_show'] = 1; @@ -42,9 +42,18 @@ class Gift extends Model $list = $this->field('gid as gift_id,gift_name,base_image,gift_price')->where($map)->where($where)->order('sort asc, gift_price asc')->select(); if($label==2){ + $is_open_blind_box_turntable = 0; + if($room_id){ + $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable'); + } + if($is_open_blind_box_turntable==1){ + $activities_id = [4,5]; + }else{ + $activities_id = [4]; + } foreach ($list as &$v) { //获取盲盒列表 - $box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where(['activities_id'=>["in",[4,5]]])->select(); + $box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where(['activities_id'=>["in",$activities_id]])->select(); foreach ($box_list as $key =>$box) { $ext = json_decode($box['ext'],true); if ($ext['gift_id'] == $v['gift_id']) {