|
@@ -30,6 +30,18 @@ class CustomerService extends Service
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
+ //车型
|
|
|
+ if(empty($data['car_type']) && ! empty($data['car_type_title'])){
|
|
|
+ $model_2 = new BasicType();
|
|
|
+ $model_2->title = $data['car_type_title'];
|
|
|
+ $model_2->type = 10;
|
|
|
+ $model_2->depart_id = $data['depart_id'] ?? 0;
|
|
|
+ $model_2->top_depart_id = $data['top_depart_id'] ?? 0;
|
|
|
+ $model_2->crt_id = $user['id'];
|
|
|
+ $model_2->save();
|
|
|
+ $data['car_type'] = $model_2->id;
|
|
|
+ }
|
|
|
+
|
|
|
$model = Customer::where('id',$data['id'])->first();
|
|
|
$model->title = $data['title'];
|
|
|
$model->code = $data['code'] ?? "";
|
|
@@ -170,6 +182,18 @@ class CustomerService extends Service
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
+ //车型
|
|
|
+ if(empty($data['car_type']) && ! empty($data['car_type_title'])){
|
|
|
+ $model_2 = new BasicType();
|
|
|
+ $model_2->title = $data['car_type_title'];
|
|
|
+ $model_2->type = 10;
|
|
|
+ $model_2->depart_id = $data['depart_id'] ?? 0;
|
|
|
+ $model_2->top_depart_id = $data['top_depart_id'] ?? 0;
|
|
|
+ $model_2->crt_id = $user['id'];
|
|
|
+ $model_2->save();
|
|
|
+ $data['car_type'] = $model_2->id;
|
|
|
+ }
|
|
|
+
|
|
|
$model = new Customer();
|
|
|
$model->title = $data['title'];
|
|
|
$model->code = $data['code'] ?? "";
|
|
@@ -558,6 +582,16 @@ class CustomerService extends Service
|
|
|
// if(empty($data['customer_contact'])) return [false,'客户联系方式不能为空'];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if(empty($data['car_type']) && ! empty($data['car_type_title'])){
|
|
|
+ $bool = BasicType::where('title',$data['car_type_title'])
|
|
|
+ ->where('top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('type',10)
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->exists();
|
|
|
+ if($bool) return [false,'车型名称已存在'];
|
|
|
+ }
|
|
|
+
|
|
|
if($is_add){
|
|
|
$bool = Customer::where('del_time',0)
|
|
|
->where('top_depart_id',$data['top_depart_id'])
|