|
|
@@ -14,7 +14,6 @@ import com.qtzl.alterSales.dao.repo.jpa.second.AflServerFeeRefundRepo; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.UcServiceError; |
|
|
|
import com.qtzl.alterSales.manager.service.third.ConstantConfig; |
|
|
|
import com.qtzl.alterSales.manager.service.third.FmsService; |
|
|
|
import com.qtzl.alterSales.manager.vo.WechatPayApplyLogGroupByTimeCountVO; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
@@ -90,36 +89,33 @@ public class AflCommissionReportExportServiceImpl implements AflCommissionReport |
|
|
|
int endDateInt = convertToInteger(endDate); |
|
|
|
List<AflMchStatistics> aflMchStatistics = Optional.ofNullable(aflMchStatisticsRepo.findBySubMchIdAndStatisticalDateRange(subMchId, startDateInt, endDateInt)).orElse(Collections.emptyList()); |
|
|
|
|
|
|
|
|
|
|
|
ExcelHeadCommissionVO vo = new ExcelHeadCommissionVO(); |
|
|
|
vo.setIndex(indexSer.getAndIncrement()); |
|
|
|
WechatPayApplyLogGroupByTimeCountVO orderCountVo = Optional.ofNullable(wechatPayApplyResultLogRepo.countByYearMonth(String.valueOf(e))).orElse(new WechatPayApplyLogGroupByTimeCountVO()); |
|
|
|
long count = Optional.ofNullable(wechatPayApplyResultLogRepo.countByYearMonth(String.valueOf(e))).orElse(0L); |
|
|
|
|
|
|
|
String yearAndMonthFormat = year + "-" + month; |
|
|
|
WechatPayApplyLogGroupByTimeCountVO refundOrderCountVo = Optional.ofNullable(aflServerFeeRefundRepo.countByYearMonth(yearAndMonthFormat)).orElse(new WechatPayApplyLogGroupByTimeCountVO()); |
|
|
|
long refundCount = Optional.ofNullable(aflServerFeeRefundRepo.countByYearMonth(yearAndMonthFormat)).orElse(0L); |
|
|
|
|
|
|
|
// 当月订单总数 |
|
|
|
Long orderNum = Optional.ofNullable(orderCountVo.getCount()).orElse(0L); |
|
|
|
// 退费订单总数 |
|
|
|
Long refundOrderNum = Optional.ofNullable(refundOrderCountVo.getCount()).orElse(0L); |
|
|
|
// 实际用户订单数 actualUserNum = orderNum - refundOrderNum |
|
|
|
long actualUserCount = orderNum - refundOrderNum; |
|
|
|
long actualUserCount = count - refundCount; |
|
|
|
|
|
|
|
// 手续费总额. 服务费即为手续费 |
|
|
|
BigDecimal serviceFee = aflMchStatistics.stream().map(AflMchStatistics::getTotalServiceFee).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP); |
|
|
|
// 50元服务费的服务费 |
|
|
|
BigDecimal serviceFee = aflMchStatistics.stream().filter(v -> v.getFeeType().contains("服务费")).map(AflMchStatistics::getTotalServiceFee).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP); |
|
|
|
// 通行费的服务费 |
|
|
|
BigDecimal toll = aflMchStatistics.stream().filter(v -> v.getFeeType().contains("通行费")).map(AflMchStatistics::getTotalServiceFee).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
// 比亚迪手续费 |
|
|
|
BigDecimal bydChannelFee = BigDecimal.valueOf(actualUserCount * 20.5 * 0.001).setScale(2, RoundingMode.HALF_UP); |
|
|
|
// 晟安通手续费 |
|
|
|
BigDecimal satChannelFee = BigDecimal.valueOf(actualUserCount * 13.7 * 0.001).setScale(2, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
// 手续费总额 - 比亚迪手续费 - 晟安通手续费 = 黔通手续费 |
|
|
|
// 50元服务费的手续费总额 - 比亚迪手续费 - 晟安通手续费 = 黔通手续费 |
|
|
|
BigDecimal qtChannelFee = serviceFee.subtract(bydChannelFee).subtract(satChannelFee).setScale(2, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
vo.setSatChannelFee(satChannelFee); |
|
|
|
vo.setSatChannelFee(satChannelFee.add(toll)); |
|
|
|
vo.setBdyChannelFee(bydChannelFee); |
|
|
|
vo.setQtChannelFee(qtChannelFee); |
|
|
|
vo.setChannelFee(serviceFee); |
|
|
|
vo.setChannelFee(serviceFee.add(toll)); |
|
|
|
vo.setYear(year); |
|
|
|
vo.setMonth(month); |
|
|
|
vo.setRemark(""); |