72 Commits

Author SHA1 Message Date
5754f71023 盲盒转盘优化-重构-调试-再加日志 2025-10-29 17:47:12 +08:00
3d4465a5c6 盲盒转盘优化-重构-调试-再加日志 2025-10-29 17:03:57 +08:00
5e132848bc 盲盒转盘优化-重构-调试-再加日志 2025-10-29 16:24:55 +08:00
4dfdcf325d 盲盒转盘优化-重构-修改调试 2025-10-29 16:01:47 +08:00
e2aea224c9 盲盒转盘优化-重构-修改调试 2025-10-29 15:11:50 +08:00
2814c8a7b7 盲盒转盘优化-重构-修改调试 2025-10-29 12:58:51 +08:00
d6eacc53ce 盲盒转盘优化-重构-调试 2025-10-29 12:55:17 +08:00
678f2f5cea 盲盒转盘优化-重构-调试 2025-10-29 12:00:42 +08:00
ddf8bbf387 盲盒转盘优化-重构-调试 2025-10-29 11:47:18 +08:00
81382c1591 盲盒转盘优化-重构-调试 2025-10-29 11:13:27 +08:00
a832c1024b 盲盒转盘优化-重构-调试 2025-10-29 11:05:29 +08:00
0f7cf82276 盲盒转盘优化-重构-调试 2025-10-29 10:54:57 +08:00
5b03fec4f6 盲盒转盘优化-重构-调试 2025-10-29 09:03:17 +08:00
47e02d8796 盲盒转盘优化-重构-调试 2025-10-29 09:02:20 +08:00
50ed633439 盲盒转盘优化-重构-调试 2025-10-28 18:58:01 +08:00
752fbece93 盲盒转盘优化-重构-调试 2025-10-28 18:31:55 +08:00
54efad0668 盲盒转盘优化-重构-调试 2025-10-28 18:12:41 +08:00
bbb3f85fee 盲盒转盘优化-重构-调试 2025-10-28 18:07:28 +08:00
590f5cb092 盲盒转盘优化-重构-调试 2025-10-28 14:31:53 +08:00
172beb8d34 盲盒转盘优化-重构-调试 2025-10-28 14:30:14 +08:00
3d7beb38fc 盲盒转盘优化-重构-调试 2025-10-28 13:09:59 +08:00
b2320cf92d 盲盒转盘优化-重构-调试 2025-10-28 13:00:17 +08:00
bd4b016586 盲盒转盘优化-重构-调试 2025-10-28 12:07:24 +08:00
4f917863e6 盲盒转盘优化-重构-调试 2025-10-28 12:03:43 +08:00
60b517312c 盲盒转盘优化-调试-加日志监控 2025-10-25 18:31:33 +08:00
60e2cde5e7 盲盒转盘优化-调试-加日志监控 2025-10-25 18:14:36 +08:00
1bd790071c 盲盒转盘优化-调试-加日志监控 2025-10-25 17:55:14 +08:00
f54302f22e 盲盒转盘优化-调试-加日志监控 2025-10-25 16:45:57 +08:00
7937998240 盲盒转盘优化-调试-加日志监控 2025-10-25 16:37:13 +08:00
93e60d695b 盲盒转盘优化-调试-加日志监控 2025-10-25 16:34:55 +08:00
943921a352 盲盒转盘优化-调试-加日志监控 2025-10-25 16:25:41 +08:00
fc48e1f261 盲盒转盘优化-调试-加日志监控 2025-10-25 16:18:11 +08:00
4effce28ef 盲盒转盘优化-调试-加日志监控 2025-10-25 16:16:02 +08:00
08bb57e5a3 Merge remote-tracking branch 'origin/develop' into develop 2025-10-25 12:01:31 +08:00
c4cfcb393f 盲盒转盘优化-调试-加日志监控 2025-10-25 12:01:22 +08:00
5b2c655be8 获取房间信息 2025-10-25 11:57:03 +08:00
910717464f pk房间类型修改 2025-10-25 11:25:56 +08:00
bad85524ef 盲盒转盘优化-调试-加日志监控 2025-10-25 11:03:37 +08:00
8ad606a8dd 盲盒转盘优化-调试-加日志监控 2025-10-25 10:56:30 +08:00
b7302fa213 盲盒转盘优化-调试-加日志监控 2025-10-25 10:46:58 +08:00
b4827f823b 盲盒转盘优化-调试 2025-10-25 10:05:55 +08:00
7e9c2b5138 盲盒转盘优化-调试 2025-10-24 21:36:05 +08:00
e7a17bb34e 盲盒转盘优化-调试 2025-10-24 20:58:31 +08:00
3b22f8d134 盲盒转盘优化-调试 2025-10-24 15:44:40 +08:00
de5ae479c9 盲盒转盘优化-调试 2025-10-24 15:08:02 +08:00
8315eeae2d 盲盒转盘优化-调试 2025-10-24 14:58:35 +08:00
46d12d99b1 盲盒转盘优化 2025-10-24 14:28:58 +08:00
817da774ef 提现税值取值修改 2025-10-24 11:23:18 +08:00
0d734d092b 盲盒转盘优化调整 2025-10-23 18:32:05 +08:00
a6ae1d8c01 线上bug修改 2025-10-22 18:46:19 +08:00
6ef84a2690 线上bug修改 2025-10-22 15:58:25 +08:00
29ec30fd65 表情管理-后台接口提交 2025-10-22 14:45:09 +08:00
c49abb572f 线上bug修改 2025-10-22 14:32:56 +08:00
24bb57f516 表情包功能上传 2025-10-22 11:16:58 +08:00
5ebcdb2a7e 表情包功能上传 2025-10-22 10:57:30 +08:00
0451444b85 表情包功能上传 2025-10-22 10:38:47 +08:00
391a2481e9 秘地新的需求池更新版本-4 2025-10-22 09:17:00 +08:00
0353bae8db 秘地新的需求池更新版本-10 2025-10-21 18:52:37 +08:00
df976eebfe 秘地新的需求池更新版本-11 2025-10-21 18:24:13 +08:00
2a085baaa5 气泡显示 2025-10-21 17:43:01 +08:00
9038538ee8 秘地新的需求池更新版本-5-公会房间列表加总流水 2025-10-21 17:20:47 +08:00
8bba9f61ec Merge remote-tracking branch 'origin/develop' into develop 2025-10-21 17:07:39 +08:00
59ba40a66a 秘地新的需求池更新版本-1-公会房间列表加总流水 2025-10-21 17:07:32 +08:00
dc3f0983da 聊天气泡 2025-10-21 16:59:19 +08:00
7ea48b8c9f Merge remote-tracking branch 'origin/develop' into develop 2025-10-21 16:52:26 +08:00
dbd4a43a15 新需求-装备加聊天气泡 2025-10-21 16:52:18 +08:00
ca79d16c95 聊天气泡 2025-10-21 16:35:20 +08:00
c7a1864c65 聊天气泡 2025-10-21 16:33:27 +08:00
396dfeaa07 新需求-后台优化-盲盒转盘超抽问题解决 2025-10-21 09:52:27 +08:00
6cca013d61 新需求-后台优化 2025-10-20 17:44:30 +08:00
c96d8750b6 送礼物数量 2025-10-20 15:27:21 +08:00
287523fc88 新需求-后台优化 2025-10-20 15:12:17 +08:00
26 changed files with 2274 additions and 243 deletions

View File

@@ -62,17 +62,14 @@ class BlindBox extends adminApi
$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();
if(empty($gift_data)){
continue;
}
$lists[$key]['base_image'] = $gift_data['base_image'];
$lists[$key]['gift_price'] = $gift_data['gift_price'];
$lists[$key]['quantity'] = $value['quantity'];
$lists[$key]['remaining_number'] = $value['remaining_number'];
$lists[$key]['is_public_screen'] = $gift_data['is_public_screen'];
$lists[$key]['is_public_server'] = $gift_data['is_public_server'];
$lists[$key]['is_world_show'] = $value['is_world_show'];
$lists[$key]['weight'] = $value['weight'];
$lists[$key]['base_image'] = $gift_data['base_image'] ?? "";
$lists[$key]['gift_price'] = $gift_data['gift_price'] ?? 0;
$lists[$key]['quantity'] = $value['quantity'] ?? 0;
$lists[$key]['remaining_number'] = $value['remaining_number'] ?? 0;
$lists[$key]['is_public_screen'] = $gift_data['is_public_screen'] ?? 0;
$lists[$key]['is_public_server'] = $gift_data['is_public_server'] ?? 0;
$lists[$key]['is_world_show'] = $value['is_world_show'] ?? 0;
$lists[$key]['weight'] = $value['weight'] ?? 0;
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
}
@@ -354,6 +351,14 @@ class BlindBox extends adminApi
foreach ($gift_bag_detail as $k=>$v){
$bag_data = db::name($this->table)->where(['id'=>$v['id']])->update(['remaining_number'=>$v['quantity']]);
}
// 清除缓存
Cache::rm("pan_gift_bag".$gift_bag_id);
Cache::rm("pan_gift_bag_detail".$gift_bag_id);
Cache::rm("pan_total_quantity".$gift_bag_id);
Cache::rm("pan_total_remaining".$gift_bag_id);
Cache::rm("pan_total_draw".$gift_bag_id);
Cache::rm("pan_gift_info_map".$gift_bag_id);
return V(1,"成功");
}

View File

@@ -31,36 +31,46 @@ class GiveGift extends adminApi
$end_time = input('end_time', '');
$where=[];
$gwhere = [];
if($send_user != ''){
$user_id = db::name('user')->where('user_code', $send_user)->value('id');
$where['user_id'] = $user_id;
$gwhere['gg.user_id'] = $user_id;
}
if($gift_user != ''){
$gift_user_id = db::name('user')->where('user_code', $gift_user)->value('id');
$where['gift_user'] = $gift_user_id;
$gwhere['gg.gift_user'] = $gift_user_id;
}
if($from_id != ''){
$room_id = db::name('vs_room')->where('room_number', $from_id)->value('id');
if($room_id){
$where['from_id'] = $room_id;
$gwhere['gg.from_id'] = $room_id;
}else{
$where['from_id'] = $from_id;
$gwhere['gg.from_id'] = $from_id;
}
}
if($gift_id != ''){
$where['gift_id'] = $gift_id;
$gwhere['gg.gift_id'] = $gift_id;
}
if($from != ''){
$where['from'] = $from;
$gwhere['gg.from'] = $from;
}
// 时间筛选优化
if (!empty($start_time) || !empty($end_time)) {
if (!empty($start_time) && !empty($end_time)) {
$where['createtime'] = ['between', [strtotime($start_time), strtotime($end_time)]];
$gwhere['gg.createtime'] = ['between', [strtotime($start_time), strtotime($end_time)]];
} elseif (!empty($start_time)) {
$where['createtime'] = ['>=', strtotime($start_time)];
$gwhere['gg.createtime'] = ['>=', strtotime($start_time)];
} elseif (!empty($end_time)) {
$where['createtime'] = ['<=', strtotime($end_time)];
$gwhere['gg.createtime'] = ['<=', strtotime($end_time)];
}
}
//礼物总数
@@ -79,15 +89,12 @@ class GiveGift extends adminApi
$count = db::name('vs_give_gift')->where($where)->count();
$earning_list = [];
if(!empty($where)){
$gift_ids = db::name('vs_give_gift')->where($where)->column('id');
if (!empty($gift_ids)) {
// 批量获取所有收益记录
$earning_list = db::name('vs_give_gift_ratio_log')
->field('app_earning,gift_user_earning,room_owner_earning')
->where('give_gift_id', 'in', $gift_ids)
->order('id', 'desc')
->select();
}
$earning_list = db::name('vs_give_gift_ratio_log')
->alias('egl')
->join('vs_give_gift gg', 'egl.give_gift_id = gg.id')
->where($gwhere) // 替换为实际的筛选条件
->field('egl.app_earning,egl.gift_user_earning,egl.room_owner_earning')
->select();
}else{
// 批量获取所有收益记录
$earning_list = db::name('vs_give_gift_ratio_log')
@@ -199,6 +206,8 @@ class GiveGift extends adminApi
$value['gift_user_earning'] = $earning_info ? $earning_info['gift_user_earning'] : 0;
$value['room_owner_earning'] = $earning_info ? $earning_info['room_owner_earning'] : 0;
}
//比例
$config = get_system_config();
$return_data = [
'page' =>$page,
'page_limit' => $page_limit,
@@ -209,7 +218,10 @@ class GiveGift extends adminApi
'total_price' => $total_price,
'app_earning' => round($app_earning,2) ,
'receive_earning' => round($receive_earning,2),
'room_owner_earning' => round($room_owner_earning,2)
'room_owner_earning' => round($room_owner_earning,2),
'app_earning_ratio' => 100 - $config['room_gift_ratio'] - $config['room_author_ratio'],
'receive_earning_ratio' => $config['room_gift_ratio'] ?? 0,
'room_owner_earning_ratio' => $config['room_author_ratio'] ?? 0,
]
];
return V(1,"成功", $return_data);

View File

@@ -84,6 +84,7 @@ class Guild extends adminApi
//当日流水
$list[$k]['today_money'] = model('Guild')->getTodayMoney($v['id'],$search_stime,$search_etime);
$list[$k]['is_show'] = $v['is_show'];
$list[$k]['is_show_str'] = $v['is_show'] == 1 ? '显示' : '隐藏';
$list[$k]['status'] = $v['status'];
$list[$k]['status_str'] = $v['status'] == 1 ? '正常' : '解散';
$list[$k]['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
@@ -102,6 +103,21 @@ class Guild extends adminApi
$reslut['list'] = $list;
return V(1,"成功", $reslut);
}
/*
* 工会显示状态修改
*/
public function guild_show_status_edit(){
$id = input('id',0);
$guild = model('Guild')->getOne(['id'=>$id]);
if (!$guild) {
return V(0, "数据不存在");
}
if ($guild) {
$status = $guild['is_show'] == 1 ? 0 : 1;
}
$res = db::name('vs_guild')->where('id',$id)->update(['is_show'=>$status]);;
return V(1,"成功", $res);
}
/**
* 工会添加
@@ -379,8 +395,8 @@ class Guild extends adminApi
$page = input('page', 1);
$page_limit = input('page_limit', 30);
$guild_id = input('guild_id', 0);
$search_stime = input('search_stime','');
$search_etime = input('search_etime','');
$search_stime_str = input('search_stime','');
$search_etime_str = input('search_etime','');
$room_id = input('room_id', 0);
$where=['a.status'=>1];
$where=['a.room_id'=>['>',0]];
@@ -399,23 +415,39 @@ class Guild extends adminApi
->where(['a.guild_id'=>$guild_id])->where($where)->count();
$list = db::name($this->table_guild_user)->alias('a')
->join('vs_room b', 'a.room_id = b.id', 'left')
->where(['a.guild_id'=>$guild_id])->where($where)->page($page, $page_limit)->select();
->where(['a.guild_id'=>$guild_id])->where($where)
// ->page($page, $page_limit)
->select();
if(!$list){
return V(0,"暂无数据");
}
$rum_lists = [];
//总流水
$total_consumption = 0;
foreach ($list as $k=>$v){
if($search_stime!="" && $v['createtime'] < strtotime($search_stime)){
$search_stime = $search_stime;
}else{
$search_stime = date('Y-m-d H:i:s',$v['createtime']) ;
}
if($v['quit_time']){
if($search_etime!="" && $v['quit_time'] > strtotime($search_etime)){
$search_etime = $search_etime;
$search_stime = $search_stime_str;
$search_etime = $search_etime_str;
if($search_stime!=""){
if($search_stime!="" && $v['createtime'] < strtotime($search_stime)){
$search_stime = $search_stime;
}else{
$search_etime = date('Y-m-d H:i:s',$v['quit_time']);
$search_stime = date('Y-m-d H:i:s',$v['createtime']) ;
}
}else{
$search_stime = $search_stime;
}
if($search_etime!=""){
if($v['quit_time']){
if($search_etime!="" && $v['quit_time'] > strtotime($search_etime)){
$search_etime = $search_etime;
}else{
$search_etime = date('Y-m-d H:i:s',$v['quit_time']);
}
}else{
$search_etime = $search_etime;
}
}else{
$search_etime = $search_etime;
}
$room_info = db::name('vs_room')->where(['id'=>$v['room_id']])->find();
@@ -427,10 +459,18 @@ class Guild extends adminApi
//房间流水
$rum_lists[$k]['consumption']= model('Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime);
$rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['createtime']);
$total_consumption += $rum_lists[$k]['consumption'];
}
usort($rum_lists, function($a, $b) {
return $b['consumption'] - $a['consumption'];
});
//分页
$rum_lists = array_slice($rum_lists, ($page-1)*$page_limit, $page_limit);
$return_data = [
'page' =>$page,
'page_limit' => $page_limit,
'total_consumption' => $total_consumption,
'count' => $count,
'lists' => $rum_lists
];
@@ -661,7 +701,7 @@ class Guild extends adminApi
$lists_data = db::name($this->table_guild_subsidy)->alias('a')
->join('vs_guild b','a.guild_id = b.id')
->where($where)
->order('a.id desc')
->order('a.total_transaction desc')
->field('a.*,b.guild_name,b.user_id,b.guild_special_id')
->page($page,$page_limit)
->select();

View File

@@ -445,6 +445,8 @@ class Room extends adminApi
}
if($type_id!==''){
$where['type_id'] = $type_id;
}else{
$where['type_id'] = ['<>',6];
}
if($label_id!==''){
$where['label_id'] = $label_id;
@@ -460,7 +462,6 @@ class Room extends adminApi
}
//房间列表只展示 审核通过的房间
$where['apply_status'] = 2;//1待审核 2审核通过 3审核失败
$where['type_id'] = ['<>',6];
$count = db::name($this->table)->where($where)->count();
$room_lists = db::name($this->table)->where($where)->page($page, $page_limit)->select();
$lists = [];

View File

@@ -0,0 +1,227 @@
<?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\Model;
use think\Session;
use think\Validate;
/**
* 房间
* @internal
*/
class RoomEmoji extends adminApi
{
protected $noNeedLogin = [];
protected $noNeedRight = ['emoji_list','add_emoji','edit_emoji','del_emoji','emoji_detail','emoji_type_list'];
protected $table = 'vs_room_emoji';
protected $table_type = 'vs_room_emoji_type';
public function _initialize()
{
parent::_initialize();
}
//房间表情列表
function emoji_list(){
$id = input('id', '', 'intval');
$name = input('name', '', 'trim');
$page = input('page', 1);
$page_limit = input('page_limit', 30);
$where = [];
if ($id) {
$where['id'] = $id;
}
if ($name) {
$where['name'] = ['like', '%' . $name . '%'];
}
$total = Db::name($this->table)
->where($where)
->count();
$list = Db::name($this->table)
->where($where)
->where(['deletetime' => 0])
->order('sort desc,id desc')
->page($page, $page_limit)
->select();
foreach ($list as &$item) {
$item['type_str'] = Db::name($this->table_type)->where('id', $item['type_id'])->value('type_name');
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
$item['status_str'] = $item['status'] == 1 ? '显示' : '隐藏';
}
$return_data = [
'page' =>$page,
'page_limit' => $page_limit,
'count' => $total,
'list' => $list
];
return V(1,"成功", $return_data);
}
//添加房间表情
function add_emoji(){
$pid = input('pid', 0, 'intval');
$name = input('name', '', 'trim');
$img = input('image', '', 'trim');
$animate_image = input('animate_image', '', 'trim');
$sort = input('sort', 0, 'intval');
$type_id = input('type_id', 0);
$status = input('status', 1, 'intval');
if (!$name) {
return V(0, '请输入表情名称');
}
if (!$img) {
return V(0, '请上传表情图片');
}
if (!$type_id) {
return V(0, '请选择表情类型');
}
$data = [
'pid' => $pid,
'name' => $name,
'image' => $img,
'animate_image' => $animate_image,
'sort' => $sort,
'type_id' => $type_id,
'status' => $status,
'createtime' => time(),
];
$res = Db::name($this->table)->insert($data);
if ($res) {
return V(1, '添加成功');
}
}
//房间表情修改
function edit_emoji(){
$id = input('id', 0, 'intval');
$name = input('name', '', 'trim');
$img = input('image', '', 'trim');
$animate_image = input('animate_image', '', 'trim');
$sort = input('sort', 0, 'intval');
$type_id = input('type_id', 0);
$status = input('status', 1, 'intval');
if (!$id) {
return V(0, '请选择要修改的表情');
}
if($name){
$data['name'] = $name;
}
if($img){
$data['image'] = $img;
}
if($animate_image){
$data['animate_image'] = $animate_image;
}
if($sort){
$data['sort'] = $sort;
}
if($type_id){
$data['type_id'] = $type_id;
}
$data['status'] = $status;
$res = Db::name($this->table)->where('id',$id)->update($data);
if ($res) {
return V(1, '修改成功');
}
}
//房间表情删除
function del_emoji(){
$id = input('id', 0, 'intval');
if (!$id) {
return V(0, '请选择要删除的表情');
}
$res = Db::name($this->table)->where('id',$id)->update(
['deletetime' => time()]
);
if ($res) {
return V(1, '删除成功');
}
}
//表情详情
function emoji_detail(){
$id = input('id', 0, 'intval');
if (!$id) {
return V(0, '请选择要查看的表情');
}
$detail = Db::name($this->table)->where('id',$id)->find();
if (!$detail) {
return V(0, '表情不存在');
}
return V(1,"成功", $detail);
}
//表情类型列表
function emoji_type_list(){
$emoji_type = Db::name($this->table_type)
->field('id,type_name')
->where(['deletetime'=>0,'status'=>1])
->order('sort desc,id desc')
->select();
return V(1,"成功", $emoji_type);
}
//表情类型添加
function add_emoji_type(){
$type_name = input('type_name', '', 'trim');
if (!$type_name) {
return V(0, '请输入表情类型名称');
}
$data = [
'type_name' => $type_name,
'sort' => 0,
'status' => 1,
'createtime' => time(),
];
$res = Db::name($this->table_type)->insert($data);
if ($res) {
return V(1, '添加成功');
}
}
//表情类型修改
function edit_emoji_type(){
$id = input('id', 0, 'intval');
$type_name = input('type_name', '', 'trim');
$sort = input('sort', 0, 'intval');
$status = input('status', 1, 'intval');
if (!$id) {
return V(0, '请选择要修改的表情类型');
}
if($type_name){
$data['type_name'] = $type_name;
}
if($sort){
$data['sort'] = $sort;
}
if($status){
$data['status'] = $status;
}
$res = Db::name($this->table_type)->where('id',$id)->update($data);
if ($res) {
return V(1, '修改成功');
}
return V(0, '修改失败');
}
//表情类型删除
function del_emoji_type(){
$id = input('id', 0, 'intval');
if (!$id) {
return V(0, '请选择要删除的表情类型');
}
$res = Db::name($this->table_type)->where('id',$id)->update(
['deletetime' => time()]
);
if ($res) {
return V(1, '删除成功');
}
return V(0, '删除失败');
}
}

View File

@@ -35,6 +35,9 @@ class SysSet extends adminApi
'10' => '邀请奖励',
'11' => '二级密码',
];
public $noAdminConfigType = [
'1' => '基础设置',
];
public function _initialize()
{
@@ -45,14 +48,18 @@ class SysSet extends adminApi
* 类型列表
*/
public function type_list(){
$configType = $this->configType;
if($this->auth->isSuperAdmin()){
$configType = $this->configType;
}else{
$configType = $this->noAdminConfigType;
}
$list = [];
$i=0;
foreach ($configType as $k=>$v){
$list[$i]['id'] = $k;
$list[$i]['name'] = $v;
$i++;
}
foreach ($configType as $k=>$v){
$list[$i]['id'] = $k;
$list[$i]['name'] = $v;
$i++;
}
return V(1,"成功", $list);
}

View File

@@ -72,7 +72,9 @@ class User extends adminApi
if($v=='coin1'){
$where['c.coin'] = ['>=',$input_data];
}elseif($v=='coin2'){
$where['c.coin'] = ['<=',$input_data];
if($input_data){
$where['c.coin'] = ['<=',$input_data];
}
}elseif($v=='createtime'){
$where['a.createtime'] = ['>=',strtotime($input_data)];
$where['a.createtime'] = ['<=',strtotime($input_data)];
@@ -436,7 +438,15 @@ class User extends adminApi
$page = input('page',1);
$page_limit = input('page_limit',10);
$type = input('type','');
$return = model('UserWallet')->money_change_log($user_id,$type,$page,$page_limit);
$stime = input('stime','');
$etime = input('etime','');
$change_type = input('change_type','');
$seach = [
'stime' => $stime,
'etime' => $etime,
'change_type' => $change_type
];
$return = model('UserWallet')->money_change_log($user_id,$seach,$type,$page,$page_limit);
$list = [];
foreach($return['list'] as $k=>$v){
$list[$k] = [
@@ -456,6 +466,14 @@ class User extends adminApi
return V(1,"操作成功", $return_data);
}
/*
* 获取用户资金类型
*/
public function get_money_type(){
$reslut = model('UserWallet')->getChangeTypeLableList();
return V(1,"操作成功", $reslut);
}
/*
* 相册列表
*/

View File

@@ -92,18 +92,18 @@ class Room extends Model
* 房间绑定盘
*/
public function bindPan($room_id){
db::name('vs_room_pan')->where(['room_id'=>$room_id])->delete();
$gift_bag = db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>['in',[10,11,12,13]]])->select();
foreach ($gift_bag as $k=>$v){
$data = [
'room_id'=>$room_id,
'gift_bag_id'=>$v['gift_bag_id'],
'gift_bag_detail_id'=>$v['id'],
'remaining_number'=>$v['quantity'],
'createtime'=>time()
];
db::name('vs_room_pan')->insert($data);
}
// db::name('vs_room_pan')->where(['room_id'=>$room_id])->delete();
// $gift_bag = db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>['in',[10,11,12,13]]])->select();
// foreach ($gift_bag as $k=>$v){
// $data = [
// 'room_id'=>$room_id,
// 'gift_bag_id'=>$v['gift_bag_id'],
// 'gift_bag_detail_id'=>$v['id'],
// 'remaining_number'=>$v['quantity'],
// 'createtime'=>time()
// ];
// db::name('vs_room_pan')->insert($data);
// }
return ['code' => 1, 'msg' => '成功', 'data' => null];
}

View File

@@ -40,7 +40,7 @@ class BlindBoxTurntable extends BaseCom
$num = input('num',1);
$heart_id = input('heart_id',0);
$auction_id = input('auction_id',0);
$reslut = model('BlindBoxTurntableGiftDrawWorld')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
return v($reslut['code'], $reslut['msg'], $reslut['data']);
}
/*
@@ -93,7 +93,7 @@ class BlindBoxTurntable extends BaseCom
$user_id = $this->uid;
$room_id = input('room_id',0);
$num = input('num',1);
$reslut = model('BlindBoxTurntableGiftDrawWorld')->xlh_draw_gift($user_id,$num,$room_id);
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->xlh_draw_gift($user_id,$num,$room_id);
return v($reslut['code'], $reslut['msg'], $reslut['data']);
}
/*

View File

@@ -0,0 +1,22 @@
<?php
namespace app\api\controller;
use app\common\controller\BaseCom;
use think\Db;
class RoomEmoji extends BaseCom
{
//表情类型列表
public function type_list(){
$reslut = model('RoomEmoji')->getRoomEmojiType();
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//表情列表
public function emoji_list(){
$type_id = input('type_id', "");
$pid = input('pid', "");
$reslut = model('RoomEmoji')->getRoomEmoji($type_id,$pid,true);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
}

View File

@@ -236,23 +236,26 @@ class BlindBoxTurntableGift extends Model
$pan_xlh = db::name('vs_room_pan_xlh')->where(['send_time'=>0,'end_time'=>['>',time()]])->order('id desc')->find();
$xlh_periods_num = Cache::get("xlh_periods_num") ?? 0;
if(empty($pan_xlh)){
if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
$xlh_periods = Cache::get("this_xlh_periods") ?? 0;
$pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([
'room_id' => $room_id,
'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'],
'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'],
'periods' => $xlh_periods+1,
'num' => 0,
'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60,
'createtime' => time()
]);
Cache::set("this_xlh_periods", $xlh_periods+1, 0);//修改巡乐会期数
$pan_xlh = db::name('vs_room_pan_xlh')->where(['id'=>$pan_xlh_id])->find();
}else{
return ['code' => 0, 'msg' => '巡乐会已结束', 'data' => null];
}
return ['code' => 0, 'msg' => '巡乐会已结束', 'data' => null];
}
// if(empty($pan_xlh)){
// if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
// $xlh_periods = Cache::get("this_xlh_periods") ?? 0;
// $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([
// 'room_id' => $room_id,
// 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'],
// 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'],
// 'periods' => $xlh_periods+1,
// 'num' => 0,
// 'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60,
// 'createtime' => time()
// ]);
// Cache::set("this_xlh_periods", $xlh_periods+1, 0);//修改巡乐会期数
// $pan_xlh = db::name('vs_room_pan_xlh')->where(['id'=>$pan_xlh_id])->find();
// }else{
// return ['code' => 0, 'msg' => '巡乐会已结束', 'data' => null];
// }
// }
$xlh_user_data= null;
$room_user_data = null;
if($pan_xlh && $pan_xlh['user_id']){

View File

@@ -8,6 +8,7 @@ use think\Model;
use think\Db;
use think\Session;
use Redis;
use think\queue;
/*
* 盲盒转盘优化后方法
*
@@ -37,100 +38,230 @@ class BlindBoxTurntableGiftDrawWorld extends Model
public function draw_gift($gift_bag_id, $user_id, $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0,$auction_id = 0)
{
// 最大重试次数
$maxRetries = 3;
for ($attempt = 0; $attempt < $maxRetries; $attempt++) {
try {
// 1. 验证参数并提前处理错误
$validationResult = $this->validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids);
if ($validationResult !== true) {
return $validationResult;
}
// 2. 预加载必要数据
$loadResult = $this->loadDrawData($gift_bag_id, $user_id, $room_id, $num, $gift_user_ids);
if ($loadResult['code'] !== 1) {
return $loadResult;
}
// 添加以下检查以防止 null 错误
if (!isset($loadResult['data']) || !is_array($loadResult['data'])) {
return ['code' => 0, 'msg' => '数据加载失败', 'data' => null];
}
['bag_data' => $bag_data, 'room' => $room, 'xlh_ext' => $xlh_ext] = $loadResult['data'];
try {
// 1. 验证参数并提前处理错误
$validationResult = $this->validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids);
if ($validationResult !== true) {
return $validationResult;
}
// 2. 预加载必要数据
$loadResult = $this->loadDrawData($gift_bag_id, $user_id, $room_id, $num, $gift_user_ids);
if ($loadResult['code'] !== 1) {
return $loadResult;
}
// 添加以下检查以防止 null 错误
if (!isset($loadResult['data']) || !is_array($loadResult['data'])) {
return ['code' => 0, 'msg' => '数据加载失败', 'data' => null];
}
['bag_data' => $bag_data, 'room' => $room, 'xlh_ext' => $xlh_ext] = $loadResult['data'];
// 3. 预计算抽奖结果
$precomputeResult = $this->precomputeDrawResults(
$bag_data,
$gift_user_ids,
$num
);
if ($precomputeResult['code'] !== 1) {
return $precomputeResult;
// 3. 预计算抽奖结果
$precomputeResult = $this->precomputeDrawResults(
$bag_data,
$gift_user_ids,
$num
);
if ($precomputeResult['code'] !== 1) {
return $precomputeResult;
}
$precomputedResults = $precomputeResult['data']['results'];
$availableGiftss = $precomputeResult['data']['availableGifts'];
$currentXlhPeriodsNum = $precomputeResult['data']['current_xlh_periods_num'];
$addcurrentXlhPeriodsNum = $precomputeResult['data']['addcurrentXlhPeriodsNum'];
$expectedCount = count(explode(',', $gift_user_ids)) * $num;
if (count($precomputedResults) != $expectedCount) {
// 记录错误到Redis
$this->recordDrawErrorToRedis($expectedCount, count($precomputedResults), $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults);
return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null];
}
foreach ($precomputedResults as $result) {
$key = $result['gift_user_id'] . '_' . $result['gift_bag_detail']['foreign_id'];
if (!isset($giftUserCountsJianCha[$key])) {
$giftUserCountsJianCha[$key] = [
'gift_user_id' => $result['gift_user_id'],
'gift_id' => $result['gift_bag_detail']['foreign_id'],
'count' => 0,
'gift_price' => $result['gift']['gift_price'],
'quantity' => $result['gift_bag_detail']['quantity'],
];
}
$precomputedResults = $precomputeResult['data']['results'];
$availableGiftss = $precomputeResult['data']['availableGifts'];
$currentXlhPeriodsNum = $precomputeResult['data']['current_xlh_periods_num'];
$addcurrentXlhPeriodsNum = $precomputeResult['data']['addcurrentXlhPeriodsNum'];
$expectedCount = count(explode(',', $gift_user_ids)) * $num;
if (count($precomputedResults) != $expectedCount) {
$giftUserCountsJianCha[$key]['count']++;
if($giftUserCountsJianCha[$key]['count'] > $result['gift_bag_detail']['quantity']){
// 记录错误到Redis
$this->recordDrawErrorToRedis($expectedCount, count($precomputedResults), $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults);
// 使用正确的Redis方法存储数据
$key = 'blind_box_draw_world_errors_' . date('Y-m-d-H-i-s');
$errorData = [
'gift_bag_id' => $gift_bag_id,
'user_id' => $user_id,
'gift_user_ids' => $gift_user_ids,
'num' => $num,
'giftUserCountsJianCha' => $giftUserCountsJianCha,
];
$this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData));
return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null];
}
// 4. 执行抽奖事务(核心操作)
$transactionResult = $this->executeDrawTransaction(
$bag_data,
$user_id,
$room_id,
$num,
$precomputedResults,
$availableGiftss,
$gift_user_ids,
$heart_id,
$auction_id
);
if ($transactionResult['code'] !== 1) {
return $transactionResult;
}
$boxTurntableLog = $transactionResult['data']['log_id'];
$giftCounts = $transactionResult['data']['gift_counts'];
// 5. 处理后续操作(非事务性操作)
$this->handlePostDrawOperations(
$precomputedResults,
$boxTurntableLog,
$room_id,
$xlh_ext,
$currentXlhPeriodsNum,
$addcurrentXlhPeriodsNum,
$room
);
// 6. 构建并返回结果
return $this->buildDrawResult($boxTurntableLog, $giftCounts);
} catch (\Exception $e) {
$key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s');
$errorData = [
'gift_bag_id' => $gift_bag_id,
'user_id' => $user_id,
'gift_user_ids' => $gift_user_ids,
'num' => $num,
'room_id' => $room_id,
'heart_id' => $heart_id,
'auction_id' => $auction_id,
];
if ($this->redis) {
$this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($errorData));
}
// 如果是死锁且还有重试机会
if (strpos($e->getMessage(), 'Deadlock') !== false && $attempt < $maxRetries - 1) {
// 随机延迟后重试
usleep(rand(50000, 200000)); // 50-200ms
continue;
}
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
}
// 4. 执行抽奖事务(核心操作)
$transactionResult = $this->executeDrawTransaction(
$bag_data,
$user_id,
$room_id,
$num,
$precomputedResults,
$availableGiftss,
$gift_user_ids,
$heart_id,
$auction_id
);
if ($transactionResult['code'] !== 1) {
return $transactionResult;
}
$boxTurntableLog = $transactionResult['data']['log_id'];
$giftCounts = $transactionResult['data']['gift_counts'];
// 5. 处理后续操作(非事务性操作)
$this->handlePostDrawOperations(
$precomputedResults,
$boxTurntableLog,
$room_id,
$xlh_ext,
$currentXlhPeriodsNum,
$addcurrentXlhPeriodsNum,
$room
);
// 6. 构建并返回结果
return $this->buildDrawResult($boxTurntableLog, $giftCounts);
} catch (\Exception $e) {
$key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s');
$errorData = [
'gift_bag_id' => $gift_bag_id,
'user_id' => $user_id,
'gift_user_ids' => $gift_user_ids,
'num' => $num,
'room_id' => $room_id,
'heart_id' => $heart_id,
'auction_id' => $auction_id,
];
if ($this->redis) {
$this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($errorData));
}
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
}
}
/**
* 生成奖池并存入Redis
*/
public function generateGiftPool($gift_bag_id)
{
try {
// 获取奖池基本信息
$poolKey = "blind_box_pool:{$gift_bag_id}";
$poolInfoKey = "blind_box_pool_info:{$gift_bag_id}";
// 检查Redis连接
if (!$this->redis) {
throw new \Exception('Redis连接不可用');
}
// 获取数据库中的期数信息
$dbPeriods = db::name("vs_gift_bag")
->where(['id' => $gift_bag_id])
->value('periods');
// 获取奖池详细信息
$gift_bag_detail_data = $this->getCachedGiftBagDetail($gift_bag_id);
// 获取可用礼物列表
$availableGifts = [];
foreach ($gift_bag_detail_data as $gift) {
if ($gift['remaining_number'] > 0) {
// 根据权重添加礼物到可选列表
for ($i = 0; $i < $gift['weight']; $i++) {
$availableGifts[] = $gift;
}
}
}
if (empty($availableGifts)) {
throw new \Exception('没有可用的礼物');
}
// 生成大量抽奖结果例如1000个
$results = [];
for ($i = 0; $i < 1000; $i++) {
$randomIndex = array_rand($availableGifts);
$selectedGift = $availableGifts[$randomIndex];
// 获取礼物详细信息
$giftInfo = db::name("vs_gift")
->where(['gid' => $selectedGift['foreign_id']])
->find();
$results[] = [
'gift_bag_detail' => $selectedGift,
'gift' => $giftInfo ?? []
];
}
// 使用事务确保原子操作
$this->redis->watch($poolKey, $poolInfoKey);
$this->redis->multi();
// 清空现有奖池
$this->redis->del($poolKey);
// 添加新结果到奖池
foreach ($results as $result) {
$this->redis->rPush($poolKey, json_encode($result));
}
// 更新奖池信息
$this->redis->hMSet($poolInfoKey, [
'periods' => $dbPeriods,
'draw_times' => 0,
'total_count' => count($results),
'last_update' => time()
]);
$this->redis->exec();
Log::record("奖池生成成功gift_bag_id: {$gift_bag_id}", 'info');
return true;
} catch (\Exception $e) {
Log::record('生成奖池失败: ' . $e->getMessage(), 'error');
return false;
}
}
/**
* 从奖池中获取一个礼物
*/
public function getGiftFromPool($gift_bag_id)
{
try {
$poolKey = "blind_box_pool:{$gift_bag_id}";
// 从Redis奖池中取出一个结果
$result = $this->redis->lPop($poolKey);
if (!$result) {
// 奖池为空,重新生成
$this->generateGiftPool($gift_bag_id);
$result = $this->redis->lPop($poolKey);
}
return $result ? json_decode($result, true) : null;
} catch (\Exception $e) {
Log::record('从奖池获取礼物失败: ' . $e->getMessage(), 'error');
return null;
}
}
/**
* 验证抽奖参数
*/
@@ -327,14 +458,14 @@ class BlindBoxTurntableGiftDrawWorld extends Model
'draw_times' => $totalDrawTimes,
'periods' => $periods,
];
$precomputedResultss[] = [
'gift_user_id' => $giftUserId,
'gift_bag_detail' => $selectedGift,
'gift' => $gift,
'draw_times' => $totalDrawTimes,
'periods' => $periods,
];
$totalDrawTimes++;
// $precomputedResultss[] = [
// 'gift_user_id' => $giftUserId,
// 'gift_bag_detail' => $selectedGift,
// 'gift' => $gift,
// 'draw_times' => $totalDrawTimes,
// 'periods' => $periods,
// ];
// $totalDrawTimes++;
$currentXlhPeriodsNum++;
$addcurrentXlhPeriodsNum++;
@@ -343,6 +474,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
}
}
}
$totalDrawTimes = 0;
}
// 再从新奖池中分配剩余所需礼物
@@ -495,65 +627,55 @@ class BlindBoxTurntableGiftDrawWorld extends Model
$bagGiftPrice = $bag_data['gift_price'] * $num * $gift_user_num;
// 增加重试机制
$maxRetries = 3;
for ($retry = 0; $retry < $maxRetries; $retry++) {
try {
db::startTrans();
// 按照固定顺序处理事务步骤
// 1. 扣除用户金币(优先处理)
$this->deductUserCoins($user_id, $bagGiftPrice, $room_id);
try {
db::startTrans();
// 按照固定顺序处理事务步骤
// 1. 扣除用户金币(优先处理)
$this->deductUserCoins($user_id, $bagGiftPrice, $room_id);
// 2. 创建抽奖记录
$boxTurntableLog = db::name('vs_blind_box_turntable_log')->insertGetId([
'user_id' => $user_id,
'gift_bag_id' => $bag_data['id'],
'num' => $num,
'room_id' => $room_id,
'bag_price' => $bag_data['gift_price'],
'createtime' => time()
]);
// 2. 创建抽奖记录
$boxTurntableLog = db::name('vs_blind_box_turntable_log')->insertGetId([
'user_id' => $user_id,
'gift_bag_id' => $bag_data['id'],
'num' => $num,
'room_id' => $room_id,
'bag_price' => $bag_data['gift_price'],
'createtime' => time()
]);
if (!$boxTurntableLog) {
throw new \Exception('添加盲盒转盘记录失败');
}
// 3. 批量更新库存按ID排序避免死锁
$this->batchUpdateGiftInventory($availableGiftss, $room_id);
// 4. 批量插入礼包发放记录
$this->batchInsertGiftBagReceiveLog($user_id, $boxTurntableLog, $bag_data, $room_id, $precomputedResults);
// 5. 发送礼物
$result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id);
if (isset($result['code']) && $result['code'] !== 1) {
throw new \Exception($result['msg']);
}
db::commit();
// 统计礼物数量
$giftCounts = $this->countGifts($precomputedResults);
return [
'code' => 1,
'msg' => '事务执行成功',
'data' => [
'log_id' => $boxTurntableLog,
'gift_counts' => $giftCounts
]
];
} catch (\Exception $e) {
db::rollback();
// 检查是否是死锁错误
if (strpos($e->getMessage(), 'Deadlock') !== false && $retry < $maxRetries - 1) {
// 等待随机时间后重试
usleep(rand(10000, 100000)); // 10-100ms
continue;
}
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
if (!$boxTurntableLog) {
throw new \Exception('添加盲盒转盘记录失败');
}
// 3. 批量更新库存按ID排序避免死锁
$this->batchUpdateGiftInventory($availableGiftss, $room_id);
// 4. 批量插入礼包发放记录
$this->batchInsertGiftBagReceiveLog($user_id, $boxTurntableLog, $bag_data, $room_id, $precomputedResults);
// 5. 发送礼物
$result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id);
if (isset($result['code']) && $result['code'] !== 1) {
throw new \Exception($result['msg']);
}
db::commit();
// 统计礼物数量
$giftCounts = $this->countGifts($precomputedResults);
return [
'code' => 1,
'msg' => '事务执行成功',
'data' => [
'log_id' => $boxTurntableLog,
'gift_counts' => $giftCounts
]
];
} catch (\Exception $e) {
db::rollback();
throw new \Exception($e->getMessage());
}
return ['code' => 0, 'msg' => '操作超时,请重试', 'data' => null];
}
/**
@@ -573,12 +695,25 @@ class BlindBoxTurntableGiftDrawWorld extends Model
// 批量更新
foreach ($inventoryUpdates as $giftId => $count) {
$giftBagDetail = Db::name("vs_gift_bag_detail")
->where('id', $giftId)
->find();
if (!$giftBagDetail) {
throw new \Exception("礼物详情不存在ID: " . $giftId);
}
// 检查库存是否足够
if ($giftBagDetail['remaining_number'] < $count) {
throw new \Exception("礼物库存不足ID: " . $giftId);
}
$ret = db::name("vs_gift_bag_detail")->where('id',$giftId)
->setDec('remaining_number', $count);
if (!$ret) {
Log::record('巡乐会更新礼物剩余数量: ' . $room_id."【数据】".var_export($precomputedResults, true),"info");
throw new \Exception('更新礼物剩余数量失败');
}
// 同时更新缓存中的库存信息
$this->updateCachedGiftBagDetail($giftBagDetail['gift_bag_id'], $giftId, $count);
}
}
@@ -692,7 +827,6 @@ class BlindBoxTurntableGiftDrawWorld extends Model
}
$giftUserCounts[$key]['count']++;
}
// 批量插入
$batchInsertData = [];
foreach ($giftUserCounts as $userGift) {
@@ -1524,5 +1658,71 @@ class BlindBoxTurntableGiftDrawWorld extends Model
Log::record('Redis操作失败: ' . $e->getMessage(), 'error');
}
}
/**
* 获取转盘礼包详细信息【缓存】
*/
private function getCachedGiftBag($gift_bag_id,$is_cache = true) {
$cacheKey = "pan_gift_bag".$gift_bag_id;
$gift_bag_data = Cache::get($cacheKey);
if (!$gift_bag_data || !$is_cache) {
$bag_data = db::name("vs_gift_bag")
->field('id,name,ext,periods')
->where('id', $gift_bag_id)
->find();
if (!$bag_data) {
return [];
}
$gift_bag_data = json_decode($bag_data['ext'], true);
$gift_bag_data['gift_bag_id'] = $gift_bag_id;
$gift_bag_data['gift_bag_name'] = $bag_data['name'];
$gift_bag_data['periods'] = $bag_data['periods'];
$gift_bag_data['gift_price'] = DB::name("vs_gift") ->where(['gid' => $gift_bag_data['gift_id']])->value('gift_price');
Cache::set($cacheKey, $gift_bag_data, $this->cache_time);
}
return $gift_bag_data;
}
/**
* 获取奖池详细信息【缓存】
*/
private function getCachedGiftBagDetail($gift_bag_id,$is_cache = true) {
$cacheKey = "pan_gift_bag_detail".$gift_bag_id;
$gift_bag_detail_data = Cache::get($cacheKey);
if (!$gift_bag_detail_data || !$is_cache) {
$gift_bag_detail_data = db::name("vs_gift_bag_detail")
->field('id,quantity,remaining_number,weight,foreign_id,gift_bag_id')
->where(['gift_bag_id' => $gift_bag_id])
->select();
if (!$gift_bag_detail_data) {
return [];
}
$gift_bag_detail_data['total_quantity'] = 0;
$gift_bag_detail_data['total_remaining'] = 0;
foreach ($gift_bag_detail_data as &$item) {
$item['total_quantity'] += $item['quantity'];
$item['total_remaining'] += $item['remaining_number'];
}
Cache::set($cacheKey, $gift_bag_detail_data, $this->cache_time);
}
return $gift_bag_detail_data;
}
/**
* 更新缓存中的奖池信息
*/
private function updateCachedGiftBagDetail($gift_bag_id, $detail_id, $decrement = 1) {
$cacheKey = "pan_gift_bag_detail".$gift_bag_id;
$gift_bag_detail_data = Cache::get($cacheKey);
if ($gift_bag_detail_data) {
foreach ($gift_bag_detail_data as &$item) {
if ($item['id'] == $detail_id) {
$item['remaining_number'] -= $decrement;
break;
}
}
Cache::set($cacheKey, $gift_bag_detail_data, $this->cache_time);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@ class Decorate extends Model
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
public $TypeArray = [1=>'头像框',2=>'坐骑',3=>'麦圈',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号'];
public $TypeArray = [1=>'头像框',2=>'坐骑',3=>'麦圈',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号',9=>'聊天气泡'];
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送',8=>'新人充值好礼'];
public function __construct($data = [])
{
@@ -412,7 +412,11 @@ class Decorate extends Model
if(empty($did)){
$reslut = '';//返回数据
}else{
$reslut = db::name('vs_decorate')->where('did', $did)->value('play_image');
if($type == 9){
$reslut = db::name('vs_decorate')->where('did', $did)->value('base_image');
}else{
$reslut = db::name('vs_decorate')->where('did', $did)->value('play_image');
}
}
}
return $reslut;

View File

@@ -72,6 +72,7 @@ class GiveGift extends Model
$FromUserInfo = db::name('user')->where('id',$uid)->field('id as user_id,nickname,avatar,sex')->find();
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($uid);//财富图标
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($uid);//魅力图标
$FromUserInfo['chat_bubble'] = model('Decorate')->user_decorate_detail($uid,9);//聊天气泡
//送给一人礼物的总价格(扣除用户的数额)
$gift_price = $gift_info['gift_price'] * $num;
@@ -449,7 +450,7 @@ class GiveGift extends Model
'FromUserInfo' => $FromUserInfo,
'ToUserInfo' => $ToUserInfo,
'GiftInfo' => $gift_inf,
'GiftNum' => $count,
'gift_num' => $count,
'text' => null
];
@@ -503,7 +504,7 @@ class GiveGift extends Model
'FromUserInfo' => $FromUserInfo,
'ToUserInfo' => $ToUserInfo,
'GiftInfo' => $gift_info,
'GiftNum' => $num,
'gift_num' => $num,
'text' => $text
];
//聊天室推送系统消息
@@ -616,6 +617,7 @@ class GiveGift extends Model
$FromUserInfo = db::name('user')->where('id',$uid)->field('id as user_id,nickname,avatar,sex')->find();
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($uid);//财富图标
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($uid);//魅力图标
$FromUserInfo['chat_bubble'] = model('Decorate')->user_decorate_detail($uid,9);//聊天气泡
//送给一人礼物的总价格(扣除用户的数额)
$gift_price = $gift_info['gift_price'] * $num;
@@ -887,7 +889,7 @@ class GiveGift extends Model
'FromUserInfo' => $FromUserInfo,
'ToUserInfo' => $ToUserInfo,
'GiftInfo' => $gift_info,
'GiftNum' => $num,
'gift_num' => $num,
'text' => $text
];
//聊天室推送系统消息

View File

@@ -29,6 +29,7 @@ class Guild extends Model
->where(['is_show'=>1,'delete_time'=>0])
->where($where)
->page($page, $page_limit)
->order('num desc')
->select();
$count = Db::name('vs_guild')
->where(['is_show'=>1,'delete_time'=>0])
@@ -757,7 +758,7 @@ class Guild extends Model
* 工会流水查询
* @return array
*/
public function get_guild_transaction($guild_id,$start_time=0,$end_time=0,$page=1,$page_limit=20){
public function get_guild_transaction($guild_id,$seach_start_time,$seach_end_time,$page,$page_limit){
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'delete_time'=>0])->find();
if(empty($guild_info)){
return ['code' => 0, 'msg' => '公会不存在!', 'data' => null];
@@ -766,6 +767,8 @@ class Guild extends Model
$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();
@@ -787,7 +790,7 @@ class Guild extends Model
}
//查询工会所有房间流水
$list = db::name('vs_guild_user')->where(['guild_id'=>$guild_id,'delete_time'=>0,'status'=>1,'room_id'=>['<>',0]])
->order('coin desc')
->order('id asc')
->page($page, $page_limit)
->select();
@@ -795,6 +798,8 @@ 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();

View File

@@ -202,6 +202,7 @@ class Login extends Model
$return_res[0]['mobile'] = $user_info['mobile'];
$return_res[0]['icon'][0] = model('UserData')->user_wealth_icon($user_info['id']);//财富图标
$return_res[0]['icon'][1] = model('UserData')->user_charm_icon($user_info['id']);//魅力图标
$return_res[0]['chat_bubble'] = model('Decorate')->user_decorate_detail($user_info['user_id'],9);//聊天气泡
$isAuth = 0;
if($user_info['mobile']){

View File

@@ -849,7 +849,7 @@ class Room extends Model
$friend = null;
}
$xlh_info['xlh_info'] = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
$xlh_info['xlh_info'] = model('api/BlindBoxTurntableGift')->get_user_xlh_info($room_id);
$open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
if($open_time > 0){
if($open_time <= time()){
@@ -1815,7 +1815,7 @@ class Room extends Model
$user_in_room = db::name('vs_room_visitor')->where(['room_id' => $room_id,'user_id' => $user_id])->find();
if(!$user_in_room){
// return ['code' => 0, 'msg' => '您已不在此房间', 'data' => null];
return ['code' => 0, 'msg' => '', 'data' => null];
// return ['code' => 0, 'msg' => '', 'data' => null];
}
$room = db::name('vs_room')->where(['id' => $room_id])->find();
$song_list = null;
@@ -2023,7 +2023,7 @@ class Room extends Model
$friend = null;
}
$xlh_info['xlh_info'] = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
$xlh_info['xlh_info'] = model('api/BlindBoxTurntableGift')->get_user_xlh_info($room_id);
$open_time = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('open_time');
if($open_time > 0){
if($open_time <= time()){

View File

@@ -0,0 +1,67 @@
<?php
namespace app\api\model;
use app\common\controller\Push;
use think\Cache;
use think\Db;
use think\Model;
class RoomEmoji extends Model
{
protected $table = 'vs_room_emoji';
protected $table_type = 'vs_room_emoji_type';
private $redis;
public function __construct()
{
parent::__construct();
$this->redis = \think\Cache::store('redis')->handler();
}
//获取房间表情包类型
public function getRoomEmojiType(){
$list = db($this->table_type)->field('id,type_name')->where(['status'=>1,'deletetime'=>0])->select();
return ['code' => 1, 'msg' => '创建成功', 'data' => $list];
}
//获取房间表情包
public function getRoomEmoji($type_id=0,$pid=0, $isTree = false){
$where = [];
if($type_id){
$where['type_id'] = $type_id;
}
if($pid!=""){
$where['pid'] = $pid;
}
$list = db($this->table)
->field('id,pid,type_id,name,image,animate_image')
->where(['status'=>1,'deletetime'=>0])
->where($where)
->order('sort desc,id desc')
->select();
if ($isTree && !empty($list) && empty($pid)) {
$list = $this->buildTree($list);
}
return ['code' => 1, 'msg' => '成功', 'data' => $list];
}
/**
* 将扁平数据转换为树状结构
* @param array $data 数据列表
* @param int $pid 父级ID
* @return array
*/
private function buildTree($data, $pid = 0)
{
$tree = [];
foreach ($data as $item) {
if ($item['pid'] == $pid) {
$children = $this->buildTree($data, $item['id']);
if (!empty($children)) {
$item['children'] = $children;
}
$tree[] = $item;
}
}
return $tree;
}
}

View File

@@ -51,7 +51,7 @@ class RoomHourRanking extends Model
foreach ($profit as &$v) {
$v['total_price'] = $v['total_price'] * get_system_config_value('coin_charm_exp');
if($v['room_id'] > 0 && $is_open_xlh == 1){
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']);
$xlh_status = model('api/BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']);
$v['xlh_status'] = $xlh_status['xlh_status'];
}else{
$v['xlh_status'] = 0;

View File

@@ -287,7 +287,7 @@ class RoomPk extends Model
'a.is_show_room' => 1,
'b.pit_number' => 9,
'b.user_id' => ['<>',0],
'a.type_id' => ['in',[1,3,4]],
'a.type_id' => ['in',[1,3,4,8]],
'a.label_id' => 1,
];

View File

@@ -147,6 +147,7 @@ class User extends Model
}
//头像装扮
$user_info['dress'] = model('Decorate')->user_decorate_detail($user_info['user_id'],1);
$user_info['chat_bubble'] = model('Decorate')->user_decorate_detail($user_info['user_id'],9);//聊天气泡
$user_info['auth'] = db::name('user_auth')->where(['mobile' => $user_info['mobile'],'is_real' => 1])->find() ? 1 : 0;
//是否可以发布动态
@@ -326,6 +327,8 @@ class User extends Model
$user_info['age'] = getAge($user_info['birthday']);
//头像装扮
$user_info['dress'] = model('Decorate')->user_decorate_detail($user_info['user_id'],1);
//聊天泡
$user_info['chat_bubble'] = model('Decorate')->user_decorate_detail($user_info['user_id'],9);//聊天气泡
//记录用户访问记录
if($from_uid != $uid){

View File

@@ -207,6 +207,7 @@ class UserWithdrawal extends Model
$withdraw_list = db::name('vs_user_withdrawal')
->where($where)
->page($page,$page_limit)
->order('createtime desc')
->select();
$return_data = [];
foreach ($withdraw_list as $key=>$value){

View File

@@ -125,7 +125,7 @@ class UserWallet extends Model
return isset($status[$value]) ? $status[$value] : '';
}
public static function ChangeTypeLable($type)
public static function ChangeTypeLable($type="")
{
$status = [
self::OPERATION_SYSTEM => '系统调节',
@@ -163,7 +163,12 @@ class UserWallet extends Model
self::RED_PACKET_LEFT_COIN => '红包剩余退回(金币)',
self::RED_PACKET_LEFT_DIAMOND => '红包剩余退回(钻石)',
];
return $status[$type] ?? '';
if($type){
return $status[$type] ?? '';
}else{
return $status;
}
}
/**
@@ -269,10 +274,19 @@ class UserWallet extends Model
/*
* 用户资金变动日志
*/
public function money_change_log($user_id, $money_type=0, $page=0,$page_limit=30){
public function money_change_log($user_id,$seach, $money_type=0, $page=0,$page_limit=30){
if($money_type){
$where['money_type'] =$money_type;
}
if($seach['stime']){
$where['createtime'] = ['>=',strtotime($seach['stime'])];
}
if($seach['etime']){
$where['createtime'] = ['<=',strtotime($seach['etime'])];
}
if($seach['change_type']){
$where['change_type'] =$seach['change_type'];
}
$log['count'] = Db::name('vs_user_money_log')->where($where)->where('user_id',$user_id)->count();
$log_select = Db::name('vs_user_money_log')
->where($where)
@@ -306,4 +320,11 @@ class UserWallet extends Model
}
return $log;
}
/*
* 获取用户资金类型
*/
public function getChangeTypeLableList(){
return $this->ChangeTypeLable();
}
}

View File

@@ -145,7 +145,7 @@ class PerformPerSecond
continue;
}
}
if($value['yun_order_status'] == 5077){
if(in_array($value['yun_order_status'],[261,5077])){
continue;
}
echo "提现订单查询:".$value['order_sn']."\n";
@@ -160,7 +160,7 @@ class PerformPerSecond
'updatetime' => time(),
'yun_order_status' => $result['data']['code'],
// 'personal_tax_rate' => $result['personal_tax_rate'] ?? 0,
'received_tax_amount' => $result['received_tax_amount'] ?? 0,
'received_tax_amount' => $result['data']['received_tax_amount'] ?? 0,
]);
}else{
db::name('vs_user_withdrawal')->where('order_sn',$value['order_sn'])->update([
@@ -170,7 +170,7 @@ class PerformPerSecond
'updatetime' => time(),
'yun_order_status' => $result['data']['code'],
// 'personal_tax_rate' => $result['personal_tax_rate'] ?? 0,
'received_tax_amount' => $result['received_tax_amount'] ?? 0,
'received_tax_amount' => $result['data']['received_tax_amount'] ?? 0,
]);
if(in_array($result['data']['code'],[5077,261]) && $value['yun_order_status'] == null){
// if($result['data']['code']==5077 && $value['yun_order_status'] == null){

View File

@@ -205,6 +205,7 @@ class YunPay
$request->setRequestID($request_id);
$response = $this->paymentClient->getOrder($request);
if ($response->isSuccess()) {
$tax_detail = $response->getData()->getTaxDetail();//获取税详情
// if(!empty($response->getData()->getTaxDetail())){
// $personal_tax_rate = $response->getData()->getTaxDetail()->getPersonalTaxRate();
// }else{
@@ -216,7 +217,7 @@ class YunPay
'code' => $response->getData()->getStatusDetail(),
'msg' => $response->getData()->getStatusMessage(),
// 'personal_tax_rate' => $personal_tax_rate,
'received_tax_amount' => $response->getData()->getReceivedTaxAmount()
'received_tax_amount' => $tax_detail['user_received_personal_tax'] ?? 0
]];
}else{
@@ -224,7 +225,7 @@ class YunPay
'code' => $response->getData()->getStatusDetail(),
'msg' => $response->getData()->getStatusDetailMessage(),
// 'personal_tax_rate' => $personal_tax_rate,
'received_tax_amount' => $response->getData()->getReceivedTaxAmount()
'received_tax_amount' => $tax_detail['user_received_personal_tax'] ?? 0
]];
}