|
@@ -558,6 +558,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
AtomicDouble shopPromotionFee = new AtomicDouble(0);
|
|
|
// 供应商超级会员优惠
|
|
|
AtomicDouble svipShopReduction = new AtomicDouble(0);
|
|
|
+
|
|
|
// 遍历所有商品
|
|
|
for (Object productObject : productArr) {
|
|
|
JSONObject productTemp = (JSONObject) productObject;
|
|
@@ -730,7 +731,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 不含税不可开票商品和未知商品,税率置为0
|
|
|
product.setTaxRate(0d);
|
|
|
}
|
|
|
- log.info("productTax==="+productTax);
|
|
|
+ log.info("productTax===" + productTax);
|
|
|
// 商品价格
|
|
|
if (Integer.valueOf(0).equals(product.getIncludedTax())) {
|
|
|
if (null != product.getTaxRate() && product.getTaxRate() > 0d) {
|
|
@@ -865,7 +866,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
product.setShopTaxRate(product.getTaxRate());
|
|
|
}
|
|
|
if (taxFlag) {
|
|
|
- shopTax = MathUtil.div(MathUtil.mul(MathUtil.div(costPrice,MathUtil.div(MathUtil.add(product.getTaxRate(), 100),100)), product.getShopTaxRate()), 100, 2).doubleValue();
|
|
|
+ shopTax = MathUtil.div(MathUtil.mul(MathUtil.div(costPrice, MathUtil.div(MathUtil.add(product.getTaxRate(), 100), 100)), product.getShopTaxRate()), 100, 2).doubleValue();
|
|
|
} else if (!Integer.valueOf(1).equals(product.getIncludedTax())) {
|
|
|
// 不含税不可开票商品和未知商品,税率置为0
|
|
|
product.setShopTaxRate(0d);
|
|
@@ -875,7 +876,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 单个商品付供应商总税费
|
|
|
product.setShouldPayTotalTax(MathUtil.mul(shopTax, productNum).doubleValue());
|
|
|
// 付供应商 商品费=成本价*(购买数量 + 赠品数量)
|
|
|
- Double costAmount = MathUtil.mul(costPrice, MathUtil.add(productNum, presentNum)).doubleValue();
|
|
|
+ Double costAmount = MathUtil.mul(costPrice, MathUtil.add(productNum, presentNum)).doubleValue();
|
|
|
product.setShopProductAmount(costAmount);
|
|
|
log.info("product.getShopProductAmount()***" + product.getShopProductAmount());
|
|
|
//应付供应商(单)=成本价+供应商税费(单)
|
|
@@ -927,18 +928,18 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
|
|
|
// 成本 | 佣金比例 商城sku 成本 | 配置比例
|
|
|
CmOrganizeSkuPo organizeSkuInfo = submitMapper.getOrganizeSkuInfo(skuId, organizeId);
|
|
|
- if ( StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
|
|
|
+ if (StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
|
|
|
// 固定成本
|
|
|
if (taxFlag) {
|
|
|
- organizeSkuInfo.setOrganizeCostPrice(MathUtil.add(organizeSkuInfo.getOrganizeCostPrice(), MathUtil.div( MathUtil.mul(organizeSkuInfo.getOrganizeCostPrice(), product.getTaxRate()), 100)).doubleValue());
|
|
|
- organizeSkuInfo.setCmCostPrice(MathUtil.add(organizeSkuInfo.getCmCostPrice(), MathUtil.div( MathUtil.mul(organizeSkuInfo.getCmCostPrice(), product.getTaxRate()), 100)).doubleValue());
|
|
|
+ organizeSkuInfo.setOrganizeCostPrice(MathUtil.add(organizeSkuInfo.getOrganizeCostPrice(), MathUtil.div(MathUtil.mul(organizeSkuInfo.getOrganizeCostPrice(), product.getTaxRate()), 100)).doubleValue());
|
|
|
+ organizeSkuInfo.setCmCostPrice(MathUtil.add(organizeSkuInfo.getCmCostPrice(), MathUtil.div(MathUtil.mul(organizeSkuInfo.getCmCostPrice(), product.getTaxRate()), 100)).doubleValue());
|
|
|
}
|
|
|
product.setOrganizeCostPrice(organizeSkuInfo.getOrganizeCostPrice());
|
|
|
product.setCmCostPrice(organizeSkuInfo.getCmCostPrice());
|
|
|
}
|
|
|
- if ( StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "2".equals(organizeSkuInfo.getCostCheckFlag())) {
|
|
|
+ if (StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "2".equals(organizeSkuInfo.getCostCheckFlag())) {
|
|
|
// 比例成本
|
|
|
- product.setOrganizeCostPrice(MathUtil.div(MathUtil.mul(product.getPrice(),organizeSkuInfo.getOrganizePercent()), 100).doubleValue());
|
|
|
+ product.setOrganizeCostPrice(MathUtil.div(MathUtil.mul(product.getPrice(), organizeSkuInfo.getOrganizePercent()), 100).doubleValue());
|
|
|
product.setCmCostPrice(MathUtil.div(MathUtil.mul(product.getPrice(), organizeSkuInfo.getCmPercent()), 100).doubleValue());
|
|
|
|
|
|
product.setCmPercent(organizeSkuInfo.getCmPercent());
|
|
@@ -954,7 +955,6 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
// 设置运费
|
|
|
if (1 == postageFlag && 0 == mainOrder.getUserBeans()) {
|
|
|
- // postage = MathUtil.add(shopIsColdChina.get(), postage).doubleValue();
|
|
|
shopOrder.setShopPostFee(postage);
|
|
|
}
|
|
|
// 需要支付金额 shouldPayFee +运费
|
|
@@ -1051,7 +1051,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
shopOrder.setConfirmTime(curDateStr);
|
|
|
}
|
|
|
// 余额支付标识,0不使用,1使用
|
|
|
- log.info("balance.get()====="+balance.get());
|
|
|
+ log.info("balance.get()=====" + balance.get());
|
|
|
if (1 == orderParamBo.getBalancePayFlag() && 3 == orderParamBo.getCartType() && balance.get() > 0) {
|
|
|
// 使用余额支付
|
|
|
shopOrder.setUseBalanceFlag(1);
|
|
@@ -1063,14 +1063,14 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 余额抵扣金额
|
|
|
shopOrder.setAccountAmount(shopOrder.getNeedPayAmount());
|
|
|
}
|
|
|
- balance.updateAndGet( b -> balance.get() - shopOrder.getNeedPayAmount());
|
|
|
+ balance.updateAndGet(b -> balance.get() - shopOrder.getNeedPayAmount());
|
|
|
} else {
|
|
|
// 使用余额支付
|
|
|
shopOrder.setUseBalanceFlag(0);
|
|
|
// 余额抵扣金额
|
|
|
shopOrder.setAccountAmount(0d);
|
|
|
}
|
|
|
- log.info("shopOrder.getAccountAmount()===="+shopOrder.getAccountAmount());
|
|
|
+ log.info("shopOrder.getAccountAmount()====" + shopOrder.getAccountAmount());
|
|
|
// 运费标记
|
|
|
shopOrder.setShopPostFlag(postageFlag);
|
|
|
// 添加到子订单列表
|
|
@@ -1158,37 +1158,12 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
couponAmount = 0d;
|
|
|
}
|
|
|
mainOrder.setCouponAmount(couponAmount);
|
|
|
- /**
|
|
|
- * 计算运费
|
|
|
- */
|
|
|
- /*if (3 != orderParamBo.getCartType()) {
|
|
|
- // 机构用户 校验商品运费
|
|
|
- if (orderParamBo.getPostageFlag() != -1) {
|
|
|
- Integer townId = baseMapper.getTownIdByAddressId(orderParamBo.getAddressId());
|
|
|
- Map<String, Object> postageMap = productService.computePostage(orderParamBo.getUserId(), townId, skuIdList);
|
|
|
- // 运费标志:0包邮 -1到付 1遵循运费规则
|
|
|
- Integer postageFlag = (Integer) postageMap.get("postageFlag");
|
|
|
- Double postage = (Double) postageMap.get("postage");
|
|
|
- if (!orderParamBo.getPostageFlag().equals(postageFlag) || MathUtil.compare(orderParamBo.getPostage(), postage) != 0) {
|
|
|
- return ResponseJson.error("订单邮费不正确!", null);
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
- // 设置运费
|
|
|
- // mainOrder.setPostage(orderParamBo.getPostage());
|
|
|
// 订单总额 = 商品费 + 运费
|
|
|
log.info("总运费" + postageFee.get());
|
|
|
payTotalFee.set(MathUtil.add(productTotalFee.get(), postageFee.get()).doubleValue());
|
|
|
log.info("payTotalFee.get()=------=-=-====" + payTotalFee.get());
|
|
|
- // 运费标志:0包邮 -1到付 1遵循运费规则
|
|
|
- // mainOrder.setPostageFlag(orderParamBo.getPostageFlag());
|
|
|
-// if (1 == orderParamBo.getPostageFlag() && orderParamBo.getOffsetBeans() > 0) {
|
|
|
-// // 订单总额 = 商品费 - 优惠券金额
|
|
|
-// payTotalFee.set(MathUtil.sub(productTotalFee.get(), couponAmount).doubleValue());
|
|
|
-// } else {
|
|
|
- // 订单总额 -= 优惠券金额
|
|
|
- payTotalFee.set(MathUtil.sub(payTotalFee.get(), couponAmount).doubleValue());
|
|
|
-// }
|
|
|
+ // 订单总额 -= 优惠券金额
|
|
|
+ payTotalFee.set(MathUtil.sub(payTotalFee.get(), couponAmount).doubleValue());
|
|
|
// 超级会员优惠
|
|
|
mainOrder.setSvipFullReduction(svipFullReduction.get());
|
|
|
// 商品总额
|
|
@@ -1264,7 +1239,6 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
log.info("订单总额" + payTotalFee.get());
|
|
|
// 判断前端传入orderShouldPayFee订单应付金额,和后台计算应付金额对比
|
|
|
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());
|
|
|
if (compare != 0) {
|
|
|
// 设置手动回滚事务
|
|
@@ -1333,9 +1307,6 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
//子订单分多子订单,满减分摊到原子订单分开的子订单,无满减重算佣金/应付
|
|
|
//重组订单
|
|
|
shopOrderList = findSplitShopOrder(orderProductList, shopOrderList, shops, orderParamBo);
|
|
|
- //线上支付分摊优惠总和到子订单
|
|
|
- //经理折扣+优惠券+满减 提交订单的时候无经理折扣
|
|
|
- double allDiscount = MathUtil.add(couponAmount, promotionFullReduction.get()).doubleValue();
|
|
|
// 分摊优惠前总佣金
|
|
|
AtomicDouble oldBrokerage = new AtomicDouble(0);
|
|
|
//超级会员价/复购价/阶梯价/促销活动冲突,只能生效一个,促销活动满减计入优惠分摊,子订单售价=realNeedPay+promotionFullReduction
|
|
@@ -1343,6 +1314,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
orderShopPo.setOldPrice(orderShopPo.getNeedPayAmount());
|
|
|
orderShopPo.setOldBrokerage(orderShopPo.getBrokerage());
|
|
|
oldBrokerage.set(MathUtil.add(oldBrokerage.get(), orderShopPo.getOldBrokerage()).doubleValue());
|
|
|
+
|
|
|
});
|
|
|
// 按分摊前的佣金排序
|
|
|
shopOrderList.sort((o1, o2) -> o2.getOldBrokerage().compareTo(o1.getOldBrokerage()));
|
|
@@ -1350,86 +1322,38 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
/** todo
|
|
|
* 当前版本为子订单下单,且优惠仅存在供应商优惠,优惠金额应从供应商成本扣除,暂时去除均摊优惠逻辑
|
|
|
*/
|
|
|
-// AtomicDouble allReduction = new AtomicDouble(0);
|
|
|
-// if (allDiscount > 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()), 2).doubleValue();
|
|
|
-// shopOrderList.get(i).setEachDiscount(v);
|
|
|
-// //子订单真实支付金额
|
|
|
-// double realPay = MathUtil.round(MathUtil.sub(shopOrderList.get(i).getOldPrice(), v), 2).doubleValue();
|
|
|
-// shopOrderList.get(i).setRealPay(realPay);
|
|
|
-// 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).setEachDiscount(v);
|
|
|
-// shopOrderList.get(i).setRealPay(MathUtil.round(MathUtil.sub(shopOrderList.get(i).getOldPrice(), v), 2).doubleValue());
|
|
|
-// }
|
|
|
-// //有优惠金额,最高手续费=支付金额*0.65%>10取0.65,不大于取10(合利宝最高0.65%)
|
|
|
-// double realPay = shopOrderList.get(i).getRealPay();
|
|
|
-// //佣金
|
|
|
-// double bro = MathUtil.sub(realPay, shopOrderList.get(i).getShouldPayShopAmount()).doubleValue();
|
|
|
-// //成本>实付不能线上
|
|
|
-// if (bro < 0) {
|
|
|
-// onlinePay.set(false);
|
|
|
-// } else {
|
|
|
-// double WXCharge = MathUtil.mul(realPay, 0.0065, 2).doubleValue();
|
|
|
-// double QuickCharge = MathUtil.mul(realPay, 0.006, 2).doubleValue();
|
|
|
-// double AliCharge = MathUtil.mul(realPay, 0.0025, 2).doubleValue();
|
|
|
-// double B2CCharge = MathUtil.mul(realPay, 0.002, 2).doubleValue();
|
|
|
-// //佣金和手续费比较,佣金>手续费则可以走当前支付渠道
|
|
|
-// //支持子订单佣金小于最小手续费时,也能进行线上支付,此时不限制支付方式(佣金大于最大手续费或小于最小手续费支持全渠道付款)
|
|
|
-// String payWays = "";
|
|
|
-// payWays += bro >= WXCharge ? "1" : "";
|
|
|
-// payWays += bro >= AliCharge ? ",2" : "";
|
|
|
-// payWays += bro >= B2CCharge ? ",3" : "";
|
|
|
-// payWays += bro >= 10 ? ",4" : "";
|
|
|
-// payWays += bro >= QuickCharge ? ",5" : "";
|
|
|
-// //小于所有的情况下线下补手续费,开放所有渠道
|
|
|
-// if ("".equals(payWays)) {
|
|
|
-// payWays = "1,2,3,4,5";
|
|
|
-// }
|
|
|
-// shopOrderList.get(i).setOnlinePayWays(payWays);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } else {
|
|
|
- //无优惠金额
|
|
|
- shopOrderList.forEach(so -> {
|
|
|
- //不包含优惠的真实支付金额=子订单应付?
|
|
|
- double realPay = so.getNeedPayAmount();
|
|
|
- so.setRealPay(realPay);
|
|
|
- so.setEachDiscount(0d);
|
|
|
- double bro = so.getBrokerage();
|
|
|
- so.setRealPay(realPay);
|
|
|
- so.setEachDiscount(0d);
|
|
|
- //成本>实付不能线上
|
|
|
- if (bro < 0) {
|
|
|
- onlinePay.set(false);
|
|
|
- } else {
|
|
|
- double WXCharge = MathUtil.mul(realPay, 0.0065, 2).doubleValue();
|
|
|
- double QuickCharge = MathUtil.mul(realPay, 0.006, 2).doubleValue();
|
|
|
- double AliCharge = MathUtil.mul(realPay, 0.0025, 2).doubleValue();
|
|
|
- double B2CCharge = MathUtil.mul(realPay, 0.002, 2).doubleValue();
|
|
|
- //佣金和手续费比较,佣金>手续费则可以走当前支付渠道
|
|
|
- //支持子订单佣金小于最小手续费时,也能进行线上支付,此时不限制支付方式(佣金大于最大手续费或小于最小手续费支持全渠道付款)
|
|
|
- String payWays = "";
|
|
|
- payWays += bro >= WXCharge ? "1" : "";
|
|
|
- payWays += bro >= AliCharge ? ",2" : "";
|
|
|
- payWays += bro >= B2CCharge ? ",3" : "";
|
|
|
- payWays += bro >= 10 ? ",4" : "";
|
|
|
- payWays += bro >= QuickCharge ? ",5" : "";
|
|
|
- //小于所有的情况下线下补手续费,开放所有渠道
|
|
|
- if ("".equals(payWays)) {
|
|
|
- payWays = "1,2,3,4,5";
|
|
|
- }
|
|
|
- so.setOnlinePayWays(payWays);
|
|
|
+ //无优惠金额
|
|
|
+ shopOrderList.forEach(so -> {
|
|
|
+ //不包含优惠的真实支付金额=子订单应付?
|
|
|
+ double realPay = so.getNeedPayAmount();
|
|
|
+ so.setRealPay(realPay);
|
|
|
+ so.setEachDiscount(0d);
|
|
|
+ double bro = so.getBrokerage();
|
|
|
+ so.setRealPay(realPay);
|
|
|
+ so.setEachDiscount(0d);
|
|
|
+ //成本>实付不能线上
|
|
|
+ if (bro < 0) {
|
|
|
+ onlinePay.set(false);
|
|
|
+ } else {
|
|
|
+ double WXCharge = MathUtil.mul(realPay, 0.0065, 2).doubleValue();
|
|
|
+ double QuickCharge = MathUtil.mul(realPay, 0.006, 2).doubleValue();
|
|
|
+ double AliCharge = MathUtil.mul(realPay, 0.0025, 2).doubleValue();
|
|
|
+ double B2CCharge = MathUtil.mul(realPay, 0.002, 2).doubleValue();
|
|
|
+ //佣金和手续费比较,佣金>手续费则可以走当前支付渠道
|
|
|
+ //支持子订单佣金小于最小手续费时,也能进行线上支付,此时不限制支付方式(佣金大于最大手续费或小于最小手续费支持全渠道付款)
|
|
|
+ String payWays = "";
|
|
|
+ payWays += bro >= WXCharge ? "1" : "";
|
|
|
+ payWays += bro >= AliCharge ? ",2" : "";
|
|
|
+ payWays += bro >= B2CCharge ? ",3" : "";
|
|
|
+ payWays += bro >= 10 ? ",4" : "";
|
|
|
+ payWays += bro >= QuickCharge ? ",5" : "";
|
|
|
+ //小于所有的情况下线下补手续费,开放所有渠道
|
|
|
+ if ("".equals(payWays)) {
|
|
|
+ payWays = "1,2,3,4,5";
|
|
|
}
|
|
|
- });
|
|
|
-// }
|
|
|
+ so.setOnlinePayWays(payWays);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
/*
|
|
|
* 整理 子订单信息cm_shop_order
|
|
@@ -1478,15 +1402,10 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
shopOrder.setRealPay(shopOrder.getNeedPayAmount());
|
|
|
}
|
|
|
shopOrder.setClubId(clubId);
|
|
|
- // 设置运费
|
|
|
- /*boolean shopFlag = ( 1 == shopOrder.getShopPostFlag() && (null != mainOrder.getUserBeans() && 0 == mainOrder.getUserBeans()) ) || ( 0 == shopOrder.getShopPostFlag() && isColdChina.get() > 0.00d && 0 != organizeId ) || ( -1 == shopOrder.getShopPostFlag() && isColdChina.get() > 0.00d && 0 != organizeId );
|
|
|
- if (!shopFlag) {
|
|
|
- shopOrder.setShopPostFee(0d);
|
|
|
- }*/
|
|
|
/*
|
|
|
* 保存子订单
|
|
|
*/
|
|
|
- log.info("shopOrderStatus======"+shopOrder.getShopStatus());
|
|
|
+ log.info("shopOrderStatus======" + shopOrder.getShopStatus());
|
|
|
submitMapper.insertShopOrder(shopOrder);
|
|
|
log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增子订单(insert[cm_shop_order])shopOrderId:" + shopOrder.getShopOrderId() + ",orderId:" + mainOrder.getOrderId());
|
|
|
// 收集子订单Id字符串
|
|
@@ -1497,7 +1416,48 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- /*
|
|
|
+ /**
|
|
|
+ * 保存优惠券使用情况
|
|
|
+ * todo
|
|
|
+ * 重排子订单后,对促销活动和优惠券的优惠金额对子订单进行减免,
|
|
|
+ * 当前版本存在问题,当子订单中商品有多个商户号时,以上根据商户号重新分配子订单会把一个供应商多个商户号的子订单拆分为多个,
|
|
|
+ * 此时优惠金额无法再次分配
|
|
|
+ */
|
|
|
+ if (null != orderParamBo.getClubCouponId() && orderParamBo.getClubCouponId() > 0) {
|
|
|
+ /** 修改优惠券使用情况
|
|
|
+ * couponType = 0/3
|
|
|
+ * 当前版本仅开放指定商品优惠券和店铺券,优惠券减免金额算作指定商品的供应商/店铺卷供应商对应子订购单的金额减免
|
|
|
+ * totalAmount/needPayAmount/discountAmount应减去优惠券金额
|
|
|
+ * preferential加上优惠券金额
|
|
|
+ */
|
|
|
+ if (3 != orderParamBo.getCartType()) {
|
|
|
+ // 自主订单立即确认,协销订单待确认 ,确认订单时才真正使用优惠券
|
|
|
+ orderClubMapper.updateCouponClubStatus(orderParamBo.getClubCouponId(), mainOrder.getOrderId());
|
|
|
+ }
|
|
|
+ CouponVo finalCoupon = coupon;
|
|
|
+ shopOrderList.forEach(s -> {
|
|
|
+ if (0 == finalCoupon.getCouponType() || 3 == finalCoupon.getCouponType()) {
|
|
|
+ // 当前版本所有指定商品均出自综合供应商,所以limit1
|
|
|
+ Integer shopId = null == finalCoupon.getShopId() ? baseMapper.findShopIdByProduct(finalCoupon.getCouponId()) : finalCoupon.getShopId();
|
|
|
+ s.setCouponAmount(finalCoupon.getCouponAmount());
|
|
|
+ s.setCouponClubId(finalCoupon.getClubCouponId());
|
|
|
+ if (s.getShopId().equals(shopId)) {
|
|
|
+ s.setNeedPayAmount(s.getNeedPayAmount() - finalCoupon.getCouponAmount());
|
|
|
+ s.setTotalAmount(s.getTotalAmount() - finalCoupon.getCouponAmount());
|
|
|
+ s.setRealPay(s.getRealPay() - finalCoupon.getCouponAmount());
|
|
|
+ }
|
|
|
+ submitMapper.updateShopOrderCoupon(s);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CouponOrderRecordPo orderRecord = new CouponOrderRecordPo();
|
|
|
+ BeanUtils.copyProperties(coupon, orderRecord);
|
|
|
+ orderRecord.setOrderId(mainOrder.getOrderId());
|
|
|
+ orderRecord.setCreateDate(date);
|
|
|
+ // 保存订单优惠券使用记录
|
|
|
+ submitMapper.insertCouponOrderRecord(orderRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 订单商品分子订单cm_order_product
|
|
|
*/
|
|
|
for (OrderProductPo orderProduct : orderProductList) {
|
|
@@ -1558,121 +1518,6 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 设置邮费子订单( 0包邮 -1到付 1遵循运费规则)
|
|
|
- * 采美豆抵扣不生成
|
|
|
- * 版本不在使用运费子订单
|
|
|
- */
|
|
|
-// if (organizeId == 998 && ( 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);
|
|
|
-// // 生成子订单编号
|
|
|
-// StringBuilder postageOrderNo = new StringBuilder();
|
|
|
-// postageOrderNo.append(mainOrder.getOrderNo());
|
|
|
-// if (shopOrderIndex.get() < 10) {
|
|
|
-// postageOrderNo.append("0");
|
|
|
-// }
|
|
|
-// postageOrderNo.append(shopOrderIndex.get());
|
|
|
-// shopOrderIndex.incrementAndGet();
|
|
|
-// /*
|
|
|
-// * 初始化邮费订单
|
|
|
-// */
|
|
|
-// OrderShopPo postageOrder = new OrderShopPo();
|
|
|
-// postageOrder.setShopOrderNo(postageOrderNo.toString());
|
|
|
-// postageOrder.setOrderNo(mainOrder.getOrderNo());
|
|
|
-// postageOrder.setOrderId(mainOrder.getOrderId());
|
|
|
-// postageOrder.setUserId(mainOrder.getUserId());
|
|
|
-// postageOrder.setOrderSubmitType(mainOrder.getOrderSubmitType());
|
|
|
-// postageOrder.setItemCount(1);
|
|
|
-// if (0 == organizeId) {
|
|
|
-// postageOrder.setSplitCode(Constant.CUSTOMERNUM);
|
|
|
-// } else {
|
|
|
-// // 联合丽格
|
|
|
-// postageOrder.setSplitCode(Constant.BCCMERCHANT);
|
|
|
-// }
|
|
|
-// // 冷链运输费
|
|
|
-// if (isColdChina.get() >= 700) {
|
|
|
-// postageOrder.setIsColdChina(1);
|
|
|
-// mainOrder.setPostage(MathUtil.add(mainOrder.getPostage(), isColdChina.get()).doubleValue());
|
|
|
-// } else {
|
|
|
-// postageOrder.setIsColdChina(0);
|
|
|
-// }
|
|
|
-// postageOrder.setRealPay(mainOrder.getPostage());
|
|
|
-// postageOrder.setEachDiscount(0d);
|
|
|
-//
|
|
|
-// //运费商品供应商Id默认998
|
|
|
-// postageOrder.setShopId(postageProduct.getShopId());
|
|
|
-// postageOrder.setProductAmount(mainOrder.getPostage());
|
|
|
-// postageOrder.setTotalAmount(mainOrder.getPostage());
|
|
|
-// postageOrder.setNeedPayAmount(mainOrder.getPostage());
|
|
|
-// postageOrder.setOrderTime(mainOrder.getOrderTime());
|
|
|
-// postageOrder.setCanRefundAmount(0d);
|
|
|
-// postageOrder.setClubId(mainOrder.getClubId());
|
|
|
-// // 已付供应商金额
|
|
|
-// postageOrder.setPayedShopAmount(0d);
|
|
|
-// // (付款供应商)付款状态:1待付款、2部分付款、3已付款
|
|
|
-// postageOrder.setPayStatus(3);
|
|
|
-// if (3 == orderParamBo.getCartType()) {
|
|
|
-// // 协销订单
|
|
|
-// postageOrder.setSpId(orderParamBo.getBuyUserId());
|
|
|
-// postageOrder.setOrderType(0);
|
|
|
-// } else {
|
|
|
-// // 普通订单
|
|
|
-// postageOrder.setOrderType(1);
|
|
|
-// }
|
|
|
-// // 订单默认可拆分
|
|
|
-// postageOrder.setSplitFlag(1);
|
|
|
-// // 设置组织Id
|
|
|
-// postageOrder.setOrganizeId(organizeId);
|
|
|
-// /*
|
|
|
-// * 保存运费子订单
|
|
|
-// */
|
|
|
-// submitMapper.insertShopOrder(postageOrder);
|
|
|
-// log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增子订单(运费商品)(insert[cm_shop_order])shopOrderId::" + postageOrder.getShopOrderId() + ",orderId:" + mainOrder.getOrderId());
|
|
|
-// // 收集子订单Id字符串
|
|
|
-// if (StringUtils.isEmpty(shopOrderIds.get())) {
|
|
|
-// shopOrderIds.set(postageOrder.getShopOrderId().toString());
|
|
|
-// } else {
|
|
|
-// shopOrderIds.set(shopOrderIds.get() + "," + postageOrder.getShopOrderId());
|
|
|
-// }
|
|
|
-// // 有冷链运输费 且大于 0 修改主订单运费状态
|
|
|
-// if (MathUtil.add(mainOrder.getPostage(), isColdChina.get()).doubleValue() > 0) {
|
|
|
-// submitMapper.updateOrder(mainOrder.getPostage().doubleValue(), mainOrder.getOrderId());
|
|
|
-// }
|
|
|
-// /*
|
|
|
-// * 设置运费商品
|
|
|
-// */
|
|
|
-// postageProduct.setOrderNo(mainOrder.getOrderNo());
|
|
|
-// postageProduct.setOrderId(mainOrder.getOrderId());
|
|
|
-// postageProduct.setShopOrderId(postageOrder.getShopOrderId());
|
|
|
-// postageProduct.setShopOrderNo(postageOrder.getShopOrderNo());
|
|
|
-// postageProduct.setNum(1);
|
|
|
-// postageProduct.setPresentNum(0);
|
|
|
-// postageProduct.setPrice(mainOrder.getPostage());
|
|
|
-// postageProduct.setNormalPrice(mainOrder.getPostage());
|
|
|
-// postageProduct.setTotalAmount(mainOrder.getPostage());
|
|
|
-// postageProduct.setTotalFee(mainOrder.getPostage());
|
|
|
-// postageProduct.setShouldPayFee(mainOrder.getPostage());
|
|
|
-// postageProduct.setDiscount(100d);
|
|
|
-// postageProduct.setDiscountPrice(mainOrder.getPostage());
|
|
|
-// postageProduct.setTaxRate(100d);
|
|
|
-// postageProduct.setAddedValueTax(0d);
|
|
|
-// postageProduct.setTotalAddedValueTax(0d);
|
|
|
-// postageProduct.setShopFee(0d);
|
|
|
-// postageProduct.setOtherFee(0d);
|
|
|
-// postageProduct.setCmFee(mainOrder.getPostage());
|
|
|
-// postageProduct.setSingleShopFee(0d);
|
|
|
-// postageProduct.setSingleOtherFee(0d);
|
|
|
-// postageProduct.setSingleCmFee(mainOrder.getPostage());
|
|
|
-// postageProduct.setNotOutStore(0);
|
|
|
-// postageProduct.setBuyAgainFlag(0);
|
|
|
-// /*
|
|
|
-// * 保存 订单运费商品
|
|
|
-// */
|
|
|
-// submitMapper.insertOrderProduct(postageProduct);
|
|
|
-// log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>保存订单运费商品(insert[cm_order_product])OrderProductId:" + postageProduct.getOrderProductId() + ",orderId:" + mainOrder.getOrderId());
|
|
|
-// }
|
|
|
-
|
|
|
- /*
|
|
|
* 更新主订单的子订单Id信息,如:1000,1002
|
|
|
*/
|
|
|
if (StringUtils.isNotEmpty(shopOrderIds.get())) {
|
|
@@ -1744,7 +1589,6 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
if (1 == orderParamBo.getBalancePayFlag() && MathUtil.compare(balancePayFee.get(), 0) > 0) {
|
|
|
// 保存余额抵扣到收款记录(自主订单)
|
|
|
if (3 != orderParamBo.getCartType()) {
|
|
|
- Integer orderId = mainOrder.getOrderId();
|
|
|
productService.saveDiscernReceipt(balancePayFee.get(), shopOrderList, "【提交订单】");
|
|
|
}
|
|
|
}
|
|
@@ -1810,86 +1654,26 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
productService.updateUserBeans(beansHistory, beans, "【提交订单】");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 自主下单价格低于1000,倒扣500采美豆
|
|
|
- */
|
|
|
if (0 == organizeId) {
|
|
|
-// try {
|
|
|
-// if (orderParamBo.getCartType() != 3 && payTotalFee.get() < 1000) {
|
|
|
-// if (orderParamBo.getUserBeans() < 0) {
|
|
|
-// //设置手动回滚事务
|
|
|
-// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
-// return ResponseJson.error(-4, "采美豆不足,不能提交订单。建议您前往采美旗下“呵呵商城”小程序购买小额商品。");
|
|
|
-// } else {
|
|
|
-// //查历史2021.10.27后是否有两个1000以下订单,有return不让下单,没有扣豆子
|
|
|
-// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
-// Date orderTime = format.parse("2021-10-28 10:40:01");
|
|
|
-// List<Integer> mainOrderIds = submitMapper.findLowOrder(mainOrder.getUserId(), orderTime);
|
|
|
-// if (mainOrderIds != null && mainOrderIds.size() > 2) {
|
|
|
-// //设置手动回滚事务
|
|
|
-// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
-// return ResponseJson.error(-3, "您已有2个采购金额过小的订单,本次不能再进行采购。您可使用微信扫描以下二维码,进入采美旗下“呵呵商城”小程序购买小额商品");
|
|
|
-// }
|
|
|
-// if (orderParamBo.getOrderMiniType() == 0) {
|
|
|
-// if (mainOrderIds != null && mainOrderIds.size() <= 1) {
|
|
|
-// // 设置手动回滚事务
|
|
|
-// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
-// return ResponseJson.error(-5, "采购金额过小,将扣除500采美豆,建议您使用微信扫描以下二维码,进入采美旗下“呵呵商城”小程序购买小额商品。");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// log.info("订单提交状态:" + orderParamBo.getOrderMiniType());
|
|
|
-// UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
|
|
|
-// beansHistory.setUserId(mainOrder.getUserId());
|
|
|
-// beansHistory.setOrderId(mainOrder.getOrderId());
|
|
|
-// beansHistory.setBeansType(15);
|
|
|
-// beansHistory.setType(2);
|
|
|
-// beansHistory.setNum(500);
|
|
|
-// beansHistory.setPushStatus(0);
|
|
|
-// beansHistory.setAddTime(date);
|
|
|
-// beansHistory.setDelFlag(0);
|
|
|
-// int beans = baseMapper.findBeans(orderParamBo.getUserId()) - 500;
|
|
|
-// productService.updateUserBeans(beansHistory, beans, "【价格低于1000,倒扣500采美豆】");
|
|
|
-// }
|
|
|
-// }
|
|
|
- if (orderParamBo.getOrderMiniType() != 2) {
|
|
|
- boolean bol = false;
|
|
|
- // 机构一级分类
|
|
|
- String firstClubType = baseMapper.firstClubTypeById(orderParamBo.getClubId());
|
|
|
- if (!StringUtils.isNotBlank(firstClubType)) {
|
|
|
- firstClubType = "0";
|
|
|
- }
|
|
|
- // 获取订单商品械字号类型
|
|
|
- List<String> machineType = baseMapper.machineTypeByID(skuIdList);
|
|
|
- for (String str : machineType) {
|
|
|
- if ("3".equals(str)) {
|
|
|
- bol = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!"1".equals(firstClubType) && bol) {
|
|
|
- // 设置手动回滚事务
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- return ResponseJson.error(-6, "订单内存在械字号三类商品,需要拥有医疗执业许可证的医美机构才能购买。建议升级医美机构后再下单,否则会导致订单退款或影响发货。");
|
|
|
+ if (orderParamBo.getOrderMiniType() != 2) {
|
|
|
+ boolean bol = false;
|
|
|
+ // 机构一级分类
|
|
|
+ String firstClubType = baseMapper.firstClubTypeById(orderParamBo.getClubId());
|
|
|
+ if (!StringUtils.isNotBlank(firstClubType)) {
|
|
|
+ firstClubType = "0";
|
|
|
+ }
|
|
|
+ // 获取订单商品械字号类型
|
|
|
+ List<String> machineType = baseMapper.machineTypeByID(skuIdList);
|
|
|
+ for (String str : machineType) {
|
|
|
+ if ("3".equals(str)) {
|
|
|
+ bol = true;
|
|
|
}
|
|
|
}
|
|
|
-// } catch (ParseException e) {
|
|
|
-// log.info("自主下单价格低于1000,倒扣500采美豆", e);
|
|
|
-// }
|
|
|
-
|
|
|
- /*
|
|
|
- * 保存优惠券使用情况
|
|
|
- */
|
|
|
- if (null != orderParamBo.getClubCouponId() && orderParamBo.getClubCouponId() > 0) {
|
|
|
- // 修改优惠券使用情况
|
|
|
- if (3 != orderParamBo.getCartType()) {
|
|
|
- // 自主订单立即确认,协销订单待确认 ,确认订单时才真正使用优惠券
|
|
|
- orderClubMapper.updateCouponClubStatus(orderParamBo.getClubCouponId(), mainOrder.getOrderId());
|
|
|
+ if (!"1".equals(firstClubType) && bol) {
|
|
|
+ // 设置手动回滚事务
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return ResponseJson.error(-6, "订单内存在械字号三类商品,需要拥有医疗执业许可证的医美机构才能购买。建议升级医美机构后再下单,否则会导致订单退款或影响发货。");
|
|
|
}
|
|
|
- CouponOrderRecordPo orderRecord = new CouponOrderRecordPo();
|
|
|
- BeanUtils.copyProperties(coupon, orderRecord);
|
|
|
- orderRecord.setOrderId(mainOrder.getOrderId());
|
|
|
- orderRecord.setCreateDate(date);
|
|
|
- // 保存订单优惠券使用记录
|
|
|
- submitMapper.insertCouponOrderRecord(orderRecord);
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
@@ -1911,17 +1695,10 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
String name = "0";
|
|
|
try {
|
|
|
String accessToken = weChatService.getAccessToken();
|
|
|
-// orderClubMapper.getOpenidunionId(orderClubMapper.getUserId(mainOrder.getOrderId()))
|
|
|
List<String> openidList = orderClubMapper.getOpenidListByPermission(orderParamBo.getUnionId());
|
|
|
orderClubMapper.AddUnionId(orderParamBo.getUnionId(), mainOrder.getOrderId());
|
|
|
openidList.removeIf(Objects::isNull);
|
|
|
String i = orderClubMapper.getOrderIds(mainOrder.getOrderId()).toString();
|
|
|
- /*if (i.length() < 10) {
|
|
|
- name = StringUtils.strip(i, "[]");
|
|
|
- } else {
|
|
|
- name = StringUtils.strip(i.substring(0, 11), "[]");
|
|
|
- name += "...";
|
|
|
- }*/
|
|
|
name = StringUtils.strip(i, "[]");
|
|
|
log.info("订单商品>>>>>" + name + "" + mainOrder.getOrderId());
|
|
|
String associateTitle = "订单已成功提交,等待付款!";
|
|
@@ -1953,8 +1730,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
if (name.length() > 10) {
|
|
|
name = name.substring(0, 10);
|
|
|
}
|
|
|
- String content = "您已成功下单“" + name + "...”等" + mainOrder.getProductCount() + "件商品,订单编号:" + mainOrder.getOrderNo() + ",订单等待支付,支付完成后采美将尽快安排发货。" +
|
|
|
- "您可关注采美公众号或者访问采美微信小程序和网站查看并支付订单。平台公众号:微信搜索“采美365网”; 微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
|
|
|
+ String content = "您已成功下单“" + name + "...”等" + mainOrder.getProductCount() + "件商品,订单编号:" + mainOrder.getOrderNo() + ",订单等待支付,支付完成后采美将尽快安排发货。" + "您可关注采美公众号或者访问采美微信小程序和网站查看并支付订单。平台公众号:微信搜索“采美365网”; 微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
|
|
|
boolean sendSms = remoteCallService.getSendSms(1, 3, orderParamBo.getBindMobile(), content);
|
|
|
if (!sendSms) {
|
|
|
log.info("下单推送失败,orderId>>>>" + mainOrder.getOrderId());
|
|
@@ -2458,7 +2234,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
product.setShopTaxRate(product.getTaxRate());
|
|
|
}
|
|
|
if (taxFlag) {
|
|
|
- shopTax = MathUtil.div(MathUtil.mul(MathUtil.div(costPrice,MathUtil.div(MathUtil.add(product.getTaxRate(), 100),100)), product.getShopTaxRate()), 100, 2).doubleValue();
|
|
|
+ shopTax = MathUtil.div(MathUtil.mul(MathUtil.div(costPrice, MathUtil.div(MathUtil.add(product.getTaxRate(), 100), 100)), product.getShopTaxRate()), 100, 2).doubleValue();
|
|
|
} else if (!Integer.valueOf(1).equals(product.getIncludedTax())) {
|
|
|
// 不含税不可开票商品和未知商品,税率置为0
|
|
|
product.setShopTaxRate(0d);
|
|
@@ -2520,18 +2296,18 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
|
|
|
// 成本 | 佣金比例 商城sku配置 成本 | 佣金比例
|
|
|
CmOrganizeSkuPo organizeSkuInfo = submitMapper.getOrganizeSkuInfo(skuId, orderProduct.getOrganizeId());
|
|
|
- if ( StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
|
|
|
+ if (StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
|
|
|
// 固定成本
|
|
|
if (taxFlag) {
|
|
|
- organizeSkuInfo.setOrganizeCostPrice(MathUtil.add(organizeSkuInfo.getOrganizeCostPrice(), MathUtil.div( MathUtil.mul(organizeSkuInfo.getOrganizeCostPrice(), product.getTaxRate()), 100)).doubleValue());
|
|
|
- organizeSkuInfo.setCmCostPrice(MathUtil.add(organizeSkuInfo.getCmCostPrice(), MathUtil.div( MathUtil.mul(organizeSkuInfo.getCmCostPrice(), product.getTaxRate()), 100)).doubleValue());
|
|
|
+ organizeSkuInfo.setOrganizeCostPrice(MathUtil.add(organizeSkuInfo.getOrganizeCostPrice(), MathUtil.div(MathUtil.mul(organizeSkuInfo.getOrganizeCostPrice(), product.getTaxRate()), 100)).doubleValue());
|
|
|
+ organizeSkuInfo.setCmCostPrice(MathUtil.add(organizeSkuInfo.getCmCostPrice(), MathUtil.div(MathUtil.mul(organizeSkuInfo.getCmCostPrice(), product.getTaxRate()), 100)).doubleValue());
|
|
|
}
|
|
|
product.setOrganizeCostPrice(organizeSkuInfo.getOrganizeCostPrice());
|
|
|
product.setCmCostPrice(organizeSkuInfo.getCmCostPrice());
|
|
|
}
|
|
|
- if ( StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "2".equals(organizeSkuInfo.getCostCheckFlag())) {
|
|
|
+ if (StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "2".equals(organizeSkuInfo.getCostCheckFlag())) {
|
|
|
// 比例成本
|
|
|
- product.setOrganizeCostPrice(MathUtil.div(MathUtil.mul(product.getPrice(),organizeSkuInfo.getOrganizePercent()), 100).doubleValue());
|
|
|
+ product.setOrganizeCostPrice(MathUtil.div(MathUtil.mul(product.getPrice(), organizeSkuInfo.getOrganizePercent()), 100).doubleValue());
|
|
|
product.setCmCostPrice(MathUtil.div(MathUtil.mul(product.getPrice(), organizeSkuInfo.getCmPercent()), 100).doubleValue());
|
|
|
|
|
|
product.setCmPercent(organizeSkuInfo.getCmPercent());
|