diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 36ab72c..876d9c6 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -214,17 +214,13 @@ class MerchantRepository extends BaseRepository */ public function createMerchant(array $data) { - if ($this->fieldExists('mer_name', $data['mer_name'])) - throw new ValidateException('商户名已存在'); - if ($data['mer_phone'] && isPhone($data['mer_phone'])) - throw new ValidateException('请输入正确的手机号'); + if ($this->fieldExists('mer_name', $data['mer_name'])) throw new ValidateException('商户名已存在'); + if ($data['mer_phone'] && isPhone($data['mer_phone'])) throw new ValidateException('请输入正确的手机号'); $merchantCategoryRepository = app()->make(MerchantCategoryRepository::class); $adminRepository = app()->make(MerchantAdminRepository::class); - if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) - throw new ValidateException('商户分类不存在'); - if ($adminRepository->fieldExists('account', $data['mer_account'])) - throw new ValidateException('账号已存在'); + // if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) throw new ValidateException('商户分类不存在'); + if ($adminRepository->fieldExists('account', $data['mer_account'])) throw new ValidateException('账号已存在'); /** @var MerchantAdminRepository $make */ $make = app()->make(MerchantAdminRepository::class); diff --git a/app/services/supplier/SystemSupplierApplyServices.php b/app/services/supplier/SystemSupplierApplyServices.php index 4e96e39..e4938fe 100644 --- a/app/services/supplier/SystemSupplierApplyServices.php +++ b/app/services/supplier/SystemSupplierApplyServices.php @@ -1,6 +1,10 @@ transaction(function() use ($params){ // 修改状态 $this->update($params['id'],['status'=>$params['status']]); - // 自动生成账号信息 + // 自动生成账号信息 —— 供应链信息 $applyInfo = $this->searchModel(['id'=>$params['id']])->findOrEmpty()->toArray(); app()->make(SystemSupplierServices::class)->create([ 'accountInfo' => [ @@ -118,6 +122,47 @@ class SystemSupplierApplyServices extends BaseServices{ 'supplier_password' => substr($applyInfo['contacts_phone'],-6), ], ]); + // 自动生成账号信息 —— 供应商信息 + $password = substr($applyInfo['contacts_phone'],-6); + $config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']); + $merchant = app()->make(MerchantRepository::class)->createMerchant([ + 'mer_name' => $applyInfo['winery_name'], + 'mer_phone' => $applyInfo['contacts_phone'], + 'mer_account' => $applyInfo['contacts_phone'], + 'category_id' => 0, + 'type_id' => 0, + 'real_name' => $applyInfo['contacts_name'], + 'status' => 1, + 'is_audit' => 1, + 'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1, + 'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1, + 'mer_password' => $password, + 'is_margin' => $margin['is_margin'] ?? -1, + 'margin' => $margin['margin'] ?? 0, + 'merchant_type' => 2,// 商户类别:0=普通商户,1=酒道馆,2=供应商 + ]); + // 存在默认管理员信息 生成管理员 + $staffUserInfo = User::where('uid', $applyInfo['uid'])->findOrEmpty()->toArray(); + $staffData = [ + 'uid' => $applyInfo['uid'], + 'nickname' => $staffUserInfo['nickname'] ?? $staffUserInfo['real_name'], + 'account' => $applyInfo['contacts_phone'], + 'pwd' => $password, + 'is_open' => 1, + 'status' => 1, + 'customer' => 1, + 'is_verify' => 1, + 'is_goods' => 1, + 'is_user' => 1, + 'staff_manage' => 1, + 'notify' => 1, + 'avatar' => $staffUserInfo['avatar'] ?? '', + 'phone' => $applyInfo['contacts_phone'], + 'sort' => 1, + 'mer_id' => $merchant->mer_id, + 'is_manage' => 1 + ]; + app()->make(StoreServiceRepository::class)->createInfo($staffData); }); }