diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/HardDoorFlowServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/HardDoorFlowServiceImpl.java index d329ca222..4e19e253e 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/HardDoorFlowServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/HardDoorFlowServiceImpl.java @@ -12,6 +12,7 @@ import com.bsd.pjcloud.hard.api.constant.HardDoorFlowEnum; import com.bsd.pjcloud.hard.api.constant.HardDoorOpenTypeEnum; import com.bsd.pjcloud.hard.api.dto.HardDoorFlowOpenDto; import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto; +import com.bsd.pjcloud.hard.api.entity.HardAuthEntity; import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity; import com.bsd.pjcloud.hard.api.entity.manager.HardDoorManagerEntity; import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; @@ -51,11 +52,9 @@ public class HardDoorFlowServiceImpl extends ServiceImpl carList = hardCarService.getByParentCarId(order.getParentCarId()); + if (ObjectUtil.isEmpty(carList)) throw new RuntimeException("扣减库存错误,购物车不存在"); + List list = carList.stream().map(v -> { + DeductionSpuStockDto entity = new DeductionSpuStockDto(); + entity.setHardSpuId(v.getProductId()); + entity.setIncrCount(v.getProductCount()); + return entity; + }).toList(); + Boolean isDeduction = hardSpuService.deductionSpuStock(list); + if (!isDeduction) { + log.info("|{}|{},失败,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(list)); + throw new RuntimeException("扣减智能柜库存" + CarErrorMsg + "错误"); + } + log.info("扣减智能柜库存成功|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(list)); + return; } } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/spu/HardSpuServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/spu/HardSpuServiceImpl.java index 0c3492a59..62bd3e727 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/spu/HardSpuServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/spu/HardSpuServiceImpl.java @@ -234,7 +234,11 @@ public class HardSpuServiceImpl extends ServiceImpl list) { if (ObjectUtil.isEmpty(list)) { log.error("|{}|扣减商品库存失败list为空", TAG); @@ -249,14 +253,16 @@ public class HardSpuServiceImpl extends ServiceImpl updateList = new ArrayList<>(); for (HardSpuEntity i : hardSpuList) { list.stream().filter(j -> ObjectUtil.equals(i.getId(), j.getHardSpuId())).findFirst().ifPresent(hardSpu -> { - if(ObjectUtil.isNotEmpty(hardSpu.getIncrCount())){ + if (ObjectUtil.isNotEmpty(hardSpu.getIncrCount())) { HardSpuEntity entity = new HardSpuEntity(); entity.setId(hardSpu.getHardSpuId()); entity.setRepertoryCount(i.getRepertoryCount() - hardSpu.getIncrCount()); + updateList.add(entity); } }); } - return null; + baseMapper.updateById(updateList); + return true; } public boolean asyncAllGroup(KsBarcodeLikeDto likeDto) {