initiating
This commit is contained in:
@@ -24,15 +24,14 @@ import com.cool.store.vo.BusinessLicenseInfoVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -76,6 +75,9 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
|
||||
@Resource
|
||||
AliyunService aliyunService;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -202,26 +204,45 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
|
||||
}
|
||||
verifyDate(request);
|
||||
Map<String, Object> requestMap = new HashMap<>();
|
||||
fillSignatureInfo(requestMap);
|
||||
String url = xfsgUrl + Constants.INTENTION_CONTRACT_URL + "?timestamp=" + requestMap.get("timestamp") + "&signature=" + requestMap.get("signature");
|
||||
InitiatingDO initiatingDO = request.toInitiatingDO();
|
||||
initiatingDO.setApply_user(user.getJobNumber());
|
||||
initiatingDO.setApply_user_name(user.getName());
|
||||
LineInfoDO lineInfoDO = lineInfoMapper.getByLineId(request.getLineId());
|
||||
initiatingDO.setJmsxx(lineInfoDO.getPartnerNum());
|
||||
initiatingDO.setKdzBusinessId(AuditEnum.CONTRACT_INTENTION.getCode() + "_" + lineInfoDO.getId() + "_" + lineInfoDO.getWorkflowSubStageStatus());
|
||||
InitiatingResponse initiatingResponse = httpRestTemplateService.postForObject(url, initiatingDO, InitiatingResponse.class);
|
||||
if (initiatingResponse.getCode() != 0L) {
|
||||
return new ResponseResult(500, initiatingResponse.getMsg(), initiatingResponse.getData());
|
||||
} else {
|
||||
String redisKey = "OA:" + request.getMobile() + request.getIdCardNo();
|
||||
log.info("initiating redisKey:{},request:{}", redisKey, JSONObject.toJSONString(request));
|
||||
redisUtilPool.setString(redisKey, JSONObject.toJSONString(request));
|
||||
lineInfoDO.setWorkflowSubStageStatus(WorkflowSubStageStatusEnum.SIGN_INTENT_AGREEMENT_75.getCode());
|
||||
lineInfoMapper.updateByPrimaryKeySelective(lineInfoDO);
|
||||
return new ResponseResult(200000, initiatingResponse.getMsg(), initiatingResponse.getData());
|
||||
String lockKey = "submitSignFranchise:" + request.getLineId();
|
||||
//流水
|
||||
String lockValue = UUID.randomUUID().toString();
|
||||
boolean acquired = false;
|
||||
try {
|
||||
acquired = redisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
|
||||
if (Boolean.TRUE.equals(acquired)) {
|
||||
Map<String, Object> requestMap = new HashMap<>();
|
||||
fillSignatureInfo(requestMap);
|
||||
String url = xfsgUrl + Constants.INTENTION_CONTRACT_URL + "?timestamp=" + requestMap.get("timestamp") + "&signature=" + requestMap.get("signature");
|
||||
InitiatingDO initiatingDO = request.toInitiatingDO();
|
||||
initiatingDO.setApply_user(user.getJobNumber());
|
||||
initiatingDO.setApply_user_name(user.getName());
|
||||
LineInfoDO lineInfoDO = lineInfoMapper.getByLineId(request.getLineId());
|
||||
initiatingDO.setJmsxx(lineInfoDO.getPartnerNum());
|
||||
initiatingDO.setKdzBusinessId(AuditEnum.CONTRACT_INTENTION.getCode() + "_" + lineInfoDO.getId() + "_" + lineInfoDO.getWorkflowSubStageStatus());
|
||||
InitiatingResponse initiatingResponse = httpRestTemplateService.postForObject(url, initiatingDO, InitiatingResponse.class);
|
||||
if (initiatingResponse.getCode() != 0L) {
|
||||
return new ResponseResult(500, initiatingResponse.getMsg(), initiatingResponse.getData());
|
||||
} else {
|
||||
String redisKey = "OA:" + request.getMobile() + request.getIdCardNo();
|
||||
log.info("initiating redisKey:{},request:{}", redisKey, JSONObject.toJSONString(request));
|
||||
redisUtilPool.setString(redisKey, JSONObject.toJSONString(request));
|
||||
lineInfoDO.setWorkflowSubStageStatus(WorkflowSubStageStatusEnum.SIGN_INTENT_AGREEMENT_75.getCode());
|
||||
lineInfoMapper.updateByPrimaryKeySelective(lineInfoDO);
|
||||
return new ResponseResult(200000, initiatingResponse.getMsg(), initiatingResponse.getData());
|
||||
}
|
||||
}else {
|
||||
throw new ServiceException(ErrorCodeEnum.DUPLICATE_SUBMISSION);
|
||||
}
|
||||
}finally {
|
||||
if (Boolean.TRUE.equals(acquired)) {
|
||||
String currentValue = redisTemplate.opsForValue().get(lockKey);
|
||||
if (lockValue.equals(currentValue)) {
|
||||
redisTemplate.delete(lockKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void verifyDate(InitiatingRequest request) {
|
||||
|
||||
Reference in New Issue
Block a user