|
@@ -872,8 +872,6 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
|
|
|
// 添加studentPaymentOrderDetail
|
|
|
StudentPaymentOrderDetail studentPaymentOrderDetail = null;
|
|
|
|
|
|
- BigDecimal totalPrice = BigDecimal.ZERO;
|
|
|
-
|
|
|
if (goodsSellDtos != null) {
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
for (GoodsSellDto goodsSellDto : goodsSellDtos) {
|
|
@@ -890,7 +888,10 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
|
|
|
multiply(new BigDecimal(t.getGoodsNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
Goods goods = null;
|
|
|
- for (String goodsIdStr : goodsIdsStr.split(",")) {
|
|
|
+ String[] goodsIds = goodsIdsStr.split(",");
|
|
|
+ BigDecimal subTotalPrice = totalGroupPurchasePrice;
|
|
|
+ for (int i = 0; i < goodsIds.length; i++) {
|
|
|
+ String goodsIdStr = goodsIds[i];
|
|
|
if (StringUtils.isBlank(goodsIdStr)) {
|
|
|
continue;
|
|
|
}
|
|
@@ -911,20 +912,20 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
|
|
|
}
|
|
|
studentPaymentOrderDetail.setGoodsIdList(goodsIdStr);
|
|
|
|
|
|
+ //获取比例
|
|
|
BigDecimal tempPrice = BigDecimal.ZERO;
|
|
|
if (totalGroupPurchasePrice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- tempPrice = studentPaymentOrder.getExpectAmount().multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, RoundingMode.DOWN).setScale(2, RoundingMode.DOWN);
|
|
|
+ tempPrice = goods.getDiscountPrice().divide(totalGroupPurchasePrice,6, RoundingMode.DOWN);
|
|
|
}
|
|
|
-
|
|
|
- if (totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0 || goodsIdsStr.split(",").length == studentPaymentOrderDetailList.size() + 1) {
|
|
|
- studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));
|
|
|
- } else {
|
|
|
- studentPaymentOrderDetail.setPrice(tempPrice);
|
|
|
+ if(i == goodsIds.length - 1){
|
|
|
+ studentPaymentOrderDetail.setPrice(subTotalPrice);
|
|
|
+ }else {
|
|
|
+ BigDecimal decimal = studentPaymentOrder.getExpectAmount().multiply(tempPrice).setScale(2, RoundingMode.DOWN);
|
|
|
+ studentPaymentOrderDetail.setPrice(decimal);
|
|
|
+ subTotalPrice = subTotalPrice.subtract(decimal);
|
|
|
}
|
|
|
studentPaymentOrderDetail.setUpdateTime(date);
|
|
|
studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
|
|
|
-
|
|
|
- totalPrice = totalPrice.add(studentPaymentOrderDetail.getPrice());
|
|
|
studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
|
|
|
}
|
|
|
}
|