Zhouzhendong 5 лет назад
Родитель
Сommit
6dfd4aa350

+ 19 - 0
app/Console/Commands/OrderThaw.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\OrderFreeze;
+use Illuminate\Console\Command;
+
+class OrderThaw extends Command
+{
+    protected $signature = 'thaw:order';
+
+    protected $description = 'automatic thaw order';
+
+    public function handle()
+    {
+        OrderFreeze::query()->where("status",0)
+            ->where("thawed_at",date("Y-m-d"))->get();
+    }
+}

+ 3 - 2
app/Jobs/OrderFreeze.php

@@ -51,7 +51,7 @@ class OrderFreeze implements ShouldQueue
     {
         $freezeOrders = [];
         foreach ($this->params as $param){
-            if (!$param["frozen"]=='是')continue;
+            if ($param["frozen"]=='是')continue;
             if (!$param["logistic_id"])continue;
             if ($this->isFreeze($param))$freezeOrders[] = $param["code"];
         }
@@ -80,8 +80,9 @@ class OrderFreeze implements ShouldQueue
         if (!$freezeOrders)return;
         $where = "''";
         foreach ($freezeOrders as $f)$where .= ",'{$f}'";
+        $edit = date("Y-m-d H:i:s");
         $sql = <<<sql
-UPDATE DOC_ORDER_HEADER SET releasestatus = 'H',waveno='*',notes = CASE WHEN notes IS NULL THEN '停运' ELSE  notes||',停运' END where ORDERNO in ({$where})
+UPDATE DOC_ORDER_HEADER SET edittime = TO_DATE({$edit},'yyyy-mm-dd hh24:mi:ss'),releasestatus = 'H',waveno='*',notes = CASE WHEN notes IS NULL THEN '停运' ELSE  notes||',停运' END where ORDERNO in ({$where})
 sql;
         DB::connection("oracle")->update($sql);
         LogService::log(__METHOD__,"订单同步-自动冻结",$sql);

+ 1 - 1
app/OrderFreeze.php

@@ -13,7 +13,7 @@ class OrderFreeze extends Model
     use ModelTimeFormat;
 
     protected $fillable = [
-        "status","logistic_id","province_id","city_id","district_id","town_id","street_id"
+        "status","logistic_id","province_id","city_id","district_id","town_id","street_id","thawed_at"
     ];
 
     const status=[

+ 32 - 0
database/migrations/2021_01_29_101642_add_column_thawed_at_table_order_freeze.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddColumnThawedAtTableOrderFreeze extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('order_freezes', function (Blueprint $table) {
+            $table->date("thawed_at")->nullable()->index()->comment("解冻时间");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('order_freezes', function (Blueprint $table) {
+            $table->dropColumn("thawed_at");
+        });
+    }
+}