diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/RabbitMQListener.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/RabbitMQListener.java index 45df3fb8f..3da8bbf82 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/RabbitMQListener.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/RabbitMQListener.java @@ -45,14 +45,14 @@ public class RabbitMQListener { try { if (orderService.closeOrder(orderId)) { // 如果关单成功,发送消息释放库存 - // rabbitTemplate.convertAndSend("product_event_change", "inventory:unlock", orderSn); + // rabbitTemplate.convertAndSend("product_event_change", "stock:unlock", orderSn); List orderItems = orderItemService.getByOrderId(orderId); List inventoryList = orderItems.stream().map(orderItem -> InventoryDTO.builder() .skuId(orderItem.getSkuId()) .count(orderItem.getSkuQuantity()) .build()) .collect(Collectors.toList()); - inventoryFeignService.unlockInventory(inventoryList); + inventoryFeignService.unlockStock(inventoryList); } else { // 如果关单失败,则订单可能已经被处理,直接手动ACK确认消息 channel.basicAck(message.getMessageProperties().getDeliveryTag(), true); diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderPayServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderPayServiceImpl.java index 68845e4f3..d12fef761 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderPayServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderPayServiceImpl.java @@ -73,7 +73,7 @@ public class OrderPayServiceImpl extends ServiceImpl impleme .build()) .collect(Collectors.toList()); - Result result = inventoryFeignService.lockInventory(items); + Result result = inventoryFeignService.lockStock(items); if (!StrUtil.equals(result.getCode(), ResultCode.SUCCESS.getCode())) { throw new BizException("下单失败,锁定库存错误"); } diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/admin/InventoryFeignService.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/admin/InventoryFeignService.java index 13e56862b..0a49f9ca2 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/admin/InventoryFeignService.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/admin/InventoryFeignService.java @@ -12,7 +12,7 @@ public interface InventoryFeignService { /** * 扣减库存 */ - @PostMapping("/api.app/v1/skus/{id}/inventory/_deduct") + @PostMapping("/api.app/v1/skus/{id}/stock/_deduct") Result deductInventory(@PathVariable Long id, @RequestParam Integer num); diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/PmsSkuFeignService.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/PmsSkuFeignService.java index e53b4730d..a81bd4c8b 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/PmsSkuFeignService.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/PmsSkuFeignService.java @@ -27,18 +27,18 @@ public interface PmsSkuFeignService { /** * 锁定库存 */ - @PutMapping("/api.app/v1/skus/batch/lock_inventory") - Result lockInventory(@RequestBody List list); + @PutMapping("/api.app/v1/skus/batch/lock_stock") + Result lockStock(@RequestBody List list); /** * 解锁库存 */ - @PutMapping("/api.app/v1/skus/batch/unlock_inventory") - Result unlockInventory(@RequestBody List list); + @PutMapping("/api.app/v1/skus/batch/unlock_stock") + Result unlockStock(@RequestBody List list); - @PutMapping("/api.app/v1/skus/batch/minus_inventory") - Result minusInventory(@RequestBody List list); + @PutMapping("/api.app/v1/skus/batch/deduct_stock") + Result deductStock(@RequestBody List list); } diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSku.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSku.java index cc9010fa6..6a37819a0 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSku.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSku.java @@ -16,7 +16,7 @@ public class PmsSku extends BaseEntity { private String pic; private Long originPrice; private Long price; - private Integer inventory; - private Integer lockedInventory; + private Integer stock; + private Integer lockedStock; private String specValueIds; } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/constant/PmsConstants.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/constant/PmsConstants.java index 90efcf42f..1dc981f32 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/constant/PmsConstants.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/constant/PmsConstants.java @@ -6,6 +6,6 @@ package com.youlai.mall.pms.common.constant; */ public interface PmsConstants { - String PRODUCT_INVENTORY_PREFIX = "pms:inventory:"; + String PRODUCT_INVENTORY_PREFIX = "pms:stock:"; } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java index 592ae8649..994fb8b7f 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java @@ -1,6 +1,5 @@ package com.youlai.mall.pms.controller.app; -import cn.hutool.core.bean.BeanUtil; import com.youlai.common.result.Result; import com.youlai.mall.pms.pojo.domain.PmsSku; import com.youlai.mall.pms.pojo.dto.SkuDTO; @@ -25,49 +24,46 @@ public class SkuController { @ApiOperation(value = "商品库存详情", httpMethod = "GET") @ApiImplicitParam(name = "id", value = "商品库存ID", required = true, paramType = "path", dataType = "Long") @GetMapping("/{id}") - public Result detail(@PathVariable Long id) { + public Result getById(@PathVariable Long id) { PmsSku sku = iPmsSkuService.getById(id); return Result.success(sku); } @ApiOperation("获取商品的库存数量") @ApiImplicitParam(name = "id", value = "商品库存ID", required = true, paramType = "path", dataType = "Long") - @GetMapping("/{id}/inventory") - public Result getInventoryById(@PathVariable Long id) { - Integer inventory = iPmsSkuService.getInventoryById(id); - return Result.success(inventory); + @GetMapping("/{id}/stock") + public Result getStockById(@PathVariable Long id) { + Integer stock = iPmsSkuService.getStockById(id); + return Result.success(stock); } @ApiOperation(value = "锁定库存", httpMethod = "PUT") @ApiImplicitParam(name = "list", value = "锁定库存", required = true, paramType = "body", dataType = "InventoryNumDTO") - @PutMapping("/batch/lock_inventory") - public Result lockInventory(@RequestBody List list) { - boolean result = iPmsSkuService.lockInventory(list); + @PutMapping("/batch/lock_stock") + public Result lockStock(@RequestBody List list) { + boolean result = iPmsSkuService.lockStock(list); return Result.judge(result); } @ApiOperation(value = "解锁库存", httpMethod = "PUT") @ApiImplicitParam(name = "list", value = "释放库存", required = true, paramType = "body", dataType = "InventoryNumDTO") - @PutMapping("/batch/unlock_inventory") - public Result unlockInventory(@RequestBody List list) { - boolean result = iPmsSkuService.unlockInventory(list); + @PutMapping("/batch/unlock_stock") + public Result unlockStock(@RequestBody List list) { + boolean result = iPmsSkuService.unlockStock(list); return Result.judge(result); } @ApiOperation(value = "扣减库存", httpMethod = "PUT") @ApiImplicitParam(name = "list", value = "释放库存", required = true, paramType = "body", dataType = "InventoryNumDTO") - @PutMapping("/batch/minus_inventory") - public Result minusInventory(@RequestBody List list) { - boolean result = iPmsSkuService.minusInventory(list); + @PutMapping("/batch/deduct_stock") + public Result deductStock(@RequestBody List list) { + boolean result = iPmsSkuService.deductStock(list); return Result.judge(result); } - - - @ApiOperation(value = "库存列表", httpMethod = "GET") @ApiImplicitParam(name = "skuIds", value = "库存ID集合", required = true, paramType = "body", dataType = "String") @GetMapping diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/listener/InventoryListener.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/listener/InventoryListener.java index 20e19dad3..f9181c8b0 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/listener/InventoryListener.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/listener/InventoryListener.java @@ -13,7 +13,7 @@ public class InventoryListener { /** * 支付成功减库存 */ - public void minusInventory(){ + public void deductStock(){ } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSkuMapper.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSkuMapper.java index 967ef702a..90459d859 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSkuMapper.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSkuMapper.java @@ -26,7 +26,7 @@ public interface PmsSkuMapper extends BaseMapper { " t1.pic,", " t1.origin_price,", " t1.price price,", - " t1.inventory inventory,", + " t1.stock stock,", " t2.id spu_id,", " t2.NAME product_name,", " t2.pic product_pic,", diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSkuService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSkuService.java index 957a32121..3d13466cb 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSkuService.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSkuService.java @@ -14,14 +14,14 @@ public interface IPmsSkuService extends IService { * @param list * @return 库存锁定结果 */ - boolean lockInventory(List list); + boolean lockStock(List list); /** * 解锁库存 * @param list * @return 解锁库存结果 */ - boolean unlockInventory(List list); + boolean unlockStock(List list); /** @@ -29,7 +29,7 @@ public interface IPmsSkuService extends IService { * @param id 库存ID * @return */ - Integer getInventoryById(Long id); + Integer getStockById(Long id); /** @@ -39,5 +39,5 @@ public interface IPmsSkuService extends IService { */ List listBySkuIds(List ids); - boolean minusInventory(List list); + boolean deductStock(List list); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSkuServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSkuServiceImpl.java index 28cb8a44d..351bb1f08 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSkuServiceImpl.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSkuServiceImpl.java @@ -29,13 +29,13 @@ public class PmsSkuServiceImpl extends ServiceImpl impleme @Override @Transactional(rollbackFor = Exception.class) - public boolean lockInventory(List inventories) { + public boolean lockStock(List inventories) { log.info("锁定库存: {}", inventories); inventories.forEach(item -> { boolean result = this.update(new LambdaUpdateWrapper() .eq(PmsSku::getId, item.getSkuId()) - .apply("inventory >= locked_inventory + {0}", item.getCount()) + .apply("stock >= locked_inventory + {0}", item.getCount()) .setSql("locked_inventory = locked_inventory + " + item.getCount()) ); if (!result) { @@ -47,7 +47,7 @@ public class PmsSkuServiceImpl extends ServiceImpl impleme } @Override - public boolean unlockInventory(List inventories) { + public boolean unlockStock(List inventories) { inventories.forEach(item -> { boolean result = this.update(new LambdaUpdateWrapper() .eq(PmsSku::getId, item.getSkuId()) @@ -62,12 +62,12 @@ public class PmsSkuServiceImpl extends ServiceImpl impleme @Override - public boolean minusInventory(List inventories) { + public boolean deductStock(List inventories) { inventories.forEach(item -> { boolean result = this.update(new LambdaUpdateWrapper() .eq(PmsSku::getId, item.getSkuId()) .setSql("locked_inventory = locked_inventory - " + item.getCount()) - .setSql("inventory = inventory - " + item.getCount()) + .setSql("stock = stock - " + item.getCount()) ); if (!result) { throw new BizException("扣减库存失败"); @@ -86,13 +86,13 @@ public class PmsSkuServiceImpl extends ServiceImpl impleme * @return */ @Override - public Integer getInventoryById(Long id) { - Integer inventory = 0; + public Integer getStockById(Long id) { + Integer stock = 0; // 读->缓存 Object cacheVal = redisTemplate.opsForValue().get(PmsConstants.PRODUCT_INVENTORY_PREFIX + id); if (cacheVal != null) { - inventory = Convert.toInt(cacheVal); - return inventory; + stock = Convert.toInt(cacheVal); + return stock; } // 读->数据库 @@ -101,12 +101,12 @@ public class PmsSkuServiceImpl extends ServiceImpl impleme .select(PmsSku::getInventory)); if (pmsSku != null) { - inventory = pmsSku.getInventory(); + stock = pmsSku.getInventory(); // 写->缓存 - redisTemplate.opsForValue().set(PmsConstants.PRODUCT_INVENTORY_PREFIX + id, inventory); + redisTemplate.opsForValue().set(PmsConstants.PRODUCT_INVENTORY_PREFIX + id, stock); } - return inventory; + return stock; } diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsMemberFeignService.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsMemberFeignService.java index 4be0fdc0c..bdaa889c4 100644 --- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsMemberFeignService.java +++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsMemberFeignService.java @@ -29,7 +29,7 @@ public interface UmsMemberFeignService { /** * 修改会员积分 */ - @PutMapping("/api.admin/v1/members/{id}/point") + @PutMapping("/api.admin/v1/members/{id}/points") Result updatePoint(@PathVariable Long id, @RequestParam Integer num); /** diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/mapper/UmsUserMapper.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/mapper/UmsUserMapper.java index 591b435fc..eb5f3dee1 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/mapper/UmsUserMapper.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/mapper/UmsUserMapper.java @@ -17,7 +17,7 @@ public interface UmsUserMapper extends BaseMapper { @Select("