diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 4948acb3..927eb2dc 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -1355,16 +1355,15 @@ class Auth extends BaseController //同步商户状态信息 public function merchantStatus($id) { - Log::info("接收到同步商户状态HOST:" . request()->host() . request()->url()); - Log::info("接收到同步商户状态数据:" . json_encode(request()->param())); + // business_status 交易申请状态:0未申请 1申请中 2申请通过 3申请拒绝 + Log::info("同步商户交易申请状态HOST:" . request()->host() . request()->url()); + Log::info("同步商户交易申请状态数据:" . json_encode(request()->param())); $repository = app()->make(MerchantIntentionRepository::class); if (!$repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) return app('json')->fail('数据不存在'); $param = $this->request->params(['status']); - $data['status'] = $param['status']; - $data['create_mer'] = -1; - $data['fail_msg'] = $param['status'] == 1 ? '自动审核通过' : '自动审核拒绝'; - $repository->updateStatus($id, $data); + $data['business_status'] = ($param['status'] ?? 0) == 1 ? 2 : 3; + Db::name('merchant')->where('mer_intention_id', $id)->where('status', 1)->update($data); return app('json')->success('同步成功'); } } diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index 8caa88bb..b27846bc 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -97,6 +97,40 @@ class MerchantIntention extends BaseController return app('json')->success('提交成功'); } + public function businessApply() + { + if (!systemConfig('mer_intention_open')) { + return app('json')->fail('未开启商户入驻'); + } + if ($this->userInfo) $data['uid'] = $this->userInfo->uid; + $merInfo = Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->find(); + $intenInfo = Db::name('merchant_intention')->where('mer_intention_id', $merInfo['mer_intention_id'] ?? 0)->find(); + if (empty($intenInfo)) { + return app('json')->fail('商户状态异常'); + } + $areaInfo = Db::name('geo_area')->where('area_code', $intenInfo['area_id'] ?? '')->find(); + $sendData = [ + 'type_name' => Db::name('merchant_type')->where('mer_type_id', $merInfo['type_id'])->value('type_name', ''), + 'category_name' => Db::name('merchant_category')->where('merchant_category_id', $merInfo['category_id'])->value('category_name', ''), + 'company_name' => $intenInfo['company_name'] ?? '', + 'organization_code' => $intenInfo['social_credit_code'] ?? '', + 'master_name' => $intenInfo['name'], + 'master_phone' => $intenInfo['phone'], + 'images' => !empty($intenInfo['images'])?json_encode(explode(',', $intenInfo['images'])):'', + 'city' => $areaInfo['city_code'] ?? '', + 'area' => $intenInfo['area_id'] ?? '', + 'street' => $intenInfo['street_id'] ?? '', + 'address' => $intenInfo['address'] ?? '', + 'mer_intention_id' => $intenInfo['mer_intention_id'] + ]; + $res = $this->sendMerIntentionApply($sendData); + if (!$res) { + throw new ValidateException('商户交易申请失败,请联系平台'); + } + Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status'=>1]); + return app('json')->success('申请成功'); + } + //发送商户入驻申请 public function sendMerIntentionApply($data) { diff --git a/route/api.php b/route/api.php index 8779c127..3cd1c87b 100644 --- a/route/api.php +++ b/route/api.php @@ -555,6 +555,7 @@ Route::group('api/', function () { Route::post('upload/video', 'merchant.Common/uploadVideo'); Route::get('excel/download/:id', 'merchant.store.order.Order/download'); //申请商户 + Route::post('intention/business', 'api.store.merchant.MerchantIntention/businessApply'); Route::post('intention/create', 'api.store.merchant.MerchantIntention/create'); Route::get('intention/cate', 'api.store.merchant.MerchantIntention/cateLst'); Route::get('intention/v2/cate', 'api.store.merchant.MerchantIntention/v2CateLst');