耗材 开关
This commit is contained in:
@@ -164,6 +164,22 @@ public class ConsInfoController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款退回开关
|
||||||
|
*
|
||||||
|
* @param id 耗材信息id
|
||||||
|
*/
|
||||||
|
@PostMapping("onOffIsRefundStock")
|
||||||
|
@OperationLog("耗材信息-退款退回开关")
|
||||||
|
//@SaAdminCheckPermission("consInfo:on-off")
|
||||||
|
public CzgResult<Void> onOffIsRefundStock(@RequestParam Long id, @RequestParam Integer isRefundStockConsInfo) {
|
||||||
|
//效验数据
|
||||||
|
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||||
|
AssertUtil.isNull(isRefundStockConsInfo, "退款退回开关值不能为空");
|
||||||
|
consInfoService.isRefundStockConsInfo(id, isRefundStockConsInfo);
|
||||||
|
return CzgResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑副单位
|
* 编辑副单位
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ public class ConsInfoDTO implements Serializable {
|
|||||||
* 是否检测耗材: 1 检测 0 不检测
|
* 是否检测耗材: 1 检测 0 不检测
|
||||||
*/
|
*/
|
||||||
private Integer isStock;
|
private Integer isStock;
|
||||||
|
/**
|
||||||
|
* 是否退款退回: 1 退回 0 不退回
|
||||||
|
*/
|
||||||
|
private Integer isRefundStock;
|
||||||
/**
|
/**
|
||||||
* 第二单位
|
* 第二单位
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ public class ConsInfo implements Serializable {
|
|||||||
* 是否检测耗材: 1 检测 0 不检测
|
* 是否检测耗材: 1 检测 0 不检测
|
||||||
*/
|
*/
|
||||||
private Integer isStock;
|
private Integer isStock;
|
||||||
|
/**
|
||||||
|
* 是否退款退回: 1 退回 0 不退回
|
||||||
|
*/
|
||||||
|
private Integer isRefundStock;
|
||||||
/**
|
/**
|
||||||
* 第二单位
|
* 第二单位
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ public interface ConsInfoService extends IService<ConsInfo> {
|
|||||||
*/
|
*/
|
||||||
void onOffConsInfo(Long id, Integer isStock);
|
void onOffConsInfo(Long id, Integer isStock);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否退款退回
|
||||||
|
*/
|
||||||
|
void isRefundStockConsInfo(Long id, Integer isRefundStock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改耗材单位
|
* 修改耗材单位
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -176,6 +176,14 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
|||||||
super.updateById(entity);
|
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
|
@Override
|
||||||
public void modifySubUnit(ConsSubUnitParam param) {
|
public void modifySubUnit(ConsSubUnitParam param) {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
|||||||
if (product == null) {
|
if (product == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 商品未开启库存
|
// 商品开启库存
|
||||||
if (product.getIsStock() == SystemConstants.OneZero.ONE) {
|
if (product.getIsStock() == SystemConstants.OneZero.ONE) {
|
||||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "sub", dto.getNum());
|
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "sub", dto.getNum());
|
||||||
// 记录商品库存流水
|
// 记录商品库存流水
|
||||||
@@ -112,13 +112,13 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
|||||||
Long consInfoId = prodConsRelation.getConsInfoId();
|
Long consInfoId = prodConsRelation.getConsInfoId();
|
||||||
// 耗材消耗数量
|
// 耗材消耗数量
|
||||||
BigDecimal surplusStock = prodConsRelation.getSurplusStock();
|
BigDecimal surplusStock = prodConsRelation.getSurplusStock();
|
||||||
if (surplusStock == null) {
|
if (surplusStock == null || surplusStock.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 实际消耗数量 = 耗材消耗数量 * 商品购买数量
|
// 实际消耗数量 = 耗材消耗数量 * 商品购买数量
|
||||||
surplusStock = NumberUtil.mul(surplusStock, dto.getNum());
|
surplusStock = NumberUtil.mul(surplusStock, dto.getNum());
|
||||||
ConsInfo consInfo = consInfoMapper.selectOneById(consInfoId);
|
ConsInfo consInfo = consInfoMapper.selectOneById(consInfoId);
|
||||||
if (consInfo == null) {
|
if (consInfo == null || consInfo.getIsStock() == SystemConstants.OneZero.ZERO) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BigDecimal stockNumber = consInfo.getStockNumber();
|
BigDecimal stockNumber = consInfo.getStockNumber();
|
||||||
@@ -239,43 +239,33 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
|||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info(">>>>>>>>>>>>>>>>>:入参1:{}", list.size());
|
|
||||||
boolean isLowWarnLine = false;
|
boolean isLowWarnLine = false;
|
||||||
for (ProductStockSubtractDTO dto : list) {
|
for (ProductStockSubtractDTO dto : list) {
|
||||||
Product product = productMapper.selectOneById(dto.getProductId());
|
Product product = productMapper.selectOneById(dto.getProductId());
|
||||||
log.info(">>>>>>>>>>>>>>>>>:入参2:{}", product.getName());
|
|
||||||
// 商品是否允许退款退货时归还库存
|
// 商品是否允许退款退货时归还库存
|
||||||
if (SystemConstants.OneZero.ZERO == product.getIsRefundStock()) {
|
if (SystemConstants.OneZero.ONE == product.getIsRefundStock() && SystemConstants.OneZero.ONE == product.getIsStock()) {
|
||||||
continue;
|
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "add", dto.getNum());
|
||||||
}
|
// 记录商品库存流水
|
||||||
// 商品未开启库存
|
ProductStockFlow flow = new ProductStockFlow();
|
||||||
if (SystemConstants.OneZero.ZERO == product.getIsStock()) {
|
flow.setCreateUserId(1L);
|
||||||
continue;
|
flow.setCreateUserName("银收客");
|
||||||
}
|
flow.setShopId(shopId);
|
||||||
log.info(">>>>>>>>>>>>>>>>>:入参3:{}", product.getName());
|
flow.setProductId(product.getId());
|
||||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "add", dto.getNum());
|
flow.setProductName(product.getName());
|
||||||
// 记录商品库存流水
|
flow.setBeforeNumber(NumberUtil.toBigDecimal(product.getStockNumber()));
|
||||||
ProductStockFlow flow = new ProductStockFlow();
|
flow.setInOutNumber(NumberUtil.toBigDecimal(dto.getNum()));
|
||||||
flow.setCreateUserId(1L);
|
flow.setAfterNumber(NumberUtil.add(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
|
||||||
flow.setCreateUserName("银收客");
|
flow.setInOutType(InOutTypeEnum.OUT.value());
|
||||||
flow.setShopId(shopId);
|
flow.setInOutItem(InOutItemEnum.ORDER_OUT.value());
|
||||||
flow.setProductId(product.getId());
|
flow.setRemark("红冲订单取消/退菜/退单消耗的库存");
|
||||||
flow.setProductName(product.getName());
|
flow.setOrderId(orderId);
|
||||||
flow.setBeforeNumber(NumberUtil.toBigDecimal(product.getStockNumber()));
|
productStockFlowService.saveFlow(flow);
|
||||||
flow.setInOutNumber(NumberUtil.toBigDecimal(dto.getNum()));
|
// String key = StrUtil.format(SHOP_PRODUCT_STOCK, shopId, product.getId());
|
||||||
flow.setAfterNumber(NumberUtil.add(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
|
refreshRedisProdStock(shopId, product.getId(), flow.getAfterNumber());
|
||||||
flow.setInOutType(InOutTypeEnum.OUT.value());
|
Integer warnLine = ObjUtil.defaultIfNull(product.getWarnLine(), 10);
|
||||||
flow.setInOutItem(InOutItemEnum.ORDER_OUT.value());
|
if (!isLowWarnLine && (NumberUtil.isLessOrEqual(flow.getBeforeNumber(), BigDecimal.ZERO) || NumberUtil.isLess(flow.getAfterNumber(), Convert.toBigDecimal(warnLine)))) {
|
||||||
flow.setRemark("红冲订单取消/退菜/退单消耗的库存");
|
isLowWarnLine = true;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
// 查询商品绑定耗材信息
|
// 查询商品绑定耗材信息
|
||||||
List<ProdConsRelation> relationList = prodConsRelationMapper.selectListByQuery(QueryWrapper.create().eq(ProdConsRelation::getProductId, dto.getProductId()));
|
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();
|
Long consInfoId = prodConsRelation.getConsInfoId();
|
||||||
// 耗材消耗数量
|
// 耗材消耗数量
|
||||||
BigDecimal surplusStock = prodConsRelation.getSurplusStock();
|
BigDecimal surplusStock = prodConsRelation.getSurplusStock();
|
||||||
if (surplusStock == null) {
|
if (surplusStock == null || surplusStock.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 实际消耗数量 = 耗材消耗数量 * 商品购买数量
|
// 实际消耗数量 = 耗材消耗数量 * 商品购买数量
|
||||||
surplusStock = NumberUtil.mul(surplusStock, dto.getNum());
|
surplusStock = NumberUtil.mul(surplusStock, dto.getNum());
|
||||||
ConsInfo consInfo = consInfoMapper.selectOneById(consInfoId);
|
ConsInfo consInfo = consInfoMapper.selectOneById(consInfoId);
|
||||||
if (consInfo == null) {
|
if (consInfo == null || consInfo.getIsStock() == SystemConstants.OneZero.ZERO || consInfo.getIsRefundStock() == SystemConstants.OneZero.ZERO) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BigDecimal stockNumber = consInfo.getStockNumber();
|
BigDecimal stockNumber = consInfo.getStockNumber();
|
||||||
|
|||||||
Reference in New Issue
Block a user