diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderSplitRecordServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderSplitRecordServiceImpl.java index 627fabb22..02d2d7dc0 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderSplitRecordServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderSplitRecordServiceImpl.java @@ -33,6 +33,7 @@ import com.jsowell.pile.service.OrderSplitRecordService; import com.jsowell.pile.service.PileMerchantInfoService; import com.jsowell.pile.vo.OrderInfoDetailVO; import com.jsowell.pile.vo.web.*; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -42,6 +43,7 @@ import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; +@Slf4j @Service public class OrderSplitRecordServiceImpl implements OrderSplitRecordService { @@ -158,7 +160,19 @@ public class OrderSplitRecordServiceImpl implements OrderSplitRecordService { return Lists.newArrayList(); } // 根据入参拉出时间段内所有订单的分账记录 - return orderSplitRecordMapper.queryOrderSplitDataList(merchantId, stationId, startTime, endTime); + List orderSplitRecords = orderSplitRecordMapper.queryOrderSplitDataList(merchantId, stationId, startTime, endTime); + log.info("根据入参拉出时间段内所有订单的分账记录, merchantId:{}, stationId:{}, startTime:{}, endTime:{}", + merchantId, stationId, startTime, endTime); + // orderSplitRecords中电费分账金额与服务费分账金额为null, 设置0 + for (OrderSplitRecord orderSplitRecord : orderSplitRecords) { + if (orderSplitRecord.getElectricitySplitAmount() == null) { + orderSplitRecord.setElectricitySplitAmount(BigDecimal.ZERO); + } + if (orderSplitRecord.getServiceSplitAmount() == null) { + orderSplitRecord.setServiceSplitAmount(BigDecimal.ZERO); + } + } + return orderSplitRecords; } /** diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/SettleOrderReportServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/SettleOrderReportServiceImpl.java index a97bee1fd..74a117827 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/SettleOrderReportServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/SettleOrderReportServiceImpl.java @@ -680,7 +680,8 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService { log.info("站点:{}, 在{}-{}查询到订单数据{}条,订单编号:{}", stationInfo.getStationName(), startTime, endTime, orderListVOS.size(), collect); // 根据入参拉出时间段内所有订单的分账记录 - List orderSplitRecords = orderSplitRecordService.queryOrderSplitRecordList(stationInfo.getMerchantId(), stationId, startTime, endTime); + List orderSplitRecords = orderSplitRecordService.queryOrderSplitRecordList(stationInfo.getMerchantId(), stationId, tradeDate, tradeDate); + log.info("查分账记录,站点:{}, 在{}-{}查询到分账数据{}条", stationInfo.getStationName(), startTime, endTime, orderSplitRecords.size()); // orderSplitRecords转为map, key为订单编号, value为分账记录 Map splitRecordMap = orderSplitRecords.stream().collect(Collectors.toMap(OrderSplitRecord::getOrderCode, v -> v)); @@ -741,16 +742,21 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService { // 电费金额, 如果splitRecordMap中存在,取Rrecord.getElectricitySplitAmount(), 如果不存在取vo.getTotalElectricityAmount() OrderSplitRecord record = splitRecordMap.get(vo.getOrderCode()); - BigDecimal electricityAmount = record != null - ? record.getElectricitySplitAmount() - : vo.getTotalElectricityAmount() != null ? vo.getTotalElectricityAmount() : BigDecimal.ZERO; + BigDecimal electricityAmount; + BigDecimal serviceAmount; // BigDecimal e = vo.getTotalElectricityAmount() != null ? vo.getTotalElectricityAmount() : BigDecimal.ZERO; + if (record != null) { + electricityAmount = record.getElectricitySplitAmount() != null ? record.getElectricitySplitAmount() : BigDecimal.ZERO; + serviceAmount = record.getServiceSplitAmount() != null ? record.getServiceSplitAmount() : BigDecimal.ZERO; + log.info("record订单编号:{}, 订单金额:{}, 电费金额:{}, 服务费金额:{}", vo.getOrderCode(), orderAmount, electricityAmount, serviceAmount); + } else { + electricityAmount = vo.getTotalElectricityAmount() != null ? vo.getTotalElectricityAmount() : BigDecimal.ZERO; + serviceAmount = vo.getTotalServiceAmount() != null ? vo.getTotalServiceAmount() : BigDecimal.ZERO; + log.info("vo订单编号:{}, 订单金额:{}, 电费金额:{}, 服务费金额:{}", vo.getOrderCode(), orderAmount, electricityAmount, serviceAmount); + } totalElectricityAmount = totalElectricityAmount.add(electricityAmount); // 服务费金额,如果splitRecordMap中存在,取Rrecord.getElectricitySplitAmount(), 如果不存在取vo.getTotalElectricityAmount() - BigDecimal serviceAmount = record != null - ? record.getServiceSplitAmount() - : vo.getTotalServiceAmount() != null ? vo.getTotalServiceAmount() : BigDecimal.ZERO; // BigDecimal serviceAmount = vo.getTotalServiceAmount() != null ? vo.getTotalServiceAmount() : BigDecimal.ZERO; totalServiceAmount = totalServiceAmount.add(serviceAmount);