Merge branch 'feature_business_apply' into dev

This commit is contained in:
yaooo 2023-09-19 10:55:18 +08:00
commit d6847e71d1
4 changed files with 59 additions and 25 deletions

View File

@ -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) {

View File

@ -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->post('status', 0);
$type = $this->request->post('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('同步成功');
}
@ -1372,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);
}
}

View File

@ -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('提交成功');
}
@ -104,12 +107,16 @@ 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('商户状态异常');
}
$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,20 +130,23 @@ 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('商户交易申请失败,请联系平台');
}
Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status'=>1]);
$intenInfoArray = $intenInfo->toArray();
$intenInfoArray['type'] = 1;
Db::name('merchant_intention')->insert($intenInfoArray);
return app('json')->success('申请成功');
}
//发送商户入驻申请
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 +157,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 +206,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,18 +220,19 @@ 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('修改成功');
}
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);
}

View File

@ -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');