公会流水清洗修改

This commit is contained in:
2025-12-24 16:14:24 +08:00
parent 6466b0cab7
commit 0dfccdd617
3 changed files with 287 additions and 198 deletions

View File

@@ -1004,6 +1004,10 @@ class GiveGift extends Model
if(!$res){
return false;
}
//记录公会流水
if($from_type==2){
model('api/Guild')->guild_flow($from_id,$gift_price,$res);
}
//查询是否第一次送礼
$is_first_gift = db::name('vs_give_gift')->where(['user_id'=>$uid])->count();
if($is_first_gift == 1){

View File

@@ -1262,4 +1262,30 @@ class Guild extends Model
}
}
}
//公会流水记录
public function guild_flow($room_id,$flow_price,$give_gift_id=0){
$guild_user_info = Db::name('vs_guild_user')->where(['room_id' => $room_id, 'delete_time' => 0, 'status' => 1, 'quit_time' => 0])->find();
if ($guild_user_info) {
//记录流水
$data = [
'guild_id' => $guild_user_info['guild_id'],
'room_id' => $room_id,
'give_gift_id' => $give_gift_id,
'flow_price' => $flow_price,
'day' => date('Y-m-d'),
'createtime' => time(),
'updatetime' => time(),
];
$res = Db::name('vs_guild_flow')->insert($data);
if (!$res) {
return ['code' => 0, 'msg' => '提交失败', 'data' => null];
}
//增加用户公会流水
Db::name('vs_guild_user')->where(['id' => $guild_user_info['id']])->setInc('coin', $flow_price);
//增加公会总流水
Db::name('vs_guild')->where(['id' => $guild_user_info['guild_id']])->setInc('income', $flow_price);
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
}
}
}

View File

@@ -10,6 +10,7 @@ use Yzh\YunPay;
/*
* 定时任务,每秒执行的方法
*/
class Test
{
/* https://vespa.qxyushen.top/api/Cron/Test
@@ -19,12 +20,12 @@ class Test
{
// 设置脚本执行时间无限
set_time_limit(0);
echo "清洗任务数据\n";
// echo "清洗任务数据\n";
// $this->blind_box_error();
// $this->xlh_gift_send();
// echo "\n";
//
$this->clean_task_data();
$this->clean_guild_flow();
}
@@ -71,31 +72,31 @@ class Test
// 设置数据库查询超时时间
Db::query("SET SESSION wait_timeout=600");
Db::query("SET SESSION interactive_timeout=600");
// 分批处理数据,避免一次性加载大量数据到内存
$batchSize = 1000;
$offset = 0;
$data_multiple = [];
$totalProcessed = 0;
do {
// 分批获取数据
$turntable_log = Db::name('vs_blind_box_turntable_log')
->limit($offset, $batchSize)
->select();
->limit($offset, $batchSize)
->select();
// 如果没有更多数据,退出循环
if (empty($turntable_log)) {
break;
}
foreach ($turntable_log as $key => $value) {
//查询本轮是否有多个接收礼物的人
$turntable_results_log = Db::name('vs_blind_box_turntable_results_log')
->where('tid', $value['id'])
->group('gift_user_id')
->select();
// 统计送给多人的数据
if (count($turntable_results_log) > 1) {
$data_multiple[] = [
@@ -104,9 +105,9 @@ class Test
'data' => $value
];
}
$totalProcessed++;
// 每处理100条记录输出一次进度
if ($totalProcessed % 100 == 0) {
echo "已处理 {$totalProcessed} 条记录...\n";
@@ -114,19 +115,19 @@ class Test
gc_collect_cycles();
}
}
// 更新偏移量
$offset += $batchSize;
// 释放内存
unset($turntable_log);
unset($turntable_results_log);
} while ($totalProcessed <= 1400);
echo "送给多人的数据共 " . count($data_multiple) . " 条记录\n";
echo "统计盲盒转盘错误数据完成-共处理 " . $totalProcessed . " 条数据\n";
// 输出详细信息
foreach ($data_multiple as $item) {
echo "转盘ID: {$item['turntable_id']}, 接收人数: {$item['recipient_count']}\n";
@@ -135,10 +136,10 @@ class Test
public function RoomOwners()
{
$room = Db::name('vs_room')->where(['room_status' => 1,'apply_status' => 2])->select();
$arr = [];
$room = Db::name('vs_room')->where(['room_status' => 1, 'apply_status' => 2])->select();
$arr = [];
foreach ($room as $key => $value) {
$liushui = Db::name('vs_give_gift')->where(['from_id' => $value['id'],'from' => 2])->sum('total_price');
$liushui = Db::name('vs_give_gift')->where(['from_id' => $value['id'], 'from' => 2])->sum('total_price');
$usercode = Db::name('user')->where(['id' => $value['user_id']])->value('user_code');
$nickname = Db::name('user')->where(['id' => $value['user_id']])->value('nickname');
$arr[] = [
@@ -151,11 +152,11 @@ class Test
}
//房主的收益
foreach ($arr as $key => $v){
$shouyi = db::name('vs_user_money_log')->where(['user_id' => $v['user_id'],'change_type' => 18,'money_type' =>2,'createtime'=>['<',1759585380]])->sum('change_value');
foreach ($arr as $key => $v) {
$shouyi = db::name('vs_user_money_log')->where(['user_id' => $v['user_id'], 'change_type' => 18, 'money_type' => 2, 'createtime' => ['<', 1759585380]])->sum('change_value');
$arr[$key]['shouyi'] = $shouyi;
$arr[$key]['duibi'] = $shouyi.'-'.$v['liushui']/10/10;
$arr[$key]['chazhi'] = $v['liushui']/10/10 - $shouyi;
$arr[$key]['duibi'] = $shouyi . '-' . $v['liushui'] / 10 / 10;
$arr[$key]['chazhi'] = $v['liushui'] / 10 / 10 - $shouyi;
}
var_dump($arr);
}
@@ -163,138 +164,142 @@ class Test
/*
* 巡乐会中奖后房主礼物补发放
*/
public function xlh_gift_send(){
public function xlh_gift_send()
{
die("暂停");
echo "开始补发巡乐会中奖后房主礼物 \n";
$xlh_list = db::name('vs_room_pan_xlh')->where(['id'=>['in',[279]]])->select();
echo "共有".count($xlh_list)."个需要发放的礼物 \n";
if(empty($xlh_list)){
$xlh_list = db::name('vs_room_pan_xlh')->where(['id' => ['in', [279]]])->select();
echo "共有" . count($xlh_list) . "个需要发放的礼物 \n";
if (empty($xlh_list)) {
echo "没有需要发放的礼物 \n";
}
foreach ($xlh_list as $key=>$value){
try{
foreach ($xlh_list as $key => $value) {
try {
//发放
//房主礼物落包
$res = [];
//获取房主id
$user_id = db::name('vs_room')->where(['id'=>$value['room_id']])->value('user_id');
$res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$value['homeowner_gift_id'],1,model('api/UserGiftPack')::XLH_DRAW_GIFT_GET,"巡乐会中奖后房主礼物发放-补发");
$user_id = db::name('vs_room')->where(['id' => $value['room_id']])->value('user_id');
$res = model('api/UserGiftPack')->change_user_gift_pack($user_id, $value['homeowner_gift_id'], 1, model('api/UserGiftPack')::XLH_DRAW_GIFT_GET, "巡乐会中奖后房主礼物发放-补发");
if ($res['code'] != 1) {
echo $res['msg']."\n";
echo $res['msg'] . "\n";
continue;
}
echo "巡乐会中奖后房主礼物发放成功 房主Id".$user_id."\n";
}catch (\Exception $e){
echo $e->getMessage()."\n";
echo "巡乐会中奖后房主礼物发放成功 房主Id" . $user_id . "\n";
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
}
}
/*
* 任务历史数据补发
*/
public function task_history_send(){
public function task_history_send()
{
echo "开始补发任务历史数据 \n";
$user_list = db::name('user')->where(['status'=>1,'delete_time'=>0])->select();
$user_list = db::name('user')->where(['status' => 1, 'delete_time' => 0])->select();
//任务
$task_list = db::name('vs_tasks')->where(['task_type'=>1,'delete_time'=>0])->select();
foreach ($user_list as $key=>$value){
echo "开始补发用户({$value['id']})".$value['nickname']."的任务数据 \n";
foreach ($task_list as $k=>$v){
if($v['id']==3){//实名认证任务
$task_list = db::name('vs_tasks')->where(['task_type' => 1, 'delete_time' => 0])->select();
foreach ($user_list as $key => $value) {
echo "开始补发用户({$value['id']})" . $value['nickname'] . "的任务数据 \n";
foreach ($task_list as $k => $v) {
if ($v['id'] == 3) {//实名认证任务
//判断用户是否实名认证
$is_real = model('api/UserData')->real_name_info($value['id']);
if($is_real['code']==1&&$is_real['data']['is_real'] ==1){
$re =model('api/Tasks')->tasks_complete($value['id'],3);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
if ($is_real['code'] == 1 && $is_real['data']['is_real'] == 1) {
$re = model('api/Tasks')->tasks_complete($value['id'], 3);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."实名认证任务完成 \n";
}elseif($v['id']==4){//完善个人资料-创建相册
echo "用户({$value['id']})" . $value['nickname'] . "实名认证任务完成 \n";
} elseif ($v['id'] == 4) {//完善个人资料-创建相册
$album_list = db::name('user_album')->where(['user_id' => $value['id']])->field('id,name,image,pwd,read_num,like_num')->select();
if(!empty($album_list)){
$re = model('api/Tasks')->tasks_complete($value['id'],4);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
if (!empty($album_list)) {
$re = model('api/Tasks')->tasks_complete($value['id'], 4);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."完善个人资料-创建相册任务完成 \n";
}elseif($v['id']==5){//完善个人资料- 绑定支付宝或银行卡信息
$user_data = db::name('user_data')->where('user_id',$value['id'])->find();
if(!empty($user_data['alipay_account'])||!empty($user_data['bank_card_number'])){
$re = model('api/Tasks')->tasks_complete($value['id'],5);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
echo "用户({$value['id']})" . $value['nickname'] . "完善个人资料-创建相册任务完成 \n";
} elseif ($v['id'] == 5) {//完善个人资料- 绑定支付宝或银行卡信息
$user_data = db::name('user_data')->where('user_id', $value['id'])->find();
if (!empty($user_data['alipay_account']) || !empty($user_data['bank_card_number'])) {
$re = model('api/Tasks')->tasks_complete($value['id'], 5);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."完善个人资料- 绑定支付宝或银行卡信息任务完成 \n";
}elseif($v['id']==6){//第一次签约师傅
echo "用户({$value['id']})" . $value['nickname'] . "完善个人资料- 绑定支付宝或银行卡信息任务完成 \n";
} elseif ($v['id'] == 6) {//第一次签约师傅
$is_sign = db::name('vs_user_sign')->where(['sign_user_id' => $value['id']])->find();
if(!empty($is_sign)){
$re = model('api/Tasks')->tasks_complete($value['id'],6);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
if (!empty($is_sign)) {
$re = model('api/Tasks')->tasks_complete($value['id'], 6);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."第一次签约师傅任务完成 \n";
} elseif($v['id']==7){//第一次送礼
echo "用户({$value['id']})" . $value['nickname'] . "第一次签约师傅任务完成 \n";
} elseif ($v['id'] == 7) {//第一次送礼
$give_gift = db::name('vs_give_gift')->where(['user_id' => $value['id']])->find();
if(!empty($give_gift)){
$re = model('api/Tasks')->tasks_complete($value['id'],7);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
if (!empty($give_gift)) {
$re = model('api/Tasks')->tasks_complete($value['id'], 7);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."第一次送礼任务完成 \n";
}elseif($v['id']==8){//第一次收礼
echo "用户({$value['id']})" . $value['nickname'] . "第一次送礼任务完成 \n";
} elseif ($v['id'] == 8) {//第一次收礼
$give_gift = db::name('vs_give_gift')->where(['gift_user' => $value['id']])->find();
if(!empty($give_gift)){
$re = model('api/Tasks')->tasks_complete($value['id'],8);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
if (!empty($give_gift)) {
$re = model('api/Tasks')->tasks_complete($value['id'], 8);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."第一次收礼任务完成 \n";
}elseif($v['id']==9){//第一次拍卖关系
$auction = db::name('vs_room_auction')->where(['user_id' => $value['id'],'bidder_user_id'=>['>',0]])->find();
if(!empty($auction)){
$re = model('api/Tasks')->tasks_complete($value['id'],9);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
echo "用户({$value['id']})" . $value['nickname'] . "第一次收礼任务完成 \n";
} elseif ($v['id'] == 9) {//第一次拍卖关系
$auction = db::name('vs_room_auction')->where(['user_id' => $value['id'], 'bidder_user_id' => ['>', 0]])->find();
if (!empty($auction)) {
$re = model('api/Tasks')->tasks_complete($value['id'], 9);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."第一次拍卖关系任务完成 \n";
}elseif($v['id']==10){//第一次星球房卡关系(互娱房)
$friending1 = db::name('vs_user_friending_heart')->where(['user1_id' => $value['id'],'status'=>3])->find();
if(empty($friending1)){
$friending1 = db::name('vs_user_friending_heart')->where(['user2_id' => $value['id'],'status'=>3])->find();
echo "用户({$value['id']})" . $value['nickname'] . "第一次拍卖关系任务完成 \n";
} elseif ($v['id'] == 10) {//第一次星球房卡关系(互娱房)
$friending1 = db::name('vs_user_friending_heart')->where(['user1_id' => $value['id'], 'status' => 3])->find();
if (empty($friending1)) {
$friending1 = db::name('vs_user_friending_heart')->where(['user2_id' => $value['id'], 'status' => 3])->find();
}
if(!empty($friending1)){
$re = model('api/Tasks')->tasks_complete($value['id'],10);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
if (!empty($friending1)) {
$re = model('api/Tasks')->tasks_complete($value['id'], 10);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."第一次星球房卡关系任务完成 \n";
}elseif($v['id']==11){//第一次 加入公会
echo "用户({$value['id']})" . $value['nickname'] . "第一次星球房卡关系任务完成 \n";
} elseif ($v['id'] == 11) {//第一次 加入公会
$guild_list = db::name('vs_guild_user')->where(['user_id' => $value['id']])->find();
if(!empty($guild_list)){
$re = model('api/Tasks')->tasks_complete($value['id'],11);
if($re['code']!=1){
echo "用户({$value['id']})".$value['nickname']."任务({$v['id']})".$v['task_name']."任务完成失败 失败原因:".$re['msg']."\n";
if (!empty($guild_list)) {
$re = model('api/Tasks')->tasks_complete($value['id'], 11);
if ($re['code'] != 1) {
echo "用户({$value['id']})" . $value['nickname'] . "任务({$v['id']})" . $v['task_name'] . "任务完成失败 失败原因:" . $re['msg'] . "\n";
}
}
echo "用户({$value['id']})".$value['nickname']."第一次加入公会任务完成 \n";
echo "用户({$value['id']})" . $value['nickname'] . "第一次加入公会任务完成 \n";
}
}
echo "用户({$value['id']})".$value['nickname']."的任务数据补发完成 \n";
echo '------------------------------------------------------'."\n";
echo "用户({$value['id']})" . $value['nickname'] . "的任务数据补发完成 \n";
echo '------------------------------------------------------' . "\n";
}
echo "任务历史数据补发完成 用户总数:".count($user_list). " \n";
echo "任务历史数据补发完成 用户总数:" . count($user_list) . " \n";
}
//推算7号平台结余
public function calc_7_balance(){
public function calc_7_balance()
{
set_time_limit(0);
$jisuan = 0;
@@ -323,22 +328,22 @@ class Test
$earnings = $value['earnings'];
//根据注释应该计算2025-12-07之前的收益所得
$income = db::name('vs_user_money_log')
->where(['user_id'=>$value['user_id']])
->whereIn('change_type',[6,9,11,12,18,19,21,22,31,28,34,52,53,54,55,57])
->where('createtime','>=', strtotime('2025-12-07'))
->where('createtime','<=', time())
->where(['user_id' => $value['user_id']])
->whereIn('change_type', [6, 9, 11, 12, 18, 19, 21, 22, 31, 28, 34, 52, 53, 54, 55, 57])
->where('createtime', '>=', strtotime('2025-12-07'))
->where('createtime', '<=', time())
->sum('change_value');
//根据注释应该计算2025-12-07之前的消费
$expense = db::name('vs_user_money_log')
->where(['user_id'=>$value['user_id']])
->whereIn('change_type',[3,14,29])
->where('createtime','>=', strtotime('2025-12-07'))
->where('createtime','<=', time())
->where(['user_id' => $value['user_id']])
->whereIn('change_type', [3, 14, 29])
->where('createtime', '>=', strtotime('2025-12-07'))
->where('createtime', '<=', time())
->sum('change_value');
$jisuan += ($earnings - $income + $expense);
echo "用户({$value['user_id']})"."的结余:".($earnings - $income + $expense)."\n";
echo "用户({$value['user_id']})" . "的结余:" . ($earnings - $income + $expense) . "\n";
}
echo "".$page."页数据处理完成 \n";
echo "" . $page . "页数据处理完成 \n";
// 释放内存
unset($user_list);
$page++;
@@ -348,31 +353,33 @@ class Test
echo "已处理 {$page} 页数据...\n";
}
}
echo "2025-12-07以前平台结余".$jisuan."\n";
echo "2025-12-07以前平台结余" . $jisuan . "\n";
}
public function calc_7_balances(){
public function calc_7_balances()
{
//当前平台结余
for($i=1;$i<=18;$i++){
$time = strtotime('2025-12-'.$i);
for ($i = 1; $i <= 18; $i++) {
$time = strtotime('2025-12-' . $i);
$all_earnings = db::name('user_wallet')->sum('earnings');
$all_income = db::name('vs_user_money_log')
->whereIn('change_type',[6,9,11,12,18,19,21,22,31,28,34,52,53,54,55,57])
->where('money_type',2)
->where('createtime','>=', $time)
->where('createtime','<=', time())
->whereIn('change_type', [6, 9, 11, 12, 18, 19, 21, 22, 31, 28, 34, 52, 53, 54, 55, 57])
->where('money_type', 2)
->where('createtime', '>=', $time)
->where('createtime', '<=', time())
->sum('change_value');
$all_expense = db::name('vs_user_money_log')
->whereIn('change_type',[14,29])
->where('money_type',2)
->where('createtime','>=',$time)
->where('createtime','<=', time())
->whereIn('change_type', [14, 29])
->where('money_type', 2)
->where('createtime', '>=', $time)
->where('createtime', '<=', time())
->sum('change_value');
//提现
$all_tixian = db::name('vs_user_money_log')
->whereIn('change_type',[3])
->where('money_type',2)
->where('createtime','>=',$time)
->where('createtime','<=', time())
->whereIn('change_type', [3])
->where('money_type', 2)
->where('createtime', '>=', $time)
->where('createtime', '<=', time())
->sum('change_value');
//充值
// $all_recharge = db::name('vs_user_money_log')
@@ -382,116 +389,168 @@ class Test
// ->sum('change_value');
//充值
$all_recharge1 = db::name('vs_user_recharge')
->where('pay_status',2)
->where('createtime','>=', $time)
->where('createtime','<=', time())
->where('pay_status', 2)
->where('createtime', '>=', $time)
->where('createtime', '<=', time())
->sum('money');
$jisuan = ($all_earnings + $all_expense + $all_tixian) - $all_income;
echo date('Y-m-d',time())." 当前平台总结余:".$all_earnings."\n";
echo date('Y-m-d',$time)." 以后平台总收入(用户总收益):".$all_income."\n";
echo date('Y-m-d',$time)." 以后平台总支出(用户总消耗钻石红包,兑换金币):".$all_expense."\n";
echo date('Y-m-d',$time)." 以后的提现记录:".$all_tixian."\n";
echo date('Y-m-d',$time)." 以后充值(完成)".$all_recharge1 ."\n";
echo date('Y-m-d',$time)." 以前平台总结余:".$jisuan."\n";
echo "========================================================"."\n";
echo date('Y-m-d', time()) . " 当前平台总结余:" . $all_earnings . "\n";
echo date('Y-m-d', $time) . " 以后平台总收入(用户总收益):" . $all_income . "\n";
echo date('Y-m-d', $time) . " 以后平台总支出(用户总消耗钻石红包,兑换金币):" . $all_expense . "\n";
echo date('Y-m-d', $time) . " 以后的提现记录:" . $all_tixian . "\n";
echo date('Y-m-d', $time) . " 以后充值(完成)" . $all_recharge1 . "\n";
echo date('Y-m-d', $time) . " 以前平台总结余:" . $jisuan . "\n";
echo "========================================================" . "\n";
}
}
//1
public function calc_1_7_balances(){
public function calc_1_7_balances()
{
//当前平台结余
$stime = strtotime('2025-12-01');
$etime = strtotime('2025-12-08');
$all_expense = db::name('vs_user_money_log')
->whereIn('change_type',[3,14,29])
->where('money_type',2)
->where('createtime','>=',$stime)
->where('createtime','<=', $etime)
->whereIn('change_type', [3, 14, 29])
->where('money_type', 2)
->where('createtime', '>=', $stime)
->where('createtime', '<=', $etime)
->sum('change_value');
echo "2025-12-01至2025-12-07平台总提现".$all_expense."\n";
echo "2025-12-01至2025-12-07平台总提现" . $all_expense . "\n";
}
/*
* 首次创建房间任务历史数据补发
*/
public function task_history_send_34(){
public function task_history_send_34()
{
die();
echo "开始补发任务历史数据 \n";
$room_list = db::name('vs_room')->where(['type_id' => ['<>',6], 'apply_status' => 2])->select();
foreach ($room_list as $key=>$value){
$room_list = db::name('vs_room')->where(['type_id' => ['<>', 6], 'apply_status' => 2])->select();
foreach ($room_list as $key => $value) {
echo "开始补发房间({$value['room_name']}) 的任务数据 \n";
$re =model('api/Tasks')->tasks_complete($value['user_id'],34);
if($re['code']!=1){
echo $value['room_name']."首次建立房间任务完成失败 失败原因:".$re['msg']."\n";
$re = model('api/Tasks')->tasks_complete($value['user_id'], 34);
if ($re['code'] != 1) {
echo $value['room_name'] . "首次建立房间任务完成失败 失败原因:" . $re['msg'] . "\n";
continue;
}
}
$reslut = Db::name('vs_tasks_user_daily')->where('task_id',34)->update([
$reslut = Db::name('vs_tasks_user_daily')->where('task_id', 34)->update([
'is_claimed' => 1,
]);
echo "任务历史数据补发完成 用户总数:".count($room_list). " \n";
echo "任务历史数据补发完成 用户总数:" . count($room_list) . " \n";
}
public function clear_room_offline_user() {
public function clear_room_offline_user()
{
echo "开始清除房间离线用户 \n";
$room = db::name('vs_room_visitor')->where(['is_online' => 2])->select();
$res_i = 0;
if($room){
if ($room) {
foreach ($room as $value) {
$time = time() - $value['updatetime'];
if($time > 86400){
$re = model('api/Room')->quit_room($value['user_id'], $value['room_id'],$value['user_id']);
if($re['code'] != 1){
echo "清除房间离线用户失败:".$value['user_id']."---".$re['msg']."\n";
}else{
echo "清除房间离线用户成功:".$value['user_id']."\n";
$res_i ++;
if ($time > 86400) {
$re = model('api/Room')->quit_room($value['user_id'], $value['room_id'], $value['user_id']);
if ($re['code'] != 1) {
echo "清除房间离线用户失败:" . $value['user_id'] . "---" . $re['msg'] . "\n";
} else {
echo "清除房间离线用户成功:" . $value['user_id'] . "\n";
$res_i++;
}
}
}
}
echo "清除房间离线用户完成 (".$res_i.") \n";
echo "清除房间离线用户完成 (" . $res_i . ") \n";
}
//清洗任务数据
public function clean_task_data(){
//清洗任务数据
public function clean_task_data()
{
echo "开始清洗任务数据 \n";
$task_student = Db::name('vs_tasks_student')->where(['status'=>2,'delete_time'=>0])->select();
foreach ($task_student as $value) {
$tasks_bag_id = db::name('vs_tasks')->where(['id'=>$value['task_id']])->value('tasks_bag_id');
$insert_data =[
'user_id' => $value['user_id'],
'task_id' => $value['task_id'],
'tasks_bag_id' => $tasks_bag_id,
'is_completed' => 1,
'is_claimed' => 1,
'createtime' => time(),
'updatetime' => time(),
'completion_time' => $value['createtime'],
'collection_time' => $value['updatetime'],
];
Db::name('vs_tasks_user_daily')->insert($insert_data);
echo "清洗师徒任务数据成功:".$value['id']."\n";
$task_student = Db::name('vs_tasks_student')->where(['status' => 2, 'delete_time' => 0])->select();
foreach ($task_student as $value) {
$tasks_bag_id = db::name('vs_tasks')->where(['id' => $value['task_id']])->value('tasks_bag_id');
$insert_data = [
'user_id' => $value['user_id'],
'task_id' => $value['task_id'],
'tasks_bag_id' => $tasks_bag_id,
'is_completed' => 1,
'is_claimed' => 1,
'createtime' => time(),
'updatetime' => time(),
'completion_time' => $value['createtime'],
'collection_time' => $value['updatetime'],
];
Db::name('vs_tasks_user_daily')->insert($insert_data);
echo "清洗师徒任务数据成功:" . $value['id'] . "\n";
}
$user_couple_task = Db::name('vs_user_cp_task')->where(['status' => 2, 'delete_time' => 0])->select();
foreach ($user_couple_task as $value) {
$tasks_bag_id = db::name('vs_tasks')->where(['id' => $value['tasks_bag_id']])->value('tasks_bag_id');
Db::name('vs_tasks_user_daily')->insert([
'user_id' => $value['user_id'],
'task_id' => $value['tasks_bag_id'],
'tasks_bag_id' => $tasks_bag_id,
'is_completed' => 1,
'is_claimed' => 1,
'createtime' => time(),
'updatetime' => time(),
'completion_time' => $value['createtime'],
'collection_time' => $value['createtime'],
]);
echo "清洗CP任务数据成功" . $value['id'] . "\n";
}
echo "清洗任务数据完成 \n";
}
$user_couple_task = Db::name('vs_user_cp_task')->where(['status'=>2 ,'delete_time'=>0])->select();
foreach ($user_couple_task as $value) {
$tasks_bag_id = db::name('vs_tasks')->where(['id'=>$value['tasks_bag_id']])->value('tasks_bag_id');
Db::name('vs_tasks_user_daily')->insert([
'user_id' => $value['user_id'],
'task_id' => $value['tasks_bag_id'],
'tasks_bag_id' => $tasks_bag_id,
'is_completed' => 1,
'is_claimed' => 1,
'createtime' => time(),
'updatetime' => time(),
'completion_time' => $value['createtime'],
'collection_time' => $value['createtime'],
]);
echo "清洗CP任务数据成功".$value['id']."\n";
//清洗公会流水
public function clean_guild_flow()
{
echo "开始清洗公会流水: \n";
$guild = db::name('vs_guild')->where(['status' => 1, 'income' => 0])->select();
foreach ($guild as $value) {
echo "================================\n";
echo "开始清洗公会({$value['id']})流水 \n";
$guild_user = db::name('vs_guild_user')->where(['guild_id' => $value['id'],'status' => 1,'apply_time'=>['>',0],'room_id' => ['>',0]])->select();
$transaction = 0;
foreach ($guild_user as $v) {
$week_start_time_seach = "1761554521";
$week_end_time_seach = time();
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')
->where('from_id',$v['room_id'])
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
->sum('total_price');
db::name('vs_guild_user')->where(['id' => $v['id']])->update([
'coin' => $transaction_one,
]);
$data = [
'guild_id' => $value['id'],
'room_id' => $v['room_id'],
'give_gift_id' => 0,
'flow_price' => $transaction_one,
'day' => "",
'createtime' => time(),
];
$res = Db::name('vs_guild_flow')->insert($data);
$transaction += $transaction_one;
echo " 公会房间(". $v['room_id'] .")流水:" . $transaction_one . "\n";
}
db::name('vs_guild')->where(['id' => $value['id']])->update([
'income' => $transaction,
]);
echo "清洗公会房间流水完成:" . count($guild_user) . "\n";
}
echo "清洗公会流水完成: ".count($guild)."\n";
}
echo "清洗任务数据完成 \n";
}
}