From a96a958f7e4a3bd6f56194b3939aef61947ff770 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 19 Sep 2023 10:06:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E6=88=B7?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Auth.php | 17 ++++++-- .../api/store/merchant/MerchantIntention.php | 41 +++++++++++-------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index aba91ddf..c70cd9ad 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -1362,9 +1362,20 @@ class Auth extends BaseController $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['business_status'] = ($param['status'] ?? 0) == 1 ? 2 : 3; - Db::name('merchant')->where('mer_intention_id', $id)->where('status', 1)->update($data); + $status = $this->request->params('status', 0); + $type = $this->request->params('type', 1); + if ($type == 1) { + //商户入驻申请 + $data['status'] = $status; + $data['create_mer'] = -1; + $data['fail_msg'] = $status == 1 ? '自动审核通过' : '自动审核拒绝'; + $repository->updateStatus($id, $data); + } else { + //商户交易申请 + $data['business_status'] = $status == 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 b27846bc..f62aecd6 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -77,6 +77,9 @@ class MerchantIntention extends BaseController ]); $areaInfo = Db::name('geo_area')->where('area_code', $data['area_id'] ?? '')->find(); $sendData = [ + 'type' => 1, + 'type_name' => Db::name('merchant_type')->where('mer_type_id', $data['mer_type_id'])->value('type_name', ''), + 'category_name' => Db::name('merchant_category')->where('merchant_category_id', $data['merchant_category_id'])->value('category_name', ''), 'company_name' => $data['company_name'] ?? '', 'organization_code' => $data['social_credit_code'] ?? '', 'master_name' => $data['name'], @@ -88,12 +91,12 @@ class MerchantIntention extends BaseController 'address' => $data['address'] ?? '', 'mer_intention_id' => $intention->mer_intention_id ]; - // 新增交易申请流程取消合同签约 - // $res = $this->sendMerIntentionApply($sendData); - // if (!$res) { - // Db::name('merchant_intention')->where('mer_intention_id', $intention->mer_intention_id)->delete(); - // throw new ValidateException('申请商户入驻任务失败,请联系平台'); - // } + $postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant'; + $res = $this->sendMerIntentionApply($sendData, $postUrl); + if (!$res) { + Db::name('merchant_intention')->where('mer_intention_id', $intention->mer_intention_id)->delete(); + throw new ValidateException('申请商户入驻任务,请联系平台'); + } return app('json')->success('提交成功'); } @@ -110,6 +113,7 @@ class MerchantIntention extends BaseController } $areaInfo = Db::name('geo_area')->where('area_code', $intenInfo['area_id'] ?? '')->find(); $sendData = [ + 'type' => 2, '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'] ?? '', @@ -123,7 +127,8 @@ class MerchantIntention extends BaseController 'address' => $intenInfo['address'] ?? '', 'mer_intention_id' => $intenInfo['mer_intention_id'] ]; - $res = $this->sendMerIntentionApply($sendData); + $postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant'; + $res = $this->sendMerIntentionApply($sendData, $postUrl); if (!$res) { throw new ValidateException('商户交易申请失败,请联系平台'); } @@ -132,11 +137,10 @@ class MerchantIntention extends BaseController } //发送商户入驻申请 - public function sendMerIntentionApply($data) + public function sendMerIntentionApply($data, $postUrl) { - $postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant'; - Log::info("商户入驻申请HOST: {$postUrl}"); - Log::info("发送商户入驻申请信息: " . json_encode($data)); + Log::info("商户申请HOST: {$postUrl}"); + Log::info("发送商户申请信息: " . json_encode($data)); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $postUrl); curl_setopt($ch, CURLOPT_HEADER, 0); @@ -147,7 +151,7 @@ class MerchantIntention extends BaseController curl_close($ch); $ok = false; if (!empty($resData) && is_string($resData)) { - Log::info("商户入驻申请反馈信息" . $resData); + Log::info("商户申请反馈信息" . $resData); $resInfo = json_decode($resData, true); if(!empty($resInfo['code']) && $resInfo['code'] == 1){ $ok = true; @@ -196,6 +200,9 @@ class MerchantIntention extends BaseController ]); $areaInfo = Db::name('geo_area')->where('area_code', $data['area_id'] ?? '')->find(); $sendData = [ + 'type' => 1, + 'type_name' => Db::name('merchant_type')->where('mer_type_id', $data['mer_type_id'])->value('type_name', ''), + 'category_name' => Db::name('merchant_category')->where('merchant_category_id', $data['merchant_category_id'])->value('category_name', ''), 'company_name' => $data['company_name'] ?? '', 'organization_code' => $data['social_credit_code'] ?? '', 'master_name' => $data['name'], @@ -207,11 +214,11 @@ class MerchantIntention extends BaseController 'address' => $data['address'] ?? '', 'mer_intention_id' => $id ]; - // 新增交易申请流程取消合同签约 - // $res = $this->sendMerIntentionApply($sendData); - // if (!$res) { - // throw new ValidateException('申请商户入驻任务失败,请联系平台'); - // } + $postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant'; + $res = $this->sendMerIntentionApply($sendData, $postUrl); + if (!$res) { + throw new ValidateException('申请商户入驻失败,请联系平台'); + } return app('json')->success('修改成功'); } From fa00a574e590c686070443127ceae432ea929ddc Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 19 Sep 2023 10:29:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E6=88=B7?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E7=94=B3=E8=AF=B7=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/store/merchant/MerchantIntention.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index f62aecd6..db9c0a39 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -107,7 +107,10 @@ class MerchantIntention extends BaseController } 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($merInfo['business_status']) && ($merInfo['business_status']==2)) { + return app('json')->fail('商户交易申请已通过'); + } + $intenInfo = Db::name('merchant_intention')->where('mer_intention_id', $merInfo['mer_intention_id'] ?? 0)->where('type', 1)->find(); if (empty($intenInfo)) { return app('json')->fail('商户状态异常'); } @@ -133,6 +136,14 @@ class MerchantIntention extends BaseController throw new ValidateException('商户交易申请失败,请联系平台'); } Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status'=>1]); + $intenInfoArray = $intenInfo->toArray(); + $intenInfoArray['type'] = 1; + $bussIntention = Db::name('merchant_intention')->where('mer_intention_id', $intenInfo['mer_intention_id'])->where('type', 2)->find(); + if ($bussIntention) { + Db::name('merchant_intention')->where('mer_intention_id', $intenInfo['mer_intention_id'])->where('type', 2)->update($intenInfoArray); + }else { + Db::name('merchant_intention')->insert($intenInfoArray); + } return app('json')->success('申请成功'); } From 7168f816447e8c7de830c1e71f6a27fb35f8f620 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 19 Sep 2023 10:55:01 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/system/merchant/MerchantIntentionDao.php | 2 ++ app/controller/api/Auth.php | 12 +++++++++--- .../api/store/merchant/MerchantIntention.php | 10 +++------- route/api.php | 5 +++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/common/dao/system/merchant/MerchantIntentionDao.php b/app/common/dao/system/merchant/MerchantIntentionDao.php index 67a4a579..e74f2de1 100644 --- a/app/common/dao/system/merchant/MerchantIntentionDao.php +++ b/app/common/dao/system/merchant/MerchantIntentionDao.php @@ -31,6 +31,8 @@ class MerchantIntentionDao extends BaseDao $query->where('uid', $where['uid']); })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) { $query->where('status', (int)$where['status']); + })->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) { + $query->where('type', (int)$where['type']); })->when(isset($where['mer_intention_id']) && $where['mer_intention_id'] !== '', function ($query) use ($where) { $query->where('mer_intention_id', $where['mer_intention_id']); })->when(isset($where['category_id']) && $where['category_id'] !== '', function ($query) use ($where) { diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index c70cd9ad..fbe60792 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -1362,8 +1362,8 @@ class Auth extends BaseController $repository = app()->make(MerchantIntentionRepository::class); if (!$repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) return app('json')->fail('数据不存在'); - $status = $this->request->params('status', 0); - $type = $this->request->params('type', 1); + $status = $this->request->post('status', 0); + $type = $this->request->post('type', 1); if ($type == 1) { //商户入驻申请 $data['status'] = $status; @@ -1383,7 +1383,13 @@ class Auth extends BaseController public function businessAgree() { $repository = app()->make(CacheRepository::class); - $data = $repository->getResult('business_apply_agree'); + //sys_intention_agree business_apply_agree + $type = $this->request->get('type', 'sys_intention_agree'); + $typeArray = ['sys_intention_agree', 'business_apply_agree']; + if (!in_array($type, $typeArray)) { + return app('json')->fail('协议key错误'); + } + $data = $repository->getResult($type); return app('json')->success($data); } } diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index db9c0a39..15125759 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -138,12 +138,7 @@ class MerchantIntention extends BaseController Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status'=>1]); $intenInfoArray = $intenInfo->toArray(); $intenInfoArray['type'] = 1; - $bussIntention = Db::name('merchant_intention')->where('mer_intention_id', $intenInfo['mer_intention_id'])->where('type', 2)->find(); - if ($bussIntention) { - Db::name('merchant_intention')->where('mer_intention_id', $intenInfo['mer_intention_id'])->where('type', 2)->update($intenInfoArray); - }else { - Db::name('merchant_intention')->insert($intenInfoArray); - } + Db::name('merchant_intention')->insert($intenInfoArray); return app('json')->success('申请成功'); } @@ -236,7 +231,8 @@ class MerchantIntention extends BaseController public function lst() { [$page, $limit] = $this->getPage(); - $data = $this->repository->getList(['uid' => $this->userInfo->uid], $page, $limit); + $type = $this->request->get('type', 1); + $data = $this->repository->getList(['uid' => $this->userInfo->uid, 'type'=>$type], $page, $limit); return app('json')->success($data); } diff --git a/route/api.php b/route/api.php index 45b7185a..7c5d18e0 100644 --- a/route/api.php +++ b/route/api.php @@ -253,6 +253,8 @@ Route::group('api/', function () { //申请商户 Route::get('intention/lst', 'api.store.merchant.MerchantIntention/lst'); + //交易申请商户 + Route::post('intention/business', 'api.store.merchant.MerchantIntention/businessApply'); Route::get('intention/detail/:id', 'api.store.merchant.MerchantIntention/detail'); Route::post('intention/update/:id', 'api.store.merchant.MerchantIntention/update'); Route::post('store/product/group/cancel', 'api.store.product.StoreProductGroup/cancel'); @@ -555,8 +557,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');