mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-12 23:48:53 +00:00
1. models 关系规范化; 2. 本地-在线 订单处理改写; 3. 优化用户界面节点的查表操作; 4. 半修复 VNet SSR版需要面板主动提交用户信息变动的问题;(节点等级,用户分组,Node信息修改 主动通知节点尚未添加); 5. 简化并提取出了 返利佣金相关处理逻辑;
35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Goods;
|
|
use App\Models\Order;
|
|
use App\Models\User;
|
|
use Illuminate\Console\Command;
|
|
use Log;
|
|
|
|
class updateUserLevel extends Command {
|
|
protected $signature = 'updateUserLevel';
|
|
protected $description = '更新用户等级';
|
|
|
|
public function handle(): void {
|
|
Log::info('----------------------------【用户等级升级】开始----------------------------');
|
|
// 预设level 0
|
|
User::where('level', '<>', 0)->update(['level' => 0]);
|
|
|
|
// 获取商品列表,取新等级
|
|
$goodsLevel = Goods::type(2)->where('level', '<>', 0)->pluck('id')->toArray();
|
|
// 取生效的套餐
|
|
$orderList = Order::with('goods')->whereIn('goods_id', $goodsLevel)->active()->get();
|
|
foreach($orderList as $order){
|
|
$ret = $order->user->update(['level' => $order->goods->level]);
|
|
|
|
if($ret){
|
|
Log::info('用户: '.$order->user_id.', 按照订单'.$order->id.' 等级为'.$order->goods->level);
|
|
}else{
|
|
Log::error('用户: '.$order->user_id.' 等级更新失败!');
|
|
}
|
|
}
|
|
Log::info('----------------------------【用户等级升级】结束----------------------------');
|
|
}
|
|
} |