|
|
|
|
@@ -0,0 +1,188 @@
|
|
|
|
|
package com.cool.store.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.cool.store.dao.EnterpriseUserDAO;
|
|
|
|
|
import com.cool.store.dto.login.UserIdInfoDTO;
|
|
|
|
|
import com.cool.store.dto.mdm.AccessTokenDTO;
|
|
|
|
|
import com.cool.store.dto.response.MDMResultDTO;
|
|
|
|
|
import com.cool.store.entity.*;
|
|
|
|
|
import com.cool.store.enums.DataSourceEnum;
|
|
|
|
|
import com.cool.store.enums.ErrorCodeEnum;
|
|
|
|
|
import com.cool.store.enums.WorkflowStatusEnum;
|
|
|
|
|
import com.cool.store.exception.ApiException;
|
|
|
|
|
import com.cool.store.exception.ServiceException;
|
|
|
|
|
import com.cool.store.mapper.DingdingUserMapper;
|
|
|
|
|
import com.cool.store.mapper.HyPartnerCertificationInfoMapper;
|
|
|
|
|
import com.cool.store.mapper.HyPartnerInterviewMapper;
|
|
|
|
|
import com.cool.store.mapper.HyPartnerLineInfoMapper;
|
|
|
|
|
import com.cool.store.request.CreateQualifyVerifyReq;
|
|
|
|
|
import com.cool.store.request.RpcCreateQualifyVerfyReq;
|
|
|
|
|
import com.cool.store.request.RpcGetMdmTokenReq;
|
|
|
|
|
import com.cool.store.service.FlowService;
|
|
|
|
|
import com.cool.store.utils.RedisUtilPool;
|
|
|
|
|
import com.cool.store.utils.RestTemplateUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author: young.yu
|
|
|
|
|
* @Date: 2023-06-14 14:22
|
|
|
|
|
* @Description:
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class FlowServiceImpl implements FlowService {
|
|
|
|
|
|
|
|
|
|
// @Value("${hs.mdm.baseUrl}")
|
|
|
|
|
private String mdmBaseUrl;
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisUtilPool redisUtilPool;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private HyPartnerLineInfoMapper hyPartnerLineInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private EnterpriseUserDAO enterpriseUserDAO;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private DingdingUserMapper dingdingUserMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private HyPartnerInterviewMapper hyPartnerInterviewMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private HyPartnerCertificationInfoMapper hyPartnerCertificationInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void createQualifyVerify(CreateQualifyVerifyReq request) throws ApiException {
|
|
|
|
|
//1.发起加盟商资质审核
|
|
|
|
|
RpcCreateQualifyVerfyReq rpcRequest = new RpcCreateQualifyVerfyReq();
|
|
|
|
|
rpcRequest.setIntendedSignDate(request.getWantSignTime());
|
|
|
|
|
rpcRequest.setFraSource("HSAYPartner");
|
|
|
|
|
rpcRequest.setAmtDeposit(Integer.valueOf(request.getSecurityFund()));
|
|
|
|
|
|
|
|
|
|
//获取授权码
|
|
|
|
|
String authCode = null;
|
|
|
|
|
if (StringUtils.isBlank(request.getLineId())) {
|
|
|
|
|
//根据线索id获取线索信息
|
|
|
|
|
HyPartnerLineInfoDO hyPartnerLineInfoDO = hyPartnerLineInfoMapper.selectByPrimaryKeySelective(Long.valueOf(request.getLineId()));
|
|
|
|
|
if (!Objects.isNull(hyPartnerLineInfoDO)) {
|
|
|
|
|
String investmentManagerId = hyPartnerLineInfoDO.getInvestmentManager();
|
|
|
|
|
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.getUserInfoById(investmentManagerId);
|
|
|
|
|
if (!Objects.isNull(enterpriseUserDO)) {
|
|
|
|
|
String jobNumber = enterpriseUserDO.getJobnumber();
|
|
|
|
|
String mobile = enterpriseUserDO.getMobile();
|
|
|
|
|
DingdingUserDO dingdingUserDO = dingdingUserMapper.selectDingDingUserByMobile(mobile);
|
|
|
|
|
if (Objects.isNull(dingdingUserDO)) {
|
|
|
|
|
throw new ServiceException(ErrorCodeEnum.DINGDING_USER_NOT_EXIST);
|
|
|
|
|
}
|
|
|
|
|
rpcRequest.setDingUserId(dingdingUserDO.getUserid());
|
|
|
|
|
authCode = generateAuthCode(jobNumber);
|
|
|
|
|
rpcRequest.setAuthCode(authCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
rpcRequest.setIntendedSigner(request.getIntentionSignerUsername());
|
|
|
|
|
rpcRequest.setIntendedSignerTel(request.getIntentionSignerMobile());
|
|
|
|
|
|
|
|
|
|
String qualifyVerifyId = createQualifyVerify(rpcRequest);
|
|
|
|
|
//2.更新审核信息
|
|
|
|
|
HyPartnerCertificationInfoDO partnerCertificationInfoDO = new HyPartnerCertificationInfoDO();
|
|
|
|
|
partnerCertificationInfoDO.setPartnerId(request.getPartnerId());
|
|
|
|
|
partnerCertificationInfoDO.setPartnerLineId(Long.valueOf(request.getLineId()));
|
|
|
|
|
partnerCertificationInfoDO.setPartnerInterviewId(Long.valueOf(request.getInterviewId()));
|
|
|
|
|
partnerCertificationInfoDO.setPartnership(String.valueOf(request.getPartnership()));
|
|
|
|
|
partnerCertificationInfoDO.setWantSignTime(DateUtil.parseDate(request.getWantSignTime()));
|
|
|
|
|
partnerCertificationInfoDO.setPartnerFee(request.getPartnerFee());
|
|
|
|
|
partnerCertificationInfoDO.setSecurityFund(request.getSecurityFund());
|
|
|
|
|
partnerCertificationInfoDO.setTechnicalServiceFee(request.getTechnicalServiceFee());
|
|
|
|
|
partnerCertificationInfoDO.setIntentionMoney(request.getIntentionMoney());
|
|
|
|
|
partnerCertificationInfoDO.setIntentionSignerUsername(request.getIntentionSignerUsername());
|
|
|
|
|
partnerCertificationInfoDO.setIntentionSignerMobile(request.getIntentionSignerMobile());
|
|
|
|
|
partnerCertificationInfoDO.setIntentionEdu(request.getIntentionEdu());
|
|
|
|
|
partnerCertificationInfoDO.setRealControlUsername(request.getRealControlUsername());
|
|
|
|
|
partnerCertificationInfoDO.setRealControlIdcard(request.getRealControlIdcard());
|
|
|
|
|
partnerCertificationInfoDO.setSignerRealControlRelation(request.getSignerRealControlRelation());
|
|
|
|
|
partnerCertificationInfoDO.setSignerOtherRealControlRelation(request.getSignerOtherRealControlRelation());
|
|
|
|
|
partnerCertificationInfoDO.setSignerRealControlRelationCert(request.getSignerRealControlRelationCert());
|
|
|
|
|
partnerCertificationInfoDO.setCreateTime(new Date());
|
|
|
|
|
partnerCertificationInfoDO.setUpdateTime(new Date());
|
|
|
|
|
hyPartnerCertificationInfoMapper.updateByPrimaryKeySelective(partnerCertificationInfoDO);
|
|
|
|
|
//3.更新面试信息
|
|
|
|
|
//根据面试id获取面试信息
|
|
|
|
|
HyPartnerInterviewDO hyPartnerInterviewDO = hyPartnerInterviewMapper.selectByPrimaryKeySelective(request.getInterviewId());
|
|
|
|
|
if (Objects.isNull(hyPartnerInterviewDO)) {
|
|
|
|
|
throw new ServiceException(ErrorCodeEnum.INTERVIEW_NOT_EXIST);
|
|
|
|
|
}
|
|
|
|
|
hyPartnerInterviewDO.setQualifyVerifyId(qualifyVerifyId);
|
|
|
|
|
hyPartnerInterviewDO.setUpdateTime(new Date());
|
|
|
|
|
//更新
|
|
|
|
|
hyPartnerInterviewDO.setStatus(Integer.valueOf(WorkflowStatusEnum.INTERVIEW_4.getCode()));
|
|
|
|
|
hyPartnerInterviewMapper.updateByPrimaryKeySelective(hyPartnerInterviewDO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String createQualifyVerify(RpcCreateQualifyVerfyReq rpcRequest) throws ApiException{
|
|
|
|
|
String url = mdmBaseUrl + "/api/openapi/runtime/form/startFraQualExam";
|
|
|
|
|
ResponseEntity<MDMResultDTO> responseEntity = null;
|
|
|
|
|
try {
|
|
|
|
|
RpcGetMdmTokenReq rpcGetMDMTokenReq = new RpcGetMdmTokenReq();
|
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
|
|
headers.put("Authorization", getMdmAccessToken(rpcGetMDMTokenReq));
|
|
|
|
|
responseEntity = RestTemplateUtil.post(url, headers,rpcRequest, MDMResultDTO.class);
|
|
|
|
|
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
|
|
|
|
if (Objects.nonNull(responseEntity.getBody()) && responseEntity.getBody().isSuccess()) {
|
|
|
|
|
return JSONObject.toJSONString(responseEntity.getBody().getData());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.info("调用MDM接口出错{}", e);
|
|
|
|
|
throw new ApiException(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getMdmAccessToken(RpcGetMdmTokenReq rpcGetMDMTokenReq) throws ApiException {
|
|
|
|
|
String url = mdmBaseUrl + "/api/oauth2/accessToken";
|
|
|
|
|
ResponseEntity<MDMResultDTO> responseEntity = null;
|
|
|
|
|
try {
|
|
|
|
|
responseEntity = RestTemplateUtil.post(url,rpcGetMDMTokenReq, MDMResultDTO.class);
|
|
|
|
|
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
|
|
|
|
if (Objects.nonNull(responseEntity.getBody()) && responseEntity.getBody().isSuccess()) {
|
|
|
|
|
AccessTokenDTO accessTokenDTO = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getData()), AccessTokenDTO.class);
|
|
|
|
|
if(accessTokenDTO==null || StringUtils.isBlank(accessTokenDTO.getAccessToken())){
|
|
|
|
|
throw new ServiceException("获取Mdm token失败!");
|
|
|
|
|
}
|
|
|
|
|
return accessTokenDTO.getAccessToken();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.info("调用MDM接口出错{}", e);
|
|
|
|
|
throw new ApiException(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成授权码
|
|
|
|
|
*
|
|
|
|
|
* @param jobNumber
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String generateAuthCode(String jobNumber) {
|
|
|
|
|
String prefix = jobNumber + DateUtil.format(new Date(), "yyyyMMdd");
|
|
|
|
|
return prefix + redisUtilPool.incrby(prefix, 1, 60 * 60 * 25);
|
|
|
|
|
}
|
|
|
|
|
}
|