耗材 开关
This commit is contained in:
@@ -176,6 +176,14 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
||||
super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isRefundStockConsInfo(Long id, Integer isRefundStock) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
ConsInfo entity = super.getOne(query().eq(ConsInfo::getId, id).eq(ConsInfo::getShopId, shopId));
|
||||
entity.setIsRefundStock(isRefundStock);
|
||||
super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifySubUnit(ConsSubUnitParam param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||
if (product == null) {
|
||||
continue;
|
||||
}
|
||||
// 商品未开启库存
|
||||
// 商品开启库存
|
||||
if (product.getIsStock() == SystemConstants.OneZero.ONE) {
|
||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "sub", dto.getNum());
|
||||
// 记录商品库存流水
|
||||
@@ -112,13 +112,13 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||
Long consInfoId = prodConsRelation.getConsInfoId();
|
||||
// 耗材消耗数量
|
||||
BigDecimal surplusStock = prodConsRelation.getSurplusStock();
|
||||
if (surplusStock == null) {
|
||||
if (surplusStock == null || surplusStock.compareTo(BigDecimal.ZERO) == 0) {
|
||||
continue;
|
||||
}
|
||||
// 实际消耗数量 = 耗材消耗数量 * 商品购买数量
|
||||
surplusStock = NumberUtil.mul(surplusStock, dto.getNum());
|
||||
ConsInfo consInfo = consInfoMapper.selectOneById(consInfoId);
|
||||
if (consInfo == null) {
|
||||
if (consInfo == null || consInfo.getIsStock() == SystemConstants.OneZero.ZERO) {
|
||||
continue;
|
||||
}
|
||||
BigDecimal stockNumber = consInfo.getStockNumber();
|
||||
@@ -239,43 +239,33 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
log.info(">>>>>>>>>>>>>>>>>:入参1:{}", list.size());
|
||||
boolean isLowWarnLine = false;
|
||||
for (ProductStockSubtractDTO dto : list) {
|
||||
Product product = productMapper.selectOneById(dto.getProductId());
|
||||
log.info(">>>>>>>>>>>>>>>>>:入参2:{}", product.getName());
|
||||
// 商品是否允许退款退货时归还库存
|
||||
if (SystemConstants.OneZero.ZERO == product.getIsRefundStock()) {
|
||||
continue;
|
||||
}
|
||||
// 商品未开启库存
|
||||
if (SystemConstants.OneZero.ZERO == product.getIsStock()) {
|
||||
continue;
|
||||
}
|
||||
log.info(">>>>>>>>>>>>>>>>>:入参3:{}", product.getName());
|
||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "add", dto.getNum());
|
||||
// 记录商品库存流水
|
||||
ProductStockFlow flow = new ProductStockFlow();
|
||||
flow.setCreateUserId(1L);
|
||||
flow.setCreateUserName("银收客");
|
||||
flow.setShopId(shopId);
|
||||
flow.setProductId(product.getId());
|
||||
flow.setProductName(product.getName());
|
||||
flow.setBeforeNumber(NumberUtil.toBigDecimal(product.getStockNumber()));
|
||||
flow.setInOutNumber(NumberUtil.toBigDecimal(dto.getNum()));
|
||||
flow.setAfterNumber(NumberUtil.add(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setInOutType(InOutTypeEnum.OUT.value());
|
||||
flow.setInOutItem(InOutItemEnum.ORDER_OUT.value());
|
||||
flow.setRemark("红冲订单取消/退菜/退单消耗的库存");
|
||||
flow.setOrderId(orderId);
|
||||
productStockFlowService.saveFlow(flow);
|
||||
String key = StrUtil.format(SHOP_PRODUCT_STOCK, shopId, product.getId());
|
||||
log.info(">>>>>>>>>>>>>>>>>:入参4:{}", redisService.get(key));
|
||||
refreshRedisProdStock(shopId, product.getId(), flow.getAfterNumber());
|
||||
log.info(">>>>>>>>>>>>>>>>>:入参5:{}", redisService.get(key));
|
||||
Integer warnLine = ObjUtil.defaultIfNull(product.getWarnLine(), 10);
|
||||
if (!isLowWarnLine && (NumberUtil.isLessOrEqual(flow.getBeforeNumber(), BigDecimal.ZERO) || NumberUtil.isLess(flow.getAfterNumber(), Convert.toBigDecimal(warnLine)))) {
|
||||
isLowWarnLine = true;
|
||||
if (SystemConstants.OneZero.ONE == product.getIsRefundStock() && SystemConstants.OneZero.ONE == product.getIsStock()) {
|
||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "add", dto.getNum());
|
||||
// 记录商品库存流水
|
||||
ProductStockFlow flow = new ProductStockFlow();
|
||||
flow.setCreateUserId(1L);
|
||||
flow.setCreateUserName("银收客");
|
||||
flow.setShopId(shopId);
|
||||
flow.setProductId(product.getId());
|
||||
flow.setProductName(product.getName());
|
||||
flow.setBeforeNumber(NumberUtil.toBigDecimal(product.getStockNumber()));
|
||||
flow.setInOutNumber(NumberUtil.toBigDecimal(dto.getNum()));
|
||||
flow.setAfterNumber(NumberUtil.add(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setInOutType(InOutTypeEnum.OUT.value());
|
||||
flow.setInOutItem(InOutItemEnum.ORDER_OUT.value());
|
||||
flow.setRemark("红冲订单取消/退菜/退单消耗的库存");
|
||||
flow.setOrderId(orderId);
|
||||
productStockFlowService.saveFlow(flow);
|
||||
// String key = StrUtil.format(SHOP_PRODUCT_STOCK, shopId, product.getId());
|
||||
refreshRedisProdStock(shopId, product.getId(), flow.getAfterNumber());
|
||||
Integer warnLine = ObjUtil.defaultIfNull(product.getWarnLine(), 10);
|
||||
if (!isLowWarnLine && (NumberUtil.isLessOrEqual(flow.getBeforeNumber(), BigDecimal.ZERO) || NumberUtil.isLess(flow.getAfterNumber(), Convert.toBigDecimal(warnLine)))) {
|
||||
isLowWarnLine = true;
|
||||
}
|
||||
}
|
||||
// 查询商品绑定耗材信息
|
||||
List<ProdConsRelation> relationList = prodConsRelationMapper.selectListByQuery(QueryWrapper.create().eq(ProdConsRelation::getProductId, dto.getProductId()));
|
||||
@@ -287,13 +277,13 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||
Long consInfoId = prodConsRelation.getConsInfoId();
|
||||
// 耗材消耗数量
|
||||
BigDecimal surplusStock = prodConsRelation.getSurplusStock();
|
||||
if (surplusStock == null) {
|
||||
if (surplusStock == null || surplusStock.compareTo(BigDecimal.ZERO) == 0) {
|
||||
continue;
|
||||
}
|
||||
// 实际消耗数量 = 耗材消耗数量 * 商品购买数量
|
||||
surplusStock = NumberUtil.mul(surplusStock, dto.getNum());
|
||||
ConsInfo consInfo = consInfoMapper.selectOneById(consInfoId);
|
||||
if (consInfo == null) {
|
||||
if (consInfo == null || consInfo.getIsStock() == SystemConstants.OneZero.ZERO || consInfo.getIsRefundStock() == SystemConstants.OneZero.ZERO) {
|
||||
continue;
|
||||
}
|
||||
BigDecimal stockNumber = consInfo.getStockNumber();
|
||||
|
||||
Reference in New Issue
Block a user