|
@@ -1,5 +1,6 @@
|
|
|
package com.sqx.modules.order.service.impl;
|
|
package com.sqx.modules.order.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -11,6 +12,9 @@ import com.sqx.common.utils.DateUtils;
|
|
|
import com.sqx.common.utils.DistanceUtil;
|
|
import com.sqx.common.utils.DistanceUtil;
|
|
|
import com.sqx.common.utils.PageUtils;
|
|
import com.sqx.common.utils.PageUtils;
|
|
|
import com.sqx.common.utils.Result;
|
|
import com.sqx.common.utils.Result;
|
|
|
|
|
+import com.sqx.modules.activity.service.ActivityService;
|
|
|
|
|
+import com.sqx.modules.activity.service.ActivityPartRecordService;
|
|
|
|
|
+import com.sqx.modules.activity.vo.OrderSuitActivityVO;
|
|
|
import com.sqx.modules.address.entity.Address;
|
|
import com.sqx.modules.address.entity.Address;
|
|
|
import com.sqx.modules.address.service.AddressService;
|
|
import com.sqx.modules.address.service.AddressService;
|
|
|
import com.sqx.modules.app.dao.UserBrowseDao;
|
|
import com.sqx.modules.app.dao.UserBrowseDao;
|
|
@@ -58,6 +62,7 @@ import com.sqx.modules.utils.fieYun.FeiYunUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
@@ -126,6 +131,12 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
private AddressService addressService;
|
|
private AddressService addressService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ShopMessageService shopMessageService;
|
|
private ShopMessageService shopMessageService;
|
|
|
|
|
+ @Lazy
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ActivityService activityService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ActivityPartRecordService activityPartRecordService;
|
|
|
|
|
+
|
|
|
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
|
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -373,6 +384,9 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
// 校验地址、配送费信息
|
|
// 校验地址、配送费信息
|
|
|
checkAddress(parentOrder, addressId, goodsShop);
|
|
checkAddress(parentOrder, addressId, goodsShop);
|
|
|
|
|
|
|
|
|
|
+ // 检查活动优惠信息
|
|
|
|
|
+ checkActivity(parentOrder);
|
|
|
|
|
+
|
|
|
// 校验优惠券信息
|
|
// 校验优惠券信息
|
|
|
checkCoupon(parentOrder, userId);
|
|
checkCoupon(parentOrder, userId);
|
|
|
|
|
|
|
@@ -382,6 +396,18 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
return parentOrder;
|
|
return parentOrder;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void checkActivity(TbOrder parentOrder) {
|
|
|
|
|
+ // 获取当前订单最优惠的活动
|
|
|
|
|
+ OrderSuitActivityVO orderBestActivity = activityService.getOrderBestActivity(parentOrder.getOrderId());
|
|
|
|
|
+ if (ObjectUtil.isNotNull(orderBestActivity)) {
|
|
|
|
|
+ // 支付金额减去活动优惠金额
|
|
|
|
|
+ parentOrder.setPayMoney(parentOrder.getPayMoney().subtract(new BigDecimal(orderBestActivity.getDiscountAmount())));
|
|
|
|
|
+
|
|
|
|
|
+ // 保存活动参与信息
|
|
|
|
|
+ activityPartRecordService.saveByOrderAndSuitActivityVO(parentOrder, orderBestActivity);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void subStock(TbOrder tbOrder) {
|
|
public void subStock(TbOrder tbOrder) {
|
|
|
Long shopId1 = tbOrder.getShopId();
|
|
Long shopId1 = tbOrder.getShopId();
|
|
@@ -764,9 +790,10 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
throw new SqxException("订单不存在,请刷新后重试!");
|
|
throw new SqxException("订单不存在,请刷新后重试!");
|
|
|
}
|
|
}
|
|
|
for(int i = 0; i < orderList.size(); i++) {
|
|
for(int i = 0; i < orderList.size(); i++) {
|
|
|
|
|
+ Long orderId = orderList.get(i).getOrderId();
|
|
|
List<OrderGoods> orderGoodsList = orderGoodsDao.selectList(
|
|
List<OrderGoods> orderGoodsList = orderGoodsDao.selectList(
|
|
|
new QueryWrapper<OrderGoods>()
|
|
new QueryWrapper<OrderGoods>()
|
|
|
- .eq("order_id", orderList.get(i).getOrderId()));
|
|
|
|
|
|
|
+ .eq("order_id", orderId));
|
|
|
for (int a = 0; a < orderGoodsList.size(); a++) {
|
|
for (int a = 0; a < orderGoodsList.size(); a++) {
|
|
|
BigDecimal goodsNum = new BigDecimal(orderGoodsList.get(a).getGoodsNum());
|
|
BigDecimal goodsNum = new BigDecimal(orderGoodsList.get(a).getGoodsNum());
|
|
|
BigDecimal goodsPrice = orderGoodsList.get(a).getGoodsPrice();
|
|
BigDecimal goodsPrice = orderGoodsList.get(a).getGoodsPrice();
|