修改商品导入金额问题

This commit is contained in:
zjf committed 2025-03-20 14:32:48 +08:00
1 parent 6aa0cb0928
commit cd0a5e603b
2 files changed
+24 -6

No files matched your search

@@ -40,22 +40,22 @@ public class SmErpSpuImportDto {
private Integer packageNum; // 装数
@ExcelProperty("进价")
private Integer purchasePrice; // 进价
private Double purchasePrice; // 进价
@ExcelProperty("零售价")
private Integer retailPrice; // 零售价
private Double retailPrice; // 零售价
@ExcelProperty("货商")
private String supplier; // 货商
@ExcelProperty("促销价")
private Integer promotionPrice; // 促销价
private Double promotionPrice; // 促销价
@ExcelProperty("商品性质")
private String commodityNature; // 商品性质
@ExcelProperty("成本单价")
private Integer costPrice; // 成本单价
private Double costPrice; // 成本单价
@ExcelProperty("库存上限")
private int inventoryUpperLimit; // 库存上限
@@ -44,6 +44,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
@@ -644,8 +646,24 @@ public class SmErpSpuServiceImpl extends ServiceImpl<SmErpSpuMapper, SmErpSpuEnt
// 处理单位数据
SmErpUnitEntity unit = new SmErpUnitEntity();
org.springframework.beans.BeanUtils.copyProperties(dto, unit);
unit.setPurchasePrice(dto.getPurchasePrice()*100);
unit.setRetailPrice(dto.getRetailPrice()*100);
unit.setPurchasePrice( BigDecimal.valueOf(dto.getPurchasePrice())
.multiply(BigDecimal.valueOf(100))
.setScale(0, RoundingMode.HALF_UP) // 四舍五入
.intValueExact());
unit.setRetailPrice(
BigDecimal.valueOf(dto.getRetailPrice())
.multiply(BigDecimal.valueOf(100))
.setScale(0, RoundingMode.HALF_UP)
.intValueExact()
);
unit.setPromotionPrice(BigDecimal.valueOf(dto.getPromotionPrice())
.multiply(BigDecimal.valueOf(100))
.setScale(0, RoundingMode.HALF_UP)
.intValueExact());
unit.setCostPrice(BigDecimal.valueOf(dto.getCostPrice())
.multiply(BigDecimal.valueOf(100))
.setScale(0, RoundingMode.HALF_UP)
.intValueExact());
unit.setSpuId(spu.getId());
unit.setIsBase(true);
unitBatch.add(unit);