gaoluyang
3 天以前 d39e4f7d839167c16425086dfa2f8747bccfdff9
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
@@ -74,8 +74,31 @@
        if (noticeLine != null) {
            line.setSaleOrderItemId(noticeLine.getSaleOrderItemId());
        }
        fillProductSalesLinePrice(line);
        productSalesLineMapper.insert(line);
        return line.getId();
    }
    /**
     * 按销售订单行单价回填出库行金额,供开票/对账使用
     */
    private void fillProductSalesLinePrice(MesWmProductSalesLineDO line) {
        if (line.getSaleOrderItemId() == null) {
            return;
        }
        try {
            var item = saleOrderApi.getSaleOrderItem(line.getSaleOrderItemId()).getData();
            if (item == null || item.getProductPrice() == null) {
                return;
            }
            line.setPrice(item.getProductPrice());
            if (line.getQuantity() != null) {
                line.setTotalPrice(item.getProductPrice().multiply(line.getQuantity()));
            }
        } catch (Exception ex) {
            // 价格只是快照,订单行取不到时不阻断开单
            log.warn("[fillProductSalesLinePrice][销售订单行({}) 价格快照失败]", line.getSaleOrderItemId(), ex);
        }
    }
    @Override
@@ -91,6 +114,7 @@
        if (noticeLine != null) {
            updateObj.setSaleOrderItemId(noticeLine.getSaleOrderItemId());
        }
        fillProductSalesLinePrice(updateObj);
        productSalesLineMapper.updateById(updateObj);
        // 提交出库单后由质检人员选择已完成的出厂检验单。