|
@@ -74,8 +74,11 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
* "cartType":3, //购买类型:(1自主下单(购物车),2自主下单(立即购买),3协销下单)
|
|
|
* "serviceProviderId": 1378, //协销ID(小程序忽略)
|
|
|
* "clubCouponId": "" //优惠券Id
|
|
|
+ * <p>
|
|
|
+ * 购物车结算/order/club/cart/settlement组装商品
|
|
|
* "orderInfo": [ //【订单商品】
|
|
|
* { "shopId":1001, // 供应商Id
|
|
|
+ * "splitCode:E123123" //分账号
|
|
|
* "note":备注,
|
|
|
* "productInfo":[ // 商品id,数量,赠品数,商品类型
|
|
|
* {"productId": 2789, "productNum": 1, "presentNum":0,"productType":2},
|
|
@@ -377,6 +380,8 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
boolean secondHandOrderFlag = false;
|
|
|
// 是否包含活动商品
|
|
|
boolean hasActProductFlag = false;
|
|
|
+ // 是否能线上支付
|
|
|
+ boolean onlinePay = true;
|
|
|
//促销活动ids
|
|
|
List<Integer> promotionsIds = new ArrayList<>();
|
|
|
// 促销活动信息
|
|
@@ -391,10 +396,14 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
for (Object infoObject : orderInfo) {
|
|
|
JSONObject shopInfo = (JSONObject) infoObject;
|
|
|
Integer shopId = (Integer) shopInfo.get("shopId");
|
|
|
+ String splitCode = (String) shopInfo.get("splitCode");
|
|
|
String shopNote = (String) shopInfo.get("note");
|
|
|
if (null == shopId) {
|
|
|
return ResponseJson.error("供应商数据异常!", null);
|
|
|
}
|
|
|
+ if(StringUtils.isBlank(splitCode)){
|
|
|
+ onlinePay = false;
|
|
|
+ }
|
|
|
JSONArray productArr = (JSONArray) shopInfo.get("productInfo");
|
|
|
if (null == productArr) {
|
|
|
return ResponseJson.error("订单商品数据异常!", null);
|
|
@@ -405,6 +414,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
* 初始化子订单
|
|
|
*/
|
|
|
OrderShopPo shopOrder = new OrderShopPo();
|
|
|
+ shopOrder.setSplitCode(splitCode);
|
|
|
shopOrder.setShopId(shopId);
|
|
|
shopOrder.setShopName(shopName);
|
|
|
shopOrder.setNote(shopNote);
|
|
@@ -908,7 +918,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
Double couponAmount = 0d;
|
|
|
CouponVo coupon = null;
|
|
|
if (null != orderParamBo.getClubCouponId() && orderParamBo.getClubCouponId() > 0) {
|
|
|
- coupon = orderClubMapper.getClubCouponById(orderParamBo.getClubCouponId(),orderParamBo.getUserId());
|
|
|
+ coupon = orderClubMapper.getClubCouponById(orderParamBo.getClubCouponId(), orderParamBo.getUserId());
|
|
|
if (null == coupon) {
|
|
|
// 设置手动回滚事务
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
@@ -1099,18 +1109,29 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
});
|
|
|
|
|
|
/*
|
|
|
- * 整理 订单商品
|
|
|
+ * 订单商品分子订单
|
|
|
*/
|
|
|
for (OrderProductPo orderProduct : orderProductList) {
|
|
|
// 设置商品订单Id
|
|
|
orderProduct.setOrderId(mainOrder.getOrderId());
|
|
|
orderProduct.setOrderNo(mainOrder.getOrderNo());
|
|
|
// 设置商品子订单Id
|
|
|
+ boolean finalOnlinePay = onlinePay;
|
|
|
shopOrderList.forEach(shopOrder -> {
|
|
|
- if (orderProduct.getShopId().equals(shopOrder.getShopId())) {
|
|
|
- orderProduct.setShopOrderId(shopOrder.getShopOrderId());
|
|
|
- orderProduct.setShopOrderNo(shopOrder.getShopOrderNo());
|
|
|
+ //能线上的一定有分账号,按分账号分子订单
|
|
|
+ if (finalOnlinePay) {
|
|
|
+ //都有商户号的情况下,子订单的商户号和商品的一致分到一个子订单
|
|
|
+ if (orderProduct.getShopId().equals(shopOrder.getShopId()) && orderProduct.getSplitCode().equals(shopOrder.getSplitCode())) {
|
|
|
+ orderProduct.setShopOrderId(shopOrder.getShopOrderId());
|
|
|
+ orderProduct.setShopOrderNo(shopOrder.getShopOrderNo());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (orderProduct.getShopId().equals(shopOrder.getShopId())) {
|
|
|
+ orderProduct.setShopOrderId(shopOrder.getShopOrderId());
|
|
|
+ orderProduct.setShopOrderNo(shopOrder.getShopOrderNo());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
});
|
|
|
// 设置订单商品促销Id
|
|
|
promotionList.forEach(promotions -> {
|
|
@@ -1410,7 +1431,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
|
BeanUtils.copyProperties(coupon, orderRecord);
|
|
|
orderRecord.setOrderId(mainOrder.getOrderId());
|
|
|
orderRecord.setCreateDate(date);
|
|
|
- // 保存订单优惠记录
|
|
|
+ // 保存订单优惠券使用记录
|
|
|
submitMapper.insertCouponOrderRecord(orderRecord);
|
|
|
}
|
|
|
|