巡乐会抽奖接口提交.-后台列表修改
This commit is contained in:
@@ -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 = [];
|
||||
}
|
||||
}
|
||||
@@ -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']);
|
||||
}
|
||||
//聊天送礼物 (音信)
|
||||
|
||||
@@ -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']) {
|
||||
|
||||
Reference in New Issue
Block a user