对账增加时间段设置

This commit is contained in:
panshuling321 2022-02-15 11:25:29 +08:00
parent aa391e89bc
commit 62bc906011
14 changed files with 301 additions and 143 deletions

View File

@ -6,12 +6,16 @@ import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.log.annotation.Log; import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType; 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.domain.XhpcTradebillUploadRecordDomain;
import com.xhpc.tradebill.service.CommonService; import com.xhpc.tradebill.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -23,19 +27,24 @@ public class CommonController extends BaseController {
@Resource @Resource
CommonService commonService; CommonService commonService;
@Resource
LogUserUtils logUserUtils;
@Log(title = "上传对账单(OSS方式)", businessType = BusinessType.INSERT) @Log(title = "上传对账单(OSS方式)", businessType = BusinessType.INSERT)
@PostMapping("/oss/upload") @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)); return AjaxResult.success(commonService.ossUpload(domain));
} }
@Log(title = "上传对账单(文件方式)", businessType = BusinessType.INSERT) @Log(title = "上传对账单(文件方式)", businessType = BusinessType.INSERT)
@PostMapping("/file/upload") @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){ if (file ==null || type < 1){
return AjaxResult.error("文件或者对账类型为空"); return AjaxResult.error("文件或者对账类型为空");
} }
return AjaxResult.success(commonService.fileUpload(file, type)); return AjaxResult.success(commonService.fileUpload(file, type, startTime, endTime));
} }
@GetMapping("/file/getPage") @GetMapping("/file/getPage")

View File

@ -44,5 +44,10 @@ public class XhpcTradebillUploadRecordDomain implements Serializable {
private String tenantId; private String tenantId;
// === 时间区段内的订单仅参数使用
private String startTime;
private String endTime;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -16,4 +16,9 @@ public interface XhpcHistoryOrderMapper {
XhpcHistoryOrderDomain findOneByInternetSerialNumber(String internetSerialNumber); XhpcHistoryOrderDomain findOneByInternetSerialNumber(String internetSerialNumber);
List<XhpcHistoryOrderDomain> findListByInternetSerialNumbers(@Param("orderNumbers") List<String> internetSerialNumbers); List<XhpcHistoryOrderDomain> findListByInternetSerialNumbers(@Param("orderNumbers") List<String> internetSerialNumbers);
List<XhpcHistoryOrderDomain> findListByTimeBetween(@Param("startTime") String startTime,
@Param("endTime")String endTime,
@Param("tenantId")String tenantId);
} }

View File

@ -14,4 +14,10 @@ public interface XhpcRechargeOrderMapper {
List<Map<String, Object>> findListByOrderNumbers(@Param("orderNumbers") List<String> orderNumbers); List<Map<String, Object>> findListByOrderNumbers(@Param("orderNumbers") List<String> orderNumbers);
List<Map<String, Object>> findListByTimeBetween(@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("tenantId") String tenantId);
} }

View File

@ -12,6 +12,12 @@ public interface XhpcRefundOrderMapper {
XhpcRefundOrderDomain findByOrderNumber(String orderNumber); XhpcRefundOrderDomain findByOrderNumber(String orderNumber);
List<Map<String, Object>> findListByOrderNumbers(@Param("orderNumbers") List<String> orderNumbers); List<Map<String, Object>> findListByOrderNumbers(@Param("orderNumbers") List<String> orderNumbers);
List<Map<String, Object>> findListByTimeBetween(@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("tenantId") String tenantId);
} }

View File

@ -11,7 +11,7 @@ public interface CommonService {
XhpcTradebillUploadRecordDomain ossUpload(XhpcTradebillUploadRecordDomain domain) throws Exception; 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<XhpcTradebillUploadRecordDomain> getFilePage(Map<String, Object> params); List<XhpcTradebillUploadRecordDomain> getFilePage(Map<String, Object> params);
} }

View File

@ -35,7 +35,7 @@ public interface InternetBillService {
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
List<XhpcTradebillInternetCheckRecordDomain> getHdInternetDataList(String fileUrl) throws Exception; List<XhpcTradebillInternetCheckRecordDomain> getHdInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception;
/** /**
@ -44,7 +44,7 @@ public interface InternetBillService {
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
List<XhpcTradebillInternetCheckRecordDomain> getHdInternetDataList(File dataFile) throws Exception; List<XhpcTradebillInternetCheckRecordDomain> getHdInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception;
/** /**
@ -53,7 +53,7 @@ public interface InternetBillService {
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
List<XhpcTradebillInternetCheckRecordDomain> getXjInternetDataList(String fileUrl) throws Exception; List<XhpcTradebillInternetCheckRecordDomain> getXjInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception;
@ -63,7 +63,7 @@ public interface InternetBillService {
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
List<XhpcTradebillInternetCheckRecordDomain> getXjInternetDataList(File dataFile) throws Exception; List<XhpcTradebillInternetCheckRecordDomain> getXjInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception;
/** /**
@ -72,7 +72,7 @@ public interface InternetBillService {
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
List<XhpcTradebillInternetCheckRecordDomain> getXDTInternetDataList(String fileUrl) throws Exception; List<XhpcTradebillInternetCheckRecordDomain> getXDTInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception;
/** /**
@ -81,7 +81,7 @@ public interface InternetBillService {
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
List<XhpcTradebillInternetCheckRecordDomain> getXDTInternetDataList(File dataFile) throws Exception; List<XhpcTradebillInternetCheckRecordDomain> getXDTInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception;
@ -91,7 +91,7 @@ public interface InternetBillService {
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
List<XhpcTradebillInternetCheckRecordDomain> getKDInternetDataList(String fileUrl) throws Exception; List<XhpcTradebillInternetCheckRecordDomain> getKDInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception;
/** /**
@ -100,7 +100,7 @@ public interface InternetBillService {
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
List<XhpcTradebillInternetCheckRecordDomain> getKDInternetDataList(File dataFile) throws Exception; List<XhpcTradebillInternetCheckRecordDomain> getKDInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception;
/** /**

View File

@ -37,7 +37,7 @@ public interface PaymentBillService {
* @param fileUrl 数据文件存放地址 * @param fileUrl 数据文件存放地址
* @return 对账完成的数据列表 * @return 对账完成的数据列表
*/ */
List<XhpcTradebillPaymentCheckRecordDomain> getAliPayDataList(String fileUrl) throws Exception ; List<XhpcTradebillPaymentCheckRecordDomain> getAliPayDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception ;
/** /**
@ -46,7 +46,7 @@ public interface PaymentBillService {
* @param dataFile 数据文件 * @param dataFile 数据文件
* @return 对账完成的数据列表 * @return 对账完成的数据列表
*/ */
List<XhpcTradebillPaymentCheckRecordDomain> getAliPayDataList(File dataFile) throws Exception ; List<XhpcTradebillPaymentCheckRecordDomain> getAliPayDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception ;
/** /**
@ -55,7 +55,7 @@ public interface PaymentBillService {
* @param fileUrl 数据文件存放地址 * @param fileUrl 数据文件存放地址
* @return 对账完成的数据列表 * @return 对账完成的数据列表
*/ */
List<XhpcTradebillPaymentCheckRecordDomain> getWechatDataList(String fileUrl) throws Exception ; List<XhpcTradebillPaymentCheckRecordDomain> getWechatDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception ;
/** /**
@ -64,7 +64,7 @@ public interface PaymentBillService {
* @param dataFile 数据文件 * @param dataFile 数据文件
* @return 对账完成的数据列表 * @return 对账完成的数据列表
*/ */
List<XhpcTradebillPaymentCheckRecordDomain> getWechatDataList(File dataFile) throws Exception ; List<XhpcTradebillPaymentCheckRecordDomain> getWechatDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception ;
/** /**

View File

@ -38,7 +38,8 @@ public class CommonServiceImpl implements CommonService {
AliOSSProperties ossProperties; AliOSSProperties ossProperties;
@Override @Override
public XhpcTradebillUploadRecordDomain ossUpload(XhpcTradebillUploadRecordDomain domain) throws Exception{ public XhpcTradebillUploadRecordDomain ossUpload(XhpcTradebillUploadRecordDomain domain) throws Exception {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
domain.setCreateBy(userId); domain.setCreateBy(userId);
domain.setUpdateBy(userId); domain.setUpdateBy(userId);
@ -58,42 +59,42 @@ public class CommonServiceImpl implements CommonService {
Map<String, Integer> totalMap = new HashMap<>(); Map<String, Integer> totalMap = new HashMap<>();
int insertCount = 0; int insertCount = 0;
resDomain.setStatus(2); resDomain.setStatus(2);
switch (domain.getType()){ switch (domain.getType()) {
case 1: case 1:
case 2: case 2:
// 微信支付 // 微信支付
paymentCheckRecordDomainList = paymentBillService.getWechatDataList(domain.getUrl()); paymentCheckRecordDomainList = paymentBillService.getWechatDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId());
insertCount = paymentBillService.insertPaymentCheckList(resDomain.getId(), paymentCheckRecordDomainList); insertCount = paymentBillService.insertPaymentCheckList(resDomain.getId(), paymentCheckRecordDomainList);
totalMap = computePaymentRecord(paymentCheckRecordDomainList); totalMap = computePaymentRecord(paymentCheckRecordDomainList);
break; break;
case 3: case 3:
case 4: case 4:
// 支付宝支付 // 支付宝支付
paymentCheckRecordDomainList = paymentBillService.getAliPayDataList(domain.getUrl()); paymentCheckRecordDomainList = paymentBillService.getAliPayDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId());
insertCount = paymentBillService.insertPaymentCheckList(resDomain.getId(), paymentCheckRecordDomainList); insertCount = paymentBillService.insertPaymentCheckList(resDomain.getId(), paymentCheckRecordDomainList);
totalMap = computePaymentRecord(paymentCheckRecordDomainList); totalMap = computePaymentRecord(paymentCheckRecordDomainList);
break; break;
case 5: case 5:
// 恒大 // 恒大
recordDomainList = internetBillService.getHdInternetDataList(domain.getUrl()); recordDomainList = internetBillService.getHdInternetDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId());
insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList); insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList);
totalMap = computeInternetRecord(recordDomainList); totalMap = computeInternetRecord(recordDomainList);
break; break;
case 6: case 6:
// 小桔 // 小桔
recordDomainList = internetBillService.getXjInternetDataList(domain.getUrl()); recordDomainList = internetBillService.getXjInternetDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId());
insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList); insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList);
totalMap = computeInternetRecord(recordDomainList); totalMap = computeInternetRecord(recordDomainList);
break; break;
case 7: case 7:
// 新电途 // 新电途
recordDomainList = internetBillService.getXDTInternetDataList(domain.getUrl()); recordDomainList = internetBillService.getXDTInternetDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId());
insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList); insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList);
totalMap = computeInternetRecord(recordDomainList); totalMap = computeInternetRecord(recordDomainList);
break; break;
case 8: case 8:
// 快电 // 快电
recordDomainList = internetBillService.getKDInternetDataList(domain.getUrl()); recordDomainList = internetBillService.getKDInternetDataList(domain.getUrl(), domain.getStartTime(), domain.getEndTime(), domain.getTenantId());
insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList); insertCount = internetBillService.insertInternetCheckList(resDomain.getId(), recordDomainList);
totalMap = computeInternetRecord(recordDomainList); totalMap = computeInternetRecord(recordDomainList);
break; break;
@ -115,17 +116,17 @@ public class CommonServiceImpl implements CommonService {
} }
@Override @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(); XhpcTradebillUploadRecordDomain domain = new XhpcTradebillUploadRecordDomain();
// 创建OSSClient实例 // 创建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 dataFile = File.createTempFile("temp_", suffix);
file.transferTo(dataFile); 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 ossClient = new OSSClient(ossProperties.getEndpoint(), ossProperties.getAccessKey(), ossProperties.getSecretKey());
// 上传文件流 // 上传文件流
ossClient.putObject(ossProperties.getBucketName(), ossPath, dataFile); ossClient.putObject(ossProperties.getBucketName(), ossPath, dataFile);
@ -133,29 +134,34 @@ public class CommonServiceImpl implements CommonService {
domain.setFileName(file.getOriginalFilename()); domain.setFileName(file.getOriginalFilename());
domain.setUrl(ossProperties.getDomain() + ossPath); domain.setUrl(ossProperties.getDomain() + ossPath);
domain.setStartTime(startTime);
domain.setEndTime(endTime);
domain.setType(type); domain.setType(type);
return ossUpload(domain); return ossUpload(domain);
} }
@Override @Override
public List<XhpcTradebillUploadRecordDomain> getFilePage(Map<String, Object> params){ public List<XhpcTradebillUploadRecordDomain> getFilePage(Map<String, Object> params) {
return uploadRecordMapper.selectByType(params); return uploadRecordMapper.selectByType(params);
} }
private Map<String, Integer> computePaymentRecord(List<XhpcTradebillPaymentCheckRecordDomain> domainList){ private Map<String, Integer> computePaymentRecord(List<XhpcTradebillPaymentCheckRecordDomain> domainList) {
Integer successCount = 0; Integer successCount = 0;
Integer failCount = 0; Integer failCount = 0;
Integer checkCount = 0; Integer checkCount = 0;
Integer uncheckCount = 0; Integer uncheckCount = 0;
Map<String, Integer> result = new HashMap<>(); Map<String, Integer> result = new HashMap<>();
for (XhpcTradebillPaymentCheckRecordDomain domain: domainList){ for (XhpcTradebillPaymentCheckRecordDomain domain : domainList) {
if(domain.getStatus() == 2){ if (domain.getStatus() == 2) {
successCount++; checkCount++; successCount++;
} else if(domain.getStatus() == 1 || domain.getStatus() == 0){ checkCount++;
failCount++; checkCount++; } else if (domain.getStatus() == 1 || domain.getStatus() == 0) {
failCount++;
checkCount++;
} else { } else {
uncheckCount++; uncheckCount++;
} }
@ -168,17 +174,20 @@ public class CommonServiceImpl implements CommonService {
} }
private Map<String, Integer> computeInternetRecord(List<XhpcTradebillInternetCheckRecordDomain> domainList){ private Map<String, Integer> computeInternetRecord(List<XhpcTradebillInternetCheckRecordDomain> domainList) {
Integer successCount = 0; Integer successCount = 0;
Integer failCount = 0; Integer failCount = 0;
Integer checkCount = 0; Integer checkCount = 0;
Integer uncheckCount = 0; Integer uncheckCount = 0;
Map<String, Integer> result = new HashMap<>(); Map<String, Integer> result = new HashMap<>();
for (XhpcTradebillInternetCheckRecordDomain domain: domainList){ for (XhpcTradebillInternetCheckRecordDomain domain : domainList) {
if(domain.getStatus() == 2){ if (domain.getStatus() == 2) {
successCount++; checkCount++; successCount++;
} else if(domain.getStatus() == 1 || domain.getStatus() == 0){ checkCount++;
failCount++; checkCount++; } else if (domain.getStatus() == 1 || domain.getStatus() == 0) {
failCount++;
checkCount++;
} else { } else {
uncheckCount++; uncheckCount++;
} }
@ -189,4 +198,5 @@ public class CommonServiceImpl implements CommonService {
result.put("uncheckCount", uncheckCount); result.put("uncheckCount", uncheckCount);
return result; return result;
} }
} }

View File

@ -6,7 +6,6 @@ import cn.hutool.core.io.file.FileReader;
import cn.hutool.core.text.csv.CsvReader; import cn.hutool.core.text.csv.CsvReader;
import cn.hutool.core.text.csv.CsvUtil; import cn.hutool.core.text.csv.CsvUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelWriter; import cn.hutool.poi.excel.ExcelWriter;
import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.utils.poi.ExcelUtil; import com.xhpc.common.core.utils.poi.ExcelUtil;
@ -48,23 +47,25 @@ public class InternetBillServiceImpl implements InternetBillService {
EtOrderMappingMapper orderMappingMapper; EtOrderMappingMapper orderMappingMapper;
@Override @Override
public XhpcTradebillInternetCheckRecordDomain getInfoByPk(int pk){ public XhpcTradebillInternetCheckRecordDomain getInfoByPk(int pk) {
return internetCheckRecordMapper.selectByPrimaryKey(pk); return internetCheckRecordMapper.selectByPrimaryKey(pk);
} }
@Override @Override
public boolean updateInfoByDomain(XhpcTradebillInternetCheckRecordDomain domain){ public boolean updateInfoByDomain(XhpcTradebillInternetCheckRecordDomain domain) {
domain.setUpdateBy(SecurityUtils.getUserId()); domain.setUpdateBy(SecurityUtils.getUserId());
return internetCheckRecordMapper.updateStatusByPk(domain); return internetCheckRecordMapper.updateStatusByPk(domain);
} }
@Override @Override
public Integer insertInternetCheckList(int uploadId, List<XhpcTradebillInternetCheckRecordDomain> internetCheckRecordDomainList){ public Integer insertInternetCheckList(int uploadId, List<XhpcTradebillInternetCheckRecordDomain> internetCheckRecordDomainList) {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
for(XhpcTradebillInternetCheckRecordDomain domain: internetCheckRecordDomainList){ for (XhpcTradebillInternetCheckRecordDomain domain : internetCheckRecordDomainList) {
domain.setUploadId(uploadId); domain.setUploadId(uploadId);
domain.setCreateBy(userId); domain.setCreateBy(userId);
domain.setUpdateBy(userId); domain.setUpdateBy(userId);
@ -74,26 +75,32 @@ public class InternetBillServiceImpl implements InternetBillService {
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getInternetCheckList(Map<String, Object> params){ public List<XhpcTradebillInternetCheckRecordDomain> getInternetCheckList(Map<String, Object> params) {
return internetCheckRecordMapper.selectListByParams(params); return internetCheckRecordMapper.selectListByParams(params);
} }
@Override @Override
public Map<String, Object> getStatusTotal(Map<String, Object> params){ public Map<String, Object> getStatusTotal(Map<String, Object> params) {
List<Map<String, Object>> resultList = internetCheckRecordMapper.selectTotalGroupbyStatus(params); List<Map<String, Object>> resultList = internetCheckRecordMapper.selectTotalGroupbyStatus(params);
int successCount = 0; int successCount = 0;
int failCount = 0; int failCount = 0;
int uncheckCount = 0; int uncheckCount = 0;
int checkCount = 0; int checkCount = 0;
for(Map<String, Object> res : resultList){ for (Map<String, Object> res : resultList) {
switch (res.get("status").toString()){ switch (res.get("status").toString()) {
case "0": case "0":
uncheckCount = Integer.parseInt(res.get("total").toString()); break; uncheckCount = Integer.parseInt(res.get("total").toString());
break;
case "1": case "1":
failCount = Integer.parseInt(res.get("total").toString()); break; failCount = Integer.parseInt(res.get("total").toString());
break;
case "2": case "2":
successCount = Integer.parseInt(res.get("total").toString()); break; successCount = Integer.parseInt(res.get("total").toString());
default: break; break;
default:
break;
} }
} }
checkCount = successCount + failCount; checkCount = successCount + failCount;
@ -108,68 +115,78 @@ public class InternetBillServiceImpl implements InternetBillService {
/** /**
* 获取恒大对账数据 * 获取恒大对账数据
*
* @param fileUrl 文件访问地址 * @param fileUrl 文件访问地址
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getHdInternetDataList(String fileUrl) throws Exception { public List<XhpcTradebillInternetCheckRecordDomain> getHdInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception {
File dataFile = DownloadUtil.downloadFile(fileUrl); File dataFile = DownloadUtil.downloadFile(fileUrl);
return getHdInternetDataList(dataFile); return getHdInternetDataList(dataFile, startTime, endTime, tenantId);
} }
/** /**
* 获取小桔对账数据 * 获取小桔对账数据
*
* @param fileUrl 文件访问地址 * @param fileUrl 文件访问地址
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getXjInternetDataList(String fileUrl) throws Exception { public List<XhpcTradebillInternetCheckRecordDomain> getXjInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception {
File dataFile = DownloadUtil.downloadFile(fileUrl); File dataFile = DownloadUtil.downloadFile(fileUrl);
return getXjInternetDataList(dataFile); return getXjInternetDataList(dataFile, startTime, endTime, tenantId);
} }
/** /**
* 获取新电途对账数据 * 获取新电途对账数据
*
* @param fileUrl 文件访问地址 * @param fileUrl 文件访问地址
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getXDTInternetDataList(String fileUrl) throws Exception { public List<XhpcTradebillInternetCheckRecordDomain> getXDTInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception {
File dataFile = DownloadUtil.downloadFile(fileUrl); File dataFile = DownloadUtil.downloadFile(fileUrl);
return getXDTInternetDataList(dataFile); return getXDTInternetDataList(dataFile, startTime, endTime, tenantId);
} }
/** /**
* 获取快电对账数据 * 获取快电对账数据
*
* @param fileUrl 文件访问地址 * @param fileUrl 文件访问地址
* @return 对账数据 * @return 对账数据
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getKDInternetDataList(String fileUrl) throws Exception { public List<XhpcTradebillInternetCheckRecordDomain> getKDInternetDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception {
File dataFile = DownloadUtil.downloadFile(fileUrl); File dataFile = DownloadUtil.downloadFile(fileUrl);
return getKDInternetDataList(dataFile); return getKDInternetDataList(dataFile, startTime, endTime, tenantId);
} }
/** /**
* 获取恒大对账数据 * 获取恒大对账数据
*
* @param dataFile 对账单文件,格式为xlsx * @param dataFile 对账单文件,格式为xlsx
* @return 对账数据 * @return 对账数据
*/ */
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getHdInternetDataList(File dataFile) throws Exception { public List<XhpcTradebillInternetCheckRecordDomain> getHdInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception {
List<XhpcTradebillInternetCheckRecordDomain> checkRecordDomainList = new ArrayList<>(); List<XhpcTradebillInternetCheckRecordDomain> checkRecordDomainList = new ArrayList<>();
String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1); String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1);
List<HDTradebillVo> hdTradebillVoList = new ArrayList<>(); List<HDTradebillVo> hdTradebillVoList = new ArrayList<>();
List<String> serialNumberList = new ArrayList<>(); List<String> serialNumberList = new ArrayList<>();
switch (suffix.toUpperCase()){ switch (suffix.toUpperCase()) {
case "XLS": case "XLS":
case "XLSX": case "XLSX":
ExcelUtil<HDTradebillVo> util = new ExcelUtil<HDTradebillVo>(HDTradebillVo.class); ExcelUtil<HDTradebillVo> util = new ExcelUtil<HDTradebillVo>(HDTradebillVo.class);
@ -180,30 +197,31 @@ public class InternetBillServiceImpl implements InternetBillService {
FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK")); FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK"));
hdTradebillVoList = reader.read(fileReader.readString(), HDTradebillVo.class); hdTradebillVoList = reader.read(fileReader.readString(), HDTradebillVo.class);
break; break;
default:break; default:
break;
} }
for(HDTradebillVo vo: hdTradebillVoList){ for (HDTradebillVo vo : hdTradebillVoList) {
XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain(); XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain();
domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim()); domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim());
domain.setInternetSerialNumber(vo.getOrderNo().trim()); domain.setInternetSerialNumber(vo.getOrderNo().trim());
domain.setSource("恒大"); domain.setSource("恒大");
domain.setInternetName("恒大"); domain.setInternetName("恒大");
domain.setInternetChargeStation(vo.getStationName()); 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); 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); 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); 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.setInternetServerAmount(serverAmount);
domain.setInternetDiscountAmount(BigDecimal.ZERO); 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); domain.setInternetPayAmount(payAmount);
serialNumberList.add(domain.getInternetSerialNumber()); serialNumberList.add(domain.getInternetSerialNumber());
@ -211,7 +229,7 @@ public class InternetBillServiceImpl implements InternetBillService {
// getHistoryOrderInfo(domain); // getHistoryOrderInfo(domain);
checkRecordDomainList.add(domain); checkRecordDomainList.add(domain);
} }
getHistoryOrderList(checkRecordDomainList, serialNumberList); getHistoryOrderList(checkRecordDomainList, serialNumberList, startTime, endTime, tenantId);
return checkRecordDomainList; return checkRecordDomainList;
} }
@ -219,18 +237,19 @@ public class InternetBillServiceImpl implements InternetBillService {
/** /**
* 获取小桔对账数据 * 获取小桔对账数据
*
* @param dataFile 对账单文件,格式为xlsx * @param dataFile 对账单文件,格式为xlsx
* @return 对账数据 * @return 对账数据
*/ */
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getXjInternetDataList(File dataFile) throws Exception { public List<XhpcTradebillInternetCheckRecordDomain> getXjInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception {
String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1); String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1);
List<XhpcTradebillInternetCheckRecordDomain> checkRecordDomainList = new ArrayList<>(); List<XhpcTradebillInternetCheckRecordDomain> checkRecordDomainList = new ArrayList<>();
List<XJTradeBillVo> xjTradeBillVoList = new ArrayList<>(); List<XJTradeBillVo> xjTradeBillVoList = new ArrayList<>();
List<String> serialNumberList = new ArrayList<>(); List<String> serialNumberList = new ArrayList<>();
switch (suffix.toUpperCase()){ switch (suffix.toUpperCase()) {
case "XLS": case "XLS":
case "XLSX": case "XLSX":
ExcelUtil<XJTradeBillVo> util = new ExcelUtil<XJTradeBillVo>(XJTradeBillVo.class); ExcelUtil<XJTradeBillVo> util = new ExcelUtil<XJTradeBillVo>(XJTradeBillVo.class);
@ -241,10 +260,11 @@ public class InternetBillServiceImpl implements InternetBillService {
FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK")); FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK"));
xjTradeBillVoList = reader.read(fileReader.readString(), XJTradeBillVo.class); xjTradeBillVoList = reader.read(fileReader.readString(), XJTradeBillVo.class);
break; break;
default: break; default:
break;
} }
for(XJTradeBillVo vo: xjTradeBillVoList){ for (XJTradeBillVo vo : xjTradeBillVoList) {
XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain(); XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain();
domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim()); domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim());
domain.setInternetSerialNumber(vo.getOrderNo().trim()); domain.setInternetSerialNumber(vo.getOrderNo().trim());
@ -253,23 +273,23 @@ public class InternetBillServiceImpl implements InternetBillService {
domain.setInternetChargeStation(vo.getStationName()); domain.setInternetChargeStation(vo.getStationName());
domain.setInternetStartSoc(vo.getStartSoc()); domain.setInternetStartSoc(vo.getStartSoc());
domain.setInternetEndSoc(vo.getEndSoc()); 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.setInternetChargingDegree(chargingDegree);
domain.setInternetChargingTime(vo.getChargingTime().toString()); domain.setInternetChargingTime(vo.getChargingTime().toString());
domain.setInternetStartTime(vo.getChargingStartTime()); domain.setInternetStartTime(vo.getChargingStartTime());
domain.setInternetEndTime(vo.getChargingEndTime()); 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); 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); 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.setInternetServerAmount(serverAmount);
domain.setInternetDiscountAmount(BigDecimal.ZERO); 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); domain.setInternetPayAmount(payAmount);
serialNumberList.add(domain.getInternetSerialNumber()); serialNumberList.add(domain.getInternetSerialNumber());
@ -277,24 +297,26 @@ public class InternetBillServiceImpl implements InternetBillService {
// //
checkRecordDomainList.add(domain); checkRecordDomainList.add(domain);
} }
getHistoryOrderList(checkRecordDomainList, serialNumberList); getHistoryOrderList(checkRecordDomainList, serialNumberList, startTime, endTime, tenantId);
return checkRecordDomainList; return checkRecordDomainList;
} }
/** /**
* 获取新电途对账数据 * 获取新电途对账数据
*
* @param dataFile 对账单文件,格式为xlsx * @param dataFile 对账单文件,格式为xlsx
* @return 对账数据 * @return 对账数据
*/ */
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getXDTInternetDataList(File dataFile) throws Exception { public List<XhpcTradebillInternetCheckRecordDomain> getXDTInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception {
String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1); String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1);
List<XhpcTradebillInternetCheckRecordDomain> checkRecordDomainList = new ArrayList<>(); List<XhpcTradebillInternetCheckRecordDomain> checkRecordDomainList = new ArrayList<>();
List<XDTTradebillVo> xdtTradebillVoList = new ArrayList<>(); List<XDTTradebillVo> xdtTradebillVoList = new ArrayList<>();
List<String> serialNumberList = new ArrayList<>(); List<String> serialNumberList = new ArrayList<>();
switch (suffix.toUpperCase()){ switch (suffix.toUpperCase()) {
case "XLS": case "XLS":
case "XLSX": case "XLSX":
ExcelUtil<XDTTradebillVo> util = new ExcelUtil<XDTTradebillVo>(XDTTradebillVo.class); ExcelUtil<XDTTradebillVo> util = new ExcelUtil<XDTTradebillVo>(XDTTradebillVo.class);
@ -305,10 +327,11 @@ public class InternetBillServiceImpl implements InternetBillService {
FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK")); FileReader fileReader = new FileReader(dataFile.getAbsolutePath(), Charset.forName("GBK"));
xdtTradebillVoList = reader.read(fileReader.readString(), XDTTradebillVo.class); xdtTradebillVoList = reader.read(fileReader.readString(), XDTTradebillVo.class);
break; break;
default: break; default:
break;
} }
for(XDTTradebillVo vo: xdtTradebillVoList){ for (XDTTradebillVo vo : xdtTradebillVoList) {
XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain(); XhpcTradebillInternetCheckRecordDomain domain = new XhpcTradebillInternetCheckRecordDomain();
domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim()); domain.setPlatformInternetSerialNumber(vo.getOrderNo().trim());
domain.setInternetSerialNumber(vo.getOrderNo().trim()); domain.setInternetSerialNumber(vo.getOrderNo().trim());
@ -316,55 +339,58 @@ public class InternetBillServiceImpl implements InternetBillService {
domain.setInternetName("新电途"); domain.setInternetName("新电途");
domain.setInternetChargeStation(vo.getStationName()); 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); 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); 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); 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.setInternetServerAmount(serverAmount);
domain.setInternetDiscountAmount(BigDecimal.ZERO); 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); domain.setInternetPayAmount(payAmount);
serialNumberList.add(domain.getInternetSerialNumber()); serialNumberList.add(domain.getInternetSerialNumber());
// getHistoryOrderInfo(domain); // getHistoryOrderInfo(domain);
checkRecordDomainList.add(domain); checkRecordDomainList.add(domain);
} }
getHistoryOrderList(checkRecordDomainList, serialNumberList); getHistoryOrderList(checkRecordDomainList, serialNumberList, startTime, endTime, tenantId);
return checkRecordDomainList; return checkRecordDomainList;
} }
/** /**
* 获取快电对账数据 * 获取快电对账数据
*
* @param dataFile 对账单文件,格式为xlsx * @param dataFile 对账单文件,格式为xlsx
* @return 对账数据 * @return 对账数据
*/ */
@Override @Override
public List<XhpcTradebillInternetCheckRecordDomain> getKDInternetDataList(File dataFile) throws Exception { public List<XhpcTradebillInternetCheckRecordDomain> getKDInternetDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception {
String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1); String suffix = dataFile.getName().substring(dataFile.getName().lastIndexOf(".") + 1);
List<XhpcTradebillInternetCheckRecordDomain> checkRecordDomainList = new ArrayList<>(); List<XhpcTradebillInternetCheckRecordDomain> checkRecordDomainList = new ArrayList<>();
List<KDTradebillVo> kdTradebillVoList = new ArrayList<>(); List<KDTradebillVo> kdTradebillVoList = new ArrayList<>();
List<Map<String, Object>> dataList = new ArrayList<>(); List<Map<String, Object>> dataList = new ArrayList<>();
List<String> serialNumberList = new ArrayList<>(); List<String> serialNumberList = new ArrayList<>();
switch (suffix.toUpperCase()){ switch (suffix.toUpperCase()) {
case "XLS": case "XLS":
case "XLSX": case "XLSX":
ExcelUtil<KDTradebillVo> util = new ExcelUtil<KDTradebillVo>(KDTradebillVo.class); ExcelUtil<KDTradebillVo> util = new ExcelUtil<KDTradebillVo>(KDTradebillVo.class);
kdTradebillVoList = util.importExcel(new FileInputStream(dataFile), 1); kdTradebillVoList = util.importExcel(new FileInputStream(dataFile), 1);
break; break;
default: break; default:
break;
} }
for(KDTradebillVo vo: kdTradebillVoList){ for (KDTradebillVo vo : kdTradebillVoList) {
if (vo.getOrderNo().equals("交易订单号") || StrUtil.hasBlank(vo.getOrderNo())) { if (vo.getOrderNo().equals("交易订单号") || StrUtil.hasBlank(vo.getOrderNo())) {
continue; continue;
} }
@ -374,18 +400,18 @@ public class InternetBillServiceImpl implements InternetBillService {
domain.setInternetSerialNumber(vo.getOrderNo()); domain.setInternetSerialNumber(vo.getOrderNo());
domain.setPlatformInternetSerialNumber(vo.getOrderNo()); domain.setPlatformInternetSerialNumber(vo.getOrderNo());
Date startTime = StrUtil.hasBlank(vo.getStartTime()) ? null: DateUtil.parse(vo.getStartTime()); Date startTime1 = StrUtil.hasBlank(vo.getStartTime()) ? null : DateUtil.parse(vo.getStartTime());
domain.setInternetStartTime(startTime); domain.setInternetStartTime(startTime1);
Date endTime = StrUtil.hasBlank(vo.getEndTime()) ? null: DateUtil.parse(vo.getEndTime()); Date endTime1 = StrUtil.hasBlank(vo.getEndTime()) ? null : DateUtil.parse(vo.getEndTime());
domain.setInternetEndTime(endTime); domain.setInternetEndTime(endTime1);
domain.setInternetChargeStation(vo.getStationName()); 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); 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); 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());
@ -393,25 +419,27 @@ public class InternetBillServiceImpl implements InternetBillService {
domain.setInternetDiscountAmount(BigDecimal.ZERO); 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.setInternetOrderAmount(new BigDecimal(orderAmount));
domain.setInternetPayAmount(domain.getInternetOrderAmount()); domain.setInternetPayAmount(domain.getInternetOrderAmount());
serialNumberList.add(domain.getInternetSerialNumber()); serialNumberList.add(domain.getInternetSerialNumber());
checkRecordDomainList.add(domain); checkRecordDomainList.add(domain);
} }
getHistoryOrderList(checkRecordDomainList, serialNumberList); getHistoryOrderList(checkRecordDomainList, serialNumberList, startTime, endTime, tenantId);
return checkRecordDomainList; return checkRecordDomainList;
} }
/** /**
* 导出对账单 * 导出对账单
*
* @param response 返回体 * @param response 返回体
* @param params 查询参数 * @param params 查询参数
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override @Override
public void export(HttpServletResponse response, Map<String, Object> params) throws Exception{ public void export(HttpServletResponse response, Map<String, Object> params) throws Exception {
List<Map<String, Object>> list = internetCheckRecordMapper.selectByParams(params); List<Map<String, Object>> list = internetCheckRecordMapper.selectByParams(params);
// 通过工具类创建writer默认创建xls格式 // 通过工具类创建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()); XhpcHistoryOrderDomain orderDomain = historyOrderMapper.findOneByInternetSerialNumber(domain.getInternetSerialNumber());
if(orderDomain != null){ if (orderDomain != null) {
domain.setHistoryOrderNo(orderDomain.getHistoryOrderId()); domain.setHistoryOrderNo(orderDomain.getHistoryOrderId());
domain.setPlatformInternetSerialNumber(orderDomain.getInternetSerialNumber()); domain.setPlatformInternetSerialNumber(orderDomain.getInternetSerialNumber());
domain.setPlatformSerialNumber(orderDomain.getSerialNumber()); domain.setPlatformSerialNumber(orderDomain.getSerialNumber());
domain.setPlatformChargeStation(orderDomain.getChargingStationName()); domain.setPlatformChargeStation(orderDomain.getChargingStationName());
domain.setPlatformStartSoc(orderDomain.getStartSoc()); domain.setPlatformStartSoc(orderDomain.getStartSoc());
domain.setPlatformEndSoc(orderDomain.getEndSoc()); domain.setPlatformEndSoc(orderDomain.getEndSoc());
BigDecimal chargingDegree = orderDomain.getChargingDegree() != null? BigDecimal chargingDegree = orderDomain.getChargingDegree() != null ?
BigDecimal.valueOf(orderDomain.getChargingDegree()): BigDecimal.ZERO; BigDecimal.valueOf(orderDomain.getChargingDegree()) : BigDecimal.ZERO;
domain.setPlatformChargingDegree(chargingDegree); domain.setPlatformChargingDegree(chargingDegree);
domain.setPlatformChargingTime(orderDomain.getChargingTime()); domain.setPlatformChargingTime(orderDomain.getChargingTime());
domain.setPlatformStartTime(orderDomain.getStartTime()); domain.setPlatformStartTime(orderDomain.getStartTime());
@ -488,24 +516,27 @@ public class InternetBillServiceImpl implements InternetBillService {
} }
private List<XhpcTradebillInternetCheckRecordDomain> getHistoryOrderList(List<XhpcTradebillInternetCheckRecordDomain> domainList, List<String> serialNumberList){ private List<XhpcTradebillInternetCheckRecordDomain> getHistoryOrderList(List<XhpcTradebillInternetCheckRecordDomain> domainList,
List<XhpcHistoryOrderDomain> orderDomainList = historyOrderMapper.findListByInternetSerialNumbers(serialNumberList); List<String> serialNumberList,
String startTime, String endTime, String tenantId) {
List<XhpcHistoryOrderDomain> orderDomainList = historyOrderMapper.findListByTimeBetween(startTime, endTime, tenantId);
Map<String, XhpcHistoryOrderDomain> orderDomainMap = new HashMap<>(); Map<String, XhpcHistoryOrderDomain> orderDomainMap = new HashMap<>();
for(XhpcHistoryOrderDomain orderDomain: orderDomainList){ for (XhpcHistoryOrderDomain orderDomain : orderDomainList) {
orderDomainMap.put(orderDomain.getInternetSerialNumber(), orderDomain); orderDomainMap.put(orderDomain.getInternetSerialNumber(), orderDomain);
} }
for(XhpcTradebillInternetCheckRecordDomain domain: domainList){ for (XhpcTradebillInternetCheckRecordDomain domain : domainList) {
XhpcHistoryOrderDomain orderDomain = orderDomainMap.get(domain.getInternetSerialNumber()); XhpcHistoryOrderDomain orderDomain = orderDomainMap.get(domain.getInternetSerialNumber());
if(orderDomain != null){ if (orderDomain != null) {
domain.setHistoryOrderNo(orderDomain.getHistoryOrderId()); domain.setHistoryOrderNo(orderDomain.getHistoryOrderId());
domain.setPlatformInternetSerialNumber(orderDomain.getInternetSerialNumber()); domain.setPlatformInternetSerialNumber(orderDomain.getInternetSerialNumber());
domain.setPlatformSerialNumber(orderDomain.getSerialNumber()); domain.setPlatformSerialNumber(orderDomain.getSerialNumber());
domain.setPlatformChargeStation(orderDomain.getChargingStationName()); domain.setPlatformChargeStation(orderDomain.getChargingStationName());
domain.setPlatformStartSoc(orderDomain.getStartSoc()); domain.setPlatformStartSoc(orderDomain.getStartSoc());
domain.setPlatformEndSoc(orderDomain.getEndSoc()); domain.setPlatformEndSoc(orderDomain.getEndSoc());
BigDecimal chargingDegree = orderDomain.getChargingDegree() != null? BigDecimal chargingDegree = orderDomain.getChargingDegree() != null ?
BigDecimal.valueOf(orderDomain.getChargingDegree()): BigDecimal.ZERO; BigDecimal.valueOf(orderDomain.getChargingDegree()) : BigDecimal.ZERO;
domain.setPlatformChargingDegree(chargingDegree); domain.setPlatformChargingDegree(chargingDegree);
domain.setPlatformChargingTime(orderDomain.getChargingTime()); domain.setPlatformChargingTime(orderDomain.getChargingTime());
domain.setPlatformStartTime(orderDomain.getStartTime()); domain.setPlatformStartTime(orderDomain.getStartTime());
@ -516,25 +547,51 @@ public class InternetBillServiceImpl implements InternetBillService {
domain.setPlatformDiscountAmount(orderDomain.getPromotionDiscount()); domain.setPlatformDiscountAmount(orderDomain.getPromotionDiscount());
domain.setPlatformPayAmount(orderDomain.getActPrice()); domain.setPlatformPayAmount(orderDomain.getActPrice());
} }
orderDomainMap.remove(domain.getInternetSerialNumber());
checkoutOrderResult(domain); 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)); domainList.sort(Comparator.comparing(XhpcTradebillInternetCheckRecordDomain::getStatus));
return domainList; return domainList;
} }
private void checkoutOrderResult(XhpcTradebillInternetCheckRecordDomain domain){ private void checkoutOrderResult(XhpcTradebillInternetCheckRecordDomain domain) {
int checkoutStatus = 0; int checkoutStatus = 0;
// 流量方的订单金额大于本平台的历史订单的订单金额就可以判断成功 // 流量方的订单金额大于本平台的历史订单的订单金额就可以判断成功
if(domain.getPlatformOrderAmount() != null && domain.getPlatformOrderAmount().compareTo(domain.getInternetOrderAmount()) == 0 if (domain.getPlatformOrderAmount() != null && domain.getPlatformOrderAmount().compareTo(domain.getInternetOrderAmount()) == 0
&& domain.getPlatformPowerAmount() != null && domain.getPlatformPowerAmount().compareTo(domain.getInternetPowerAmount()) == 0 && domain.getPlatformPowerAmount() != null && domain.getPlatformPowerAmount().compareTo(domain.getInternetPowerAmount()) == 0
&& domain.getPlatformServerAmount() != null && domain.getPlatformServerAmount().compareTo(domain.getInternetServerAmount()) == 0 && domain.getPlatformServerAmount() != null && domain.getPlatformServerAmount().compareTo(domain.getInternetServerAmount()) == 0
&& domain.getPlatformChargingDegree() != null && domain.getPlatformChargingDegree().compareTo(domain.getInternetChargingDegree()) == 0){ && domain.getPlatformChargingDegree() != null && domain.getPlatformChargingDegree().compareTo(domain.getInternetChargingDegree()) == 0) {
checkoutStatus = 2; checkoutStatus = 2;
} }
domain.setStatus(checkoutStatus); domain.setStatus(checkoutStatus);
} }
} }

View File

@ -23,6 +23,7 @@ import com.xhpc.tradebill.config.AliPayProperties;
import com.xhpc.tradebill.constant.WeixinPayConstant; import com.xhpc.tradebill.constant.WeixinPayConstant;
import com.xhpc.tradebill.domain.XhpcRechargeOrderDomain; import com.xhpc.tradebill.domain.XhpcRechargeOrderDomain;
import com.xhpc.tradebill.domain.XhpcRefundOrderDomain; import com.xhpc.tradebill.domain.XhpcRefundOrderDomain;
import com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain;
import com.xhpc.tradebill.domain.XhpcTradebillPaymentCheckRecordDomain; import com.xhpc.tradebill.domain.XhpcTradebillPaymentCheckRecordDomain;
import com.xhpc.tradebill.mapper.XhpcRechargeOrderMapper; import com.xhpc.tradebill.mapper.XhpcRechargeOrderMapper;
import com.xhpc.tradebill.mapper.XhpcRefundOrderMapper; import com.xhpc.tradebill.mapper.XhpcRefundOrderMapper;
@ -136,10 +137,10 @@ public class PaymentBillServiceImpl implements PaymentBillService {
* @param fileUrl 数据文件存放地址 * @param fileUrl 数据文件存放地址
* @return 对账完成的数据列表 * @return 对账完成的数据列表
*/ */
public List<XhpcTradebillPaymentCheckRecordDomain> getAliPayDataList(String fileUrl) throws Exception { public List<XhpcTradebillPaymentCheckRecordDomain> getAliPayDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception {
File dataFile = DownloadUtil.downloadFile(fileUrl); 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 数据文件 * @param dataFile 数据文件
* @return 对账完成的数据列表 * @return 对账完成的数据列表
*/ */
public List<XhpcTradebillPaymentCheckRecordDomain> getAliPayDataList(File dataFile) throws public List<XhpcTradebillPaymentCheckRecordDomain> getAliPayDataList(File dataFile, String startTime, String endTime, String tenantId) throws
Exception { Exception {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
@ -210,7 +211,7 @@ public class PaymentBillServiceImpl implements PaymentBillService {
} }
paymentCheckRecordDomainList.add(domain); paymentCheckRecordDomainList.add(domain);
} }
getPlatOrderData(paymentCheckRecordDomainList, orderType, serialNumberList); getPlatOrderData(paymentCheckRecordDomainList, orderType, serialNumberList, startTime, endTime, tenantId);
break; break;
case "ZIP": case "ZIP":
@ -233,7 +234,7 @@ public class PaymentBillServiceImpl implements PaymentBillService {
outputStream.close(); outputStream.close();
} }
if (file != null) { if (file != null) {
paymentCheckRecordDomainList = getAliPayDataList(file); paymentCheckRecordDomainList = getAliPayDataList(file, startTime, endTime, tenantId);
} }
break; break;
@ -251,10 +252,10 @@ public class PaymentBillServiceImpl implements PaymentBillService {
* @param fileUrl 数据文件存放地址 * @param fileUrl 数据文件存放地址
* @return 对账完成的数据列表 * @return 对账完成的数据列表
*/ */
public List<XhpcTradebillPaymentCheckRecordDomain> getWechatDataList(String fileUrl) throws Exception { public List<XhpcTradebillPaymentCheckRecordDomain> getWechatDataList(String fileUrl, String startTime, String endTime, String tenantId) throws Exception {
File dataFile = DownloadUtil.downloadFile(fileUrl); 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 数据文件 * @param dataFile 数据文件
* @return 对账完成的数据列表 * @return 对账完成的数据列表
*/ */
public List<XhpcTradebillPaymentCheckRecordDomain> getWechatDataList(File dataFile) throws Exception { public List<XhpcTradebillPaymentCheckRecordDomain> getWechatDataList(File dataFile, String startTime, String endTime, String tenantId) throws Exception {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
List<XhpcTradebillPaymentCheckRecordDomain> paymentCheckRecordDomainList = new ArrayList<>(); List<XhpcTradebillPaymentCheckRecordDomain> paymentCheckRecordDomainList = new ArrayList<>();
@ -327,7 +328,7 @@ public class PaymentBillServiceImpl implements PaymentBillService {
paymentCheckRecordDomainList.add(computeTradebillData(domain)); paymentCheckRecordDomainList.add(computeTradebillData(domain));
} }
getPlatOrderData(paymentCheckRecordDomainList, orderType, serialNumberList); getPlatOrderData(paymentCheckRecordDomainList, orderType, serialNumberList, startTime, endTime, tenantId);
} else { } else {
throw new Exception("暂不支持的文件格式"); throw new Exception("暂不支持的文件格式");
@ -449,13 +450,18 @@ public class PaymentBillServiceImpl implements PaymentBillService {
private List<XhpcTradebillPaymentCheckRecordDomain> getPlatOrderData(List<XhpcTradebillPaymentCheckRecordDomain> domainList, int orderType, List<String> serialNumberList){ private List<XhpcTradebillPaymentCheckRecordDomain> getPlatOrderData(List<XhpcTradebillPaymentCheckRecordDomain> domainList,
int orderType,
List<String> serialNumberList,
String startTime,
String endTime,
String tenantId){
List<Map<String, Object>> orderMapList = null; List<Map<String, Object>> orderMapList = null;
if (orderType == 1) { if (orderType == 1) {
orderMapList = rechargeOrderMapper.findListByOrderNumbers(serialNumberList); orderMapList = rechargeOrderMapper.findListByTimeBetween(startTime, endTime, tenantId);
} else if (orderType == 2) { } else if (orderType == 2) {
orderMapList = refundOrderMapper.findListByOrderNumbers(serialNumberList); orderMapList = refundOrderMapper.findListByTimeBetween(startTime, endTime, tenantId);
} }
Map<String, Map<String, Object>> orderList = new HashMap<>(); Map<String, Map<String, Object>> orderList = new HashMap<>();
@ -472,9 +478,23 @@ public class PaymentBillServiceImpl implements PaymentBillService {
domain.setPlatformAmount(new BigDecimal(orderMap.get("amount").toString())); domain.setPlatformAmount(new BigDecimal(orderMap.get("amount").toString()));
domain.setPlatformPayTime(DateUtil.parse(orderMap.get("updateTime").toString(), "yyyy-MM-dd'T'HH:mm")); domain.setPlatformPayTime(DateUtil.parse(orderMap.get("updateTime").toString(), "yyyy-MM-dd'T'HH:mm"));
} }
orderList.remove(domain.getPaymentPayNumber());
computeTradebillData(domain); computeTradebillData(domain);
} }
if(orderList.size() > 0){
for(Map<String, Object> 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; return domainList;
} }

View File

@ -38,4 +38,17 @@
#{orderNumber} #{orderNumber}
</foreach> </foreach>
</select> </select>
<select id="findListByTimeBetween" resultType="com.xhpc.tradebill.domain.XhpcHistoryOrderDomain">
select
o.*,
s.name as 'charging_station_name',
c.charging_degree as 'charging_degree',
c.charging_time as 'charging_time'
from xhpc_history_order o
left join xhpc_charging_station s on o.charging_station_id=s.charging_station_id
left join xhpc_charge_order c on o.charge_order_id=c.charge_order_id
where tenant_id=#{tenantId} and create_time BETWEEN #{startTime} AND #{endTime}
</select>
</mapper> </mapper>

View File

@ -43,4 +43,18 @@
#{orderNumber} #{orderNumber}
</foreach> </foreach>
</select> </select>
<select id="findListByTimeBetween" resultType="map">
select
recharge_order_id as 'id',
recharge_order_number as 'orderNumber',
user_id as 'userId',
amount as 'amount',
create_time as 'createTime',
update_time as 'updateTime'
from xhpc_recharge_order
where tenant_id=#{tenantId} and create_time BETWEEN #{startTime} AND #{endTime}
</select>
</mapper> </mapper>

View File

@ -39,4 +39,17 @@
#{orderNumber} #{orderNumber}
</foreach> </foreach>
</select> </select>
<select id="findListByTimeBetween" resultType="map">
select
refund_order_id as 'id',
refund_order_number as 'orderNumber',
user_id as 'userId',
amount as 'amount',
create_time as 'createTime',
update_time as 'updateTime'
from xhpc_refund_order
where tenant_id=#{tenantId} and create_time BETWEEN #{startTime} AND #{endTime}
</select>
</mapper> </mapper>