@ -108,13 +108,7 @@ public class CodeServiceImpl implements CodeService {
@Override
@Transactional ( rollbackFor = Exception . class )
public void upload ( CodeUploadFormDTO formDTO ) {
//获取上传代码信息
CodeCustomerDTO uploadCode = codeCustomerService . getUploadCodeByCustomer ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) ) ;
if ( null ! = uploadCode ) {
if ( CodeConstant . AUDITING . equals ( uploadCode . getStatus ( ) ) ) {
throw new RenException ( "已经有正在审核的版本,请等待审核完毕或者撤回审核后再上传" ) ;
}
}
//是否授权
if ( ! customerMpService . getAuthFlag ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) ) ) {
throw new RenException ( "未授权" ) ;
@ -147,15 +141,14 @@ public class CodeServiceImpl implements CodeService {
WxResult wxResult = wxMaCodeService . commit ( authInfo . getAuthorizerAccessToken ( ) , request ) ;
//上传失败,抛出异常
if ( ! wxResult . success ( ) ) {
saveOperation ( formDTO . getCustomerId ( ) , null , formDTO . getUserVersion ( ) , CodeConstant . OPER_UPLOAD , wxResult . getErrorMsg ( ) ) ;
saveOperation ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) , null , formDTO . getUserVersion ( ) , CodeConstant . OPER_UPLOAD ,
wxResult . getErrorMsg ( ) ) ;
throw new RenException ( wxResult . getErrorCode ( ) , wxResult . getErrorMsg ( ) ) ;
}
//获取客户信息
CustomerDTO customerDTO = new CustomerDTO ( ) ;
customerDTO . setId ( formDTO . getCustomerId ( ) ) ;
PaCustomerDTO paCustomerDTO = paCustomerService . get ( formDTO . getCustomerId ( ) ) ;
//将之前上传信息删除
codeCustomerService . deleteCode ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) ) ;
//将上传信息存入表中
CodeCustomerDTO codeCustomerDTO = ConvertUtils . sourceToTarget ( formDTO , CodeCustomerDTO . class ) ;
@ -166,47 +159,77 @@ public class CodeServiceImpl implements CodeService {
codeCustomerDTO . setStatus ( CodeConstant . UNAUDITED ) ;
String codeId = codeCustomerService . save ( codeCustomerDTO ) ;
saveOperation ( formDTO . getCustomerId ( ) , codeId , formDTO . getUserVersion ( ) , CodeConstant . OPER_UPLOAD , "上传成功" ) ;
saveOperation ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) , codeId , formDTO . getUserVersion ( ) , CodeConstant . OPER_UPLOAD , "上传成功" ) ;
}
@Override
public PageData uploadList ( UploadListFormDTO formDTO ) {
List < CodeCustomerDTO > auditingList = codeCustomerService . getAuditingCodeList ( formDTO . getSource ( ) ) ;
String customerId = formDTO . getCustomerId ( ) ;
if ( null ! = auditingList & & auditingList . size ( ) > NumConstant . ZERO ) {
auditingList . forEach ( code - > {
//获取小程序调用令牌
AuthorizationInfoDTO authInfo = authorizationInfoDao . getAuthInfoByCustomer ( code . getCustomerId ( ) , code . getClientType ( ) ) ;
//获取审核结果信息
CodeAuditResultDTO auditResult = codeAuditResultService . getAuditResultByCodeId ( code . getId ( ) ) ;
//调用微信API获取最新审核状态
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq ( ) ;
request . setAuditId ( auditResult . getAuditId ( ) ) ;
WxResult < WxMaAuditStatusResult > wxAuditResult = wxMaCodeService . getAuditStatus ( authInfo . getAuthorizerAccessToken ( ) , request ) ;
if ( wxAuditResult . success ( ) ) {
WxMaAuditStatusResult result = wxAuditResult . getData ( ) ;
if ( result . getStatus ( ) = = NumConstant . ZERO ) {
code . setStatus ( CodeConstant . AUDIT_SUCCESS ) ;
auditResult . setResult ( CodeConstant . AUDIT_SUCCESS ) ;
saveOperation ( customerId , code . getId ( ) , code . getUserVersion ( ) , CodeConstant . OPER_SUCCESS , "审核成功" ) ;
} else if ( result . getStatus ( ) = = NumConstant . ONE ) {
code . setStatus ( CodeConstant . AUDIT_FAILED ) ;
auditResult . setResult ( CodeConstant . AUDIT_FAILED ) ;
auditResult . setReason ( result . getReason ( ) ) ;
auditResult . setScreenShot ( result . getScreenshot ( ) ) ;
saveOperation ( customerId , code . getId ( ) , code . getUserVersion ( ) , CodeConstant . OPER_FAILED , result . getReason ( ) ) ;
} else if ( result . getStatus ( ) = = NumConstant . FOUR ) {
code . setStatus ( CodeConstant . DELAY ) ;
auditResult . setResult ( CodeConstant . DELAY ) ;
auditResult . setReason ( result . getReason ( ) ) ;
saveOperation ( customerId , code . getId ( ) , code . getUserVersion ( ) , CodeConstant . OPER_DELAY , result . getReason ( ) ) ;
}
codeCustomerService . update ( code ) ;
codeAuditResultService . update ( auditResult ) ;
return codeCustomerService . getCodeList ( formDTO ) ;
}
@Override
public CodeVersionInfoResultDTO version ( CustomerClientFormDTO formDTO ) {
CodeVersionInfoResultDTO resultDTO = new CodeVersionInfoResultDTO ( ) ;
//开发版本
CodeCustomerDTO commit = codeCustomerService . getCommitInfo ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) ) ;
resultDTO . getCommit ( ) . setCodeId ( commit . getId ( ) ) ;
resultDTO . getCommit ( ) . setCodeInfo ( commit . getUserDesc ( ) ) ;
resultDTO . getCommit ( ) . setModelId ( commit . getTemplateId ( ) ) ;
resultDTO . getCommit ( ) . setVersion ( commit . getUserVersion ( ) ) ;
resultDTO . getCommit ( ) . setCommitTime ( DateUtils . format ( commit . getCommitTime ( ) , DateUtils . DATE_TIME_PATTERN ) ) ;
//审核版本
CodeCustomerDTO audit = codeCustomerService . getAuditInfo ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) ) ;
resultDTO . getAudit ( ) . setCodeId ( audit . getId ( ) ) ;
resultDTO . getAudit ( ) . setVersion ( audit . getUserVersion ( ) ) ;
resultDTO . getAudit ( ) . setCodeInfo ( audit . getUserDesc ( ) ) ;
if ( CodeConstant . AUDITING . equals ( audit . getStatus ( ) ) ) {
//获取小程序调用令牌
AuthorizationInfoDTO authInfo = authorizationInfoDao . getAuthInfoByCustomer ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) ) ;
//获取审核结果信息
CodeAuditResultDTO auditResult = codeAuditResultService . getAuditResultByCodeId ( audit . getId ( ) ) ;
//调用微信API获取最新审核状态
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq ( ) ;
request . setAuditId ( auditResult . getAuditId ( ) ) ;
WxResult < WxMaAuditStatusResult > wxAuditResult = wxMaCodeService . getAuditStatus ( authInfo . getAuthorizerAccessToken ( ) , request ) ;
if ( wxAuditResult . success ( ) ) {
WxMaAuditStatusResult result = wxAuditResult . getData ( ) ;
if ( result . getStatus ( ) = = NumConstant . ZERO ) {
audit . setStatus ( CodeConstant . AUDIT_SUCCESS ) ;
auditResult . setResult ( CodeConstant . AUDIT_SUCCESS ) ;
saveOperation ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) , audit . getId ( ) , audit . getUserVersion ( ) , CodeConstant . OPER_SUCCESS
, "审核成功" ) ;
} else if ( result . getStatus ( ) = = NumConstant . ONE ) {
audit . setStatus ( CodeConstant . AUDIT_FAILED ) ;
auditResult . setResult ( CodeConstant . AUDIT_FAILED ) ;
auditResult . setReason ( result . getReason ( ) ) ;
auditResult . setScreenShot ( result . getScreenshot ( ) ) ;
saveOperation ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) , audit . getId ( ) , audit . getUserVersion ( ) , CodeConstant . OPER_FAILED ,
result . getReason ( ) ) ;
} else if ( result . getStatus ( ) = = NumConstant . FOUR ) {
audit . setStatus ( CodeConstant . DELAY ) ;
auditResult . setResult ( CodeConstant . DELAY ) ;
auditResult . setReason ( result . getReason ( ) ) ;
saveOperation ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) , audit . getId ( ) , audit . getUserVersion ( ) , CodeConstant . OPER_DELAY ,
result . getReason ( ) ) ;
}
} ) ;
codeCustomerService . update ( audit ) ;
codeAuditResultService . update ( auditResult ) ;
}
}
return codeCustomerService . getCodeList ( formDTO ) ;
resultDTO . getAudit ( ) . setStatus ( audit . getStatus ( ) ) ;
resultDTO . getAudit ( ) . setCommitTime ( DateUtils . format ( audit . getCommitTime ( ) , DateUtils . DATE_TIME_PATTERN ) ) ;
resultDTO . getAudit ( ) . setAuditTime ( DateUtils . format ( audit . getAuditTime ( ) , DateUtils . DATE_TIME_PATTERN ) ) ;
//线上版本
CodeCustomerDTO release = codeCustomerService . getReleaseInfo ( formDTO . getCustomerId ( ) , formDTO . getClientType ( ) ) ;
resultDTO . getRelease ( ) . setCodeId ( release . getId ( ) ) ;
resultDTO . getRelease ( ) . setCodeInfo ( release . getUserDesc ( ) ) ;
resultDTO . getRelease ( ) . setCommitTime ( DateUtils . format ( release . getCommitTime ( ) , DateUtils . DATE_TIME_PATTERN ) ) ;
resultDTO . getRelease ( ) . setAuditTime ( DateUtils . format ( release . getAuditTime ( ) , DateUtils . DATE_TIME_PATTERN ) ) ;
resultDTO . getRelease ( ) . setReleaseTime ( DateUtils . format ( release . getReleaseTime ( ) , DateUtils . DATE_TIME_PATTERN ) ) ;
resultDTO . getRelease ( ) . setReleaseType ( release . getReleaseType ( ) ) ;
resultDTO . getRelease ( ) . setGrayPercentage ( release . getGaryPercentage ( ) ) ;
resultDTO . getRelease ( ) . setVersion ( release . getUserVersion ( ) ) ;
return resultDTO ;
}
@Override
@ -233,8 +256,8 @@ public class CodeServiceImpl implements CodeService {
request . setUgcDeclare ( formDTO . getUgcDeclare ( ) ) ;
WxResult < String > wxResult = wxMaCodeService . submitAudit ( authInfo . getAuthorizerAccessToken ( ) , request ) ;
if ( ! wxResult . success ( ) ) {
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getId ( ) , codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_SUBMIT ,
wxResult . getErrorMsg ( ) ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getClientType ( ) , codeCustomerDTO . getId ( ) ,
codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_SUBMIT , wxResult . getErrorMsg ( ) ) ;
throw new RenException ( wxResult . getErrorCode ( ) , wxResult . getErrorMsg ( ) ) ;
}
if ( formDTO . getIsSpeed ( ) ) {
@ -243,8 +266,8 @@ public class CodeServiceImpl implements CodeService {
speedRequest . setAuditId ( wxResult . getData ( ) ) ;
WxResult wxSpeedResult = wxMaCodeService . speedUpAudit ( authInfo . getAuthorizerAccessToken ( ) , speedRequest ) ;
if ( ! wxSpeedResult . success ( ) ) {
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getId ( ) , codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_SUBMIT ,
wxSpeedResult . getErrorMsg ( ) ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getClientType ( ) , codeCustomerDTO . getId ( ) ,
codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_SUBMIT , wxSpeedResult . getErrorMsg ( ) ) ;
throw new RenException ( wxSpeedResult . getErrorCode ( ) , wxSpeedResult . getErrorMsg ( ) ) ;
}
}
@ -270,8 +293,8 @@ public class CodeServiceImpl implements CodeService {
//更新代码表状态
codeCustomerDTO . setStatus ( CodeConstant . AUDITING ) ;
codeCustomerService . update ( codeCustomerDTO ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getId ( ) , codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_SUBMIT ,
"审核中" ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getClientType ( ) , codeCustomerDTO . get Id ( ) , codeCustomerDTO . getUserVersion ( ) ,
CodeConstant . OPER_SUBMIT , "审核中" ) ;
}
@Override
@ -302,8 +325,8 @@ public class CodeServiceImpl implements CodeService {
//调用微信API撤销审核
WxResult wxResult = wxMaCodeService . undoCodeAudit ( authInfo . getAuthorizerAccessToken ( ) ) ;
if ( ! wxResult . success ( ) ) {
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getId ( ) , codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_UNDO ,
wxResult . getErrorMsg ( ) ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getClientType ( ) , codeCustomerDTO . getId ( ) ,
codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_UNDO , wxResult . getErrorMsg ( ) ) ;
throw new RenException ( wxResult . getErrorCode ( ) , wxResult . getErrorMsg ( ) ) ;
}
//更新审核结果
@ -315,8 +338,8 @@ public class CodeServiceImpl implements CodeService {
//更新审核操作记录描述
codeOperationHistoryService . updateDescribe ( codeCustomerDTO . getId ( ) , "已撤回" ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getId ( ) , codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_UNDO ,
"成功" ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getClientType ( ) , codeCustomerDTO . get Id ( ) , codeCustomerDTO . getUserVersion ( ) ,
CodeConstant . OPER_UNDO , "成功" ) ;
}
@Override
@ -338,15 +361,18 @@ public class CodeServiceImpl implements CodeService {
//更新代码表状态
codeCustomerDTO . setStatus ( CodeConstant . RELEASE_FAILED ) ;
codeCustomerService . update ( codeCustomerDTO ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getId ( ) , codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_RELEASE ,
wxResult . getErrorMsg ( ) ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getClientType ( ) , codeCustomerDTO . getId ( ) ,
codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_RELEASE , wxResult . getErrorMsg ( ) ) ;
throw new RenException ( wxResult . getErrorCode ( ) , wxResult . getErrorMsg ( ) ) ;
}
//将之前上传信息删除
codeCustomerService . deleteCode ( formDTO . getCustomerId ( ) , codeCustomerDTO . getClientType ( ) ) ;
//更新代码表状态
codeCustomerDTO . setStatus ( CodeConstant . RELEASE_SUCCESS ) ;
codeCustomerService . update ( codeCustomerDTO ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getId ( ) , codeCustomerDTO . getUserVersion ( ) , CodeConstant . OPER_RELEASE ,
"发布成功" ) ;
saveOperation ( codeCustomerDTO . getCustomerId ( ) , codeCustomerDTO . getClientType ( ) , codeCustomerDTO . get Id ( ) , codeCustomerDTO . getUserVersion ( ) ,
CodeConstant . OPER_RELEASE , "发布成功" ) ;
}
@Override
@ -522,9 +548,15 @@ public class CodeServiceImpl implements CodeService {
} ) ;
}
private void saveOperation ( String customerId , String codeId , String version , String operation , String describe ) {
@Override
public PageData getCustomerList ( UploadListFormDTO formDTO ) {
return paCustomerService . getCustomerList ( formDTO ) ;
}
private void saveOperation ( String customerId , String clientType , String codeId , String version , String operation , String describe ) {
CodeOperationHistoryDTO operationDTO = new CodeOperationHistoryDTO ( ) ;
operationDTO . setCustomerId ( customerId ) ;
operationDTO . setClientType ( clientType ) ;
operationDTO . setCodeId ( codeId ) ;
operationDTO . setVersion ( version ) ;
operationDTO . setOperation ( operation ) ;