Commit 1a9048374583aedaf4de62cffb1426e9e44bf7f0

Authored by yeqianyong
1 parent 2adb35b8

楚江erp:台账报表统计逻辑调整

@@ -51,6 +51,7 @@ import java.math.RoundingMode; @@ -51,6 +51,7 @@ import java.math.RoundingMode;
51 import java.time.LocalDate; 51 import java.time.LocalDate;
52 import java.time.LocalDateTime; 52 import java.time.LocalDateTime;
53 import java.time.YearMonth; 53 import java.time.YearMonth;
  54 +import java.time.format.DateTimeFormatter;
54 import java.time.temporal.ChronoUnit; 55 import java.time.temporal.ChronoUnit;
55 import java.time.temporal.TemporalAdjusters; 56 import java.time.temporal.TemporalAdjusters;
56 import java.util.*; 57 import java.util.*;
@@ -483,6 +484,16 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -483,6 +484,16 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
483 public PageResult<ReceiptLedgerReportBo> report(Integer pageIndex, Integer pageSize, ReceiptLedgerReportVo vo) { 484 public PageResult<ReceiptLedgerReportBo> report(Integer pageIndex, Integer pageSize, ReceiptLedgerReportVo vo) {
484 Assert.greaterThanZero(pageIndex); 485 Assert.greaterThanZero(pageIndex);
485 Assert.greaterThanZero(pageSize); 486 Assert.greaterThanZero(pageSize);
  487 + // 获取当月1号和当前时间
  488 + LocalDateTime endTime = LocalDateTime.now();
  489 + LocalDateTime startTime = LocalDate.now().withDayOfMonth(1).atStartOfDay();
  490 + if (vo.getStartTime() == null) {
  491 + vo.setStartTime(startTime);
  492 + }
  493 + if (vo.getEndTime() == null) {
  494 + vo.setEndTime(endTime);
  495 + }
  496 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
486 // 开启分页 497 // 开启分页
487 PageHelperUtil.startPage(pageIndex, pageSize); 498 PageHelperUtil.startPage(pageIndex, pageSize);
488 List<ReceiptLedgerReportBo> dataList = getBaseMapper().report(vo); 499 List<ReceiptLedgerReportBo> dataList = getBaseMapper().report(vo);
@@ -491,11 +502,15 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -491,11 +502,15 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
491 return result; 502 return result;
492 } 503 }
493 List<String> shortNames = dataList.stream().map(ReceiptLedgerReportBo::getCustomerShortName).distinct().collect(Collectors.toList()); 504 List<String> shortNames = dataList.stream().map(ReceiptLedgerReportBo::getCustomerShortName).distinct().collect(Collectors.toList());
494 - // 根据简称获取台账明细数据  
495 - Map<String, List<ReceiptLedgerInfo>> agreementDataMap = getLedgerInfoByShortName(shortNames, Boolean.FALSE);  
496 - Map<String, List<ReceiptLedgerInfo>> overdueDataMap = getLedgerInfoByShortName(shortNames, Boolean.TRUE); 505 + // 获取当月所有台账明细数据(内贸)
  506 + QueryReceiptLedgerInfoVo ledgerInfoVo = new QueryReceiptLedgerInfoVo();
  507 + ledgerInfoVo.setType("INSIDE");
  508 + ledgerInfoVo.setCreateTimeStart(startTime.format(formatter));
  509 + ledgerInfoVo.setCreateTimeEnd(endTime.format(formatter));
  510 + List<ReceiptLedgerInfo> ledgerInfoList = getBaseMapper().query(ledgerInfoVo);
497 // 统计各个阶段欠款金额数据 511 // 统计各个阶段欠款金额数据
498 - List<Map<String, Object>> debtAmountList = getBaseMapper().statisticsDebtByShortName(shortNames, null, "INSIDE"); 512 + List<Map<String, Object>> debtAmountList = getBaseMapper().statisticsDebtByShortName(shortNames, null, "INSIDE"
  513 + , vo.getStartTime(), vo.getEndTime());
499 if (CollectionUtils.isEmpty(debtAmountList)) { 514 if (CollectionUtils.isEmpty(debtAmountList)) {
500 return result; 515 return result;
501 } 516 }
@@ -511,6 +526,7 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -511,6 +526,7 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
511 List<Map<String, Object>> list = debtMap.computeIfAbsent(shortName, k -> new ArrayList<>()); 526 List<Map<String, Object>> list = debtMap.computeIfAbsent(shortName, k -> new ArrayList<>());
512 list.add(map); 527 list.add(map);
513 } 528 }
  529 + Set<String> customerNames = new HashSet<>();
514 // 获取待交付订货单数 530 // 获取待交付订货单数
515 Map<String, Long> orderCountMap = shipmentsOrderInfoService.countWaitDeliveredOrder(customerNameList); 531 Map<String, Long> orderCountMap = shipmentsOrderInfoService.countWaitDeliveredOrder(customerNameList);
516 for (ReceiptLedgerReportBo report : dataList) { 532 for (ReceiptLedgerReportBo report : dataList) {
@@ -520,28 +536,19 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -520,28 +536,19 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
520 continue; 536 continue;
521 } 537 }
522 long waitDeliveredOrderTotal = 0; 538 long waitDeliveredOrderTotal = 0;
523 - List<String> creditStatusList = new ArrayList<>();  
524 - List<String> debtStates = new ArrayList<>();  
525 Map<String, ReceiptLedgerReportDetail> reportDetailMap = new LinkedHashMap<>(); 539 Map<String, ReceiptLedgerReportDetail> reportDetailMap = new LinkedHashMap<>();
526 for (Map<String, Object> map : list) { 540 for (Map<String, Object> map : list) {
527 String customerName = (String) map.get("name"); 541 String customerName = (String) map.get("name");
528 String debtStatus = (String) map.get("debt_status"); 542 String debtStatus = (String) map.get("debt_status");
529 - debtStates.add(debtStatus);  
530 BigDecimal debtAmount = (BigDecimal) map.get("debt_amount"); 543 BigDecimal debtAmount = (BigDecimal) map.get("debt_amount");
531 544
532 ReceiptLedgerReportDetail reportDetail = reportDetailMap.get(customerName); 545 ReceiptLedgerReportDetail reportDetail = reportDetailMap.get(customerName);
533 if (reportDetail == null) { 546 if (reportDetail == null) {
534 reportDetail = new ReceiptLedgerReportDetail(); 547 reportDetail = new ReceiptLedgerReportDetail();
  548 + reportDetail.setCustomerName(customerName);
535 } 549 }
536 - reportDetail.setCustomerName(customerName);  
537 - if ("AGREEMENT".equals(debtStatus) || "DEPOSIT".equals(debtStatus)) {  
538 - BigDecimal agreement = reportDetail.getAgreement();  
539 - if (agreement == null) {  
540 - agreement = debtAmount;  
541 - } else {  
542 - agreement = agreement.add(debtAmount);  
543 - }  
544 - reportDetail.setAgreement(valueConvert(agreement)); 550 + if ("AGREEMENT".equals(debtStatus)) {
  551 + reportDetail.setAgreement(valueConvert(debtAmount));
545 reportDetail.setTimingStatus("约定内"); 552 reportDetail.setTimingStatus("约定内");
546 } else if ("FIRST_COORDINATE".equals(debtStatus)) { 553 } else if ("FIRST_COORDINATE".equals(debtStatus)) {
547 reportDetail.setFirstCoordinate(valueConvert(debtAmount)); 554 reportDetail.setFirstCoordinate(valueConvert(debtAmount));
@@ -553,17 +560,13 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -553,17 +560,13 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
553 reportDetail.setClearDebt(valueConvert(debtAmount)); 560 reportDetail.setClearDebt(valueConvert(debtAmount));
554 reportDetail.setTimingStatus("超期3"); 561 reportDetail.setTimingStatus("超期3");
555 } 562 }
556 - // 计算超额数据(授信状态)  
557 - String creditStatus = calculateExcess(debtAmount, report.getQuota());  
558 - if (StringUtils.isNotBlank(creditStatus)) {  
559 - report.setCreditStatus(creditStatus);  
560 - creditStatusList.add(creditStatus);  
561 - }  
562 // 统计待交付订单数 563 // 统计待交付订单数
563 Long count = orderCountMap.get(customerName); 564 Long count = orderCountMap.get(customerName);
564 - if (count != null) { 565 + if (count != null && !customerNames.contains(customerName)) {
565 waitDeliveredOrderTotal += count; 566 waitDeliveredOrderTotal += count;
566 reportDetail.setWaitDeliveredOrder(count); 567 reportDetail.setWaitDeliveredOrder(count);
  568 + // 防止重复相加
  569 + customerNames.add(customerName);
567 } 570 }
568 // 计算总欠款 571 // 计算总欠款
569 BigDecimal debtTotal = reportDetail.getDebtTotal(); 572 BigDecimal debtTotal = reportDetail.getDebtTotal();
@@ -577,22 +580,28 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -577,22 +580,28 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
577 } 580 }
578 List<ReceiptLedgerReportDetail> details = new ArrayList<>(reportDetailMap.values()); 581 List<ReceiptLedgerReportDetail> details = new ArrayList<>(reportDetailMap.values());
579 if (CollectionUtils.isNotEmpty(details)) { 582 if (CollectionUtils.isNotEmpty(details)) {
580 - // 转换成万元  
581 for (ReceiptLedgerReportDetail detail : details) { 583 for (ReceiptLedgerReportDetail detail : details) {
  584 + // 转换成万元
582 BigDecimal debtTotal = detail.getDebtTotal(); 585 BigDecimal debtTotal = detail.getDebtTotal();
583 detail.setDebtTotal(valueConvert(debtTotal)); 586 detail.setDebtTotal(valueConvert(debtTotal));
  587 + // 计算超额数据(授信状态)
  588 + String creditStatus = calculateExcess(debtTotal, report.getQuota());
  589 + if (StringUtils.isNotBlank(creditStatus)) {
  590 + detail.setCreditStatus(creditStatus);
  591 + }
584 } 592 }
585 } 593 }
586 report.setDetailList(details); 594 report.setDetailList(details);
587 595
588 // 处理约定内、一次协调、二次协调、清欠小计数据 596 // 处理约定内、一次协调、二次协调、清欠小计数据
589 - handleSubtotal(agreementDataMap, overdueDataMap, report);  
590 - // 授时状态  
591 - report.setTimingStatus(getHighestPriorityStatus(debtStates)); 597 + handleSubtotal(ledgerInfoList, report);
592 // 授信状态 598 // 授信状态
593 - report.setCreditStatus(findMaxPercentageString(creditStatusList));  
594 - report.setWaitDeliveredOrderTotal(waitDeliveredOrderTotal);  
595 BigDecimal debtTotal = report.getDebtTotal(); 599 BigDecimal debtTotal = report.getDebtTotal();
  600 + String creditStatus = calculateExcess(debtTotal, report.getQuota());
  601 + if (StringUtils.isNotBlank(creditStatus)) {
  602 + report.setCreditStatus(creditStatus);
  603 + }
  604 + report.setWaitDeliveredOrderTotal(waitDeliveredOrderTotal);
596 report.setDebtTotal(valueConvert(debtTotal)); 605 report.setDebtTotal(valueConvert(debtTotal));
597 } 606 }
598 return result; 607 return result;
@@ -1032,13 +1041,111 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -1032,13 +1041,111 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
1032 /** 1041 /**
1033 * 处理“小计”数据 1042 * 处理“小计”数据
1034 * 1043 *
1035 - * @param agreementDataMap 约定内数据集合  
1036 - * @param overdueDataMap 逾期数据集合  
1037 - * @param report 报表数据 1044 + * @param ledgerInfoList 台账明细数据
  1045 + * @param report 报表数据
1038 */ 1046 */
1039 - private void handleSubtotal(Map<String, List<ReceiptLedgerInfo>> agreementDataMap, Map<String, List<ReceiptLedgerInfo>> overdueDataMap  
1040 - , ReceiptLedgerReportBo report) {  
1041 - String customerShortName = report.getCustomerShortName(); 1047 + private void handleSubtotal(List<ReceiptLedgerInfo> ledgerInfoList, ReceiptLedgerReportBo report) {
  1048 + if (CollectionUtils.isEmpty(ledgerInfoList) || report == null) {
  1049 + return;
  1050 + }
  1051 + BigDecimal debtTotal = report.getDebtTotal();
  1052 + // 约定内欠款
  1053 + BigDecimal agreement = getAgreementDebt(ledgerInfoList, report);
  1054 + if (agreement.compareTo(debtTotal) >= 0) {
  1055 + report.setAgreementTotal(valueConvert(debtTotal));
  1056 + report.setTimingStatus("约定内");
  1057 + return;
  1058 + }
  1059 + // 一次协调欠款
  1060 + BigDecimal firstCoordinate = BigDecimal.ZERO;
  1061 + for (ReceiptLedgerInfo ledgerInfo : ledgerInfoList) {
  1062 + String customerShortName = report.getCustomerShortName();
  1063 + if (!customerShortName.equals(ledgerInfo.getCustomerShortName())) {
  1064 + continue;
  1065 + }
  1066 + BigDecimal startAccountReceivable = ledgerInfo.getStartAccountReceivable();
  1067 + String debtStatus = ledgerInfo.getDebtStatus();
  1068 + if ("FIRST_COORDINATE".equals(debtStatus)) {
  1069 + firstCoordinate = firstCoordinate.add(startAccountReceivable);
  1070 + }
  1071 + }
  1072 + if (firstCoordinate.add(agreement).compareTo(debtTotal) >= 0) {
  1073 + BigDecimal difference = debtTotal.subtract(agreement);
  1074 + report.setAgreementTotal(valueConvert(agreement));
  1075 + report.setFirstCoordinateTotal(valueConvert(difference));
  1076 + report.setTimingStatus("超期1");
  1077 + return;
  1078 + }
  1079 + // 二次协调欠款
  1080 + BigDecimal secondCoordinate = BigDecimal.ZERO;
  1081 + for (ReceiptLedgerInfo ledgerInfo : ledgerInfoList) {
  1082 + String customerShortName = report.getCustomerShortName();
  1083 + if (!customerShortName.equals(ledgerInfo.getCustomerShortName())) {
  1084 + continue;
  1085 + }
  1086 + BigDecimal startAccountReceivable = ledgerInfo.getStartAccountReceivable();
  1087 + String debtStatus = ledgerInfo.getDebtStatus();
  1088 + if ("SECOND_COORDINATE".equals(debtStatus)) {
  1089 + secondCoordinate = secondCoordinate.add(startAccountReceivable);
  1090 + }
  1091 + }
  1092 + BigDecimal secondCoordinateDifference = debtTotal.subtract(agreement).subtract(firstCoordinate);
  1093 + if (secondCoordinate.add(firstCoordinate).add(agreement).compareTo(debtTotal) >= 0) {
  1094 + report.setAgreementTotal(valueConvert(agreement));
  1095 + report.setFirstCoordinateTotal(valueConvert(firstCoordinate));
  1096 + report.setSecondCoordinateTotal(valueConvert(secondCoordinateDifference));
  1097 + report.setTimingStatus("超期2");
  1098 + return;
  1099 + }
  1100 + // 清欠阶段欠款
  1101 + BigDecimal clearDebt = BigDecimal.ZERO;
  1102 + for (ReceiptLedgerInfo ledgerInfo : ledgerInfoList) {
  1103 + String customerShortName = report.getCustomerShortName();
  1104 + if (!customerShortName.equals(ledgerInfo.getCustomerShortName())) {
  1105 + continue;
  1106 + }
  1107 + BigDecimal startAccountReceivable = ledgerInfo.getStartAccountReceivable();
  1108 + String debtStatus = ledgerInfo.getDebtStatus();
  1109 + if ("CLEAR_DEBTS".equals(debtStatus)) {
  1110 + clearDebt = clearDebt.add(startAccountReceivable);
  1111 + }
  1112 + }
  1113 + report.setAgreementTotal(valueConvert(agreement));
  1114 + report.setFirstCoordinateTotal(valueConvert(firstCoordinate));
  1115 + report.setSecondCoordinateTotal(valueConvert(secondCoordinate));
  1116 + report.setTimingStatus("超期3");
  1117 + if (clearDebt.add(secondCoordinate).add(firstCoordinate).add(agreement).compareTo(debtTotal) >= 0) {
  1118 + BigDecimal difference = secondCoordinateDifference.subtract(secondCoordinate);
  1119 + report.setClearDebtTotal(valueConvert(difference));
  1120 + } else {
  1121 + report.setClearDebtTotal(valueConvert(clearDebt));
  1122 + }
  1123 + }
  1124 +
  1125 + /**
  1126 + * 获取约定内欠款小计
  1127 + *
  1128 + * @param ledgerInfoList 应收款台账明细数据
  1129 + * @param report 报表数据
  1130 + * @return BigDecimal
  1131 + */
  1132 + private static BigDecimal getAgreementDebt(List<ReceiptLedgerInfo> ledgerInfoList, ReceiptLedgerReportBo report) {
  1133 + BigDecimal agreement = BigDecimal.ZERO;
  1134 + for (ReceiptLedgerInfo ledgerInfo : ledgerInfoList) {
  1135 + String customerShortName = report.getCustomerShortName();
  1136 + if (!customerShortName.equals(ledgerInfo.getCustomerShortName())) {
  1137 + continue;
  1138 + }
  1139 + BigDecimal startAccountReceivable = ledgerInfo.getStartAccountReceivable();
  1140 + String debtStatus = ledgerInfo.getDebtStatus();
  1141 + if ("AGREEMENT".equals(debtStatus) || "SETTLE_UP".equals(debtStatus)) {
  1142 + agreement = agreement.add(startAccountReceivable);
  1143 + } else if ("DEPOSIT".equals(debtStatus)) {
  1144 + BigDecimal endAccountReceivable = ledgerInfo.getEndAccountReceivable();
  1145 + agreement = agreement.add(endAccountReceivable.abs());
  1146 + }
  1147 + }
  1148 + return agreement;
1042 } 1149 }
1043 1150
1044 1151
@@ -1099,8 +1206,12 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge @@ -1099,8 +1206,12 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge
1099 } 1206 }
1100 data.setSettleTerm(credit.getCompanySettlementPeriod()); 1207 data.setSettleTerm(credit.getCompanySettlementPeriod());
1101 } 1208 }
1102 - data.setDeptId(deptId);  
1103 - data.setRegion(region); 1209 + if (StringUtils.isNotBlank(deptId) && !deptId.equals("null")) {
  1210 + data.setDeptId(deptId);
  1211 + }
  1212 + if (StringUtils.isNotBlank(region) && !region.equals("null")) {
  1213 + data.setRegion(region);
  1214 + }
1104 data.setCustomerId(shipmentsOrderInfo.getCustomerId()); 1215 data.setCustomerId(shipmentsOrderInfo.getCustomerId());
1105 data.setShipmentDate(shipmentsOrderInfo.getShipmentsDate()); 1216 data.setShipmentDate(shipmentsOrderInfo.getShipmentsDate());
1106 1217
@@ -7,6 +7,7 @@ import com.lframework.xingyun.sc.vo.ledger.receipt.QueryReceiptLedgerInfoVo; @@ -7,6 +7,7 @@ import com.lframework.xingyun.sc.vo.ledger.receipt.QueryReceiptLedgerInfoVo;
7 import com.lframework.xingyun.sc.vo.ledger.receipt.ReceiptLedgerReportVo; 7 import com.lframework.xingyun.sc.vo.ledger.receipt.ReceiptLedgerReportVo;
8 import org.apache.ibatis.annotations.Param; 8 import org.apache.ibatis.annotations.Param;
9 9
  10 +import java.time.LocalDateTime;
10 import java.util.List; 11 import java.util.List;
11 import java.util.Map; 12 import java.util.Map;
12 13
@@ -57,7 +58,7 @@ public interface ReceiptLedgerInfoMapper extends BaseMapper<ReceiptLedgerInfo> { @@ -57,7 +58,7 @@ public interface ReceiptLedgerInfoMapper extends BaseMapper<ReceiptLedgerInfo> {
57 * @return List<Map<String, BigDecimal>> 58 * @return List<Map<String, BigDecimal>>
58 */ 59 */
59 List<Map<String, Object>> statisticsDebtByShortName(@Param("shortNames") List<String> shortNames, @Param("debtStatusList") List<String> debtStatusList 60 List<Map<String, Object>> statisticsDebtByShortName(@Param("shortNames") List<String> shortNames, @Param("debtStatusList") List<String> debtStatusList
60 - , @Param("type") String type); 61 + , @Param("type") String type, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
61 62
62 /** 63 /**
63 * 根据客户简称获取台账明细数据 64 * 根据客户简称获取台账明细数据
@@ -87,6 +87,9 @@ public class QueryReceiptLedgerInfoVo extends PageVo implements BaseVo, Serializ @@ -87,6 +87,9 @@ public class QueryReceiptLedgerInfoVo extends PageVo implements BaseVo, Serializ
87 @ApiModelProperty("厂别") 87 @ApiModelProperty("厂别")
88 private String factoryType; 88 private String factoryType;
89 89
  90 + /**
  91 + * 欠款状态
  92 + */
90 @ApiModelProperty("欠款状态") 93 @ApiModelProperty("欠款状态")
91 private String debtStatus; 94 private String debtStatus;
92 95
@@ -7,6 +7,7 @@ import lombok.Data; @@ -7,6 +7,7 @@ import lombok.Data;
7 7
8 import java.io.Serializable; 8 import java.io.Serializable;
9 import java.math.BigDecimal; 9 import java.math.BigDecimal;
  10 +import java.time.LocalDateTime;
10 11
11 @Data 12 @Data
12 public class ReceiptLedgerReportVo extends PageVo implements BaseVo, Serializable { 13 public class ReceiptLedgerReportVo extends PageVo implements BaseVo, Serializable {
@@ -54,4 +55,16 @@ public class ReceiptLedgerReportVo extends PageVo implements BaseVo, Serializabl @@ -54,4 +55,16 @@ public class ReceiptLedgerReportVo extends PageVo implements BaseVo, Serializabl
54 */ 55 */
55 @ApiModelProperty("导出类型") 56 @ApiModelProperty("导出类型")
56 private String exportType; 57 private String exportType;
  58 +
  59 + /**
  60 + * 开始时间
  61 + */
  62 + @ApiModelProperty("开始时间")
  63 + private LocalDateTime startTime;
  64 +
  65 + /**
  66 + * 结束时间
  67 + */
  68 + @ApiModelProperty("结束时间")
  69 + private LocalDateTime endTime;
57 } 70 }
@@ -237,9 +237,11 @@ @@ -237,9 +237,11 @@
237 left join sys_dept d on tb.dept_id = d.id 237 left join sys_dept d on tb.dept_id = d.id
238 left join sys_dept r on tb.region = r.id 238 left join sys_dept r on tb.region = r.id
239 left join customer_credit cc on tb.customer_id = cc.company_id 239 left join customer_credit cc on tb.customer_id = cc.company_id
240 - left join receipt_ledger_info rl on tb.id = rl.customer_short_id 240 + left join receipt_ledger_info rl on tb.id = rl.customer_short_id and rl.del_flag = false
241 <where> 241 <where>
242 and rl.type = 'INSIDE' 242 and rl.type = 'INSIDE'
  243 + -- 只统计当月数据
  244 + and rl.create_time >= #{vo.startTime} and rl.create_time &lt;= #{vo.endTime}
243 <if test="vo.customerType != null and vo.customerType != ''"> 245 <if test="vo.customerType != null and vo.customerType != ''">
244 and tb.type = #{vo.customerType} 246 and tb.type = #{vo.customerType}
245 </if> 247 </if>
@@ -269,6 +271,9 @@ @@ -269,6 +271,9 @@
269 inner join base_data_customer_short cs on tb.customer_id = cs.customer_id 271 inner join base_data_customer_short cs on tb.customer_id = cs.customer_id
270 inner join base_data_customer c on tb.customer_id = c.id 272 inner join base_data_customer c on tb.customer_id = c.id
271 <where> 273 <where>
  274 + and tb.del_flag = false
  275 + -- 只统计当月数据
  276 + and tb.create_time >= #{startTime} and tb.create_time &lt;= #{endTime}
272 <if test="type != null and type != ''"> 277 <if test="type != null and type != ''">
273 and tb.type = #{type} 278 and tb.type = #{type}
274 </if> 279 </if>
@@ -292,6 +297,7 @@ @@ -292,6 +297,7 @@
292 from receipt_ledger_info tb 297 from receipt_ledger_info tb
293 left join base_data_customer_short cs on tb.customer_id = cs.customer_id 298 left join base_data_customer_short cs on tb.customer_id = cs.customer_id
294 <where> 299 <where>
  300 + and tb.del_flag = false
295 <if test="type != null and type != ''"> 301 <if test="type != null and type != ''">
296 and tb.type = #{type} 302 and tb.type = #{type}
297 </if> 303 </if>