From 4fea2f6ea4841124050214c28bd84a60e4cc4799 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Mon, 5 Feb 2024 18:17:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E7=94=B3=E8=AF=B7=E9=80=9A=E8=BF=87=E5=90=8E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90=E4=BE=9B=E5=BA=94=E5=95=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E8=B4=A6=E5=8F=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantRepository.php | 12 ++--- .../supplier/SystemSupplierApplyServices.php | 47 ++++++++++++++++++- 2 files changed, 50 insertions(+), 9 deletions(-) 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); }); }