no message
This commit is contained in:
parent
28c5d34acf
commit
5a172360bc
|
|
@ -727,6 +727,28 @@ public class OrderController extends BaseController {
|
|||
// 所有商品
|
||||
List<GoodsStandard> goodsList = goodsStandardService.selectByIds(goodsStandardIds);
|
||||
logger.info("商品信息{}", goodsList);
|
||||
|
||||
// 扣减库存
|
||||
Map<Long, GoodsStandard> goodsStandardMap = goodsList.stream()
|
||||
.collect(Collectors.toMap(GoodsStandard::getGoodsStandardId, gs -> gs));
|
||||
for (AppGoodsRequest appGoods : appGoodsList) {
|
||||
GoodsStandard goodsStandard = goodsStandardMap.get(appGoods.getGoodsStandardId());
|
||||
if (goodsStandard != null && goodsStandard.getGoodsNum() != null) {
|
||||
// 记录扣减前的库存
|
||||
Integer oldStock = goodsStandard.getGoodsNum();
|
||||
// 扣减库存
|
||||
Integer newStock = oldStock - appGoods.getNum();
|
||||
if (newStock < 0) {
|
||||
logger.error("库存扣减异常,商品规格ID: {}, 当前库存: {}, 扣减数量: {}",
|
||||
appGoods.getGoodsStandardId(), oldStock, appGoods.getNum());
|
||||
return AjaxResult.error("库存不足,扣减失败!");
|
||||
}
|
||||
goodsStandard.setGoodsNum(newStock);
|
||||
goodsStandardService.update(goodsStandard);
|
||||
logger.info("商品规格ID: {} 库存扣减成功,扣减前: {}, 扣减数量: {}, 扣减后: {}",
|
||||
appGoods.getGoodsStandardId(), oldStock, appGoods.getNum(), newStock);
|
||||
}
|
||||
}
|
||||
// 商品所属师傅
|
||||
// 获取商品信息
|
||||
Goods goods = goodsService.selectById(goodsList.get(0).getGoodsId());
|
||||
|
|
@ -2177,7 +2199,7 @@ public class OrderController extends BaseController {
|
|||
|| master.getOrderStatus() == 4))
|
||||
&& master.getWorkerId() != null;
|
||||
|
||||
orderListResponse.setIsDeliveryToStore(1);
|
||||
orderListResponse.setIsDeliveryToStore(master.getIsDeliveryToStore());
|
||||
orderListResponse.setServiceShop(shopService.getShop(master.getServiceShopId()));
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue