Commit 60d4aa97fbdf0a2c19aad7228b00bb64a34558ac
1 parent
059202a5
code review:售后详情接口
Showing
11 changed files
with
54 additions
and
40 deletions
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleDetailRespVO.java
| @@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderItemBas | @@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderItemBas | ||
| 8 | import io.swagger.v3.oas.annotations.media.Schema; | 8 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | import lombok.Data; | 9 | import lombok.Data; |
| 10 | 10 | ||
| 11 | -import javax.validation.constraints.NotNull; | ||
| 12 | import java.util.List; | 11 | import java.util.List; |
| 13 | 12 | ||
| 14 | @Schema(description = "管理后台 - 售后订单的详情 Response VO") | 13 | @Schema(description = "管理后台 - 售后订单的详情 Response VO") |
| @@ -16,7 +15,6 @@ import java.util.List; | @@ -16,7 +15,6 @@ import java.util.List; | ||
| 16 | public class TradeAfterSaleDetailRespVO extends TradeAfterSaleBaseVO { | 15 | public class TradeAfterSaleDetailRespVO extends TradeAfterSaleBaseVO { |
| 17 | 16 | ||
| 18 | @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 17 | @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 19 | - @NotNull(message = "售后编号不能为空") | ||
| 20 | private Long id; | 18 | private Long id; |
| 21 | 19 | ||
| 22 | /** | 20 | /** |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java
| @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery; | @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 7 | -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | ||
| 8 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; |
| 9 | import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; | 7 | import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; |
| 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| @@ -68,11 +66,9 @@ public class DeliveryPickUpStoreController { | @@ -68,11 +66,9 @@ public class DeliveryPickUpStoreController { | ||
| 68 | @GetMapping("/list-all-simple") | 66 | @GetMapping("/list-all-simple") |
| 69 | @Operation(summary = "获得自提门店精简信息列表") | 67 | @Operation(summary = "获得自提门店精简信息列表") |
| 70 | public CommonResult<List<DeliveryPickUpStoreSimpleRespVO>> getSimpleDeliveryPickUpStoreList() { | 68 | public CommonResult<List<DeliveryPickUpStoreSimpleRespVO>> getSimpleDeliveryPickUpStoreList() { |
| 71 | - List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 72 | - return success(CollectionUtils.convertList(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list), item -> { | ||
| 73 | - item.setAreaName(AreaUtils.format(item.getAreaId())); | ||
| 74 | - return item; | ||
| 75 | - })); | 69 | + List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( |
| 70 | + CommonStatusEnum.ENABLE.getStatus()); | ||
| 71 | + return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); | ||
| 76 | } | 72 | } |
| 77 | 73 | ||
| 78 | @GetMapping("/list") | 74 | @GetMapping("/list") |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java
| @@ -69,14 +69,7 @@ public interface TradeAfterSaleConvert { | @@ -69,14 +69,7 @@ public interface TradeAfterSaleConvert { | ||
| 69 | PageResult<AppTradeAfterSaleRespVO> convertPage02(PageResult<TradeAfterSaleDO> page); | 69 | PageResult<AppTradeAfterSaleRespVO> convertPage02(PageResult<TradeAfterSaleDO> page); |
| 70 | 70 | ||
| 71 | List<TradeAfterSaleLogRespDTO> convertList(List<TradeAfterSaleLogDO> list); | 71 | List<TradeAfterSaleLogRespDTO> convertList(List<TradeAfterSaleLogDO> list); |
| 72 | - | ||
| 73 | - List<TradeAfterSaleLogRespVO> convertList1(List<TradeAfterSaleLogRespDTO> list); | ||
| 74 | - | ||
| 75 | - TradeOrderBaseVO convert(TradeOrderDO order); | ||
| 76 | - | ||
| 77 | - @Mapping(target = "id", source = "afterSale.id") | ||
| 78 | - TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, List<TradeOrderItemDO> orderItems, List<TradeAfterSaleLogRespVO> logs); | ||
| 79 | - | 72 | + |
| 80 | default TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, TradeOrderDO order, List<TradeOrderItemDO> orderItems, | 73 | default TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, TradeOrderDO order, List<TradeOrderItemDO> orderItems, |
| 81 | MemberUserRespDTO user, List<TradeAfterSaleLogRespDTO> logs) { | 74 | MemberUserRespDTO user, List<TradeAfterSaleLogRespDTO> logs) { |
| 82 | TradeAfterSaleDetailRespVO respVO = convert(afterSale, orderItems, convertList1(logs)); | 75 | TradeAfterSaleDetailRespVO respVO = convert(afterSale, orderItems, convertList1(logs)); |
| @@ -86,4 +79,9 @@ public interface TradeAfterSaleConvert { | @@ -86,4 +79,9 @@ public interface TradeAfterSaleConvert { | ||
| 86 | respVO.setOrder(convert(order)); | 79 | respVO.setOrder(convert(order)); |
| 87 | return respVO; | 80 | return respVO; |
| 88 | } | 81 | } |
| 82 | + List<TradeAfterSaleLogRespVO> convertList1(List<TradeAfterSaleLogRespDTO> list); | ||
| 83 | + @Mapping(target = "id", source = "afterSale.id") | ||
| 84 | + TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, List<TradeOrderItemDO> orderItems, List<TradeAfterSaleLogRespVO> logs); | ||
| 85 | + TradeOrderBaseVO convert(TradeOrderDO order); | ||
| 86 | + | ||
| 89 | } | 87 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java
| @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.Deliver | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.Deliver | ||
| 8 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; | 8 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; |
| 9 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; | 9 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| 10 | import org.mapstruct.Mapper; | 10 | import org.mapstruct.Mapper; |
| 11 | +import org.mapstruct.Mapping; | ||
| 11 | import org.mapstruct.Named; | 12 | import org.mapstruct.Named; |
| 12 | import org.mapstruct.factory.Mappers; | 13 | import org.mapstruct.factory.Mappers; |
| 13 | 14 | ||
| @@ -28,10 +29,13 @@ public interface DeliveryPickUpStoreConvert { | @@ -28,10 +29,13 @@ public interface DeliveryPickUpStoreConvert { | ||
| 28 | 29 | ||
| 29 | PageResult<DeliveryPickUpStoreRespVO> convertPage(PageResult<DeliveryPickUpStoreDO> page); | 30 | PageResult<DeliveryPickUpStoreRespVO> convertPage(PageResult<DeliveryPickUpStoreDO> page); |
| 30 | 31 | ||
| 31 | - @Named("convertAreaIdToName") | ||
| 32 | - default String convertAreaIdToName(Integer areaId) { | 32 | + List<DeliveryPickUpStoreSimpleRespVO> convertList1(List<DeliveryPickUpStoreDO> list); |
| 33 | + @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") | ||
| 34 | + DeliveryPickUpStoreSimpleRespVO convert02(DeliveryPickUpStoreDO bean); | ||
| 35 | + | ||
| 36 | + @Named("convertAreaIdToAreaName") | ||
| 37 | + default String convertAreaIdToAreaName(Integer areaId) { | ||
| 33 | return AreaUtils.format(areaId); | 38 | return AreaUtils.format(areaId); |
| 34 | } | 39 | } |
| 35 | 40 | ||
| 36 | - List<DeliveryPickUpStoreSimpleRespVO> convertList1(List<DeliveryPickUpStoreDO> list); | ||
| 37 | } | 41 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java
| @@ -27,6 +27,11 @@ import java.time.LocalDateTime; | @@ -27,6 +27,11 @@ import java.time.LocalDateTime; | ||
| 27 | @AllArgsConstructor | 27 | @AllArgsConstructor |
| 28 | public class TradeOrderDO extends BaseDO { | 28 | public class TradeOrderDO extends BaseDO { |
| 29 | 29 | ||
| 30 | + /** | ||
| 31 | + * 发货物流公司编号 - 空(无需发货) | ||
| 32 | + */ | ||
| 33 | + public static final Long LOGISTICS_ID_NULL = 0L; | ||
| 34 | + | ||
| 30 | // ========== 订单基本信息 ========== | 35 | // ========== 订单基本信息 ========== |
| 31 | /** | 36 | /** |
| 32 | * 订单编号,主键自增 | 37 | * 订单编号,主键自增 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogRespDTO.java
| @@ -8,6 +8,7 @@ import lombok.NoArgsConstructor; | @@ -8,6 +8,7 @@ import lombok.NoArgsConstructor; | ||
| 8 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
| 9 | import java.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
| 10 | 10 | ||
| 11 | +// TODO @puhui999:这个是不是应该搞成 vo 啊? | ||
| 11 | /** | 12 | /** |
| 12 | * 贸易售后日志详情 DTO | 13 | * 贸易售后日志详情 DTO |
| 13 | * | 14 | * |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/service/AfterSaleLogService.java
| @@ -26,7 +26,7 @@ public interface AfterSaleLogService { | @@ -26,7 +26,7 @@ public interface AfterSaleLogService { | ||
| 26 | /** | 26 | /** |
| 27 | * 获取售后日志 | 27 | * 获取售后日志 |
| 28 | * | 28 | * |
| 29 | - * @param afterSaleId 售后 id | 29 | + * @param afterSaleId 售后编号 |
| 30 | * @return 售后日志 | 30 | * @return 售后日志 |
| 31 | */ | 31 | */ |
| 32 | List<TradeAfterSaleLogRespDTO> getLog(Long afterSaleId); | 32 | List<TradeAfterSaleLogRespDTO> getLog(Long afterSaleId); |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
| @@ -91,6 +91,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | @@ -91,6 +91,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | ||
| 91 | @Override | 91 | @Override |
| 92 | public TradeAfterSaleDO getAfterSale(Long id) { | 92 | public TradeAfterSaleDO getAfterSale(Long id) { |
| 93 | TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); | 93 | TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); |
| 94 | + // TODO @puhui999;读不到,不要这里报错哈;交给前端报错;一般是读取信息不到,message 提示,然后 close tab; | ||
| 94 | if (afterSale == null) { | 95 | if (afterSale == null) { |
| 95 | throw exception(AFTER_SALE_NOT_FOUND); | 96 | throw exception(AFTER_SALE_NOT_FOUND); |
| 96 | } | 97 | } |
| @@ -457,4 +458,5 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | @@ -457,4 +458,5 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | ||
| 457 | List<TradeAfterSaleLogDO> saleLogDOs = tradeAfterSaleLogMapper.selectList(TradeAfterSaleLogDO::getAfterSaleId, afterSaleId); | 458 | List<TradeAfterSaleLogDO> saleLogDOs = tradeAfterSaleLogMapper.selectList(TradeAfterSaleLogDO::getAfterSaleId, afterSaleId); |
| 458 | return TradeAfterSaleConvert.INSTANCE.convertList(saleLogDOs); | 459 | return TradeAfterSaleConvert.INSTANCE.convertList(saleLogDOs); |
| 459 | } | 460 | } |
| 461 | + | ||
| 460 | } | 462 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java
| @@ -48,6 +48,14 @@ public interface DeliveryExpressService { | @@ -48,6 +48,14 @@ public interface DeliveryExpressService { | ||
| 48 | DeliveryExpressDO getDeliveryExpress(Long id); | 48 | DeliveryExpressDO getDeliveryExpress(Long id); |
| 49 | 49 | ||
| 50 | /** | 50 | /** |
| 51 | + * 校验快递公司是否合法 | ||
| 52 | + * | ||
| 53 | + * @param id 编号 | ||
| 54 | + * @return 快递公司 | ||
| 55 | + */ | ||
| 56 | + DeliveryExpressDO validateDeliveryExpress(Long id); | ||
| 57 | + | ||
| 58 | + /** | ||
| 51 | * 获得快递公司分页 | 59 | * 获得快递公司分页 |
| 52 | * | 60 | * |
| 53 | * @param pageReqVO 分页查询 | 61 | * @param pageReqVO 分页查询 |
| @@ -70,4 +78,5 @@ public interface DeliveryExpressService { | @@ -70,4 +78,5 @@ public interface DeliveryExpressService { | ||
| 70 | * @return 快递公司列表 | 78 | * @return 快递公司列表 |
| 71 | */ | 79 | */ |
| 72 | List<DeliveryExpressDO> getDeliveryExpressListByStatus(Integer status); | 80 | List<DeliveryExpressDO> getDeliveryExpressListByStatus(Integer status); |
| 81 | + | ||
| 73 | } | 82 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java
| 1 | package cn.iocoder.yudao.module.trade.service.delivery; | 1 | package cn.iocoder.yudao.module.trade.service.delivery; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; | 5 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; |
| 5 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; |
| @@ -12,12 +13,10 @@ import org.springframework.stereotype.Service; | @@ -12,12 +13,10 @@ import org.springframework.stereotype.Service; | ||
| 12 | import org.springframework.validation.annotation.Validated; | 13 | import org.springframework.validation.annotation.Validated; |
| 13 | 14 | ||
| 14 | import javax.annotation.Resource; | 15 | import javax.annotation.Resource; |
| 15 | -import java.util.Collection; | ||
| 16 | import java.util.List; | 16 | import java.util.List; |
| 17 | 17 | ||
| 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_CODE_DUPLICATE; | ||
| 20 | -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS; | 19 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; |
| 21 | 20 | ||
| 22 | /** | 21 | /** |
| 23 | * 快递公司 Service 实现类 | 22 | * 快递公司 Service 实现类 |
| @@ -86,6 +85,18 @@ public class DeliveryExpressServiceImpl implements DeliveryExpressService { | @@ -86,6 +85,18 @@ public class DeliveryExpressServiceImpl implements DeliveryExpressService { | ||
| 86 | } | 85 | } |
| 87 | 86 | ||
| 88 | @Override | 87 | @Override |
| 88 | + public DeliveryExpressDO validateDeliveryExpress(Long id) { | ||
| 89 | + DeliveryExpressDO deliveryExpress = deliveryExpressMapper.selectById(id); | ||
| 90 | + if (deliveryExpress == null) { | ||
| 91 | + throw exception(EXPRESS_NOT_EXISTS); | ||
| 92 | + } | ||
| 93 | + if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { | ||
| 94 | + throw exception(EXPRESS_STATUS_NOT_ENABLE); | ||
| 95 | + } | ||
| 96 | + return deliveryExpress; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Override | ||
| 89 | public PageResult<DeliveryExpressDO> getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO) { | 100 | public PageResult<DeliveryExpressDO> getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO) { |
| 90 | return deliveryExpressMapper.selectPage(pageReqVO); | 101 | return deliveryExpressMapper.selectPage(pageReqVO); |
| 91 | } | 102 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| @@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil; | @@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil; | ||
| 7 | import cn.hutool.core.util.StrUtil; | 7 | import cn.hutool.core.util.StrUtil; |
| 8 | import cn.hutool.extra.spring.SpringUtil; | 8 | import cn.hutool.extra.spring.SpringUtil; |
| 9 | import cn.iocoder.yudao.framework.common.core.KeyValue; | 9 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 10 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 11 | import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | 10 | import cn.iocoder.yudao.framework.common.enums.TerminalEnum; |
| 12 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 11 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 13 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 12 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| @@ -43,7 +42,6 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettle | @@ -43,7 +42,6 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettle | ||
| 43 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; | 42 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; |
| 44 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; | 43 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 45 | import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; | 44 | import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; |
| 46 | -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; | ||
| 47 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; | 45 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 48 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | 46 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| 49 | import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; | 47 | import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; |
| @@ -416,32 +414,24 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { | @@ -416,32 +414,24 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { | ||
| 416 | @Override | 414 | @Override |
| 417 | @Transactional(rollbackFor = Exception.class) | 415 | @Transactional(rollbackFor = Exception.class) |
| 418 | public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) { | 416 | public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) { |
| 419 | - // TODO @puhui999:只有选择快递的,才可以发货 | ||
| 420 | // 1.1 校验并获得交易订单(可发货) | 417 | // 1.1 校验并获得交易订单(可发货) |
| 421 | TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); | 418 | TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); |
| 422 | - // 校验 deliveryType 是否为快递,是快递才可以发货 | 419 | + // 1.2 校验 deliveryType 是否为快递,是快递才可以发货 |
| 423 | if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) { | 420 | if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) { |
| 424 | throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS); | 421 | throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS); |
| 425 | } | 422 | } |
| 426 | - // TODO @puhui999:下面不修改 deliveryType,直接校验 deliveryType 是否为快递,是快递才可以发货;先做严格的方式哈。 | ||
| 427 | - // 判断发货类型 | 423 | + |
| 424 | + // 2. 更新订单为已发货 | ||
| 428 | TradeOrderDO updateOrderObj = new TradeOrderDO(); | 425 | TradeOrderDO updateOrderObj = new TradeOrderDO(); |
| 429 | // 2.1 快递发货 | 426 | // 2.1 快递发货 |
| 430 | - if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), 0L)) { | ||
| 431 | - // 校验快递公司 | ||
| 432 | - DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId()); | ||
| 433 | - if (deliveryExpress == null) { | ||
| 434 | - throw exception(EXPRESS_NOT_EXISTS); | ||
| 435 | - } | ||
| 436 | - if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { | ||
| 437 | - throw exception(EXPRESS_STATUS_NOT_ENABLE); | ||
| 438 | - } | 427 | + if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) { |
| 428 | + deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId()); | ||
| 439 | updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); | 429 | updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); |
| 440 | } else { | 430 | } else { |
| 441 | // 2.2 无需发货 | 431 | // 2.2 无需发货 |
| 442 | updateOrderObj.setLogisticsId(0L).setLogisticsNo(""); | 432 | updateOrderObj.setLogisticsId(0L).setLogisticsNo(""); |
| 443 | } | 433 | } |
| 444 | - // 更新 TradeOrderDO 状态为已发货,等待收货 | 434 | + // 执行更新 |
| 445 | updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); | 435 | updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); |
| 446 | int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj); | 436 | int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj); |
| 447 | if (updateCount == 0) { | 437 | if (updateCount == 0) { |