fix:退库存bug
This commit is contained in:
1 parent
7d038b41ef
commit
5f3bd682b9
1 file changed
+10
-5
+10
-5
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.service.impl.order;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
@@ -455,13 +456,13 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(order.getSysType());
|
||||
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
|
||||
if (!ObjectUtil.isAllNotEmpty(hardTypeEnum, orderTypeEnum)) return;
|
||||
String CarErrorMsg = ObjectUtil.equals(isReduce, YesNoEnum.YES.getCode()) ? "扣减库存错误" : "恢复库存错误";
|
||||
int base = ObjectUtil.equals(isReduce, YesNoEnum.YES.getCode()) ? -1 : 1;
|
||||
String CarErrorMsg = ObjectUtil.equals(isReduce, YesNoEnum.YES) ? "扣减库存" : "恢复库存";
|
||||
int base = ObjectUtil.equals(isReduce, YesNoEnum.YES) ? -1 : 1;
|
||||
// 食堂扣件库存
|
||||
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.CANTEEN) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.RESERVE)) {
|
||||
// 查询购物车
|
||||
List<HardCarEntity> carList = hardCarService.getByParentCarId(order.getParentCarId());
|
||||
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException(CarErrorMsg + ",购物车不存在");
|
||||
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException(CarErrorMsg + "错误,购物车不存在");
|
||||
CanteenSpuUpdateStockReqDTO dto = new CanteenSpuUpdateStockReqDTO();
|
||||
List<CanteenSpuUpdateStockReqDTO.Item> list = carList.stream().map(v -> {
|
||||
CanteenSpuUpdateStockReqDTO.Item item = new CanteenSpuUpdateStockReqDTO.Item();
|
||||
@@ -472,8 +473,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
dto.setItems(list);
|
||||
R updateSkuStockRes = onlineCanteenSpuService.updateSkuStock(dto);
|
||||
if (updateSkuStockRes.getCode() != 0) {
|
||||
throw new RuntimeException(CarErrorMsg);
|
||||
log.info("|{}|{},失败,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto));
|
||||
throw new RuntimeException(CarErrorMsg + "错误");
|
||||
}
|
||||
log.info("|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto));
|
||||
return;
|
||||
}
|
||||
// 超市扣家库存
|
||||
@@ -491,8 +494,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
dto.setItems(list);
|
||||
R updateSkuStockRes = supermarketSpuService.updateSpuStock(dto);
|
||||
if (updateSkuStockRes.getCode() != 0) {
|
||||
throw new RuntimeException(CarErrorMsg);
|
||||
log.info("|{}|{},失败,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto));
|
||||
throw new RuntimeException(CarErrorMsg + "错误");
|
||||
}
|
||||
log.info("|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user