|
@@ -2,13 +2,16 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
|
|
|
import static com.ym.mec.biz.dal.enums.GroupType.GOODS_SELL;
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.MUSIC;
|
|
|
import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.*;
|
|
|
import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.ORGAN_SHARE_PROFIT;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Consumer;
|
|
|
import java.util.function.Function;
|
|
|
+import java.util.function.Supplier;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -291,9 +294,15 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
for (int i = 0; i < goodsOrderDetails.size(); i++) {
|
|
|
StudentPaymentOrderDetail orderDetail = orderDetails.get(i);
|
|
|
//获取支付金额比例
|
|
|
- BigDecimal ratioAmount = orderDetail.getPrice().divide(detailTotalPrice, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
- //获取优惠券金额比例
|
|
|
- BigDecimal ratioCouponAmount = orderDetail.getRemitFee().divide(detailTotalRemitPrice, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal ratioAmount = BigDecimal.ZERO;
|
|
|
+ if(detailTotalPrice.compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ ratioAmount = orderDetail.getPrice().divide(detailTotalPrice, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ BigDecimal ratioCouponAmount = BigDecimal.ZERO;
|
|
|
+ if (detailTotalRemitPrice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //获取优惠券金额比例
|
|
|
+ ratioCouponAmount = orderDetail.getRemitFee().divide(detailTotalRemitPrice, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
//获取分配的余额
|
|
|
BigDecimal detailBalance;
|
|
|
//获取分配的优惠券金额
|
|
@@ -627,7 +636,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public List<SellOrder> initSellOrder(StudentPaymentOrder order, String musicGroupId, List<Integer> goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseType,
|
|
|
- BigDecimal totalBalance, BigDecimal expectTotalAmount, BigDecimal couponRemitAmount, BigDecimal actualTotalAmount,Boolean saveFlag) {
|
|
|
+ BigDecimal totalBalance, BigDecimal expectTotalAmount, BigDecimal couponRemitAmount,
|
|
|
+ BigDecimal actualTotalAmount, Boolean saveFlag) {
|
|
|
//可用优惠券金额
|
|
|
BigDecimal subCouponRemitAmount = couponRemitAmount;
|
|
|
//可用总金额
|
|
@@ -669,7 +679,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
BigDecimal actualAmount;
|
|
|
|
|
|
if (goodsTotalPrice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- goodsRatioAmount = nowGoods.getGroupPurchasePrice().divide(goodsTotalPrice, 6, RoundingMode.HALF_UP);
|
|
|
+ goodsRatioAmount = order.getGroupType() == MUSIC ?nowGoods.getGroupPurchasePrice():nowGoods.getDiscountPrice()
|
|
|
+ .divide(goodsTotalPrice, 6, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
if(i == goodies.size() - 1){
|
|
|
expectAmount = subExpectTotalAmount;
|
|
@@ -768,7 +779,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public List<SellOrder> initSellOrder(StudentPaymentOrder order, String musicGroupId, List<Integer> goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseType,Boolean saveFlag) {
|
|
|
+ public List<SellOrder> initSellOrder(StudentPaymentOrder order, String musicGroupId, List<Integer> goodsIds,
|
|
|
+ KitGroupPurchaseTypeEnum kitGroupPurchaseType,Boolean saveFlag) {
|
|
|
BigDecimal totalBalance = order.getBalancePaymentAmount();
|
|
|
if (totalBalance == null) {
|
|
|
totalBalance = BigDecimal.ZERO;
|
|
@@ -776,7 +788,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
BigDecimal expectTotalAmount = order.getExpectAmount();
|
|
|
BigDecimal couponRemitAmount = order.getCouponRemitFee();
|
|
|
BigDecimal actualTotalAmount = order.getActualAmount();
|
|
|
- return this.initSellOrder(order, musicGroupId, goodsIds, kitGroupPurchaseType, totalBalance, expectTotalAmount, couponRemitAmount, actualTotalAmount,saveFlag==null?true:saveFlag);
|
|
|
+ return this.initSellOrder(order, musicGroupId, goodsIds, kitGroupPurchaseType, totalBalance, expectTotalAmount,
|
|
|
+ couponRemitAmount, actualTotalAmount,saveFlag==null?true:saveFlag);
|
|
|
}
|
|
|
|
|
|
public Map<String, BigDecimal> calcSellAmount(StudentPaymentOrder order,BigDecimal cloudBalanceIncome,BigDecimal cloudIncome) {
|