706 lines
25 KiB
PHP
706 lines
25 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\controller;
|
|
|
|
use app\admin\model\AdminLog;
|
|
use app\common\controller\adminApi;
|
|
use think\Config;
|
|
use think\Db;
|
|
use think\Hook;
|
|
use think\Session;
|
|
use think\Validate;
|
|
|
|
/**
|
|
* 盲盒
|
|
* @internal
|
|
*/
|
|
class Activities extends adminApi
|
|
{
|
|
|
|
protected $noNeedLogin = [];
|
|
protected $noNeedRight = ['decorate_list'];
|
|
|
|
protected $table = 'vs_gift_bag';
|
|
|
|
//1金币2礼物3装扮4钻石
|
|
public $gift_type =[
|
|
1=>'金币',
|
|
2=>'礼物',
|
|
3=>'装扮',
|
|
4=>'钻石'
|
|
];
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
|
|
}
|
|
/*
|
|
* 首充类型列表
|
|
*/
|
|
public function first_charge_lists(){
|
|
$page = input('page', 1);
|
|
$page_limit = input('page_limit', 30);
|
|
$where = [];
|
|
$where['activities_id'] = 1;
|
|
$where['delete_time'] = 0;
|
|
$count = db($this->table)->where($where)->count();
|
|
$lists = db($this->table)->where($where)->page($page, $page_limit)->select();
|
|
$bag_list = [];
|
|
foreach ($lists as $key=>$value){
|
|
$bag_list[$key]['id'] = $value['id'];
|
|
$bag_list[$key]['name'] = $value['name'];
|
|
$bag_list[$key]['title'] = $value['title'];
|
|
$bag_list[$key]['status'] = $value['status'];
|
|
$bag_list[$key]['status_str'] = $value['status']==1?'开启' : '关闭';
|
|
$bag_list[$key]['createtime'] = $value['createtime'];
|
|
$ext = json_decode($value['ext'],true);
|
|
$bag_list[$key]['title1'] = $ext['title1'];
|
|
$bag_list[$key]['title2'] = $ext['title2'];
|
|
$bag_list[$key]['money'] = $ext['money'];
|
|
}
|
|
$return_data = [
|
|
'page' =>$page,
|
|
'page_limit' => $page_limit,
|
|
'count' => $count,
|
|
'lists' => $bag_list
|
|
];
|
|
return V(1,"成功", $return_data);
|
|
}
|
|
/*
|
|
* 首充类型添加
|
|
*/
|
|
public function add_first_charge_type(){
|
|
$name = input('name', '');
|
|
$title = input('title', '');
|
|
$status = input('status', '');
|
|
$title1 = input('title1', '');
|
|
$title2 = input('title2', '');
|
|
$money = input('money', '');
|
|
$return_data = [
|
|
'name' => $name,
|
|
'title' => $title,
|
|
'status' => $status,
|
|
'activities_id' => 1,
|
|
];
|
|
$ext = [
|
|
'title1' => $title1,
|
|
'title2' => $title2,
|
|
'money' => $money
|
|
];
|
|
$return_data['ext'] = json_encode($ext);
|
|
$res = db::name($this->table)->insert($return_data);
|
|
if($res){
|
|
return V(1,"成功");
|
|
}else{
|
|
return V(0,"失败");
|
|
}
|
|
}
|
|
/*
|
|
* 首充类型修改
|
|
*/
|
|
public function update_first_charge(){
|
|
$name = input('name', '');
|
|
$title = input('title', '');
|
|
$status = input('status', '');
|
|
$title1 = input('title1', '');
|
|
$title2 = input('title2', '');
|
|
$money = input('money', '');
|
|
$id = input('id', '');
|
|
$gift_bag = db::name($this->table)->find($id);
|
|
if(!$gift_bag){
|
|
return V(0,"参数错误");
|
|
}
|
|
$data = [];
|
|
if($name!=""){
|
|
$data['name'] = $name;
|
|
}
|
|
if($title!=""){
|
|
$data['title'] = $title;
|
|
}
|
|
if($status!=""){
|
|
$data['status'] = $status;
|
|
}
|
|
$gift_bag_ext = json_decode($gift_bag['ext'], true);
|
|
$ext = [
|
|
'title1' => $gift_bag_ext['title1'],
|
|
'title2' => $gift_bag_ext['title2'],
|
|
'money' => $gift_bag_ext['money'],
|
|
];
|
|
if($title1!=""){
|
|
$ext['title1'] = $title1;
|
|
}
|
|
if($title2!=""){
|
|
$ext['title2'] = $title2;
|
|
}
|
|
if($money!=""){
|
|
$ext['money'] = $money;
|
|
$data['money'] = $money;
|
|
}
|
|
$data['ext'] = json_encode($ext);
|
|
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
|
if($res){
|
|
return V(1,"成功");
|
|
}else{
|
|
return V(0,"失败");
|
|
}
|
|
}
|
|
/*
|
|
* 首充类型删除
|
|
*/
|
|
public function del_first_charge(){
|
|
$id = input('id', '', 'intval');
|
|
if(!$id){
|
|
return V(0,"参数错误");
|
|
}
|
|
$res = db::name($this->table)->where(['id'=>$id])->update(['status'=>2,'delete_time'=>time()]);
|
|
if($res){
|
|
return V(1,"成功");
|
|
}else{
|
|
return V(0,"失败");
|
|
}
|
|
}
|
|
/*
|
|
* 首充礼包发放记录
|
|
*/
|
|
public function first_charge_send_list(){
|
|
$page = input('page', 1);
|
|
$page_limit = input('page_limit', 30);
|
|
$user_id = input('user_id', '');
|
|
$gift_bag_id = input('gift_bag_id', '');
|
|
$where = [];
|
|
if($user_id){
|
|
$where['user_id'] = $user_id;
|
|
}
|
|
$gift_bag = db('vs_gift_bag')->where(['activities_id'=>1,'delete_time'=>0])->select();
|
|
|
|
if($gift_bag_id){
|
|
$where['gift_bag_id'] = $gift_bag_id;
|
|
}else{
|
|
$gift_bag_id = array_column($gift_bag,'id');
|
|
$where['gift_bag_id'] = ['in',$gift_bag_id];
|
|
}
|
|
$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) {
|
|
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
|
$lists[$key]['id'] = $value['id'];
|
|
$lists[$key]['user_id'] = $value['user_id'];
|
|
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
|
|
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
|
$lists[$key]['money'] = $gift_bag['money'];
|
|
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
|
}
|
|
$return_data = [
|
|
'page' =>$page,
|
|
'page_limit' => $page_limit,
|
|
'count' => $count,
|
|
'lists' => $lists,
|
|
];
|
|
return V(1,"成功", $return_data);
|
|
}
|
|
|
|
/*
|
|
* 礼包列表
|
|
*/
|
|
public function gift_bag_list(){
|
|
$page = input('page', 1);
|
|
$page_limit = input('page_limit', 30);
|
|
$gift_bag_id = input('gift_bag_id', 0);
|
|
if($gift_bag_id == 0){
|
|
return V(0,"请选择礼包");
|
|
}
|
|
$where = [];
|
|
$where['gift_bag_id'] = $gift_bag_id;
|
|
$count = db("vs_gift_bag_detail")->where($where)->count();
|
|
$lists = db("vs_gift_bag_detail")->where($where)->page($page, $page_limit)->select();
|
|
$bag_list = [];
|
|
foreach ($lists as $kk=>$vv){
|
|
$bag_list[$kk]['id'] = $vv['id'];
|
|
$bag_list[$kk]['gift_id'] = $vv['foreign_id'];
|
|
$bag_list[$kk]['gift_bag_id'] = $vv['gift_bag_id'];
|
|
if($vv['type'] == 1){
|
|
$bag_list[$kk]['name'] = "金币";
|
|
$bag_list[$kk]['num'] = $vv['quantity'];
|
|
$bag_list[$kk]['gold'] = $vv['gold'];
|
|
$bag_list[$kk]['type'] = 1;
|
|
$bag_list[$kk]['type_str'] = "金币";
|
|
$bag_list[$kk]['icon'] = localpath_to_netpath("static/image/icon/gold.png");
|
|
}elseif ($vv['type'] == 2) {
|
|
$gift = DB::name('vs_gift')->where(['gid'=>$vv['foreign_id']])->find();
|
|
$bag_list[$kk]['name'] = $gift['gift_name'];
|
|
$bag_list[$kk]['num'] = $vv['quantity'];
|
|
$bag_list[$kk]['gold'] = $gift['gift_price'];
|
|
$bag_list[$kk]['type'] =2;
|
|
$bag_list[$kk]['type_str'] = "礼物";
|
|
$bag_list[$kk]['icon'] = $gift['base_image'];
|
|
} elseif ($vv['type'] == 3) {
|
|
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$vv['foreign_id']])->find();
|
|
if($decorate_price){
|
|
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
|
}
|
|
$bag_list[$kk]['name'] = $gift['title']??""; //装扮名称
|
|
$bag_list[$kk]['num'] = $decorate_price['day']??0; //天数
|
|
$bag_list[$kk]['gold'] = $decorate_price['price']??0; //价格
|
|
$bag_list[$kk]['type'] =3;
|
|
$bag_list[$kk]['type_str'] = "装扮";
|
|
$bag_list[$kk]['icon'] = $gift['base_image']??"";
|
|
}elseif ($vv['type'] == 4) {
|
|
$bag_list[$kk]['name'] = "钻石";
|
|
$bag_list[$kk]['num'] = $vv['quantity'];
|
|
$bag_list[$kk]['gold'] = $vv['gold'];
|
|
$bag_list[$kk]['type'] = 4;
|
|
$bag_list[$kk]['type_str'] = "钻石";
|
|
$bag_list[$kk]['icon'] = localpath_to_netpath("static/image/icon/diamond.png");
|
|
}
|
|
$bag_list[$kk]['createtime'] = date("Y-m-d H:i:s",$vv['createtime']);
|
|
|
|
}
|
|
$return_data = [
|
|
'page' =>$page,
|
|
'page_limit' => $page_limit,
|
|
'count' => $count,
|
|
'lists' => $bag_list
|
|
];
|
|
return V(1,"成功", $return_data);
|
|
}
|
|
/*
|
|
* 礼包添加
|
|
*/
|
|
public function gift_bag_add(){
|
|
$type = input('type', "");
|
|
$num = input('num', 1);
|
|
$gift_id = input('gift_id', 0);
|
|
$gift_bag_id = input('gift_bag_id', 1);
|
|
if($type==""){
|
|
return V(0,"请选择礼物类型");
|
|
}
|
|
if($type == 1){
|
|
$data = [
|
|
'type' => 1,
|
|
'gift_bag_id' => $gift_bag_id,
|
|
'name' => "金币",
|
|
'quantity' => $num,
|
|
'gold' => 1,
|
|
];
|
|
}elseif($type == 2){
|
|
$gift = DB::name('vs_gift')->where(['gid'=>$gift_id])->find();
|
|
if(!$gift){
|
|
return V(0,"请选择礼物");
|
|
}
|
|
$data = [
|
|
'type' => 2,
|
|
'gift_bag_id' => $gift_bag_id,
|
|
'foreign_id' => $gift_id,
|
|
'name' => $gift['gift_name'],
|
|
'quantity' => $num,
|
|
];
|
|
} elseif($type == 3){
|
|
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$gift_id])->find();
|
|
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
|
if(!$decorate_price){
|
|
return V(0,"请选择装扮");
|
|
}
|
|
$data = [
|
|
'type' => 3,
|
|
'gift_bag_id' => $gift_bag_id,
|
|
'foreign_id' => $gift_id,
|
|
'name' => $gift['title'],
|
|
'days' => $decorate_price['day'],
|
|
];
|
|
} elseif($type == 4){
|
|
$data = [
|
|
'type' => 4,
|
|
'gift_bag_id' => $gift_bag_id,
|
|
'name' => "钻石",
|
|
'quantity' => $num,
|
|
'gold' => 1,
|
|
];
|
|
}
|
|
$data['createtime'] = time();
|
|
$res = db::name('vs_gift_bag_detail')->insert($data);
|
|
if(!$res){
|
|
return V(0,"添加失败");
|
|
}
|
|
return V(1,"成功");
|
|
}
|
|
|
|
/*
|
|
* 礼包编辑
|
|
*/
|
|
public function gift_bag_edit(){
|
|
$type = input('type', "");
|
|
$num = input('num', 1);
|
|
$gift_id = input('gift_id', 0);
|
|
$gift_bag_id = input('gift_bag_id', 1);
|
|
$id = input('id', 0);
|
|
if($id == 0){
|
|
return V(0,"参数错误");
|
|
}
|
|
$gift_bag = db::name('vs_gift_bag_detail')->where(['id'=>$id])->find();
|
|
if(!$gift_bag){
|
|
return V(0,"请选择礼包");
|
|
}
|
|
if($type == 1){
|
|
$data = [
|
|
'type' => 1,
|
|
'gift_bag_id' => $gift_bag_id,
|
|
'name' => "金币",
|
|
'quantity' => $num,
|
|
'gold' => 1,
|
|
];
|
|
}elseif($type == 2){
|
|
$gift = DB::name('vs_gift')->where(['gid'=>$gift_id])->find();
|
|
if(!$gift){
|
|
return V(0,"请选择礼物");
|
|
}
|
|
$data = [
|
|
'type' => 2,
|
|
'gift_bag_id' => $gift_bag_id,
|
|
'foreign_id' => $gift_id,
|
|
'name' => $gift['gift_name'],
|
|
'quantity' => $num,
|
|
];
|
|
} elseif($type == 3){
|
|
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$gift_id])->find();
|
|
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
|
if(!$decorate_price){
|
|
return V(0,"请选择装扮");
|
|
}
|
|
$data = [
|
|
'type' => 3,
|
|
'gift_bag_id' => $gift_bag_id,
|
|
'foreign_id' => $gift_id,
|
|
'name' => $gift['title'],
|
|
'days' => $decorate_price['day'],
|
|
];
|
|
} elseif($type == 4){
|
|
$data = [
|
|
'type' => 4,
|
|
'gift_bag_id' => $gift_bag_id,
|
|
'name' => "钻石",
|
|
'quantity' => $num,
|
|
'gold' => 1,
|
|
];
|
|
}
|
|
$res = db::name('vs_gift_bag_detail')->where('id', $id)->update($data);
|
|
if(!$res){
|
|
return V(0,"编辑失败");
|
|
}
|
|
return V(1,"成功");
|
|
}
|
|
|
|
/*
|
|
* 删除礼包
|
|
*/
|
|
public function gift_bag_list_del(){
|
|
$id = input('id');
|
|
$res = db::name('vs_gift_bag_detail')->delete($id);
|
|
if(!$res){
|
|
return V(0,"删除失败");
|
|
}
|
|
return V(1,"成功");
|
|
}
|
|
|
|
/*
|
|
* 天降好礼详情
|
|
*/
|
|
public function day_drop_gift(){
|
|
$where['activities_id'] = 3;
|
|
$where['delete_time'] = 0;
|
|
$day_drop_gift = db($this->table)->where($where)->order('id desc')->find();
|
|
$ext = json_decode($day_drop_gift['ext'],true);
|
|
$data = [
|
|
'id' => $day_drop_gift['id'],
|
|
'name' => $day_drop_gift['name'],
|
|
'title' => $day_drop_gift['title'],
|
|
'status' => $day_drop_gift['status'],
|
|
'counter' => $ext['counter'],
|
|
'money' => $ext['money'],
|
|
'money_str' => $ext['money_str'],
|
|
'diamond' => $ext['diamond'],
|
|
];
|
|
return V(1,"成功",$data);
|
|
}
|
|
/*
|
|
* 天降好礼配置
|
|
*/
|
|
public function day_drop_gift_site(){
|
|
$name = input('name', '');
|
|
$title = input('title', '');
|
|
$status = input('status', '');
|
|
$counter = input('counter', '');
|
|
$money = input('money', '');
|
|
$money_str = input('money_str', '');
|
|
$diamond = input('diamond', '');
|
|
$id = input('id', 6);
|
|
$data = [
|
|
'name' => $name,
|
|
'title' => $title,
|
|
'status' => $status
|
|
];
|
|
$ext = [
|
|
'counter' => $counter,
|
|
'money_str' => $money_str,
|
|
'diamond' => $diamond,
|
|
'money' => $money
|
|
];
|
|
$data['ext'] = json_encode($ext);
|
|
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
|
if(!$res){
|
|
return V(0,"失败");
|
|
}
|
|
return V(1,"成功");
|
|
}
|
|
/*
|
|
* 天降好礼礼包发放记录
|
|
*/
|
|
public function day_drop_send_list(){
|
|
$page = input('page', 1);
|
|
$page_limit = input('page_limit', 30);
|
|
$user_id = input('user_id', '');
|
|
$gift_bag_id = input('gift_bag_id', 6);
|
|
$where = [];
|
|
if($user_id){
|
|
$where['user_id'] = $user_id;
|
|
}
|
|
if($gift_bag_id){
|
|
$where['gift_bag_id'] = $gift_bag_id;
|
|
}
|
|
$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) {
|
|
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
|
$lists[$key]['id'] = $value['id'];
|
|
$lists[$key]['user_id'] = $value['user_id'];
|
|
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
|
|
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
|
$lists[$key]['money'] = $gift_bag['money'];
|
|
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
|
}
|
|
$return_data = [
|
|
'page' =>$page,
|
|
'page_limit' => $page_limit,
|
|
'count' => $count,
|
|
'lists' => $lists,
|
|
];
|
|
return V(1,"成功", $return_data);
|
|
}
|
|
|
|
//礼盒管理
|
|
/*
|
|
* 规则配置
|
|
*/
|
|
public function daily_tasks_box_config_set(){
|
|
$gift_bag_id = input('gift_bag_id', "");
|
|
$highest_gain = input('highest_gain', "");
|
|
$meet = input('meet','');
|
|
$num = input('num', 0);
|
|
$content = input('content', 0);
|
|
if($gift_bag_id==""){
|
|
return V(0,"请选择礼包类型");
|
|
}
|
|
if($highest_gain==""){
|
|
return V(0,"请填写礼包总价值");
|
|
}
|
|
if($num==""){
|
|
return V(0,"请填写每日可领取数量");
|
|
}
|
|
if($meet==""){
|
|
return V(0,"请填写每天累计购买金币数");
|
|
}
|
|
$ext = [
|
|
'highest_gain' => $highest_gain,
|
|
'meet' => $meet,
|
|
'num' => $num
|
|
];
|
|
$data['ext'] = json_encode($ext);
|
|
$res = db::name($this->table)->where(['id'=>$gift_bag_id])->update($data);
|
|
if(!$res){
|
|
return V(0,"失败");
|
|
}
|
|
if($content){
|
|
db::name('vs_activities')->where('id',2)->update(['content'=>$content]);
|
|
}
|
|
return V(1,"成功");
|
|
}
|
|
|
|
/*
|
|
* 规则配置详情
|
|
*/
|
|
public function daily_tasks_box_config(){
|
|
$gift_bag_id = input('gift_bag_id', "");
|
|
$where['id'] = $gift_bag_id;
|
|
$where['delete_time'] = 0;
|
|
$day_drop_gift = db($this->table)->where($where)->order('id desc')->find();
|
|
$ext = json_decode($day_drop_gift['ext'],true);
|
|
$activities_content = db::name('vs_activities')->where('id',2)->value('content');
|
|
$data = [
|
|
'id' => $day_drop_gift['id'],
|
|
'name' => $day_drop_gift['name'],
|
|
'title' => $day_drop_gift['title'],
|
|
'status' => $day_drop_gift['status'],
|
|
'highest_gain' => $ext['highest_gain'],
|
|
'meet' => $ext['meet'],
|
|
'num' => $ext['num'],
|
|
'content' => $activities_content,
|
|
];
|
|
return V(1,"成功",$data);
|
|
|
|
}
|
|
|
|
/*
|
|
* 礼盒列表
|
|
*/
|
|
public function daily_tasks_box_gift_list(){
|
|
$page = input('page', 1);
|
|
$page_limit = input('page_limit', 30);
|
|
$gift_id = input('gift_id', '');
|
|
$gift_name = input('gift_name', '');
|
|
$gift_bag_id = input('gift_bag_id', 1);
|
|
$gift_type = input("gift_type",'');
|
|
if(empty($gift_bag_id)){
|
|
return V(0,"请选择礼盒类型");
|
|
}
|
|
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>2,'status'=>1])->select();
|
|
foreach ($bag_list as &$v) {
|
|
$v['default'] = $gift_bag_id == $v['id'] ? 1 : 0;
|
|
}
|
|
$where=[];
|
|
$where['gift_bag_id'] = $gift_bag_id;
|
|
if($gift_id!==''){
|
|
$where['foreign_id'] =$gift_id;
|
|
}
|
|
if($gift_name!==''){
|
|
$where['name'] = ['like', '%'.$gift_name.'%'];
|
|
}
|
|
if($gift_type!==''){
|
|
$where['type'] = $gift_type;
|
|
}
|
|
$count = db::name("vs_gift_bag_detail")->where($where)->count();
|
|
$lists_data = db::name("vs_gift_bag_detail")->where($where)->page($page, $page_limit)->order("id desc")->select();
|
|
$lists = [];
|
|
$bag_data = db::name("vs_gift_bag")->field('id,name,ext')->where(['id'=>$gift_bag_id])->find();
|
|
foreach ($lists_data as $key => $value) {
|
|
$lists[$key]['id'] = $value['id'];
|
|
$lists[$key]['box_name'] = $bag_data['name'];
|
|
$lists[$key]['gift_type'] = $value['type'];
|
|
$lists[$key]['gift_type_str'] = $this->gift_type[$value['type']];
|
|
if ($value['type'] == 2) {
|
|
$lists[$key]['gift_id'] = $value['foreign_id'];
|
|
$lists[$key]['gift_name'] = $value['name'];
|
|
$gift_data = db::name('vs_gift')->where(['gid' => $value['foreign_id']])->find();
|
|
$lists[$key]['base_image'] = $gift_data['base_image'];
|
|
$lists[$key]['quantity'] = $value['quantity'];
|
|
$lists[$key]['quantity_str'] = $value['quantity']."个";
|
|
$lists[$key]['gift_price'] = $gift_data['gift_price'];
|
|
}elseif ($value['type'] == 3){
|
|
$lists[$key]['gift_id'] = $value['foreign_id'];
|
|
$lists[$key]['gift_name'] = $value['name'];
|
|
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$value['foreign_id']])->find();
|
|
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
|
$lists[$key]['base_image'] = $gift['base_image'];
|
|
$lists[$key]['quantity'] = $value['quantity'];
|
|
$lists[$key]['quantity_str'] = $decorate_price['day']."天";
|
|
$lists[$key]['gift_price'] = $decorate_price['price'];
|
|
}else{
|
|
$lists[$key]['gift_id'] = "--";
|
|
$lists[$key]['gift_name'] = "--";
|
|
$lists[$key]['base_image'] = "--";
|
|
$lists[$key]['quantity'] = 0;
|
|
$lists[$key]['quantity_str'] = "0";
|
|
$lists[$key]['gift_price'] = $value['gold'];
|
|
}
|
|
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
|
|
|
}
|
|
//统计
|
|
$total_data = [];
|
|
//抽奖次数总计
|
|
$total_count = db::name("vs_gift_bag_receive_log")
|
|
->where(['gift_bag_id'=>$gift_bag_id])
|
|
->count();
|
|
//抽奖收入总计
|
|
$total_price = db::name('vs_gift_bag_receive_log')
|
|
->where(['gift_bag_id'=>$gift_bag_id])
|
|
->sum('bag_price');
|
|
//今日抽奖总次数
|
|
$today_total_count = db::name('vs_gift_bag_receive_log')
|
|
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
|
->count();
|
|
//今日抽奖收入
|
|
$today_total_price = db::name('vs_gift_bag_receive_log')
|
|
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
|
->sum('bag_price');
|
|
$return_data = [
|
|
'page' =>$page,
|
|
'page_limit' => $page_limit,
|
|
'count' => $count,
|
|
'lists' => $lists,
|
|
'bag_list' => $bag_list,
|
|
'total_data' => [
|
|
'total_count' => $total_count,
|
|
'total_price' => $total_price,
|
|
'today_total_count' => $today_total_count,
|
|
'today_total_price' => $today_total_price,
|
|
]
|
|
];
|
|
return V(1,"成功", $return_data);
|
|
}
|
|
|
|
/*
|
|
* 礼盒开奖记录
|
|
*/
|
|
public function daily_tasks_box_gift_send_list(){
|
|
$page = input('page', 1);
|
|
$page_limit = input('page_limit', 30);
|
|
$user_id = input('user_id', '');
|
|
$gift_bag_id = input('gift_bag_id', 1);
|
|
$where = [];
|
|
if($user_id){
|
|
$where['user_id'] = $user_id;
|
|
}
|
|
if($gift_bag_id){
|
|
$where['gift_bag_id'] = $gift_bag_id;
|
|
}
|
|
$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) {
|
|
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
|
$lists[$key]['id'] = $value['id'];
|
|
$lists[$key]['user_id'] = $value['user_id'];
|
|
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
|
|
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
|
$lists[$key]['money'] = $gift_bag['money'];
|
|
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
|
}
|
|
$return_data = [
|
|
'page' =>$page,
|
|
'page_limit' => $page_limit,
|
|
'count' => $count,
|
|
'lists' => $lists,
|
|
];
|
|
return V(1,"成功", $return_data);
|
|
}
|
|
|
|
/*
|
|
* 装扮列表
|
|
*/
|
|
public function decorate_list(){
|
|
$decorate_list = db::name('vs_decorate_price')->alias('a')
|
|
->field('a.id,a.did,b.type,a.day,a.price,b.title,b.base_image')
|
|
->where('b.delete_time',0)
|
|
->join('vs_decorate b','a.did = b.did')
|
|
->select();
|
|
$return_data = [];
|
|
foreach ($decorate_list as $key => $value) {
|
|
$return_data[$key]['id'] = $value['id'];
|
|
$return_data[$key]['name'] = model('api/Decorate')->TypeArray[$value['type']].'-'.$value['day'].'天-'.$value['title'];
|
|
$return_data[$key]['day'] = $value['day'];
|
|
}
|
|
return V(1,"成功", $return_data);
|
|
|
|
}
|
|
} |