mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 23:19:05 +00:00
## 主题更新
1. 更新至remark5.1.0;
2. 对input中range进行了一些自定义美化;
## 功能添加/重置
1. 支付相关代码重置;
1.1 对在线&余额处理代码整合;
1.2 剃离失效的有赞云;
2. 套餐相关代码重置;
* 2.1 重置日从日改为了日期,列6号 改为 xxxx年x月6号;
2.2 添加预支付套餐功能;
2.3 套餐逻辑修改;套餐为主,流量包为辅;流量包将会在下一个重置日期时失效;
2.4 套餐添加 重置流量周期;默认为30天;
## BUG修复和优化
1. 对上版本添加的节点TCP和ICMP检测 功能进行代码简化,已经提示信息显示优化;
2. 对定时任务进行逻辑优化&简化; [自动化任务]消耗时间减半;
3. 对2019年的老代码进行清理;
## 页面添加与修改
1. 管理员界面 用户相关页面添加重置日期修改;
2. 管理员界面 批量添加用户功能现在将不是默认10个而是可自定义添加数额;
3. 用户界面 检测并提示用户预支付套餐;
90 lines
2.4 KiB
PHP
90 lines
2.4 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use App\Components\Callback;
|
||
use App\Components\Helpers;
|
||
use App\Http\Models\Order;
|
||
use App\Http\Models\User;
|
||
use App\Http\Models\UserLabel;
|
||
use DB;
|
||
use Exception;
|
||
use Illuminate\Console\Command;
|
||
use Log;
|
||
|
||
class ServiceTimer extends Command
|
||
{
|
||
use Callback;
|
||
protected $signature = 'serviceTimer';
|
||
protected $description = '服务计时器';
|
||
protected static $systemConfig;
|
||
|
||
public function __construct()
|
||
{
|
||
parent::__construct();
|
||
self::$systemConfig = Helpers::systemConfig();
|
||
}
|
||
|
||
public function handle()
|
||
{
|
||
$jobStartTime = microtime(TRUE);
|
||
|
||
// 扣减用户到期商品的流量
|
||
$this->decGoodsTraffic();
|
||
|
||
$jobEndTime = microtime(TRUE);
|
||
$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
|
||
|
||
Log::info('执行定时任务【'.$this->description.'】,耗时'.$jobUsedTime.'秒');
|
||
}
|
||
|
||
// 扣减用户到期商品的流量
|
||
private function decGoodsTraffic()
|
||
{
|
||
$orderList = Order::query()->with(['user', 'goods'])->where('status', 2)->where('is_expire', 0)->where('expire_at', '<=', date('Y-m-d H:i:s'))->get();
|
||
if($orderList->isNotEmpty()){
|
||
DB::beginTransaction();
|
||
try{
|
||
foreach($orderList as $order){
|
||
// 过期本订单
|
||
Order::query()->where('oid', $order->oid)->update(['is_expire' => 1]);
|
||
|
||
// 过期生效中的加油包
|
||
Order::query()
|
||
->with(['goods'])
|
||
->where('user_id', $order->user_id)
|
||
->where('status', 2)
|
||
->where('is_expire', 0)
|
||
->whereHas('goods', function($q){
|
||
$q->where('type', 1);
|
||
})->update(['is_expire' => 1]);
|
||
|
||
if(empty($order->user) || empty($order->goods)){
|
||
continue;
|
||
}
|
||
|
||
// 清理全部流量
|
||
Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $order->user->transfer_enable, 0, '[定时任务]用户所购商品到期,扣减商品对应的流量');
|
||
User::query()->where('id', $order->user_id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => 0, 'reset_time' => NULL]);
|
||
|
||
// 删除对应用户的所有标签
|
||
UserLabel::query()->where('user_id', $order->user_id)->delete();
|
||
|
||
// 检查该订单对应用户是否有预支付套餐
|
||
$prepaidOrder = Order::query()->where('user_id', $order->user_id)->where('status', 3)->orderBy('oid', 'asc')->first();
|
||
|
||
if($prepaidOrder){
|
||
$this->activePrepaidOrder($prepaidOrder->oid);
|
||
}
|
||
}
|
||
|
||
DB::commit();
|
||
} catch(Exception $e){
|
||
Log::error($this->description.':'.$e);
|
||
|
||
DB::rollBack();
|
||
}
|
||
}
|
||
}
|
||
}
|