diff --git a/app/common/repositories/system/merchant/MerchantIntentionRepository.php b/app/common/repositories/system/merchant/MerchantIntentionRepository.php index b4632868..7eb92021 100644 --- a/app/common/repositories/system/merchant/MerchantIntentionRepository.php +++ b/app/common/repositories/system/merchant/MerchantIntentionRepository.php @@ -104,6 +104,7 @@ class MerchantIntentionRepository extends BaseRepository $create = $data['create_mer'] == 1; unset($data['create_mer']); $intention = $this->search(['mer_intention_id' => $id])->find(); + if (!$intention) throw new ValidateException('信息不存在'); if ($intention->status) @@ -129,7 +130,11 @@ class MerchantIntentionRepository extends BaseRepository 'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1, 'mer_password' => $password, 'is_margin' => $margin['is_margin'] ?? -1, - 'margin' => $margin['margin'] ?? 0 + 'margin' => $margin['margin'] ?? 0, + 'area_id' => $intention['area_id'] ?? 0, + 'geo_street' => $intention['street_id'] ?? 0, + 'village_id' => $intention['village_id'] ?? 0, + 'is_nmsc' => $intention['is_nmsc'] ?? 0, ]; if ($data['status'] == 1) { $data['fail_msg'] = ''; diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 270645a1..26948f2a 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -120,8 +120,9 @@ class MerchantRepository extends BaseRepository $merchantTypeRepository = app()->make(MerchantTypeRepository::class); $options = $merchantTypeRepository->getOptions(); $margin = $merchantTypeRepository->getMargin(); - $formData['geo_street']=Db::name('merchant_address')->where('mer_id',$id)->find(); + $config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']); + $rule = [ Elm::input('mer_name', '商户名称')->required(), Elm::select('category_id', '商户分类')->options(function () use ($make) { @@ -252,8 +253,10 @@ class MerchantRepository extends BaseRepository $merchant = $this->dao->create($data); $make->createMerchantAccount($merchant, $account, $password); - $adds=['mer_id'=>$merchant->mer_id,'area_id'=>$data['geo_street'][0],'street_id'=>$data['geo_street'][1],'village_id'=>$data['geo_street'][2]]; - Db::name('merchant_address')->insert($adds); + $address_id = Db::name('merchant_address')->insertGetId(['mer_id'=>$merchant->mer_id,'street_id'=>$data['geo_street']]); + if($data['area_id'] && $data['village_id']){ + Db::name('merchant_address')->where('id',$address_id)->update(['area_id'=>$data['area_id'],'village_id'=>$data['village_id']]); + } app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id); app()->make(ProductCopyRepository::class)->defaulCopyNum($merchant->mer_id); return $merchant; diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index cc0f8236..e81b065b 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -106,7 +106,7 @@ class MerchantIntention extends BaseController protected function checkParams() { - $data = $this->request->params(['phone', 'mer_name', 'name', 'code', 'images', 'merchant_category_id', 'mer_type_id']); + $data = $this->request->params(['phone', 'mer_name', 'name', 'code', 'images', 'merchant_category_id', 'mer_type_id','area_id','street_id','village_id','is_nmsc']); app()->make(MerchantIntentionValidate::class)->check($data); $check = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['code'], 'intention'); $data['mer_type_id'] = (int)$data['mer_type_id'];