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

+ 18 - 18
app/Services/FeatureService.php

@@ -242,7 +242,24 @@ Class FeatureService
                 $column = $features[$str]["type"];
                 $logic = $features[$str]["logic"];
                 $describe = $features[$str]["describe"];
-                if (($column == '商品名称' || $column == '订单数') && $isMultiMatching){
+                if ($column == '订单数'){
+                    $sum = 0;
+                    switch ($logic) {
+                        case "大于":
+                            if ($sum > $describe) return 'true';
+                            break;
+                        case "大于等于":
+                            if ($sum >= $describe) return 'true';
+                            break;
+                        case "小于":
+                            if ($sum < $describe) return 'true';
+                            break;
+                        case "小于等于":
+                            if ($sum <= $describe) return 'true';
+                            break;
+                    }
+                }
+                if ($column == '商品名称' && $isMultiMatching){
                     $packageColumn = $columnMapping["packages"] ?? "packages";
                     $packages = $matchObject[$packageColumn] ?? [];
                     $str = $this->multiMatching($packages,$logic,$describe,$columnMapping[$column] ?? '');
@@ -289,7 +306,6 @@ Class FeatureService
     {
         if(!$column)return 'false';
 
-        $sum = 0;
         foreach ($packages as $package){
             $value = $package[$column] ?? '';
             switch ($logic) {
@@ -302,24 +318,8 @@ Class FeatureService
                 case "等于":
                     if ($value == $describe)return 'true';
                     break;
-                default:
-                    $sum += $value;
             }
         }
-        switch ($logic) {
-            case "大于":
-                if ($sum > $describe) return 'true';
-                break;
-            case "大于等于":
-                if ($sum >= $describe) return 'true';
-                break;
-            case "小于":
-                if ($sum < $describe) return 'true';
-                break;
-            case "小于等于":
-                if ($sum <= $describe) return 'true';
-                break;
-        }
         return "false";
     }
 

+ 1 - 1
app/Services/OrderService.php

@@ -1060,7 +1060,7 @@ class OrderService
 
        if (app("OwnerFeeDetailService")->create([
             "owner_id"          => $order->owner_id,
-            "worked_at"         => $order->wms_edittime,
+            "worked_at"         => $order->wms_edittime ?? $order->updated_at,
             "type"              => "发货",
             "shop_id"           => $order->shop_id,
             "operation_bill"    => $order->code,

+ 1 - 0
app/Services/OwnerPriceOperationService.php

@@ -162,6 +162,7 @@ Class OwnerPriceOperationService
             return -7;
         }*/
         foreach ($rules as $rule){
+
             if (!$rule->items)continue;
             if ($rule->strategy == '特征'){
                 $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);

+ 12 - 4
database/migrations/2021_01_27_174543_add_column_owner_price_model_storage.php

@@ -17,8 +17,12 @@ class AddColumnOwnerPriceModelStorage extends Migration
         Schema::table('owner_storage_price_models', function (Blueprint $table) {
             $table->bigInteger("time_unit_id")->comment("计时单位");
         });
-        DB::statement("ALTER TABLE features MODIFY COLUMN type enum ('商品名称','订单类型','承运商','店铺类型','订单数') default null");
-        DB::statement("ALTER TABLE features MODIFY COLUMN logic enum ('包含','不包含','等于','大于','大于等于','小于','小于等于') default null");
+        Schema::table("owner_price_model_operations",function (Blueprint $table){
+            $table->decimal("discount_count")->nullable()->comment("减免数");
+        });
+        Schema::table("owner_price_model_operation_items",function (Blueprint $table){
+            $table->decimal("discount_price")->nullable()->comment("减免单价");
+        });
     }
 
     /**
@@ -31,7 +35,11 @@ class AddColumnOwnerPriceModelStorage extends Migration
         Schema::table('owner_storage_price_models', function (Blueprint $table) {
             $table->dropColumn("time_unit_id");
         });
-        DB::statement("ALTER TABLE features MODIFY COLUMN type enum ('商品名称','订单类型','承运商','店铺类型') default null");
-        DB::statement("ALTER TABLE features MODIFY COLUMN logic enum ('包含','不包含','等于') default null");
+        Schema::table("owner_price_model_operations",function (Blueprint $table){
+            $table->dropColumn("discount_count");
+        });
+        Schema::table("owner_price_model_operation_items",function (Blueprint $table){
+            $table->dropColumn("discount_price");
+        });
     }
 }