|
@@ -3,10 +3,7 @@ package com.caimei365.order.service.impl;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.caimei365.order.components.ProductService;
|
|
import com.caimei365.order.components.ProductService;
|
|
-import com.caimei365.order.mapper.BaseMapper;
|
|
|
|
-import com.caimei365.order.mapper.CartClubMapper;
|
|
|
|
-import com.caimei365.order.mapper.CartSellerMapper;
|
|
|
|
-import com.caimei365.order.mapper.SubmitMapper;
|
|
|
|
|
|
+import com.caimei365.order.mapper.*;
|
|
import com.caimei365.order.model.ResponseJson;
|
|
import com.caimei365.order.model.ResponseJson;
|
|
import com.caimei365.order.model.dto.RechargeDto;
|
|
import com.caimei365.order.model.dto.RechargeDto;
|
|
import com.caimei365.order.model.po.*;
|
|
import com.caimei365.order.model.po.*;
|
|
@@ -55,6 +52,8 @@ public class SubmitServiceImpl implements SubmitService {
|
|
@Resource
|
|
@Resource
|
|
private ProductService productService;
|
|
private ProductService productService;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private OrderClubMapper orderClubMapper;
|
|
|
|
+ @Resource
|
|
private CartClubMapper cartClubMapper;
|
|
private CartClubMapper cartClubMapper;
|
|
@Resource
|
|
@Resource
|
|
private CartSellerMapper cartSellerMapper;
|
|
private CartSellerMapper cartSellerMapper;
|
|
@@ -64,12 +63,13 @@ public class SubmitServiceImpl implements SubmitService {
|
|
* 生成订单
|
|
* 生成订单
|
|
*
|
|
*
|
|
* @param submitDto {
|
|
* @param submitDto {
|
|
|
|
+ * "clubId": 10708, //机构ID
|
|
* "unionId":"", //微信unionId
|
|
* "unionId":"", //微信unionId
|
|
- * "cartType":3, //购买类型:(1自主下单, 3协销下单)
|
|
|
|
|
|
+ * "addressId": 2732, //地址ID
|
|
* "orderSource": 2, //订单来源:1WWW、2CRM、4客服[适用后台下单]、5外单[适用后台下单]、6小程序[采美,星范]、7呵呵商城小程序、8维沙小程序
|
|
* "orderSource": 2, //订单来源:1WWW、2CRM、4客服[适用后台下单]、5外单[适用后台下单]、6小程序[采美,星范]、7呵呵商城小程序、8维沙小程序
|
|
- * "serviceProviderId": 1378, //协销Id(小程序忽略)
|
|
|
|
- * "clubUserId": 10708, //机构用户Id
|
|
|
|
- * "addressId": 2732, //地址Id
|
|
|
|
|
|
+ * "cartType":3, //购买类型:(1自主下单, 3协销下单)
|
|
|
|
+ * "serviceProviderId": 1378, //协销ID(小程序忽略)
|
|
|
|
+ * "clubCouponId": "" //优惠券Id
|
|
* "orderInfo": [ //【订单商品】
|
|
* "orderInfo": [ //【订单商品】
|
|
* { "shopId":1001, // 供应商Id
|
|
* { "shopId":1001, // 供应商Id
|
|
* "note":备注,
|
|
* "note":备注,
|
|
@@ -81,7 +81,6 @@ public class SubmitServiceImpl implements SubmitService {
|
|
* ],
|
|
* ],
|
|
* "payInfo": { //【订单金额】
|
|
* "payInfo": { //【订单金额】
|
|
* "orderShouldPayFee": 609.11,
|
|
* "orderShouldPayFee": 609.11,
|
|
- *
|
|
|
|
* "balancePayFlag": 0,
|
|
* "balancePayFlag": 0,
|
|
* "clauseId": "2",
|
|
* "clauseId": "2",
|
|
* "postage": "15",
|
|
* "postage": "15",
|
|
@@ -264,6 +263,7 @@ public class SubmitServiceImpl implements SubmitService {
|
|
}
|
|
}
|
|
orderParamBo.setBuyUserId(buyUserId);
|
|
orderParamBo.setBuyUserId(buyUserId);
|
|
orderParamBo.setAddressId(submitDto.getAddressId());
|
|
orderParamBo.setAddressId(submitDto.getAddressId());
|
|
|
|
+ orderParamBo.setClubCouponId(submitDto.getClubCouponId());
|
|
/*
|
|
/*
|
|
* 保存订单
|
|
* 保存订单
|
|
*/
|
|
*/
|
|
@@ -766,7 +766,23 @@ public class SubmitServiceImpl implements SubmitService {
|
|
mainOrder.setPresentCount(presentCount.get());
|
|
mainOrder.setPresentCount(presentCount.get());
|
|
//促销赠品数量
|
|
//促销赠品数量
|
|
mainOrder.setPromotionalGiftsCount(promotionalGiftsCount.get());
|
|
mainOrder.setPromotionalGiftsCount(promotionalGiftsCount.get());
|
|
-
|
|
|
|
|
|
+ /*
|
|
|
|
+ * 处理优惠券
|
|
|
|
+ */
|
|
|
|
+ Double couponAmount = 0d;
|
|
|
|
+ CouponVo coupon = null;
|
|
|
|
+ if (null != orderParamBo.getClubCouponId() && orderParamBo.getClubCouponId() > 0) {
|
|
|
|
+ coupon = submitMapper.getClubCouponById(orderParamBo.getClubCouponId());
|
|
|
|
+ if (null == coupon) {
|
|
|
|
+ // 设置手动回滚事务
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
+ return ResponseJson.error("优惠券使用异常!", null);
|
|
|
|
+ }
|
|
|
|
+ couponAmount = coupon.getCouponAmount();
|
|
|
|
+ }
|
|
|
|
+ mainOrder.setCouponAmount(couponAmount);
|
|
|
|
+ // 订单总额 = 商品费 - 优惠券金额
|
|
|
|
+ payTotalFee.set(MathUtil.sub(productTotalFee.get(), couponAmount).doubleValue());
|
|
/*
|
|
/*
|
|
* 计算运费
|
|
* 计算运费
|
|
*/
|
|
*/
|
|
@@ -791,7 +807,6 @@ public class SubmitServiceImpl implements SubmitService {
|
|
// 采美豆抵扣运费,订单总额 = 商品费
|
|
// 采美豆抵扣运费,订单总额 = 商品费
|
|
payTotalFee.set(productTotalFee.get());
|
|
payTotalFee.set(productTotalFee.get());
|
|
}
|
|
}
|
|
-
|
|
|
|
// 商品总额
|
|
// 商品总额
|
|
mainOrder.setProductTotalFee(productTotalFee.get());
|
|
mainOrder.setProductTotalFee(productTotalFee.get());
|
|
mainOrder.setOrderTotalFee(productTotalFee.get());
|
|
mainOrder.setOrderTotalFee(productTotalFee.get());
|
|
@@ -1183,6 +1198,23 @@ public class SubmitServiceImpl implements SubmitService {
|
|
productService.updateUserBeans(beansHistory, beans,"【提交订单】");
|
|
productService.updateUserBeans(beansHistory, beans,"【提交订单】");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * 保存优惠券使用情况
|
|
|
|
+ */
|
|
|
|
+ if (null != orderParamBo.getClubCouponId() && orderParamBo.getClubCouponId() > 0) {
|
|
|
|
+ // 修改优惠券使用情况
|
|
|
|
+ if (3 != orderParamBo.getCartType()) {
|
|
|
|
+ // 自主订单立即确认,协销订单待确认 ,确认订单时才真正使用优惠券
|
|
|
|
+ orderClubMapper.updateCouponClubStatus(orderParamBo.getClubCouponId(), mainOrder.getOrderId());
|
|
|
|
+ }
|
|
|
|
+ CouponOrderRecordPo orderRecord = new CouponOrderRecordPo();
|
|
|
|
+ BeanUtils.copyProperties(coupon, orderRecord);
|
|
|
|
+ orderRecord.setOrderId(mainOrder.getOrderId());
|
|
|
|
+ orderRecord.setCreateDate(date);
|
|
|
|
+ // 保存订单优惠记录
|
|
|
|
+ submitMapper.insertCouponOrderRecord(orderRecord);
|
|
|
|
+ }
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* 删除购物车
|
|
* 删除购物车
|
|
*/
|
|
*/
|