mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	code review:售后详情接口
This commit is contained in:
		@@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderItemBas
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - 售后订单的详情 Response VO")
 | 
			
		||||
@@ -16,7 +15,6 @@ import java.util.List;
 | 
			
		||||
public class TradeAfterSaleDetailRespVO extends TradeAfterSaleBaseVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    @NotNull(message = "售后编号不能为空")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
 | 
			
		||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
 | 
			
		||||
@@ -68,11 +66,9 @@ public class DeliveryPickUpStoreController {
 | 
			
		||||
    @GetMapping("/list-all-simple")
 | 
			
		||||
    @Operation(summary = "获得自提门店精简信息列表")
 | 
			
		||||
    public CommonResult<List<DeliveryPickUpStoreSimpleRespVO>> getSimpleDeliveryPickUpStoreList() {
 | 
			
		||||
        List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(CommonStatusEnum.ENABLE.getStatus());
 | 
			
		||||
        return success(CollectionUtils.convertList(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list), item -> {
 | 
			
		||||
            item.setAreaName(AreaUtils.format(item.getAreaId()));
 | 
			
		||||
            return item;
 | 
			
		||||
        }));
 | 
			
		||||
        List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(
 | 
			
		||||
                CommonStatusEnum.ENABLE.getStatus());
 | 
			
		||||
        return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/list")
 | 
			
		||||
 
 | 
			
		||||
@@ -70,13 +70,6 @@ public interface TradeAfterSaleConvert {
 | 
			
		||||
 | 
			
		||||
    List<TradeAfterSaleLogRespDTO> convertList(List<TradeAfterSaleLogDO> list);
 | 
			
		||||
    
 | 
			
		||||
    List<TradeAfterSaleLogRespVO> convertList1(List<TradeAfterSaleLogRespDTO> list);
 | 
			
		||||
 | 
			
		||||
    TradeOrderBaseVO convert(TradeOrderDO order);
 | 
			
		||||
 | 
			
		||||
    @Mapping(target = "id", source = "afterSale.id")
 | 
			
		||||
    TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, List<TradeOrderItemDO> orderItems, List<TradeAfterSaleLogRespVO> logs);
 | 
			
		||||
 | 
			
		||||
    default TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, TradeOrderDO order, List<TradeOrderItemDO> orderItems,
 | 
			
		||||
                                               MemberUserRespDTO user, List<TradeAfterSaleLogRespDTO> logs) {
 | 
			
		||||
        TradeAfterSaleDetailRespVO respVO = convert(afterSale, orderItems, convertList1(logs));
 | 
			
		||||
@@ -86,4 +79,9 @@ public interface TradeAfterSaleConvert {
 | 
			
		||||
        respVO.setOrder(convert(order));
 | 
			
		||||
        return respVO;
 | 
			
		||||
    }
 | 
			
		||||
    List<TradeAfterSaleLogRespVO> convertList1(List<TradeAfterSaleLogRespDTO> list);
 | 
			
		||||
    @Mapping(target = "id", source = "afterSale.id")
 | 
			
		||||
    TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, List<TradeOrderItemDO> orderItems, List<TradeAfterSaleLogRespVO> logs);
 | 
			
		||||
    TradeOrderBaseVO convert(TradeOrderDO order);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.Deliver
 | 
			
		||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
 | 
			
		||||
import org.mapstruct.Mapper;
 | 
			
		||||
import org.mapstruct.Mapping;
 | 
			
		||||
import org.mapstruct.Named;
 | 
			
		||||
import org.mapstruct.factory.Mappers;
 | 
			
		||||
 | 
			
		||||
@@ -28,10 +29,13 @@ public interface DeliveryPickUpStoreConvert {
 | 
			
		||||
 | 
			
		||||
    PageResult<DeliveryPickUpStoreRespVO> convertPage(PageResult<DeliveryPickUpStoreDO> page);
 | 
			
		||||
 | 
			
		||||
    @Named("convertAreaIdToName")
 | 
			
		||||
    default String convertAreaIdToName(Integer areaId) {
 | 
			
		||||
    List<DeliveryPickUpStoreSimpleRespVO> convertList1(List<DeliveryPickUpStoreDO> list);
 | 
			
		||||
    @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName")
 | 
			
		||||
    DeliveryPickUpStoreSimpleRespVO convert02(DeliveryPickUpStoreDO bean);
 | 
			
		||||
 | 
			
		||||
    @Named("convertAreaIdToAreaName")
 | 
			
		||||
    default String convertAreaIdToAreaName(Integer areaId) {
 | 
			
		||||
        return AreaUtils.format(areaId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    List<DeliveryPickUpStoreSimpleRespVO> convertList1(List<DeliveryPickUpStoreDO> list);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,11 @@ import java.time.LocalDateTime;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
public class TradeOrderDO extends BaseDO {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 发货物流公司编号 - 空(无需发货)
 | 
			
		||||
     */
 | 
			
		||||
    public static final Long LOGISTICS_ID_NULL = 0L;
 | 
			
		||||
 | 
			
		||||
    // ========== 订单基本信息 ==========
 | 
			
		||||
    /**
 | 
			
		||||
     * 订单编号,主键自增
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
// TODO @puhui999:这个是不是应该搞成 vo 啊?
 | 
			
		||||
/**
 | 
			
		||||
 * 贸易售后日志详情 DTO
 | 
			
		||||
 *
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ public interface AfterSaleLogService {
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取售后日志
 | 
			
		||||
     *
 | 
			
		||||
     * @param afterSaleId 售后 id
 | 
			
		||||
     * @param afterSaleId 售后编号
 | 
			
		||||
     * @return 售后日志
 | 
			
		||||
     */
 | 
			
		||||
    List<TradeAfterSaleLogRespDTO> getLog(Long afterSaleId);
 | 
			
		||||
 
 | 
			
		||||
@@ -91,6 +91,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
 | 
			
		||||
    @Override
 | 
			
		||||
    public TradeAfterSaleDO getAfterSale(Long id) {
 | 
			
		||||
        TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id);
 | 
			
		||||
        // TODO @puhui999;读不到,不要这里报错哈;交给前端报错;一般是读取信息不到,message 提示,然后 close tab;
 | 
			
		||||
        if (afterSale == null) {
 | 
			
		||||
            throw exception(AFTER_SALE_NOT_FOUND);
 | 
			
		||||
        }
 | 
			
		||||
@@ -457,4 +458,5 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
 | 
			
		||||
        List<TradeAfterSaleLogDO> saleLogDOs = tradeAfterSaleLogMapper.selectList(TradeAfterSaleLogDO::getAfterSaleId, afterSaleId);
 | 
			
		||||
        return TradeAfterSaleConvert.INSTANCE.convertList(saleLogDOs);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,14 @@ public interface DeliveryExpressService {
 | 
			
		||||
     */
 | 
			
		||||
    DeliveryExpressDO getDeliveryExpress(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验快递公司是否合法
 | 
			
		||||
     *
 | 
			
		||||
     * @param id 编号
 | 
			
		||||
     * @return 快递公司
 | 
			
		||||
     */
 | 
			
		||||
    DeliveryExpressDO validateDeliveryExpress(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得快递公司分页
 | 
			
		||||
     *
 | 
			
		||||
@@ -70,4 +78,5 @@ public interface DeliveryExpressService {
 | 
			
		||||
     * @return 快递公司列表
 | 
			
		||||
     */
 | 
			
		||||
    List<DeliveryExpressDO> getDeliveryExpressListByStatus(Integer status);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
package cn.iocoder.yudao.module.trade.service.delivery;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO;
 | 
			
		||||
@@ -12,12 +13,10 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
			
		||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_CODE_DUPLICATE;
 | 
			
		||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS;
 | 
			
		||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 快递公司 Service 实现类
 | 
			
		||||
@@ -85,6 +84,18 @@ public class DeliveryExpressServiceImpl implements DeliveryExpressService {
 | 
			
		||||
        return deliveryExpressMapper.selectById(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public DeliveryExpressDO validateDeliveryExpress(Long id) {
 | 
			
		||||
        DeliveryExpressDO deliveryExpress = deliveryExpressMapper.selectById(id);
 | 
			
		||||
        if (deliveryExpress == null) {
 | 
			
		||||
            throw exception(EXPRESS_NOT_EXISTS);
 | 
			
		||||
        }
 | 
			
		||||
        if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
 | 
			
		||||
            throw exception(EXPRESS_STATUS_NOT_ENABLE);
 | 
			
		||||
        }
 | 
			
		||||
        return deliveryExpress;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public PageResult<DeliveryExpressDO> getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO) {
 | 
			
		||||
        return deliveryExpressMapper.selectPage(pageReqVO);
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import cn.hutool.extra.spring.SpringUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
 | 
			
		||||
@@ -43,7 +42,6 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettle
 | 
			
		||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO;
 | 
			
		||||
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.dal.mysql.order.TradeOrderItemMapper;
 | 
			
		||||
@@ -416,32 +414,24 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
 | 
			
		||||
    @Override
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) {
 | 
			
		||||
        // TODO @puhui999:只有选择快递的,才可以发货
 | 
			
		||||
        // 1.1 校验并获得交易订单(可发货)
 | 
			
		||||
        TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
 | 
			
		||||
        // 校验 deliveryType 是否为快递,是快递才可以发货
 | 
			
		||||
        // 1.2 校验 deliveryType 是否为快递,是快递才可以发货
 | 
			
		||||
        if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) {
 | 
			
		||||
            throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS);
 | 
			
		||||
        }
 | 
			
		||||
        // TODO @puhui999:下面不修改 deliveryType,直接校验 deliveryType 是否为快递,是快递才可以发货;先做严格的方式哈。
 | 
			
		||||
        // 判断发货类型
 | 
			
		||||
 | 
			
		||||
        // 2. 更新订单为已发货
 | 
			
		||||
        TradeOrderDO updateOrderObj = new TradeOrderDO();
 | 
			
		||||
        // 2.1 快递发货
 | 
			
		||||
        if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), 0L)) {
 | 
			
		||||
            // 校验快递公司
 | 
			
		||||
            DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId());
 | 
			
		||||
            if (deliveryExpress == null) {
 | 
			
		||||
                throw exception(EXPRESS_NOT_EXISTS);
 | 
			
		||||
            }
 | 
			
		||||
            if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
 | 
			
		||||
                throw exception(EXPRESS_STATUS_NOT_ENABLE);
 | 
			
		||||
            }
 | 
			
		||||
        if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) {
 | 
			
		||||
            deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId());
 | 
			
		||||
            updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
 | 
			
		||||
        } else {
 | 
			
		||||
            // 2.2 无需发货
 | 
			
		||||
            updateOrderObj.setLogisticsId(0L).setLogisticsNo("");
 | 
			
		||||
        }
 | 
			
		||||
        // 更新 TradeOrderDO 状态为已发货,等待收货
 | 
			
		||||
        // 执行更新
 | 
			
		||||
        updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
 | 
			
		||||
        int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj);
 | 
			
		||||
        if (updateCount == 0) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user