|
@@ -562,13 +562,18 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
return ResponseJson.error("订单商品不存在!", null);
|
|
|
}
|
|
|
// 联合丽格冷链费商品
|
|
|
- if (7502 == product.getProductId()) {
|
|
|
- if (productNum >= 100) {
|
|
|
- isColdChina.set(0.00d);
|
|
|
- } else {
|
|
|
- isColdChina.set(700.00d);
|
|
|
- orderParamBo.setOrderShouldPayFee(MathUtil.sub(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
|
|
|
+ if (1 == orderParamBo.getIsColdChain()) {
|
|
|
+ if (7881 == product.getProductId()) {
|
|
|
+ if (productNum >= 100) {
|
|
|
+ isColdChina.set(0.00d);
|
|
|
+ } else {
|
|
|
+ isColdChina.set(700.00d);
|
|
|
+ // payableAmount.set(MathUtil.add(payableAmount.get(), isColdChina).doubleValue());
|
|
|
+// orderParamBo.setOrderShouldPayFee(MathUtil.sub(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
+ isColdChina.set(0.00d);
|
|
|
}
|
|
|
// 是否二手商品
|
|
|
if (null != product.getProductCategory() && 2 == product.getProductCategory()) {
|
|
@@ -628,69 +633,71 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
// 计算单价
|
|
|
// 超级会员单价折扣计算
|
|
|
- if (null != svipProductPo && 1 == svipProductPo.getSvipProductFlag()) {
|
|
|
- // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
- if (orderParamBo.getSvipUserFlag()) {
|
|
|
- if (1 == svipProductPo.getSvipPriceType()) {
|
|
|
- // 折扣价
|
|
|
- discountPrice = MathUtil.div(MathUtil.mul(productPrice, svipProductPo.getSvipDiscount()), 100, 2).doubleValue();
|
|
|
- } else if (2 == svipProductPo.getSvipPriceType()) {
|
|
|
- // 直接优惠价
|
|
|
- discountPrice = svipProductPo.getSvipDiscountPrice();
|
|
|
- }
|
|
|
- // 商品超级会员优惠
|
|
|
- BigDecimal svipReduction = MathUtil.sub(productPrice, discountPrice);
|
|
|
- if (taxFlag) {
|
|
|
- // 商品税费超级会员优惠
|
|
|
- BigDecimal svipTaxReduction = MathUtil.div(MathUtil.mul(svipReduction, product.getTaxRate()), 100, 2);
|
|
|
- svipReduction = MathUtil.add(svipReduction, svipTaxReduction);
|
|
|
+ if (0 == organizeId) {
|
|
|
+ if (null != svipProductPo && 1 == svipProductPo.getSvipProductFlag()) {
|
|
|
+ // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
+ if (orderParamBo.getSvipUserFlag()) {
|
|
|
+ if (1 == svipProductPo.getSvipPriceType()) {
|
|
|
+ // 折扣价
|
|
|
+ discountPrice = MathUtil.div(MathUtil.mul(productPrice, svipProductPo.getSvipDiscount()), 100, 2).doubleValue();
|
|
|
+ } else if (2 == svipProductPo.getSvipPriceType()) {
|
|
|
+ // 直接优惠价
|
|
|
+ discountPrice = svipProductPo.getSvipDiscountPrice();
|
|
|
+ }
|
|
|
+ // 商品超级会员优惠
|
|
|
+ BigDecimal svipReduction = MathUtil.sub(productPrice, discountPrice);
|
|
|
+ if (taxFlag) {
|
|
|
+ // 商品税费超级会员优惠
|
|
|
+ BigDecimal svipTaxReduction = MathUtil.div(MathUtil.mul(svipReduction, product.getTaxRate()), 100, 2);
|
|
|
+ svipReduction = MathUtil.add(svipReduction, svipTaxReduction);
|
|
|
+ }
|
|
|
+ // 统计超级会员优惠
|
|
|
+ product.setSvipReduction(svipReduction.doubleValue());
|
|
|
+ svipShopReduction.set(MathUtil.add(svipShopReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
|
|
|
+ svipFullReduction.set(MathUtil.add(svipFullReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
|
|
|
+ // 保存订单商品svip数据
|
|
|
+ product.setSvipPriceFlag(1);
|
|
|
+ product.setSvipPriceType(svipProductPo.getSvipPriceType());
|
|
|
+ product.setSvipDiscount(1 == svipProductPo.getSvipPriceType() ? svipProductPo.getSvipDiscount() : 0.00d);
|
|
|
}
|
|
|
- // 统计超级会员优惠
|
|
|
- product.setSvipReduction(svipReduction.doubleValue());
|
|
|
- svipShopReduction.set(MathUtil.add(svipShopReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
|
|
|
- svipFullReduction.set(MathUtil.add(svipFullReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
|
|
|
- // 保存订单商品svip数据
|
|
|
- product.setSvipPriceFlag(1);
|
|
|
- product.setSvipPriceType(svipProductPo.getSvipPriceType());
|
|
|
- product.setSvipDiscount(1 == svipProductPo.getSvipPriceType() ? svipProductPo.getSvipDiscount() : 0.00d);
|
|
|
}
|
|
|
- }
|
|
|
- // 有单品优惠价促销活动
|
|
|
- else if (null != promotions || null != shopPromotions) {
|
|
|
- // 是否包含活动商品(受订单未支付自动关闭时间影响) 0 否 1 是
|
|
|
- hasActProductFlag = true;
|
|
|
- // 关闭阶梯价格,活动优先
|
|
|
- product.setLadderPriceFlag(0);
|
|
|
- product.setActProduct(1);
|
|
|
- if (null != promotions && promotions.getType() == 1 && promotions.getMode() == 1) {
|
|
|
- discountPrice = promotions.getTouchPrice();
|
|
|
+ // 有单品优惠价促销活动
|
|
|
+ else if (null != promotions || null != shopPromotions) {
|
|
|
+ // 是否包含活动商品(受订单未支付自动关闭时间影响) 0 否 1 是
|
|
|
+ hasActProductFlag = true;
|
|
|
+ // 关闭阶梯价格,活动优先
|
|
|
+ product.setLadderPriceFlag(0);
|
|
|
+ product.setActProduct(1);
|
|
|
+ if (null != promotions && promotions.getType() == 1 && promotions.getMode() == 1) {
|
|
|
+ discountPrice = promotions.getTouchPrice();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //有阶梯价
|
|
|
- else if (1 == product.getLadderPriceFlag()) {
|
|
|
- // 启用了阶梯价格
|
|
|
- List<LadderPriceVo> ladderPrices = baseMapper.getLadderPriceList(skuId);
|
|
|
- // 判断阶梯价格的购买数量校验
|
|
|
- int minBuyNumber = null != ladderPrices.get(0) ? ladderPrices.get(0).getBuyNum() : 0;
|
|
|
- if (productNum < minBuyNumber) {
|
|
|
- return ResponseJson.error("商品购买量低于最小起订量!", null);
|
|
|
- }
|
|
|
- //根据商品购买数量获取商品对应阶梯价格
|
|
|
- for (LadderPriceVo ladderPrice : ladderPrices) {
|
|
|
- if (productNum >= ladderPrice.getBuyNum()) {
|
|
|
- discountPrice = ladderPrice.getBuyPrice();
|
|
|
+ //有阶梯价
|
|
|
+ else if (1 == product.getLadderPriceFlag()) {
|
|
|
+ // 启用了阶梯价格
|
|
|
+ List<LadderPriceVo> ladderPrices = baseMapper.getLadderPriceList(skuId);
|
|
|
+ // 判断阶梯价格的购买数量校验
|
|
|
+ int minBuyNumber = null != ladderPrices.get(0) ? ladderPrices.get(0).getBuyNum() : 0;
|
|
|
+ if (productNum < minBuyNumber) {
|
|
|
+ return ResponseJson.error("商品购买量低于最小起订量!", null);
|
|
|
}
|
|
|
+ //根据商品购买数量获取商品对应阶梯价格
|
|
|
+ for (LadderPriceVo ladderPrice : ladderPrices) {
|
|
|
+ if (productNum >= ladderPrice.getBuyNum()) {
|
|
|
+ discountPrice = ladderPrice.getBuyPrice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ product.setLadderPrices(ladderPrices);
|
|
|
+ product.setActProduct(2);
|
|
|
+ } else {
|
|
|
+ // 复购价
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(skuId, orderParamBo.getUserId());
|
|
|
+ if (null != repurchase && repurchase > 0) {
|
|
|
+ discountPrice = repurchase;
|
|
|
+ }
|
|
|
+ product.setActProduct(0);
|
|
|
}
|
|
|
- product.setLadderPrices(ladderPrices);
|
|
|
- product.setActProduct(2);
|
|
|
- } else {
|
|
|
- // 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(skuId, orderParamBo.getUserId());
|
|
|
- if (null != repurchase && repurchase > 0) {
|
|
|
- discountPrice = repurchase;
|
|
|
- }
|
|
|
- product.setActProduct(0);
|
|
|
}
|
|
|
if (MathUtil.compare(discountPrice, BigDecimal.ZERO) == 0) {
|
|
|
return ResponseJson.error("商品购买价格不能为0!", null);
|
|
@@ -837,6 +844,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 付供应商 商品费=成本价*(购买数量 + 赠品数量)
|
|
|
Double costAmount = MathUtil.mul(costPrice, MathUtil.add(productNum, presentNum)).doubleValue();
|
|
|
product.setShopProductAmount(costAmount);
|
|
|
+ log.info("product.getShopProductAmount()***"+product.getShopProductAmount());
|
|
|
//应付供应商(单)=成本价+供应商税费(单)
|
|
|
Double singleShopFee = MathUtil.add(product.getCostPrice(), shopTax).doubleValue();
|
|
|
product.setSingleShopFee(singleShopFee);
|
|
@@ -879,6 +887,8 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 商品总金额
|
|
|
shopAmount.set(MathUtil.add(shopAmount.get(), product.getTotalAmount()).doubleValue());
|
|
|
// 付供应商 商品费
|
|
|
+ log.info("shopProductAmount.get()"+shopProductAmount.get());
|
|
|
+ log.info("product.getShopProductAmount()"+product.getShopProductAmount());
|
|
|
shopProductAmount.set(MathUtil.add(shopProductAmount.get(), product.getShopProductAmount()).doubleValue());
|
|
|
// 付供应商税费
|
|
|
shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
|
|
@@ -1103,8 +1113,8 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 商品总额
|
|
|
mainOrder.setProductTotalFee(productTotalFee.get());
|
|
|
mainOrder.setOrderTotalFee(productTotalFee.get());
|
|
|
- // 订单总额(商品金额+运费)
|
|
|
- mainOrder.setPayTotalFee(payTotalFee.get());
|
|
|
+ // 订单总额(商品金额+运费)-- 冷链运输费
|
|
|
+ mainOrder.setPayTotalFee(MathUtil.add(payTotalFee.get(), isColdChina.get()).doubleValue());
|
|
|
// 订单状态
|
|
|
if (0 == organizeId) {
|
|
|
if (3 == orderParamBo.getCartType()) {
|
|
@@ -1165,8 +1175,8 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
// 余额支付金额
|
|
|
mainOrder.setBalancePayFee(balancePayFee.get());
|
|
|
- // 实际支付金额(商品金额+运费-余额抵扣)
|
|
|
- mainOrder.setPayableAmount(payableAmount.get());
|
|
|
+ // 实际支付金额(商品金额+运费-余额抵扣) + 冷链费用
|
|
|
+ mainOrder.setPayableAmount(MathUtil.add(payableAmount.get(), isColdChina.get()).doubleValue());
|
|
|
|
|
|
// 是否返佣订单
|
|
|
Integer rebateFlag = (null == orderParamBo.getRebateFlag() ? 0 : orderParamBo.getRebateFlag());
|
|
@@ -1176,6 +1186,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
|
|
|
// 判断前端传入orderShouldPayFee订单应付金额,和后台计算应付金额对比
|
|
|
+ orderParamBo.setOrderShouldPayFee(MathUtil.sub(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
|
|
|
log.info("【提交订单】>>>>>后台计算payableAmount:" + payableAmount.get() + " ,前端传入orderShouldPayFee:" + orderParamBo.getOrderShouldPayFee());
|
|
|
// compare return[-1:v1<v2, 0:v1=v2, 1:v1>v2]
|
|
|
int compare = MathUtil.compare(orderParamBo.getOrderShouldPayFee(), payableAmount.get());
|
|
@@ -1184,7 +1195,8 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return ResponseJson.error("订单付款金额不正确!", null);
|
|
|
}
|
|
|
-
|
|
|
+ // 加冷链费
|
|
|
+ orderParamBo.setOrderShouldPayFee(MathUtil.add(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
|
|
|
// 售后条款
|
|
|
Integer clauseId = orderParamBo.getClauseId();
|
|
|
String clauseName = null;
|
|
@@ -1445,7 +1457,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
* 采美豆抵扣不生成
|
|
|
*/
|
|
|
log.info("PostageFlag===="+mainOrder.getPostageFlag()+"====UserBeans=====***"+mainOrder.getUserBeans());
|
|
|
- if (( 1 == mainOrder.getPostageFlag() && 0 == mainOrder.getUserBeans() ) || ( 0 == mainOrder.getPostageFlag() && 0 != organizeId )) {
|
|
|
+ if (( 1 == mainOrder.getPostageFlag() && 0 == mainOrder.getUserBeans() ) || ( 0 == mainOrder.getPostageFlag() && isColdChina.get() > 0.00d && 0 != organizeId ) || ( -1 == mainOrder.getPostageFlag() && isColdChina.get() > 0.00d && 0 != organizeId )) {
|
|
|
// 获取 邮费商品 productId 999 skuId 1
|
|
|
OrderProductPo postageProduct = submitMapper.getProductDetails(1);
|
|
|
// 生成子订单编号
|
|
@@ -1466,9 +1478,12 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
postageOrder.setUserId(mainOrder.getUserId());
|
|
|
postageOrder.setOrderSubmitType(mainOrder.getOrderSubmitType());
|
|
|
postageOrder.setItemCount(1);
|
|
|
- postageOrder.setSplitCode(Constant.CUSTOMERNUM);
|
|
|
- postageOrder.setRealPay(mainOrder.getPostage());
|
|
|
- postageOrder.setEachDiscount(0d);
|
|
|
+ if (0 == organizeId) {
|
|
|
+ postageOrder.setSplitCode(Constant.CUSTOMERNUM);
|
|
|
+ } else {
|
|
|
+ // 联合丽格
|
|
|
+ postageOrder.setSplitCode("E1807782723");
|
|
|
+ }
|
|
|
// 冷链运输费
|
|
|
if (1 == orderParamBo.getIsColdChain()) {
|
|
|
postageOrder.setIsColdChina(1);
|
|
@@ -1476,6 +1491,9 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
} else {
|
|
|
postageOrder.setIsColdChina(0);
|
|
|
}
|
|
|
+ postageOrder.setRealPay(mainOrder.getPostage());
|
|
|
+ postageOrder.setEachDiscount(0d);
|
|
|
+
|
|
|
//运费商品供应商Id默认998
|
|
|
postageOrder.setShopId(postageProduct.getShopId());
|
|
|
postageOrder.setProductAmount(mainOrder.getPostage());
|
|
@@ -1498,6 +1516,8 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
// 订单默认可拆分
|
|
|
postageOrder.setSplitFlag(1);
|
|
|
+ // 设置组织Id
|
|
|
+ postageOrder.setOrganizeId(organizeId);
|
|
|
/*
|
|
|
* 保存运费子订单
|
|
|
*/
|
|
@@ -1509,6 +1529,10 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
} else {
|
|
|
shopOrderIds.set(shopOrderIds.get() + "," + postageOrder.getShopOrderId());
|
|
|
}
|
|
|
+ // 有冷链运输费 且大于 0 修改主订单运费状态
|
|
|
+ if (MathUtil.add(mainOrder.getPostage(), isColdChina.get()).doubleValue() > 0) {
|
|
|
+ submitMapper.updateOrder(mainOrder.getPostage().doubleValue(), mainOrder.getOrderId());
|
|
|
+ }
|
|
|
/*
|
|
|
* 设置运费商品
|
|
|
*/
|
|
@@ -1791,7 +1815,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
log.info("**********************微信模板消息推送*****************************");
|
|
|
List<Integer> productIds = orderClubMapper.getProductOrder(mainOrder.getOrderId());
|
|
|
- if (0 == mainOrder.getSecondHandOrderFlag() && 0 == mainOrder.getRebateFlag() && (null != productIds && !productIds.contains(6060)) && mainOrder.getOrderType() != 0) {
|
|
|
+ if (0 == organizeId && 0 == mainOrder.getSecondHandOrderFlag() && 0 == mainOrder.getRebateFlag() && (null != productIds && !productIds.contains(6060)) && mainOrder.getOrderType() != 0) {
|
|
|
log.info("*******获取公众名" + orderClubMapper.getOrderIds(mainOrder.getOrderId()).toString());
|
|
|
String name = "0";
|
|
|
try {
|