修改:商户入驻绑定招商员信息
This commit is contained in:
parent
197e059fcb
commit
d64936c818
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue