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 = dto.getStartTime() + "" + dto.getEndTime();
BigDecimal totalElectricitySplitAmount = BigDecimal.ZERO;
BigDecimal totalServiceSplitAmount = BigDecimal.ZERO;
BigDecimal totalFeeAmount = BigDecimal.ZERO;
for (SplitConfigStationVO splitConfigStationVO : splitConfigStationVOList) {
// 总电费分账金额
totalElectricitySplitAmount = totalElectricitySplitAmount.add(splitConfigStationVO.getElectricityAmount());
// 总服务费分账金额
totalServiceSplitAmount = totalServiceSplitAmount.add(splitConfigStationVO.getServiceAmount());
// 总手续费
totalFeeAmount = totalFeeAmount.add(splitConfigStationVO.getFeeAmount());
}
// 总收入
BigDecimal totalRevenueAmount = totalElectricitySplitAmount.add(totalServiceSplitAmount).subtract(totalFeeAmount);
SplitConfigOrderVO vo = SplitConfigOrderVO.builder()
.stationId(stationId)
.stationName(splitConfigStationVOList.get(0).getStationName())
.totalElectricitySplitAmount(totalElectricitySplitAmount)
.totalServiceSplitAmount(totalServiceSplitAmount)
.totalFeeAmount(totalFeeAmount)
.totalRevenueAmount(totalRevenueAmount)
.orderCount(splitConfigStationVOList.size())
.timeRange(timeRange)
.build();
resultList.add(vo);
String timeRange = startTime + "" + endTime;
//总的电费分账金额totalElectricitySplitAmount //总的电费分账金额totalElectricitySplitAmount
BigDecimal totalElectricitySplitAmount = // BigDecimal totalElectricitySplitAmount =
splitConfigStationVOList.stream() // splitConfigStationVOList.stream()
.map(SplitConfigStationVO::getElectricityAmount) // .map(SplitConfigStationVO::getElectricityAmount)
.filter(Objects::nonNull) //过滤掉null // .filter(Objects::nonNull) //过滤掉null
.reduce(BigDecimal.ZERO, BigDecimal::add); // .reduce(BigDecimal.ZERO, BigDecimal::add);
//总的服务费分账金额totalServiceSplitAmount // //总的服务费分账金额totalServiceSplitAmount
BigDecimal totalServiceSplitAmount = // BigDecimal totalServiceSplitAmount =
splitConfigStationVOList.stream() // splitConfigStationVOList.stream()
.map(SplitConfigStationVO::getServiceAmount) // .map(SplitConfigStationVO::getServiceAmount)
.filter(Objects::nonNull) // .filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add); // .reduce(BigDecimal.ZERO, BigDecimal::add);
//总手续费分账金额totalFeeAmount // //总手续费分账金额totalFeeAmount
BigDecimal totalFeeAmount = // BigDecimal totalFeeAmount =
splitConfigStationVOList.stream() // splitConfigStationVOList.stream()
.map(SplitConfigStationVO::getFeeAmount) // .map(SplitConfigStationVO::getFeeAmount)
.filter(Objects::nonNull) // .filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add); // .reduce(BigDecimal.ZERO, BigDecimal::add);
//
//总收入分账金额= 总电费分账金额 +总手续费分账金额 -总手续费分账金额 // //总收入分账金额= 总电费分账金额 +总手续费分账金额 -总手续费分账金额
BigDecimal totalRevenueAmount = totalElectricitySplitAmount.add(totalServiceSplitAmount).subtract(totalFeeAmount); // BigDecimal totalRevenueAmount = totalElectricitySplitAmount.add(totalServiceSplitAmount).subtract(totalFeeAmount);
SplitConfigOrderVO splitConfigOrderVO = // SplitConfigOrderVO splitConfigOrderVO =
SplitConfigOrderVO.builder() // SplitConfigOrderVO.builder()
.stationId(stationId) // .stationId(stationId)
.stationName(splitConfigStationVOList.get(0).getStationName()) // .stationName(splitConfigStationVOList.get(0).getStationName())
.orderCount(splitConfigStationVOList.size()) // .orderCount(splitConfigStationVOList.size())
.timeRange(timeRange) // .timeRange(timeRange)
.totalElectricitySplitAmount(totalElectricitySplitAmount) // .totalElectricitySplitAmount(totalElectricitySplitAmount)
.totalServiceSplitAmount(totalServiceSplitAmount) // .totalServiceSplitAmount(totalServiceSplitAmount)
.totalFeeAmount(totalFeeAmount) // .totalFeeAmount(totalFeeAmount)
.totalRevenueAmount(totalRevenueAmount) // .totalRevenueAmount(totalRevenueAmount)
.build(); // .build();
//
resultList.add(splitConfigOrderVO); // 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>