|
|
@ -23,6 +23,7 @@ import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.mock.web.MockMultipartFile; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -165,12 +166,26 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); |
|
|
|
String codeId = codeCustomerService.save(codeCustomerDTO); |
|
|
|
|
|
|
|
//设置服务器域名
|
|
|
|
wxResult = wxMaCodeService.modifyDomain(authInfo.getAuthorizerAccessToken()); |
|
|
|
if (!wxResult.success()) { |
|
|
|
saveOperation(formDTO.getCustomerId(), null, formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, wxResult.getErrorMsg()); |
|
|
|
throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); |
|
|
|
} |
|
|
|
//设置业务域名
|
|
|
|
wxResult = wxMaCodeService.setWebviewDomain(authInfo.getAuthorizerAccessToken()); |
|
|
|
if (!wxResult.success()) { |
|
|
|
saveOperation(formDTO.getCustomerId(), null, formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, wxResult.getErrorMsg()); |
|
|
|
throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
saveOperation(formDTO.getCustomerId(), 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 -> { |
|
|
|
//获取小程序调用令牌
|
|
|
@ -186,18 +201,18 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
if (result.getStatus() == NumConstant.ZERO) { |
|
|
|
code.setStatus(CodeConstant.AUDIT_SUCCESS); |
|
|
|
auditResult.setResult(CodeConstant.AUDIT_SUCCESS); |
|
|
|
saveOperation(formDTO.getCustomerId(), code.getId(), code.getUserVersion(), CodeConstant.OPER_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(formDTO.getCustomerId(), code.getId(), code.getUserVersion(), CodeConstant.OPER_FAILED, result.getReason()); |
|
|
|
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(formDTO.getCustomerId(), code.getId(), code.getUserVersion(), CodeConstant.OPER_DELAY, result.getReason()); |
|
|
|
saveOperation(customerId, code.getId(), code.getUserVersion(), CodeConstant.OPER_DELAY, result.getReason()); |
|
|
|
} |
|
|
|
codeCustomerService.update(code); |
|
|
|
codeAuditResultService.update(auditResult); |
|
|
@ -246,9 +261,13 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
codeAuditResultDTO.setResult(CodeConstant.AUDITING); |
|
|
|
codeAuditResultService.save(codeAuditResultDTO); |
|
|
|
} else { |
|
|
|
codeAuditResultService.deleteById(codeAuditResultDTO.getId()); |
|
|
|
codeAuditResultDTO = new CodeAuditResultDTO(); |
|
|
|
codeAuditResultDTO.setCustomerId(codeCustomerDTO.getCustomerId()); |
|
|
|
codeAuditResultDTO.setCodeId(codeCustomerDTO.getId()); |
|
|
|
codeAuditResultDTO.setAuditId(wxResult.getData()); |
|
|
|
codeAuditResultDTO.setResult(CodeConstant.AUDITING); |
|
|
|
codeAuditResultService.update(codeAuditResultDTO); |
|
|
|
codeAuditResultService.save(codeAuditResultDTO); |
|
|
|
} |
|
|
|
//更新代码表状态
|
|
|
|
codeCustomerDTO.setStatus(CodeConstant.AUDITING); |
|
|
@ -333,8 +352,9 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ReasonResultDTO reason(CodeCommonFormDTO formDTO) { |
|
|
|
ReasonResultDTO result = new ReasonResultDTO(); |
|
|
|
public List<ReasonResultDTO> reason(CodeCommonFormDTO formDTO) { |
|
|
|
List<ReasonResultDTO> resultList = new ArrayList<>(); |
|
|
|
|
|
|
|
//获取上传代码信息
|
|
|
|
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); |
|
|
|
//是否授权
|
|
|
@ -346,25 +366,48 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
throw new RenException("未授权"); |
|
|
|
} |
|
|
|
//获取审核结果信息
|
|
|
|
CodeAuditResultDTO codeAuditResultDTO = codeAuditResultService.getAuditResultByCodeId(formDTO.getCodeId()); |
|
|
|
result.setReason(codeAuditResultDTO.getReason()); |
|
|
|
String[] mediaIds = codeAuditResultDTO.getScreenShot().split("[|]"); |
|
|
|
List<String> mediaIdList = new ArrayList<>(mediaIds.length); |
|
|
|
Collections.addAll(mediaIdList, mediaIds); |
|
|
|
List<String> urlList = new ArrayList<>(); |
|
|
|
mediaIdList.forEach(mediaId -> { |
|
|
|
//调用微信API获取素材
|
|
|
|
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); |
|
|
|
request.setAuditId(codeAuditResultDTO.getAuditId()); |
|
|
|
WxMaNewsReq wxMaNewsReq = new WxMaNewsReq(); |
|
|
|
wxMaNewsReq.setMediaId(mediaId); |
|
|
|
WxResult<byte[]> wxAuditResult = wxMaCodeService.getMaterial(authInfo.getAuthorizerAccessToken(), wxMaNewsReq); |
|
|
|
MultipartFile file = new MockMultipartFile("file", "QRCode.jpg", "image/jpeg", wxAuditResult.getData()); |
|
|
|
Result<UploadImgResultDTO> uploadResult = ossFeignClient.uploadQrCode(file); |
|
|
|
urlList.add(uploadResult.getData().getUrl()); |
|
|
|
List<CodeAuditResultDTO> codeAuditResultList = codeAuditResultService.getAuditFailedList(formDTO.getCodeId()); |
|
|
|
codeAuditResultList.forEach(dto -> { |
|
|
|
ReasonResultDTO result = new ReasonResultDTO(); |
|
|
|
result.setReason(dto.getReason()); |
|
|
|
result.setAuditTime(DateUtils.format(dto.getCreatedTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
if (StringUtils.isBlank(dto.getScreenShotUrl())) { |
|
|
|
List<String> urlList = new ArrayList<>(); |
|
|
|
if(StringUtils.isNotBlank(dto.getScreenShot())) { |
|
|
|
String[] mediaIds = dto.getScreenShot().split("[|]"); |
|
|
|
List<String> mediaIdList = new ArrayList<>(mediaIds.length); |
|
|
|
Collections.addAll(mediaIdList, mediaIds); |
|
|
|
String screenShotUrl = ""; |
|
|
|
for(String mediaId : mediaIdList) { |
|
|
|
//调用微信API获取素材
|
|
|
|
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); |
|
|
|
request.setAuditId(dto.getAuditId()); |
|
|
|
WxMaNewsReq wxMaNewsReq = new WxMaNewsReq(); |
|
|
|
wxMaNewsReq.setMediaId(mediaId); |
|
|
|
WxResult<byte[]> wxAuditResult = wxMaCodeService.getMaterial(authInfo.getAuthorizerAccessToken(), wxMaNewsReq); |
|
|
|
MultipartFile file = new MockMultipartFile("file", "QRCode.jpg", "image/jpeg", wxAuditResult.getData()); |
|
|
|
Result<UploadImgResultDTO> uploadResult = ossFeignClient.uploadQrCode(file); |
|
|
|
urlList.add(uploadResult.getData().getUrl()); |
|
|
|
if (StringUtils.isBlank(screenShotUrl)) { |
|
|
|
screenShotUrl = uploadResult.getData().getUrl(); |
|
|
|
} else { |
|
|
|
screenShotUrl = screenShotUrl + "|" + uploadResult.getData().getUrl(); |
|
|
|
} |
|
|
|
} |
|
|
|
dto.setScreenShotUrl(screenShotUrl); |
|
|
|
codeAuditResultService.update(dto); |
|
|
|
} |
|
|
|
result.setScreenshotUrl(urlList); |
|
|
|
} else { |
|
|
|
String[] url = dto.getScreenShotUrl().split("[|]"); |
|
|
|
List<String> urlList = new ArrayList<>(url.length); |
|
|
|
Collections.addAll(urlList, url); |
|
|
|
result.setScreenshotUrl(urlList); |
|
|
|
} |
|
|
|
resultList.add(result); |
|
|
|
}); |
|
|
|
result.setScreenshotUrl(urlList); |
|
|
|
return result; |
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -400,8 +443,8 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
public PageData history(CodeCommonFormDTO formDTO) { |
|
|
|
PageHelper.startPage(formDTO.getPage(), formDTO.getLimit()); |
|
|
|
//获取上传代码信息
|
|
|
|
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); |
|
|
|
List<CodeHistoryResultDTO> list = codeOperationHistoryService.getHistoryList(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); |
|
|
|
// CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
|
|
|
|
List<CodeHistoryResultDTO> list = codeOperationHistoryService.getHistoryList(formDTO.getCodeId()); |
|
|
|
PageInfo<CodeHistoryResultDTO> pageInfo = new PageInfo<>(list); |
|
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
|
} |
|
|
|