add:商城商户入驻认证,通滩镇商户要查询一下是否已通过企业认证,通过的情况下直接生成合同

This commit is contained in:
chenbo 2023-09-15 17:45:46 +08:00
parent 41a9a27292
commit aa47142942
2 changed files with 48 additions and 1 deletions

View File

@ -24,6 +24,7 @@ use app\api\controller\JunziqianController;
use app\common\logic\RedisLogic;
use app\common\model\auth\Admin;
use app\common\model\Company;
use app\common\model\contract\ShopContract;
use app\common\model\ShopMerchant;
use think\cache\driver\Redis;
use think\Exception;
@ -373,7 +374,10 @@ class CompanyController extends BaseAdminController
throw new Exception('商户法人名称不能为空');
}
$master_email=Db::name('company_form')->where('organization_code',$params['organization_code'])->value('master_email');
$isQueryStatus = false; // 需要进一步查询是否已做过企业认证
// $master_email为空表示没有做过认证
if($master_email){
$isQueryStatus = true;
}else{
$master_email=substr(md5(uniqid()),rand(0, 22),10)."@lihai.com";
}
@ -394,6 +398,36 @@ class CompanyController extends BaseAdminController
$shopMerchantModel = ShopMerchant::create($data);
Log::info(['商户入驻请求-通滩镇商户', $params['street'], $isQueryStatus]);
// 如果是通滩镇的商户,查询一下企业认证状态,通过的情况,则直接发起生成合同
if ($params['street'] == '510502106' && $isQueryStatus) {
$statusRe = app(JunziqianController::class)->shopMerchantStatusQuery($master_email);
Log::info(['商户入驻请求-通滩镇商户-认证状态查询结果', $statusRe]);
if($statusRe->success == true) {
$statusData = json_decode($statusRe->data, true);
if ($statusData['status'] == 1) {
// 生成合同
$createContractData = [
'id' => $shopMerchantModel->id,
'party_a' => 1,
'party_a_name' => '泸州市海之农科技有限公司',
'party_b' => $shopMerchantModel->id,
'party_b_name' => $params['company_name'],
'contract_type' => 22,
];
$shopContractModel = new ShopContract();
$shopContractModel->contract_no = time();
$shopContractModel->create_time = time();
$shopContractModel->check_status = 1;
$shopContractModel->update_time = time();
$shopContractModel->setAttrs($createContractData);
$shopContractModel->save($createContractData);
return $this->success('已做过企业认证,直接生成合同成功', [], 1, 1);
}
}
}
if (!$shopMerchantModel->isEmpty()) {
// 自动发起企业认证
$shopMerchantCertificationData = [
@ -409,7 +443,7 @@ class CompanyController extends BaseAdminController
} else {
throw new Exception('商户创建失败');
}
return $this->success('成功', [], 1, 1);
return $this->success('商户创建成功', [], 1, 1);
} catch (Exception $exception) {
Log::error(['商户入驻请求失败', $exception->getMessage()]);
return $this->fail($exception->getMessage());

View File

@ -160,6 +160,19 @@ class JunziqianController extends BaseApiController
return $response;
}
public function shopMerchantStatusQuery($email)
{
$param = Request()->param();
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//初始化合同参数
$request = array(
"emailOrMobile" => $email, //TODO *
);
//发起请求
$response = $requestUtils->doPost("/v2/user/organizationAuditStatus", $request);
return $response;
}
//企业自定义公章
public function Custom_seal()
{