From e992a62a5beeaeea9906f74d99d7bb7ca31238c4 Mon Sep 17 00:00:00 2001 From: wangy Date: Thu, 21 May 2026 15:31:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(sip):bug=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E7=A8=8E=E7=8E=87=E7=A8=8E=E9=A2=9D=E5=8F=96=E7=9A=84=E6=98=AF?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E4=BF=A1=E6=81=AF=E4=B8=AD=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/sip/mapper/ProductInfoMapper.java | 2 ++ .../impl/OmsPurchaseOrderServiceImpl.java | 30 ++++++++++++++----- .../mapper/system/ProductInfoMapper.xml | 8 +++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProductInfoMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProductInfoMapper.java index 7f82d5e0..b355cb12 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProductInfoMapper.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProductInfoMapper.java @@ -79,4 +79,6 @@ public interface ProductInfoMapper void updateCount(List values); List listInventory(ProductInfo info); + + ProductInfo selectProductInfoByBomCode(String productCode); } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPurchaseOrderServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPurchaseOrderServiceImpl.java index 12f9ad67..d5c3e8ed 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPurchaseOrderServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPurchaseOrderServiceImpl.java @@ -20,9 +20,7 @@ import com.ruoyi.sip.flowable.domain.Todo; import com.ruoyi.sip.flowable.service.DeleteFlowableProcessInstanceCmd; import com.ruoyi.sip.flowable.service.TodoCommonTemplate; import com.ruoyi.sip.flowable.service.TodoService; -import com.ruoyi.sip.mapper.OmsPurchaseOrderItemHistoryMapper; -import com.ruoyi.sip.mapper.OmsPurchaseOrderHistoryMapper; -import com.ruoyi.sip.mapper.VendorInfoMapper; +import com.ruoyi.sip.mapper.*; import com.ruoyi.sip.service.*; import com.ruoyi.system.mapper.SysUserMapper; import lombok.extern.slf4j.Slf4j; @@ -38,7 +36,6 @@ import org.springframework.stereotype.Service; import com.ruoyi.common.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.sip.mapper.OmsPurchaseOrderMapper; import javax.annotation.Resource; @@ -67,6 +64,9 @@ public class OmsPurchaseOrderServiceImpl implements IOmsPurchaseOrderService, To @Resource private VendorInfoMapper vendorInfoMapper; + @Resource + private ProductInfoMapper productInfoMapper; + @Resource private SysUserMapper userMapper; @@ -646,10 +646,26 @@ public class OmsPurchaseOrderServiceImpl implements IOmsPurchaseOrderService, To orderItem.setProductType(addToNexReq.getProductType()); orderItem.setProductCode(addToNexReq.getProductCode()); orderItem.setQuantity(new BigDecimal(addToNexReq.getQuantity())); - orderItem.setPrice(addToNexReq.getPrice()); - orderItem.setTaxRate(addToNexReq.getTaxRate()); - orderItem.setTaxTotal(addToNexReq.getTaxTotal()); + // 根据BOM编码查询产品信息,折扣,单价和税率都从产品信息读 + log.info("通过BOM编码查询产品信息"); + ProductInfo productInfo = productInfoMapper.selectProductInfoByBomCode(addToNexReq.getProductCode()); + if (productInfo == null) { + throw new ServiceException("未找到BOM编码对应的产品信息: " + addToNexReq.getProductCode()); + } + log.info("通过BOM编码查询产品信息"); + // 将String类型转换为BigDecimal + BigDecimal price = new BigDecimal(productInfo.getCataloguePrice() != null ? productInfo.getCataloguePrice() : "0"); + BigDecimal taxRate = new BigDecimal(productInfo.getGuidanceDiscount() != null ? productInfo.getGuidanceDiscount() : "0"); + + orderItem.setPrice(price); + orderItem.setTaxRate(taxRate); + + // 税额 = 单价 * 数量 - (单价 * 数量) / (1 + 税率),结果取两位小数 + BigDecimal quantity = orderItem.getQuantity(); + BigDecimal totalAmount = price.multiply(quantity); + BigDecimal taxTotal = totalAmount.subtract(totalAmount.divide(BigDecimal.ONE.add(taxRate), 2, BigDecimal.ROUND_HALF_UP)); + orderItem.setTaxTotal(taxTotal.setScale(2, BigDecimal.ROUND_HALF_UP)); // 根据传入的参数计算金额 BigDecimal amountTotal = addToNexReq.getPrice() != null && addToNexReq.getQuantity() != null ? addToNexReq.getPrice().multiply(new BigDecimal(addToNexReq.getQuantity())) diff --git a/ruoyi-sip/src/main/resources/mapper/system/ProductInfoMapper.xml b/ruoyi-sip/src/main/resources/mapper/system/ProductInfoMapper.xml index 9275a710..78014779 100644 --- a/ruoyi-sip/src/main/resources/mapper/system/ProductInfoMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/system/ProductInfoMapper.xml @@ -259,4 +259,12 @@ + + + \ No newline at end of file