Browse Source

up - MasterWorkerRegister

liugc 1 năm trước cách đây
mục cha
commit
db1dadc046

+ 24 - 21
app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php

@@ -157,27 +157,30 @@ class MasterWorkerRegisterLogic extends BaseLogic
                 'category_ids' => $params['category_ids']??'',
             ]);
 
-            MasterWorkerRegister::create([
-                'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
-                'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
-                'other_exp_name' => (isset($params['other_exp_name']) && isset($params['other_exp_type']) && $params['other_exp_type'] == 4)?$params['other_exp_name']:'',
-                'province' => $params['province']??0,
-                'city' => $params['city']??0,
-                'area_name' => $params['area_name']??'',
-                'vehicle_type' => $params['vehicle_type']??0,
-                'name' => $params['real_name']??'',
-                'age' => $params['age']??0,
-                'sex' => $params['sex']??0,
-                'status' => 1,
-                'worker_id' => $masterWorker->id,
-                'mobile' => $params['mobile'],
-                'is_credential' => !empty($params['is_credential'])?$params['is_credential']:0,
-                'credential_name' => !empty($params['credential_name'])?$params['credential_name']:'',
-                'credential_images'=>!empty($params['credential_images'])?json_encode($params['credential_images'],JSON_UNESCAPED_UNICODE):'',
-                'lon' => !empty($params['lon'])?$params['lon']:0,
-                'lat' => !empty($params['lat'])?$params['lat']:0,
-                'address' => !empty($params['address'])?$params['address']:'',
-            ]);
+            $masterWorkerRegister = MasterWorkerRegister::where($where)->findOrEmpty();
+            if ($masterWorkerRegister->isEmpty()) {
+                MasterWorkerRegister::create([
+                    'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
+                    'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
+                    'other_exp_name' => (isset($params['other_exp_name']) && isset($params['other_exp_type']) && $params['other_exp_type'] == 4)?$params['other_exp_name']:'',
+                    'province' => $params['province']??0,
+                    'city' => $params['city']??0,
+                    'area_name' => $params['area_name']??'',
+                    'vehicle_type' => $params['vehicle_type']??0,
+                    'name' => $params['real_name']??'',
+                    'age' => $params['age']??0,
+                    'sex' => $params['sex']??0,
+                    'status' => 1,
+                    'worker_id' => $masterWorker->id,
+                    'mobile' => $params['mobile'],
+                    'is_credential' => !empty($params['is_credential'])?$params['is_credential']:0,
+                    'credential_name' => !empty($params['credential_name'])?$params['credential_name']:'',
+                    'credential_images'=>!empty($params['credential_images'])?json_encode($params['credential_images'],JSON_UNESCAPED_UNICODE):'',
+                    'lon' => !empty($params['lon'])?$params['lon']:0,
+                    'lat' => !empty($params['lat'])?$params['lat']:0,
+                    'address' => !empty($params['address'])?$params['address']:'',
+                ]);
+            }
         }
         return $masterWorker->id;
     }