@@ -3,6 +3,7 @@ package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject ;
import com.cool.store.constants.CommonConstants ;
import com.cool.store.context.LoginUserInfo ;
import com.cool.store.dao.HyPartnerUserChannelDAO ;
import com.cool.store.dao.LineInfoDAO ;
import com.cool.store.entity.* ;
import com.cool.store.enums.* ;
@@ -14,8 +15,7 @@ import com.cool.store.request.*;
import com.cool.store.response.InitiatingResponse ;
import com.cool.store.response.ResponseResult ;
import com.cool.store.response.SigningBaseInfoResponse ;
import com.cool.store.service.AliyunService ;
import com.cool.store.service.IntentAgreementService ;
import com.cool.store.service.* ;
import com.cool.store.utils.RedisUtilPool ;
import com.cool.store.utils.SecureUtil ;
import com.cool.store.utils.StringUtil ;
@@ -73,6 +73,11 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
@Resource
AliyunService aliyunService ;
@Resource
private UserAuthMappingService userAuthMappingService ;
@Resource
private ShopService shopService ;
@Override
@Transactional ( rollbackFor = Exception . class )
@@ -84,16 +89,21 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
if ( Objects . isNull ( lineInfoDO ) ) {
throw new ServiceException ( ErrorCodeEnum . INTERVIEW_PARTNER_NOT_EXIST ) ;
}
lineInfoDO . setWorkflowSubStageStatus ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_63 . getCode ( ) ) ;
lineInfoDO . setWorkflowSubStageStatus ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_125 . getCode ( ) ) ;
lineInfoMapper . updateByPrimaryKeySelective ( lineInfoDO ) ;
Map < String , String > r equestMap = new HashMap < > ( ) ;
r equestMap . put ( " partnerUsername " , lineInfoDO . getUsername ( ) ) ;
r equestMap . put ( " partnerMobile " , lineInfoDO . getMobil e ( ) ) ;
requestMap . put ( " lineId " , String . valueOf ( lineInfoDO . getId ( ) ) ) ;
requestMap . put ( " submitTime " , DateUtils . dateTimeNow ( DateUtils . SPECIAL_DATE_START ) ) ;
commonService . sendMessage ( Collections . singletonList ( lineInfoDO . getInvestmentManager ( ) ) ,
MessageEnum . MESSAGE_30 ,
requestMap) ;
AuditPassRequest auditPassR equest = new AuditPassRequest ( ) ;
auditPassR equest. setLineId ( lineInfoDO . getId ( ) ) ;
auditPassR equest. setWorkflowSubStage ( lineInfoDO . getWorkflowSubStag e ( ) ) ;
commonService . getLineFlowService ( lineInfoDO . getWorkflowSubStage ( ) ) . auditPass ( auditPassRequest , null ) ;
// TODO: 2024/6/18 企微工作通知
// Map<String, String> requestMap = new HashMap<>();
// requestMap.put("partnerUsername", lineInfoDO.getUsername());
// requestMap.put("partnerMobile", lineInfoDO.getMobile()) ;
// requestMap.put("lineId", String.valueOf(lineInfoDO.getId()));
// requestMap.put("submitTime", DateUtils.dateTimeNow(DateUtils.SPECIAL_DATE_START));
// commonService.sendMessage(Collections.singletonList(lineInfoDO.getInvestmentManager()),
// MessageEnum.MESSAGE_30,
// requestMap);
return Boolean . TRUE ;
}
@@ -125,119 +135,55 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
@Override
protected Boolean auditPass ( Long auditId , LineInfoDO lineInfo , String userId ) {
//校验是否是审核节点
if ( ! lineInfo . getWorkflowSubStageStatus ( ) . equals ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_63 . getCode ( ) ) & &
! lineInfo . g etWorkflowSubS tageStatus ( ) . equals ( WorkflowSubS tageStatus Enum . SIGN_INTENT_AGREEMENT_75 . getCode ( ) ) ) {
throw new ServiceException ( ErrorCodeEnum . NOT_APPROVE_NODE ) ;
}
//待审核code 63 处理逻辑
if ( lineInfo . g etWorkflowSubStageStatus ( ) . equals ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_63 . getCode ( ) ) ) {
lineInfo . setWorkflowSubStageStatus ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_70 . getCode ( ) ) ;
lineInfoDAO . updateLineInfo ( lineInfo ) ;
}
//待OA审核code 75 处理逻辑
if ( lineInfo . getWorkflowSubStageStatus ( ) . equals ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_75 . getCode ( ) ) ) {
WorkflowSubStageEnum workflowSubStageEnum = WorkflowSubStageEnum . getWorkflowSubStageEnum ( lineInfo . getWorkflowSubStage ( ) ) ;
WorkflowSubStageEnum nextStage = workflowSubStageEnum . getNextStage ( ) ;
//更新线索阶段
lineInfoDAO . updateWorkflowStage ( lineInfo . getId ( ) , nextStage , nextStage . getInitStatus ( ) , userId ) ;
Map < String , String > requestMap = new HashMap < > ( ) ;
requestMap . put ( " partnerUsername " , lineInfo . getUsername ( ) ) ;
requestMap . put ( " lineId " , String . valueOf ( lineInfo . getId ( ) ) ) ;
requestMap . put ( " partnerMobile " , lineInfo . getMobile ( ) ) ;
commonService . sendMessage ( Collections . singletonList ( lineInfo . getInvestmentManager ( ) ) , MessageEnum . MESSAGE_32 , requestMap ) ;
commonService . sendSms ( lineInfo . getMobile ( ) , SMSMsgEnum . INTENTION_PAYMENT_PASS ) ;
}
//更新auditId
SigningBaseInfoDO signingBaseInfoDO = intentAgreementMapper . selectByPartnerIdOrLineId ( null , lineInfo . getId ( ) ) ;
if ( Objects . nonNull ( signingBaseInfoDO ) ) {
intentAgreementMapper . updateAuditId ( lineInfo . getId ( ) , auditId ) ;
} else {
throw new ServiceException ( " 无法更新,没有对应的签约基本信息 " ) ;
}
LineInfoDO updateLine = new LineInfoDO ( ) ;
updateLine . setId ( lineInfo . getId ( ) ) ;
updateLine . s etWorkflowStage( WorkflowStageEnum . STORE . getCode ( ) ) ;
updateLine . setWorkflowSubStageStatus ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_125 . getCode ( ) ) ;
EnterpriseUserDO enterpriseUser = userAuthMappingService . getUserByRoleEnumAndWantShopAreaId ( UserRoleEnum . SELECT_SITE_COMMISSIONER , lineInfo . getWantShopAreaId ( ) ) ;
String developmentManager = Optional . ofNullable ( enterpriseUser ) . map ( EnterpriseUserDO : : getUserId ) . orElse ( null ) ;
updateLine . s etDevelopmentManager ( developmentManager ) ;
updateLine . setUpdateUserId ( userId ) ;
lineInfoDAO . updateLineInfo ( updateLine ) ;
//初始化店铺
shopService . initShop ( lineInfo ) ;
return Boolean . TRUE ;
}
@Override
protected Boolean auditReject ( Long auditId , LineInfoDO lineInfo , String userId ) {
if ( ( ! lineInfo . getWorkflowSubStageStatus ( ) . equals ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_63 . getCode ( ) ) & &
! lineInfo . getWorkflowSubStageStatus ( ) . equals ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_75 . getCode ( ) ) ) ) {
throw new ServiceException ( ErrorCodeEnum . NOT_APPROVE_NODE ) ;
}
//待审核code 63 处理逻辑
if ( lineInfo . getWorkflowSubStageStatus ( ) . equals ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_63 . getCode ( ) ) ) {
lineInfo . setWorkflowSubStageStatus ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_65 . getCode ( ) ) ;
lineInfo . setUpdateUserId ( userId ) ;
lineInfoDAO . updateLineInfo ( lineInfo ) ;
commonService . sendSms ( lineInfo . getMobile ( ) , SMSMsgEnum . INTENTION_PROTOCOL_FAIL ) ;
}
//待OA审核code 75 处理逻辑
if ( lineInfo . getWorkflowSubStageStatus ( ) . equals ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_75 . getCode ( ) ) ) {
lineInfo . setWorkflowSubStageStatus ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_80 . getCode ( ) ) ;
lineInfo . setUpdateUserId ( userId ) ;
lineInfoDAO . updateLineInfo ( lineInfo ) ;
//message
Map < String , String > requestMap = new HashMap < > ( ) ;
requestMap . put ( " partnerUsername " , lineInfo . getUsername ( ) ) ;
requestMap . put ( " lineId " , String . valueOf ( lineInfo . getId ( ) ) ) ;
requestMap . put ( " submitTime " , DateUtils . dateTimeNow ( DateUtils . SPECIAL_DATE_START ) ) ;
commonService . sendMessage ( Collections . singletonList ( lineInfo . getInvestmentManager ( ) ) ,
MessageEnum . MESSAGE_31 ,
requestMap ) ;
// commonService.sendSms(lineInfo.getMobile(), SMSMsgEnum.INTENTION_PAYMENT_FAIL);
}
//更新auditId
intentAgreementMapper . updateAuditId ( lineInfo . getId ( ) , auditId ) ;
return Boolean . TRUE ;
return null ;
}
@Override
public ResponseResult initiating ( Initiating Request request , LoginUserInfo user ) {
log . info ( " initiating request:{} " , JSONObject . toJSONString ( request ) ) ;
if ( Objects . isNull ( request ) ) {
throw new ServiceException ( ErrorCodeEnum . PARAMS_VALIDATE_ERROR ) ;
}
verifyDate ( request ) ;
String lockKey = " submitSignFranchise: " + request . getLineId ( ) ;
//流水
String lockValue = UUID . randomUUID ( ) . toString ( ) ;
boolean acquired = false ;
try {
acquired = redisUtilPool . setNxExpire ( lockKey , lockValue , CommonConstants . TEN_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 ) ;
public Boolean initiating ( IntentAgreementSubmit Request request , LoginUserInfo user ) {
log . info ( " initiating request:{} " , JSONObject . toJSONString ( request ) ) ;
SigningBaseInfoDO signingBaseInfoDO = request . toSigningBaseInfoDO ( ) ;
boolean submitStatus = intentAgreementMapper . insert ( signingBaseInfoDO ) ;
if ( submitStatus ) {
LineInfoDO lineInfoDO = lineInfoMapper . getByPartnerId ( request . getPartnerId ( ) ) ;
if ( Objects . isNull ( lineInfoDO ) ) {
throw new ServiceException ( ErrorCodeEnum . INTERVIEW_PARTNER_NOT_EXIST ) ;
}
} finally {
if ( Boolean . TRUE . equals ( acquired ) ) {
String currentValue = redisUtilPool . getString ( lockKey ) ;
if ( lockValue . equals ( currentValue ) ) {
redisUtilPool . delKey ( lockKey ) ;
}
}
}
lineInfoDO . setWorkflowSubStageStatus ( WorkflowSubStageStatusEnum . SIGN_INTENT_AGREEMENT_125 . getCode ( ) ) ;
lineInfoMapper . updateByPrimaryKeySelective ( lineInfoDO ) ;
AuditPassRequest auditPassRequest = new AuditPassRequest ( ) ;
auditPassRequest . setLineId ( lineInfoDO . getId ( ) ) ;
auditPassRequest . setWorkflowSubStage ( lineInfoDO . getWorkflowSubStage ( ) ) ;
commonService . getLineFlowService ( lineInfoDO . getWorkflowSubStage ( ) ) . auditPass ( auditPassRequest , null ) ;
// TODO: 2024/6/18 企微工作通知
// Map<String, String> requestMap = new HashMap<>();
// requestMap.put("partnerUsername", lineInfoDO.getUsername());
// requestMap.put("partnerMobile", lineInfoDO.getMobile());
// requestMap.put("lineId", String.valueOf(lineInfoDO.getId()));
// requestMap.put("submitTime", DateUtils.dateTimeNow(DateUtils.SPECIAL_DATE_START));
// commonService.sendMessage(Collections.singletonList(lineInfoDO.getInvestmentManager()),
// MessageEnum.MESSAGE_30,
// requestMap);
return Boolean . TRUE ;
}
return false ;
}
private void verifyDate ( InitiatingRequest request ) {
@@ -326,7 +272,7 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
lineInfoMapper . updateByPrimaryKeySelective ( lineInfoParam ) ;
}
if ( initiatingResponse . getCode ( ) ! = 0 ) {
lineInfoDO. setWorkflowSubStageStatus( WorkflowSubStageStatusEnum. SIGN_INTENT_AGREEMENT_63. getCode( ) ) ;
// lineInfoDO. setWorkflowSubStageStatus( WorkflowSubStageStatusEnum. SIGN_INTENT_AGREEMENT_63. getCode()) ;
lineInfoMapper . updateByPrimaryKeySelective ( lineInfoDO ) ;
return new ResponseResult ( 500 , initiatingResponse . getMessage ( ) , initiatingResponse . getData ( ) ) ;
} else {
@@ -358,10 +304,10 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
throw new ServiceException ( ErrorCodeEnum . LINE_ID_IS_NOT_EXIST ) ;
}
String auditResult = redisUtilPool . getString ( redisKey ) ;
if ( WorkflowSubStageStatusEnum. SIGN_INTENT_AGREEMENT_70. getCode( ) . equals( lineInfoDO. getWorkflowSubStageStatus( ) ) ) {
//鲜丰系统不稳定, 会出现调用成功但内部状态未更改的情况, 这时直接返回true即可
return true ;
}
// if ( WorkflowSubStageStatusEnum. SIGN_INTENT_AGREEMENT_70. getCode(). equals( lineInfoDO. getWorkflowSubStageStatus())) {
// //鲜丰系统不稳定, 会出现调用成功但内部状态未更改的情况, 这时直接返回true即可
// return true;
// }
if ( request . getAuditResult ( ) = = 1 ) {
AuditPassRequest auditPassRequest = new AuditPassRequest ( ) ;
auditPassRequest . setLineId ( lineInfoDO . getId ( ) ) ;