选装售后
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

AflPaccountRefundCountServiceImpl.java 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package com.qtzl.alterSales.manager.service;
  2. import cn.com.taiji.common.manager.net.http.ServiceHandleException;
  3. import cn.hutool.core.bean.BeanUtil;
  4. import com.qtzl.alterSales.dao.entity.primary.FssPaccountPay;
  5. import com.qtzl.alterSales.dao.entity.second.AflPaccountRefundCount;
  6. import com.qtzl.alterSales.dao.repo.jpa.primary.FssPaccountPayRepo;
  7. import com.qtzl.alterSales.dao.repo.jpa.second.AflPaccountRefundCountRepo;
  8. import com.qtzl.alterSales.manager.model.protocol.UcServiceError;
  9. import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageRequest;
  10. import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageViewRequest;
  11. import com.qtzl.alterSales.manager.service.third.ConstantConfig;
  12. import com.qtzl.alterSales.manager.service.third.FmsService;
  13. import com.qtzl.alterSales.manager.tools.ExcelUtils;
  14. import com.qtzl.alterSales.manager.vo.AflPaccountRefundCountVo;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.stereotype.Service;
  19. import javax.annotation.Resource;
  20. import java.io.File;
  21. import java.time.LocalDateTime;
  22. import java.time.format.DateTimeFormatter;
  23. import java.util.List;
  24. @Service
  25. public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCountService{
  26. private static final Logger log = LoggerFactory.getLogger(AflPaccountRefundCountServiceImpl.class);
  27. @Resource
  28. AflPaccountRefundCountRepo aflPaccountRefundCountRepo;
  29. @Resource
  30. FssPaccountPayRepo fssPaccountPayRepo;
  31. @Resource
  32. FmsService fmsService;
  33. @Resource
  34. ConstantConfig constantConfig;
  35. @Override
  36. public String export(AflPaccountRefundCountFindPageViewRequest request, Logger logger) throws ServiceHandleException {
  37. String pathFile =null;
  38. try {
  39. AflPaccountRefundCountFindPageRequest queryRequest = new AflPaccountRefundCountFindPageRequest();
  40. BeanUtil.copyProperties(request, queryRequest);
  41. List<AflPaccountRefundCountVo> aflPaccountRefundCountVos = aflPaccountRefundCountRepo.list(queryRequest);
  42. if (aflPaccountRefundCountVos==null||aflPaccountRefundCountVos.size()==0) {
  43. pathFile = ExcelUtils.export(null, "部中心请款流水统计",constantConfig.getFilePath() ,null, AflPaccountRefundCountVo.class);
  44. } else {
  45. logger.info("选装-部中心请款流水统计导出我进来了");
  46. pathFile = ExcelUtils.export(null, "部中心请款流水统计",constantConfig.getFilePath(), aflPaccountRefundCountVos, AflPaccountRefundCountVo.class);
  47. }
  48. if (StringUtils.isEmpty(pathFile)){
  49. throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("部中心请款流水统计导出失败");
  50. }
  51. String s = null;
  52. try {
  53. s = fmsService.uploadFile(constantConfig.getUploadFile(),pathFile, 90000);
  54. } catch (ServiceHandleException e) {
  55. logger.error("选装-部中心请款流水统计导出失败:{}", e.getMessage());
  56. throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException(e.getMessage());
  57. }
  58. if (StringUtils.isEmpty(s)){
  59. throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("部中心请款流水统计导出失败");
  60. }
  61. return s;
  62. } catch (Exception e) {
  63. if (e instanceof ServiceHandleException) {
  64. throw e;
  65. }
  66. logger.error("选装-部中心请款流水统计导出失败:{}", e.getMessage());
  67. throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("部中心请款流水统计导出失败");
  68. }finally {
  69. File file = null;
  70. try {
  71. file = new File(pathFile);
  72. } catch (Exception e) {
  73. }
  74. if (file!=null){
  75. file.delete();
  76. }
  77. }
  78. }
  79. @Override
  80. public void saveFind(String payId) {
  81. log.error("请求查询流水信息请求参数,payId={}",payId);
  82. if (StringUtils.isEmpty(payId)){
  83. log.error("请求查询流水信息请求参数为空");
  84. return;
  85. }
  86. FssPaccountPay fssPaccountPay = fssPaccountPayRepo.findByPayId(payId);
  87. if (fssPaccountPay==null){
  88. log.error("未查询到流水信息,payId ={}",payId);
  89. return;
  90. }
  91. if (fssPaccountPay.getStatus()==null ||fssPaccountPay.getStatus().equals(1)){
  92. log.error("查询到流水信息状态为已补缴或状态为空,payId ={},status={}",payId,fssPaccountPay.getStatus());
  93. return;
  94. }
  95. if (StringUtils.isEmpty(fssPaccountPay.getAgentId())||fssPaccountPay.getInserttime()==null||fssPaccountPay.getReceiptAmt()==null){
  96. log.error("查询到流水信息渠道id不存在或者插入时间为空或金额为空,payId ={}",payId);
  97. return;
  98. }
  99. String format =null;
  100. try {
  101. format = DateTimeFormatter.ofPattern("yyyyMMdd").format(fssPaccountPay.getInserttime());
  102. } catch (Exception e) {
  103. log.error("查询到流水信息插入时间转换有误,payId ={}",payId);
  104. return;
  105. }
  106. if (StringUtils.isEmpty(format)){
  107. log.error("查询到流水信息时间日期为空,payId ={}",payId);
  108. return;
  109. }
  110. AflPaccountRefundCount aflPaccountRefundCount = null;
  111. try {
  112. if ("52010188999".equals(fssPaccountPay.getAgentId())){
  113. fssPaccountPay.setAgentId("52010188930");
  114. }
  115. aflPaccountRefundCount = aflPaccountRefundCountRepo.finByDateAndAgentId(fssPaccountPay.getAgentId(),Integer.parseInt(format));
  116. } catch (NumberFormatException e) {
  117. log.error("格式转换有误,AgentId ={},accountDate={}",fssPaccountPay.getAgentId(),format);
  118. }
  119. if (aflPaccountRefundCount==null){
  120. log.error("未查询到部中心原始流水统计信息,AgentId ={},accountDate={}",fssPaccountPay.getAgentId(),format);
  121. return;
  122. }
  123. Long collectMoney =0l;
  124. if (aflPaccountRefundCount.getCollectMoney()!=null){
  125. collectMoney = aflPaccountRefundCount.getCollectMoney();
  126. }
  127. // Long collectMoney = aflPaccountRefundCount.getCollectMoney();
  128. log.info("查询到流水统计信息已收取金额为,collectMoney ={}",collectMoney);
  129. log.info("查询到流水信息扣款金额为,receiptAmt ={}",fssPaccountPay.getReceiptAmt());
  130. Long newCollectMoney=collectMoney;
  131. if (fssPaccountPay.getReceiptAmt()!=null){
  132. newCollectMoney = collectMoney + fssPaccountPay.getReceiptAmt();
  133. }
  134. log.info("查询到流水统计信息最新已收取金额为,newCollectMoney ={}",newCollectMoney);
  135. aflPaccountRefundCount.setCollectMoney(newCollectMoney);
  136. aflPaccountRefundCount.setUpdateTime(LocalDateTime.now());
  137. aflPaccountRefundCountRepo.save(aflPaccountRefundCount);
  138. }
  139. }