123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use App\Facades\Servers\Redis\RedisLock;
- use App\Facades\Servers\WechatWork\ExternalContact;
- use App\Models\Product as Model;
- class ProductDelist extends Command
- {
- /**
- * 任务名称
- *
- * @var string
- */
- protected $signature = 'product_delist';
- /**
- * 任务描述
- *
- * @var string
- */
- protected $description = '产品自动上下架';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- // 执行任务
- $this->run_task();
- return 0;
- }
- /**
- * 执行任务
- *
- * */
- public function run_task(){
- // 实例化
- $Model = New Model();
- // 限购自动下架
- $Model->query()->where([['quota_end','>',0],['quota_end','<=',time()],['status','=',0]])->update(['status'=>1,'update_time'=>time()]);
- // 预上架的产品自动上架
- $Model->query()->where([['puton_time','>',0],['puton_time','<=',time()],['status','=',2]])->update(['status'=>0,'update_time'=>time()]);
- // 已上架并且需要自动下架的产品,自动下架
- $Model->query()->where([['putoff_time','>',0],['putoff_time','<=',time()],['status','=',0]])->update(['status'=>4,'update_time'=>time()]);
- }
- }
|