|
|
@@ -35,7 +35,7 @@ class PriceModelController extends Controller
|
|
|
public function storageIndex(Request $request)
|
|
|
{
|
|
|
if(!Gate::allows('计费模型-仓储')){ return redirect('denied'); }
|
|
|
- $models = app('OwnerStoragePriceModelService')->paginate($request->input("id"),["unit","owners"]);
|
|
|
+ $models = app('OwnerStoragePriceModelService')->paginate($request->input("id"),["unit","owners","timeUnit"]);
|
|
|
return response()->view('maintenance.priceModel.storage.index',compact("models"));
|
|
|
}
|
|
|
|
|
|
@@ -79,6 +79,7 @@ class PriceModelController extends Controller
|
|
|
"discount_type" => $request->input("discount_type"),
|
|
|
"discount_value"=> $request->input("discount_value"),
|
|
|
"unit_id" => $request->input("unit_id"),
|
|
|
+ "time_unit_id" => $request->input("time_unit_id"),
|
|
|
]);
|
|
|
$model = new OwnerStoragePriceModel();
|
|
|
$model->id = $request->input("id");
|
|
|
@@ -105,6 +106,7 @@ class PriceModelController extends Controller
|
|
|
'price'=>['required','numeric','min:0'],
|
|
|
'discount_type'=>['required'],
|
|
|
'unit_id'=>['required','integer'],
|
|
|
+ 'time_unit_id'=>['required','integer'],
|
|
|
],[
|
|
|
'required'=>':attribute 为必填项',
|
|
|
'min'=>':attribute 不得小于0',
|
|
|
@@ -118,6 +120,7 @@ class PriceModelController extends Controller
|
|
|
'discount_type' =>"减免类型",
|
|
|
'discount_value'=>"减免值",
|
|
|
'unit_id' =>"单位",
|
|
|
+ 'time_unit_id' =>"计时单位",
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -262,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 = [];
|
|
|
@@ -309,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);
|
|
|
//录入子表
|
|
|
@@ -1005,6 +1014,7 @@ class PriceModelController extends Controller
|
|
|
"discount_type" => request("discount_type"),
|
|
|
"discount_value" => request("discount_value") ?? 0,
|
|
|
"unit_id" => request("unit_id"),
|
|
|
+ "time_unit_id" => request("time_unit_id"),
|
|
|
];
|
|
|
if (request("id"))app('OwnerStoragePriceModelService')->update(["id"=>request("id")],$values);
|
|
|
else{
|
|
|
@@ -1037,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 = [];//需要新增子项
|
|
|
@@ -1073,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;
|
|
|
@@ -1296,7 +1304,13 @@ class PriceModelController extends Controller
|
|
|
{
|
|
|
$owner = new Owner();
|
|
|
$owner->id = request("id");
|
|
|
- $owner->load(["ownerStoragePriceModels","ownerPriceOperations.items","ownerPriceExpresses"=>function($query){
|
|
|
+ $owner->load(["ownerStoragePriceModels","ownerPriceOperations"=>function($query){
|
|
|
+ /** @var Builder $query */
|
|
|
+ $query->with(["items"=>function($query){
|
|
|
+ /** @var Builder $query */
|
|
|
+ $query->orderByRaw("CASE strategy WHEN '起步' THEN 1 WHEN '默认' THEN 2 WHEN '特征' THEN 3 END");
|
|
|
+ }]);
|
|
|
+ },"ownerPriceExpresses"=>function($query){
|
|
|
/** @var Builder $query */
|
|
|
$query->with(["details","logistics"]);
|
|
|
},"ownerPriceLogistics"=>function($query){
|
|
|
@@ -1310,6 +1324,9 @@ class PriceModelController extends Controller
|
|
|
$operation["featureFormat"] = $operation->featureFormat;
|
|
|
foreach ($operation->items as &$item){
|
|
|
$item["featureFormat"] = $item->featureFormat;
|
|
|
+ if ($operation["operation_type"]==='出库' && $item["strategy"] == "起步"){
|
|
|
+ $item["type"] = $item["amount"] ? 0 : 1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$this->success($owner);
|