From 62bc90601133204f831502286332da09ae3dd3d7 Mon Sep 17 00:00:00 2001 From: panshuling321 Date: Tue, 15 Feb 2022 11:25:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E5=A2=9E=E5=8A=A0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=AE=B5=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CommonController.java | 15 +- .../XhpcTradebillUploadRecordDomain.java | 5 + .../mapper/XhpcHistoryOrderMapper.java | 5 + .../mapper/XhpcRechargeOrderMapper.java | 6 + .../mapper/XhpcRefundOrderMapper.java | 6 + .../xhpc/tradebill/service/CommonService.java | 2 +- .../service/InternetBillService.java | 16 +- .../tradebill/service/PaymentBillService.java | 8 +- .../service/impl/CommonServiceImpl.java | 62 +++-- .../service/impl/InternetBillServiceImpl.java | 235 +++++++++++------- .../service/impl/PaymentBillServiceImpl.java | 44 +++- .../mapper/XhpcHistoryOrderMapper.xml | 13 + .../mapper/XhpcRechargeOrderMapper.xml | 14 ++ .../mapper/XhpcRefundOrderMapper.xml | 13 + 14 files changed, 301 insertions(+), 143 deletions(-) diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/controller/CommonController.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/controller/CommonController.java index 8eb09059..b5801d42 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/controller/CommonController.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/controller/CommonController.java @@ -6,12 +6,16 @@ import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.log.annotation.Log; import com.xhpc.common.log.enums.BusinessType; +import com.xhpc.common.util.LogUserUtils; +import com.xhpc.system.api.model.LoginUser; import com.xhpc.tradebill.domain.XhpcTradebillUploadRecordDomain; import com.xhpc.tradebill.service.CommonService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; @@ -23,19 +27,24 @@ public class CommonController extends BaseController { @Resource CommonService commonService; + @Resource + LogUserUtils logUserUtils; + @Log(title = "上传对账单(OSS方式)", businessType = BusinessType.INSERT) @PostMapping("/oss/upload") - public AjaxResult OssUpload(@RequestBody XhpcTradebillUploadRecordDomain domain) throws Exception{ + public AjaxResult OssUpload(HttpServletRequest request, @RequestBody XhpcTradebillUploadRecordDomain domain) throws Exception{ + LoginUser logUser = logUserUtils.getLogUser(request); + domain.setTenantId(logUser.getTenantId()); return AjaxResult.success(commonService.ossUpload(domain)); } @Log(title = "上传对账单(文件方式)", businessType = BusinessType.INSERT) @PostMapping("/file/upload") - public AjaxResult fileUpload(MultipartFile file, int type) throws Exception { + public AjaxResult fileUpload(MultipartFile file, int type, String startTime, String endTime) throws Exception { if (file ==null || type < 1){ return AjaxResult.error("文件或者对账类型为空"); } - return AjaxResult.success(commonService.fileUpload(file, type)); + return AjaxResult.success(commonService.fileUpload(file, type, startTime, endTime)); } @GetMapping("/file/getPage") diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/domain/XhpcTradebillUploadRecordDomain.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/domain/XhpcTradebillUploadRecordDomain.java index 47219b5f..00aa5fa1 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/domain/XhpcTradebillUploadRecordDomain.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/domain/XhpcTradebillUploadRecordDomain.java @@ -44,5 +44,10 @@ public class XhpcTradebillUploadRecordDomain implements Serializable { private String tenantId; + // === 时间区段内的订单,仅参数使用 + private String startTime; + private String endTime; + + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcHistoryOrderMapper.java index bc387241..2dc35397 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcHistoryOrderMapper.java @@ -16,4 +16,9 @@ public interface XhpcHistoryOrderMapper { XhpcHistoryOrderDomain findOneByInternetSerialNumber(String internetSerialNumber); List findListByInternetSerialNumbers(@Param("orderNumbers") List internetSerialNumbers); + + + List findListByTimeBetween(@Param("startTime") String startTime, + @Param("endTime")String endTime, + @Param("tenantId")String tenantId); } \ No newline at end of file diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcRechargeOrderMapper.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcRechargeOrderMapper.java index 47f29167..2f345328 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcRechargeOrderMapper.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcRechargeOrderMapper.java @@ -14,4 +14,10 @@ public interface XhpcRechargeOrderMapper { List> findListByOrderNumbers(@Param("orderNumbers") List orderNumbers); + + + List> findListByTimeBetween(@Param("startTime") String startTime, + @Param("endTime") String endTime, + @Param("tenantId") String tenantId); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcRefundOrderMapper.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcRefundOrderMapper.java index 8d2e6b10..2c962a81 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcRefundOrderMapper.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/mapper/XhpcRefundOrderMapper.java @@ -12,6 +12,12 @@ public interface XhpcRefundOrderMapper { XhpcRefundOrderDomain findByOrderNumber(String orderNumber); + List> findListByOrderNumbers(@Param("orderNumbers") List orderNumbers); + + List> findListByTimeBetween(@Param("startTime") String startTime, + @Param("endTime") String endTime, + @Param("tenantId") String tenantId); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/CommonService.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/CommonService.java index 3cd69133..ae687413 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/CommonService.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/CommonService.java @@ -11,7 +11,7 @@ public interface CommonService { XhpcTradebillUploadRecordDomain ossUpload(XhpcTradebillUploadRecordDomain domain) throws Exception; - XhpcTradebillUploadRecordDomain fileUpload(MultipartFile file, int type) throws Exception; + XhpcTradebillUploadRecordDomain fileUpload(MultipartFile file, int type, String startTime, String endTime) throws Exception; List getFilePage(Map params); } diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/InternetBillService.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/InternetBillService.java index c0ba9315..d3e526e1 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/InternetBillService.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/InternetBillService.java @@ -35,7 +35,7 @@ public interface InternetBillService { * @return 对账数据 * @throws Exception 异常 */ - List getHdInternetDataList(String fileUrl) throws Exception; + List getHdInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception; /** @@ -44,7 +44,7 @@ public interface InternetBillService { * @return 对账数据 * @throws Exception 异常 */ - List getHdInternetDataList(File dataFile) throws Exception; + List getHdInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception; /** @@ -53,7 +53,7 @@ public interface InternetBillService { * @return 对账数据 * @throws Exception 异常 */ - List getXjInternetDataList(String fileUrl) throws Exception; + List getXjInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception; @@ -63,7 +63,7 @@ public interface InternetBillService { * @return 对账数据 * @throws Exception 异常 */ - List getXjInternetDataList(File dataFile) throws Exception; + List getXjInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception; /** @@ -72,7 +72,7 @@ public interface InternetBillService { * @return 对账数据 * @throws Exception 异常 */ - List getXDTInternetDataList(String fileUrl) throws Exception; + List getXDTInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception; /** @@ -81,7 +81,7 @@ public interface InternetBillService { * @return 对账数据 * @throws Exception 异常 */ - List getXDTInternetDataList(File dataFile) throws Exception; + List getXDTInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception; @@ -91,7 +91,7 @@ public interface InternetBillService { * @return 对账数据 * @throws Exception 异常 */ - List getKDInternetDataList(String fileUrl) throws Exception; + List getKDInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception; /** @@ -100,7 +100,7 @@ public interface InternetBillService { * @return 对账数据 * @throws Exception 异常 */ - List getKDInternetDataList(File dataFile) throws Exception; + List getKDInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception; /** diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/PaymentBillService.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/PaymentBillService.java index b06fd4f4..2e1bc3b9 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/PaymentBillService.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/PaymentBillService.java @@ -37,7 +37,7 @@ public interface PaymentBillService { * @param fileUrl 数据文件存放地址 * @return 对账完成的数据列表 */ - List getAliPayDataList(String fileUrl) throws Exception ; + List getAliPayDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception ; /** @@ -46,7 +46,7 @@ public interface PaymentBillService { * @param dataFile 数据文件 * @return 对账完成的数据列表 */ - List getAliPayDataList(File dataFile) throws Exception ; + List getAliPayDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception ; /** @@ -55,7 +55,7 @@ public interface PaymentBillService { * @param fileUrl 数据文件存放地址 * @return 对账完成的数据列表 */ - List getWechatDataList(String fileUrl) throws Exception ; + List getWechatDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception ; /** @@ -64,7 +64,7 @@ public interface PaymentBillService { * @param dataFile 数据文件 * @return 对账完成的数据列表 */ - List getWechatDataList(File dataFile) throws Exception ; + List getWechatDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception ; /** diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/CommonServiceImpl.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/CommonServiceImpl.java index c9bc4a0c..9c4a7232 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/CommonServiceImpl.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/CommonServiceImpl.java @@ -38,7 +38,8 @@ public class CommonServiceImpl implements CommonService { AliOSSProperties ossProperties; @Override - public XhpcTradebillUploadRecordDomain ossUpload(XhpcTradebillUploadRecordDomain domain) throws Exception{ + public XhpcTradebillUploadRecordDomain ossUpload(XhpcTradebillUploadRecordDomain domain) throws Exception { + Long userId = SecurityUtils.getUserId(); domain.setCreateBy(userId); domain.setUpdateBy(userId); @@ -58,42 +59,42 @@ public class CommonServiceImpl implements CommonService { Map totalMap = new HashMap<>(); int insertCount = 0; resDomain.setStatus(2); - switch (domain.getType()){ + switch (domain.getType()) { case 1: case 2: // 微信支付 - paymentCheckRecordDomainList = paymentBillService.getWechatDataList(domain.getUrl()); + paymentCheckRecordDomainList = paymentBillService.getWechatDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId()); insertCount = paymentBillService.insertPaymentCheckList(resDomain.getId(), paymentCheckRecordDomainList); totalMap = computePaymentRecord(paymentCheckRecordDomainList); break; case 3: case 4: // 支付宝支付 - paymentCheckRecordDomainList = paymentBillService.getAliPayDataList(domain.getUrl()); + paymentCheckRecordDomainList = paymentBillService.getAliPayDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId()); insertCount = paymentBillService.insertPaymentCheckList(resDomain.getId(), paymentCheckRecordDomainList); totalMap = computePaymentRecord(paymentCheckRecordDomainList); break; case 5: // 恒大 - recordDomainList = internetBillService.getHdInternetDataList(domain.getUrl()); + recordDomainList = internetBillService.getHdInternetDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId()); insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList); totalMap = computeInternetRecord(recordDomainList); break; case 6: // 小桔 - recordDomainList = internetBillService.getXjInternetDataList(domain.getUrl()); + recordDomainList = internetBillService.getXjInternetDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId()); insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList); totalMap = computeInternetRecord(recordDomainList); break; case 7: // 新电途 - recordDomainList = internetBillService.getXDTInternetDataList(domain.getUrl()); + recordDomainList = internetBillService.getXDTInternetDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId()); insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList); totalMap = computeInternetRecord(recordDomainList); break; case 8: // 快电 - recordDomainList = internetBillService.getKDInternetDataList(domain.getUrl()); + recordDomainList = internetBillService.getKDInternetDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId()); insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList); totalMap = computeInternetRecord(recordDomainList); break; @@ -111,21 +112,21 @@ public class CommonServiceImpl implements CommonService { resDomain.setCheckedCount(totalMap.get("checkCount")); resDomain.setUncheckCount(totalMap.get("uncheckCount")); uploadRecordMapper.updateByPrimaryKey(resDomain); - return resDomain; + return resDomain; } - @Override - public XhpcTradebillUploadRecordDomain fileUpload(MultipartFile file, int type) throws Exception{ + public XhpcTradebillUploadRecordDomain fileUpload(MultipartFile file, int type, String startTime, String endTime) throws Exception { + XhpcTradebillUploadRecordDomain domain = new XhpcTradebillUploadRecordDomain(); // 创建OSSClient实例 - String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); + String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); File dataFile = File.createTempFile("temp_", suffix); file.transferTo(dataFile); - String ossPath = "bill/" + file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf(".")) + "_" +System.currentTimeMillis() + "." + suffix; + String ossPath = "bill/" + file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf(".")) + "_" + System.currentTimeMillis() + "." + suffix; OSSClient ossClient = new OSSClient(ossProperties.getEndpoint(), ossProperties.getAccessKey(), ossProperties.getSecretKey()); // 上传文件流 ossClient.putObject(ossProperties.getBucketName(), ossPath, dataFile); @@ -133,29 +134,34 @@ public class CommonServiceImpl implements CommonService { domain.setFileName(file.getOriginalFilename()); domain.setUrl(ossProperties.getDomain() + ossPath); + domain.setStartTime(startTime); + domain.setEndTime(endTime); domain.setType(type); return ossUpload(domain); } @Override - public List getFilePage(Map params){ + public List getFilePage(Map params) { return uploadRecordMapper.selectByType(params); } - private Map computePaymentRecord(List domainList){ + private Map computePaymentRecord(List domainList) { + Integer successCount = 0; Integer failCount = 0; Integer checkCount = 0; Integer uncheckCount = 0; Map result = new HashMap<>(); - for (XhpcTradebillPaymentCheckRecordDomain domain: domainList){ - if(domain.getStatus() == 2){ - successCount++; checkCount++; - } else if(domain.getStatus() == 1 || domain.getStatus() == 0){ - failCount++; checkCount++; + for (XhpcTradebillPaymentCheckRecordDomain domain : domainList) { + if (domain.getStatus() == 2) { + successCount++; + checkCount++; + } else if (domain.getStatus() == 1 || domain.getStatus() == 0) { + failCount++; + checkCount++; } else { uncheckCount++; } @@ -168,17 +174,20 @@ public class CommonServiceImpl implements CommonService { } - private Map computeInternetRecord(List domainList){ + private Map computeInternetRecord(List domainList) { + Integer successCount = 0; Integer failCount = 0; Integer checkCount = 0; Integer uncheckCount = 0; Map result = new HashMap<>(); - for (XhpcTradebillInternetCheckRecordDomain domain: domainList){ - if(domain.getStatus() == 2){ - successCount++; checkCount++; - } else if(domain.getStatus() == 1 || domain.getStatus() == 0){ - failCount++; checkCount++; + for (XhpcTradebillInternetCheckRecordDomain domain : domainList) { + if (domain.getStatus() == 2) { + successCount++; + checkCount++; + } else if (domain.getStatus() == 1 || domain.getStatus() == 0) { + failCount++; + checkCount++; } else { uncheckCount++; } @@ -189,4 +198,5 @@ public class CommonServiceImpl implements CommonService { result.put("uncheckCount", uncheckCount); return result; } + } diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/InternetBillServiceImpl.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/InternetBillServiceImpl.java index 76238d99..88760321 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/InternetBillServiceImpl.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/InternetBillServiceImpl.java @@ -6,7 +6,6 @@ import cn.hutool.core.io.file.FileReader; import cn.hutool.core.text.csv.CsvReader; import cn.hutool.core.text.csv.CsvUtil; import cn.hutool.core.util.StrUtil; -import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelWriter; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.utils.poi.ExcelUtil; @@ -48,23 +47,25 @@ public class InternetBillServiceImpl implements InternetBillService { EtOrderMappingMapper orderMappingMapper; - @Override - public XhpcTradebillInternetCheckRecordDomain getInfoByPk(int pk){ + public XhpcTradebillInternetCheckRecordDomain getInfoByPk(int pk) { + return internetCheckRecordMapper.selectByPrimaryKey(pk); } @Override - public boolean updateInfoByDomain(XhpcTradebillInternetCheckRecordDomain domain){ + public boolean updateInfoByDomain(XhpcTradebillInternetCheckRecordDomain domain) { + domain.setUpdateBy(SecurityUtils.getUserId()); return internetCheckRecordMapper.updateStatusByPk(domain); } @Override - public Integer insertInternetCheckList(int uploadId, List internetCheckRecordDomainList){ + public Integer insertInternetCheckList(int uploadId, List internetCheckRecordDomainList) { + Long userId = SecurityUtils.getUserId(); - for(XhpcTradebillInternetCheckRecordDomain domain: internetCheckRecordDomainList){ + for (XhpcTradebillInternetCheckRecordDomain domain : internetCheckRecordDomainList) { domain.setUploadId(uploadId); domain.setCreateBy(userId); domain.setUpdateBy(userId); @@ -74,26 +75,32 @@ public class InternetBillServiceImpl implements InternetBillService { @Override - public List getInternetCheckList(Map params){ + public List getInternetCheckList(Map params) { + return internetCheckRecordMapper.selectListByParams(params); } @Override - public Map getStatusTotal(Map params){ + public Map getStatusTotal(Map params) { + List> resultList = internetCheckRecordMapper.selectTotalGroupbyStatus(params); int successCount = 0; int failCount = 0; int uncheckCount = 0; int checkCount = 0; - for(Map res : resultList){ - switch (res.get("status").toString()){ + for (Map res : resultList) { + switch (res.get("status").toString()) { case "0": - uncheckCount = Integer.parseInt(res.get("total").toString()); break; + uncheckCount = Integer.parseInt(res.get("total").toString()); + break; case "1": - failCount = Integer.parseInt(res.get("total").toString()); break; + failCount = Integer.parseInt(res.get("total").toString()); + break; case "2": - successCount = Integer.parseInt(res.get("total").toString()); break; - default: break; + successCount = Integer.parseInt(res.get("total").toString()); + break; + default: + break; } } checkCount = successCount + failCount; @@ -108,68 +115,78 @@ public class InternetBillServiceImpl implements InternetBillService { /** * 获取恒大对账数据 + * * @param fileUrl 文件访问地址 - * @return 对账数据 + * @return 对账数据 * @throws Exception 异常 */ @Override - public List getHdInternetDataList(String fileUrl) throws Exception { + public List getHdInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception { + File dataFile = DownloadUtil.downloadFile(fileUrl); - return getHdInternetDataList(dataFile); + return getHdInternetDataList(dataFile, startTime, endTime, tenantId); } /** * 获取小桔对账数据 + * * @param fileUrl 文件访问地址 - * @return 对账数据 + * @return 对账数据 * @throws Exception 异常 */ @Override - public List getXjInternetDataList(String fileUrl) throws Exception { + public List getXjInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception { + File dataFile = DownloadUtil.downloadFile(fileUrl); - return getXjInternetDataList(dataFile); + return getXjInternetDataList(dataFile, startTime, endTime, tenantId); } /** * 获取新电途对账数据 + * * @param fileUrl 文件访问地址 - * @return 对账数据 + * @return 对账数据 * @throws Exception 异常 */ @Override - public List getXDTInternetDataList(String fileUrl) throws Exception { + public List getXDTInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception { + File dataFile = DownloadUtil.downloadFile(fileUrl); - return getXDTInternetDataList(dataFile); + return getXDTInternetDataList(dataFile, startTime, endTime, tenantId); } /** * 获取快电对账数据 + * * @param fileUrl 文件访问地址 - * @return 对账数据 + * @return 对账数据 * @throws Exception 异常 */ @Override - public List getKDInternetDataList(String fileUrl) throws Exception { + public List getKDInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception { + File dataFile = DownloadUtil.downloadFile(fileUrl); - return getKDInternetDataList(dataFile); + return getKDInternetDataList(dataFile, startTime, endTime, tenantId); } /** * 获取恒大对账数据 + * * @param dataFile 对账单文件,格式为xlsx * @return 对账数据 */ @Override - public List getHdInternetDataList(File dataFile) throws Exception { + public List getHdInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception { + List checkRecordDomainList = new ArrayList<>(); String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1); List hdTradebillVoList = new ArrayList<>(); List serialNumberList = new ArrayList<>(); - switch (suffix.toUpperCase()){ + switch (suffix.toUpperCase()) { case "XLS": case "XLSX": ExcelUtil util = new ExcelUtil(HDTradebillVo.class); @@ -180,30 +197,31 @@ public class InternetBillServiceImpl implements InternetBillService { FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK")); hdTradebillVoList = reader.read(fileReader.readString(), HDTradebillVo.class); break; - default:break; + default: + break; } - for(HDTradebillVo vo: hdTradebillVoList){ + for (HDTradebillVo vo : hdTradebillVoList) { XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain(); domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim()); domain.setInternetSerialNumber(vo.getOrderNo().trim()); domain.setSource("恒大"); domain.setInternetName("恒大"); domain.setInternetChargeStation(vo.getStationName()); - BigDecimal chargingDegree = vo.getChargeDegree()!=null ? BigDecimal.valueOf(vo.getChargeDegree()) : BigDecimal.ZERO; + BigDecimal chargingDegree = vo.getChargeDegree() != null ? BigDecimal.valueOf(vo.getChargeDegree()) : BigDecimal.ZERO; domain.setInternetChargingDegree(chargingDegree); - BigDecimal orderAmount = vo.getOrderTotalAmount() !=null? BigDecimal.valueOf(vo.getOrderTotalAmount()): BigDecimal.ZERO; + BigDecimal orderAmount = vo.getOrderTotalAmount() != null ? BigDecimal.valueOf(vo.getOrderTotalAmount()) : BigDecimal.ZERO; domain.setInternetOrderAmount(orderAmount); - BigDecimal powerAmount = vo.getPowerAmount()!=null? BigDecimal.valueOf(vo.getPowerAmount()): BigDecimal.ZERO; + BigDecimal powerAmount = vo.getPowerAmount() != null ? BigDecimal.valueOf(vo.getPowerAmount()) : BigDecimal.ZERO; domain.setInternetPowerAmount(powerAmount); - BigDecimal serverAmount = vo.getServerAmount()!= null? BigDecimal.valueOf(vo.getServerAmount()): BigDecimal.ZERO; + BigDecimal serverAmount = vo.getServerAmount() != null ? BigDecimal.valueOf(vo.getServerAmount()) : BigDecimal.ZERO; domain.setInternetServerAmount(serverAmount); domain.setInternetDiscountAmount(BigDecimal.ZERO); - BigDecimal payAmount = vo.getOrderTotalAmount()!=null ? BigDecimal.valueOf(vo.getOrderTotalAmount()): BigDecimal.ZERO; + BigDecimal payAmount = vo.getOrderTotalAmount() != null ? BigDecimal.valueOf(vo.getOrderTotalAmount()) : BigDecimal.ZERO; domain.setInternetPayAmount(payAmount); serialNumberList.add(domain.getInternetSerialNumber()); @@ -211,7 +229,7 @@ public class InternetBillServiceImpl implements InternetBillService { // getHistoryOrderInfo(domain); checkRecordDomainList.add(domain); } - getHistoryOrderList(checkRecordDomainList, serialNumberList); + getHistoryOrderList(checkRecordDomainList, serialNumberList, startTime, endTime, tenantId); return checkRecordDomainList; } @@ -219,18 +237,19 @@ public class InternetBillServiceImpl implements InternetBillService { /** * 获取小桔对账数据 + * * @param dataFile 对账单文件,格式为xlsx * @return 对账数据 */ @Override - public List getXjInternetDataList(File dataFile) throws Exception { + public List getXjInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception { String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1); List checkRecordDomainList = new ArrayList<>(); List xjTradeBillVoList = new ArrayList<>(); List serialNumberList = new ArrayList<>(); - switch (suffix.toUpperCase()){ + switch (suffix.toUpperCase()) { case "XLS": case "XLSX": ExcelUtil util = new ExcelUtil(XJTradeBillVo.class); @@ -241,10 +260,11 @@ public class InternetBillServiceImpl implements InternetBillService { FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK")); xjTradeBillVoList = reader.read(fileReader.readString(), XJTradeBillVo.class); break; - default: break; + default: + break; } - for(XJTradeBillVo vo: xjTradeBillVoList){ + for (XJTradeBillVo vo : xjTradeBillVoList) { XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain(); domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim()); domain.setInternetSerialNumber(vo.getOrderNo().trim()); @@ -253,23 +273,23 @@ public class InternetBillServiceImpl implements InternetBillService { domain.setInternetChargeStation(vo.getStationName()); domain.setInternetStartSoc(vo.getStartSoc()); domain.setInternetEndSoc(vo.getEndSoc()); - BigDecimal chargingDegree = vo.getChargingDegree()!=null ? BigDecimal.valueOf(vo.getChargingDegree()): BigDecimal.ZERO; + BigDecimal chargingDegree = vo.getChargingDegree() != null ? BigDecimal.valueOf(vo.getChargingDegree()) : BigDecimal.ZERO; domain.setInternetChargingDegree(chargingDegree); domain.setInternetChargingTime(vo.getChargingTime().toString()); domain.setInternetStartTime(vo.getChargingStartTime()); domain.setInternetEndTime(vo.getChargingEndTime()); - BigDecimal orderAmount = vo.getBillAmount() !=null? BigDecimal.valueOf(vo.getBillAmount()): BigDecimal.ZERO; + BigDecimal orderAmount = vo.getBillAmount() != null ? BigDecimal.valueOf(vo.getBillAmount()) : BigDecimal.ZERO; domain.setInternetOrderAmount(orderAmount); - BigDecimal powerAmount = vo.getOrderPowerAmount()!=null? BigDecimal.valueOf(vo.getOrderPowerAmount()): BigDecimal.ZERO; + BigDecimal powerAmount = vo.getOrderPowerAmount() != null ? BigDecimal.valueOf(vo.getOrderPowerAmount()) : BigDecimal.ZERO; domain.setInternetPowerAmount(powerAmount); - BigDecimal serverAmount = vo.getOrderServerAmount()!= null? BigDecimal.valueOf(vo.getOrderServerAmount()): BigDecimal.ZERO; + BigDecimal serverAmount = vo.getOrderServerAmount() != null ? BigDecimal.valueOf(vo.getOrderServerAmount()) : BigDecimal.ZERO; domain.setInternetServerAmount(serverAmount); domain.setInternetDiscountAmount(BigDecimal.ZERO); - BigDecimal payAmount = vo.getOrderTotalAmount()!=null ? BigDecimal.valueOf(vo.getOrderTotalAmount()): BigDecimal.ZERO; + BigDecimal payAmount = vo.getOrderTotalAmount() != null ? BigDecimal.valueOf(vo.getOrderTotalAmount()) : BigDecimal.ZERO; domain.setInternetPayAmount(payAmount); serialNumberList.add(domain.getInternetSerialNumber()); @@ -277,24 +297,26 @@ public class InternetBillServiceImpl implements InternetBillService { // checkRecordDomainList.add(domain); } - getHistoryOrderList(checkRecordDomainList, serialNumberList); + getHistoryOrderList(checkRecordDomainList, serialNumberList, startTime, endTime, tenantId); return checkRecordDomainList; } /** * 获取新电途对账数据 + * * @param dataFile 对账单文件,格式为xlsx * @return 对账数据 */ @Override - public List getXDTInternetDataList(File dataFile) throws Exception { + public List getXDTInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception { + String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1); List checkRecordDomainList = new ArrayList<>(); List xdtTradebillVoList = new ArrayList<>(); List serialNumberList = new ArrayList<>(); - switch (suffix.toUpperCase()){ + switch (suffix.toUpperCase()) { case "XLS": case "XLSX": ExcelUtil util = new ExcelUtil(XDTTradebillVo.class); @@ -305,10 +327,11 @@ public class InternetBillServiceImpl implements InternetBillService { FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK")); xdtTradebillVoList = reader.read(fileReader.readString(), XDTTradebillVo.class); break; - default: break; + default: + break; } - for(XDTTradebillVo vo: xdtTradebillVoList){ + for (XDTTradebillVo vo : xdtTradebillVoList) { XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain(); domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim()); domain.setInternetSerialNumber(vo.getOrderNo().trim()); @@ -316,55 +339,58 @@ public class InternetBillServiceImpl implements InternetBillService { domain.setInternetName("新电途"); domain.setInternetChargeStation(vo.getStationName()); - BigDecimal chargingDegree = vo.getChargingDegree()!=null? BigDecimal.valueOf(vo.getChargingDegree()): BigDecimal.ZERO; + BigDecimal chargingDegree = vo.getChargingDegree() != null ? BigDecimal.valueOf(vo.getChargingDegree()) : BigDecimal.ZERO; domain.setInternetChargingDegree(chargingDegree); - BigDecimal orderAmount = vo.getOrderAmount() !=null? BigDecimal.valueOf(vo.getOrderAmount()): BigDecimal.ZERO; + BigDecimal orderAmount = vo.getOrderAmount() != null ? BigDecimal.valueOf(vo.getOrderAmount()) : BigDecimal.ZERO; domain.setInternetOrderAmount(orderAmount); - BigDecimal powerAmount = vo.getPowerAmount()!=null? BigDecimal.valueOf(vo.getPowerAmount()): BigDecimal.ZERO; + BigDecimal powerAmount = vo.getPowerAmount() != null ? BigDecimal.valueOf(vo.getPowerAmount()) : BigDecimal.ZERO; domain.setInternetPowerAmount(powerAmount); - BigDecimal serverAmount = vo.getServerAmount()!= null? BigDecimal.valueOf(vo.getServerAmount()): BigDecimal.ZERO; + BigDecimal serverAmount = vo.getServerAmount() != null ? BigDecimal.valueOf(vo.getServerAmount()) : BigDecimal.ZERO; domain.setInternetServerAmount(serverAmount); domain.setInternetDiscountAmount(BigDecimal.ZERO); - BigDecimal payAmount = vo.getPayAmount()!=null ? BigDecimal.valueOf(vo.getPayAmount()): BigDecimal.ZERO; + BigDecimal payAmount = vo.getPayAmount() != null ? BigDecimal.valueOf(vo.getPayAmount()) : BigDecimal.ZERO; domain.setInternetPayAmount(payAmount); serialNumberList.add(domain.getInternetSerialNumber()); // getHistoryOrderInfo(domain); checkRecordDomainList.add(domain); } - getHistoryOrderList(checkRecordDomainList, serialNumberList); + getHistoryOrderList(checkRecordDomainList, serialNumberList, startTime, endTime, tenantId); return checkRecordDomainList; } /** * 获取快电对账数据 + * * @param dataFile 对账单文件,格式为xlsx * @return 对账数据 */ @Override - public List getKDInternetDataList(File dataFile) throws Exception { + public List getKDInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception { + String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1); List checkRecordDomainList = new ArrayList<>(); List kdTradebillVoList = new ArrayList<>(); List> dataList = new ArrayList<>(); List serialNumberList = new ArrayList<>(); - switch (suffix.toUpperCase()){ + switch (suffix.toUpperCase()) { case "XLS": case "XLSX": ExcelUtil util = new ExcelUtil(KDTradebillVo.class); kdTradebillVoList = util.importExcel(new FileInputStream(dataFile), 1); break; - default: break; + default: + break; } - for(KDTradebillVo vo: kdTradebillVoList){ + for (KDTradebillVo vo : kdTradebillVoList) { if (vo.getOrderNo().equals("交易订单号") || StrUtil.hasBlank(vo.getOrderNo())) { continue; } @@ -374,44 +400,46 @@ public class InternetBillServiceImpl implements InternetBillService { domain.setInternetSerialNumber(vo.getOrderNo()); domain.setPlatformInternetSerialNumber(vo.getOrderNo()); - Date startTime = StrUtil.hasBlank(vo.getStartTime()) ? null: DateUtil.parse(vo.getStartTime()); - domain.setInternetStartTime(startTime); + Date startTime1 = StrUtil.hasBlank(vo.getStartTime()) ? null : DateUtil.parse(vo.getStartTime()); + domain.setInternetStartTime(startTime1); - Date endTime = StrUtil.hasBlank(vo.getEndTime()) ? null: DateUtil.parse(vo.getEndTime()); - domain.setInternetEndTime(endTime); + Date endTime1 = StrUtil.hasBlank(vo.getEndTime()) ? null : DateUtil.parse(vo.getEndTime()); + domain.setInternetEndTime(endTime1); domain.setInternetChargeStation(vo.getStationName()); - BigDecimal chargingDegree = vo.getChargingDegree() == null ? BigDecimal.ZERO: BigDecimal.valueOf(vo.getChargingDegree()); + BigDecimal chargingDegree = vo.getChargingDegree() == null ? BigDecimal.ZERO : BigDecimal.valueOf(vo.getChargingDegree()); domain.setInternetChargingDegree(chargingDegree); - BigDecimal powerAmount= vo.getTotalPowerAmount() == null? BigDecimal.ZERO: BigDecimal.valueOf(vo.getTotalPowerAmount()); + BigDecimal powerAmount = vo.getTotalPowerAmount() == null ? BigDecimal.ZERO : BigDecimal.valueOf(vo.getTotalPowerAmount()); domain.setInternetPowerAmount(powerAmount); - BigDecimal serverAmount = vo.getServerAmount() == null ? BigDecimal.ZERO : BigDecimal.valueOf(vo.getServerAmount()); + BigDecimal serverAmount = vo.getServerAmount() == null ? BigDecimal.ZERO : BigDecimal.valueOf(vo.getServerAmount()); domain.setInternetServerAmount(serverAmount); domain.setInternetDiscountAmount(BigDecimal.ZERO); - String orderAmount = vo.getOrderAmount() == null? "0": vo.getOrderAmount().toString(); + String orderAmount = vo.getOrderAmount() == null ? "0" : vo.getOrderAmount().toString(); domain.setInternetOrderAmount(new BigDecimal(orderAmount)); domain.setInternetPayAmount(domain.getInternetOrderAmount()); serialNumberList.add(domain.getInternetSerialNumber()); checkRecordDomainList.add(domain); } - getHistoryOrderList(checkRecordDomainList, serialNumberList); + getHistoryOrderList(checkRecordDomainList, serialNumberList, startTime, endTime, tenantId); return checkRecordDomainList; } /** * 导出对账单 + * * @param response 返回体 - * @param params 查询参数 + * @param params 查询参数 * @throws Exception 异常 */ @Override - public void export(HttpServletResponse response, Map params) throws Exception{ + public void export(HttpServletResponse response, Map params) throws Exception { + List> list = internetCheckRecordMapper.selectByParams(params); // 通过工具类创建writer,默认创建xls格式 @@ -462,18 +490,18 @@ public class InternetBillServiceImpl implements InternetBillService { } + private void getHistoryOrderInfo(XhpcTradebillInternetCheckRecordDomain domain) { - private void getHistoryOrderInfo(XhpcTradebillInternetCheckRecordDomain domain){ XhpcHistoryOrderDomain orderDomain = historyOrderMapper.findOneByInternetSerialNumber(domain.getInternetSerialNumber()); - if(orderDomain != null){ + if (orderDomain != null) { domain.setHistoryOrderNo(orderDomain.getHistoryOrderId()); domain.setPlatformInternetSerialNumber(orderDomain.getInternetSerialNumber()); domain.setPlatformSerialNumber(orderDomain.getSerialNumber()); domain.setPlatformChargeStation(orderDomain.getChargingStationName()); domain.setPlatformStartSoc(orderDomain.getStartSoc()); domain.setPlatformEndSoc(orderDomain.getEndSoc()); - BigDecimal chargingDegree = orderDomain.getChargingDegree() != null? - BigDecimal.valueOf(orderDomain.getChargingDegree()): BigDecimal.ZERO; + BigDecimal chargingDegree = orderDomain.getChargingDegree() != null ? + BigDecimal.valueOf(orderDomain.getChargingDegree()) : BigDecimal.ZERO; domain.setPlatformChargingDegree(chargingDegree); domain.setPlatformChargingTime(orderDomain.getChargingTime()); domain.setPlatformStartTime(orderDomain.getStartTime()); @@ -488,24 +516,27 @@ public class InternetBillServiceImpl implements InternetBillService { } - private List getHistoryOrderList(List domainList, List serialNumberList){ - List orderDomainList = historyOrderMapper.findListByInternetSerialNumbers(serialNumberList); + private List getHistoryOrderList(List domainList, + List serialNumberList, + String startTime, String endTime, String tenantId) { + + List orderDomainList = historyOrderMapper.findListByTimeBetween(startTime, endTime, tenantId); Map orderDomainMap = new HashMap<>(); - for(XhpcHistoryOrderDomain orderDomain: orderDomainList){ + for (XhpcHistoryOrderDomain orderDomain : orderDomainList) { orderDomainMap.put(orderDomain.getInternetSerialNumber(), orderDomain); } - for(XhpcTradebillInternetCheckRecordDomain domain: domainList){ + for (XhpcTradebillInternetCheckRecordDomain domain : domainList) { XhpcHistoryOrderDomain orderDomain = orderDomainMap.get(domain.getInternetSerialNumber()); - if(orderDomain != null){ + if (orderDomain != null) { domain.setHistoryOrderNo(orderDomain.getHistoryOrderId()); domain.setPlatformInternetSerialNumber(orderDomain.getInternetSerialNumber()); domain.setPlatformSerialNumber(orderDomain.getSerialNumber()); domain.setPlatformChargeStation(orderDomain.getChargingStationName()); domain.setPlatformStartSoc(orderDomain.getStartSoc()); domain.setPlatformEndSoc(orderDomain.getEndSoc()); - BigDecimal chargingDegree = orderDomain.getChargingDegree() != null? - BigDecimal.valueOf(orderDomain.getChargingDegree()): BigDecimal.ZERO; + BigDecimal chargingDegree = orderDomain.getChargingDegree() != null ? + BigDecimal.valueOf(orderDomain.getChargingDegree()) : BigDecimal.ZERO; domain.setPlatformChargingDegree(chargingDegree); domain.setPlatformChargingTime(orderDomain.getChargingTime()); domain.setPlatformStartTime(orderDomain.getStartTime()); @@ -516,25 +547,51 @@ public class InternetBillServiceImpl implements InternetBillService { domain.setPlatformDiscountAmount(orderDomain.getPromotionDiscount()); domain.setPlatformPayAmount(orderDomain.getActPrice()); } + orderDomainMap.remove(domain.getInternetSerialNumber()); checkoutOrderResult(domain); } + + if (orderDomainMap.size() > 0){ + for(XhpcHistoryOrderDomain orderDomain: orderDomainMap.values()){ + XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain(); + domain.setHistoryOrderNo(orderDomain.getHistoryOrderId()); + domain.setPlatformInternetSerialNumber(orderDomain.getInternetSerialNumber()); + domain.setPlatformSerialNumber(orderDomain.getSerialNumber()); + domain.setPlatformChargeStation(orderDomain.getChargingStationName()); + domain.setPlatformStartSoc(orderDomain.getStartSoc()); + domain.setPlatformEndSoc(orderDomain.getEndSoc()); + BigDecimal chargingDegree = orderDomain.getChargingDegree() != null ? + BigDecimal.valueOf(orderDomain.getChargingDegree()) : BigDecimal.ZERO; + domain.setPlatformChargingDegree(chargingDegree); + domain.setPlatformChargingTime(orderDomain.getChargingTime()); + domain.setPlatformStartTime(orderDomain.getStartTime()); + domain.setPlatformEndTime(orderDomain.getEndTime()); + domain.setPlatformOrderAmount(orderDomain.getTotalPrice()); + domain.setPlatformPowerAmount(orderDomain.getPowerPriceTotal()); + domain.setPlatformServerAmount(orderDomain.getServicePriceTotal()); + domain.setPlatformDiscountAmount(orderDomain.getPromotionDiscount()); + domain.setPlatformPayAmount(orderDomain.getActPrice()); + checkoutOrderResult(domain); + domainList.add(domain); + } + } domainList.sort(Comparator.comparing(XhpcTradebillInternetCheckRecordDomain::getStatus)); - return domainList; + return domainList; } - private void checkoutOrderResult(XhpcTradebillInternetCheckRecordDomain domain){ + private void checkoutOrderResult(XhpcTradebillInternetCheckRecordDomain domain) { + int checkoutStatus = 0; // 流量方的订单金额大于本平台的历史订单的订单金额,就可以判断成功 - if(domain.getPlatformOrderAmount() != null && domain.getPlatformOrderAmount().compareTo(domain.getInternetOrderAmount()) == 0 - && domain.getPlatformPowerAmount() != null && domain.getPlatformPowerAmount().compareTo(domain.getInternetPowerAmount()) == 0 - && domain.getPlatformServerAmount() != null && domain.getPlatformServerAmount().compareTo(domain.getInternetServerAmount()) == 0 - && domain.getPlatformChargingDegree() != null && domain.getPlatformChargingDegree().compareTo(domain.getInternetChargingDegree()) == 0){ + if (domain.getPlatformOrderAmount() != null && domain.getPlatformOrderAmount().compareTo(domain.getInternetOrderAmount()) == 0 + && domain.getPlatformPowerAmount() != null && domain.getPlatformPowerAmount().compareTo(domain.getInternetPowerAmount()) == 0 + && domain.getPlatformServerAmount() != null && domain.getPlatformServerAmount().compareTo(domain.getInternetServerAmount()) == 0 + && domain.getPlatformChargingDegree() != null && domain.getPlatformChargingDegree().compareTo(domain.getInternetChargingDegree()) == 0) { checkoutStatus = 2; } domain.setStatus(checkoutStatus); } - } diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/PaymentBillServiceImpl.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/PaymentBillServiceImpl.java index dd8042ff..570ff9a9 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/PaymentBillServiceImpl.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/impl/PaymentBillServiceImpl.java @@ -23,6 +23,7 @@ import com.xhpc.tradebill.config.AliPayProperties; import com.xhpc.tradebill.constant.WeixinPayConstant; import com.xhpc.tradebill.domain.XhpcRechargeOrderDomain; import com.xhpc.tradebill.domain.XhpcRefundOrderDomain; +import com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain; import com.xhpc.tradebill.domain.XhpcTradebillPaymentCheckRecordDomain; import com.xhpc.tradebill.mapper.XhpcRechargeOrderMapper; import com.xhpc.tradebill.mapper.XhpcRefundOrderMapper; @@ -136,10 +137,10 @@ public class PaymentBillServiceImpl implements PaymentBillService { * @param fileUrl 数据文件存放地址 * @return 对账完成的数据列表 */ - public List getAliPayDataList(String fileUrl) throws Exception { + public List getAliPayDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception { File dataFile = DownloadUtil.downloadFile(fileUrl); - return getAliPayDataList(dataFile); + return getAliPayDataList(dataFile, startTime, endTime, tenantId); } @@ -149,7 +150,7 @@ public class PaymentBillServiceImpl implements PaymentBillService { * @param dataFile 数据文件 * @return 对账完成的数据列表 */ - public List getAliPayDataList(File dataFile) throws + public List getAliPayDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception { Long userId = SecurityUtils.getUserId(); @@ -210,7 +211,7 @@ public class PaymentBillServiceImpl implements PaymentBillService { } paymentCheckRecordDomainList.add(domain); } - getPlatOrderData(paymentCheckRecordDomainList, orderType, serialNumberList); + getPlatOrderData(paymentCheckRecordDomainList, orderType, serialNumberList, startTime, endTime, tenantId); break; case "ZIP": @@ -233,7 +234,7 @@ public class PaymentBillServiceImpl implements PaymentBillService { outputStream.close(); } if (file != null) { - paymentCheckRecordDomainList = getAliPayDataList(file); + paymentCheckRecordDomainList = getAliPayDataList(file, startTime, endTime, tenantId); } break; @@ -251,10 +252,10 @@ public class PaymentBillServiceImpl implements PaymentBillService { * @param fileUrl 数据文件存放地址 * @return 对账完成的数据列表 */ - public List getWechatDataList(String fileUrl) throws Exception { + public List getWechatDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception { File dataFile = DownloadUtil.downloadFile(fileUrl); - return getWechatDataList(dataFile); + return getWechatDataList(dataFile, startTime, endTime, tenantId); } @@ -264,7 +265,7 @@ public class PaymentBillServiceImpl implements PaymentBillService { * @param dataFile 数据文件 * @return 对账完成的数据列表 */ - public List getWechatDataList(File dataFile) throws Exception { + public List getWechatDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception { Long userId = SecurityUtils.getUserId(); List paymentCheckRecordDomainList = new ArrayList<>(); @@ -327,7 +328,7 @@ public class PaymentBillServiceImpl implements PaymentBillService { paymentCheckRecordDomainList.add(computeTradebillData(domain)); } - getPlatOrderData(paymentCheckRecordDomainList, orderType, serialNumberList); + getPlatOrderData(paymentCheckRecordDomainList, orderType, serialNumberList, startTime, endTime, tenantId); } else { throw new Exception("暂不支持的文件格式"); @@ -449,13 +450,18 @@ public class PaymentBillServiceImpl implements PaymentBillService { - private List getPlatOrderData(List domainList, int orderType, List serialNumberList){ + private List getPlatOrderData(List domainList, + int orderType, + List serialNumberList, + String startTime, + String endTime, + String tenantId){ List> orderMapList = null; if (orderType == 1) { - orderMapList = rechargeOrderMapper.findListByOrderNumbers(serialNumberList); + orderMapList = rechargeOrderMapper.findListByTimeBetween(startTime, endTime, tenantId); } else if (orderType == 2) { - orderMapList = refundOrderMapper.findListByOrderNumbers(serialNumberList); + orderMapList = refundOrderMapper.findListByTimeBetween(startTime, endTime, tenantId); } Map> orderList = new HashMap<>(); @@ -472,9 +478,23 @@ public class PaymentBillServiceImpl implements PaymentBillService { domain.setPlatformAmount(new BigDecimal(orderMap.get("amount").toString())); domain.setPlatformPayTime(DateUtil.parse(orderMap.get("updateTime").toString(), "yyyy-MM-dd'T'HH:mm")); } + orderList.remove(domain.getPaymentPayNumber()); computeTradebillData(domain); } + if(orderList.size() > 0){ + for(Map orderMap: orderList.values()){ + XhpcTradebillPaymentCheckRecordDomain domain = new XhpcTradebillPaymentCheckRecordDomain(); + domain.setPlatformOrderNumber(orderMap.get("orderNumber").toString().trim()); + domain.setPlatformUserId(orderMap.get("userId").toString()); + domain.setPlatformPayNumber(orderMap.get("id").toString()); + domain.setPlatformAmount(new BigDecimal(orderMap.get("amount").toString())); + domain.setPlatformPayTime(DateUtil.parse(orderMap.get("updateTime").toString(), "yyyy-MM-dd'T'HH:mm")); + computeTradebillData(domain); + domainList.add(domain); + } + } + domainList.sort(Comparator.comparing(XhpcTradebillPaymentCheckRecordDomain::getStatus)); return domainList; } diff --git a/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index ea1f6644..42a4693c 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -38,4 +38,17 @@ #{orderNumber} + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcRechargeOrderMapper.xml b/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcRechargeOrderMapper.xml index 4f400562..dc692cea 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcRechargeOrderMapper.xml +++ b/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcRechargeOrderMapper.xml @@ -43,4 +43,18 @@ #{orderNumber} + + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcRefundOrderMapper.xml b/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcRefundOrderMapper.xml index bfcd70e2..aab2fc8b 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcRefundOrderMapper.xml +++ b/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcRefundOrderMapper.xml @@ -39,4 +39,17 @@ #{orderNumber} + + + \ No newline at end of file