|
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.service.order;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
@@ -22,7 +23,7 @@ import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDT
|
|
|
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
|
|
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
|
|
|
import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi;
|
|
|
-import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateReqDTO;
|
|
|
+import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
|
|
import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi;
|
|
|
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
|
|
|
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
|
@@ -59,8 +60,6 @@ import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
|
|
|
-import static cn.hutool.core.util.ObjectUtil.equal;
|
|
|
-import static cn.hutool.core.util.ObjectUtil.notEqual;
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
|
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
@@ -172,13 +171,13 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
afterCreateTradeOrder(userId, createReqVO, order, orderItems, calculateRespBO);
|
|
|
// 3.3 校验订单类型
|
|
|
// 拼团
|
|
|
- if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
|
|
+ if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
|
|
MemberUserRespDTO user = memberUserApi.getUser(userId);
|
|
|
// TODO 拼团一次应该只能选择一种规格的商品
|
|
|
- combinationRecordApi.createRecord(TradeOrderConvert.INSTANCE.convert(order, orderItems.get(0), createReqVO, user));
|
|
|
+ combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItems.get(0), createReqVO, user));
|
|
|
}
|
|
|
// TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除
|
|
|
- if (equal(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) {
|
|
|
+ if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) {
|
|
|
|
|
|
}
|
|
|
|
|
@@ -205,7 +204,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
TradePriceCalculateRespBO calculateRespBO) {
|
|
|
// 用户选择物流配送的时候才需要填写收货地址
|
|
|
AddressRespDTO address = new AddressRespDTO();
|
|
|
- if (equal(createReqVO.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) {
|
|
|
+ if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) {
|
|
|
// 用户收件地址的校验
|
|
|
address = validateAddress(userId, createReqVO.getAddressId());
|
|
|
}
|
|
@@ -309,9 +308,9 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
}
|
|
|
// 校验活动
|
|
|
// 1、拼团活动
|
|
|
- if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
|
|
+ if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
|
|
// 更新拼团状态 TODO puhui999:订单支付失败或订单支付过期删除这条拼团记录
|
|
|
- combinationRecordApi.updateRecordStatus(new CombinationRecordUpdateReqDTO().setUserId(order.getUserId())
|
|
|
+ combinationRecordApi.updateCombinationRecordStatus(new CombinationRecordUpdateStatusReqDTO().setUserId(order.getUserId())
|
|
|
.setOrderId(order.getId()).setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()).setStartTime(LocalDateTime.now()));
|
|
|
}
|
|
|
// TODO 芋艿:发送订单变化的消息
|
|
@@ -344,7 +343,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID);
|
|
|
}
|
|
|
// 校验支付订单匹配
|
|
|
- if (notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号
|
|
|
+ if (ObjectUtil.notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号
|
|
|
log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]",
|
|
|
id, payOrderId, JsonUtils.toJsonString(order));
|
|
|
throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR);
|
|
@@ -363,13 +362,13 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS);
|
|
|
}
|
|
|
// 校验支付金额一致
|
|
|
- if (notEqual(payOrder.getPrice(), order.getPayPrice())) {
|
|
|
+ if (ObjectUtil.notEqual(payOrder.getPrice(), order.getPayPrice())) {
|
|
|
log.error("[validateOrderPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]",
|
|
|
id, payOrderId, JsonUtils.toJsonString(order), JsonUtils.toJsonString(payOrder));
|
|
|
throw exception(ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH);
|
|
|
}
|
|
|
// 校验支付订单匹配(二次)
|
|
|
- if (notEqual(payOrder.getMerchantOrderId(), id.toString())) {
|
|
|
+ if (ObjectUtil.notEqual(payOrder.getMerchantOrderId(), id.toString())) {
|
|
|
log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]",
|
|
|
id, payOrderId, JsonUtils.toJsonString(payOrder));
|
|
|
throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR);
|
|
@@ -393,19 +392,19 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
TradeOrderDO updateOrderObj = new TradeOrderDO();
|
|
|
// 判断发货类型
|
|
|
// 2.1 快递发货
|
|
|
- if (equal(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) {
|
|
|
+ if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) {
|
|
|
// 校验快递公司
|
|
|
validateDeliveryExpress(deliveryReqVO);
|
|
|
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
|
|
|
}
|
|
|
// 2.2 用户自提
|
|
|
- if (equal(deliveryReqVO.getType(), DeliveryTypeEnum.PICK_UP.getMode())) {
|
|
|
+ if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.PICK_UP.getMode())) {
|
|
|
// TODO 校验自提门店是否存在
|
|
|
// 重置一下确保快递公司和快递单号为空
|
|
|
updateOrderObj.setLogisticsId(null).setLogisticsNo("");
|
|
|
}
|
|
|
// 2.3 TODO 芋艿:如果无需发货,需要怎么存储?回复:需要把 deliverType 设置为 DeliveryTypeEnum.NULL
|
|
|
- if (equal(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) {
|
|
|
+ if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) {
|
|
|
// TODO 情况一:正常走发货逻辑和用户自提有点像 不同点:不需要自提门店只需要用户确认收货
|
|
|
// TODO 情况二:用户下单付款后直接确认收货或等待用户确认收货
|
|
|
// 重置一下确保快递公司和快递单号为空
|
|
@@ -455,17 +454,17 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
}
|
|
|
// 校验订单是否是待发货状态
|
|
|
if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())
|
|
|
- || notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus())) {
|
|
|
+ || ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus())) {
|
|
|
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
|
|
|
}
|
|
|
// 校验订单是否退款
|
|
|
- if (notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) {
|
|
|
+ if (ObjectUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) {
|
|
|
throw exception(ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE);
|
|
|
}
|
|
|
// 订单类型:拼团
|
|
|
- if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
|
|
+ if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
|
|
// 校验订单拼团是否成功
|
|
|
- if (combinationRecordApi.isRecordSuccess(order.getUserId(), order.getId())) {
|
|
|
+ if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) {
|
|
|
throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS);
|
|
|
}
|
|
|
}
|
|
@@ -515,7 +514,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
}
|
|
|
// 校验订单是否是待收货状态
|
|
|
if (!TradeOrderStatusEnum.isDelivered(order.getStatus())
|
|
|
- || notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus())) {
|
|
|
+ || ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus())) {
|
|
|
throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
|
|
|
}
|
|
|
return order;
|
|
@@ -525,7 +524,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
public TradeOrderDO getOrder(Long userId, Long id) {
|
|
|
TradeOrderDO order = tradeOrderMapper.selectById(id);
|
|
|
if (order != null
|
|
|
- && notEqual(order.getUserId(), userId)) {
|
|
|
+ && ObjectUtil.notEqual(order.getUserId(), userId)) {
|
|
|
return null;
|
|
|
}
|
|
|
return order;
|
|
@@ -569,7 +568,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
public TradeOrderItemDO getOrderItem(Long userId, Long itemId) {
|
|
|
TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(itemId);
|
|
|
if (orderItem != null
|
|
|
- && notEqual(orderItem.getUserId(), userId)) {
|
|
|
+ && ObjectUtil.notEqual(orderItem.getUserId(), userId)) {
|
|
|
return null;
|
|
|
}
|
|
|
return orderItem;
|
|
@@ -649,10 +648,10 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
if (order == null) {
|
|
|
throw exception(ORDER_NOT_FOUND);
|
|
|
}
|
|
|
- if (notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) {
|
|
|
+ if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) {
|
|
|
throw exception(ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED);
|
|
|
}
|
|
|
- if (notEqual(order.getCommentStatus(), Boolean.FALSE)) {
|
|
|
+ if (ObjectUtil.notEqual(order.getCommentStatus(), Boolean.FALSE)) {
|
|
|
throw exception(ORDER_COMMENT_STATUS_NOT_FALSE);
|
|
|
}
|
|
|
|
|
@@ -662,7 +661,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|
|
// 更新订单项评价状态
|
|
|
tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE));
|
|
|
List<TradeOrderItemDO> orderItems = getOrderItemListByOrderId(CollUtil.newArrayList(order.getId()));
|
|
|
- if (!anyMatch(orderItems, item -> equal(item.getCommentStatus(), Boolean.FALSE))) {
|
|
|
+ if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) {
|
|
|
// 对于 order 来说,就是评论完,把 order 更新完合理的 status 等字段。
|
|
|
tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE));
|
|
|
}
|