|  |  | @ -13,8 +13,12 @@ import com.epmet.dao.AuthorizationInfoDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.ComponentAccessTokenDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.CodeHistoryResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.QrCodeResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.ReasonResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.TemplateListResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.OperCrmOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.OssFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.wxapi.param.WxMaCodeCommitReq; | 
			
		
	
	
		
			
				
					|  |  | @ -24,8 +28,6 @@ import com.epmet.wxapi.result.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.wxapi.service.WxMaCodeService; | 
			
		
	
		
			
				
					|  |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
		
			
				
					|  |  |  | import com.github.pagehelper.PageInfo; | 
			
		
	
		
			
				
					|  |  |  | import com.google.gson.JsonElement; | 
			
		
	
		
			
				
					|  |  |  | import com.google.gson.JsonParser; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
	
		
			
				
					|  |  | @ -63,6 +65,8 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 	private CodeMediaService codeMediaService; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private CodeExtService codeExtService; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private OssFeignClient ossFeignClient; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	public List<TemplateListResultDTO> templateList() { | 
			
		
	
	
		
			
				
					|  |  | @ -101,7 +105,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 	@Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  | 	public void upload(CodeUploadFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  | 		//是否授权
 | 
			
		
	
		
			
				
					|  |  |  | 		if (customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 		if (!customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("未授权"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//获取小程序调用令牌
 | 
			
		
	
	
		
			
				
					|  |  | @ -148,6 +152,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class); | 
			
		
	
		
			
				
					|  |  |  | 		codeCustomerDTO.setCustomerName(customerInfo.getData().getCustomerName()); | 
			
		
	
		
			
				
					|  |  |  | 		codeCustomerDTO.setExtJson(formDTO.getExtJson()); | 
			
		
	
		
			
				
					|  |  |  | 		codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid()); | 
			
		
	
		
			
				
					|  |  |  | 		codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); | 
			
		
	
		
			
				
					|  |  |  | 		codeCustomerService.save(codeCustomerDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -158,37 +163,36 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 	public PageData uploadList(UploadListFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  | 		//获取小程序调用令牌
 | 
			
		
	
		
			
				
					|  |  |  | 		AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); | 
			
		
	
		
			
				
					|  |  |  | 		if (null == authInfo) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("未授权"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		List<CodeCustomerDTO> auditingList = codeCustomerService.getAuditingCodeList(); | 
			
		
	
		
			
				
					|  |  |  | 		auditingList.forEach(code -> { | 
			
		
	
		
			
				
					|  |  |  | 			//获取审核结果信息
 | 
			
		
	
		
			
				
					|  |  |  | 			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); | 
			
		
	
		
			
				
					|  |  |  | 					codeOperationHistoryService.updateDescribe(code.getId(), "审核成功"); | 
			
		
	
		
			
				
					|  |  |  | 				} else if (result.getStatus() == NumConstant.ONE) { | 
			
		
	
		
			
				
					|  |  |  | 					code.setStatus(CodeConstant.AUDIT_FAILED); | 
			
		
	
		
			
				
					|  |  |  | 					auditResult.setResult(CodeConstant.AUDIT_FAILED); | 
			
		
	
		
			
				
					|  |  |  | 					auditResult.setReason(result.getReason()); | 
			
		
	
		
			
				
					|  |  |  | 					codeOperationHistoryService.updateDescribe(code.getId(), result.getReason()); | 
			
		
	
		
			
				
					|  |  |  | 				} else if (result.getStatus() == NumConstant.FOUR) { | 
			
		
	
		
			
				
					|  |  |  | 					code.setStatus(CodeConstant.DELAY); | 
			
		
	
		
			
				
					|  |  |  | 					auditResult.setResult(CodeConstant.DELAY); | 
			
		
	
		
			
				
					|  |  |  | 					codeOperationHistoryService.updateDescribe(code.getId(), "审核延后"); | 
			
		
	
		
			
				
					|  |  |  | 		if (null != authInfo) { | 
			
		
	
		
			
				
					|  |  |  | 			List<CodeCustomerDTO> auditingList = codeCustomerService.getAuditingCodeList(); | 
			
		
	
		
			
				
					|  |  |  | 			auditingList.forEach(code -> { | 
			
		
	
		
			
				
					|  |  |  | 				//获取审核结果信息
 | 
			
		
	
		
			
				
					|  |  |  | 				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); | 
			
		
	
		
			
				
					|  |  |  | 						codeOperationHistoryService.updateDescribe(code.getId(), "审核成功"); | 
			
		
	
		
			
				
					|  |  |  | 					} else if (result.getStatus() == NumConstant.ONE) { | 
			
		
	
		
			
				
					|  |  |  | 						code.setStatus(CodeConstant.AUDIT_FAILED); | 
			
		
	
		
			
				
					|  |  |  | 						auditResult.setResult(CodeConstant.AUDIT_FAILED); | 
			
		
	
		
			
				
					|  |  |  | 						auditResult.setReason(result.getReason()); | 
			
		
	
		
			
				
					|  |  |  | 						codeOperationHistoryService.updateDescribe(code.getId(), result.getReason()); | 
			
		
	
		
			
				
					|  |  |  | 					} else if (result.getStatus() == NumConstant.FOUR) { | 
			
		
	
		
			
				
					|  |  |  | 						code.setStatus(CodeConstant.DELAY); | 
			
		
	
		
			
				
					|  |  |  | 						auditResult.setResult(CodeConstant.DELAY); | 
			
		
	
		
			
				
					|  |  |  | 						codeOperationHistoryService.updateDescribe(code.getId(), "审核延后"); | 
			
		
	
		
			
				
					|  |  |  | 					} | 
			
		
	
		
			
				
					|  |  |  | 					codeCustomerService.update(code); | 
			
		
	
		
			
				
					|  |  |  | 					codeAuditResultService.update(auditResult); | 
			
		
	
		
			
				
					|  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  | 				codeCustomerService.update(code); | 
			
		
	
		
			
				
					|  |  |  | 				codeAuditResultService.update(auditResult); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 		}); | 
			
		
	
		
			
				
					|  |  |  | 			}); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		return codeCustomerService.getCodeList(formDTO); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -197,7 +201,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		//获取上传代码信息
 | 
			
		
	
		
			
				
					|  |  |  | 		CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); | 
			
		
	
		
			
				
					|  |  |  | 		//是否授权
 | 
			
		
	
		
			
				
					|  |  |  | 		if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 		if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("未授权"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//获取小程序调用令牌
 | 
			
		
	
	
		
			
				
					|  |  | @ -232,7 +236,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		//获取上传代码信息
 | 
			
		
	
		
			
				
					|  |  |  | 		CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); | 
			
		
	
		
			
				
					|  |  |  | 		//是否授权
 | 
			
		
	
		
			
				
					|  |  |  | 		if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 		if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("未授权"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//获取审核结果信息
 | 
			
		
	
	
		
			
				
					|  |  | @ -277,7 +281,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		//获取上传代码信息
 | 
			
		
	
		
			
				
					|  |  |  | 		CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); | 
			
		
	
		
			
				
					|  |  |  | 		//是否授权
 | 
			
		
	
		
			
				
					|  |  |  | 		if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 		if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("未授权"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//获取小程序调用令牌
 | 
			
		
	
	
		
			
				
					|  |  | @ -308,7 +312,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		//获取上传代码信息
 | 
			
		
	
		
			
				
					|  |  |  | 		CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); | 
			
		
	
		
			
				
					|  |  |  | 		//是否授权
 | 
			
		
	
		
			
				
					|  |  |  | 		if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 		if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("未授权"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); | 
			
		
	
	
		
			
				
					|  |  | @ -343,7 +347,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		//获取上传代码信息
 | 
			
		
	
		
			
				
					|  |  |  | 		CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); | 
			
		
	
		
			
				
					|  |  |  | 		//是否授权
 | 
			
		
	
		
			
				
					|  |  |  | 		if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 		if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("未授权"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//获取小程序调用令牌
 | 
			
		
	
	
		
			
				
					|  |  | @ -383,7 +387,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 			CodeMediaDTO codeMediaDTO = new CodeMediaDTO(); | 
			
		
	
		
			
				
					|  |  |  | 			codeMediaDTO.setCodeId(formDTO.getCodeId()); | 
			
		
	
		
			
				
					|  |  |  | 			codeMediaDTO.setMediaId(wxResult.getData().getMediaId()); | 
			
		
	
		
			
				
					|  |  |  | 			codeMediaDTO.setMediaName(formDTO.getMedia().getName()); | 
			
		
	
		
			
				
					|  |  |  | 			codeMediaDTO.setMediaName(formDTO.getMedia().getOriginalFilename()); | 
			
		
	
		
			
				
					|  |  |  | 			codeMediaDTO.setMediaType(wxResult.getData().getType()); | 
			
		
	
		
			
				
					|  |  |  | 			codeMediaService.save(codeMediaDTO); | 
			
		
	
		
			
				
					|  |  |  | 			return wxResult.getData().getMediaId(); | 
			
		
	
	
		
			
				
					|  |  | @ -399,7 +403,7 @@ public class CodeServiceImpl implements CodeService { | 
			
		
	
		
			
				
					|  |  |  | 		operationDTO.setCodeId(codeId); | 
			
		
	
		
			
				
					|  |  |  | 		operationDTO.setVersion(version); | 
			
		
	
		
			
				
					|  |  |  | 		operationDTO.setOperation(operation); | 
			
		
	
		
			
				
					|  |  |  | 		operationDTO.setDescribe(describe); | 
			
		
	
		
			
				
					|  |  |  | 		operationDTO.setDescription(describe); | 
			
		
	
		
			
				
					|  |  |  | 		codeOperationHistoryService.save(operationDTO); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 |