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 | 8 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | 9 | import lombok.Data; |
| 10 | 10 | |
| 11 | -import javax.validation.constraints.NotNull; | |
| 12 | 11 | import java.util.List; |
| 13 | 12 | |
| 14 | 13 | @Schema(description = "管理后台 - 售后订单的详情 Response VO") |
| ... | ... | @@ -16,7 +15,6 @@ import java.util.List; |
| 16 | 15 | public class TradeAfterSaleDetailRespVO extends TradeAfterSaleBaseVO { |
| 17 | 16 | |
| 18 | 17 | @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 19 | - @NotNull(message = "售后编号不能为空") | |
| 20 | 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 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 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 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; |
| 9 | 7 | import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; |
| 10 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| ... | ... | @@ -68,11 +66,9 @@ public class DeliveryPickUpStoreController { |
| 68 | 66 | @GetMapping("/list-all-simple") |
| 69 | 67 | @Operation(summary = "获得自提门店精简信息列表") |
| 70 | 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 | 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 | 69 | PageResult<AppTradeAfterSaleRespVO> convertPage02(PageResult<TradeAfterSaleDO> page); |
| 70 | 70 | |
| 71 | 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 | 73 | default TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, TradeOrderDO order, List<TradeOrderItemDO> orderItems, |
| 81 | 74 | MemberUserRespDTO user, List<TradeAfterSaleLogRespDTO> logs) { |
| 82 | 75 | TradeAfterSaleDetailRespVO respVO = convert(afterSale, orderItems, convertList1(logs)); |
| ... | ... | @@ -86,4 +79,9 @@ public interface TradeAfterSaleConvert { |
| 86 | 79 | respVO.setOrder(convert(order)); |
| 87 | 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 | 8 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| 10 | 10 | import org.mapstruct.Mapper; |
| 11 | +import org.mapstruct.Mapping; | |
| 11 | 12 | import org.mapstruct.Named; |
| 12 | 13 | import org.mapstruct.factory.Mappers; |
| 13 | 14 | |
| ... | ... | @@ -28,10 +29,13 @@ public interface DeliveryPickUpStoreConvert { |
| 28 | 29 | |
| 29 | 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 | 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 | 27 | @AllArgsConstructor |
| 28 | 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
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/service/AfterSaleLogService.java
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 | 91 | @Override |
| 92 | 92 | public TradeAfterSaleDO getAfterSale(Long id) { |
| 93 | 93 | TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); |
| 94 | + // TODO @puhui999;读不到,不要这里报错哈;交给前端报错;一般是读取信息不到,message 提示,然后 close tab; | |
| 94 | 95 | if (afterSale == null) { |
| 95 | 96 | throw exception(AFTER_SALE_NOT_FOUND); |
| 96 | 97 | } |
| ... | ... | @@ -457,4 +458,5 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa |
| 457 | 458 | List<TradeAfterSaleLogDO> saleLogDOs = tradeAfterSaleLogMapper.selectList(TradeAfterSaleLogDO::getAfterSaleId, afterSaleId); |
| 458 | 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 | 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 | 61 | * @param pageReqVO 分页查询 |
| ... | ... | @@ -70,4 +78,5 @@ public interface DeliveryExpressService { |
| 70 | 78 | * @return 快递公司列表 |
| 71 | 79 | */ |
| 72 | 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 | 1 | package cn.iocoder.yudao.module.trade.service.delivery; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; |
| ... | ... | @@ -12,12 +13,10 @@ import org.springframework.stereotype.Service; |
| 12 | 13 | import org.springframework.validation.annotation.Validated; |
| 13 | 14 | |
| 14 | 15 | import javax.annotation.Resource; |
| 15 | -import java.util.Collection; | |
| 16 | 16 | import java.util.List; |
| 17 | 17 | |
| 18 | 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 | 22 | * 快递公司 Service 实现类 |
| ... | ... | @@ -86,6 +85,18 @@ public class DeliveryExpressServiceImpl implements DeliveryExpressService { |
| 86 | 85 | } |
| 87 | 86 | |
| 88 | 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 | 100 | public PageResult<DeliveryExpressDO> getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO) { |
| 90 | 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 | import cn.hutool.core.util.StrUtil; |
| 8 | 8 | import cn.hutool.extra.spring.SpringUtil; |
| 9 | 9 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 10 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 11 | 10 | import cn.iocoder.yudao.framework.common.enums.TerminalEnum; |
| 12 | 11 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 13 | 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 | 42 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; |
| 44 | 43 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 45 | 44 | import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; |
| 46 | -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; | |
| 47 | 45 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 48 | 46 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| 49 | 47 | import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; |
| ... | ... | @@ -416,32 +414,24 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 416 | 414 | @Override |
| 417 | 415 | @Transactional(rollbackFor = Exception.class) |
| 418 | 416 | public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) { |
| 419 | - // TODO @puhui999:只有选择快递的,才可以发货 | |
| 420 | 417 | // 1.1 校验并获得交易订单(可发货) |
| 421 | 418 | TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); |
| 422 | - // 校验 deliveryType 是否为快递,是快递才可以发货 | |
| 419 | + // 1.2 校验 deliveryType 是否为快递,是快递才可以发货 | |
| 423 | 420 | if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) { |
| 424 | 421 | throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS); |
| 425 | 422 | } |
| 426 | - // TODO @puhui999:下面不修改 deliveryType,直接校验 deliveryType 是否为快递,是快递才可以发货;先做严格的方式哈。 | |
| 427 | - // 判断发货类型 | |
| 423 | + | |
| 424 | + // 2. 更新订单为已发货 | |
| 428 | 425 | TradeOrderDO updateOrderObj = new TradeOrderDO(); |
| 429 | 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 | 429 | updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); |
| 440 | 430 | } else { |
| 441 | 431 | // 2.2 无需发货 |
| 442 | 432 | updateOrderObj.setLogisticsId(0L).setLogisticsNo(""); |
| 443 | 433 | } |
| 444 | - // 更新 TradeOrderDO 状态为已发货,等待收货 | |
| 434 | + // 执行更新 | |
| 445 | 435 | updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); |
| 446 | 436 | int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj); |
| 447 | 437 | if (updateCount == 0) { | ... | ... |