Răsfoiți Sursa

【Add】产品限购到期自动上下架

liuxiangxin 6 luni în urmă
părinte
comite
f3ab4d83df

+ 57 - 0
app/Console/Commands/ProductDelist.php

@@ -0,0 +1,57 @@
+<?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(){
+		// 获取数据
+		( New Model() )->query()->where([['quota_end','>',0],['quota_end','<=',time()]])->update(['status'=>1,'update_time'=>time()]);
+	}
+
+}

+ 3 - 3
app/Console/Kernel.php

@@ -24,12 +24,12 @@ class Kernel extends ConsoleKernel
      */
     protected function schedule(Schedule $schedule)
     {
-        // 后台任务
+        // 微伴同步客户信息
         $schedule->command('staff_relation')->runInBackground();
-        // 后台任务
         $schedule->command('staff_remark')->runInBackground();
-        // 后台任务
         $schedule->command('tag_relation')->runInBackground();
+        // 产品限购自动下架
+        $schedule->command('product_delist')->everyMinute();
     }
 
     /**

+ 4 - 4
resources/views/admin/product/index.blade.php

@@ -40,8 +40,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>产品状态</th>
 						<th>生产厂家</th>
 						<th>排序</th>
-						<th>创建人</th>
-						<th>创建时间</th>
+						<th>限购数量</th>
+						<th>修改时间</th>
 						<th>操作</th>
 					</tr>
 				</thead>
@@ -62,8 +62,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 								{{$a['sort']}}
 							@endif
 						</td>
-						<td> {{$a['admin_name']}}</td>
-						<td> {{date('Y/m/d H:i:s',$a['insert_time'])}}</td>
+						<td> {{$a['quota']}} </td>
+						<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
 						<td>
 							<a class="btn btn-sm btn-warning" href="{{url('admin/product/edit?'.http_build_query(['id'=>$a['id']]))}}" title="查看">
 								编辑