项目初始化

This commit is contained in:
2025-09-22 18:52:07 +08:00
commit c4fca82443
5192 changed files with 866921 additions and 0 deletions

View File

@@ -0,0 +1 @@
<?php

View File

@@ -0,0 +1,6 @@
<?php
//配置文件
return [
];

View File

@@ -0,0 +1,43 @@
<?php
namespace app\cron\controller;
use think\Db;
/*
* 定时任务,每秒执行的方法
*/
class DaySeconds
{
/*
* 运行函数
*/
function index()
{
echo "清除房间热度值:\n";
$this->clear_room_today_hot_value();//0点以后房间热度值清零
echo "\n";
}
/*
* 0点以后房间热度值清零
* 配置:定时脚本每天 0点 执行
* 配置http://vschat.qxmier.com/api/Cron/DaySeconds
*/
public function clear_room_today_hot_value() {
$where = [];
$where['delete_time'] = 0;
$where['is_show_room'] = 1;
$room = db::name('vs_room')->where($where)->select();
echo date('Y-m-d H:i:s').' 开始清零:'.count($room)."\n";
foreach ($room as $key => $value) {
$data = [
'today_hot_value' => 0,
];
db::name('vs_room')->where(['id' => $value['id']])->update($data);
}
echo date('Y-m-d H:i:s').' 完成'."\n";
die;
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace app\cron\controller;
use think\Db;
class FriendEnd
{
/*
* 运行函数
*/
function index()
{
echo "清除交友房过期未结束数据开始:\n";
$this->clearFriendingEndRoom();//清除交友房过期未结束数据
echo "清除结束 \n";
echo "清除私密小屋过期数据开始:\n";
$this->clear_room_end();//清除私密小屋过期数据
echo "清除私密小屋过期数据结束 \n";
}
//清除交友房过期未结束数据
public function clearFriendingEndRoom()
{
//清除交友房过期数据
$room_list = db::name('vs_room')->where(['type_id'=>7])->whereIn('step', [2,3])
->field(['id','step'])->select();
if(!empty($room_list)){
foreach ($room_list as $room) {
//查询交友信息
$friending_info = db::name('vs_user_friending')->where('room_id', $room['id'])->where('status', 1)->order('id', 'desc')->find();
if($friending_info){
//判断结束时间是否到期
if($friending_info['end_time'] <= time() || $room['step'] == 3){
model('Friend')->end_friend(0,$room['id'],$friending_info['id'],1);
}
}
}
}
}
//清除私密小屋过期数据
public function clear_room_end()
{
$room_list = db::name('vs_room_cp_movie')->where(['status' => 1,'type'=>1,'time_day' =>['<',time()]])->select();
if(!empty($room_list)){
foreach ($room_list as $room) {
model('Friend')->outRoom(0,$room['room_id']);
}
}
}
}

View File

@@ -0,0 +1,208 @@
<?php
namespace app\cron\controller;
use think\Db;
use Yzh\YunPay;
/*
* 定时任务,每秒执行的方法
*/
class PerformPerSecond
{
/*
* 运行函数
*/
function index()
{
echo "拍卖房结束提醒:\n";
$this->auction_end_notice();//拍卖房结束提醒
echo "\n";
echo "Pk房连线中倒计时结束操作PK结束\n";
$this->pk_start_end();
echo "\n";
echo "Pk房PK进行中倒计时结束操作PK结束\n";
$this->pk_end();
echo "\n";
echo "Pk房PK结束惩罚倒计时结束断开操作\n";
$this->pk_close();
echo "\n";
echo "pk发起10秒后无应答拒绝\n";
$this->pk_start_refuse();
echo "\n";
// echo "房间火热值更新:\n";
// $this->room_hot_update();
// echo "\n";
}
//拍卖房结束提醒
protected function auction_end_notice()
{
$auction_list = db::name('vs_room_auction')->where(['status'=>2,'duration' => ['<',time()]])->select();
$data_count = 0;
if($auction_list){
foreach ($auction_list as &$value){
model('api/RoomAuction')->room_auction_end($value['room_id'],$value['auction_id']);
$data_count++;
}
}
echo "拍卖结束提醒完成-共" . $data_count . "条数据\n";
}
//pk发起10秒后无应答拒绝
protected function pk_start_refuse()
{
$pk_list = db::name('vs_room_pk')->where(['status'=>1])->select();
$data_count = 0;
if($pk_list){
foreach ($pk_list as &$value){
if($value['createtime'] + 10 <= time()){
//pk发起10秒后无应答拒绝
model('api/RoomPk')->accept_pk($value['pk_id'],2);
$data_count++;
}
}
}
echo "pk发起10秒后无应答拒绝-共". $data_count . "条数据\n";
}
//Pk房连线中倒计时结束操作PK结束
protected function pk_start_end()
{
$pk_list = db::name('vs_room_pk')->where(['status'=>2])->select();
$data_count = 0;
if($pk_list){
foreach ($pk_list as &$value){
if($value['updatetime'] + 300 <= time()){
//pk结束
model('api/RoomPk')->end_pk($value['pk_id'],4);
}
$data_count++;
}
}
echo "Pk房连线中倒计时结束操作PK结束-共". $data_count . "条数据\n";
}
//Pk房PK进行中倒计时结束操作PK结束
protected function pk_end()
{
$pk_list = db::name('vs_room_pk')->where(['status'=>3])->select();
$data_count = 0;
if($pk_list){
foreach ($pk_list as &$value){
if($value['start_time'] + $value['pk_times'] * 60 <= time()){
//pk结束
model('api/RoomPk')->end_pk($value['pk_id']);
}
$data_count++;
}
}
echo "Pk房PK进行中倒计时结束操作PK结束-共". $data_count . "条数据\n";
}
//Pk房PK结束惩罚倒计时结束断开操作
protected function pk_close()
{
$pk_list = db::name('vs_room_pk')->where(['status'=>['in',[4,7]]])->select();
$data_count = 0;
if($pk_list){
foreach ($pk_list as &$value){
if($value['updatetime'] + 300 <= time()){
//断开操作
model('api/RoomPk')->end_pk($value['pk_id'],2);
}
$data_count++;
}
}
echo "Pk房PK结束惩罚倒计时结束断开操作-共". $data_count . "条数据\n";
}
/*
* 提现云账号订单状态查询
*/
public function withdraw_order_status(){
//一个月内的数据
$time = time() - 7 * 86400;
$withdrawal = db::name('vs_user_withdrawal')->where(['deal_type'=>2,'status'=>['in',[4,5]]])->where(['submit_yun_time'=>['>=',$time]])->select();
echo "提现云账号订单状态查询条数(".count($withdrawal)."\n";
foreach ($withdrawal as $key => $value) {
if($value['status'] == 5){
if((time()-$value['pay_time']) >= 3600){
continue;
}
}
echo "提现订单查询:".$value['order_sn']."\n";
$yun_pay = new YunPay($value['order_sn'], "", "", "", "","");
$result = $yun_pay->queryOrder($value['type']);
if($result['code'] == 1){
if($result['data']['code']==0){
db::name('vs_user_withdrawal')->where('order_sn',$value['order_sn'])->update([
'status' => 6,
'pay_time' => time(),
'pay_message' => $result['data']['msg'],
'updatetime' => time()
]);
}else{
db::name('vs_user_withdrawal')->where('order_sn',$value['order_sn'])->update([
'status' => 5,
'pay_time' => time(),
'pay_message' => $result['data']['msg'],
'updatetime' => time()
]);
}
echo "提现订单查询成功:".$result['msg']."\n";
}else{
echo "提现订单查询失败:".$result['msg']."\n";
}
}
}
//房间火热值更新
public function room_hot_update(){
$room_id_list = db::name('vs_room_hot_value_log')->field('id,room_id')->select();
$room_list = db::name('vs_room_hot_value_log')->field('room_id,sum(hot_value) as value')->group('room_id')->select();
if($room_list){
$data_count = 0;
$data_room_list = [];
foreach ($room_list as $value){
$hot_value = 0;
$hot_values = db::name('vs_room')->where('id',$value['room_id'])->field('hot_value,today_hot_value')->find();
if($hot_values['today_hot_value'] == $value['value'] || $value['value'] == 0){
continue;
}
if($hot_values['today_hot_value'] < $value['value']){
$hot_value = $hot_values['hot_value'] + ($value['value'] - $hot_values['today_hot_value']);
}
if($hot_values['today_hot_value'] > $value['value']){
$hot_value = $hot_values['hot_value'];
$today_hot_value = $value['value'];
}
$res = db::name('vs_room')->where('id',$value['room_id'])->update([
'today_hot_value' => $today_hot_value,
'hot_value' => $hot_value,
'updatetime' => time()
]);
if($res){
// db::name('vs_room_hot_value_log')->where('room_id',$value['room_id'])->delete();
$data_room_list[] = $value['room_id'];
}
$data_count ++;
}
foreach ($room_id_list as $v){
if(in_array($v['room_id'],$data_room_list)){
db::name('vs_room_hot_value_log')->where('id',$v['id'])->delete();
}
}
echo "房间火热值更新操作-共". $data_count . "条数据\n";
}
}
}

View File

@@ -0,0 +1,195 @@
<?php
namespace app\cron\controller;
use app\common\controller\Push;
use think\Db;
/*
* 定时任务,每秒执行的方法
*/
class RoomPan
{
/*
* 运行函数
*/
function index()
{
echo "巡乐会礼物发放开始:\n";
$this->xlh_gift_send();//拍卖房结束提醒
echo "礼物发放结束 \n";
echo "盲盒转盘礼物补发:\n";
$this->blind_box_turntable_gift_send();//盲盒转盘礼物补发
echo "盲盒转盘礼物补发结束 \n";
}
/*
* 盲盒转盘礼物推送补发
*/
public function blind_box_turntable_gift_send(){
$blind_box_turntable = db('vs_blind_box_turntable_log')->where(['is_sued'=>0,'createtime'=>['>=',time()-60*30]])->limit(1000)->select();
if(empty($blind_box_turntable)){
echo "没有需要发放的礼物 \n";
}
echo "开始发放".count($blind_box_turntable)." \n";
foreach ($blind_box_turntable as $k => $v) {
$blind_box_turntable_results_log = db('vs_blind_box_turntable_results_log')->where('tid',$v['id'])->select();
if(empty($blind_box_turntable_results_log)){
echo $v['id']." 没有需要发放的礼物 \n";
continue;
}
$room_id = $v['room_id'];
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
$FromUserInfo = Db::name('user')->where(['id'=>$v['user_id']])->find();
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($v['user_id']);//财富图标
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($v['user_id']);//魅力图标
$user_nickname = $FromUserInfo['nickname'];
$textMessage = $user_nickname;
$text_message = $user_nickname;
foreach ($blind_box_turntable_results_log as $key => $value) {
$ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find();
$draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find();
$textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n";
$play_image[] = $draw_gift['play_image'];
$gift_names[] = $draw_gift['gift_name'];
$text_message = $text_message . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n";
if($draw_gift['is_public_server'] == 1) {
$text_list_new[] = [
'text' => $text_message,
'gift_picture' => $draw_gift['base_image'],
'room_id' => $room_id,
'fromUserName' => $FromUserInfo['nickname'],
'toUserName' => $ToUserInfo['nickname'],
'giftName' => $draw_gift['gift_name'],
'roomId' => $room_id,
'number' => $value['count'],
];
}
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
}
foreach($ToUserInfosList as &$userInfo) {
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标
$userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力
$ToUserInfos[] = $userInfo;
}
$text = [
'FromUserInfo' => $FromUserInfo,
'ToUserInfos' => $ToUserInfos,
'GiftInfo' => [
'play_image' => implode(',',$play_image),
'gift_name' => implode(',',$gift_names),
],
'text' => $textMessage
];
//聊天室推送系统消息
model('Chat')->sendMsg(1005,$room_id,$text);
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
if($roomtype == 6){
//推送消息
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
->sum('total_price');
$text1 = [
'room_id' => $room_id,
'hot_value' => $hot_value * 10,
'text' => '房间心动值变化'
];
//聊天室推送系统消息
model('Chat')->sendMsg(1028,$room_id,$text1);
}else{
if(!empty($text_list_new)){
//推送礼物横幅
$push = new Push($v['user_id'], $room_id);
$push->giftBanner($text_list_new);
}
}
db::name('vs_blind_box_turntable_log')->where('id', $v['id'])->update(['is_sued' => 1, 'updatetime' => time()]);
}
}
/*
* 巡乐会结束 礼物发放 【定时脚本】
*/
public function xlh_gift_send(){
$xlh_list = db::name('vs_room_pan_xlh')->where(['send_time'=>0,'end_time'=>['<=',time()]])->select();
if(empty($xlh_list)){
echo "没有需要发放的礼物 \n";
}
foreach ($xlh_list as $key=>$value){
try{
if($value['user_id'] == 0){
echo "第.".$value['periods']." 巡乐会结束 没有中奖用户 \n";
$res = db::name('vs_room_pan_xlh')->where('id',$value['id'])->update([
'send_time' => time()
]);
db::name("vs_room")->where('id',$value['room_id'])->update([
'xlh_periods_num' => 0
]);
//推送礼物横幅
$text = "本轮巡乐会已结束,请大家重新开始下一轮巡乐会";
$push = new Push(0, $value['room_id']);
$text_list_new = [
'text' => $text,
'room_id' => $value['room_id'],
'from_type' => 3
];
$push->xunlehui($text_list_new);
continue;
}
//发放
//抽中礼物落包
$res = [];
$res = model('api/UserGiftPack')->change_user_gift_pack($value['user_id'],$value['gift_id'],$value['num'],model('UserGiftPack')::XLH_DRAW_GIFT_GET,"巡乐会中奖发放");
if ($res['code'] != 1) {
echo $res['msg']."\n";
continue;
}
echo "巡乐会中奖礼物发放成功 用户Id".$value['user_id']."\n";
//房主礼物落包
$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('UserGiftPack')::XLH_DRAW_GIFT_GET,"巡乐会中奖后房主礼物发放");
if ($res['code'] != 1) {
echo $res['msg']."\n";
continue;
}
echo "巡乐会中奖后房主礼物发放成功 房主Id".$user_id."\n";
//处理发放记录
$res = [];
$res = db::name('vs_room_pan_xlh')->where('id',$value['id'])->update([
'send_time' => time()
]);
$xlh_log = db::name('vs_room_pan_xlh_log')->where(['xlh_id'=>$value['id'],'user_id'=>$value['user_id']])->order('id desc')->find();
$res = db::name('vs_room_pan_xlh_log')->where('id',$xlh_log['id'])->update([
'is_send' => 1
]);
if ($res === false) {
echo "处理发放记录失败 \n";
continue;
}
db::name("vs_room")->where('id',$value['room_id'])->update([
'xlh_periods_num' => 0
]);
//推送
$FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id'=>$value['user_id']])->find();
$room_name = db::name('vs_room')->where(['id'=>$value['room_id']])->value('room_name');
$gift_name = db::name('vs_gift')->where(['gid'=>$value['gift_id']])->value('gift_name');
$text = $FromUserInfo['nickname'] . ' 用户在 ' . $room_name.' 房间巡乐会中 ' .$gift_name.'礼物 x ' .$value['num']." 已收入背包";
//推送礼物横幅
$push = new Push(0, $value['room_id']);
$text_list_new = [
'text' => $text,
'room_id' => $value['room_id'],
'from_type' => 3
];
$push->xunlehui($text_list_new);
}catch (\Exception $e){
echo $e->getMessage()."\n";
}
}
}
}

View File

@@ -0,0 +1,158 @@
<?php
namespace app\cron\controller;
use app\common\controller\adminApi;
use think\Controller;
use think\Db;
/*
* 工会
*/
class Subsidy
{
/*
* 运行函数
*/
function index()
{
echo "工会补贴生成开始:\n";
$this->createGuildSubsidyData();//工会补贴数据
echo "\n";
echo "房间补贴生成开始:\n";
$this->createRoomSubsidyData();//房间补贴数据
}
/*
* 生成工会补贴数据
* 配置:定时脚本每周一 执行
* 配置:/cron/Subsidy/createGuildSubsidyData
*/
public function createGuildSubsidyData(){
//获取上周第一天时间
$week_start_time = strtotime('last monday');
$week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last sunday')));
// $week_start_time = strtotime('2025-08-11');
// $week_end_time = strtotime('2025-08-17 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
$room_ids = db::name('vs_guild_user')->where('guild_id', $value['id'])->field('room_id')->select();
$room_ids = array_column($room_ids, 'room_id');
$transaction = db::name('vs_give_gift')
->whereIn('from_id',$room_ids)
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time, $week_end_time]]])
->sum('total_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);
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(),
];
$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";
}
/*
* 生成房间补贴数据
* 配置:定时脚本每周一 执行
* 配置:/Core/RoomSubsidy/createRoomSubsidyData
*/
public function createRoomSubsidyData(){
//获取上周第一天时间
$week_start_time = strtotime('last monday');
$week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last sunday')));
// $week_start_time = strtotime('2025-08-11');
// $week_end_time = strtotime('2025-08-17 23:59:59');
//获取上周时间
$time_value = date('o-W', $week_start_time);
echo $time_value . "房间周补贴数据生成开始\n";
//查询所有房间
$room_list = db::name('vs_room')->where(['delete_time'=>0,'is_earnings'=>1])->field('id')->select();
$data_count = 0;
foreach ($room_list as $key => $value) {
$transaction = db::name('vs_give_gift')
->where('from_id',$value['id'])
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time, $week_end_time]]])
->sum('total_price');
if($transaction > 0){
//判断是否已经生成过
if (db::name('vs_room_subsidy')->where(['room_id'=>$value['id'],'week'=>$time_value])->find()) {
continue;
}
//获取补贴配置
$config = db::name('vs_room_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);
break; // 找到匹配项后提前退出循环
}
}
//生成补贴数据
$data = [
'room_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(),
];
$subsidy_id = Db::name('vs_room_subsidy')->insertGetId($data);
if ($subsidy_id) {
echo "房间".$value['id']."生成成功(补贴ID".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
$data_count++;
}
}
}
echo $time_value . "房间周补贴数据生成完成-共" . $data_count . "条数据\n";
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace app\cron\controller;
use think\Db;
/*
* 定时任务,每秒执行的方法
*/
class TenSeconds
{
/*
* 运行函数
*/
function index()
{
echo "房间在线人数:\n";
$this->auction_end_notice();//拍卖房结束提醒
echo "\n";
}
protected function auction_end_notice()
{
$auction_list = db::name('vs_room')->field('id')->where(['room_status'=>1,'apply_status' => 2,'type_id' =>['<>',6]])->select();
$data_count = 0;
$data_number = 0;
if($auction_list){
foreach ($auction_list as &$value){
$num = model('api/Room')->room_online_number($value['id']);
// $on_pit_num = db::name('vs_room_pit')->field('user_id')->where(['room_id' => $value['id'],'user_id' => ['<>',0]])->count();
if($num['code'] == 1){
if($num['data']['online_number'] > 0){
$text = [
'online_number' => $num['data']['online_number'],
'room_id' => $value['id'],//接受房间id
];
model('api/Chat')->sendMsg(1036,$value['id'],$text);
$data_number++;
}
}
// else{
// if($on_pit_num > 0){
// $text = [
// 'online_number' => $on_pit_num,
// 'room_id' => $value['id'],//接受房间id
// ];
// model('api/Chat')->sendMsg(1036,$value['id'],$text);
// $data_number++;
// }
// }
$data_count++;
}
}
echo "房间共" . $data_count . "条数据\n";
echo "房间在线人数>0 的总共" . $data_number . "条数据\n";
}
}