|
@@ -59,6 +59,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
private CartSellerMapper cartSellerMapper;
|
|
|
@Resource
|
|
|
private RemoteCallService remoteCallService;
|
|
|
+
|
|
|
/**
|
|
|
* 生成订单
|
|
|
*
|
|
@@ -71,49 +72,49 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
* "serviceProviderId": 1378, //协销ID(小程序忽略)
|
|
|
* "clubCouponId": "" //优惠券Id
|
|
|
* "orderInfo": [ //【订单商品】
|
|
|
- * { "shopId":1001, // 供应商Id
|
|
|
- * "note":备注,
|
|
|
- * "productInfo":[ // 商品id,数量,赠品数,商品类型
|
|
|
- * {"productId": 2789, "productNum": 1, "presentNum":0,"productType":2},
|
|
|
- * {"productId": 2789, "productNum": 1, "presentNum":0,"productType":0}
|
|
|
- * ]
|
|
|
- * },{多个供应商商品数据结构同上}
|
|
|
+ * { "shopId":1001, // 供应商Id
|
|
|
+ * "note":备注,
|
|
|
+ * "productInfo":[ // 商品id,数量,赠品数,商品类型
|
|
|
+ * {"productId": 2789, "productNum": 1, "presentNum":0,"productType":2},
|
|
|
+ * {"productId": 2789, "productNum": 1, "presentNum":0,"productType":0}
|
|
|
+ * ]
|
|
|
+ * },{多个供应商商品数据结构同上}
|
|
|
* ],
|
|
|
* "payInfo": { //【订单金额】
|
|
|
- * "orderShouldPayFee": 609.11,
|
|
|
- * "balancePayFlag": 0,
|
|
|
- * "clauseId": "2",
|
|
|
- * "postage": "15",
|
|
|
- * "postageFlag": 1, //运费标志:0包邮 -1到付 1遵循运费规则
|
|
|
- * "userBeans": 100,//抵扣采美豆数量
|
|
|
- * "rebateFlag":0
|
|
|
+ * "orderShouldPayFee": 609.11,
|
|
|
+ * "balancePayFlag": 0,
|
|
|
+ * "clauseId": "2",
|
|
|
+ * "postage": "15",
|
|
|
+ * "postageFlag": 1, //运费标志:0包邮 -1到付 1遵循运费规则
|
|
|
+ * "userBeans": 100,//抵扣采美豆数量
|
|
|
+ * "rebateFlag":0
|
|
|
* },
|
|
|
* "orderInvoice": //【发票信息】
|
|
|
- * {"type": 0 // 不开发票 }
|
|
|
- * 或: { // 普通发票
|
|
|
- * "type": 1,
|
|
|
- * "invoiceTitle": "企业抬头",
|
|
|
- * "invoiceTitleType": 1,
|
|
|
- * "corporationTaxNum": "XXX4156465465",
|
|
|
- * "invoiceContent": "明细 "
|
|
|
- * }
|
|
|
- * 或: { // 增值税发票
|
|
|
- * "type": 2,
|
|
|
- * "invoiceTitle": "单位名称",
|
|
|
- * "corporationTaxNum": "NSRSBM97897",
|
|
|
- * "registeredAddress": "注册地址",
|
|
|
- * "registeredPhone": "15814011616",
|
|
|
- * "openBank": "开户银行",
|
|
|
- * "bankAccountNo": "987987465465464"
|
|
|
- * }
|
|
|
- * }
|
|
|
+ * {"type": 0 // 不开发票 }
|
|
|
+ * 或: { // 普通发票
|
|
|
+ * "type": 1,
|
|
|
+ * "invoiceTitle": "企业抬头",
|
|
|
+ * "invoiceTitleType": 1,
|
|
|
+ * "corporationTaxNum": "XXX4156465465",
|
|
|
+ * "invoiceContent": "明细 "
|
|
|
+ * }
|
|
|
+ * 或: { // 增值税发票
|
|
|
+ * "type": 2,
|
|
|
+ * "invoiceTitle": "单位名称",
|
|
|
+ * "corporationTaxNum": "NSRSBM97897",
|
|
|
+ * "registeredAddress": "注册地址",
|
|
|
+ * "registeredPhone": "15814011616",
|
|
|
+ * "openBank": "开户银行",
|
|
|
+ * "bankAccountNo": "987987465465464"
|
|
|
+ * }
|
|
|
+ * }
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public ResponseJson<Map<String, Object>> generateOrder(SubmitDto submitDto) {
|
|
|
// 获取机构用户Id
|
|
|
Integer clubUserId = baseMapper.getUserIdByClubId(submitDto.getClubId());
|
|
|
- if (null == clubUserId || clubUserId == 0){
|
|
|
+ if (null == clubUserId || clubUserId == 0) {
|
|
|
return ResponseJson.error("机构用户信息异常!", null);
|
|
|
}
|
|
|
JSONArray orderInfo = null;
|
|
@@ -127,34 +128,37 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
log.error("订单参数解析异常try-catch:", e);
|
|
|
return ResponseJson.error("订单参数解析异常!", null);
|
|
|
}
|
|
|
- if (null == orderInfo || orderInfo.isEmpty()){
|
|
|
+ if (null == orderInfo || orderInfo.isEmpty()) {
|
|
|
return ResponseJson.error("订单商品数据异常!", null);
|
|
|
}
|
|
|
- if (null == payInfo || payInfo.isEmpty()){
|
|
|
+ if (null == payInfo || payInfo.isEmpty()) {
|
|
|
return ResponseJson.error("订单金额数据异常!", null);
|
|
|
}
|
|
|
- if (null == orderInvoice || orderInvoice.isEmpty()){
|
|
|
+ if (null == orderInvoice || orderInvoice.isEmpty()) {
|
|
|
return ResponseJson.error("发票信息数据异常!", null);
|
|
|
}
|
|
|
// 打印参数
|
|
|
- if (3 == submitDto.getCartType()){
|
|
|
- log.info("******************** 【协销订单】提交订单参数:"+ submitDto);
|
|
|
+ if (3 == submitDto.getCartType()) {
|
|
|
+ log.info("******************** 【协销订单】提交订单参数:" + submitDto);
|
|
|
} else if (2 == submitDto.getCartType()) {
|
|
|
- log.info("******************** 【自主订单】立即购买提交订单参数:"+ submitDto);
|
|
|
+ log.info("******************** 【自主订单】立即购买提交订单参数:" + submitDto);
|
|
|
} else {
|
|
|
- log.info("******************** 【自主订单】购物车提交订单参数:"+ submitDto);
|
|
|
+ log.info("******************** 【自主订单】购物车提交订单参数:" + submitDto);
|
|
|
}
|
|
|
// 机构用户
|
|
|
OrderParamBo orderParamBo = submitMapper.getOrderUserBoById(clubUserId);
|
|
|
+ //订单来源
|
|
|
orderParamBo.setOrderSource(submitDto.getOrderSource());
|
|
|
+ //订单商品
|
|
|
orderParamBo.setOrderInfo(orderInfo);
|
|
|
// 余额支付标识,0不使用,1使用
|
|
|
Integer balancePayFlag = (Integer) payInfo.get("balancePayFlag");
|
|
|
- // 判断用户可用余额是否wei0
|
|
|
+ // 判断用户可用余额是否为0
|
|
|
if (1 == balancePayFlag && null != orderParamBo.getAbleUserMoney() && MathUtil.compare(orderParamBo.getAbleUserMoney(), BigDecimal.ZERO) == 0) {
|
|
|
return ResponseJson.error("用户可用余额为0.00元!", null);
|
|
|
}
|
|
|
orderParamBo.setBalancePayFlag(balancePayFlag);
|
|
|
+ //订单应付总额
|
|
|
String orderShouldPayFee = (String) payInfo.get("orderShouldPayFee");
|
|
|
orderParamBo.setOrderShouldPayFee(Double.parseDouble(orderShouldPayFee));
|
|
|
// 运费标志:0包邮 -1到付 1遵循运费规则
|
|
@@ -176,10 +180,10 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
offsetBeans = 3000;
|
|
|
}
|
|
|
// 与前端传入采美豆数量比较
|
|
|
- if (null == orderParamBo.getUserBeans() || !userBeans.equals(offsetBeans)){
|
|
|
+ if (null == orderParamBo.getUserBeans() || !userBeans.equals(offsetBeans)) {
|
|
|
return ResponseJson.error("采美豆数据异常!", null);
|
|
|
}
|
|
|
- if (orderParamBo.getUserBeans()<=0) {
|
|
|
+ if (orderParamBo.getUserBeans() <= 0) {
|
|
|
return ResponseJson.error("用户没有剩余采美豆!", null);
|
|
|
}
|
|
|
} else {
|
|
@@ -192,20 +196,20 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
return ResponseJson.error("发票类型不能为空!", null);
|
|
|
}
|
|
|
orderParamBo.setInvoiceType(invoiceType);
|
|
|
- if (1== invoiceType || 2 == invoiceType) {
|
|
|
+ if (1 == invoiceType || 2 == invoiceType) {
|
|
|
InvoicePo invoice = new InvoicePo();
|
|
|
String invoiceTitle = (String) orderInvoice.get("invoiceTitle");
|
|
|
- if (StringUtils.isEmpty(invoiceTitle)){
|
|
|
+ if (StringUtils.isEmpty(invoiceTitle)) {
|
|
|
return ResponseJson.error("发票抬头信息不正确!", null);
|
|
|
}
|
|
|
String corporationTaxNum = (String) orderInvoice.get("corporationTaxNum");
|
|
|
- if (StringUtils.isEmpty(corporationTaxNum)){
|
|
|
+ if (StringUtils.isEmpty(corporationTaxNum)) {
|
|
|
return ResponseJson.error("纳税人识别号信息不正确!", null);
|
|
|
}
|
|
|
invoice.setType(invoiceType);
|
|
|
invoice.setInvoiceTitle(invoiceTitle);
|
|
|
invoice.setCorporationTaxNum(corporationTaxNum);
|
|
|
- if (1== invoiceType) {
|
|
|
+ if (1 == invoiceType) {
|
|
|
// 普通发票:发票类型、发票内容(商品明细)、抬头(公司名称)、纳税人识别号[普通发票的公司]
|
|
|
String invoiceContent = (String) orderInvoice.get("invoiceContent");
|
|
|
Integer invoiceTitleType = (Integer) orderInvoice.get("invoiceTitleType");
|
|
@@ -215,7 +219,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
invoice.setInvoiceContent(invoiceContent);
|
|
|
invoice.setInvoiceTitleType(invoiceTitleType);
|
|
|
}
|
|
|
- if (2== invoiceType) {
|
|
|
+ if (2 == invoiceType) {
|
|
|
// 增值税发票:发票类型、发票、抬头(公司名称)、纳税人识别号、注册地址、注册电话、开户银行、开户银行账户
|
|
|
String registeredAddress = (String) orderInvoice.get("registeredAddress");
|
|
|
String registeredPhone = (String) orderInvoice.get("registeredPhone");
|
|
@@ -241,20 +245,20 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
orderParamBo.setCartType(submitDto.getCartType());
|
|
|
// 下单人
|
|
|
Integer buyUserId = null;
|
|
|
- if (1 == submitDto.getCartType() || 2 == submitDto.getCartType()){
|
|
|
+ if (1 == submitDto.getCartType() || 2 == submitDto.getCartType()) {
|
|
|
// 自主下单
|
|
|
buyUserId = clubUserId;
|
|
|
if (StringUtils.isNotEmpty(submitDto.getUnionId())) {
|
|
|
// 运营人员Id
|
|
|
Integer operationId = submitMapper.getOperationIdByUnionId(submitDto.getUnionId(), clubUserId);
|
|
|
- if (null != operationId && operationId>0) {
|
|
|
+ if (null != operationId && operationId > 0) {
|
|
|
buyUserId = operationId;
|
|
|
}
|
|
|
}
|
|
|
- } else if (3 == submitDto.getCartType()){
|
|
|
+ } else if (3 == submitDto.getCartType()) {
|
|
|
// 协销下单, 获取协销用户Id
|
|
|
Integer spUserId = submitMapper.getServiceProviderUserId(submitDto.getServiceProviderId());
|
|
|
- if (null != spUserId && spUserId>0) {
|
|
|
+ if (null != spUserId && spUserId > 0) {
|
|
|
buyUserId = spUserId;
|
|
|
} else {
|
|
|
return ResponseJson.error("协销用户异常!", null);
|
|
@@ -284,7 +288,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
OrderPo mainOrder = new OrderPo();
|
|
|
// 订单来源
|
|
|
mainOrder.setOrderSource(orderParamBo.getOrderSource());
|
|
|
- // 订单号
|
|
|
+ // 生成订单号
|
|
|
String orderNo = CodeUtil.generateOrderNo(orderParamBo.getOrderSource());
|
|
|
mainOrder.setOrderNo(orderNo);
|
|
|
// 用户Id
|
|
@@ -298,6 +302,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
mainOrder.setUpdateDate(curDateStr);
|
|
|
// 订单状态 0 有效 其它无效
|
|
|
mainOrder.setDelFlag(0);
|
|
|
+ //协销下单
|
|
|
if (3 == orderParamBo.getCartType()) {
|
|
|
mainOrder.setSpId(orderParamBo.getServiceProviderId());
|
|
|
// 协销订单
|
|
@@ -368,7 +373,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
//促销活动ids
|
|
|
List<Integer> promotionsIds = new ArrayList<>();
|
|
|
// 促销活动信息
|
|
|
- List<PromotionsVo> promotionList= new ArrayList<>();
|
|
|
+ List<PromotionsVo> promotionList = new ArrayList<>();
|
|
|
// 订单商品列表
|
|
|
List<OrderProductPo> orderProductList = new ArrayList<>();
|
|
|
List<String> productIdList = new ArrayList<>();
|
|
@@ -376,7 +381,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 子订单订单列表
|
|
|
List<OrderShopPo> shopOrderList = new ArrayList<>();
|
|
|
JSONArray orderInfo = orderParamBo.getOrderInfo();
|
|
|
- for (Object infoObject: orderInfo) {
|
|
|
+ for (Object infoObject : orderInfo) {
|
|
|
JSONObject shopInfo = (JSONObject) infoObject;
|
|
|
Integer shopId = (Integer) shopInfo.get("shopId");
|
|
|
String shopNote = (String) shopInfo.get("note");
|
|
@@ -481,8 +486,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
product.setTaxRate(0d);
|
|
|
product.setAddedValueTax(0d);
|
|
|
product.setTotalAddedValueTax(0d);
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
// 获取商品购买价格(超级会员优惠商品价格>>>活动价格>>>阶梯价格>>>复购价格库>>>商品原始价)
|
|
|
Double productPrice = product.getPrice();
|
|
|
Double discountPrice = product.getPrice();
|
|
@@ -495,6 +499,14 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
if (null == shopPromotions) {
|
|
|
promotions = baseMapper.getPromotionByProductId(productId);
|
|
|
}
|
|
|
+ //促销活动如果协销不可见,置为空
|
|
|
+ Integer userIdentity = baseMapper.getIdentityByUserId(orderParamBo.getUserId());
|
|
|
+ if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
|
|
|
+ promotions = null;
|
|
|
+ }
|
|
|
+ if (shopPromotions != null && shopPromotions.getSeen() != null && shopPromotions.getSeen().equals("1") && userIdentity == 1) {
|
|
|
+ shopPromotions = null;
|
|
|
+ }
|
|
|
// 计算单价
|
|
|
if (null != svipProductPo && 1 == svipProductPo.getSvipProductFlag()) {
|
|
|
// 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
@@ -587,13 +599,22 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 单品优惠
|
|
|
if (promotions.getType() == 1) {
|
|
|
// 是否满足单品优惠条件
|
|
|
- if (promotions.getMode()==1 || MathUtil.compare(productFee, promotions.getTouchPrice()) >= 0) {
|
|
|
+ if (promotions.getMode() == 1 || MathUtil.compare(productFee, promotions.getTouchPrice()) >= 0) {
|
|
|
// 满减
|
|
|
if (promotions.getMode() == 2) {
|
|
|
- // 统计订单总满减金额
|
|
|
- promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
- // 统计单个商品的折后金额
|
|
|
- productFee = MathUtil.sub(productFee, promotions.getReducedPrice()).doubleValue();
|
|
|
+
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("0")) {
|
|
|
+ //叠加优惠计算
|
|
|
+ //叠加倍数
|
|
|
+ Double floor = Math.floor(MathUtil.div(productFee, promotions.getTouchPrice()).doubleValue());
|
|
|
+ promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
|
|
|
+ productFee = MathUtil.sub(productFee, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue();
|
|
|
+ } else {
|
|
|
+ // 统计订单总满减金额
|
|
|
+ promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ // 统计单个商品的折后金额
|
|
|
+ productFee = MathUtil.sub(productFee, promotions.getReducedPrice()).doubleValue();
|
|
|
+ }
|
|
|
}
|
|
|
// 添加到总促销
|
|
|
if (!promotionsIds.contains(promotions.getId())) {
|
|
@@ -603,14 +624,14 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
}
|
|
|
product.setOrderPromotionsId(promotions.getId());
|
|
|
}
|
|
|
- // 凑单优惠
|
|
|
+ // 凑单优惠
|
|
|
} else if (promotions.getType() == 2) {
|
|
|
// 商品添加到总促销
|
|
|
PromotionPriceVo promotionPrice = new PromotionPriceVo();
|
|
|
promotionPrice.setProductId(productId);
|
|
|
promotionPrice.setNumber(productNum);
|
|
|
promotionPrice.setPrice(discountTaxPrice);
|
|
|
- if (null == promotions.getProductList()){
|
|
|
+ if (null == promotions.getProductList()) {
|
|
|
promotions.setProductList(new ArrayList<>());
|
|
|
}
|
|
|
promotions.getProductList().add(promotionPrice);
|
|
@@ -621,7 +642,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
} else {
|
|
|
PromotionsVo finalPromotions = promotions;
|
|
|
promotionList.forEach(promotionsTemp -> {
|
|
|
- if (finalPromotions.getId().equals(promotionsTemp.getId())){
|
|
|
+ if (finalPromotions.getId().equals(promotionsTemp.getId())) {
|
|
|
promotionsTemp.getProductList().add(promotionPrice);
|
|
|
}
|
|
|
});
|
|
@@ -712,7 +733,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
* 子订单金额计算
|
|
|
*/
|
|
|
// 供应商商品数量
|
|
|
- shopProductCount.set(shopProductCount.get()+product.getNum());
|
|
|
+ shopProductCount.set(shopProductCount.get() + product.getNum());
|
|
|
// 佣金 = 应付采美
|
|
|
brokerage.set(MathUtil.add(brokerage.get(), product.getCmFee()).doubleValue());
|
|
|
// 需要支付金额 shouldPayFee +运费
|
|
@@ -743,16 +764,32 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
hasActProductFlag = true;
|
|
|
// 满减
|
|
|
if (shopPromotions.getMode() == 2) {
|
|
|
- // 供应商满减金额
|
|
|
- shopOrder.setPromotionFullReduction(shopPromotions.getReducedPrice());
|
|
|
- // 统计订单总满减金额
|
|
|
- promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), shopPromotions.getReducedPrice()).doubleValue());
|
|
|
- // 统计店铺商品总金额
|
|
|
- shopProductFee.set(MathUtil.sub(shopProductFee.get(), shopPromotions.getReducedPrice()).doubleValue());
|
|
|
- // 统计需要支付金额
|
|
|
- needPayAmount.set(MathUtil.sub(needPayAmount.get(), shopPromotions.getReducedPrice()).doubleValue());
|
|
|
- // 统计需要支付金额
|
|
|
- shopAmount.set(MathUtil.sub(shopAmount.get(), shopPromotions.getReducedPrice()).doubleValue());
|
|
|
+ if (shopPromotions.getDiscount() != null && shopPromotions.getDiscount().equals("0")) {
|
|
|
+ //叠加优惠计算
|
|
|
+ //叠加倍数
|
|
|
+ Double floor = Math.floor(MathUtil.div(shopPromotionFee.get(), shopPromotions.getTouchPrice()).doubleValue());
|
|
|
+ // 供应商满减金额
|
|
|
+ shopOrder.setPromotionFullReduction(MathUtil.mul(shopPromotions.getReducedPrice(), floor).doubleValue());
|
|
|
+ // 统计订单总满减金额
|
|
|
+ promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), MathUtil.mul(shopPromotions.getReducedPrice(), floor)).doubleValue());
|
|
|
+ // 统计店铺商品总金额
|
|
|
+ shopProductFee.set(MathUtil.sub(shopProductFee.get(), MathUtil.mul(shopPromotions.getReducedPrice(), floor)).doubleValue());
|
|
|
+ // 统计需要支付金额
|
|
|
+ needPayAmount.set(MathUtil.sub(needPayAmount.get(), MathUtil.mul(shopPromotions.getReducedPrice(), floor)).doubleValue());
|
|
|
+ // 统计需要支付金额
|
|
|
+ shopAmount.set(MathUtil.sub(shopAmount.get(), MathUtil.mul(shopPromotions.getReducedPrice(), floor)).doubleValue());
|
|
|
+ } else {
|
|
|
+ // 供应商满减金额
|
|
|
+ shopOrder.setPromotionFullReduction(shopPromotions.getReducedPrice());
|
|
|
+ // 统计订单总满减金额
|
|
|
+ promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), shopPromotions.getReducedPrice()).doubleValue());
|
|
|
+ // 统计店铺商品总金额
|
|
|
+ shopProductFee.set(MathUtil.sub(shopProductFee.get(), shopPromotions.getReducedPrice()).doubleValue());
|
|
|
+ // 统计需要支付金额
|
|
|
+ needPayAmount.set(MathUtil.sub(needPayAmount.get(), shopPromotions.getReducedPrice()).doubleValue());
|
|
|
+ // 统计需要支付金额
|
|
|
+ shopAmount.set(MathUtil.sub(shopAmount.get(), shopPromotions.getReducedPrice()).doubleValue());
|
|
|
+ }
|
|
|
}
|
|
|
// 添加到总促销
|
|
|
if (!promotionsIds.contains(shopPromotions.getId())) {
|
|
@@ -801,7 +838,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
// 统计商品总金额
|
|
|
productTotalFee.set(MathUtil.add(productTotalFee.get(), shopProductFee.get()).doubleValue());
|
|
|
}
|
|
|
- if (orderProductList.isEmpty()){
|
|
|
+ if (orderProductList.isEmpty()) {
|
|
|
return ResponseJson.error("订单商品数据异常!", null);
|
|
|
}
|
|
|
// 设置是否是二手订单
|
|
@@ -829,10 +866,21 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
//判断是否达到满减满赠要求
|
|
|
if (MathUtil.compare(tempProductFee.get(), promotions.getTouchPrice()) >= 0) {
|
|
|
if (promotions.getMode() == 2) {
|
|
|
- // 满减
|
|
|
- promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
- // 统计商品总金额
|
|
|
- productTotalFee.set(MathUtil.sub(productTotalFee.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("0")) {
|
|
|
+ //叠加优惠计算
|
|
|
+ //叠加倍数
|
|
|
+ Double floor = Math.floor(MathUtil.div(tempProductFee.get(), promotions.getTouchPrice()).doubleValue());
|
|
|
+ // 满减
|
|
|
+ promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), MathUtil.mul(promotions.getReducedPrice(),floor)).doubleValue());
|
|
|
+ // 统计商品总金额
|
|
|
+ productTotalFee.set(MathUtil.sub(productTotalFee.get(), MathUtil.mul(promotions.getReducedPrice(),floor)).doubleValue());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // 满减
|
|
|
+ promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ // 统计商品总金额
|
|
|
+ productTotalFee.set(MathUtil.sub(productTotalFee.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
// 删除不满足条件的凑单促销
|
|
@@ -868,7 +916,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
/*
|
|
|
* 计算运费
|
|
|
*/
|
|
|
- if (3 != orderParamBo.getCartType()){
|
|
|
+ if (3 != orderParamBo.getCartType()) {
|
|
|
// 机构用户 校验商品运费
|
|
|
if (orderParamBo.getPostageFlag() != -1) {
|
|
|
Integer townId = baseMapper.getTownIdByAddressId(orderParamBo.getAddressId());
|
|
@@ -1021,7 +1069,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
shopOrderIndex.incrementAndGet();
|
|
|
shopOrder.setShopOrderNo(shopOrderNo.toString());
|
|
|
// 订单能否拆分 1 为可拆分, 0为不可拆分
|
|
|
- if (shopOrder.getItemCount() >1) {
|
|
|
+ if (shopOrder.getItemCount() > 1) {
|
|
|
shopOrder.setSplitFlag(1);
|
|
|
} else {
|
|
|
shopOrder.setSplitFlag(0);
|
|
@@ -1308,7 +1356,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
beansHistory.setDelFlag(0);
|
|
|
// 更新用户剩余采美豆数量
|
|
|
int beans = orderParamBo.getUserBeans() - beansHistory.getNum();
|
|
|
- productService.updateUserBeans(beansHistory, beans,"【提交订单】");
|
|
|
+ productService.updateUserBeans(beansHistory, beans, "【提交订单】");
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -1402,12 +1450,12 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
public ResponseJson<Map<String, Object>> generateRechargeOrder(RechargeDto rechargeDto) {
|
|
|
// 获取机构用户Id
|
|
|
Integer clubUserId = baseMapper.getUserIdByClubId(rechargeDto.getClubId());
|
|
|
- if (null == clubUserId || clubUserId == 0){
|
|
|
+ if (null == clubUserId || clubUserId == 0) {
|
|
|
return ResponseJson.error("机构用户信息异常!", null);
|
|
|
}
|
|
|
// 获取协销用户Id
|
|
|
Integer spUserId = submitMapper.getServiceProviderUserId(rechargeDto.getServiceProviderId());
|
|
|
- if (null == spUserId || spUserId == 0){
|
|
|
+ if (null == spUserId || spUserId == 0) {
|
|
|
return ResponseJson.error("协销用户异常!", null);
|
|
|
}
|
|
|
log.info("******************** 提交充值订单逻辑处理 start *******************");
|