|
@@ -382,6 +382,10 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
boolean hasActProductFlag = false;
|
|
|
// 是否能线上支付
|
|
|
boolean onlinePay = true;
|
|
|
+ // 用余额线下
|
|
|
+ if (null != orderParamBo.getBalancePayFlag() && 1 == orderParamBo.getBalancePayFlag()) {
|
|
|
+ onlinePay = false;
|
|
|
+ }
|
|
|
//促销活动ids
|
|
|
List<Integer> promotionsIds = new ArrayList<>();
|
|
|
// 促销活动信息
|
|
@@ -401,7 +405,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
if (null == shopId) {
|
|
|
return ResponseJson.error("供应商数据异常!", null);
|
|
|
}
|
|
|
- if(StringUtils.isBlank(splitCode)){
|
|
|
+ if (StringUtils.isBlank(splitCode)) {
|
|
|
onlinePay = false;
|
|
|
}
|
|
|
JSONArray productArr = (JSONArray) shopInfo.get("productInfo");
|
|
@@ -579,8 +583,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
product.setLadderPrices(ladderPrices);
|
|
|
product.setActProduct(2);
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
// 复购价
|
|
|
Double repurchase = baseMapper.getRepurchasePrice(productId, orderParamBo.getUserId());
|
|
|
if (null != repurchase && repurchase > 0) {
|
|
@@ -821,7 +824,6 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
shopOrder.setOrderPromotionsId(shopPromotions.getId());
|
|
|
}
|
|
|
}
|
|
|
- //todo 子订单分摊优惠
|
|
|
// 佣金 采美应收
|
|
|
shopOrder.setBrokerage(brokerage.get());
|
|
|
// 可退款金额 = 余额抵扣金额
|
|
@@ -1072,8 +1074,52 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
});
|
|
|
|
|
|
/*
|
|
|
- * 整理 子订单信息
|
|
|
+ * 整理 子订单信息cm_shop_order
|
|
|
*/
|
|
|
+ if (onlinePay) {
|
|
|
+ //线上支付分摊优惠总和到子订单
|
|
|
+ //经理折扣+优惠券+满减 提交订单的时候无经理折扣
|
|
|
+ double allDiscount = MathUtil.add(couponAmount, promotionFullReduction.get()).doubleValue();
|
|
|
+ // 分摊优惠前总佣金
|
|
|
+ AtomicDouble oldBrokerage = new AtomicDouble(0);
|
|
|
+ //超级会员价/复购价/阶梯价/促销活动冲突,只能生效一个,促销活动满减计入优惠分摊,子订单售价=NeedPayAmount+promotionFullReduction
|
|
|
+ shopOrderList.forEach(orderShopPo -> {
|
|
|
+ // 店铺满减会存入shoporder信息中,凑单满减
|
|
|
+ if (null != orderShopPo.getPromotionFullReduction() && orderShopPo.getPromotionFullReduction() > 0) {
|
|
|
+ //不含分摊优惠的子订单金额
|
|
|
+ orderShopPo.setOldPrice(MathUtil.add(orderShopPo.getNeedPayAmount(), orderShopPo.getPromotionFullReduction()).doubleValue());
|
|
|
+ //不含分摊优惠的子订单佣金
|
|
|
+ orderShopPo.setOldBrokerage(MathUtil.add(orderShopPo.getBrokerage(), orderShopPo.getPromotionFullReduction()).doubleValue());
|
|
|
+ } else {
|
|
|
+ orderShopPo.setOldPrice(orderShopPo.getNeedPayAmount());
|
|
|
+ orderShopPo.setOldBrokerage(orderShopPo.getBrokerage());
|
|
|
+ }
|
|
|
+ oldBrokerage.set(MathUtil.add(oldBrokerage, orderShopPo.getOldBrokerage()).doubleValue());
|
|
|
+ });
|
|
|
+ // 按分摊前的佣金排序
|
|
|
+ shopOrderList.sort((o1, o2) -> o2.getOldBrokerage().compareTo(o1.getOldBrokerage()));
|
|
|
+ // 前面子订单的分摊优惠总和
|
|
|
+ AtomicDouble allReduction =new AtomicDouble(0);
|
|
|
+ for (int i = 0; i < shopOrderList.size(); i++) {
|
|
|
+ if(i<shopOrderList.size()-1){
|
|
|
+ //最终支付金额=分摊前支付金额oldprice-折扣*(分摊前佣金/分摊前总佣金)
|
|
|
+ //优惠分摊金额
|
|
|
+ double v = MathUtil.mul(allDiscount, MathUtil.div(shopOrderList.get(i).getOldBrokerage(), oldBrokerage.get())).doubleValue();
|
|
|
+ //子订单真实支付金额
|
|
|
+ shopOrderList.get(i).setRealPay(MathUtil.round(MathUtil.sub(shopOrderList.get(i).getOldPrice(), v), 2).doubleValue());
|
|
|
+ allReduction.set(MathUtil.add(v,allReduction.get()).doubleValue());
|
|
|
+ }
|
|
|
+ if(i==shopOrderList.size()-1){
|
|
|
+ //最后一个子订单的分摊优惠金额=全优惠allDiscount-已分摊
|
|
|
+ double v = MathUtil.sub(allDiscount, allReduction.get()).doubleValue();
|
|
|
+ shopOrderList.get(i).setRealPay(MathUtil.round(MathUtil.sub(shopOrderList.get(i).getOldPrice(),v),2).doubleValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
AtomicReference<String> shopOrderIds = new AtomicReference<>();
|
|
|
AtomicInteger shopOrderIndex = new AtomicInteger(1);
|
|
|
shopOrderList.forEach(shopOrder -> {
|
|
@@ -1116,7 +1162,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
});
|
|
|
|
|
|
/*
|
|
|
- * 订单商品分子订单
|
|
|
+ * 订单商品分子订单cm_order_product
|
|
|
*/
|
|
|
for (OrderProductPo orderProduct : orderProductList) {
|
|
|
// 设置商品订单Id
|