diff --git a/app/common/repositories/system/merchant/MerchantIntentionRepository.php b/app/common/repositories/system/merchant/MerchantIntentionRepository.php index 753618b5..07d5698e 100755 --- a/app/common/repositories/system/merchant/MerchantIntentionRepository.php +++ b/app/common/repositories/system/merchant/MerchantIntentionRepository.php @@ -12,6 +12,8 @@ namespace app\common\repositories\system\merchant; +use app\common\model\system\merchant\Merchant; +use app\common\model\system\merchant\MerchantIntention; use app\common\repositories\BaseRepository; use crmeb\jobs\SendSmsJob; use crmeb\services\SmsService; @@ -100,6 +102,7 @@ class MerchantIntentionRepository extends BaseRepository public function updateStatus($id, $data) { + $data['create_mer'] = !empty($data['create_mer']) ? $data['create_mer'] : 2; $create = ($data['create_mer'] == 1 || $data['create_mer'] == -1); $autoCreate = 0; if ($data['create_mer'] == -1) { @@ -172,27 +175,34 @@ class MerchantIntentionRepository extends BaseRepository } Db::transaction(function () use ($config, $intention, $data, $create,$margin,$merData,$smsData,$autoCreate) { if ($data['status'] == 1) { - if ($create && $intention['type'] == 1) { - $merchant = app()->make(MerchantRepository::class)->createMerchant($merData); - $data['mer_id'] = $merchant->mer_id; - $data['uid'] = $intention['uid']; - $data['reg_admin_id'] = $autoCreate ? 0: $merchant['merchant_admin']['merchant_admin_id']; - // 写入商户客服表 - $store_service_data['mer_id'] = $merchant->mer_id; - $store_service_data['uid'] = $intention['uid']; - $store_service_data['avatar'] = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/1b716202302251108516996.png'; - $store_service_data['nickname'] = $intention['mer_name']; - $store_service_data['account'] = $intention['phone']; - $store_service_data['pwd'] = password_hash('123456', PASSWORD_BCRYPT);; - $store_service_data['status'] = 1; - $store_service_data['is_open'] = 1; - $store_service_data['notify'] = 1; - $store_service_data['customer'] = 1; - $store_service_data['is_verify'] = 1; - $store_service_data['is_goods'] = 1; - $store_service_data['phone'] = $intention['phone']; - $store_service_data['create_time'] = date('Y-m-d H:i:s'); - Db::name('store_service')->insert($store_service_data); + if ($intention['type'] == 1) { + if ($create) { + $merchant = app()->make(MerchantRepository::class)->createMerchant($merData); + $data['mer_id'] = $merchant->mer_id; + $data['uid'] = $intention['uid']; + $data['reg_admin_id'] = $autoCreate ? 0: $merchant['merchant_admin']['merchant_admin_id']; + // 写入商户客服表 + $store_service_data['mer_id'] = $merchant->mer_id; + $store_service_data['uid'] = $intention['uid']; + $store_service_data['avatar'] = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/1b716202302251108516996.png'; + $store_service_data['nickname'] = $intention['mer_name']; + $store_service_data['account'] = $intention['phone']; + $store_service_data['pwd'] = password_hash('123456', PASSWORD_BCRYPT);; + $store_service_data['status'] = 1; + $store_service_data['is_open'] = 1; + $store_service_data['notify'] = 1; + $store_service_data['customer'] = 1; + $store_service_data['is_verify'] = 1; + $store_service_data['is_goods'] = 1; + $store_service_data['phone'] = $intention['phone']; + $store_service_data['create_time'] = date('Y-m-d H:i:s'); + Db::name('store_service')->insert($store_service_data); + } + } else { + $merId = MerchantIntention::where('uid', $intention['uid'])->where('status', 1)->value('mer_id'); + if (!empty($merId)) { + Merchant::where('mer_id', $merId)->update(['business_status' => 2]); + } } Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_SUCCESS', 'id' => $smsData]); } else { diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index 92a1b3ee..f1a02b7f 100755 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -184,10 +184,13 @@ class MerchantIntention extends BaseController return app('json')->fail('未开启商户入驻'); } if ($this->userInfo) $data['uid'] = $this->userInfo->uid; - $settleIn = $this->repository->getWhere(['type' => 1, 'uid' => $data['uid'], 'is_del' => 0, 'status' => 1]); + $settleIn = $this->repository->getWhere(['type' => 1, 'uid' => $data['uid'], 'is_del' => 0]); if (empty($settleIn)) { return app('json')->fail('请申请商户入驻申请!'); } + if ($settleIn['status'] == 0) { + return app('json')->fail('请等待商户入驻申请审核!'); + } $merIntentionInfo = $this->repository->getWhere(['type' => 2, 'uid' => $data['uid'], 'is_del' => 0]); if (!empty($merIntentionInfo) && ($merIntentionInfo['status'] == 0)) { return app('json')->fail('商户交易已申请,正在审核中!'); @@ -195,7 +198,7 @@ class MerchantIntention extends BaseController if (!empty($merIntentionInfo) && ($merIntentionInfo['status'] == 1)) { return app('json')->fail('商户交易申请已通过'); } - $intenInfo['phone'] = $settleIn['bank_username']; + $intenInfo['phone'] = $settleIn['phone']; $intenInfo['mer_name'] = $settleIn['mer_name']; $intenInfo['company_name'] = $settleIn['company_name']; $intenInfo['name'] = $settleIn['name'];