mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-30 17:02:04 +08:00 
			
		
		
		
	commit message
This commit is contained in:
		
							
								
								
									
										58
									
								
								app/Console/Commands/CheckCommission.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								app/Console/Commands/CheckCommission.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Console\Commands; | ||||
|  | ||||
| use Illuminate\Console\Command; | ||||
| use App\Models\Order; | ||||
| use App\Models\User; | ||||
|  | ||||
| class CheckCommission extends Command | ||||
| { | ||||
|     /** | ||||
|      * The name and signature of the console command. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $signature = 'check:commission'; | ||||
|  | ||||
|     /** | ||||
|      * The console command description. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $description = '返佣服务'; | ||||
|  | ||||
|     /** | ||||
|      * Create a new command instance. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct() | ||||
|     { | ||||
|         parent::__construct(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Execute the console command. | ||||
|      * | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function handle() | ||||
|     { | ||||
|         $order = Order::where('commission_status', 0) | ||||
|             ->where('status', 3) | ||||
|             ->get(); | ||||
|         foreach ($order as $item) { | ||||
|             if ($order->invite_user_id) { | ||||
|                 $inviter = User::find($order->invite_user_id); | ||||
|                 if (!$inviter) continue; | ||||
|                 $inviter->commission_balance = $inviter->commission_balance + $order->commission_balance; | ||||
|                 if ($inviter->save()) { | ||||
|                     $item->commission_status = 1; | ||||
|                     $item->save(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|      | ||||
| } | ||||
							
								
								
									
										53
									
								
								app/Console/Commands/CheckExpire.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								app/Console/Commands/CheckExpire.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Console\Commands; | ||||
|  | ||||
| use Illuminate\Console\Command; | ||||
| use App\Models\Order; | ||||
| use App\Models\User; | ||||
|  | ||||
| class CheckExpire extends Command | ||||
| { | ||||
|     /** | ||||
|      * The name and signature of the console command. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $signature = 'check:expire'; | ||||
|  | ||||
|     /** | ||||
|      * The console command description. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $description = '过期检查'; | ||||
|  | ||||
|     /** | ||||
|      * Create a new command instance. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct() | ||||
|     { | ||||
|         parent::__construct(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Execute the console command. | ||||
|      * | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function handle() | ||||
|     { | ||||
|         $user = User::all(); | ||||
|         foreach ($user as $item) { | ||||
|             if ($user->expired_at < time()) { | ||||
|                 $user->enable = 0; | ||||
|             } else { | ||||
|                 $user->enable = 1; | ||||
|             } | ||||
|             $item->save(); | ||||
|         } | ||||
|     } | ||||
|      | ||||
| } | ||||
							
								
								
									
										92
									
								
								app/Console/Commands/CheckOrder.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										92
									
								
								app/Console/Commands/CheckOrder.php
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,92 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Console\Commands; | ||||
|  | ||||
| use Illuminate\Console\Command; | ||||
| use App\Models\Order; | ||||
| use App\Models\User; | ||||
| use App\Models\Plan; | ||||
| use App\Utils\Helper; | ||||
|  | ||||
| class CheckOrder extends Command | ||||
| { | ||||
|     /** | ||||
|      * The name and signature of the console command. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $signature = 'check:order'; | ||||
|  | ||||
|     /** | ||||
|      * The console command description. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $description = '订单检查任务'; | ||||
|  | ||||
|     /** | ||||
|      * Create a new command instance. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct() | ||||
|     { | ||||
|         parent::__construct(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Execute the console command. | ||||
|      * | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function handle() | ||||
|     { | ||||
|         $order = Order::get(); | ||||
|         foreach ($order as $item) { | ||||
|             switch ($item->status) { | ||||
|                 case 0: | ||||
|                     if (strtotime($item->created_at) <= (time() - 1800)) { | ||||
|                         $item->status = 2; | ||||
|                         $item->save(); | ||||
|                     } | ||||
|                     break; | ||||
|                 case 1: | ||||
|                     $this->orderHandle($item); | ||||
|                     break; | ||||
|             } | ||||
|              | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     private function orderHandle ($order) { | ||||
|         $user = User::find($order->user_id); | ||||
|         if (!$user->plan_id || $order->plan_id == $user->plan_id) { | ||||
|             return $this->buy($order, $user); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     private function buy ($order, $user) { | ||||
|         $plan = Plan::find($order->plan_id); | ||||
|         $user->transfer_enable = $plan->transfer_enable * 1073741824; | ||||
|         $user->enable = 1; | ||||
|         $user->plan_id = $plan->id; | ||||
|         $user->group_id = $plan->group_id; | ||||
|         $user->expired_at = $this->getTime($order->cycle, $user->expired_at); | ||||
|         if ($user->save()) { | ||||
|             $order->status = 3; | ||||
|             $order->save(); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     private function getTime ($str, $timestamp) { | ||||
|         if ($timestamp < time()) { | ||||
|             $timestamp = time(); | ||||
|         } | ||||
|         switch ($str) { | ||||
|             case 'month_price': return strtotime('+1 month', $timestamp); | ||||
|             case 'quarter_price': return  strtotime('+3 month', $timestamp); | ||||
|             case 'quarter_price': return  strtotime('+6 month', $timestamp); | ||||
|             case 'quarter_price': return  strtotime('+12 month', $timestamp); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										45
									
								
								app/Console/Kernel.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										45
									
								
								app/Console/Kernel.php
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Console; | ||||
|  | ||||
| use Illuminate\Console\Scheduling\Schedule; | ||||
| use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||||
|  | ||||
| class Kernel extends ConsoleKernel | ||||
| { | ||||
|     /** | ||||
|      * The Artisan commands provided by your application. | ||||
|      * | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $commands = [ | ||||
|         // | ||||
|     ]; | ||||
|  | ||||
|     /** | ||||
|      * Define the application's command schedule. | ||||
|      * | ||||
|      * @param  \Illuminate\Console\Scheduling\Schedule  $schedule | ||||
|      * @return void | ||||
|      */ | ||||
|     protected function schedule(Schedule $schedule) | ||||
|     { | ||||
|         $schedule->command('check:order')->everyMinute(); | ||||
|         $schedule->command('check:expire')->everyMinute(); | ||||
|         $schedule->command('check:commission')->daily(); | ||||
|         // $schedule->command('inspire') | ||||
|         //          ->hourly(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Register the commands for the application. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     protected function commands() | ||||
|     { | ||||
|         $this->load(__DIR__.'/Commands'); | ||||
|  | ||||
|         require base_path('routes/console.php'); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user