订单:

1、移除 deliverStatus 发货状态,暂时没作用
2、无需发货时,使用 logisticsId 进行实现
3、订单详情,增加 logisticsId 和 logisticsName 返回
This commit is contained in:
YunaiV 2023-08-13 20:12:24 +08:00
parent e159b2e500
commit 503c996acd
9 changed files with 42 additions and 64 deletions

View File

@ -152,19 +152,9 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
// 准备参数 // 准备参数
CombinationActivityPageReqVO reqVO = new CombinationActivityPageReqVO(); CombinationActivityPageReqVO reqVO = new CombinationActivityPageReqVO();
reqVO.setName(null); reqVO.setName(null);
reqVO.setSpuId(null);
reqVO.setTotalLimitCount(null);
reqVO.setSingleLimitCount(null);
reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setUserSize(null);
reqVO.setTotalNum(null);
reqVO.setSuccessNum(null);
reqVO.setOrderUserCount(null);
reqVO.setVirtualGroup(null);
reqVO.setStatus(null); reqVO.setStatus(null);
reqVO.setLimitDuration(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用 // 调用
PageResult<CombinationActivityDO> pageResult = combinationActivityService.getCombinationActivityPage(reqVO); PageResult<CombinationActivityDO> pageResult = combinationActivityService.getCombinationActivityPage(reqVO);

View File

@ -1,28 +0,0 @@
package cn.iocoder.yudao.module.trade.enums.order;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* 交易订单 - 发货状态
*
* @author 芋道源码
*/
@RequiredArgsConstructor
@Getter
public enum TradeOrderDeliveryStatusEnum {
UNDELIVERED(0, "未发货"),
DELIVERED(1, "已发货"),
RECEIVED(2, "已收货");
/**
* 状态值
*/
private final Integer status;
/**
* 状态名
*/
private final String name;
}

View File

@ -10,10 +10,12 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.*;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO;
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderService;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -42,8 +44,12 @@ public class AppTradeOrderController {
@Resource @Resource
private TradeOrderService tradeOrderService; private TradeOrderService tradeOrderService;
@Resource
private DeliveryExpressService deliveryExpressService;
@Resource @Resource
private ProductPropertyValueApi productPropertyValueApi; private ProductPropertyValueApi productPropertyValueApi;
@Resource @Resource
private TradeOrderProperties tradeOrderProperties; private TradeOrderProperties tradeOrderProperties;
@ -76,14 +82,21 @@ public class AppTradeOrderController {
public CommonResult<AppTradeOrderDetailRespVO> getOrder(@RequestParam("id") Long id) { public CommonResult<AppTradeOrderDetailRespVO> getOrder(@RequestParam("id") Long id) {
// 查询订单 // 查询订单
TradeOrderDO order = tradeOrderService.getOrder(getLoginUserId(), id); TradeOrderDO order = tradeOrderService.getOrder(getLoginUserId(), id);
if (order == null) {
return success(null);
}
// 查询订单项 // 查询订单项
List<TradeOrderItemDO> orderItems = tradeOrderService.getOrderItemListByOrderId(order.getId()); List<TradeOrderItemDO> orderItems = tradeOrderService.getOrderItemListByOrderId(order.getId());
// 查询商品属性 // 查询商品属性
List<ProductPropertyValueDetailRespDTO> propertyValueDetails = productPropertyValueApi List<ProductPropertyValueDetailRespDTO> propertyValueDetails = productPropertyValueApi
.getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems));
// 查询物流公司
DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ?
deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null;
// 最终组合 // 最终组合
return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems,
propertyValueDetails, tradeOrderProperties)); propertyValueDetails, tradeOrderProperties, express));
} }
@GetMapping("/page") @GetMapping("/page")

View File

@ -80,6 +80,12 @@ public class AppTradeOrderDetailRespVO {
@Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer deliveryType; private Integer deliveryType;
@Schema(description = "发货物流公司编号", example = "10")
private Long logisticsId;
@Schema(description = "发货物流名称", example = "顺丰快递")
private String logisticsName;
@Schema(description = "发货物流单号", example = "1024") @Schema(description = "发货物流单号", example = "1024")
private String logisticsNo; private String logisticsNo;

View File

@ -25,6 +25,7 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.*;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.cart.TradeCartDO; import cn.iocoder.yudao.module.trade.dal.dataobject.cart.TradeCartDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum;
@ -234,7 +235,8 @@ public interface TradeOrderConvert {
// TODO 芋艿可简化 // TODO 芋艿可简化
default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List<TradeOrderItemDO> orderItems, default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List<TradeOrderItemDO> orderItems,
List<ProductPropertyValueDetailRespDTO> propertyValueDetails, TradeOrderProperties tradeOrderProperties) { List<ProductPropertyValueDetailRespDTO> propertyValueDetails, TradeOrderProperties tradeOrderProperties,
DeliveryExpressDO express) {
AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems); AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems);
orderVO.setPayExpireTime(addTime(tradeOrderProperties.getExpireTime())); orderVO.setPayExpireTime(addTime(tradeOrderProperties.getExpireTime()));
if (StrUtil.isNotEmpty(order.getPayChannelCode())) { if (StrUtil.isNotEmpty(order.getPayChannelCode())) {
@ -260,6 +262,9 @@ public interface TradeOrderConvert {
} }
// 处理收货地址 // 处理收货地址
orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId()));
if (express != null) {
orderVO.setLogisticsId(express.getId()).setLogisticsName(express.getName());
}
return orderVO; return orderVO;
} }

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum; import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.*; import cn.iocoder.yudao.module.trade.enums.order.*;
@ -174,18 +175,18 @@ public class TradeOrderDO extends BaseDO {
private Integer deliveryType; private Integer deliveryType;
/** /**
* 发货物流公司编号 * 发货物流公司编号
*
* 如果无需发货 logisticsId 设置为 0原因是不想再添加额外字段
*
* 关联 {@link DeliveryExpressDO#getId()}
*/ */
private Long logisticsId; private Long logisticsId;
/** /**
* 发货物流单号 * 发货物流单号
*
* 如果无需发货 logisticsNo 设置 ""原因是不想再添加额外字段
*/ */
private String logisticsNo; private String logisticsNo;
/**
* 发货状态
*
* 枚举 {@link TradeOrderDeliveryStatusEnum}
*/
private Integer deliveryStatus;
/** /**
* 发货时间 * 发货时间
*/ */

View File

@ -217,8 +217,8 @@ public class TradeOrderServiceImpl implements TradeOrderService {
order.setTerminal(TerminalEnum.H5.getTerminal()); // todo 数据来源? order.setTerminal(TerminalEnum.H5.getTerminal()); // todo 数据来源?
// 支付信息 // 支付信息
order.setAdjustPrice(0).setPayStatus(false); order.setAdjustPrice(0).setPayStatus(false);
// 物流信息 TODO 芋艿暂时写死物流方式应该是前端选择的 // 物流信息
order.setDeliveryType(createReqVO.getDeliveryType()).setDeliveryStatus(TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus()); order.setDeliveryType(createReqVO.getDeliveryType());
// 退款信息 // 退款信息
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0);
tradeOrderMapper.insert(order); tradeOrderMapper.insert(order);
@ -412,8 +412,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
} }
// 更新 TradeOrderDO 状态为已发货等待收货 // 更新 TradeOrderDO 状态为已发货等待收货
updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()) updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
.setDeliveryStatus(TradeOrderDeliveryStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj); int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj);
if (updateCount == 0) { if (updateCount == 0) {
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
@ -422,7 +421,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
// 发送站内信 // 发送站内信
tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO().setOrderId(order.getId()) tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO().setOrderId(order.getId())
.setUserId(userId).setMessage(TradeOrderDeliveryStatusEnum.DELIVERED.getName())); .setUserId(userId).setMessage(null));
// TODO 芋艿OrderLog // TODO 芋艿OrderLog
// TODO 设计lili是不是发货后才支持售后 // TODO 设计lili是不是发货后才支持售后
@ -453,8 +452,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
throw exception(ORDER_NOT_FOUND); throw exception(ORDER_NOT_FOUND);
} }
// 校验订单是否是待发货状态 // 校验订单是否是待发货状态
if (!TradeOrderStatusEnum.isUndelivered(order.getStatus()) if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) {
|| ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus())) {
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
} }
// 校验订单是否退款 // 校验订单是否退款
@ -480,8 +478,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
// 更新 TradeOrderDO 状态为已完成 // 更新 TradeOrderDO 状态为已完成
int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(),
new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()) new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setReceiveTime(LocalDateTime.now()));
.setDeliveryStatus(TradeOrderDeliveryStatusEnum.RECEIVED.getStatus()).setReceiveTime(LocalDateTime.now()));
if (updateCount == 0) { if (updateCount == 0) {
throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
} }
@ -513,8 +510,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
throw exception(ORDER_NOT_FOUND); throw exception(ORDER_NOT_FOUND);
} }
// 校验订单是否是待收货状态 // 校验订单是否是待收货状态
if (!TradeOrderStatusEnum.isDelivered(order.getStatus()) if (!TradeOrderStatusEnum.isDelivered(order.getStatus())) {
|| ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus())) {
throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
} }
return order; return order;

View File

@ -177,7 +177,6 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
assertEquals(tradeOrderDO.getPayOrderId(), 1000L); assertEquals(tradeOrderDO.getPayOrderId(), 1000L);
assertNull(tradeOrderDO.getPayChannelCode()); assertNull(tradeOrderDO.getPayChannelCode());
assertNull(tradeOrderDO.getLogisticsId()); assertNull(tradeOrderDO.getLogisticsId());
assertEquals(tradeOrderDO.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus());
assertNull(tradeOrderDO.getDeliveryTime()); assertNull(tradeOrderDO.getDeliveryTime());
assertNull(tradeOrderDO.getReceiveTime()); assertNull(tradeOrderDO.getReceiveTime());
assertEquals(tradeOrderDO.getReceiverName(), "芋艿"); assertEquals(tradeOrderDO.getReceiverName(), "芋艿");
@ -274,8 +273,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
// mock 数据TradeOrder // mock 数据TradeOrder
TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> { TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> {
o.setId(1L).setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); o.setId(1L).setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus());
o.setLogisticsId(null).setLogisticsNo(null).setDeliveryTime(null) o.setLogisticsId(null).setLogisticsNo(null).setDeliveryTime(null);
.setDeliveryStatus(TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus());
}); });
tradeOrderMapper.insert(order); tradeOrderMapper.insert(order);
// 准备参数 // 准备参数
@ -288,7 +286,6 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
// 断言 // 断言
TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L); TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L);
assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus()); assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus());
assertEquals(dbOrder.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus());
assertPojoEquals(dbOrder, deliveryReqVO); assertPojoEquals(dbOrder, deliveryReqVO);
assertNotNull(dbOrder.getDeliveryTime()); assertNotNull(dbOrder.getDeliveryTime());
} }
@ -298,7 +295,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
// mock 数据TradeOrder // mock 数据TradeOrder
TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> { TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> {
o.setId(1L).setUserId(10L).setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()); o.setId(1L).setUserId(10L).setStatus(TradeOrderStatusEnum.DELIVERED.getStatus());
o.setDeliveryStatus(TradeOrderDeliveryStatusEnum.DELIVERED.getStatus()).setReceiveTime(null); o.setReceiveTime(null);
}); });
tradeOrderMapper.insert(order); tradeOrderMapper.insert(order);
// 准备参数 // 准备参数
@ -311,7 +308,6 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
// 断言 // 断言
TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L); TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L);
assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus()); assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus());
assertEquals(dbOrder.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.RECEIVED.getStatus());
assertNotNull(dbOrder.getReceiveTime()); assertNotNull(dbOrder.getReceiveTime());
} }

View File

@ -25,7 +25,6 @@ CREATE TABLE IF NOT EXISTS "trade_order" (
"delivery_template_id" bigint, "delivery_template_id" bigint,
"logistics_id" bigint, "logistics_id" bigint,
"logistics_no" varchar, "logistics_no" varchar,
"delivery_status" smallint NOT NULL,
"delivery_time" datetime, "delivery_time" datetime,
"receive_time" datetime, "receive_time" datetime,
"receiver_name" varchar NOT NULL, "receiver_name" varchar NOT NULL,