修复盘点价格错误问题
This commit is contained in:
parent
ff3d5a054d
commit
f491a382cb
|
|
@ -24,7 +24,6 @@ public class TbProductStocktakinController {
|
|||
private final TbProductStocktakinService tbProductStocktakinService;
|
||||
|
||||
@PostMapping
|
||||
@AnonymousAccess
|
||||
@ApiOperation("新增盘点")
|
||||
public ResponseEntity<Object> addStocktakin(
|
||||
@RequestBody @Validated TbProductStocktakinDTO productStocktakinDTO
|
||||
|
|
@ -42,7 +41,6 @@ public class TbProductStocktakinController {
|
|||
return ResponseEntity.ok("成功");
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@GetMapping
|
||||
@ApiOperation("获取盘点数据")
|
||||
public ResponseEntity<Object> getStocktakinList(TbProductStocktakinQueryCriteria productStocktakinQueryCriteria, Pageable pageable) {
|
||||
|
|
|
|||
|
|
@ -75,13 +75,15 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
|||
}
|
||||
|
||||
TbProduct product = tbProductRepository.findById(productStocktakinDTO.getProductId()).orElse(null);
|
||||
if (product == null) {
|
||||
throw new BadRequestException("商品不存在, 商品id: {}" + productStocktakinDTO.getProductId());
|
||||
}
|
||||
|
||||
TbProductStocktakin productStocktakin = new TbProductStocktakin();
|
||||
|
||||
productStocktakin.setProductId(productStocktakinDTO.getProductId());
|
||||
productStocktakin.setCreateTime(DateUtil.date());
|
||||
productStocktakin.setNote(productStocktakinDTO.getNote());
|
||||
productStocktakin.setStock(product.getStockNumber());
|
||||
productStocktakin.setInventoryStock(productStocktakinDTO.getStocktakinNum());
|
||||
productStocktakin.setName(product.getName());
|
||||
productStocktakin.setCoverImg(product.getCoverImg());
|
||||
|
|
@ -131,9 +133,7 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
|||
if (product.getIsDistribute() == 1) {
|
||||
round = (int) Math.floor( product.getStockNumber());
|
||||
productStocktakin.setPhasePrice(
|
||||
productStocktakinDTO.getPrice().multiply(BigDecimal.valueOf(productStocktakinDTO.getStocktakinNum())).subtract(
|
||||
productStocktakinDTO.getPrice().multiply(BigDecimal.valueOf(product.getStockNumber()))
|
||||
)
|
||||
productStocktakinDTO.getPrice().multiply(BigDecimal.valueOf(phaseNum))
|
||||
);
|
||||
|
||||
productStockDetail.setSubType(productStocktakinDTO.getStocktakinNum() > product.getStockNumber() ? 1 : -1);
|
||||
|
|
@ -141,6 +141,7 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
|||
productStockDetail.setType(productStocktakinDTO.getStocktakinNum() > product.getStockNumber() ? "盘点入库" : "盘点出库");
|
||||
|
||||
productStocktakin.setPhaseNum(productStocktakinDTO.getStocktakinNum() - product.getStockNumber());
|
||||
productStocktakin.setStock(product.getStockNumber());
|
||||
if (tbProductRepository.updateStock(product.getId(), product.getStockNumber(), productStocktakinDTO.getStocktakinNum()) < 1) {
|
||||
throw new BadRequestException("修改库存失败,稍后再试");
|
||||
}
|
||||
|
|
@ -165,10 +166,10 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
|||
productStockDetail.setType(productStocktakinDTO.getStocktakinNum() > productSku.getStockNumber() ? "盘点入库" : "盘点出库");
|
||||
productStocktakin.setSkuId(productSku.getId());
|
||||
productStocktakin.setPhasePrice(
|
||||
productStocktakinDTO.getPrice().multiply(BigDecimal.valueOf(productStocktakinDTO.getStocktakinNum())).subtract(
|
||||
productStocktakinDTO.getPrice().multiply(BigDecimal.valueOf(product.getStockNumber()))
|
||||
)
|
||||
productStocktakinDTO.getPrice().multiply(BigDecimal.valueOf(phaseNum))
|
||||
);
|
||||
productStocktakin.setStock(productSku.getStockNumber().intValue());
|
||||
|
||||
productStocktakin.setPhaseNum((int) (productStocktakinDTO.getStocktakinNum() - productSku.getStockNumber()));
|
||||
if (producSkutMapper.updateStock(productSku.getId(), productSku.getStockNumber(), productStocktakinDTO.getStocktakinNum()) < 1) {
|
||||
throw new BadRequestException("修改库存失败,稍后再试");
|
||||
|
|
|
|||
Loading…
Reference in New Issue