Compare commits
10 Commits
f259bab4ed
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 07672be58b | |||
| 684771b746 | |||
| 57b89a7ed7 | |||
| 6527bf63a3 | |||
| d34b947a91 | |||
| 49e620d9aa | |||
| 556c42cc72 | |||
| b2d1106e0b | |||
| 540dff822d | |||
| 7a9b1ef9cf |
@@ -3,6 +3,7 @@
|
|||||||
namespace app\adminapi\controller;
|
namespace app\adminapi\controller;
|
||||||
|
|
||||||
use app\common\controller\adminApi;
|
use app\common\controller\adminApi;
|
||||||
|
use app\common\library\GiftTableManager;
|
||||||
use think\Controller;
|
use think\Controller;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Session;
|
use think\Session;
|
||||||
@@ -479,8 +480,16 @@ class Guild extends adminApi
|
|||||||
$page = input('page', 1);
|
$page = input('page', 1);
|
||||||
$page_limit = input('page_limit', 30);
|
$page_limit = input('page_limit', 30);
|
||||||
$guild_id = input('guild_id', 0);
|
$guild_id = input('guild_id', 0);
|
||||||
$search_stime_str = input('search_stime','');
|
$firstDay = date('Y-m-01');
|
||||||
$search_etime_str = input('search_etime','');
|
$lastDay = date('Y-m-t 23:59:59');
|
||||||
|
$search_stime_str = input('search_stime',$firstDay);
|
||||||
|
$search_etime_str = input('search_etime',$lastDay);
|
||||||
|
if(empty($search_stime_str)){
|
||||||
|
$search_stime_str = $firstDay;
|
||||||
|
}
|
||||||
|
if(empty($search_etime_str)){
|
||||||
|
$search_etime_str = $lastDay;
|
||||||
|
}
|
||||||
$room_id = input('room_id', 0);
|
$room_id = input('room_id', 0);
|
||||||
$where=['a.status'=>1];
|
$where=['a.status'=>1];
|
||||||
$where=['a.room_id'=>['>',0]];
|
$where=['a.room_id'=>['>',0]];
|
||||||
@@ -498,6 +507,7 @@ class Guild extends adminApi
|
|||||||
->join('vs_room b', 'a.room_id = b.id', 'left')
|
->join('vs_room b', 'a.room_id = b.id', 'left')
|
||||||
->where(['a.guild_id'=>$guild_id])->where($where)->count();
|
->where(['a.guild_id'=>$guild_id])->where($where)->count();
|
||||||
$list = db::name($this->table_guild_user)->alias('a')
|
$list = db::name($this->table_guild_user)->alias('a')
|
||||||
|
->field('a.*,b.room_name,b.room_number')
|
||||||
->join('vs_room b', 'a.room_id = b.id', 'left')
|
->join('vs_room b', 'a.room_id = b.id', 'left')
|
||||||
->where(['a.guild_id'=>$guild_id])->where($where)
|
->where(['a.guild_id'=>$guild_id])->where($where)
|
||||||
// ->page($page, $page_limit)
|
// ->page($page, $page_limit)
|
||||||
@@ -507,6 +517,49 @@ class Guild extends adminApi
|
|||||||
}
|
}
|
||||||
$rum_lists = [];
|
$rum_lists = [];
|
||||||
//总流水
|
//总流水
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
strtotime($search_stime_str),
|
||||||
|
strtotime($search_etime_str)
|
||||||
|
);
|
||||||
|
|
||||||
|
$room_consumption =[];
|
||||||
|
if($tables){
|
||||||
|
foreach ($list as $vs) {
|
||||||
|
$search_stime = $search_stime_str;
|
||||||
|
$search_etime = $search_etime_str;
|
||||||
|
if($search_stime!=""){
|
||||||
|
if($vs['apply_time'] && strtotime($search_stime) < $vs['apply_time']) {
|
||||||
|
$search_stime = date('Y-m-d H:i:s',$vs['apply_time']);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$search_stime = date('Y-m-d H:i:s',$vs['apply_time']);
|
||||||
|
}
|
||||||
|
if($search_etime!=""){
|
||||||
|
if($vs['quit_time'] && (strtotime($search_etime) > $vs['quit_time'])){
|
||||||
|
$search_etime = date('Y-m-d H:i:s',$vs['quit_time']);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if($vs['quit_time']){
|
||||||
|
$search_etime = date('Y-m-d H:i:s',$vs['quit_time']);
|
||||||
|
}else{
|
||||||
|
$search_etime = date('Y-m-d H:i:s',time());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$all_total_price =0;
|
||||||
|
$total_price = 0;
|
||||||
|
foreach ($tables as $table_name) {
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)
|
||||||
|
->where(['from_id' => $vs['room_id'], 'from' => 2])
|
||||||
|
->where(['createtime' => ['between',[strtotime($search_stime),strtotime($search_etime)]]])
|
||||||
|
->sum('total_price');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
$room_consumption[$vs['id']] = $all_total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$total_consumption = 0;
|
$total_consumption = 0;
|
||||||
foreach ($list as $k=>$v){
|
foreach ($list as $k=>$v){
|
||||||
$search_stime = $search_stime_str;
|
$search_stime = $search_stime_str;
|
||||||
@@ -539,8 +592,9 @@ class Guild extends adminApi
|
|||||||
$rum_lists[$k]['room_name']=$room_info['room_name']?? '';
|
$rum_lists[$k]['room_name']=$room_info['room_name']?? '';
|
||||||
$rum_lists[$k]['room_cover']=$room_info['room_cover']?? '';
|
$rum_lists[$k]['room_cover']=$room_info['room_cover']?? '';
|
||||||
//房间流水
|
//房间流水
|
||||||
$rum_lists[$k]['consumption']= model('Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime);
|
// $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']);
|
$rum_lists[$k]['consumption']= $room_consumption[$v['id']]??0;
|
||||||
|
$rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['apply_time']);
|
||||||
$total_consumption += $rum_lists[$k]['consumption'];
|
$total_consumption += $rum_lists[$k]['consumption'];
|
||||||
//幸运币统计
|
//幸运币统计
|
||||||
$where_lucky = [];
|
$where_lucky = [];
|
||||||
|
|||||||
@@ -676,19 +676,43 @@ class Room extends adminApi
|
|||||||
if($type == 2){
|
if($type == 2){
|
||||||
$start_time = strtotime(date('Y-m-d'));
|
$start_time = strtotime(date('Y-m-d'));
|
||||||
$end_time = $start_time + 86400;
|
$end_time = $start_time + 86400;
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$start_time,
|
||||||
|
$end_time
|
||||||
|
);
|
||||||
}elseif ($type == 3){
|
}elseif ($type == 3){
|
||||||
$start_time = strtotime(date('Y-m-d',strtotime('-1 day')));
|
$start_time = strtotime(date('Y-m-d',strtotime('-1 day')));
|
||||||
$end_time = $start_time + 86400;
|
$end_time = $start_time + 86400;
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$start_time,
|
||||||
|
$end_time
|
||||||
|
);
|
||||||
}elseif ($type == 4){
|
}elseif ($type == 4){
|
||||||
$start_time = strtotime(date('Y-m-d',strtotime('-2 day')));
|
$start_time = strtotime(date('Y-m-d',strtotime('-2 day')));
|
||||||
$end_time = $start_time + 86400;
|
$end_time = $start_time + 86400;
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$start_time,
|
||||||
|
$end_time
|
||||||
|
);
|
||||||
}elseif ($type == 1){
|
}elseif ($type == 1){
|
||||||
$start_time = 1748676768;//2025-06-00 15:32:48
|
$start_time = 1748676768;//2025-06-00 15:32:48
|
||||||
$end_time = time();
|
$end_time = time();
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$start_time,
|
||||||
|
$end_time
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
$all_total_price =0;
|
||||||
$profit = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price');
|
if($tables){
|
||||||
return $profit;
|
foreach ($tables as $table_name){
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)->where('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $all_total_price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\adminapi\model;
|
namespace app\adminapi\model;
|
||||||
|
|
||||||
|
use app\common\library\GiftTableManager;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
use think\Session;
|
use think\Session;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
@@ -70,11 +71,30 @@ class Room extends Model
|
|||||||
/*
|
/*
|
||||||
* 查询房间流水
|
* 查询房间流水
|
||||||
*/
|
*/
|
||||||
|
// public function getRoomFlow($room_id,$stime='',$etime=''){
|
||||||
|
// $give_where = [];
|
||||||
|
// $give_where['room_id'] = $room_id;
|
||||||
|
//// $give_where['from'] = ["in",[2,3,6]];
|
||||||
|
//// $give_where['from'] = 2;
|
||||||
|
// if(!empty($stime)){
|
||||||
|
// $give_where['createtime'] = ['>=',strtotime($stime)];
|
||||||
|
// }
|
||||||
|
// if(!empty($etime)){
|
||||||
|
// $give_where['createtime'] = ['<',strtotime($etime)];
|
||||||
|
// }
|
||||||
|
// if(!empty($stime) && !empty($etime)){
|
||||||
|
//// $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
||||||
|
// $give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]];
|
||||||
|
// }
|
||||||
|
// $total_price = db::name('vs_guild_flow')->where($give_where)
|
||||||
|
// ->sum('flow_price');
|
||||||
|
// return $total_price;
|
||||||
|
// }
|
||||||
public function getRoomFlow($room_id,$stime='',$etime=''){
|
public function getRoomFlow($room_id,$stime='',$etime=''){
|
||||||
$give_where = [];
|
$give_where = [];
|
||||||
$give_where['room_id'] = $room_id;
|
$give_where['from'] = $room_id;
|
||||||
// $give_where['from'] = ["in",[2,3,6]];
|
// $give_where['from'] = ["in",[2,3,6]];
|
||||||
// $give_where['from'] = 2;
|
$give_where['from'] = 2;
|
||||||
if(!empty($stime)){
|
if(!empty($stime)){
|
||||||
$give_where['createtime'] = ['>=',strtotime($stime)];
|
$give_where['createtime'] = ['>=',strtotime($stime)];
|
||||||
}
|
}
|
||||||
@@ -85,8 +105,23 @@ class Room extends Model
|
|||||||
// $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
// $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
||||||
$give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]];
|
$give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]];
|
||||||
}
|
}
|
||||||
$total_price = db::name('vs_guild_flow')->where($give_where)
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
->sum('flow_price');
|
strtotime($stime),
|
||||||
|
strtotime($etime)
|
||||||
|
);
|
||||||
|
$all_total_price =0;
|
||||||
|
if($tables){
|
||||||
|
foreach ($tables as $table_name){
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)
|
||||||
|
->where($give_where)
|
||||||
|
->sum('total_price');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$total_price = $all_total_price;
|
||||||
return $total_price;
|
return $total_price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,17 +11,21 @@ class Sign extends BaseCom
|
|||||||
public function sign_coin_list()
|
public function sign_coin_list()
|
||||||
{
|
{
|
||||||
$sign_id = input('sign_id', 0);//场次id
|
$sign_id = input('sign_id', 0);//场次id
|
||||||
$room_sign = db::name('vs_room_sign')->where('id', $sign_id)->field('sign_user_id,room_id')->find();
|
$room_sign = db::name('vs_room_sign')->where('id', $sign_id)->field('sign_user_id,room_id,market_value')->find();
|
||||||
if (!$room_sign) {
|
if (!$room_sign) {
|
||||||
return v(0, '参数错误');
|
return v(0, '参数错误');
|
||||||
}
|
}
|
||||||
//获取出价最高用户
|
//获取出价最高用户
|
||||||
$sign_user = db::name('vs_user_sign_auction')->where(['room_id' => $room_sign['room_id'],'sign_time' => $sign_id,'type' => 0])->order('sign_value desc')->field('id,user_id,sign_value')->find();
|
$sign_user = db::name('vs_user_sign_auction')
|
||||||
|
->field('id,user_id,sign_value')
|
||||||
|
->where(['room_id' => $room_sign['room_id'],'sign_time' => $sign_id,'type' => 0])
|
||||||
|
->order('sign_value desc')
|
||||||
|
->find();
|
||||||
if($sign_user){
|
if($sign_user){
|
||||||
$market_value = $sign_user['sign_value'];
|
$market_value = $sign_user['sign_value'];
|
||||||
}else{
|
}else{
|
||||||
//获取当前用户的身价
|
//获取当前用户的身价
|
||||||
$market_value = db::name('user')->where('id', $room_sign['sign_user_id'])->value('market_value');
|
$market_value = $room_sign['market_value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sign_market_value = get_system_config_value('sign_market_value');
|
$sign_market_value = get_system_config_value('sign_market_value');
|
||||||
|
|||||||
@@ -368,14 +368,36 @@ class GiveGift extends Model
|
|||||||
//收礼人认证歌手等级升级
|
//收礼人认证歌手等级升级
|
||||||
model('api/SingerSong')->singerLevelUp($to_id,$gift_price);
|
model('api/SingerSong')->singerLevelUp($to_id,$gift_price);
|
||||||
|
|
||||||
//收礼人身价计算 这里的增长身价是收礼物的价值按比率产生的身价值 身价=收礼产生的身价+签约时的溢价
|
//收礼人身价计算 这里的增长身价是收礼物的价值按比率产生的身价值
|
||||||
$coin_market_value = get_system_config_value('coin_market_value');
|
//单笔收礼大于100,四舍五入取整,不累计在这,单笔小于100,累计到100计算一次
|
||||||
|
$coin_market_value = get_system_config_value('coin_market_value');//身价比例
|
||||||
if(!$coin_market_value){
|
if(!$coin_market_value){
|
||||||
$coin_market_value = '100,1';
|
$coin_market_value = '100,1';//默认
|
||||||
}
|
}
|
||||||
$coin_market_values = explode(',', $coin_market_value);
|
$coin_market_values = explode(',', $coin_market_value);
|
||||||
$change_value = ceil($gift_price / ($coin_market_values[0] ?? 100) * ($coin_market_values[1] ?? 1));
|
$coin_value = $coin_market_values[0] ?? 100;
|
||||||
model('api/MarketValue')->change($to_id,$change_value,0);
|
$market_value = $coin_market_values[1] ?? 1;
|
||||||
|
|
||||||
|
if($gift_price >= 100){//单笔收礼大于100,四舍五入取整
|
||||||
|
$change_value = round($gift_price / $coin_value) * $market_value;
|
||||||
|
model('api/MarketValue')->change($to_id,$change_value,0);
|
||||||
|
}else{//单笔小于100,累计到100计算一次
|
||||||
|
//获取用户累计的金币数
|
||||||
|
$accum_coin = db::name('user_data')->where(['user_id'=>$to_id])->value('market_value');
|
||||||
|
if(($accum_coin + $gift_price) >= 100){//累计到100计算一次
|
||||||
|
$change_value = floor(($accum_coin + $gift_price) / $coin_value) * $market_value;
|
||||||
|
$change_market_value = model('api/MarketValue')->change($to_id,$change_value,0);
|
||||||
|
if($change_market_value['code'] == 1){
|
||||||
|
//取余
|
||||||
|
$remain_coin = ($accum_coin + $gift_price) % $coin_value;
|
||||||
|
//修改数据
|
||||||
|
db::name('user_data')->where(['user_id'=>$to_id])->update(['market_value'=>$remain_coin]);
|
||||||
|
}
|
||||||
|
}else{//累计
|
||||||
|
db::name('user_data')->where(['user_id'=>$to_id])->update(['market_value'=>$accum_coin + $gift_price]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//收礼人是否被签约 给上级返佣
|
//收礼人是否被签约 给上级返佣
|
||||||
model('api/Sign')->check_sign_gift($to_id,$gid,$num,$gift_price,$from_id);
|
model('api/Sign')->check_sign_gift($to_id,$gid,$num,$gift_price,$from_id);
|
||||||
@@ -1041,6 +1063,9 @@ class GiveGift extends Model
|
|||||||
*/
|
*/
|
||||||
public function give_gift($uid,$to_uid,$gid,$num,$from_type,$type,$from_id = 0,$pit_number = 0,$change_type = 0,$ext = [])
|
public function give_gift($uid,$to_uid,$gid,$num,$from_type,$type,$from_id = 0,$pit_number = 0,$change_type = 0,$ext = [])
|
||||||
{
|
{
|
||||||
|
$res = model("api/SendGift")->send_gift($uid,$to_uid,$gid,$num,$num,$from_id);
|
||||||
|
return $res;
|
||||||
|
|
||||||
return ['code' => 0, 'msg' => '送礼失败,请更新APP!', 'data' => null];
|
return ['code' => 0, 'msg' => '送礼失败,请更新APP!', 'data' => null];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,39 @@ class GiveGiftBases extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间送礼统计总数
|
||||||
|
*/
|
||||||
|
public function getRoomStatistics_total($fromId, $startTime, $endTime)
|
||||||
|
{
|
||||||
|
if (!$fromId) {
|
||||||
|
$this->error('房间ID不能为空');
|
||||||
|
}
|
||||||
|
|
||||||
|
$where = ['from_id' => $fromId];
|
||||||
|
$options = [
|
||||||
|
'start_time' => $startTime,
|
||||||
|
'end_time' => $endTime,
|
||||||
|
];
|
||||||
|
|
||||||
|
// 统计房间总数据
|
||||||
|
$totalStats = $this->giftModel->getGiftStatistics($where, $options);
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'room_id' => $fromId,
|
||||||
|
'time_range' => [
|
||||||
|
'start_time' => $startTime,
|
||||||
|
'end_time' => $endTime,
|
||||||
|
'start_date' => date('Y-m-d H:i:s', $startTime),
|
||||||
|
'end_date' => date('Y-m-d H:i:s', $endTime),
|
||||||
|
],
|
||||||
|
'total_stats' => $totalStats,
|
||||||
|
];
|
||||||
|
|
||||||
|
// $this->success('获取成功', $result);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户送礼统计
|
* 用户送礼统计
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace app\api\model;
|
namespace app\api\model;
|
||||||
|
|
||||||
use app\common\controller\Push;
|
use app\common\controller\Push;
|
||||||
|
use app\common\library\GiftTableManager;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
@@ -432,13 +433,37 @@ class Room extends Model
|
|||||||
$week = strtotime(date('Y-m-d', strtotime('this week Monday')));
|
$week = strtotime(date('Y-m-d', strtotime('this week Monday')));
|
||||||
//本周的房间流水
|
//本周的房间流水
|
||||||
if($room_type == 6){
|
if($room_type == 6){
|
||||||
$total_transaction = db::name('vs_give_gift')
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
->where(['from_id' => $room_id, 'from' =>6, 'createtime' => ['between', [$week, time()]]])
|
$week,
|
||||||
->sum('total_price');
|
time()
|
||||||
|
);
|
||||||
|
$all_total_price =0;
|
||||||
|
if($tables){
|
||||||
|
foreach ($tables as $table_name){
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)->where(['from_id' => $room_id, 'from' =>6, 'createtime' => ['between', [$week, time()]]])->sum('total_price');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$total_transaction = $all_total_price;
|
||||||
}else{
|
}else{
|
||||||
$total_transaction = db::name('vs_give_gift')
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
->where(['from_id' => $room_id, 'from' =>2, 'createtime' => ['between', [$week, time()]]])
|
$week,
|
||||||
->sum('total_price');
|
time()
|
||||||
|
);
|
||||||
|
$all_total_price =0;
|
||||||
|
if($tables){
|
||||||
|
foreach ($tables as $table_name){
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)->where(['from_id' => $room_id, 'from' =>2, 'createtime' => ['between', [$week, time()]]])->sum('total_price');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$total_transaction = $all_total_price;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ss = 0;
|
$ss = 0;
|
||||||
@@ -515,7 +540,7 @@ class Room extends Model
|
|||||||
$params['end_time'] = $etime;
|
$params['end_time'] = $etime;
|
||||||
$params['page'] = $page;
|
$params['page'] = $page;
|
||||||
$params['limit'] = $page_limit;
|
$params['limit'] = $page_limit;
|
||||||
$res = model('GiveGiftBases')->getGiftRecords($params);
|
$res = model('api/GiveGiftBases')->getGiftRecords($params);
|
||||||
$list = $res['data'];
|
$list = $res['data'];
|
||||||
$list_data = [];
|
$list_data = [];
|
||||||
|
|
||||||
@@ -551,7 +576,9 @@ class Room extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
//房间总流水(2026年以后的)
|
//房间总流水(2026年以后的)
|
||||||
$total_amount = model('api/RoomDailyIncome')->getIncomeByPeriod($room_id, $stime, $etime);
|
// $total_amount = model('api/RoomDailyIncome')->getIncomeByPeriod($room_id, $stime, $etime);
|
||||||
|
$total_amount = model('api/GiveGiftBases')->getRoomStatistics_total($room_id, strtotime($stime), strtotime($etime));
|
||||||
|
var_dump($total_amount);exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//房主总收益
|
//房主总收益
|
||||||
@@ -3262,15 +3289,17 @@ class Room extends Model
|
|||||||
//开启事务
|
//开启事务
|
||||||
db::startTrans();
|
db::startTrans();
|
||||||
if($money > 0){
|
if($money > 0){
|
||||||
$user_money = db::name('user_wallet')->where('user_id',$uid)->value('coin');
|
$user_money = db::name('user_wallet_coin')->where('user_id',$uid)->value('coin');
|
||||||
if($user_money < $money){
|
if($user_money < $money){
|
||||||
return ['code' => 0, 'msg' => '您的余额不足,请充值', 'data' => null];
|
return ['code' => 0, 'msg' => '您的余额不足,请充值', 'data' => null];
|
||||||
}
|
}
|
||||||
$da = db::name('user_wallet')->where('user_id',$uid)->setDec('coin',$money);
|
//扣除用户金币并记录日志(酒吧房下的小黑屋 记录记在所属酒吧房)
|
||||||
if(!$da){
|
$wallet_update = model('api/UserWallet')->change_user_cion_log($uid,$money,0,24,'删除关系扣除余额');
|
||||||
db::rollback();
|
if(!$wallet_update){
|
||||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '网络错误-1', 'data' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$da = db::name('vs_room_auction_relation')->where('id',$id)->update(['delete_time' => time()]);
|
$da = db::name('vs_room_auction_relation')->where('id',$id)->update(['delete_time' => time()]);
|
||||||
@@ -3278,20 +3307,7 @@ class Room extends Model
|
|||||||
db::rollback();
|
db::rollback();
|
||||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||||
}
|
}
|
||||||
//记录扣除用户余额
|
|
||||||
$res5 =db::name('vs_user_money_log')->insert([
|
|
||||||
'user_id' => $uid,
|
|
||||||
'change_type' => 24,
|
|
||||||
'money_type' => 1,
|
|
||||||
'change_value' => $money,
|
|
||||||
'from_id' => $id,
|
|
||||||
'remarks' => '删除关系扣除余额',
|
|
||||||
'createtime' => time(),
|
|
||||||
]);
|
|
||||||
if(!$res5) {
|
|
||||||
Db::rollback();
|
|
||||||
return ['code' => 0, 'msg' => '记录扣除用户余额失败!', 'data' => null];
|
|
||||||
}
|
|
||||||
db::commit();
|
db::commit();
|
||||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -431,6 +431,13 @@ class RoomPk extends Model
|
|||||||
];
|
];
|
||||||
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
||||||
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
||||||
|
$Victory_user_ids = db::name('vs_room_ppt')
|
||||||
|
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
|
||||||
|
->column('user_id');
|
||||||
|
$Failure_user_ids = db::name('vs_room_ppt')
|
||||||
|
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
|
||||||
|
->column('user_id');
|
||||||
|
$Draw_user_ids = [];
|
||||||
}elseif($pk_info['create_value_a'] < $pk_info['receive_value_b']){
|
}elseif($pk_info['create_value_a'] < $pk_info['receive_value_b']){
|
||||||
db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['shibaifang_id' => $pk_info['create_user_id']]);
|
db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['shibaifang_id' => $pk_info['create_user_id']]);
|
||||||
$texta = [
|
$texta = [
|
||||||
@@ -453,10 +460,17 @@ class RoomPk extends Model
|
|||||||
];
|
];
|
||||||
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
||||||
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
||||||
|
$Victory_user_ids = db::name('vs_room_ppt')
|
||||||
|
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
|
||||||
|
->column('user_id');
|
||||||
|
$Failure_user_ids = db::name('vs_room_ppt')
|
||||||
|
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
|
||||||
|
->column('user_id');
|
||||||
|
$Draw_user_ids = [];
|
||||||
}else{
|
}else{
|
||||||
db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['shibaifang_id' => -1]);
|
db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['shibaifang_id' => -1]);
|
||||||
$texta = [
|
$texta = [
|
||||||
'type' => 2,//失败
|
'type' => 2,//平局
|
||||||
'victory_name' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_name'),
|
'victory_name' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_name'),
|
||||||
'victory_cover' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_cover'),
|
'victory_cover' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_cover'),
|
||||||
'defeated_name' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_name'),
|
'defeated_name' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_name'),
|
||||||
@@ -465,7 +479,7 @@ class RoomPk extends Model
|
|||||||
'end_time' => $pk_info['end_time'] + 300,
|
'end_time' => $pk_info['end_time'] + 300,
|
||||||
];
|
];
|
||||||
$textb = [
|
$textb = [
|
||||||
'type' => 2,//胜利
|
'type' => 2,//平局
|
||||||
'victory_name' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_name'),
|
'victory_name' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_name'),
|
||||||
'victory_cover' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_cover'),
|
'victory_cover' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_cover'),
|
||||||
'defeated_name' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_name'),
|
'defeated_name' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_name'),
|
||||||
@@ -476,8 +490,21 @@ class RoomPk extends Model
|
|||||||
|
|
||||||
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
||||||
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
||||||
|
$Victory_user = db::name('vs_room_ppt')
|
||||||
|
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
|
||||||
|
->column('user_id');
|
||||||
|
$Failure_user = db::name('vs_room_ppt')
|
||||||
|
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
|
||||||
|
->column('user_id');
|
||||||
|
|
||||||
|
$Draw_user_ids = array_merge($Victory_user, $Failure_user);
|
||||||
|
$Victory_user_ids = [];
|
||||||
|
$Failure_user_ids = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//任务:35-每日参与PK
|
||||||
|
model('api/Tasks')->tasks_complete($Victory_user_ids,$Failure_user_ids,$Draw_user_ids,35);
|
||||||
|
|
||||||
}elseif($type == 2){
|
}elseif($type == 2){
|
||||||
$text = [
|
$text = [
|
||||||
'type' => 1,//正常断开
|
'type' => 1,//正常断开
|
||||||
|
|||||||
@@ -117,7 +117,11 @@ class Sign extends Model
|
|||||||
db::name('vs_room')->where(['id' => $room_id])->inc('hot_value', $gift_totalaa)->inc('today_hot_value', $gift_totalaa)->update();
|
db::name('vs_room')->where(['id' => $room_id])->inc('hot_value', $gift_totalaa)->inc('today_hot_value', $gift_totalaa)->update();
|
||||||
|
|
||||||
//获取出价最高用户
|
//获取出价最高用户
|
||||||
$sign_user = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->order('sign_value desc,id asc')->field('id,user_id,sign_value')->find();
|
$sign_user = db::name('vs_user_sign_auction')
|
||||||
|
->field('id,user_id,sign_value')
|
||||||
|
->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])
|
||||||
|
->order('sign_value desc,id asc')
|
||||||
|
->find();
|
||||||
|
|
||||||
//其他的出价退回到用户的钱包
|
//其他的出价退回到用户的钱包
|
||||||
$refund = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->select();
|
$refund = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->select();
|
||||||
@@ -185,7 +189,10 @@ class Sign extends Model
|
|||||||
return ['code' => 0, 'msg' => '该场次签约已结束', 'data' => null];
|
return ['code' => 0, 'msg' => '该场次签约已结束', 'data' => null];
|
||||||
}
|
}
|
||||||
//获取签约出价最高的
|
//获取签约出价最高的
|
||||||
$max_sign_user = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->order('sign_value desc,id asc')->find();
|
$max_sign_user = db::name('vs_user_sign_auction')
|
||||||
|
->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])
|
||||||
|
->order('sign_value desc,id asc')
|
||||||
|
->find();
|
||||||
if($max_sign_user && $max_sign_user['sign_value'] > $sign['market_value']){
|
if($max_sign_user && $max_sign_user['sign_value'] > $sign['market_value']){
|
||||||
$before_sign_user = null;
|
$before_sign_user = null;
|
||||||
$is_sign = null;
|
$is_sign = null;
|
||||||
@@ -435,17 +442,37 @@ class Sign extends Model
|
|||||||
$text['sign_value'] = $max_sign_user['sign_value'];
|
$text['sign_value'] = $max_sign_user['sign_value'];
|
||||||
model('api/Chat')->sendMsg(1092,$room_id,$text);
|
model('api/Chat')->sendMsg(1092,$room_id,$text);
|
||||||
}else{
|
}else{
|
||||||
|
//出价用户退
|
||||||
|
$refund = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->select();
|
||||||
|
if($refund){
|
||||||
|
foreach ($refund as $k => $v){
|
||||||
|
//给用户退回签约金额记录行为日志
|
||||||
|
$result2[$k] = model('api/UserWallet')->change_user_cion_log($v['user_id'],$v['sign_value'],$room_id,51,'签约失败退款');
|
||||||
|
if(!$result2[$k]){
|
||||||
|
db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||||
|
}
|
||||||
|
$result3[$k] = db::name('vs_user_sign_auction')->where('id',$v['id'])->update(['type' => 2,'refundtime' => time()]);
|
||||||
|
if(!$result3[$k]){
|
||||||
|
db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//修改房间信息
|
//修改房间信息
|
||||||
db::name('vs_room')->where('id',$room_id)->update([
|
db::name('vs_room')->where('id',$room_id)->update([
|
||||||
'sign_type' => 0,
|
'sign_type' => 0,
|
||||||
'updatetime' => time()
|
'updatetime' => time()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//修改房间签约信息
|
//修改房间签约信息
|
||||||
db::name('vs_room_sign')->where(['id' => $sign_time])
|
db::name('vs_room_sign')->where(['id' => $sign_time])
|
||||||
->update([
|
->update([
|
||||||
'sign_type' => 0,
|
'sign_type' => 0,
|
||||||
'end_time' => time()
|
'end_time' => time()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$text['text'] = '流拍';
|
$text['text'] = '流拍';
|
||||||
$text['FromUserInfo'] = null;
|
$text['FromUserInfo'] = null;
|
||||||
$text['ToUserInfo'] = null;
|
$text['ToUserInfo'] = null;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace app\cron\controller;
|
namespace app\cron\controller;
|
||||||
|
|
||||||
use app\common\controller\adminApi;
|
use app\common\controller\adminApi;
|
||||||
|
use app\common\library\GiftTableManager;
|
||||||
use think\Controller;
|
use think\Controller;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
|
|
||||||
@@ -31,92 +32,13 @@ class Subsidy
|
|||||||
* 配置:定时脚本每周一 执行
|
* 配置:定时脚本每周一 执行
|
||||||
* 配置:/cron/Subsidy/createGuildSubsidyData
|
* 配置:/cron/Subsidy/createGuildSubsidyData
|
||||||
*/
|
*/
|
||||||
// public function createGuildSubsidyData(){
|
|
||||||
// //获取上周第一天时间
|
|
||||||
// $week_start_time = strtotime('last week Monday');
|
|
||||||
// $week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last week Sunday')));
|
|
||||||
//// $week_start_time = strtotime('2025-09-29');
|
|
||||||
//// $week_end_time = strtotime('2025-09-29 23:59:59');
|
|
||||||
//
|
|
||||||
// //获取上周时间
|
|
||||||
// $time_value = date('o-W', $week_start_time);
|
|
||||||
// echo $time_value . "工会周补贴数据生成开始\n";
|
|
||||||
// //查询所有工会
|
|
||||||
// $guild_list = db::name('vs_guild')->where(['delete_time'=>0])->field('id')->select();
|
|
||||||
// $data_count = 0;
|
|
||||||
// foreach ($guild_list as $key => $value) {
|
|
||||||
// //获取所有工会房间ID
|
|
||||||
// $guild_user_data = db::name('vs_guild_user')->where('guild_id', $value['id'])->where(['apply_time'=>['>',0],'status'=>1,'room_id'=>['>',0]])->field('room_id,apply_time,quit_time')->select();
|
|
||||||
// $transaction = 0;
|
|
||||||
// foreach ($guild_user_data as $k => $v) {
|
|
||||||
// $week_start_time_seach = $week_start_time;
|
|
||||||
// $week_end_time_seach = $week_end_time;
|
|
||||||
// if($v['apply_time'] && $week_end_time_seach < $v['apply_time']){
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if($v['quit_time'] && $v['quit_time'] < $week_start_time_seach){
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if($v['apply_time'] && $week_start_time_seach < $v['apply_time']){
|
|
||||||
// $week_start_time_seach = $v['apply_time'];
|
|
||||||
// }
|
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if($transaction > 0){
|
|
||||||
// //判断是否已经生成过
|
|
||||||
// if (db::name('vs_guild_subsidy')->where(['guild_id'=>$value['id'],'week'=>$time_value])->find()) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// //获取补贴配置
|
|
||||||
// $config = db::name('vs_guild_subsidy_config')->where(['status' => 1])->order('end_amount desc')->select(); //配置查询
|
|
||||||
// if (!$config) {
|
|
||||||
// echo '补贴配置为空\n';
|
|
||||||
// die;
|
|
||||||
// }
|
|
||||||
// $subsidy_ratio = 0;
|
|
||||||
// $subsidy_amount = 0;
|
|
||||||
// foreach ($config as $k => $v) {
|
|
||||||
// if ($transaction >= $v['end_amount']) {
|
|
||||||
// $subsidy_ratio = $v['subsidy_ratio'];
|
|
||||||
// $subsidy_amount = ($transaction * ($subsidy_ratio / 100)) / get_system_config_value('rmb_coin_ratio');//转为钻石
|
|
||||||
// break; // 找到匹配项后提前退出循环
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //生成补贴数据
|
|
||||||
// $data = [
|
|
||||||
// 'guild_id' => $value['id'],
|
|
||||||
// 'week' => $time_value,
|
|
||||||
// 'start_time' => date('Y-m-d H:i:s', $week_start_time),
|
|
||||||
// 'end_time' =>date('Y-m-d H:i:s', $week_end_time),
|
|
||||||
// 'total_transaction' => $transaction,
|
|
||||||
// 'subsidy_amount' => $subsidy_amount,
|
|
||||||
// 'subsidy_ratio' => $subsidy_ratio,
|
|
||||||
// 'status' => 0,
|
|
||||||
// 'createtime' => time(),
|
|
||||||
// ];
|
|
||||||
// // echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
|
||||||
// $subsidy_id = Db::name('vs_guild_subsidy')->insertGetId($data);
|
|
||||||
// if ($subsidy_id) {
|
|
||||||
// echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
|
||||||
// $data_count++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function createGuildSubsidyData(){
|
public function createGuildSubsidyData(){
|
||||||
//获取上周第一天时间
|
//获取上周第一天时间
|
||||||
$week_start_time = strtotime('last week Monday');
|
$week_start_time = strtotime('last week Monday');
|
||||||
$week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last week Sunday')));
|
$week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last week Sunday')));
|
||||||
|
// $week_start_time = strtotime('2025-09-29');
|
||||||
|
// $week_end_time = strtotime('2025-09-29 23:59:59');
|
||||||
|
|
||||||
//获取上周时间
|
//获取上周时间
|
||||||
$time_value = date('o-W', $week_start_time);
|
$time_value = date('o-W', $week_start_time);
|
||||||
echo $time_value . "工会周补贴数据生成开始\n";
|
echo $time_value . "工会周补贴数据生成开始\n";
|
||||||
@@ -124,10 +46,51 @@ class Subsidy
|
|||||||
$guild_list = db::name('vs_guild')->where(['delete_time'=>0])->field('id')->select();
|
$guild_list = db::name('vs_guild')->where(['delete_time'=>0])->field('id')->select();
|
||||||
$data_count = 0;
|
$data_count = 0;
|
||||||
foreach ($guild_list as $key => $value) {
|
foreach ($guild_list as $key => $value) {
|
||||||
$transaction = Db::name('vs_guild_flow')
|
//获取所有工会房间ID
|
||||||
->where(['guild_id' => $value['id']])
|
$guild_user_data = db::name('vs_guild_user')->where('guild_id', $value['id'])->where(['apply_time'=>['>',0],'status'=>1,'room_id'=>['>',0]])->field('room_id,apply_time,quit_time')->select();
|
||||||
->where(['createtime' => ['between', [$week_start_time, $week_end_time]]])
|
$transaction = 0;
|
||||||
->sum('flow_price');
|
foreach ($guild_user_data as $k => $v) {
|
||||||
|
$week_start_time_seach = $week_start_time;
|
||||||
|
$week_end_time_seach = $week_end_time;
|
||||||
|
if($v['apply_time'] && $week_end_time_seach < $v['apply_time']){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if($v['quit_time'] && $v['quit_time'] < $week_start_time_seach){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if($v['apply_time'] && $week_start_time_seach < $v['apply_time']){
|
||||||
|
$week_start_time_seach = $v['apply_time'];
|
||||||
|
}
|
||||||
|
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||||
|
$week_end_time_seach = $v['quit_time'];
|
||||||
|
}
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$week_start_time_seach,
|
||||||
|
$week_end_time_seach
|
||||||
|
);
|
||||||
|
$all_total_price =0;
|
||||||
|
if($tables){
|
||||||
|
foreach ($tables as $table_name){
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)
|
||||||
|
->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');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$transaction_one = $all_total_price;
|
||||||
|
$transaction += $transaction_one;
|
||||||
|
|
||||||
|
// $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;
|
||||||
|
}
|
||||||
|
|
||||||
if($transaction > 0){
|
if($transaction > 0){
|
||||||
//判断是否已经生成过
|
//判断是否已经生成过
|
||||||
if (db::name('vs_guild_subsidy')->where(['guild_id'=>$value['id'],'week'=>$time_value])->find()) {
|
if (db::name('vs_guild_subsidy')->where(['guild_id'=>$value['id'],'week'=>$time_value])->find()) {
|
||||||
@@ -160,17 +123,75 @@ class Subsidy
|
|||||||
'status' => 0,
|
'status' => 0,
|
||||||
'createtime' => time(),
|
'createtime' => time(),
|
||||||
];
|
];
|
||||||
// echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
// echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
||||||
$subsidy_id = Db::name('vs_guild_subsidy_1')->insertGetId($data);
|
$subsidy_id = Db::name('vs_guild_subsidy')->insertGetId($data);
|
||||||
if ($subsidy_id) {
|
if ($subsidy_id) {
|
||||||
echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
||||||
$data_count++;
|
$data_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function createGuildSubsidyData(){
|
||||||
|
// //获取上周第一天时间
|
||||||
|
// $week_start_time = strtotime('last week Monday');
|
||||||
|
// $week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last week Sunday')));
|
||||||
|
// //获取上周时间
|
||||||
|
// $time_value = date('o-W', $week_start_time);
|
||||||
|
// echo $time_value . "工会周补贴数据生成开始\n";
|
||||||
|
// //查询所有工会
|
||||||
|
// $guild_list = db::name('vs_guild')->where(['delete_time'=>0])->field('id')->select();
|
||||||
|
// $data_count = 0;
|
||||||
|
// foreach ($guild_list as $key => $value) {
|
||||||
|
// $transaction = Db::name('vs_guild_flow')
|
||||||
|
// ->where(['guild_id' => $value['id']])
|
||||||
|
// ->where(['createtime' => ['between', [$week_start_time, $week_end_time]]])
|
||||||
|
// ->sum('flow_price');
|
||||||
|
// if($transaction > 0){
|
||||||
|
// //判断是否已经生成过
|
||||||
|
// if (db::name('vs_guild_subsidy')->where(['guild_id'=>$value['id'],'week'=>$time_value])->find()) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// //获取补贴配置
|
||||||
|
// $config = db::name('vs_guild_subsidy_config')->where(['status' => 1])->order('end_amount desc')->select(); //配置查询
|
||||||
|
// if (!$config) {
|
||||||
|
// echo '补贴配置为空\n';
|
||||||
|
// die;
|
||||||
|
// }
|
||||||
|
// $subsidy_ratio = 0;
|
||||||
|
// $subsidy_amount = 0;
|
||||||
|
// foreach ($config as $k => $v) {
|
||||||
|
// if ($transaction >= $v['end_amount']) {
|
||||||
|
// $subsidy_ratio = $v['subsidy_ratio'];
|
||||||
|
// $subsidy_amount = ($transaction * ($subsidy_ratio / 100)) / get_system_config_value('rmb_coin_ratio');//转为钻石
|
||||||
|
// break; // 找到匹配项后提前退出循环
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //生成补贴数据
|
||||||
|
// $data = [
|
||||||
|
// 'guild_id' => $value['id'],
|
||||||
|
// 'week' => $time_value,
|
||||||
|
// 'start_time' => date('Y-m-d H:i:s', $week_start_time),
|
||||||
|
// 'end_time' =>date('Y-m-d H:i:s', $week_end_time),
|
||||||
|
// 'total_transaction' => $transaction,
|
||||||
|
// 'subsidy_amount' => $subsidy_amount,
|
||||||
|
// 'subsidy_ratio' => $subsidy_ratio,
|
||||||
|
// 'status' => 0,
|
||||||
|
// 'createtime' => time(),
|
||||||
|
// ];
|
||||||
|
//// echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
||||||
|
// $subsidy_id = Db::name('vs_guild_subsidy')->insertGetId($data);
|
||||||
|
// if ($subsidy_id) {
|
||||||
|
// echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
||||||
|
// $data_count++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
||||||
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 生成房间补贴数据
|
* 生成房间补贴数据
|
||||||
* 配置:定时脚本每周一 执行
|
* 配置:定时脚本每周一 执行
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace app\cron\controller;
|
namespace app\cron\controller;
|
||||||
|
|
||||||
use app\common\controller\Push;
|
use app\common\controller\Push;
|
||||||
|
use app\common\library\GiftTableManager;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use Yzh\YunPay;
|
use Yzh\YunPay;
|
||||||
@@ -739,10 +740,24 @@ class Test
|
|||||||
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||||
$week_end_time_seach = $v['quit_time'];
|
$week_end_time_seach = $v['quit_time'];
|
||||||
}
|
}
|
||||||
$transaction_one = db::name('vs_give_gift')
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
->whereIn('from_id',$v['room_id'])
|
$week_start_time_seach,
|
||||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
$week_end_time_seach
|
||||||
->sum('total_price');
|
);
|
||||||
|
$all_total_price =0;
|
||||||
|
if($tables){
|
||||||
|
foreach ($tables as $table_name){
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)
|
||||||
|
->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');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$transaction_one = $all_total_price;
|
||||||
$transaction += $transaction_one;
|
$transaction += $transaction_one;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,16 @@ class Room extends GuildAdmin
|
|||||||
$room_id = input('room_id','');
|
$room_id = input('room_id','');
|
||||||
$search_user_id = input('user_id','');
|
$search_user_id = input('user_id','');
|
||||||
$status = input('status','');
|
$status = input('status','');
|
||||||
$search_stime_str = input('search_stime','');
|
$firstDay = date('Y-m-01');
|
||||||
$search_etime_str = input('search_etime','');
|
$lastDay = date('Y-m-t 23:59:59');
|
||||||
|
$search_stime_str = input('search_stime',$firstDay);
|
||||||
|
$search_etime_str = input('search_etime',$lastDay);
|
||||||
|
if(empty($search_stime_str)){
|
||||||
|
$search_stime_str = $firstDay;
|
||||||
|
}
|
||||||
|
if(empty($search_etime_str)){
|
||||||
|
$search_etime_str = $lastDay;
|
||||||
|
}
|
||||||
$s_money_search = input('s_money_search','');
|
$s_money_search = input('s_money_search','');
|
||||||
$e_money_search = input('e_money_search','');
|
$e_money_search = input('e_money_search','');
|
||||||
if($this->auth->id != 1) {
|
if($this->auth->id != 1) {
|
||||||
@@ -82,28 +90,63 @@ class Room extends GuildAdmin
|
|||||||
->select();
|
->select();
|
||||||
$rum_lists = [];
|
$rum_lists = [];
|
||||||
//总流水
|
//总流水
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
strtotime($search_stime_str),
|
||||||
|
strtotime($search_etime_str)
|
||||||
|
);
|
||||||
|
|
||||||
|
$room_consumption =[];
|
||||||
|
if($tables){
|
||||||
|
foreach ($lists as $vs) {
|
||||||
|
$search_stime = $search_stime_str;
|
||||||
|
$search_etime = $search_etime_str;
|
||||||
|
if($search_stime!=""){
|
||||||
|
if($vs['apply_time'] && strtotime($search_stime) < $vs['apply_time']) {
|
||||||
|
$search_stime = date('Y-m-d H:i:s',$vs['apply_time']);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$search_stime = date('Y-m-d H:i:s',$vs['apply_time']);
|
||||||
|
}
|
||||||
|
if($search_etime!=""){
|
||||||
|
if($vs['quit_time'] && (strtotime($search_etime) > $vs['quit_time'])){
|
||||||
|
$search_etime = date('Y-m-d H:i:s',$vs['quit_time']);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if($vs['quit_time']){
|
||||||
|
$search_etime = date('Y-m-d H:i:s',$vs['quit_time']);
|
||||||
|
}else{
|
||||||
|
$search_etime = date('Y-m-d H:i:s',time());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$all_total_price =0;
|
||||||
|
$total_price = 0;
|
||||||
|
foreach ($tables as $table_name) {
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)
|
||||||
|
->where(['from_id' => $vs['room_id'], 'from' => 2])
|
||||||
|
->where(['createtime' => ['between',[strtotime($search_stime),strtotime($search_etime)]]])
|
||||||
|
->sum('total_price');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
$room_consumption[$vs['id']] = $all_total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$total_consumption = 0;
|
$total_consumption = 0;
|
||||||
foreach ($lists as $k=>$v){
|
foreach ($lists as $k=>$v){
|
||||||
$search_stime = $search_stime_str;
|
$search_stime = $search_stime_str;
|
||||||
$search_etime = $search_etime_str;
|
$search_etime = $search_etime_str;
|
||||||
if($search_stime!=""){
|
if($search_stime!=""){
|
||||||
if($search_stime!="" && $v['apply_time'] < strtotime($search_stime)){
|
if($v['apply_time'] && strtotime($search_stime) < $v['apply_time']) {
|
||||||
$search_stime = $search_stime;
|
$search_stime = date('Y-m-d H:i:s',$v['apply_time']);
|
||||||
}else{
|
|
||||||
$search_stime = date('Y-m-d H:i:s',$v['apply_time']) ;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$search_stime = date('Y-m-d H:i:s',$v['apply_time']) ;
|
$search_stime = date('Y-m-d H:i:s',$v['apply_time']);
|
||||||
}
|
}
|
||||||
if($search_etime!=""){
|
if($search_etime!=""){
|
||||||
if($v['quit_time']){
|
if($v['quit_time'] && (strtotime($search_etime) > $v['quit_time'])){
|
||||||
if($search_etime!="" && $v['quit_time'] > strtotime($search_etime)){
|
$search_etime = date('Y-m-d H:i:s',$v['quit_time']);
|
||||||
$search_etime = $search_etime;
|
|
||||||
}else{
|
|
||||||
$search_etime = date('Y-m-d H:i:s',$v['quit_time']);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$search_etime = $search_etime;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if($v['quit_time']){
|
if($v['quit_time']){
|
||||||
@@ -144,7 +187,8 @@ class Room extends GuildAdmin
|
|||||||
//房间状态
|
//房间状态
|
||||||
$rum_lists[$k]['room_status']= $v['room_status']==1 ? '正常' : '封禁';
|
$rum_lists[$k]['room_status']= $v['room_status']==1 ? '正常' : '封禁';
|
||||||
//房间流水
|
//房间流水
|
||||||
$rum_lists[$k]['consumption']= model('adminapi/Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime);
|
// $rum_lists[$k]['consumption']= model('adminapi/Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime);
|
||||||
|
$rum_lists[$k]['consumption']= $room_consumption[$v['id']]??0;
|
||||||
$rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['createtime']);
|
$rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||||
$total_consumption += $rum_lists[$k]['consumption'];
|
$total_consumption += $rum_lists[$k]['consumption'];
|
||||||
|
|
||||||
@@ -289,19 +333,43 @@ class Room extends GuildAdmin
|
|||||||
if($type == 2){
|
if($type == 2){
|
||||||
$start_time = strtotime(date('Y-m-d'));
|
$start_time = strtotime(date('Y-m-d'));
|
||||||
$end_time = $start_time + 86400;
|
$end_time = $start_time + 86400;
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$start_time,
|
||||||
|
$end_time
|
||||||
|
);
|
||||||
}elseif ($type == 3){
|
}elseif ($type == 3){
|
||||||
$start_time = strtotime(date('Y-m-d',strtotime('-1 day')));
|
$start_time = strtotime(date('Y-m-d',strtotime('-1 day')));
|
||||||
$end_time = $start_time + 86400;
|
$end_time = $start_time + 86400;
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$start_time,
|
||||||
|
$end_time
|
||||||
|
);
|
||||||
}elseif ($type == 4){
|
}elseif ($type == 4){
|
||||||
$start_time = strtotime(date('Y-m-d',strtotime('-2 day')));
|
$start_time = strtotime(date('Y-m-d',strtotime('-2 day')));
|
||||||
$end_time = $start_time + 86400;
|
$end_time = $start_time + 86400;
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$start_time,
|
||||||
|
$end_time
|
||||||
|
);
|
||||||
}elseif ($type == 1){
|
}elseif ($type == 1){
|
||||||
$start_time = 1748676768;//2025-06-00 15:32:48
|
$start_time = 1748676768;//2025-06-00 15:32:48
|
||||||
$end_time = time();
|
$end_time = time();
|
||||||
|
$tables = GiftTableManager::getTablesByTimeRange(
|
||||||
|
$start_time,
|
||||||
|
$end_time
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
$all_total_price =0;
|
||||||
$profit = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price');
|
if($tables){
|
||||||
return $profit;
|
foreach ($tables as $table_name){
|
||||||
|
//表前缀
|
||||||
|
$table_prefix = config('database.prefix');
|
||||||
|
$table_name = str_replace($table_prefix, '', $table_name);
|
||||||
|
$total_price = db::name($table_name)->where('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price');
|
||||||
|
$all_total_price += $total_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $all_total_price;
|
||||||
}
|
}
|
||||||
//房间访客
|
//房间访客
|
||||||
//type 1:今日 2:昨日 3:所有
|
//type 1:今日 2:昨日 3:所有
|
||||||
|
|||||||
Reference in New Issue
Block a user