This commit is contained in:
Lemon
2025-04-15 10:17:43 +08:00
parent 2ec926c0e7
commit 9c3eac914c
3 changed files with 75 additions and 42 deletions

View File

@@ -257,7 +257,7 @@ public class OrderBasicInfoController extends BaseController {
* 根据汇付会员id查询分账汇总数据 * 根据汇付会员id查询分账汇总数据
* @return * @return
*/ */
@PostMapping @PostMapping("/queryStationAggregateData")
public RestApiResponse<?> queryStationAggregateData(@RequestBody QueryOrderSplitDTO dto) { public RestApiResponse<?> queryStationAggregateData(@RequestBody QueryOrderSplitDTO dto) {
RestApiResponse<?> response = null; RestApiResponse<?> response = null;
try { try {

View File

@@ -365,53 +365,83 @@ public class OrderSplitRecordServiceImpl implements OrderSplitRecordService {
//根据分组进行分账信息的汇总 //根据分组进行分账信息的汇总
List<SplitConfigOrderVO> resultList = Lists.newArrayList(); List<SplitConfigOrderVO> resultList = Lists.newArrayList();
for (Map.Entry<String, List<SplitConfigStationVO>> entry : collect.entrySet()) { for (Map.Entry<String, List<SplitConfigStationVO>> entry : collect.entrySet()) {
String stationId = entry.getKey(); String stationId = entry.getKey();
List<SplitConfigStationVO> splitConfigStationVOList = entry.getValue(); List<SplitConfigStationVO> splitConfigStationVOList = entry.getValue();
//计算时间范围 // //计算时间范围
List<SplitConfigStationVO> sortedList = splitConfigStationVOList.stream() // List<SplitConfigStationVO> sortedList = splitConfigStationVOList.stream()
.sorted(Comparator.comparing(SplitConfigStationVO::getTradeDate)) // .sorted(Comparator.comparing(SplitConfigStationVO::getTradeDate))
.collect(Collectors.toList()); // .collect(Collectors.toList());
String startTime = sortedList.get(0).getTradeDate(); // String startTime = sortedList.get(0).getTradeDate();
String endTime = sortedList.get(sortedList.size() - 1).getTradeDate(); // String endTime = sortedList.get(sortedList.size() - 1).getTradeDate();
String timeRange = startTime + "" + endTime; String timeRange = dto.getStartTime() + "" + dto.getEndTime();
//总的电费分账金额totalElectricitySplitAmount BigDecimal totalElectricitySplitAmount = BigDecimal.ZERO;
BigDecimal totalElectricitySplitAmount = BigDecimal totalServiceSplitAmount = BigDecimal.ZERO;
splitConfigStationVOList.stream() BigDecimal totalFeeAmount = BigDecimal.ZERO;
.map(SplitConfigStationVO::getElectricityAmount) for (SplitConfigStationVO splitConfigStationVO : splitConfigStationVOList) {
.filter(Objects::nonNull) //过滤掉null // 总电费分账金额
.reduce(BigDecimal.ZERO, BigDecimal::add); totalElectricitySplitAmount = totalElectricitySplitAmount.add(splitConfigStationVO.getElectricityAmount());
//总服务费分账金额totalServiceSplitAmount // 总服务费分账金额
BigDecimal totalServiceSplitAmount = totalServiceSplitAmount = totalServiceSplitAmount.add(splitConfigStationVO.getServiceAmount());
splitConfigStationVOList.stream() // 总手续费
.map(SplitConfigStationVO::getServiceAmount) totalFeeAmount = totalFeeAmount.add(splitConfigStationVO.getFeeAmount());
.filter(Objects::nonNull) }
.reduce(BigDecimal.ZERO, BigDecimal::add);
//总手续费分账金额totalFeeAmount
BigDecimal totalFeeAmount =
splitConfigStationVOList.stream()
.map(SplitConfigStationVO::getFeeAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
//总收入分账金额= 总电费分账金额 +总手续费分账金额 -总手续费分账金额 // 总收入
BigDecimal totalRevenueAmount = totalElectricitySplitAmount.add(totalServiceSplitAmount).subtract(totalFeeAmount); BigDecimal totalRevenueAmount = totalElectricitySplitAmount.add(totalServiceSplitAmount).subtract(totalFeeAmount);
SplitConfigOrderVO splitConfigOrderVO =
SplitConfigOrderVO.builder() SplitConfigOrderVO vo = SplitConfigOrderVO.builder()
.stationId(stationId) .stationId(stationId)
.stationName(splitConfigStationVOList.get(0).getStationName()) .stationName(splitConfigStationVOList.get(0).getStationName())
.orderCount(splitConfigStationVOList.size())
.timeRange(timeRange)
.totalElectricitySplitAmount(totalElectricitySplitAmount) .totalElectricitySplitAmount(totalElectricitySplitAmount)
.totalServiceSplitAmount(totalServiceSplitAmount) .totalServiceSplitAmount(totalServiceSplitAmount)
.totalFeeAmount(totalFeeAmount) .totalFeeAmount(totalFeeAmount)
.totalRevenueAmount(totalRevenueAmount) .totalRevenueAmount(totalRevenueAmount)
.build(); .orderCount(splitConfigStationVOList.size())
.timeRange(timeRange)
resultList.add(splitConfigOrderVO); .build();
resultList.add(vo);
//总的电费分账金额totalElectricitySplitAmount
// BigDecimal totalElectricitySplitAmount =
// splitConfigStationVOList.stream()
// .map(SplitConfigStationVO::getElectricityAmount)
// .filter(Objects::nonNull) //过滤掉null
// .reduce(BigDecimal.ZERO, BigDecimal::add);
// //总的服务费分账金额totalServiceSplitAmount
// BigDecimal totalServiceSplitAmount =
// splitConfigStationVOList.stream()
// .map(SplitConfigStationVO::getServiceAmount)
// .filter(Objects::nonNull)
// .reduce(BigDecimal.ZERO, BigDecimal::add);
// //总手续费分账金额totalFeeAmount
// BigDecimal totalFeeAmount =
// splitConfigStationVOList.stream()
// .map(SplitConfigStationVO::getFeeAmount)
// .filter(Objects::nonNull)
// .reduce(BigDecimal.ZERO, BigDecimal::add);
//
// //总收入分账金额= 总电费分账金额 +总手续费分账金额 -总手续费分账金额
// BigDecimal totalRevenueAmount = totalElectricitySplitAmount.add(totalServiceSplitAmount).subtract(totalFeeAmount);
// SplitConfigOrderVO splitConfigOrderVO =
// SplitConfigOrderVO.builder()
// .stationId(stationId)
// .stationName(splitConfigStationVOList.get(0).getStationName())
// .orderCount(splitConfigStationVOList.size())
// .timeRange(timeRange)
// .totalElectricitySplitAmount(totalElectricitySplitAmount)
// .totalServiceSplitAmount(totalServiceSplitAmount)
// .totalFeeAmount(totalFeeAmount)
// .totalRevenueAmount(totalRevenueAmount)
// .build();
//
// resultList.add(splitConfigOrderVO);
} }
return resultList; return resultList;
} }

View File

@@ -874,7 +874,10 @@
WHERE WHERE
t1.adapay_member_id = #{adapayMemberId} t1.adapay_member_id = #{adapayMemberId}
AND t1.del_flag = '0' AND t1.del_flag = '0'
AND t1.trade_date BETWEEN #{startTime,jdbcType=VARCHAR} AND #{endTime,jdbcType=VARCHAR}; AND t1.trade_date BETWEEN #{startTime,jdbcType=VARCHAR} AND #{endTime,jdbcType=VARCHAR}
<if test="dto.stationId != null and dto.stationId != ''" >
and t1.station_id = #{dto.stationId,jdbcType=VARCHAR}
</if>
</select> </select>
</mapper> </mapper>