xiaoyi
2 天以前 14c80fbd16a51a355138345ecf69df9ca37746bf
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/api/sale/ErpSaleOrderApiImpl.java
@@ -13,6 +13,10 @@
import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOrderService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus;
import java.util.Objects;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -21,6 +25,7 @@
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
/**
 * ERP 销售订单 API 实现类
@@ -57,6 +62,18 @@
    @Override
    public CommonResult<ErpSaleOrderRespDTO> getSaleOrder(Long id) {
        ErpSaleOrderDO order = saleOrderService.getSaleOrder(id);
        return success(BeanUtils.toBean(order, ErpSaleOrderRespDTO.class));
    }
    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public CommonResult<ErpSaleOrderRespDTO> lockSaleOrderForNotice(Long id, String orderNo) {
        if (id == null && (orderNo == null || orderNo.isBlank())) return success(null);
        ErpSaleOrderDO order = id != null ? saleOrderMapper.selectByIdForUpdate(id) : saleOrderMapper.selectByNoForUpdate(orderNo);
        if (order == null || (orderNo != null && !orderNo.isBlank() && !Objects.equals(orderNo, order.getNo())))
            throw invalidParamException("关联销售订单不存在或订单编号不匹配");
        if (!Objects.equals(order.getStatus(), ErpAuditStatus.APPROVE.getStatus()))
            throw invalidParamException("销售订单未审核或已作废,不能生成发货通知");
        return success(BeanUtils.toBean(order, ErpSaleOrderRespDTO.class));
    }
@@ -121,4 +138,4 @@
        return success(true);
    }
}
}