订单:

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();
reqVO.setName(null);
reqVO.setSpuId(null);
reqVO.setTotalLimitCount(null);
reqVO.setSingleLimitCount(null);
reqVO.setStartTime(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.setLimitDuration(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用
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.AppTradeOrderItemRespVO;
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.TradeOrderItemDO;
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.service.delivery.DeliveryExpressService;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderService;
import com.google.common.collect.Maps;
import io.swagger.v3.oas.annotations.Operation;
@ -42,8 +44,12 @@ public class AppTradeOrderController {
@Resource
private TradeOrderService tradeOrderService;
@Resource
private DeliveryExpressService deliveryExpressService;
@Resource
private ProductPropertyValueApi productPropertyValueApi;
@Resource
private TradeOrderProperties tradeOrderProperties;
@ -76,14 +82,21 @@ public class AppTradeOrderController {
public CommonResult<AppTradeOrderDetailRespVO> getOrder(@RequestParam("id") Long id) {
// 查询订单
TradeOrderDO order = tradeOrderService.getOrder(getLoginUserId(), id);
if (order == null) {
return success(null);
}
// 查询订单项
List<TradeOrderItemDO> orderItems = tradeOrderService.getOrderItemListByOrderId(order.getId());
// 查询商品属性
List<ProductPropertyValueDetailRespDTO> propertyValueDetails = productPropertyValueApi
.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,
propertyValueDetails, tradeOrderProperties));
propertyValueDetails, tradeOrderProperties, express));
}
@GetMapping("/page")

View File

@ -80,6 +80,12 @@ public class AppTradeOrderDetailRespVO {
@Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer deliveryType;
@Schema(description = "发货物流公司编号", example = "10")
private Long logisticsId;
@Schema(description = "发货物流名称", example = "顺丰快递")
private String logisticsName;
@Schema(description = "发货物流单号", example = "1024")
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.AppTradeOrderItemRespVO;
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.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum;
@ -234,7 +235,8 @@ public interface TradeOrderConvert {
// TODO 芋艿可简化
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);
orderVO.setPayExpireTime(addTime(tradeOrderProperties.getExpireTime()));
if (StrUtil.isNotEmpty(order.getPayChannelCode())) {
@ -260,6 +262,9 @@ public interface TradeOrderConvert {
}
// 处理收货地址
orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId()));
if (express != null) {
orderVO.setLogisticsId(express.getId()).setLogisticsName(express.getName());
}
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.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.enums.delivery.DeliveryTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.*;
@ -174,18 +175,18 @@ public class TradeOrderDO extends BaseDO {
private Integer deliveryType;
/**
* 发货物流公司编号
*
* 如果无需发货 logisticsId 设置为 0原因是不想再添加额外字段
*
* 关联 {@link DeliveryExpressDO#getId()}
*/
private Long logisticsId;
/**
* 发货物流单号
*
* 如果无需发货 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.setAdjustPrice(0).setPayStatus(false);
// 物流信息 TODO 芋艿暂时写死物流方式应该是前端选择的
order.setDeliveryType(createReqVO.getDeliveryType()).setDeliveryStatus(TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus());
// 物流信息
order.setDeliveryType(createReqVO.getDeliveryType());
// 退款信息
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0);
tradeOrderMapper.insert(order);
@ -412,8 +412,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
}
// 更新 TradeOrderDO 状态为已发货等待收货
updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus())
.setDeliveryStatus(TradeOrderDeliveryStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj);
if (updateCount == 0) {
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
@ -422,7 +421,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
// 发送站内信
tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO().setOrderId(order.getId())
.setUserId(userId).setMessage(TradeOrderDeliveryStatusEnum.DELIVERED.getName()));
.setUserId(userId).setMessage(null));
// TODO 芋艿OrderLog
// TODO 设计lili是不是发货后才支持售后
@ -453,8 +452,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
throw exception(ORDER_NOT_FOUND);
}
// 校验订单是否是待发货状态
if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())
|| ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus())) {
if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) {
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
}
// 校验订单是否退款
@ -480,8 +478,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
// 更新 TradeOrderDO 状态为已完成
int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(),
new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus())
.setDeliveryStatus(TradeOrderDeliveryStatusEnum.RECEIVED.getStatus()).setReceiveTime(LocalDateTime.now()));
new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setReceiveTime(LocalDateTime.now()));
if (updateCount == 0) {
throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
}
@ -513,8 +510,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
throw exception(ORDER_NOT_FOUND);
}
// 校验订单是否是待收货状态
if (!TradeOrderStatusEnum.isDelivered(order.getStatus())
|| ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus())) {
if (!TradeOrderStatusEnum.isDelivered(order.getStatus())) {
throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
}
return order;

View File

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

View File

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