|
|
@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
@@ -24,17 +23,17 @@ import com.kxmall.common.utils.StringUtils;
|
|
|
import com.kxmall.coupon.domain.KxStoreCouponUser;
|
|
|
import com.kxmall.coupon.mapper.KxStoreCouponUserMapper;
|
|
|
import com.kxmall.executor.GlobalExecutor;
|
|
|
-import com.kxmall.notify.MemberNotifyBizService;
|
|
|
+import com.kxmall.notify.service.MemberNotifyBizService;
|
|
|
import com.kxmall.order.biz.*;
|
|
|
import com.kxmall.order.biz.common.DeliveryResult;
|
|
|
import com.kxmall.order.domain.*;
|
|
|
import com.kxmall.order.domain.bo.KxStoreOrderBo;
|
|
|
import com.kxmall.order.domain.bo.OrderMessageBO;
|
|
|
import com.kxmall.order.domain.bo.RiderProductBO;
|
|
|
+import com.kxmall.order.domain.vo.KxOrderScreenshotVo;
|
|
|
import com.kxmall.order.domain.vo.KxOrderStatisticalVo;
|
|
|
import com.kxmall.order.domain.vo.KxStoreOrderProductVo;
|
|
|
import com.kxmall.order.domain.vo.KxStoreOrderVo;
|
|
|
-import com.kxmall.order.domain.vo.KxOrderScreenshotVo;
|
|
|
import com.kxmall.order.mapper.*;
|
|
|
import com.kxmall.rider.domain.KxRider;
|
|
|
import com.kxmall.rider.domain.vo.KxRiderVo;
|
|
|
@@ -59,7 +58,10 @@ import org.springframework.util.CollectionUtils;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 订单Service业务层处理
|
|
|
@@ -109,8 +111,6 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
|
|
|
private final DeliveryStrategyFactory deliveryStrategyFactory;
|
|
|
|
|
|
- private final KxOrderDeliveryMapper orderDeliveryMapper;
|
|
|
-
|
|
|
/**
|
|
|
* 查询订单
|
|
|
*/
|
|
|
@@ -143,11 +143,11 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
|
|
|
// 加载订单照片
|
|
|
List<KxOrderScreenshotVo> photos = orderScreenshotMapper.selectVoList(
|
|
|
- new LambdaQueryWrapper<KxOrderScreenshot>()
|
|
|
- .eq(KxOrderScreenshot::getOrderId, kxStoreOrderVo.getId())
|
|
|
- .eq(KxOrderScreenshot::getIsDeleted, 0)
|
|
|
- .orderByAsc(KxOrderScreenshot::getSortOrder)
|
|
|
- .orderByAsc(KxOrderScreenshot::getCreateTime)
|
|
|
+ new LambdaQueryWrapper<KxOrderScreenshot>()
|
|
|
+ .eq(KxOrderScreenshot::getOrderId, kxStoreOrderVo.getId())
|
|
|
+ .eq(KxOrderScreenshot::getIsDeleted, 0)
|
|
|
+ .orderByAsc(KxOrderScreenshot::getSortOrder)
|
|
|
+ .orderByAsc(KxOrderScreenshot::getCreateTime)
|
|
|
);
|
|
|
kxStoreOrderVo.setPhotos(photos);
|
|
|
|
|
|
@@ -193,8 +193,8 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
if (StringUtils.isNoneBlank(bo.getOrderStatus())) {
|
|
|
if (!"all".equals(bo.getOrderStatus())) {
|
|
|
String[] states = bo.getOrderStatus().split(",");
|
|
|
- for (int i = 0; i < states.length; i++) {
|
|
|
- status.add(Integer.parseInt(states[i]));
|
|
|
+ for (String state : states) {
|
|
|
+ status.add(Integer.parseInt(state));
|
|
|
}
|
|
|
lqw.in(KxStoreOrder::getStatus, status);
|
|
|
}
|
|
|
@@ -231,7 +231,6 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
}
|
|
|
|
|
|
private LambdaQueryWrapper<KxStoreOrder> buildQueryWrapper(KxStoreOrderBo bo) {
|
|
|
- Map<String, Object> params = bo.getParams();
|
|
|
LambdaQueryWrapper<KxStoreOrder> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getOrderId()), KxStoreOrder::getOrderId, bo.getOrderId());
|
|
|
lqw.eq(bo.getUid() != null, KxStoreOrder::getUid, bo.getUid());
|
|
|
@@ -344,9 +343,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
|
// 通知会员开始配货
|
|
|
- GlobalExecutor.execute(() -> {
|
|
|
- memberNotifyBizService.newOrder(storeOrder);
|
|
|
- });
|
|
|
+ GlobalExecutor.execute(() -> memberNotifyBizService.newOrder(storeOrder));
|
|
|
|
|
|
return aBoolean;
|
|
|
}
|
|
|
@@ -358,13 +355,6 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
|
|
|
@Override
|
|
|
public Boolean merchantDistribution(Long id) {
|
|
|
- // 判断一下如果正在第三方配置,就不能点击系统配送,以免重复
|
|
|
- Long count = orderDeliveryMapper.selectCount(new LambdaQueryWrapper<KxOrderDelivery>()
|
|
|
- .eq(KxOrderDelivery::getOrderId, id)
|
|
|
- .eq(KxOrderDelivery::getIsDelete, 0));
|
|
|
- if (count > 0L) {
|
|
|
- throw new ServiceException("已发起第三方配送,无法再次发起商家配送");
|
|
|
- }
|
|
|
return this.updateOrderStatus(id, OrderStatusType.WAIT_CONFIRM.getCode(), OrderStatusType.WAIT_STOCK.getCode());
|
|
|
}
|
|
|
|
|
|
@@ -387,9 +377,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
}
|
|
|
|
|
|
// 通知会员完成订单
|
|
|
- GlobalExecutor.execute(() -> {
|
|
|
- memberNotifyBizService.completeOrder(kxStoreOrder);
|
|
|
- });
|
|
|
+ GlobalExecutor.execute(() -> memberNotifyBizService.completeOrder(kxStoreOrder));
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
@@ -433,14 +421,6 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
throw new ServiceException("订单状态更新异常,请检查当前订单真实状态!");
|
|
|
}
|
|
|
|
|
|
- // 判断一下如果正在第三方配置,就不能点击系统配送,以免重复
|
|
|
- Long count = orderDeliveryMapper.selectCount(new LambdaQueryWrapper<KxOrderDelivery>()
|
|
|
- .eq(KxOrderDelivery::getOrderId, orderNo)
|
|
|
- .eq(KxOrderDelivery::getIsDelete, 0));
|
|
|
- if (count > 0L) {
|
|
|
- throw new ServiceException("已发起第三方配送,无法再次发起系统配送");
|
|
|
- }
|
|
|
-
|
|
|
OrderMessageBO orderMessageBO = new OrderMessageBO();
|
|
|
orderMessageBO.setOrderId(orderDO.getId());
|
|
|
orderMessageBO.setOrderNo(orderDO.getOrderId());
|
|
|
@@ -667,19 +647,8 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
throw new ServiceException("订单状态更新失败");
|
|
|
}
|
|
|
|
|
|
- // 8. 记录配送信息到配送关联表
|
|
|
- KxOrderDelivery orderDelivery = new KxOrderDelivery();
|
|
|
- orderDelivery.setOrderId(orderVo.getOrderId());
|
|
|
- orderDelivery.setDeliveryType(defaultConfig.getDeliveryType());
|
|
|
- orderDelivery.setDeliveryId(result.getDeliveryId());
|
|
|
- orderDelivery.setDeliveryStatus(result.getStatus());
|
|
|
- orderDelivery.setDeliveryInfo(JSON.toJSONString(result.getOriginalData()));
|
|
|
- orderDeliveryMapper.insert(orderDelivery);
|
|
|
-
|
|
|
// 9. 通知用户
|
|
|
- GlobalExecutor.execute(() -> {
|
|
|
- memberNotifyBizService.deliveryOrder(orderVo, result);
|
|
|
- });
|
|
|
+ GlobalExecutor.execute(() -> memberNotifyBizService.deliveryOrder(orderVo, result));
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
@@ -768,7 +737,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
/**
|
|
|
* 退回优惠券
|
|
|
*
|
|
|
- * @param order
|
|
|
+ * @param order order
|
|
|
*/
|
|
|
private void returnCoupon(KxStoreOrderVo order) {
|
|
|
|
|
|
@@ -789,7 +758,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
/**
|
|
|
* 库存退回
|
|
|
*
|
|
|
- * @param order
|
|
|
+ * @param order order
|
|
|
*/
|
|
|
private void returnStock(KxStoreOrderVo order) {
|
|
|
for (KxStoreOrderProductVo orderProductVo : order.getProductList()) {
|
|
|
@@ -803,7 +772,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
* \
|
|
|
* 退回积分
|
|
|
*
|
|
|
- * @param order
|
|
|
+ * @param order order
|
|
|
*/
|
|
|
private void returnIntegral(KxStoreOrderVo order) {
|
|
|
|
|
|
@@ -833,11 +802,6 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
|
|
|
/**
|
|
|
* 更新状态
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @param newStatus
|
|
|
- * @param oldStatus
|
|
|
- * @return
|
|
|
*/
|
|
|
private Boolean updateOrderStatus(Long id, Integer newStatus, Integer oldStatus) {
|
|
|
try {
|