From d64936c81815bf5604ad90bc704016e8f07cd491 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Wed, 27 Dec 2023 15:08:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=95=86=E6=88=B7?= =?UTF-8?q?=E5=85=A5=E9=A9=BB=E7=BB=91=E5=AE=9A=E6=8B=9B=E5=95=86=E5=91=98?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/MerchantIntentionRepository.php | 53 ++++++++++--------- .../system/merchant/MerchantRepository.php | 13 ++--- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/app/common/repositories/system/merchant/MerchantIntentionRepository.php b/app/common/repositories/system/merchant/MerchantIntentionRepository.php index 30a076f..794473d 100644 --- a/app/common/repositories/system/merchant/MerchantIntentionRepository.php +++ b/app/common/repositories/system/merchant/MerchantIntentionRepository.php @@ -5,6 +5,7 @@ namespace app\common\repositories\system\merchant; use app\common\repositories\BaseRepository; +use app\common\repositories\user\UserRepository; use crmeb\jobs\SendSmsJob; use crmeb\services\SmsService; use FormBuilder\Factory\Elm; @@ -71,15 +72,15 @@ class MerchantIntentionRepository extends BaseRepository ['value' => 1, 'label' => '同意'], ['value' => 2, 'label' => '拒绝'], ])->control([ - [ - 'value' => 1, - 'rule' => [ - Elm::radio('create_mer', '自动创建商户', 1)->options([ - ['value' => 1, 'label' => '创建'], - ['value' => 2, 'label' => '不创建'], - ]) - ] - ], + // [ + // 'value' => 1, + // 'rule' => [ + // Elm::radio('create_mer', '自动创建商户', 1)->options([ + // ['value' => 1, 'label' => '创建'], + // ['value' => 2, 'label' => '不创建'], + // ]) + // ] + // ], [ 'value' => 2, 'rule' => [ @@ -93,13 +94,11 @@ class MerchantIntentionRepository extends BaseRepository public function updateStatus($id, $data) { - $create = $data['create_mer'] == 1; + $create = 1;//$data['create_mer'] == 1;// TODO:2023-12-27修改 审核通过后,直接自动创建商户信息 unset($data['create_mer']); $intention = $this->search(['mer_intention_id' => $id])->find(); - if (!$intention) - throw new ValidateException('信息不存在'); - if ($intention->status) - throw new ValidateException('状态有误,修改失败'); + if (!$intention) throw new ValidateException('信息不存在'); + if ($intention->status) throw new ValidateException('状态有误,修改失败'); $config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']); $margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']); @@ -109,20 +108,24 @@ class MerchantIntentionRepository extends BaseRepository $smsData = []; if ($create == 1) { $password = substr($intention['phone'], -6); + $uid = $intention['uid'] ?? 0; + $user = app()->make(UserRepository::class)->get($uid); $merData = [ - 'mer_name' => $intention['mer_name'], - 'mer_phone' => $intention['phone'], - 'mer_account' => $intention['phone'], - 'category_id' => $intention['merchant_category_id'], - 'type_id' => $intention['mer_type_id'], - 'real_name' => $intention['name'], - 'status' => 1, - 'is_audit' => 1, - 'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1, + 'mer_name' => $intention['mer_name'], + 'mer_phone' => $intention['phone'], + 'mer_account' => $intention['phone'], + 'category_id' => $intention['merchant_category_id'], + 'type_id' => $intention['mer_type_id'], + 'real_name' => $intention['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 + 'is_margin' => $margin['is_margin'] ?? -1, + 'margin' => $margin['margin'] ?? 0, + 'uid' => $uid, + 'spread_uid' => $user->spread_uid ?? 0 ]; $data['fail_msg'] = ''; $smsData = [ diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 2d4b5da..8723bcb 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -205,17 +205,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); @@ -228,7 +224,6 @@ class MerchantRepository extends BaseRepository $account = $data['mer_account']; $password = $data['mer_password']; unset($data['mer_account'], $data['mer_password']); - $merchant = $this->dao->create($data); $make->createMerchantAccount($merchant, $account, $password); app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id);