Merge branch 'feature_business_apply' into dev

This commit is contained in:
yaooo 2023-09-18 15:51:14 +08:00
commit 1444ea84e1
5 changed files with 47 additions and 12 deletions

View File

@ -66,6 +66,8 @@ class CacheRepository extends BaseRepository
const COUPON_AGREE = 'sys_coupon_agree';
//付费会员协议
const SYS_SVIP = 'sys_svip';
//交易申请协议
const BUSINESS_APPLY_AGREE = 'business_apply_agree';
public function getAgreeList($type)
{
@ -75,6 +77,7 @@ class CacheRepository extends BaseRepository
['label' => '平台规则', 'key' => self::PLATFORM_RULE],
['label' => '注销重要提示', 'key' => self::CANCELLATION_PROMPT],
['label' => '商户入驻申请协议', 'key' => self::INTEGRAL_AGREE],
['label' => '交易申请协议', 'key' => self::BUSINESS_APPLY_AGREE],
];
if (!$type) {
$data[] = ['label' => '注销声明', 'key' => self::CANCELLATION_MSG];
@ -88,6 +91,7 @@ class CacheRepository extends BaseRepository
return [
self::INTEGRAL_RULE,
self::INTEGRAL_AGREE,
self::BUSINESS_APPLY_AGREE,
self::PRESELL_AGREE,
self::WECHAT_MENUS,
self::RECEIPT_AGREE,

View File

@ -140,6 +140,7 @@ class MerchantIntentionRepository extends BaseRepository
'margin' => $margin['margin'] ?? 0,
'uid' => $intention['uid'],
'reg_admin_id' => $autoCreate ? 0: request()->adminId(),
'mer_intention_id' => $id
];
$data['fail_msg'] = '';
$smsData = [

View File

@ -209,18 +209,14 @@ class Auth extends BaseController
$store_service = Db::name('store_service')->where('uid', $data['uid'])->find();
if ($store_service) {
$mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time')->find();
$mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,business_status,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time')->find();
if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') {
$data['is_wsxx'] = 1;
}
$data['mer_info'] = $mer_arr;
$typCode = Db::name('merchant_type')->where('mer_type_id', $mer_arr['type_id'] ?? 0)->value('type_code');
$data['mer_info']['type_code'] = $typCode;
if (($mer_arr['create_time'] ?? '') == ($mer_arr['update_time'] ?? '')) {
$data['mer_info']['setup_status'] = 0;
} else {
$data['mer_info']['setup_status'] = 1;
}
// 交易申请状态0未申请 1申请中 2申请通过 3申请拒绝
}
$data['fan_num'] = app()->make(RelevanceRepository::class)->getUserFans($user->uid, 1, 1, 1);
$data['focus_num'] = app()->make(RelevanceRepository::class)->getUserFocus($user->uid, 1, 1, 1);
@ -1359,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('同步成功');
}
}

View File

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

View File

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