@@ -38,6 +38,29 @@ public class AflMchStatistics extends AbstractInsertTimeEntity { | |||
@ExcelExport("退款总额") | |||
private BigDecimal totalRefundFee; | |||
@ExcelExport("渠道编号") | |||
private String agentId; | |||
@ExcelExport("渠道名称") | |||
private String agentName; | |||
@Column(name = "agent_id") | |||
public String getAgentId() { | |||
return agentId; | |||
} | |||
public void setAgentId(String agentId) { | |||
this.agentId = agentId; | |||
} | |||
@Column(name = "agent_name") | |||
public String getAgentName() { | |||
return agentName; | |||
} | |||
public void setAgentName(String agentName) { | |||
this.agentName = agentName; | |||
} | |||
/*** 统计日期 */ | |||
@Column(name = "STATISTICAL_DATE") | |||
public Integer getStatisticalDate() { |
@@ -70,7 +70,7 @@ public class AflMchStatisticsPageHandler extends AbstractAfterSalesManager<AflMc | |||
if (request.getPageSize() > 100) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请求每页数量过大 " + request.getPageSize()); | |||
} | |||
return aflMchStatisticsRepo.findAll(((root, query, cb) -> { | |||
Page<AflMchStatistics> mchStatisticsRepoAll = aflMchStatisticsRepo.findAll(((root, query, cb) -> { | |||
List<Predicate> list = Lists.newArrayList(); | |||
if (!StringUtils.isEmpty(request.getSubMchId())) { | |||
list.add(cb.equal(root.<String>get("subMchId"), request.getSubMchId())); | |||
@@ -84,9 +84,28 @@ public class AflMchStatisticsPageHandler extends AbstractAfterSalesManager<AflMc | |||
if (null != request.getEndDate()) { | |||
list.add(cb.lessThanOrEqualTo(root.<Integer>get("statisticalDate"), request.getEndDate())); | |||
} | |||
if (!StringUtils.isEmpty(request.getAgentId())) { | |||
list.add(cb.equal(root.<String>get("agentId"), request.getAgentId())); | |||
} | |||
if (!StringUtils.isEmpty(request.getAgentName())) { | |||
list.add(cb.equal(root.<String>get("agentName"), request.getAgentName())); | |||
} | |||
Predicate[] p = new Predicate[list.size()]; | |||
return cb.and(list.toArray(p)); | |||
}), PageRequest.of(request.getPageNo() - 1, request.getPageSize(), | |||
Sort.by(Sort.Direction.DESC, "insertTime"))); | |||
mchStatisticsRepoAll.getContent().forEach(desc -> { | |||
desc.setFeeType(formatFeeDescription(desc.getFeeType())); | |||
}); | |||
logger.info(mchStatisticsRepoAll.getContent().toString()); | |||
return mchStatisticsRepoAll; | |||
} | |||
public String formatFeeDescription(String desc) { | |||
if (desc.equals("其他")) return desc; | |||
if (desc.contains("服务费")) return "服务费"; | |||
if (desc.contains("通行费")) return "通行费"; | |||
return desc; | |||
} | |||
} |
@@ -23,6 +23,27 @@ public class AflMchStatisticsPageRequest extends AbstractAfterSalesPageRequest<A | |||
private Integer endDate; | |||
//渠道编码 | |||
private String agentId; | |||
//渠道名称 | |||
private String agentName; | |||
public String getAgentId() { | |||
return agentId; | |||
} | |||
public void setAgentId(String agentId) { | |||
this.agentId = agentId; | |||
} | |||
public String getAgentName() { | |||
return agentName; | |||
} | |||
public void setAgentName(String agentName) { | |||
this.agentName = agentName; | |||
} | |||
public String getSubMchId() { | |||
return subMchId; | |||
} |
@@ -85,7 +85,7 @@ public class AflMchStatisticsServiceImpl implements AflMchStatisticsService { | |||
@Override | |||
public String export(AflMchStatisticsPageRequest request) throws ServiceHandleException { | |||
final List<AflMchStatistics> statisticsList = aflMchStatisticsRepo.findAll(((root, query, cb) -> { | |||
List<Predicate> list = Lists.newArrayList(); | |||
final List<Predicate> list = Lists.newArrayList(); | |||
if (!StringUtils.isEmpty(request.getSubMchId())) { | |||
list.add(cb.equal(root.<String>get("subMchId"), request.getSubMchId())); | |||
} | |||
@@ -98,12 +98,21 @@ public class AflMchStatisticsServiceImpl implements AflMchStatisticsService { | |||
if (null != request.getEndDate()) { | |||
list.add(cb.lessThanOrEqualTo(root.get(statisticalDate), request.getEndDate())); | |||
} | |||
if (!StringUtils.isEmpty(request.getAgentId())) { | |||
list.add(cb.equal(root.<String>get("agentId"), request.getAgentId())); | |||
} | |||
if (!StringUtils.isEmpty(request.getAgentName())) { | |||
list.add(cb.equal(root.<String>get("agentName"), request.getAgentName())); | |||
} | |||
Predicate[] p = new Predicate[list.size()]; | |||
return cb.and(list.toArray(p)); | |||
})); | |||
if (CollectionUtils.isEmpty(statisticsList)) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("暂无可导出数据"); | |||
} | |||
statisticsList.forEach(desc-> desc.setFeeType(formatFeeDescription(desc.getFeeType()))); | |||
String pathFile = ExcelUtils.export(null, "选装-商户号金额统计",constantConfig.getFilePath(), statisticsList, AflMchStatistics.class); | |||
try { | |||
return fmsService.uploadFile(constantConfig.getUploadFile(),pathFile, 90000); | |||
@@ -112,6 +121,12 @@ public class AflMchStatisticsServiceImpl implements AflMchStatisticsService { | |||
} | |||
} | |||
public String formatFeeDescription(String desc) { | |||
if (desc.equals("其他")) return desc; | |||
if (desc.contains("服务费")) return "服务费"; | |||
if (desc.contains("通行费")) return "通行费"; | |||
return desc; | |||
} | |||
@Override | |||
public Page<AflMchStatistics> findPage(Integer year, Integer month, String subMchId, Pageable pageable) { | |||
return aflMchStatisticsRepo.findAll(getSpecification(year, month, subMchId, null), pageable); |