|
|
@@ -1,27 +1,55 @@
|
|
|
package com.sqx.modules.reconciliation.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.sqx.common.constant.RedisKey;
|
|
|
import com.sqx.common.utils.DateUtils;
|
|
|
import com.sqx.common.utils.PageUtils;
|
|
|
-import com.sqx.modules.errand.entity.TbIndent;
|
|
|
-import com.sqx.modules.pay.entity.CashOut;
|
|
|
-import com.sqx.modules.reconciliation.model.PlatformBill;
|
|
|
+import com.sqx.modules.app.entity.UserEntity;
|
|
|
+import com.sqx.modules.errand.service.UserInfoService;
|
|
|
+import com.sqx.modules.goods.entity.GoodsShop;
|
|
|
+import com.sqx.modules.goods.service.GoodsShopService;
|
|
|
import com.sqx.modules.reconciliation.mapper.PlatformBillMapper;
|
|
|
+import com.sqx.modules.reconciliation.model.CashOutRecordBO;
|
|
|
+import com.sqx.modules.reconciliation.model.IndentOrderDataBO;
|
|
|
+import com.sqx.modules.reconciliation.model.OrderDataBO;
|
|
|
+import com.sqx.modules.reconciliation.model.PlatformBill;
|
|
|
import com.sqx.modules.reconciliation.model.PlatformBillDto;
|
|
|
import com.sqx.modules.reconciliation.model.RiderBillVo;
|
|
|
import com.sqx.modules.reconciliation.model.ShopBillVo;
|
|
|
+import com.sqx.modules.reconciliation.model.ShopMoneyRecordBO;
|
|
|
+import com.sqx.modules.reconciliation.model.SysGiftRecordBO;
|
|
|
+import com.sqx.modules.reconciliation.model.UserMoneyBalanceBO;
|
|
|
import com.sqx.modules.reconciliation.service.PlatformBillService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.sqx.modules.utils.excel.ExcelData;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.redisson.api.RLock;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.PlatformTransactionManager;
|
|
|
+import org.springframework.transaction.TransactionStatus;
|
|
|
+import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.function.ToIntFunction;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -33,8 +61,71 @@ import java.util.List;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
public class PlatformBillServiceImpl extends ServiceImpl<PlatformBillMapper, PlatformBill> implements PlatformBillService {
|
|
|
|
|
|
+ private final GoodsShopService goodsShopService;
|
|
|
+ private final UserInfoService userInfoService;
|
|
|
+ private final RedissonClient redissonClient;
|
|
|
+ private final PlatformTransactionManager transactionManager;
|
|
|
+
|
|
|
+ private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void generatePlatformBill(LocalDate date, boolean cover) {
|
|
|
+ RLock lock = redissonClient.getLock(RedisKey.PLATFORM_BILL_LOCK);
|
|
|
+ lock.lock();
|
|
|
+ TransactionStatus status = null;
|
|
|
+ try {
|
|
|
+ // 开启编程式事务
|
|
|
+ status = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
|
|
+
|
|
|
+ // 判断有无当天数据,然后根据策略觉得是否执行覆盖数据还是直接退出
|
|
|
+ LambdaQueryWrapper<PlatformBill> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(PlatformBill::getDayId, date);
|
|
|
+ if (count(wrapper) > 0) {
|
|
|
+ if (cover) {
|
|
|
+ // 删除旧数据
|
|
|
+ remove(wrapper);
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询前一天账单
|
|
|
+ LambdaQueryWrapper<PlatformBill> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PlatformBill::getDayId, date.minusDays(1));
|
|
|
+ queryWrapper.eq(PlatformBill::getType, "1");
|
|
|
+ List<PlatformBill> prePlatformBillDataS = list(queryWrapper);
|
|
|
+ Map<Long, PlatformBill> platformBillMap = prePlatformBillDataS.stream().collect(Collectors.toMap(PlatformBill::getUserId, Function.identity()));
|
|
|
+
|
|
|
+ // 查询商户数据
|
|
|
+ List<PlatformBill> shopPlatformBills = queryShopBill(date, platformBillMap);
|
|
|
+
|
|
|
+ // 查询骑手数据
|
|
|
+ List<PlatformBill> riderPlatformBills = queryRiderBill(date, platformBillMap);
|
|
|
+
|
|
|
+ // 计算平台账单数据
|
|
|
+ PlatformBill platformBills = calcPlatformBill(date, shopPlatformBills, riderPlatformBills, prePlatformBillDataS);
|
|
|
+
|
|
|
+ // 合并商户、骑手账单数据
|
|
|
+ Collection<PlatformBill> allPlatformBills = CollUtil.union(shopPlatformBills, riderPlatformBills, Arrays.asList(platformBills));
|
|
|
+
|
|
|
+ // 保存最终结果
|
|
|
+ saveBatch(allPlatformBills);
|
|
|
+
|
|
|
+ transactionManager.commit(status);
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (ObjectUtil.isNotNull(status)) {
|
|
|
+ transactionManager.rollback(status);
|
|
|
+ }
|
|
|
+
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ lock.unlock();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -247,5 +338,290 @@ public class PlatformBillServiceImpl extends ServiceImpl<PlatformBillMapper, Pla
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算平台账单数据
|
|
|
+ *
|
|
|
+ * @param date 账期
|
|
|
+ * @param shopPlatformBills 商家账单数据
|
|
|
+ * @param riderPlatformBills 骑手账单数据
|
|
|
+ * @param prePlatformBills 前一天对账数据
|
|
|
+ * @return 平台账单数据
|
|
|
+ */
|
|
|
+ private PlatformBill calcPlatformBill(LocalDate date, List<PlatformBill> shopPlatformBills, List<PlatformBill> riderPlatformBills, List<PlatformBill> prePlatformBills) {
|
|
|
+ // 账期
|
|
|
+ String accountPeriod = date.toString();
|
|
|
+
|
|
|
+ PlatformBill platformBill = new PlatformBill();
|
|
|
+ platformBill.setDayId(accountPeriod);
|
|
|
+ // 平台对账
|
|
|
+ platformBill.setType("0");
|
|
|
+
|
|
|
+ Optional<PlatformBill> prePlatformBillOptional = prePlatformBills.stream().filter(e -> "0".equals(e.getType())).findFirst();
|
|
|
+
|
|
|
+ // 初始金额
|
|
|
+ if (prePlatformBillOptional.isPresent()) {
|
|
|
+ platformBill.setStartMoney(prePlatformBillOptional.get().getEndMoney());
|
|
|
+ } else {
|
|
|
+ platformBill.setStartMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 订单总收入
|
|
|
+ platformBill.setRevenue(sum(shopPlatformBills, PlatformBill::getRevenue));
|
|
|
+ // 订单总笔数
|
|
|
+ platformBill.setRevenueCount(sumInt(shopPlatformBills, PlatformBill::getRevenueCount));
|
|
|
+ // 商家总提现金额
|
|
|
+ platformBill.setShopPayouts(sum(shopPlatformBills, PlatformBill::getShopPayouts));
|
|
|
+ // 商家总提现手续费
|
|
|
+ platformBill.setShopPayoutsRates(sum(shopPlatformBills, PlatformBill::getShopPayoutsRates));
|
|
|
+ // 商家提现笔数
|
|
|
+ platformBill.setShopPayoutsCount(sumInt(shopPlatformBills, PlatformBill::getShopPayoutsCount));
|
|
|
+ // 骑手总提现金额
|
|
|
+ platformBill.setRiderPayouts(sum(riderPlatformBills, PlatformBill::getRiderPayouts));
|
|
|
+ // 骑手总提现手续费
|
|
|
+ platformBill.setRiderPayoutsRates(sum(riderPlatformBills, PlatformBill::getRiderPayoutsRates));
|
|
|
+ // 骑手提现笔数
|
|
|
+ platformBill.setRiderPayoutsCount(sumInt(riderPlatformBills, PlatformBill::getRiderPayoutsCount));
|
|
|
+ // 退款金额
|
|
|
+ platformBill.setRefundMoney(sum(shopPlatformBills, PlatformBill::getRefundMoney));
|
|
|
+ // 退款笔数
|
|
|
+ platformBill.setRefundCount(sumInt(shopPlatformBills, PlatformBill::getRefundCount));
|
|
|
+ // 平台抽成手续费
|
|
|
+ platformBill.setPlatformRates(sum(shopPlatformBills, PlatformBill::getPlatformRates));
|
|
|
+ // 截止金额
|
|
|
+ platformBill.setEndMoney(platformBill.getRevenue());
|
|
|
+
|
|
|
+ return platformBill;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询骑手指定日期账单数据
|
|
|
+ * 从跑腿订单中获取:
|
|
|
+ * 收入
|
|
|
+ * 收入笔数
|
|
|
+ * 从提现表中获取
|
|
|
+ * 提现金额
|
|
|
+ * 提现手续费
|
|
|
+ * 提现笔数
|
|
|
+ * 从对账表中获取:
|
|
|
+ * 期初金额:前一天的期末金额
|
|
|
+ * 从用户钱包明细中获取:
|
|
|
+ * 赠送骑手余额
|
|
|
+ * 从用户信息表中获取:
|
|
|
+ * 总收益
|
|
|
+ * 期末金额:等于总收益
|
|
|
+ *
|
|
|
+ * @param date 账单日期
|
|
|
+ * @param platformBillMap 前一天对账数据
|
|
|
+ * @return 骑手对账信息
|
|
|
+ */
|
|
|
+ private List<PlatformBill> queryRiderBill(LocalDate date, Map<Long, PlatformBill> platformBillMap) {
|
|
|
+ // 账期
|
|
|
+ String accountPeriod = date.toString();
|
|
|
+ // 账期开始-截止时间
|
|
|
+ String startTime = DTF.format(date.atTime(0, 0, 0));
|
|
|
+ String endTime = DTF.format(date.atTime(0, 0, 0).plusDays(1));
|
|
|
+
|
|
|
+ // 查询骑手数据
|
|
|
+ List<UserEntity> riderInfos = userInfoService.getAllRiderInfo();
|
|
|
+ List<Long> userIds = riderInfos.stream().map(UserEntity::getUserId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 查询跑腿订单数据
|
|
|
+ List<IndentOrderDataBO> indentOrderDataBOS = baseMapper.getIndentOrderData(startTime, endTime);
|
|
|
+ Map<Long, IndentOrderDataBO> indentOrderDataMap = indentOrderDataBOS.stream().collect(Collectors.toMap(IndentOrderDataBO::getUserId, Function.identity()));
|
|
|
+
|
|
|
+ // 查询提现数据
|
|
|
+ List<CashOutRecordBO> riderCashOutRecords = baseMapper.getCashOutRecord(startTime, endTime, userIds);
|
|
|
+ Map<Long, CashOutRecordBO> riderCashOutRecordMap = riderCashOutRecords.stream().collect(Collectors.toMap(CashOutRecordBO::getUserId, Function.identity()));
|
|
|
+
|
|
|
+ // 查询订单赠送金额数据
|
|
|
+ List<SysGiftRecordBO> sysGiftRecordBOS = baseMapper.getSysGiftRecord(startTime, endTime, userIds);
|
|
|
+ Map<Long, SysGiftRecordBO> sysGiftRecordMap = sysGiftRecordBOS.stream().collect(Collectors.toMap(SysGiftRecordBO::getUserId, Function.identity()));
|
|
|
|
|
|
+ return riderInfos.stream().map(riderInfo -> {
|
|
|
+ PlatformBill platformBill = new PlatformBill();
|
|
|
+ platformBill.setDayId(accountPeriod);
|
|
|
+ platformBill.setUserId(riderInfo.getUserId());
|
|
|
+ // 骑手对账
|
|
|
+ platformBill.setType("2");
|
|
|
+
|
|
|
+ IndentOrderDataBO indentOrderData = indentOrderDataMap.get(riderInfo.getUserId());
|
|
|
+ if (ObjectUtil.isNotNull(indentOrderData)) {
|
|
|
+ platformBill.setRevenue(indentOrderData.getTotalAmount());
|
|
|
+ platformBill.setRevenueCount(indentOrderData.getOrderCount());
|
|
|
+ } else {
|
|
|
+ platformBill.setRevenue(BigDecimal.ZERO);
|
|
|
+ platformBill.setRevenueCount(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ CashOutRecordBO cashOutRecord = riderCashOutRecordMap.get(riderInfo.getUserId());
|
|
|
+ if (ObjectUtil.isNotNull(cashOutRecord)) {
|
|
|
+ platformBill.setRiderPayouts(cashOutRecord.getPayouts());
|
|
|
+ platformBill.setRiderPayoutsRates(cashOutRecord.getPayoutsRates());
|
|
|
+ platformBill.setRiderPayoutsCount(cashOutRecord.getPayoutsCount());
|
|
|
+ } else {
|
|
|
+ platformBill.setRiderPayouts(BigDecimal.ZERO);
|
|
|
+ platformBill.setRiderPayoutsRates(BigDecimal.ZERO);
|
|
|
+ platformBill.setRiderPayoutsCount(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ SysGiftRecordBO sysGiftRecord = sysGiftRecordMap.get(riderInfo.getUserId());
|
|
|
+ if (ObjectUtil.isNotNull(sysGiftRecord)) {
|
|
|
+ platformBill.setSysGiftAmount(sysGiftRecord.getAmount());
|
|
|
+ } else {
|
|
|
+ platformBill.setSysGiftAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ PlatformBill preBill = platformBillMap.get(riderInfo.getUserId());
|
|
|
+ if (ObjectUtil.isNotNull(preBill)) {
|
|
|
+ platformBill.setStartMoney(preBill.getEndMoney());
|
|
|
+ } else {
|
|
|
+ platformBill.setStartMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ platformBill.setTotalIncome(platformBill.getRevenue());
|
|
|
+
|
|
|
+ platformBill.setEndMoney(riderInfo.getBalance());
|
|
|
+
|
|
|
+ return platformBill;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询商家指定日期账单数据
|
|
|
+ * 从订单表中获取(当天数据):
|
|
|
+ * 用户实际付款:当天用户实际付款金额
|
|
|
+ * 退款金额:当天退款金额
|
|
|
+ * 退款笔数:当天退款笔数
|
|
|
+ * 收入:当天商家收入
|
|
|
+ * 收入笔数:当天商家收入笔数
|
|
|
+ * 从商家钱包明细表中获取:
|
|
|
+ * 总收益:当天的入账金额(等于订单表里的商家收入)
|
|
|
+ * 平台抽成手续费:当天平台抽成金额
|
|
|
+ * 从提现表中获取(当天数据):
|
|
|
+ * 提现金额:当天提现金额
|
|
|
+ * 提现手续费:当天提现手续费
|
|
|
+ * 提现笔数:当天提现笔数
|
|
|
+ * 从用户信息表中获取:
|
|
|
+ * 账户余额:截止统计时的用户账户余额
|
|
|
+ * 从平台对账表中获取:
|
|
|
+ * 期初金额:前一天的期末金额
|
|
|
+ * 直接复用:
|
|
|
+ * 期末金额:总收益
|
|
|
+ *
|
|
|
+ * @param date 账单日期
|
|
|
+ * @param platformBillMap 前一天账单数据
|
|
|
+ * @return 商家对账单信息
|
|
|
+ */
|
|
|
+ private List<PlatformBill> queryShopBill(LocalDate date, Map<Long, PlatformBill> platformBillMap) {
|
|
|
+ // 账期
|
|
|
+ String accountPeriod = date.toString();
|
|
|
+ // 账期开始-截止时间
|
|
|
+ String startTime = DTF.format(date.atTime(0, 0, 0));
|
|
|
+ String endTime = DTF.format(date.atTime(0, 0, 0).plusDays(1));
|
|
|
+
|
|
|
+ // 获取店铺信息
|
|
|
+ List<GoodsShop> goodsShops = goodsShopService.getAllShops();
|
|
|
+ List<Long> userIds = goodsShops.stream().map(GoodsShop::getUserId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 统计订单信息
|
|
|
+ List<OrderDataBO> orderDataBOs = baseMapper.getOrderData(startTime, endTime);
|
|
|
+ Map<Long, OrderDataBO> orderDataMap = orderDataBOs.stream().collect(Collectors.toMap(OrderDataBO::getShopId, Function.identity()));
|
|
|
+
|
|
|
+ // 查询当天平台抽成 抽成数据在user_money_details表中,订单完成时会计算商家收入、平台抽成
|
|
|
+ List<ShopMoneyRecordBO> shopMoneyRecords = baseMapper.getShopMoneyRecord(startTime, endTime);
|
|
|
+ Map<Long, ShopMoneyRecordBO> shopMoneryRecordMap = shopMoneyRecords.stream().collect(Collectors.toMap(ShopMoneyRecordBO::getShopId, Function.identity()));
|
|
|
+
|
|
|
+ // 查询所有商家提现记录
|
|
|
+ List<CashOutRecordBO> shopCashOutRecords = baseMapper.getCashOutRecord(startTime, endTime, userIds);
|
|
|
+ Map<Long, CashOutRecordBO> cashOutRecordMap = shopCashOutRecords.stream().collect(Collectors.toMap(CashOutRecordBO::getUserId, Function.identity()));
|
|
|
+
|
|
|
+ // 查询商户余额
|
|
|
+ List<UserMoneyBalanceBO> userMoneyBalances = baseMapper.getUserMoneyBalance(userIds);
|
|
|
+ Map<Object, UserMoneyBalanceBO> userMoneyBalanceMap = userMoneyBalances.stream().collect(Collectors.toMap(UserMoneyBalanceBO::getUserId, Function.identity()));
|
|
|
+
|
|
|
+
|
|
|
+ // 拼装商家对账数据
|
|
|
+ return goodsShops.stream().map(goodsShop -> {
|
|
|
+ PlatformBill platformBill = new PlatformBill();
|
|
|
+ platformBill.setDayId(accountPeriod);
|
|
|
+ platformBill.setUserId(goodsShop.getUserId());
|
|
|
+ platformBill.setShopName(goodsShop.getShopName());
|
|
|
+ // 商户对账
|
|
|
+ platformBill.setType("1");
|
|
|
+
|
|
|
+ OrderDataBO orderData = orderDataMap.get(goodsShop.getShopId());
|
|
|
+ if (ObjectUtil.isNotNull(orderData)) {
|
|
|
+ platformBill.setRevenue(orderData.getShopAmount());
|
|
|
+ platformBill.setRevenueCount(orderData.getCompletedCount());
|
|
|
+ platformBill.setRefundMoney(orderData.getCanceledAmount());
|
|
|
+ platformBill.setRefundCount(orderData.getCanceledCount());
|
|
|
+ platformBill.setPayMoney(orderData.getPayAmount());
|
|
|
+ } else {
|
|
|
+ platformBill.setRevenue(BigDecimal.ZERO);
|
|
|
+ platformBill.setRevenueCount(0);
|
|
|
+ platformBill.setRefundMoney(BigDecimal.ZERO);
|
|
|
+ platformBill.setRefundCount(0);
|
|
|
+ platformBill.setPayMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ ShopMoneyRecordBO shopMoneyRecord = shopMoneryRecordMap.get(goodsShop.getShopId());
|
|
|
+ if (ObjectUtil.isNotNull(shopMoneyRecord)) {
|
|
|
+ platformBill.setPlatformRates(shopMoneyRecord.getPlatformFee());
|
|
|
+ } else {
|
|
|
+ platformBill.setPlatformRates(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ CashOutRecordBO shopCashOutRecord = cashOutRecordMap.get(goodsShop.getUserId());
|
|
|
+ if (ObjectUtil.isNotNull(shopCashOutRecord)) {
|
|
|
+ platformBill.setShopPayouts(shopCashOutRecord.getPayouts());
|
|
|
+ platformBill.setShopPayoutsRates(shopCashOutRecord.getPayoutsRates());
|
|
|
+ platformBill.setShopPayoutsCount(shopCashOutRecord.getPayoutsCount());
|
|
|
+ } else {
|
|
|
+ platformBill.setShopPayouts(BigDecimal.ZERO);
|
|
|
+ platformBill.setShopPayoutsRates(BigDecimal.ZERO);
|
|
|
+ platformBill.setShopPayoutsCount(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ UserMoneyBalanceBO userMoneyBalance = userMoneyBalanceMap.get(goodsShop.getUserId());
|
|
|
+ if (ObjectUtil.isNotNull(userMoneyBalance)) {
|
|
|
+ platformBill.setShopBalance(userMoneyBalance.getBalance());
|
|
|
+ } else {
|
|
|
+ platformBill.setShopBalance(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ PlatformBill preBill = platformBillMap.get(goodsShop.getUserId());
|
|
|
+ if (ObjectUtil.isNotNull(preBill)) {
|
|
|
+ platformBill.setStartMoney(preBill.getEndMoney());
|
|
|
+ } else {
|
|
|
+ platformBill.setStartMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 总收益等于完成订单收入
|
|
|
+ platformBill.setTotalIncome(platformBill.getRevenue());
|
|
|
+ // 期末金额等于总收益
|
|
|
+ platformBill.setEndMoney(platformBill.getRevenue());
|
|
|
+
|
|
|
+ return platformBill;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计BigDecimal类型数值
|
|
|
+ * @param bills 待统计数据
|
|
|
+ * @param mapper 待统计字段
|
|
|
+ * @return 统计结果
|
|
|
+ */
|
|
|
+ private static BigDecimal sum(List<PlatformBill> bills, Function<PlatformBill, BigDecimal> mapper) {
|
|
|
+ return bills.stream().map(mapper).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计Integer类型数值
|
|
|
+ * @param bills 待统计数据
|
|
|
+ * @param mapper 待统计字段
|
|
|
+ * @return 统计结果
|
|
|
+ */
|
|
|
+ private static int sumInt(List<PlatformBill> bills, ToIntFunction<PlatformBill> mapper) {
|
|
|
+ return bills.stream().mapToInt(mapper).sum();
|
|
|
+ }
|
|
|
}
|