Переглянути джерело

将packages表字段合并至order_packages

Zhouzhendong 5 роки тому
батько
коміт
56b6c4cc2e

+ 8 - 2
app/OrderPackage.php

@@ -10,15 +10,21 @@ class OrderPackage extends Model
     //
     use ModelTimeFormat;
 
-    protected $fillable = ['order_id','logistic_number'];
+    protected $fillable = ['order_id','logistic_number','batch_number',
+        'batch_rule','bulk','weight','length','width','height','paper_box_id','measuring_machine_id','weighed_at','status'];
 
     public function order(){
         return $this->belongsTo('App\Order','order_id','id');
     }
-
     public function commodities(){
         return $this->hasMany('App\OrderPackageCommodities','order_package_id','id');
     }
+    public function paperBox(){
+        return $this->hasOne('App\PaperBox','id','paper_box_id');
+    }
+    public function measuringMachine(){
+        return $this->hasOne('App\MeasuringMachine','id','measuring_machine_id');
+    }
 
     public function delete()
     {

+ 0 - 1
app/Services/OrderPackageService.php

@@ -8,7 +8,6 @@ use App\OracleDOCOrderHeader;
 use App\Order;
 use App\OrderPackage;
 use App\OrderPackageCommodities;
-use Tightenco\Collect\Support\Arr;
 
 class OrderPackageService
 {

+ 52 - 0
database/migrations/2020_09_04_113603_change_order_packages_add_column.php

@@ -0,0 +1,52 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeOrderPackagesAddColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('order_packages', function (Blueprint $table) {
+            $table->string('batch_number')->nullable()->index()->comment('波次号');
+            $table->string('batch_rule')->nullable()->index()->comment('波次规则');
+            $table->decimal('bulk',16,2)->nullable()->comment('体积');
+            $table->decimal('weight')->nullable()->comment('重KG');
+            $table->decimal('length')->nullable()->comment('长(cm)');
+            $table->decimal('width')->nullable()->comment('宽(cm)');
+            $table->decimal('height')->nullable()->comment('高(cm)');
+            $table->bigInteger('paper_box_id')->nullable()->index()->comment('外键纸箱');
+            $table->bigInteger('measuring_machine_id')->nullable()->index()->comment('外键设备');
+            $table->dateTime('weighed_at')->nullable()->comment('称重时间');
+            $table->enum('status',['无','未上传','已上传','未测量','未下发','上传异常','下发异常','记录异常','已上传异常','测量异常'])->default('无')->comment('包裹信息状态');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('order_packages', function (Blueprint $table) {
+            $table->dropColumn('batch_number');
+            $table->dropColumn('batch_rule');
+            $table->dropColumn('bulk');
+            $table->dropColumn('weight');
+            $table->dropColumn('length');
+            $table->dropColumn('width');
+            $table->dropColumn('height');
+            $table->dropColumn('paper_box_id');
+            $table->dropColumn('measuring_machine_id');
+            $table->dropColumn('weighed_at');
+            $table->dropColumn('status');
+        });
+    }
+}