修改:商户入驻绑定招商员信息

This commit is contained in:
wuhui_zzw 2023-12-27 15:08:55 +08:00
parent 197e059fcb
commit d64936c818
2 changed files with 32 additions and 34 deletions

View File

@ -5,6 +5,7 @@
namespace app\common\repositories\system\merchant; namespace app\common\repositories\system\merchant;
use app\common\repositories\BaseRepository; use app\common\repositories\BaseRepository;
use app\common\repositories\user\UserRepository;
use crmeb\jobs\SendSmsJob; use crmeb\jobs\SendSmsJob;
use crmeb\services\SmsService; use crmeb\services\SmsService;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
@ -71,15 +72,15 @@ class MerchantIntentionRepository extends BaseRepository
['value' => 1, 'label' => '同意'], ['value' => 1, 'label' => '同意'],
['value' => 2, 'label' => '拒绝'], ['value' => 2, 'label' => '拒绝'],
])->control([ ])->control([
[ // [
'value' => 1, // 'value' => 1,
'rule' => [ // 'rule' => [
Elm::radio('create_mer', '自动创建商户', 1)->options([ // Elm::radio('create_mer', '自动创建商户', 1)->options([
['value' => 1, 'label' => '创建'], // ['value' => 1, 'label' => '创建'],
['value' => 2, 'label' => '不创建'], // ['value' => 2, 'label' => '不创建'],
]) // ])
] // ]
], // ],
[ [
'value' => 2, 'value' => 2,
'rule' => [ 'rule' => [
@ -93,13 +94,11 @@ class MerchantIntentionRepository extends BaseRepository
public function updateStatus($id, $data) public function updateStatus($id, $data)
{ {
$create = $data['create_mer'] == 1; $create = 1;//$data['create_mer'] == 1;// TODO2023-12-27修改 审核通过后,直接自动创建商户信息
unset($data['create_mer']); unset($data['create_mer']);
$intention = $this->search(['mer_intention_id' => $id])->find(); $intention = $this->search(['mer_intention_id' => $id])->find();
if (!$intention) if (!$intention) throw new ValidateException('信息不存在');
throw new ValidateException('信息不存在'); if ($intention->status) throw new ValidateException('状态有误,修改失败');
if ($intention->status)
throw new ValidateException('状态有误,修改失败');
$config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']); $config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']);
$margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']); $margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']);
@ -109,20 +108,24 @@ class MerchantIntentionRepository extends BaseRepository
$smsData = []; $smsData = [];
if ($create == 1) { if ($create == 1) {
$password = substr($intention['phone'], -6); $password = substr($intention['phone'], -6);
$uid = $intention['uid'] ?? 0;
$user = app()->make(UserRepository::class)->get($uid);
$merData = [ $merData = [
'mer_name' => $intention['mer_name'], 'mer_name' => $intention['mer_name'],
'mer_phone' => $intention['phone'], 'mer_phone' => $intention['phone'],
'mer_account' => $intention['phone'], 'mer_account' => $intention['phone'],
'category_id' => $intention['merchant_category_id'], 'category_id' => $intention['merchant_category_id'],
'type_id' => $intention['mer_type_id'], 'type_id' => $intention['mer_type_id'],
'real_name' => $intention['name'], 'real_name' => $intention['name'],
'status' => 1, 'status' => 1,
'is_audit' => 1, 'is_audit' => 1,
'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1, 'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1,
'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1, 'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1,
'mer_password' => $password, 'mer_password' => $password,
'is_margin' => $margin['is_margin'] ?? -1, 'is_margin' => $margin['is_margin'] ?? -1,
'margin' => $margin['margin'] ?? 0 'margin' => $margin['margin'] ?? 0,
'uid' => $uid,
'spread_uid' => $user->spread_uid ?? 0
]; ];
$data['fail_msg'] = ''; $data['fail_msg'] = '';
$smsData = [ $smsData = [

View File

@ -205,17 +205,13 @@ class MerchantRepository extends BaseRepository
*/ */
public function createMerchant(array $data) public function createMerchant(array $data)
{ {
if ($this->fieldExists('mer_name', $data['mer_name'])) if ($this->fieldExists('mer_name', $data['mer_name'])) throw new ValidateException('商户名已存在');
throw new ValidateException('商户名已存在'); if ($data['mer_phone'] && isPhone($data['mer_phone'])) throw new ValidateException('请输入正确的手机号');
if ($data['mer_phone'] && isPhone($data['mer_phone']))
throw new ValidateException('请输入正确的手机号');
$merchantCategoryRepository = app()->make(MerchantCategoryRepository::class); $merchantCategoryRepository = app()->make(MerchantCategoryRepository::class);
$adminRepository = app()->make(MerchantAdminRepository::class); $adminRepository = app()->make(MerchantAdminRepository::class);
if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) throw new ValidateException('商户分类不存在');
throw new ValidateException('商户分类不存在'); if ($adminRepository->fieldExists('account', $data['mer_account'])) throw new ValidateException('账号已存在');
if ($adminRepository->fieldExists('account', $data['mer_account']))
throw new ValidateException('账号已存在');
/** @var MerchantAdminRepository $make */ /** @var MerchantAdminRepository $make */
$make = app()->make(MerchantAdminRepository::class); $make = app()->make(MerchantAdminRepository::class);
@ -228,7 +224,6 @@ class MerchantRepository extends BaseRepository
$account = $data['mer_account']; $account = $data['mer_account'];
$password = $data['mer_password']; $password = $data['mer_password'];
unset($data['mer_account'], $data['mer_password']); unset($data['mer_account'], $data['mer_password']);
$merchant = $this->dao->create($data); $merchant = $this->dao->create($data);
$make->createMerchantAccount($merchant, $account, $password); $make->createMerchantAccount($merchant, $account, $password);
app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id); app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id);