6 小时以前 55d694aaae4e421b5e55cd941500e08f85cb5d4d
src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
@@ -23,9 +23,12 @@
import com.ruoyi.sales.dto.ShippingApproveDto;
import com.ruoyi.sales.dto.ShippingInfoDto;
import com.ruoyi.sales.dto.ShippingProductDetailDto;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.mapper.ShippingInfoMapper;
import com.ruoyi.sales.mapper.ShippingProductDetailMapper;
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.pojo.ShippingInfo;
import com.ruoyi.sales.pojo.ShippingProductDetail;
import com.ruoyi.sales.service.ShippingInfoService;
@@ -52,6 +55,8 @@
    private final SalesLedgerProductMapper salesLedgerProductMapper;
    private final SalesLedgerMapper salesLedgerMapper;
    private final StockUtils stockUtils;
@@ -172,9 +177,25 @@
    @Override
    public boolean addReq(ShippingInfoDto req) {
        // 校验该产品是否已有待审核/审核中的发货记录,防止重复提交
        // 框架合同只用于登记产品范围,实际发货必须关联框架订单产品。
        Long salesLedgerProductId = req.getSalesLedgerProductId();
        if (salesLedgerProductId != null) {
            SalesLedgerProduct product = salesLedgerProductMapper.selectById(salesLedgerProductId);
            if (product == null) {
                throw new RuntimeException("销售产品不存在");
            }
            if (req.getSalesLedgerId() != null
                    && !java.util.Objects.equals(req.getSalesLedgerId(), product.getSalesLedgerId())) {
                throw new RuntimeException("发货台账与销售产品不匹配");
            }
            SalesLedger ledger = salesLedgerMapper.selectById(product.getSalesLedgerId());
            if (ledger == null || (!java.util.Objects.equals(ledger.getContractType(), 1)
                    && !java.util.Objects.equals(ledger.getContractType(), 3))) {
                throw new RuntimeException("该销售产品不允许发货");
            }
        }
        // 校验该产品是否已有待审核/审核中的发货记录,防止重复提交
        if (salesLedgerProductId != null) {
            long pendingCount = this.count(new LambdaQueryWrapper<ShippingInfo>()
                    .eq(ShippingInfo::getSalesLedgerProductId, salesLedgerProductId)
                    .in(ShippingInfo::getStatus, "待审核", "审核中"));