商品耗材取消订单/退菜/退单红冲库存
This commit is contained in:
@@ -34,6 +34,10 @@ public class ProductModifyStockParam implements Serializable {
|
|||||||
@Min(value = 0, message = "库存数量不能小于0", groups = DefaultGroup.class)
|
@Min(value = 0, message = "库存数量不能小于0", groups = DefaultGroup.class)
|
||||||
@Max(value = Integer.MAX_VALUE, message = "库存数量不能大于" + Integer.MAX_VALUE, groups = DefaultGroup.class)
|
@Max(value = Integer.MAX_VALUE, message = "库存数量不能大于" + Integer.MAX_VALUE, groups = DefaultGroup.class)
|
||||||
private Integer stockNumber;
|
private Integer stockNumber;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
/**
|
/**
|
||||||
* 店铺id
|
* 店铺id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
|
|||||||
throw new CzgException(StrUtil.format("耗材{}报损数量不能大于当前库存{}", entity.getConName(), consInfo.getStockNumber()));
|
throw new CzgException(StrUtil.format("耗材{}报损数量不能大于当前库存{}", entity.getConName(), consInfo.getStockNumber()));
|
||||||
}
|
}
|
||||||
entity.setBeforeNumber(consInfo.getStockNumber());
|
entity.setBeforeNumber(consInfo.getStockNumber());
|
||||||
entity.setInOutNumber(NumberUtil.sub(BigDecimal.ZERO, balance));
|
entity.setInOutNumber(NumberUtil.sub(BigDecimal.ZERO, param.getNumber()));
|
||||||
entity.setAfterNumber(balance);
|
entity.setAfterNumber(balance);
|
||||||
entity.setInOutType(InOutTypeEnum.OUT.value());
|
entity.setInOutType(InOutTypeEnum.OUT.value());
|
||||||
entity.setInOutItem(InOutItemEnum.DAMAGE_OUT.value());
|
entity.setInOutItem(InOutItemEnum.DAMAGE_OUT.value());
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|||||||
if (entity.getIsStock() == YesNoEnum.NO.value()) {
|
if (entity.getIsStock() == YesNoEnum.NO.value()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!entity.getShopId().equals(param.getShopId())) {
|
if (!entity.getShopId().equals(param.getShopId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UpdateChain.of(Product.class)
|
UpdateChain.of(Product.class)
|
||||||
@@ -365,6 +365,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
flow.setAfterNumber(NumberUtil.toBigDecimal(entity.getStockNumber()));
|
flow.setAfterNumber(NumberUtil.toBigDecimal(entity.getStockNumber()));
|
||||||
|
flow.setRemark(param.getRemark());
|
||||||
productStockFlowService.saveFlow(flow);
|
productStockFlowService.saveFlow(flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,19 +540,19 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|||||||
entity.setConId(consInfo.getConsInfoId());
|
entity.setConId(consInfo.getConsInfoId());
|
||||||
entity.setConName(consInfo.getConName());
|
entity.setConName(consInfo.getConName());
|
||||||
entity.setPurchasePrice(consInfo.getPrice());
|
entity.setPurchasePrice(consInfo.getPrice());
|
||||||
BigDecimal balance = NumberUtil.sub(consInfo.getStockNumber(), param.getNumber());
|
BigDecimal inOutNumber = NumberUtil.mul(param.getNumber(), consInfo.getSurplusStock());
|
||||||
|
BigDecimal balance = NumberUtil.sub(consInfo.getStockNumber(), inOutNumber);
|
||||||
if (NumberUtil.isLess(balance, BigDecimal.ZERO)) {
|
if (NumberUtil.isLess(balance, BigDecimal.ZERO)) {
|
||||||
throw new CzgException(StrUtil.format("耗材{}存在发生变动,请刷新后重试", entity.getConName()));
|
throw new CzgException(StrUtil.format("耗材{}存在发生变动,请刷新后重试", entity.getConName()));
|
||||||
}
|
}
|
||||||
entity.setBeforeNumber(consInfo.getStockNumber());
|
entity.setBeforeNumber(consInfo.getStockNumber());
|
||||||
entity.setInOutNumber(NumberUtil.sub(BigDecimal.ZERO, balance));
|
entity.setInOutNumber(NumberUtil.sub(BigDecimal.ZERO, inOutNumber));
|
||||||
entity.setAfterNumber(balance);
|
entity.setAfterNumber(balance);
|
||||||
entity.setInOutType(InOutTypeEnum.OUT.value());
|
entity.setInOutType(InOutTypeEnum.OUT.value());
|
||||||
entity.setInOutItem(InOutItemEnum.DAMAGE_OUT.value());
|
entity.setInOutItem(InOutItemEnum.DAMAGE_OUT.value());
|
||||||
entity.setSubTotal(NumberUtil.mul(param.getNumber(), consInfo.getPrice()));
|
entity.setSubTotal(NumberUtil.mul(inOutNumber, consInfo.getPrice()));
|
||||||
entity.setImgUrls(JSON.toJSONString(param.getImgUrls()));
|
entity.setImgUrls(JSON.toJSONString(param.getImgUrls()));
|
||||||
entity.setRemark("【商品报损,自动报损相关耗材】" + StrUtil.nullToDefault(param.getRemark(), ""));
|
entity.setRemark("【商品报损,自动报损相关耗材】" + StrUtil.nullToDefault(param.getRemark(), ""));
|
||||||
consStockFlowMapper.insert(entity);
|
|
||||||
consStockFlowService.saveFlow(entity);
|
consStockFlowService.saveFlow(entity);
|
||||||
consInfo.setStockNumber(entity.getAfterNumber());
|
consInfo.setStockNumber(entity.getAfterNumber());
|
||||||
UpdateChain.of(ConsInfo.class)
|
UpdateChain.of(ConsInfo.class)
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
t2.con_unit,
|
t2.con_unit,
|
||||||
t2.con_name,
|
t2.con_name,
|
||||||
t2.price,
|
t2.price,
|
||||||
t2.stock_number
|
t2.stock_number,
|
||||||
|
t1.surplus_stock
|
||||||
FROM tb_prod_cons_relation t1
|
FROM tb_prod_cons_relation t1
|
||||||
LEFT JOIN tb_cons_info t2 on t1.cons_info_id = t2.id
|
LEFT JOIN tb_cons_info t2 on t1.cons_info_id = t2.id
|
||||||
WHERE t1.product_id = #{prodId}
|
WHERE t1.product_id = #{prodId}
|
||||||
|
|||||||
Reference in New Issue
Block a user