|
@@ -274,17 +274,33 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public List<SellOrder> addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails,
|
|
|
- StudentPaymentOrder studentPaymentOrder, MusicGroup musicGroup,BigDecimal balancePaymentAmount) {
|
|
|
+ public void addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails,
|
|
|
+ StudentPaymentOrder studentPaymentOrder, String musicGroupId) {
|
|
|
//过去非商品详情
|
|
|
List<StudentPaymentOrderDetail> goodsOrderDetails = orderDetails.stream().filter(e -> StringUtils.isNotEmpty(e.getGoodsIdList())).collect(Collectors.toList());
|
|
|
if(CollectionUtils.isEmpty(goodsOrderDetails)){
|
|
|
- throw new BizException("商品详情为空");
|
|
|
+ return;
|
|
|
}
|
|
|
- //获取总减免金额
|
|
|
- BigDecimal detailTotalRemitPrice = goodsOrderDetails.stream().map(StudentPaymentOrderDetail::getRemitFee).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
//获取总金额
|
|
|
BigDecimal detailTotalPrice = goodsOrderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal balancePaymentAmount = studentPaymentOrder.getBalancePaymentAmount();
|
|
|
+ if (balancePaymentAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ BigDecimal expectAmount = studentPaymentOrder.getExpectAmount();
|
|
|
+ BigDecimal organShareProfit = orderDetails.stream().filter(o -> o.getType() == ORGAN_SHARE_PROFIT).map(StudentPaymentOrderDetail::getPrice)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ if(organShareProfit != null){
|
|
|
+ expectAmount = expectAmount.subtract(organShareProfit);
|
|
|
+ }
|
|
|
+ //获取比例
|
|
|
+ BigDecimal ratioAmount = BigDecimal.ZERO;
|
|
|
+ if(expectAmount.compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ ratioAmount = balancePaymentAmount.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //获取分配的减免金额
|
|
|
+ balancePaymentAmount = balancePaymentAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //获取总减免金额
|
|
|
+ BigDecimal detailTotalRemitPrice = goodsOrderDetails.stream().map(StudentPaymentOrderDetail::getRemitFee).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
List<SellOrder> sellOrders = new ArrayList<>();
|
|
|
|
|
@@ -331,9 +347,12 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
subDetailActualAmount = subDetailActualAmount.subtract(detailActualAmount);
|
|
|
}
|
|
|
List<Integer> goodsIds = Arrays.asList(orderDetail.getGoodsIdList().split(",")).stream().map(Integer::parseInt).collect(Collectors.toList());
|
|
|
- sellOrders.addAll(this.initSellOrder(studentPaymentOrder, musicGroup.getId(), goodsIds, orderDetail.getKitGroupPurchaseType(),
|
|
|
+ sellOrders.addAll(this.initSellOrder(studentPaymentOrder, musicGroupId, goodsIds, orderDetail.getKitGroupPurchaseType(),
|
|
|
detailBalance, orderDetail.getPrice(), couponRemitFee, detailActualAmount, false));
|
|
|
}
|
|
|
+ this.batchInsert(sellOrders);
|
|
|
+ //同步销售订单到商城
|
|
|
+ this.syncSellOrder2Mall(sellOrders, studentPaymentOrder);
|
|
|
|
|
|
/*
|
|
|
BigDecimal goodsTotalPrice = orderDetail.getGoodsList().stream().map(Goods::getGroupPurchasePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
@@ -460,7 +479,6 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
}
|
|
|
sellOrderDao.batchInsert(sellOrders);
|
|
|
}*/
|
|
|
- return sellOrders;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -681,7 +699,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
}
|
|
|
List<Goods> goodies = goodsDao.getGoodies(goodsIds);
|
|
|
- BigDecimal goodsTotalPrice = goodies.stream().map(Goods::getGroupPurchasePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal goodsTotalPrice = goodies.stream().map(e->order.getGroupType() == MUSIC ?e.getGroupPurchasePrice():e.getDiscountPrice()).
|
|
|
+ reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
AccountType accountType = AccountType.INTERNAL;
|
|
|
if(StringUtils.isNotEmpty(order.getPaymentChannel())){
|