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

+ 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;

+ 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');
         }
     }
 }

+ 2 - 0
app/OwnerPriceOperation.php

@@ -18,7 +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;

+ 2 - 2
app/Services/OwnerPriceOperationService.php

@@ -171,12 +171,12 @@ Class OwnerPriceOperationService
             if ($rule->strategy == '特征'){//特征策略匹配
                 $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);
                 if ($bool === true){
-                    if ($rule->total_price)return $rule->total_price; //按单计价存在,直接返回单总价
+                    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{//默认策略匹配
-                if ($rule->total_price)return $rule->total_price; //按单计价存在,直接返回单总价
+                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];
             };

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

@@ -16,6 +16,7 @@ class AddColumnDiscountDate extends Migration
         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("引用的计费模型");
@@ -34,6 +35,7 @@ class AddColumnDiscountDate extends Migration
         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");

+ 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")
 

+ 17 - 10
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,7 +605,7 @@
                         return;
                     }
                     if (this.model.operation.isDiscount && !this.model.operation.discount_count){
-                        this.errors["discount_price"] = ["满减值不存在"];
+                        this.errors["discount_count"] = ["满减值不存在"];
                         this.$forceUpdate();
                         return;
                     }
@@ -612,6 +614,11 @@
                         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){
@@ -619,7 +626,7 @@
                                 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">

+ 16 - 4
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"
@@ -43,13 +45,23 @@
 </div>
 <div class="row mt-3">
     <label class="col-2" for="isSingle">按单计价</label>
-    <input type="checkbox" id="isSingle" class="col-2 rounded mt-1" v-model="model.operation.isSingle">
+    <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="discount">价格</label>
-        <input id="discount" v-model="model.operation.total_price"
+        <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 === '出库'">

+ 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 !!},
                     },