浏览代码

Merge branch 'zzd' of ssh://was.baoshi56.com:10022/var/git/bswas into LD

LD 5 年之前
父节点
当前提交
d313a69ed9

+ 19 - 15
app/Http/Controllers/PriceModelController.php

@@ -265,6 +265,9 @@ class PriceModelController extends Controller
             "priority" => $request->input("priority"),
             "remark" => $request->input("remark"),
             "feature" => $request->input("feature"),
+            "discount_count"    => request("discount_count"),
+            "total_price"       => request("total_price"),
+            "total_discount_price"=> request("total_discount_price"),
         ]);
         //录入子表
         $insert = [];
@@ -312,6 +315,9 @@ class PriceModelController extends Controller
             "priority" => $request->input("priority"),
             "remark" => $request->input("remark"),
             "feature" => $request->input("feature"),
+            "discount_count"    => request("discount_count"),
+            "total_price"       => request("total_price"),
+            "total_discount_price"=> request("total_discount_price"),
         ]);
         $service->destroyItem($id);
         //录入子表
@@ -1041,15 +1047,19 @@ class PriceModelController extends Controller
         if (count($errors)>0)$this->success(["errors"=>$errors]);
 
         if (!request("owner_id"))$this->error("参数传递错误");
+        $operation = [
+            "name"              => request("name"),
+            "operation_type"    => request("operation_type"),
+            "strategy"          => request("strategy"),
+            "feature"           => request("feature"),
+            "remark"            => request("remark"),
+            "discount_count"    => request("discount_count"),
+            "total_price"       => request("total_price"),
+            "total_discount_price"=> request("total_discount_price"),
+        ];
         if (request("id")){
             $model = app('OwnerPriceOperationService')->find(request("id"),["items"]);
-            app('OwnerPriceOperationService')->findUpdate($model,[
-                "name"              => request("name"),
-                "operation_type"    => request("operation_type"),
-                "strategy"          => request("strategy"),
-                "feature"           => request("feature"),
-                "remark"            => request("remark"),
-            ]);
+            app('OwnerPriceOperationService')->findUpdate($model,$operation);
             $delete = [];//需要删除子项
             $update = [["id","strategy","amount","unit_id","unit_price","feature"]];//需要更新子项
             $insert = [];//需要新增子项
@@ -1077,14 +1087,8 @@ class PriceModelController extends Controller
             if (count($update) > 1)app(BatchUpdateService::class)->batchUpdate("owner_price_operation_items",$update);
             if ($insert)app("OwnerPriceOperationItemService")->insert($insert);
         }else{
-            DB::transaction(function ()use(&$model,$params){
-                $model = app('OwnerPriceOperationService')->create([
-                    "name"              => request("name"),
-                    "operation_type"    => request("operation_type"),
-                    "strategy"          => request("strategy"),
-                    "feature"           => request("feature"),
-                    "remark"            => request("remark"),
-                ]);
+            DB::transaction(function ()use(&$model,$params,$operation){
+                $model = app('OwnerPriceOperationService')->create($operation);
                 foreach ($params["items"] as &$item){
                     $item["owner_price_operation_id"] = $model->id;
                     if (!isset($item["feature"]))$item["feature"] = null;

+ 2 - 2
app/Http/Controllers/TestController.php

@@ -48,6 +48,7 @@ use App\OrderPackageCommodities;
 use App\OrderPackageCountingRecord;
 use App\OrderTracking;
 use App\Owner;
+use App\OwnerFeeDetail;
 use App\OwnerPriceOperation;
 use App\OwnerPriceOperationItem;
 use App\Package;
@@ -132,8 +133,7 @@ class TestController extends Controller
     }
 
     public function zzd(){
-        $month = "2020-02";
-        dd("50"*"2");
+        dd(substr("2021-01-28",0,7) == date("Y-m"));
     }
 
     public function syncWeight()

+ 1 - 1
app/Http/Middleware/Authenticate.php

@@ -15,7 +15,7 @@ class Authenticate extends Middleware
     protected function redirectTo($request)
     {
         if ( $request->expectsJson()) {
-            return route('notLogin');
+            return route('login');
         }
     }
 }

+ 1 - 1
app/Jobs/OrderFreeze.php

@@ -65,7 +65,7 @@ class OrderFreeze implements ShouldQueue
         if (array_search($param["wms_status"],$status)===false)return false;
 
         foreach ($this->pool as $pool){
-            if ($pool->thawed_at && Carbon::parse($pool->thawed_at)->lte(Carbon::today()))continue;
+            if ($pool["thawed_at"] && Carbon::parse($pool["thawed_at"])->lte(Carbon::today()))continue;
             if ($pool["logistic_id"]!=$param["logistic_id"])continue;
             if ($pool["province_name"] && (mb_strpos($param["province"],$pool["province_name"]) === false))continue;
             if ($pool["city_name"] && (mb_strpos($param["city"],$pool["city_name"]) === false))continue;

+ 4 - 0
app/OwnerFeeDetail.php

@@ -49,4 +49,8 @@ class OwnerFeeDetail extends Model
     {   //作业类型
         return $this->hasOne(ProcessMethod::class,"id","process_method_id");
     }
+    public function order()
+    {   //出库单
+        return $this->belongsTo(Order::class,"outer_id","id");
+    }
 }

+ 3 - 0
app/OwnerPriceOperation.php

@@ -18,6 +18,9 @@ class OwnerPriceOperation extends Model
         "remark",           //备注
         "priority",         //优先级 值越大越高
         "discount_count",   //减免值
+        "discount_date",    //减免阈值触发日
+        "total_price",      //按单计价
+        "total_discount_price",//按单计价减免
     ];
     public static $features = null;
     public static $columnMapping = null;

+ 0 - 1
app/Services/FeatureService.php

@@ -224,7 +224,6 @@ Class FeatureService
             return $features;
         });
 
-
         foreach ($result[0] as &$str) {
             if (is_numeric($str) && isset($features[$str])) {
                 $column = $features[$str]["type"];

+ 23 - 6
app/Services/OrderService.php

@@ -1007,11 +1007,16 @@ class OrderService
      */
     public function createInstantBill(Order $order):bool
     {
+        /** @var \stdClass $order */
         //检查订单对象
         if (!$order || $order->wms_status != "订单完成")return false;
         if (OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first())return false;
 
-        $order->loadMissing(["logistic","packages.commodities.commodity"]);
+        $key = date("Y-m")."_".$order->owner_id;
+        if (Cache::has($key))Cache::increment($key);
+        else Cache::put($key,1,2678400);
+
+        $order->loadMissing(["logistic","shop","packages.commodities.commodity"]);
 
         /** @var OwnerPriceExpressService $service */
         $service = app("OwnerPriceExpressService");
@@ -1033,7 +1038,6 @@ class OrderService
             foreach($package->commodities as &$commodity){
                 $commodity["commodity_name"] = $commodity->commodity ? $commodity->commodity->name : '';
                 $commodity["sku"] = $commodity->commodity ? $commodity->commodity->sku : '';
-                $commodity["amount"] = $commodity->amount;
                 $amount += $commodity->amount;
             }
             $commodities = array_merge($commodities,$package->commodities->toArray());
@@ -1053,13 +1057,16 @@ class OrderService
         }
         if ($logistic_fee!==null && $logistic_fee<0)$logistic_fee = null;
 
-        $object = ["commodities"=>$commodities,"logistic_name"=>($order->logistic ? $order->logistic->name : ''),"shop_name"=>($order->shop ? $order->shop->name : ''),"order_type"=>$order->order_type];
+        $object = ["commodities"=>$commodities,
+            "logistic_name"=>($order->logistic ? $order->logistic->name : ''),
+            "shop_name"=>($order->shop ? $order->shop->name : ''),
+            "order_type"=>$order->order_type,
+            "owner_id"=>$order->owner_id];
         $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name","承运商"=>"logistic_name","店铺类型"=>"shop_name","订单类型"=>"order_type","订单数"=>"amount"];
 
         /** @var OwnerPriceOperationService $service */
         $service = app("OwnerPriceOperationService");
-        $work_fee = $service->matching($object,$mapping,$order->owner_id,"出库");
-        if ($work_fee < 0)$work_fee = null;
+        $result = $service->matching($object,$mapping,$order->owner_id,"出库");
 
        if (app("OwnerFeeDetailService")->create([
             "owner_id"          => $order->owner_id,
@@ -1074,7 +1081,8 @@ class OrderService
             "volume"            => $volume,
             "weight"            => $weight,
             "logistic_id"       => $order->logistic_id,
-            "work_fee"          => $work_fee,
+            "work_fee"          => is_array($result) ? ($result["money"]>0 ? $result["money"] : null) : null,
+            "owner_price_operation_id"  => is_array($result) ? $result["id"] : null,
             "logistic_fee"      => $logistic_fee,
             "created_at"        => date('Y-m-d H:i:s'),
             "outer_id"          => $order->id,
@@ -1083,4 +1091,13 @@ class OrderService
        return false;
     }
 
+    public function getMonthTotal($ownerId = null, $month = null)
+    {
+        if (!$month)$month = date("Y-m");
+        $day = date("t",strtotime($month));
+        $whereSql = $ownerId ? "and owner_id = ? " : " ";
+        $count = DB::selectOne(DB::raw("SELECT count(*) c from orders where wms_status ='订单完成' {$whereSql} and wms_edittime BETWEEN '{$month}-01 00:00:00' and '{$month}-{$day} 23:59:59';"));
+        return $count->c;
+    }
+
 }

+ 87 - 57
app/Services/OwnerPriceOperationService.php

@@ -2,12 +2,14 @@
 
 namespace App\Services;
 
+use App\OwnerFeeDetail;
 use App\OwnerPriceOperation;
 use App\OwnerPriceOperationItem;
 use App\Services\common\QueryService;
 use App\Unit;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 use App\Traits\ServiceAppAop;
 
@@ -86,7 +88,7 @@ Class OwnerPriceOperationService
 
     /** 参数顺序: 数量 匹配对象 列映射 货主ID 单位ID 类型 SKU .
      *  匹配顺序: 类型 货主 策略 单位 特征                    ..多对多匹配规则废弃,1对1,设单位必定为件,对应规则必然只有一项存在
-     *  单位匹配: 件,箱,单 由小到大,依次换算匹配           .
+     *  单位匹配: 件,箱 由小到大,依次换算匹配           .
      *
      *  2:没有总数量存在,都为子项内数量
      *
@@ -94,15 +96,18 @@ Class OwnerPriceOperationService
      * @param array $columnMapping       key-val
      * @param string $owner_id
      * @param string $type
-     * @return double
+     * @return double|array
      * 错误代码: -1:无匹配对象 -2:无计费模型 -3:未知单位 -4:sku为空 -5:货主未找到 -6:无箱规 -7:未匹配到计费模型
      *
      * 一. 2020-10-10 zzd
      * 二. 2021-01-08 zzd
+     * 三. 2021-01-28 zzd
+     *      增加满减策略:子策略匹配时不再考虑单,仅件箱换算,满减满足后标记模型修改历史对账单
+     *      增加按订单计价策略:主匹配模型增加字段量价,该字段存在时视为按单计价,价格为该值
      */
     public function matching($matchObject, $columnMapping, $owner_id, $type = '出库')
     {
-        $unitModels = Unit::query()->whereIn("name",["件","箱","单"])->get();
+        $unitModels = Unit::query()->whereIn("name",["件","箱"])->get();
         $units = [];
         foreach ($unitModels as $unitModel)$units[$unitModel->id] = $unitModel->name;
 
@@ -114,69 +119,80 @@ Class OwnerPriceOperationService
                 $query->where("id",$owner_id);
         })->orderByRaw("strategy desc,priority desc")->get(); //货主下的全部规则
 
-        if (!$rules)return -2;
+        if (!$rules)return -2;  //规则不存在跳出
 
-        /*if ($type == '入库'){
-            $amountColumn = $columnMapping["amount"] ?? "amount";
-            $packageColumn = $columnMapping["packages"] ?? "packages";
-            $packages = $matchObject[$packageColumn] ?? false;
-            if (!$packages)return -1;
+        $total = Cache::get(date("Y-m")."_".$matchObject["owner_id"]); //获取该货主本月单量
+        foreach ($rules as $rule){
+            if (!$rule->items)continue; //不存在子规则跳出
+            $isDiscount = false;    //是否存在满减
+            if ($type=='出库' && $rule->discount_count > 0 && $total >= $rule->discount_count)$isDiscount = true;//满足满减条件
+            //满减存在且未被标记过处理时间或处理时间不为本月,处理历史即时账单
+            if ($isDiscount && (!$rule->discount_date || substr($rule->discount_date,0,7)!=date("Y-m"))){
+                try{
+                    DB::beginTransaction();
+                    $month = date("Y-m");
+                    $day = date("t",strtotime($month));
+                    foreach (OwnerFeeDetail::query()->with(["order.logistic","order.shop","order.packages.commodities.commodity"])
+                                 ->where("owner_id",$owner_id)
+                                 ->whereBetween("worked_at",[$month."-01",$month."-".$day])->get() as $detail){
+                        $order = $detail->order;
 
-            $amount = 0;
-            foreach ($packages as $package)$amount += $package[$amountColumn] ?? 0;
-            if (!$amount)return -1;
-            foreach ($rules as $rule){
-                $sum = $amount;
-                if (!$rule->in)continue;
-                if ($rule->strategy == '特征'){
-                    $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);
-                    if ($bool === true){
-                        if (!isset($units[$rule->in->unit_id])) return -3;
-                        if ($units[$rule->in->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $sumTemp = 0;
-                            $packageColumn = $columnMapping["packages"] ?? "packages";
-                            foreach ($matchObject[$packageColumn] as $commodity){
-                                $sumTemp += $this->changeUnit($sum,$owner_id,$commodity["sku"]);
+                        $logistic_fee = 0;
+                        $commodities = [];
+                        foreach ($order->packages as &$package){
+                            // 四维转二维
+                            foreach($package->commodities as &$commodity){
+                                $commodity["commodity_name"] = $commodity->commodity ? $commodity->commodity->name : '';
+                                $commodity["sku"] = $commodity->commodity ? $commodity->commodity->sku : '';
                             }
-                            $sum = $sumTemp;
-                            if ($sum<0)return $sum;
+                            $commodities = array_merge($commodities,$package->commodities->toArray());
                         }
-                        if ($units[$rule->in->unit_id] == '单')$sum = 1; //为单时数量设为1;
-                        return ceil($sum/$rule->in->amount)*$rule->in->unit_price;
+                        if ($logistic_fee!==null && $logistic_fee<0)$logistic_fee = null;
+
+                        $object = ["commodities"=>$commodities,
+                            "logistic_name"=>($order->logistic ? $order->logistic->name : ''),
+                            "shop_name"=>($order->shop ? $order->shop->name : ''),
+                            "order_type"=>$order->order_type,
+                            "owner_id"=>$order->owner_id];
+                        $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name",
+                            "承运商"=>"logistic_name", "店铺类型"=>"shop_name",
+                            "订单类型"=>"order_type","订单数"=>"amount"];
+                        $money = $this->matchItem($rule->items,$mapping,$object,$units,$owner_id,'出库',$isDiscount);
+                        if ($money>0)$detail->update(["work_fee"=>$money]);
+                        else LogService::log(__CLASS__,"处理历史即时账单时发生匹配错误","账单主键:".$detail->id."; 错误代码".$money);
                     };
-                }else{
-                    if (!isset($units[$rule->in->unit_id])) return -3;
-                    if ($units[$rule->in->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                        $sumTemp = 0;
-                        $packageColumn = $columnMapping["packages"] ?? "packages";
-                        foreach ($matchObject[$packageColumn] as $commodity){
-                            $sumTemp += $this->changeUnit($sum,$owner_id,$commodity["sku"]);
-                        }
-                        $sum = $sumTemp;
-                        if ($sum<0)return $sum;
-                    }
-                    if ($units[$rule->in->unit_id] == '单')$sum = 1; //为单时数量设为1;
-                    return ceil($sum/$rule->in->amount)*$rule->in->unit_price;
-                };
+                    $rule->update(["discount_date"=>date("Y-m-d")]);
+                    DB::commit();
+                }catch (\Exception $e){
+                    DB::rollBack();
+                    LogService::log(__CLASS__,"处理历史即时账单时发生系统错误","计费模型主键:".$rule->id."; 错误信息".$e->getMessage());
+                }
             }
-            return -7;
-        }*/
-        foreach ($rules as $rule){
-
-            if (!$rule->items)continue;
-            if ($rule->strategy == '特征'){
+            if ($rule->strategy == '特征'){//特征策略匹配
                 $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);
                 if ($bool === true){
-                    $money = $this->matchItem($rule->items,$columnMapping,$matchObject,$units,$owner_id,$type=='入库' ? true : false);
-                    if ($money>0)return $money;
+                    if ($rule->total_price)return $isDiscount ? $rule->total_discount_price : $rule->total_price; //按单计价存在,直接返回单总价或减免总价
+                    $money = $this->matchItem($rule->items,$columnMapping,$matchObject,$units,$owner_id,$type=='入库' ? true : false,$isDiscount);
+                    if ($money>0)return ["id"=>$rule->id,"money"=>$money];
                 };
-            }else{
-                $money = $this->matchItem($rule->items,$columnMapping,$matchObject,$units,$owner_id,$type=='入库' ? true : false);
-                if ($money>0)return $money;
+            }else{//默认策略匹配
+                if ($rule->total_price)return $isDiscount ? $rule->total_discount_price : $rule->total_price; //按单计价存在,直接返回单总价或减免总价
+                $money = $this->matchItem($rule->items,$columnMapping,$matchObject,$units,$owner_id,$type=='入库' ? true : false,$isDiscount);
+                if ($money>0)return ["id"=>$rule->id,"money"=>$money];
             };
         }
         return $money ?? -7;
     }
+    /**
+     * 根据货主 sku寻找箱规并将指定数量切换为箱
+     *      不满一箱视为一箱
+     *
+     * @param integer $amount
+     * @param integer $owner_id
+     * @param string $sku
+     *
+     * @return int
+     */
     private function changeUnit($amount,$owner_id,$sku)
     {
         if (!$sku)return -4;
@@ -185,7 +201,20 @@ Class OwnerPriceOperationService
         return ceil($amount/$pack);
     }
 
-    private function matchItem($rules, $columnMapping, $matchObject, $units, $owner_id, $isIn)
+    /**
+     * 匹配子策略
+     *
+     * @param array $rules 策略对象组
+     * @param array $columnMapping 映射对象
+     * @param array $matchObject 被匹配对象
+     * @param array $units 单位集
+     * @param integer $owner_id 货主ID
+     * @param bool $isIn 是否为入库单
+     * @param bool $isDiscount 是否为满减单
+     *
+     * @return double
+     */
+    private function matchItem($rules, $columnMapping, $matchObject, $units, $owner_id, $isIn, $isDiscount)
     {
         $amountColumn = $columnMapping["amount"] ?? "amount";
         $packageColumn = $columnMapping["packages"] ?? "packages";
@@ -195,6 +224,7 @@ Class OwnerPriceOperationService
 
         $unitName = "";
         foreach ($rules as $rule){
+            if ($isDiscount)$rule->unit_price = $rule->discount_price; //满足满减条件,单价调整为满减单价
             switch ($rule->strategy){
                 case "特征":
                     $inMoney = 0;
@@ -208,7 +238,7 @@ Class OwnerPriceOperationService
                                 return -3;
                         }
                         $package["price"] = $rule->unit_price;
-                        if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单')return -3;
+                        if (!isset($units[$rule->unit_id]))return -3;
                         if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
                             $sumTemp = 0;
                             $packageColumn = $columnMapping["packages"] ?? "packages";
@@ -236,7 +266,7 @@ Class OwnerPriceOperationService
                         }
 
                         $package["price"] = $rule->unit_price;
-                        if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单')return -3;
+                        if (!isset($units[$rule->unit_id]))return -3;
                         if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
                             $sumTemp = 0;
                             $packageColumn = $columnMapping["packages"] ?? "packages";
@@ -281,7 +311,7 @@ Class OwnerPriceOperationService
         }
         return -7;
     }
-    //设置数量
+    //递归式重新设置数量
     private function settingCount($packages,$amountColumn,$startNumber)
     {
         if (!$packages) return null;

+ 3 - 3
app/Services/StoreService.php

@@ -331,8 +331,7 @@ Class StoreService
 
         $mapping = ["packages" => "storeItems", "商品名称" => "name", "订单类型" => "stored_method", "订单数"=>"amount"];
 
-        $work_fee = $service->matching($store, $mapping, $store->owner_id, "入库");
-        if ($work_fee < 0) $work_fee = null;
+        $result = $service->matching($store, $mapping, $store->owner_id, "入库");
 
         if (app("OwnerFeeDetailService")->create([
             "owner_id" => $store->owner_id,
@@ -340,7 +339,8 @@ Class StoreService
             "type" => "收货",
             "operation_bill" => $store->asn_code,
             "commodity_amount" => array_sum(array_column($store->storeItems->toArray(), "amount")),
-            "work_fee" => $work_fee,
+            "work_fee" => is_array($result) ? ($result["money"]>0 ? $result["money"] : null) : null,
+            "owner_price_operation_id" => is_array($result) ? $result["id"] : null,
             "created_at" => date('Y-m-d H:i:s'),
             "outer_id" => $store->id,
             "outer_table_name" => "stores",

+ 46 - 0
database/migrations/2021_01_28_162431_add_column_discount_date.php

@@ -0,0 +1,46 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddColumnDiscountDate extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_price_operations', function (Blueprint $table) {
+            $table->date("discount_date")->nullable()->comment("满减标记日");
+            $table->decimal("total_price")->nullable()->comment("按单计价");
+            $table->decimal("total_discount_price")->nullable()->comment("减免总价");
+        });
+        Schema::table('owner_fee_details', function (Blueprint $table) {
+            $table->bigInteger("owner_price_operation_id")->nullable()->comment("引用的计费模型");
+            $table->dropIndex(["worked_at"]);
+            $table->index(["worked_at","owner_price_operation_id"]);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_price_operations', function (Blueprint $table) {
+            $table->dropColumn("discount_date");
+            $table->dropColumn("total_price");
+            $table->dropColumn("total_discount_price");
+        });
+        Schema::table('owner_fee_details', function (Blueprint $table) {
+            $table->dropColumn("owner_price_operation_id");
+            $table->dropIndex([["worked_at","owner_price_operation_id"]]);
+            $table->index(["worked_at"]);
+        });
+    }
+}

+ 1 - 1
resources/views/customer/finance/billConfirmation.blade.php

@@ -3,7 +3,7 @@
 
 @section('content')
     @component('customer.finance.menu')@endcomponent
-    <div class="container-fluid" id="container">
+    <div class="container-fluid d-none" id="container">
         <div id="form_div"></div>
         <div class="mt-1">
             <button type="button" class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"

+ 1 - 1
resources/views/customer/finance/instantBill.blade.php

@@ -3,7 +3,7 @@
 
 @section('content')
     @component('customer.finance.menu')@endcomponent
-    <div class="container-fluid" id="container">
+    <div class="container-fluid d-none" id="container">
         <div id="form_div"></div>
         <div class="mt-1">
             <button type="button" class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"

+ 1 - 1
resources/views/customer/project/area.blade.php

@@ -4,7 +4,7 @@
 @endsection
 @section('content')
     @component('customer.project.menu')@endcomponent
-    <div class="container-fluid" id="container">
+    <div class="container-fluid d-none" id="container">
 
         @include("customer._selectedOwner")
 

+ 28 - 14
resources/views/customer/project/create.blade.php

@@ -588,14 +588,16 @@
                 },
                 _verifyOperation() {
                     if (this.selectedModel.operation.length>0 && !this.model.operation.id){
-                        if (!this.selectedModel.operation.every(operation=>{
-                            if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
-                                this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
-                                this.$forceUpdate();
-                                return false;
-                            }
-                            return true;
-                        }))return;
+                        if (this.model.operation.strategy!=='特征'){
+                            if (!this.selectedModel.operation.every(operation=>{
+                                if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
+                                    this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
+                                    this.$forceUpdate();
+                                    return false;
+                                }
+                                return true;
+                            }))return;
+                        }
                     }
                     if (!this.model.operation.name){
                         this.errors["name"] = ["名称不得为空"];
@@ -603,16 +605,28 @@
                         return;
                     }
                     if (this.model.operation.isDiscount && !this.model.operation.discount_count){
-                        this.errors["discount_price"] = ["满减值不存在"];
+                        this.errors["discount_count"] = ["满减值不存在"];
                         this.$forceUpdate();
                         return;
                     }
-                    if ((this.model.operation.operation_type === '出库' && this._verifyOperationItem(0)) || this._verifyOperationItem(1))return;
-                    if (this.model.operation.items.length>2){
-                        for (let i=2;i<this.model.operation.items.length;i++){
-                            if (this._verifyOperationItem(i))return;
-                        }
+                    if (this.model.operation.isSingle && !this.model.operation.total_price){
+                        this.errors["total_price"] = ["按单价格不存在"];
+                        this.$forceUpdate();
+                        return;
+                    }
+                    if (this.model.operation.isDiscount && this.model.operation.isSingle && !this.model.operation.total_discount_price){
+                        this.errors["total_discount_price"] = ["满减价格不存在"];
+                        this.$forceUpdate();
+                        return;
                     }
+                    if (!this.model.operation.total_price){
+                        if ((this.model.operation.operation_type === '出库' && this._verifyOperationItem(0)) || this._verifyOperationItem(1))return;
+                        if (this.model.operation.items.length>2){
+                            for (let i=2;i<this.model.operation.items.length;i++){
+                                if (this._verifyOperationItem(i))return;
+                            }
+                        }
+                    }else this.$set(this.model.operation,"items",[]);
                     let url = "{{url('maintenance/priceModel/apiStoreOperation')}}";
                     let params = this.model.operation;
                     params.owner_id = this.ownerTemp.id;

+ 1 - 1
resources/views/customer/project/index.blade.php

@@ -3,7 +3,7 @@
 
 @section('content')
     @component('customer.project.menu')@endcomponent
-    <div class="container-fluid" id="container">
+    <div class="container-fluid d-none" id="container">
         <div id="form_div"></div>
         <div class="modal fade" tabindex="-1" role="dialog" id="modal">
             <div class="modal-dialog modal-dialog-scrollable modal-dialog-centered">

+ 22 - 1
resources/views/customer/project/part/_operation.blade.php

@@ -34,7 +34,9 @@
 </div>
 <div class="row mt-3" v-if="model.operation.operation_type == '出库'">
     <label class="col-2" for="isDiscount">是否满减</label>
-    <input type="checkbox" id="isDiscount" class="col-2 rounded mt-1" v-model="model.operation.isDiscount">
+    <div class="col-2">
+        <input type="checkbox" id="isDiscount" class="col-2 rounded mt-1" v-model="model.operation.isDiscount">
+    </div>
     <div class="col-8 row" v-if="model.operation.isDiscount">
         <label class="col-3" for="discount">满减值</label>
         <input id="discount" v-model="model.operation.discount_count"
@@ -42,6 +44,25 @@
     </div>
 </div>
 <div class="row mt-3">
+    <label class="col-2" for="isSingle">按单计价</label>
+    <div class="col-2">
+        <input type="checkbox" id="isSingle" class="pull-left rounded mt-1" v-model="model.operation.isSingle">
+    </div>
+    <div class="col-8 row" v-if="model.operation.isSingle">
+        <label class="col-3" for="total_price">普通价格</label>
+        <input id="total_price" v-model="model.operation.total_price"
+               class="form-control form-control-sm col-6" :class="errors.total_price ? 'is-invalid' : ''" step="0.001" type="number" min="0">
+    </div>
+</div>
+<div class="row mt-1" v-if="model.operation.isSingle && model.operation.isDiscount">
+    <label class="col-2"></label><div class="col-2"></div>
+    <div class="col-8 row">
+        <label class="col-3" for="total_discount_price">满减价格</label>
+        <input id="total_discount_price" v-model="model.operation.total_discount_price"
+               class="form-control form-control-sm col-6" :class="errors.total_discount_price ? 'is-invalid' : ''" step="0.001" type="number" min="0">
+    </div>
+</div>
+<div class="row mt-3" v-if="!model.operation.isSingle">
     {{--起步--}}
     <div class="card row text-white offset-1 col-9 bg-dark" v-if="model.operation.operation_type === '出库'">
         <div class="card-header" style="max-height: 50px">

+ 13 - 1
resources/views/maintenance/priceModel/operation/index.blade.php

@@ -22,6 +22,10 @@
                 <th>策略</th>
                 <th>项目</th>
                 <th>优先级</th>
+                <th>满减阈值</th>
+                <th>按单单价</th>
+                <th>按单减免单价</th>
+                <th>本月满减达标日</th>
                 <th>特征</th>
                 <th>备注</th>
                 <th>录入时间</th>
@@ -30,7 +34,7 @@
             <tr v-for="(model,i) in models" :id="'model-'+model.id">
                 <td>@{{ i+1 }}</td>
                 <td>
-                    <button v-if="thisId != model.id" class="btn btn-sm btn-info" @click="showDetail(model.id,model.operationType)">维护详情</button>
+                    <button v-if="thisId != model.id && model.totalPrice" class="btn btn-sm btn-info text-white" @click="showDetail(model.id,model.operationType)">维护详情</button>
                     <button v-if="thisId == model.id" class="btn btn-sm btn-dark" @click="thisId = ''">关闭详情</button>
                 </td>
                 <td>@{{ model.name }}</td>
@@ -38,6 +42,10 @@
                 <td>@{{ model.strategy }}</td>
                 <td><small v-for="owner in model.owners" class="m-0 font-weight-bold">@{{ owner.name }}<br></small></td>
                 <td>@{{ model.priority }}</td>
+                <td>@{{ model.discountCount }}</td>
+                <td>@{{ model.totalPrice }}</td>
+                <td>@{{ model.totalDiscountPrice }}</td>
+                <td>@{{ model.discountDate }}</td>
                 <td>@{{ model.feature }}</td>
                 <td>@{{ model.remark }}</td>
                 <td>@{{ model.createdAt }}</td>
@@ -135,6 +143,10 @@
                         feature : "{{$model->featureFormat}}",
                         remark : "{{$model->remark}}",
                         priority : "{{$model->priority}}",
+                        discountCount : "{{$model->discount_count ?? '/'}}",
+                        totalPrice : "{{$model->total_price ?? '/'}}",
+                        totalDiscountPrice : "{{$model->total_discount_price ?? '/'}}",
+                        discountDate : "{{substr($model->discount_date,0,7)==date('Y-m') ? $model->discount_date : ''}}",
                         createdAt : "{{$model->created_at}}",
                         owners : {!! $model->ownerPriceOperationOwners !!},
                     },