|
@@ -8,21 +8,26 @@ use App\Imports\OwnerPriceDirectLogisticDetailImport;
|
|
|
use App\Imports\OwnerPriceLogisticDetailImport;
|
|
use App\Imports\OwnerPriceLogisticDetailImport;
|
|
|
use App\Owner;
|
|
use App\Owner;
|
|
|
use App\OwnerPriceDirectLogistic;
|
|
use App\OwnerPriceDirectLogistic;
|
|
|
|
|
+use App\OwnerPriceDirectLogisticCar;
|
|
|
use App\OwnerPriceExpress;
|
|
use App\OwnerPriceExpress;
|
|
|
use App\OwnerPriceExpressProvince;
|
|
use App\OwnerPriceExpressProvince;
|
|
|
use App\OwnerPriceLogistic;
|
|
use App\OwnerPriceLogistic;
|
|
|
|
|
+use App\OwnerPriceLogisticDetail;
|
|
|
use App\OwnerPriceOperation;
|
|
use App\OwnerPriceOperation;
|
|
|
-use App\OwnerPriceOperationItemOut;
|
|
|
|
|
|
|
+use App\OwnerPriceOperationItem;
|
|
|
|
|
+use App\OwnerStoragePriceModel;
|
|
|
|
|
+use App\Services\common\BatchUpdateService;
|
|
|
use App\Services\common\ExportService;
|
|
use App\Services\common\ExportService;
|
|
|
use App\Services\LogService;
|
|
use App\Services\LogService;
|
|
|
-use App\Services\OwnerOutStorageRuleService;
|
|
|
|
|
|
|
+use App\Services\OwnerPriceOperationItemService;
|
|
|
use App\Services\OwnerPriceOperationService;
|
|
use App\Services\OwnerPriceOperationService;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
|
+use Illuminate\Database\Eloquent\Collection;
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
-use Illuminate\Validation\Rule;
|
|
|
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
|
|
|
|
class PriceModelController extends Controller
|
|
class PriceModelController extends Controller
|
|
@@ -64,6 +69,7 @@ class PriceModelController extends Controller
|
|
|
if(!Gate::allows('计费模型-仓储-编辑')){ return redirect('denied'); }
|
|
if(!Gate::allows('计费模型-仓储-编辑')){ return redirect('denied'); }
|
|
|
app('OwnerStoragePriceModelService')->update(["id"=>$request->input("id")],[
|
|
app('OwnerStoragePriceModelService')->update(["id"=>$request->input("id")],[
|
|
|
"counting_type" => $request->input("counting_type"),
|
|
"counting_type" => $request->input("counting_type"),
|
|
|
|
|
+ "name" => $request->input("name"),
|
|
|
"using_type" => $request->input("using_type"),
|
|
"using_type" => $request->input("using_type"),
|
|
|
"minimum_area" => $request->input("minimum_area"),
|
|
"minimum_area" => $request->input("minimum_area"),
|
|
|
"price" => $request->input("price"),
|
|
"price" => $request->input("price"),
|
|
@@ -85,6 +91,7 @@ class PriceModelController extends Controller
|
|
|
private function storageValidator(array $params)
|
|
private function storageValidator(array $params)
|
|
|
{
|
|
{
|
|
|
return Validator::make($params,[
|
|
return Validator::make($params,[
|
|
|
|
|
+ 'name'=>['required'],
|
|
|
'counting_type'=>['required'],
|
|
'counting_type'=>['required'],
|
|
|
'using_type'=>['required'],
|
|
'using_type'=>['required'],
|
|
|
'minimum_area'=>['nullable','numeric','min:0'],
|
|
'minimum_area'=>['nullable','numeric','min:0'],
|
|
@@ -97,6 +104,7 @@ class PriceModelController extends Controller
|
|
|
'min'=>':attribute 不得小于0',
|
|
'min'=>':attribute 不得小于0',
|
|
|
'integer'=>':attribute 未选择',
|
|
'integer'=>':attribute 未选择',
|
|
|
],[
|
|
],[
|
|
|
|
|
+ 'name' =>"名称",
|
|
|
'counting_type' =>"计费类型",
|
|
'counting_type' =>"计费类型",
|
|
|
'using_type' =>"用仓类型",
|
|
'using_type' =>"用仓类型",
|
|
|
'minimum_area' =>"最低起租面积",
|
|
'minimum_area' =>"最低起租面积",
|
|
@@ -111,26 +119,26 @@ class PriceModelController extends Controller
|
|
|
if(!Gate::allows('计费模型-作业-查询')){ return redirect('denied'); }
|
|
if(!Gate::allows('计费模型-作业-查询')){ return redirect('denied'); }
|
|
|
$features = app("FeatureService")->getMapArray();
|
|
$features = app("FeatureService")->getMapArray();
|
|
|
OwnerPriceOperation::$features = $features;
|
|
OwnerPriceOperation::$features = $features;
|
|
|
- $models = app('OwnerPriceOperationService')->paginate($request->input(),["ownerPriceOperationOwners","ownerInStorageRule"=>function($query){$query->with("unit");}])->append("featureFormat");
|
|
|
|
|
|
|
+ $models = app('OwnerPriceOperationService')->paginate($request->input(),["ownerPriceOperationOwners","items.unit"])->append("featureFormat");
|
|
|
$owners = app("OwnerService")->getIntersectPermitting();
|
|
$owners = app("OwnerService")->getIntersectPermitting();
|
|
|
return response()->view('maintenance.priceModel.operation.index',compact("models","owners"));
|
|
return response()->view('maintenance.priceModel.operation.index',compact("models","owners"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* 获取出库模型规则 */
|
|
/* 获取出库模型规则 */
|
|
|
- public function operationGetOutStorageRule(Request $request)
|
|
|
|
|
|
|
+ public function getItems(Request $request)
|
|
|
{
|
|
{
|
|
|
if(!Gate::allows('计费模型-作业-查询')){ return ["success"=>false,"data"=>"无权操作"]; }
|
|
if(!Gate::allows('计费模型-作业-查询')){ return ["success"=>false,"data"=>"无权操作"]; }
|
|
|
- /** @var OwnerOutStorageRuleService $service */
|
|
|
|
|
- $service = app('OwnerOutStorageRuleService');
|
|
|
|
|
- $ownerOutStorageRules = $service->get(["owner_price_operation_id"=>$request->input("id")],["unit"],true)->append("featureFormat");
|
|
|
|
|
- return ["success"=>true,"data"=>$ownerOutStorageRules];
|
|
|
|
|
|
|
+ /** @var OwnerPriceOperationItemService $service */
|
|
|
|
|
+ $service = app('OwnerPriceOperationItemService');
|
|
|
|
|
+ $items = $service->get(["owner_price_operation_id"=>$request->input("id")],["unit"],true)->append("featureFormat");
|
|
|
|
|
+ return ["success"=>true,"data"=>$items];
|
|
|
}
|
|
}
|
|
|
- /* 修改出库模型规则 */
|
|
|
|
|
- public function updateOutStorageRule(Request $request)
|
|
|
|
|
|
|
+ /* 修改子规则 */
|
|
|
|
|
+ public function updateItem(Request $request)
|
|
|
{
|
|
{
|
|
|
if(!Gate::allows('计费模型-作业-编辑')){ return ["success"=>false,"data"=>"无权操作"]; }
|
|
if(!Gate::allows('计费模型-作业-编辑')){ return ["success"=>false,"data"=>"无权操作"]; }
|
|
|
- /** @var OwnerOutStorageRuleService $service */
|
|
|
|
|
- $service = app('OwnerOutStorageRuleService');
|
|
|
|
|
|
|
+ /** @var OwnerPriceOperationItemService $service */
|
|
|
|
|
+ $service = app('OwnerPriceOperationItemService');
|
|
|
$row = $service->update(["id"=>$request->input("id")],[
|
|
$row = $service->update(["id"=>$request->input("id")],[
|
|
|
"amount"=>$request->input("amount"),
|
|
"amount"=>$request->input("amount"),
|
|
|
"unit_id"=>$request->input("unit_id"),
|
|
"unit_id"=>$request->input("unit_id"),
|
|
@@ -143,11 +151,11 @@ class PriceModelController extends Controller
|
|
|
return ["success"=>false,"data"=>"受影响数据数为:".$row];
|
|
return ["success"=>false,"data"=>"受影响数据数为:".$row];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function createOutStorageRule(Request $request)
|
|
|
|
|
|
|
+ public function createItem(Request $request)
|
|
|
{
|
|
{
|
|
|
if(!Gate::allows('计费模型-作业-编辑')){ return ["success"=>false,"data"=>"无权操作"]; }
|
|
if(!Gate::allows('计费模型-作业-编辑')){ return ["success"=>false,"data"=>"无权操作"]; }
|
|
|
- /** @var OwnerOutStorageRuleService $service */
|
|
|
|
|
- $service = app('OwnerOutStorageRuleService');
|
|
|
|
|
|
|
+ /** @var OwnerPriceOperationItemService $service */
|
|
|
|
|
+ $service = app('OwnerPriceOperationItemService');
|
|
|
switch ($request->input("strategy")){
|
|
switch ($request->input("strategy")){
|
|
|
case "起步":
|
|
case "起步":
|
|
|
$c = $service->isExist(["owner_price_operation_id"=>$request->input("owner_price_operation_id"),"strategy"=>"起步"]);
|
|
$c = $service->isExist(["owner_price_operation_id"=>$request->input("owner_price_operation_id"),"strategy"=>"起步"]);
|
|
@@ -159,7 +167,6 @@ class PriceModelController extends Controller
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
$data = $service->create($request->input());
|
|
$data = $service->create($request->input());
|
|
|
- LogService::log(__METHOD__,"计费模型-录入出库规则",json_encode($request->input()));
|
|
|
|
|
$data->load("unit");
|
|
$data->load("unit");
|
|
|
return ["success"=>true,"data"=>$data];
|
|
return ["success"=>true,"data"=>$data];
|
|
|
}
|
|
}
|
|
@@ -186,11 +193,11 @@ class PriceModelController extends Controller
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (count($stack) > 0)return ["success"=>false,"data"=>"组标记错误,起始与结束标记必须对应"];
|
|
if (count($stack) > 0)return ["success"=>false,"data"=>"组标记错误,起始与结束标记必须对应"];
|
|
|
- $row = app('OwnerOutStorageRuleService')->update(["id"=>$id],["feature"=>$feature]);
|
|
|
|
|
|
|
+ $row = app('OwnerPriceOperationItemService')->update(["id"=>$id],["feature"=>$feature]);
|
|
|
if ($row != 1)return ["success"=>false,"data"=>"影响了“".$row."”行"];
|
|
if ($row != 1)return ["success"=>false,"data"=>"影响了“".$row."”行"];
|
|
|
LogService::log(__METHOD__,"计费模型-修改出库特征",json_encode($request->input()));
|
|
LogService::log(__METHOD__,"计费模型-修改出库特征",json_encode($request->input()));
|
|
|
- OwnerPriceOperationItemOut::$features = $result["map"];
|
|
|
|
|
- $rule = app('OwnerOutStorageRuleService')->find($id)->append("featureFormat");
|
|
|
|
|
|
|
+ OwnerPriceOperationItem::$features = $result["map"];
|
|
|
|
|
+ $rule = app('OwnerPriceOperationItemService')->find($id)->append("featureFormat");
|
|
|
return ["success"=>true,"data"=>["featureFormat"=>$rule->featureFormat,"feature"=>$feature]];
|
|
return ["success"=>true,"data"=>["featureFormat"=>$rule->featureFormat,"feature"=>$feature]];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -235,7 +242,7 @@ class PriceModelController extends Controller
|
|
|
public function operationStore(Request $request)
|
|
public function operationStore(Request $request)
|
|
|
{
|
|
{
|
|
|
if(!Gate::allows('计费模型-作业-录入')){ return redirect('denied'); }
|
|
if(!Gate::allows('计费模型-作业-录入')){ return redirect('denied'); }
|
|
|
- $request->offsetSet("rules",json_decode($request->input("rules"),true));
|
|
|
|
|
|
|
+ $request->offsetSet("items",json_decode($request->input("items"),true));
|
|
|
$request->offsetSet("owner_id",explode(',',$request->input("owner_id")));
|
|
$request->offsetSet("owner_id",explode(',',$request->input("owner_id")));
|
|
|
$this->operationValidator($request->input())->validate();
|
|
$this->operationValidator($request->input())->validate();
|
|
|
|
|
|
|
@@ -251,27 +258,19 @@ class PriceModelController extends Controller
|
|
|
"feature" => $request->input("feature"),
|
|
"feature" => $request->input("feature"),
|
|
|
]);
|
|
]);
|
|
|
//录入子表
|
|
//录入子表
|
|
|
- if ($request->input("operation_type") == '入库') $service->insertRule([
|
|
|
|
|
- "owner_price_operation_id" => $ownerPriceOperation->id,
|
|
|
|
|
- "amount" => $request->input("rules")[0]["amount"],
|
|
|
|
|
- "unit_id" => $request->input("rules")[0]["unit_id"],
|
|
|
|
|
- "unit_price" => $request->input("rules")[0]["unit_price"],
|
|
|
|
|
- ],"入库");
|
|
|
|
|
- else{
|
|
|
|
|
- $insert = [];
|
|
|
|
|
- foreach ($request->input("rules") as $rule){
|
|
|
|
|
- $insert[] = [
|
|
|
|
|
- "owner_price_operation_id" => $ownerPriceOperation->id,
|
|
|
|
|
- "amount" => $rule["amount"],
|
|
|
|
|
- "unit_id" => $rule["unit_id"],
|
|
|
|
|
- "unit_price" => $rule["unit_price"],
|
|
|
|
|
- "strategy" => $rule["strategy"],
|
|
|
|
|
- "feature" => $rule["feature"],
|
|
|
|
|
- "priority" => $rule["priority"],
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
- $service->insertRule($insert);
|
|
|
|
|
|
|
+ $insert = [];
|
|
|
|
|
+ foreach ($request->input("items") as $rule){
|
|
|
|
|
+ $insert[] = [
|
|
|
|
|
+ "owner_price_operation_id" => $ownerPriceOperation->id,
|
|
|
|
|
+ "amount" => $rule["amount"],
|
|
|
|
|
+ "unit_id" => $rule["unit_id"],
|
|
|
|
|
+ "unit_price" => $rule["unit_price"],
|
|
|
|
|
+ "strategy" => $rule["strategy"],
|
|
|
|
|
+ "feature" => $rule["feature"],
|
|
|
|
|
+ "priority" => $rule["priority"],
|
|
|
|
|
+ ];
|
|
|
}
|
|
}
|
|
|
|
|
+ $service->insertItem($insert);
|
|
|
//录入中间表
|
|
//录入中间表
|
|
|
/** @var OwnerPriceOperation $ownerPriceOperation */
|
|
/** @var OwnerPriceOperation $ownerPriceOperation */
|
|
|
if ($request->input("owner_id"))$ownerPriceOperation->ownerPriceOperationOwners()->sync($request->input("owner_id"));
|
|
if ($request->input("owner_id"))$ownerPriceOperation->ownerPriceOperationOwners()->sync($request->input("owner_id"));
|
|
@@ -282,7 +281,7 @@ class PriceModelController extends Controller
|
|
|
public function operationEdit($id)
|
|
public function operationEdit($id)
|
|
|
{
|
|
{
|
|
|
if(!Gate::allows('计费模型-作业-编辑')){ return redirect('denied'); }
|
|
if(!Gate::allows('计费模型-作业-编辑')){ return redirect('denied'); }
|
|
|
- $model = app('OwnerPriceOperationService')->find($id,true,["ownerPriceOperationOwners"]);
|
|
|
|
|
|
|
+ $model = app('OwnerPriceOperationService')->find($id,["items"]);
|
|
|
$owners = app("OwnerService")->getIntersectPermitting();
|
|
$owners = app("OwnerService")->getIntersectPermitting();
|
|
|
$units = app('UnitService')->getSelection();
|
|
$units = app('UnitService')->getSelection();
|
|
|
return response()->view('maintenance.priceModel.operation.create',compact("owners","units","model"));
|
|
return response()->view('maintenance.priceModel.operation.create',compact("owners","units","model"));
|
|
@@ -291,7 +290,7 @@ class PriceModelController extends Controller
|
|
|
public function operationUpdate($id,Request $request)
|
|
public function operationUpdate($id,Request $request)
|
|
|
{
|
|
{
|
|
|
if(!Gate::allows('计费模型-作业-编辑')){ return redirect('denied'); }
|
|
if(!Gate::allows('计费模型-作业-编辑')){ return redirect('denied'); }
|
|
|
- $request->offsetSet("rules",json_decode($request->input("rules"),true));
|
|
|
|
|
|
|
+ $request->offsetSet("items",json_decode($request->input("items"),true));
|
|
|
$request->offsetSet("owner_id",explode(',',$request->input("owner_id")));
|
|
$request->offsetSet("owner_id",explode(',',$request->input("owner_id")));
|
|
|
$this->operationValidator($request->input(),$id)->validate();
|
|
$this->operationValidator($request->input(),$id)->validate();
|
|
|
|
|
|
|
@@ -305,29 +304,21 @@ class PriceModelController extends Controller
|
|
|
"remark" => $request->input("remark"),
|
|
"remark" => $request->input("remark"),
|
|
|
"feature" => $request->input("feature"),
|
|
"feature" => $request->input("feature"),
|
|
|
]);
|
|
]);
|
|
|
- $service->destroyRule($id, $model->operation_type);
|
|
|
|
|
|
|
+ $service->destroyItem($id);
|
|
|
//录入子表
|
|
//录入子表
|
|
|
- if ($request->input("operation_type") == '入库') $service->insertRule([
|
|
|
|
|
- "owner_price_operation_id" => $model->id,
|
|
|
|
|
- "amount" => $request->input("rules")[0]["amount"],
|
|
|
|
|
- "unit_id" => $request->input("rules")[0]["unit_id"],
|
|
|
|
|
- "unit_price" => $request->input("rules")[0]["unit_price"],
|
|
|
|
|
- ],"入库");
|
|
|
|
|
- else{
|
|
|
|
|
- $insert = [];
|
|
|
|
|
- foreach ($request->input("rules") as $rule){
|
|
|
|
|
- $insert[] = [
|
|
|
|
|
- "owner_price_operation_id" => $model->id,
|
|
|
|
|
- "amount" => $rule["amount"],
|
|
|
|
|
- "unit_id" => $rule["unit_id"],
|
|
|
|
|
- "unit_price" => $rule["unit_price"],
|
|
|
|
|
- "strategy" => $rule["strategy"],
|
|
|
|
|
- "feature" => $rule["feature"],
|
|
|
|
|
- "priority" => $rule["priority"],
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
- $service->insertRule($insert);
|
|
|
|
|
|
|
+ $insert = [];
|
|
|
|
|
+ foreach ($request->input("items") as $rule){
|
|
|
|
|
+ $insert[] = [
|
|
|
|
|
+ "owner_price_operation_id" => $model->id,
|
|
|
|
|
+ "amount" => $rule["amount"],
|
|
|
|
|
+ "unit_id" => $rule["unit_id"],
|
|
|
|
|
+ "unit_price" => $rule["unit_price"],
|
|
|
|
|
+ "strategy" => $rule["strategy"],
|
|
|
|
|
+ "feature" => $rule["feature"],
|
|
|
|
|
+ "priority" => $rule["priority"],
|
|
|
|
|
+ ];
|
|
|
}
|
|
}
|
|
|
|
|
+ $service->insertItem($insert);
|
|
|
//录入中间表
|
|
//录入中间表
|
|
|
/** @var OwnerPriceOperation $model */
|
|
/** @var OwnerPriceOperation $model */
|
|
|
if ($request->input("owner_id"))$model->ownerPriceOperationOwners()->sync($request->input("owner_id"));
|
|
if ($request->input("owner_id"))$model->ownerPriceOperationOwners()->sync($request->input("owner_id"));
|
|
@@ -338,7 +329,6 @@ class PriceModelController extends Controller
|
|
|
private function operationValidator(array $params, $id= null)
|
|
private function operationValidator(array $params, $id= null)
|
|
|
{
|
|
{
|
|
|
return Validator::make($params,[
|
|
return Validator::make($params,[
|
|
|
- //required_with:id
|
|
|
|
|
'operation_type'=>['required'],
|
|
'operation_type'=>['required'],
|
|
|
'owner_id'=>[function ($attribute, $value, $fail)use($params,$id) {
|
|
'owner_id'=>[function ($attribute, $value, $fail)use($params,$id) {
|
|
|
if ($params["strategy"] == '默认'){
|
|
if ($params["strategy"] == '默认'){
|
|
@@ -355,15 +345,11 @@ class PriceModelController extends Controller
|
|
|
}],
|
|
}],
|
|
|
'strategy'=>['required'],
|
|
'strategy'=>['required'],
|
|
|
'name'=>['required',$id?"unique:owner_price_operations,name,$id":'unique:owner_price_operations,name'],
|
|
'name'=>['required',$id?"unique:owner_price_operations,name,$id":'unique:owner_price_operations,name'],
|
|
|
- 'priority'=>['required','integer','min:0','max:100'],
|
|
|
|
|
- 'rules.*.strategy'=>['required_if:operation_type,出库'],
|
|
|
|
|
- 'rules.*.amount'=>[Rule::requiredIf(function () use ($params) {
|
|
|
|
|
- if ("operation_type" == "入库")return true;
|
|
|
|
|
- return false;
|
|
|
|
|
- }),"integer"],
|
|
|
|
|
- 'rules.*.unit_id'=>['required','integer'],
|
|
|
|
|
- 'rules.*.unit_price'=>['required','numeric',"min:0"],
|
|
|
|
|
- 'rules.*.priority'=>['required_if:operation_type,出库','integer','min:0','max:100'],
|
|
|
|
|
|
|
+ 'priority'=>['sometimes','required','integer','min:0','max:100'],
|
|
|
|
|
+ 'items.*.strategy'=>['required'],
|
|
|
|
|
+ 'items.*.amount'=>["required","integer"],
|
|
|
|
|
+ 'items.*.unit_id'=>['required','integer'],
|
|
|
|
|
+ 'items.*.unit_price'=>['required','numeric',"min:0"],
|
|
|
],[
|
|
],[
|
|
|
'required'=>':attribute 为必填项',
|
|
'required'=>':attribute 为必填项',
|
|
|
'min'=>':attribute 不得小于0',
|
|
'min'=>':attribute 不得小于0',
|
|
@@ -375,7 +361,6 @@ class PriceModelController extends Controller
|
|
|
'operation_type' =>"操作类型",
|
|
'operation_type' =>"操作类型",
|
|
|
'strategy' =>"计费策略",
|
|
'strategy' =>"计费策略",
|
|
|
'name' =>"名称",
|
|
'name' =>"名称",
|
|
|
- 'priority' =>"优先级",
|
|
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -511,21 +496,28 @@ class PriceModelController extends Controller
|
|
|
'name'=>['required',$id?"unique:owner_price_expresses,name,$id":'unique:owner_price_expresses,name'],
|
|
'name'=>['required',$id?"unique:owner_price_expresses,name,$id":'unique:owner_price_expresses,name'],
|
|
|
'initial_weight'=>['required','numeric','min:0'],
|
|
'initial_weight'=>['required','numeric','min:0'],
|
|
|
'additional_weight'=>['required','numeric','min:0'],
|
|
'additional_weight'=>['required','numeric','min:0'],
|
|
|
- 'owner_id'=>[function ($attribute, $value, $fail)use($id) {
|
|
|
|
|
- $owners = app("OwnerPriceExpressService")->getExistOwnerName($value,$id);
|
|
|
|
|
|
|
+ 'owner_id'=>[function ($attribute, $value, $fail)use($id,$params) {
|
|
|
|
|
+ $owners = app("OwnerPriceExpressService")->getExistOwnerName($value,$params["logistic_id"] ?? [],$id);
|
|
|
if ($owners)$fail("(".implode(',',$owners).') 已经绑定计费模型');
|
|
if ($owners)$fail("(".implode(',',$owners).') 已经绑定计费模型');
|
|
|
}],
|
|
}],
|
|
|
- 'logistic_id'=>[function ($attribute, $value, $fail)use($id) {
|
|
|
|
|
|
|
+ /*'logistic_id'=>[function ($attribute, $value, $fail)use($id) {
|
|
|
$logistics = app("OwnerPriceExpressService")->getExistLogisticName($value,$id);
|
|
$logistics = app("OwnerPriceExpressService")->getExistLogisticName($value,$id);
|
|
|
if ($logistics)$fail("(".implode(',',$logistics).') 已经绑定计费模型');
|
|
if ($logistics)$fail("(".implode(',',$logistics).') 已经绑定计费模型');
|
|
|
- }],
|
|
|
|
|
|
|
+ }],*/
|
|
|
|
|
+ 'items.*.province_id'=>['sometimes','required'],
|
|
|
|
|
+ 'items.*.additional_weight_price'=>['sometimes','required','numeric',"min:0"],
|
|
|
|
|
+ 'items.*.initial_weight_price'=>['sometimes','required','numeric',"min:0"],
|
|
|
],[
|
|
],[
|
|
|
'required'=>':attribute 为必填项',
|
|
'required'=>':attribute 为必填项',
|
|
|
'unique' => ':attribute 已存在',
|
|
'unique' => ':attribute 已存在',
|
|
|
|
|
+ 'min' => ':attribute 不得小于0',
|
|
|
],[
|
|
],[
|
|
|
'name' =>"名称",
|
|
'name' =>"名称",
|
|
|
'initial_weight' =>"首重",
|
|
'initial_weight' =>"首重",
|
|
|
'additional_weight' =>"续重",
|
|
'additional_weight' =>"续重",
|
|
|
|
|
+ "items.*.province_id"=>"省份",
|
|
|
|
|
+ "items.*.additional_weight_price"=>"首重价格",
|
|
|
|
|
+ "items.*.initial_weight_price"=>"续重价格",
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -797,6 +789,19 @@ class PriceModelController extends Controller
|
|
|
$bool = app("OwnerPriceLogisticService")->checkRange($value);
|
|
$bool = app("OwnerPriceLogisticService")->checkRange($value);
|
|
|
if (!$bool)$fail("格式错误,值必须为连续的且最后一个值不允许封闭");
|
|
if (!$bool)$fail("格式错误,值必须为连续的且最后一个值不允许封闭");
|
|
|
}],
|
|
}],
|
|
|
|
|
+ 'owner_id'=>[function ($attribute, $value, $fail)use($id,$params) {
|
|
|
|
|
+ $owners = app("OwnerPriceExpressService")->getExistOwnerName($value,$params["logistic_id"] ?? [],$id,"ownerPriceLogistics");
|
|
|
|
|
+ if ($owners)$fail("(".implode(',',$owners).') 已经绑定计费模型');
|
|
|
|
|
+ }],
|
|
|
|
|
+ 'items.*.unit_id'=>['sometimes','required'],
|
|
|
|
|
+ 'items.*.range'=>['sometimes','required'],
|
|
|
|
|
+ 'items.*.province_id'=>['sometimes','required'],
|
|
|
|
|
+ 'items.*.city_id'=>['sometimes','required'],
|
|
|
|
|
+ 'items.*.unit_price'=>['sometimes','nullable','numeric',"min:0"],
|
|
|
|
|
+ 'items.*.delivery_fee'=>['sometimes','nullable','numeric',"min:0"],
|
|
|
|
|
+ 'items.*.initial_fee'=>['sometimes','nullable','numeric',"min:0"],
|
|
|
|
|
+ 'items.*.initial_amount'=>['sometimes','nullable','numeric',"min:0"],
|
|
|
|
|
+ 'items.*.rate'=>['sometimes','nullable','numeric',"min:0"],
|
|
|
],[
|
|
],[
|
|
|
'required'=>':attribute 为必填项',
|
|
'required'=>':attribute 为必填项',
|
|
|
'unique' => ':attribute 已存在',
|
|
'unique' => ':attribute 已存在',
|
|
@@ -811,6 +816,15 @@ class PriceModelController extends Controller
|
|
|
'unit_range' =>"区间值",
|
|
'unit_range' =>"区间值",
|
|
|
'other_unit_id' =>"单位二",
|
|
'other_unit_id' =>"单位二",
|
|
|
'other_unit_range' =>"区间值",
|
|
'other_unit_range' =>"区间值",
|
|
|
|
|
+ 'items.*.unit_id'=>"单位",
|
|
|
|
|
+ 'items.*.range'=>"区间",
|
|
|
|
|
+ 'items.*.province_id'=>"省份",
|
|
|
|
|
+ 'items.*.city_id'=>"城市",
|
|
|
|
|
+ 'items.*.unit_price'=>"单价",
|
|
|
|
|
+ 'items.*.delivery_fee'=>"送货费",
|
|
|
|
|
+ 'items.*.initial_fee'=>"起始计费",
|
|
|
|
|
+ 'items.*.initial_amount'=>"起始计数",
|
|
|
|
|
+ 'items.*.rate'=>"费率",
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -969,4 +983,458 @@ class PriceModelController extends Controller
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function apiStoreStorage()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $errors = $this->storageValidator(request()->input())->errors();
|
|
|
|
|
+ if (count($errors)>0)$this->success(["errors"=>$errors]);
|
|
|
|
|
+
|
|
|
|
|
+ if (!request("owner_id"))$this->error("参数传递错误");
|
|
|
|
|
+ $values = [
|
|
|
|
|
+ "name" => request("name"),
|
|
|
|
|
+ "counting_type" => request("counting_type"),
|
|
|
|
|
+ "using_type" => request("using_type"),
|
|
|
|
|
+ "minimum_area" => request("minimum_area"),
|
|
|
|
|
+ "price" => request("price"),
|
|
|
|
|
+ "discount_type" => request("discount_type"),
|
|
|
|
|
+ "discount_value" => request("discount_value"),
|
|
|
|
|
+ "unit_id" => request("unit_id"),
|
|
|
|
|
+ ];
|
|
|
|
|
+ if (request("id"))app('OwnerStoragePriceModelService')->update(["id"=>request("id")],$values);
|
|
|
|
|
+ else{
|
|
|
|
|
+ DB::transaction(function ()use(&$model,$values){
|
|
|
|
|
+ $model = app('OwnerStoragePriceModelService')->create($values);
|
|
|
|
|
+ DB::insert(DB::raw("INSERT INTO owner_storage_price_model_owner VALUES(?,?)"),[$model->id,request("owner_id")]);
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ });
|
|
|
|
|
+ $this->success($model->id);
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function apiStoreOperation()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+
|
|
|
|
|
+ $params = request()->input();
|
|
|
|
|
+ if (request("operation_type") == '入库'){
|
|
|
|
|
+ foreach ($params["items"] as $index => $it){
|
|
|
|
|
+ if (!$it || $it['strategy'] == '起步'){
|
|
|
|
|
+ unset($params["items"][$index]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $params["owner_id"] = [$params["owner_id"]];
|
|
|
|
|
+ $errors = $this->operationValidator($params,request("id"))->errors();
|
|
|
|
|
+ if (count($errors)>0)$this->success(["errors"=>$errors]);
|
|
|
|
|
+
|
|
|
|
|
+ if (!request("owner_id"))$this->error("参数传递错误");
|
|
|
|
|
+ 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"),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $delete = [];//需要删除子项
|
|
|
|
|
+ $update = [["id","strategy","amount","unit_id","unit_price","feature"]];//需要更新子项
|
|
|
|
|
+ $insert = [];//需要新增子项
|
|
|
|
|
+ foreach ($params["items"] as $item){
|
|
|
|
|
+ $obj = [
|
|
|
|
|
+ "strategy" => $item["strategy"],
|
|
|
|
|
+ "amount" => $item["amount"],
|
|
|
|
|
+ "unit_id" => $item["unit_id"],
|
|
|
|
|
+ "unit_price"=> $item["unit_price"],
|
|
|
|
|
+ "feature" => $item["feature"],
|
|
|
|
|
+ ];
|
|
|
|
|
+ if (isset($item["id"])){
|
|
|
|
|
+ $obj["id"] = $item["id"];
|
|
|
|
|
+ $update[] = $obj;
|
|
|
|
|
+ $delete[] = $item["id"];
|
|
|
|
|
+ } else{
|
|
|
|
|
+ $obj["owner_price_operation_id"] = $model->id;
|
|
|
|
|
+ $obj["feature"] = $item["feature"] ?? null;
|
|
|
|
|
+ $insert[] = $obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $ids = array_column($model->items->toArray(),"id");
|
|
|
|
|
+ $delete = array_diff($ids,$delete);
|
|
|
|
|
+ if ($delete)app("OwnerPriceOperationItemService")->destroy($delete);
|
|
|
|
|
+ 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"),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ foreach ($params["items"] as &$item){
|
|
|
|
|
+ $item["owner_price_operation_id"] = $model->id;
|
|
|
|
|
+ if (!isset($item["feature"]))$item["feature"] = null;
|
|
|
|
|
+ unset($item["features"]);
|
|
|
|
|
+ unset($item["featureFormat"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ app("OwnerPriceOperationItemService")->insert($params["items"]);
|
|
|
|
|
+ DB::insert(DB::raw("INSERT INTO owner_price_operation_owner VALUES(?,?)"),[$model->id,request("owner_id")]);
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ /** @var OwnerPriceOperation $model */
|
|
|
|
|
+ $model->load("items");
|
|
|
|
|
+ $this->success($model);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function apiStoreExpress()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $params = request()->input();
|
|
|
|
|
+ $params["logistic_id"] = $params["logistics"];
|
|
|
|
|
+ $errors = $this->expressValidator($params)->errors();
|
|
|
|
|
+ $exist = [];
|
|
|
|
|
+ foreach ($params["items"] as $index => $item){
|
|
|
|
|
+ if (isset($exist[$item["province_id"]]))$errors["items.".$index.".province_id"] = ["已存在"];
|
|
|
|
|
+ else $exist[$item["province_id"]] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (count($errors)>0)$this->success(["errors"=>$errors]);
|
|
|
|
|
+
|
|
|
|
|
+ DB::transaction(function ()use(&$model,$params){
|
|
|
|
|
+ $model = app('OwnerPriceExpressService')->create([
|
|
|
|
|
+ "name" => request("name"),
|
|
|
|
|
+ "initial_weight" => request("initial_weight"),
|
|
|
|
|
+ "additional_weight" => request("additional_weight"),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ foreach ($params["items"] as &$item)$item["owner_price_express_id"] = $model->id;
|
|
|
|
|
+ OwnerPriceExpressProvince::query()->insert($params["items"]);
|
|
|
|
|
+ DB::insert(DB::raw("INSERT INTO owner_price_express_owner VALUES(?,?)"),[$model->id,request("owner_id")]);
|
|
|
|
|
+ /** @var OwnerPriceExpress $model */
|
|
|
|
|
+ $model->logistics()->syncWithoutDetaching(request("logistics"));
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ });
|
|
|
|
|
+ $model->load("details");
|
|
|
|
|
+ $this->success($model);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function apiStoreLogistic()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $params = request()->input();
|
|
|
|
|
+ $params["owner_id"] = [$params["owner_id"]];
|
|
|
|
|
+ $params["logistic_id"] = $params["logistics"];
|
|
|
|
|
+ $errors = $this->logisticValidator($params)->errors();
|
|
|
|
|
+ $exist = [];
|
|
|
|
|
+ foreach ($params["items"] as $index => $item){
|
|
|
|
|
+ $key = $item["unit_id"]."-".$item["range"]."-".$item["province_id"]."-".$item["city_id"];
|
|
|
|
|
+ if (isset($exist[$key]))$errors["items.".$index.".unit_id"] = ["该条已存在"];
|
|
|
|
|
+ else $exist[$key] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (count($errors)>0)$this->success(["errors"=>$errors]);
|
|
|
|
|
+ DB::transaction(function ()use(&$model,$params){
|
|
|
|
|
+ $model = app("OwnerPriceLogisticService")->create([
|
|
|
|
|
+ "name" => request('name'),
|
|
|
|
|
+ "unit_range" => request('unit_range'),
|
|
|
|
|
+ "unit_id" => request('unit_id'),
|
|
|
|
|
+ "other_unit_range" => request('other_unit_range'),
|
|
|
|
|
+ "other_unit_id" => request('other_unit_id'),
|
|
|
|
|
+ "pick_up_price" => request('pick_up_price'),
|
|
|
|
|
+ "fuel_price" => request('fuel_price'),
|
|
|
|
|
+ "service_price" => request('service_price'),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ foreach ($params["items"] as &$param)$param["owner_price_logistic_id"] = $model->id;
|
|
|
|
|
+ OwnerPriceLogisticDetail::query()->insert($params["items"]);
|
|
|
|
|
+ DB::insert(DB::raw("INSERT INTO owner_price_logistic_owner VALUES(?,?)"),[$model->id,request("owner_id")]);
|
|
|
|
|
+ /** @var OwnerPriceLogistic $model */
|
|
|
|
|
+ $model->logistics()->syncWithoutDetaching(request("logistics"));
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ });
|
|
|
|
|
+ $model->load("details");
|
|
|
|
|
+ $this->success($model);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function apiStoreDirectLogistic()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $errors = $this->directLogisticValidator(request()->input())->errors();
|
|
|
|
|
+ $exist = [];
|
|
|
|
|
+ foreach (request("items") as $index=>$item){
|
|
|
|
|
+ if (isset($exist[$item['car_type_id']]))$errors["items.".$index.".car_type_id"] = ["已存在"];
|
|
|
|
|
+ else $exist[$item['car_type_id']] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (count($errors)>0)$this->success(["errors"=>$errors]);
|
|
|
|
|
+
|
|
|
|
|
+ $items = request()->input("items");
|
|
|
|
|
+ DB::transaction(function ()use(&$model,$items){
|
|
|
|
|
+ $model = app("OwnerPriceDirectLogisticService")->create([
|
|
|
|
|
+ "name" => request("name"),
|
|
|
|
|
+ "base_km" => request("base_km"),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ foreach ($items as &$item)$item["owner_price_direct_logistic_id"] = $model->id;
|
|
|
|
|
+ OwnerPriceDirectLogisticCar::query()->insert($items);
|
|
|
|
|
+ DB::insert(DB::raw("INSERT INTO owner_price_direct_logistic_owner VALUES(?,?)"),[$model->id,request("owner_id")]);
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ });
|
|
|
|
|
+ $model->load("details");
|
|
|
|
|
+ $this->success($model);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getPriceModel()
|
|
|
|
|
+ {
|
|
|
|
|
+ $owner = new Owner();
|
|
|
|
|
+ $owner->id = request("id");
|
|
|
|
|
+ $owner->load(["ownerStoragePriceModels","ownerPriceOperations.items","ownerPriceExpresses"=>function($query){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->with(["details","logistics"]);
|
|
|
|
|
+ },"ownerPriceLogistics"=>function($query){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->with(["details","logistics"]);
|
|
|
|
|
+ },"ownerPriceDirectLogistics.details"]);
|
|
|
|
|
+ $features = app("FeatureService")->getMapArray();
|
|
|
|
|
+ OwnerPriceOperation::$features = $features;
|
|
|
|
|
+ OwnerPriceOperationItem::$features = $features;
|
|
|
|
|
+ foreach ($owner->ownerPriceOperations as &$operation){
|
|
|
|
|
+ $operation["featureFormat"] = $operation->featureFormat;
|
|
|
|
|
+ foreach ($operation->items as &$item){
|
|
|
|
|
+ $item["featureFormat"] = $item->featureFormat;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success($owner);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function apiGetStorage()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $models = OwnerStoragePriceModel::query();
|
|
|
|
|
+ if (request("customer_id")){
|
|
|
|
|
+ $customerId = request("customer_id");
|
|
|
|
|
+ $models->whereHas("owners",function ($query)use($customerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("customer_id",$customerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("owner_id")){
|
|
|
|
|
+ $ownerId = request("owner_id");
|
|
|
|
|
+ $models->whereHas("owners",function ($query)use($ownerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("id",$ownerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("name")){
|
|
|
|
|
+ $models->where("name","like","%".request("name")."%");
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success($models->get());
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiGetOperation()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $models = OwnerPriceOperation::query()->with("items");
|
|
|
|
|
+ if (request("customer_id")){
|
|
|
|
|
+ $customerId = request("customer_id");
|
|
|
|
|
+ $models->whereHas("ownerPriceOperationOwners",function ($query)use($customerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("customer_id",$customerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("owner_id")){
|
|
|
|
|
+ $ownerId = request("owner_id");
|
|
|
|
|
+ $models->whereHas("ownerPriceOperationOwners",function ($query)use($ownerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("id",$ownerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("name")){
|
|
|
|
|
+ $models->where("name","like","%".request("name")."%");
|
|
|
|
|
+ }
|
|
|
|
|
+ $features = app("FeatureService")->getMapArray();
|
|
|
|
|
+ OwnerPriceOperation::$features = $features;
|
|
|
|
|
+ OwnerPriceOperationItem::$features = $features;
|
|
|
|
|
+ $models = $models->get();
|
|
|
|
|
+ foreach ($models as &$operation){
|
|
|
|
|
+ $operation["featureFormat"] = $operation->featureFormat;
|
|
|
|
|
+ $items = [[],[]];
|
|
|
|
|
+ foreach ($operation->items as $item){
|
|
|
|
|
+ $obj = [
|
|
|
|
|
+ "strategy" => $item["strategy"],
|
|
|
|
|
+ "amount" => $item["amount"],
|
|
|
|
|
+ "unit_id" => $item["unit_id"],
|
|
|
|
|
+ "unit_price" => $item["unit_price"],
|
|
|
|
|
+ "feature" => $item["feature"],
|
|
|
|
|
+ "featureFormat" => $item->featureFormat,
|
|
|
|
|
+ ];
|
|
|
|
|
+ if ($item["strategy"] == '起步')$items[0] = $obj;
|
|
|
|
|
+ if ($item["strategy"] == '默认')$items[1] = $obj;
|
|
|
|
|
+ if ($item["strategy"] == '特征')$items[] = $obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!$items[0])$items[0] = [
|
|
|
|
|
+ "strategy" => "起步",
|
|
|
|
|
+ "amount" => "",
|
|
|
|
|
+ "unit_id" => "",
|
|
|
|
|
+ "unit_price" => "",
|
|
|
|
|
+ "feature" => "",
|
|
|
|
|
+ ];
|
|
|
|
|
+ if (!$items[1])$items[1] = [
|
|
|
|
|
+ "strategy" => "默认",
|
|
|
|
|
+ "amount" => "",
|
|
|
|
|
+ "unit_id" => "",
|
|
|
|
|
+ "unit_price" => "",
|
|
|
|
|
+ "feature" => "",
|
|
|
|
|
+ ];
|
|
|
|
|
+ unset($operation["items"]);
|
|
|
|
|
+ $operation["items"] = $items;
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success($models);
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiGetExpress()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $models = OwnerPriceExpress::query()->with(["details","logistics:id"]);
|
|
|
|
|
+ if (request("customer_id")){
|
|
|
|
|
+ $customerId = request("customer_id");
|
|
|
|
|
+ $models->whereHas("owners",function ($query)use($customerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("customer_id",$customerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("owner_id")){
|
|
|
|
|
+ $ownerId = request("owner_id");
|
|
|
|
|
+ $models->whereHas("owners",function ($query)use($ownerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("id",$ownerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("logistic_id")){
|
|
|
|
|
+ $logisticId = request("logistic_id");
|
|
|
|
|
+ $models->whereHas("logistics",function ($query)use($logisticId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("id",$logisticId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("name")){
|
|
|
|
|
+ $models->where("name","like","%".request("name")."%");
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success($models->get());
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiGetLogistic()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $models = OwnerPriceLogistic::query()->with(["details","logistics"]);
|
|
|
|
|
+ if (request("customer_id")){
|
|
|
|
|
+ $customerId = request("customer_id");
|
|
|
|
|
+ $models->whereHas("owners",function ($query)use($customerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("customer_id",$customerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("owner_id")){
|
|
|
|
|
+ $ownerId = request("owner_id");
|
|
|
|
|
+ $models->whereHas("owners",function ($query)use($ownerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("id",$ownerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("logistic_id")){
|
|
|
|
|
+ $logisticId = request("logistic_id");
|
|
|
|
|
+ $models->whereHas("logistics",function ($query)use($logisticId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("id",$logisticId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("name")){
|
|
|
|
|
+ $models->where("name","like","%".request("name")."%");
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success($models->get());
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiGetDirectLogistic()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ $models = OwnerPriceDirectLogistic::query()->with("details");
|
|
|
|
|
+ if (request("customer_id")){
|
|
|
|
|
+ $customerId = request("customer_id");
|
|
|
|
|
+ $models->whereHas("owners",function ($query)use($customerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("customer_id",$customerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("owner_id")){
|
|
|
|
|
+ $ownerId = request("owner_id");
|
|
|
|
|
+ $models->whereHas("owners",function ($query)use($ownerId){
|
|
|
|
|
+ /** @var Builder $query */
|
|
|
|
|
+ $query->where("id",$ownerId);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request("name")){
|
|
|
|
|
+ $models->where("name","like","%".request("name")."%");
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success($models->get());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function apiDelStorage()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerStoragePriceModelService")->destroy(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiDelOperation()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerPriceOperationService")->destroy(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiDelOperationItem()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerPriceOperationItemService")->destroy(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiDelExpress()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerPriceExpressService")->destroy(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiDelExpressItem()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerPriceExpressService")->destroyDetail(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiDelLogistic()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerPriceLogisticService")->destroy(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiDelLogisticItem()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerPriceLogisticService")->destroyDetail(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiDelDirectLogistic()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerPriceDirectLogisticService")->destroy(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+ public function apiDelDirectLogisticItem()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->gate("客户管理-项目-录入");
|
|
|
|
|
+ if (!request("id"))$this->error("非法参数");
|
|
|
|
|
+ app("OwnerPriceDirectLogisticService")->destroyDetail(request("id"));
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|