mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
fix:auth配置错误修复
This commit is contained in:
parent
905d21999c
commit
1ebd8ba99e
@ -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<OmsOrderItem> orderItems = orderItemService.getByOrderId(orderId);
|
||||
List<InventoryDTO> 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);
|
||||
|
@ -73,7 +73,7 @@ public class OrderPayServiceImpl extends ServiceImpl<OrderPayMapper, OmsOrderPay
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
inventoryFeignService.minusInventory(inventoryList);
|
||||
inventoryFeignService.deductStock(inventoryList);
|
||||
|
||||
// 添加订单支付记录
|
||||
OmsOrderPay orderPay = OmsOrderPay.builder()
|
||||
|
@ -15,9 +15,9 @@ import com.youlai.common.web.exception.BizException;
|
||||
import com.youlai.common.web.util.BeanMapperUtils;
|
||||
import com.youlai.common.web.util.RequestUtils;
|
||||
import com.youlai.mall.oms.constant.OmsConstants;
|
||||
import com.youlai.mall.oms.mapper.OrderMapper;
|
||||
import com.youlai.mall.oms.enums.OrderStatusEnum;
|
||||
import com.youlai.mall.oms.enums.OrderTypeEnum;
|
||||
import com.youlai.mall.oms.mapper.OrderMapper;
|
||||
import com.youlai.mall.oms.pojo.bo.app.OrderBO;
|
||||
import com.youlai.mall.oms.pojo.domain.OmsOrder;
|
||||
import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery;
|
||||
@ -33,13 +33,10 @@ import com.youlai.mall.pms.pojo.dto.SkuDTO;
|
||||
import com.youlai.mall.ums.api.app.UmsAddressFeignService;
|
||||
import com.youlai.mall.ums.api.app.UmsMemberFeignService;
|
||||
import com.youlai.mall.ums.pojo.domain.UmsAddress;
|
||||
import io.netty.util.concurrent.CompleteFuture;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -279,7 +276,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> 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("下单失败,锁定库存错误");
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -27,18 +27,18 @@ public interface PmsSkuFeignService {
|
||||
/**
|
||||
* 锁定库存
|
||||
*/
|
||||
@PutMapping("/api.app/v1/skus/batch/lock_inventory")
|
||||
Result lockInventory(@RequestBody List<InventoryDTO> list);
|
||||
@PutMapping("/api.app/v1/skus/batch/lock_stock")
|
||||
Result lockStock(@RequestBody List<InventoryDTO> list);
|
||||
|
||||
/**
|
||||
* 解锁库存
|
||||
*/
|
||||
@PutMapping("/api.app/v1/skus/batch/unlock_inventory")
|
||||
Result<Boolean> unlockInventory(@RequestBody List<InventoryDTO> list);
|
||||
@PutMapping("/api.app/v1/skus/batch/unlock_stock")
|
||||
Result<Boolean> unlockStock(@RequestBody List<InventoryDTO> list);
|
||||
|
||||
|
||||
@PutMapping("/api.app/v1/skus/batch/minus_inventory")
|
||||
Result minusInventory(@RequestBody List<InventoryDTO> list);
|
||||
@PutMapping("/api.app/v1/skus/batch/deduct_stock")
|
||||
Result deductStock(@RequestBody List<InventoryDTO> list);
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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:";
|
||||
|
||||
}
|
||||
|
@ -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<Integer> getInventoryById(@PathVariable Long id) {
|
||||
Integer inventory = iPmsSkuService.getInventoryById(id);
|
||||
return Result.success(inventory);
|
||||
@GetMapping("/{id}/stock")
|
||||
public Result<Integer> 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<Boolean> lockInventory(@RequestBody List<InventoryDTO> list) {
|
||||
boolean result = iPmsSkuService.lockInventory(list);
|
||||
@PutMapping("/batch/lock_stock")
|
||||
public Result<Boolean> lockStock(@RequestBody List<InventoryDTO> 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<Boolean> unlockInventory(@RequestBody List<InventoryDTO> list) {
|
||||
boolean result = iPmsSkuService.unlockInventory(list);
|
||||
@PutMapping("/batch/unlock_stock")
|
||||
public Result<Boolean> unlockStock(@RequestBody List<InventoryDTO> 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<Boolean> minusInventory(@RequestBody List<InventoryDTO> list) {
|
||||
boolean result = iPmsSkuService.minusInventory(list);
|
||||
@PutMapping("/batch/deduct_stock")
|
||||
public Result<Boolean> deductStock(@RequestBody List<InventoryDTO> 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
|
||||
|
@ -13,7 +13,7 @@ public class InventoryListener {
|
||||
/**
|
||||
* 支付成功减库存
|
||||
*/
|
||||
public void minusInventory(){
|
||||
public void deductStock(){
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public interface PmsSkuMapper extends BaseMapper<PmsSku> {
|
||||
" 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,",
|
||||
|
@ -14,14 +14,14 @@ public interface IPmsSkuService extends IService<PmsSku> {
|
||||
* @param list
|
||||
* @return 库存锁定结果
|
||||
*/
|
||||
boolean lockInventory(List<InventoryDTO> list);
|
||||
boolean lockStock(List<InventoryDTO> list);
|
||||
|
||||
/**
|
||||
* 解锁库存
|
||||
* @param list
|
||||
* @return 解锁库存结果
|
||||
*/
|
||||
boolean unlockInventory(List<InventoryDTO> list);
|
||||
boolean unlockStock(List<InventoryDTO> list);
|
||||
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ public interface IPmsSkuService extends IService<PmsSku> {
|
||||
* @param id 库存ID
|
||||
* @return
|
||||
*/
|
||||
Integer getInventoryById(Long id);
|
||||
Integer getStockById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
@ -39,5 +39,5 @@ public interface IPmsSkuService extends IService<PmsSku> {
|
||||
*/
|
||||
List<SkuDTO> listBySkuIds(List<Long> ids);
|
||||
|
||||
boolean minusInventory(List<InventoryDTO> list);
|
||||
boolean deductStock(List<InventoryDTO> list);
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ public class PmsSkuServiceImpl extends ServiceImpl<PmsSkuMapper, PmsSku> impleme
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean lockInventory(List<InventoryDTO> inventories) {
|
||||
public boolean lockStock(List<InventoryDTO> inventories) {
|
||||
log.info("锁定库存: {}", inventories);
|
||||
|
||||
inventories.forEach(item -> {
|
||||
boolean result = this.update(new LambdaUpdateWrapper<PmsSku>()
|
||||
.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<PmsSkuMapper, PmsSku> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unlockInventory(List<InventoryDTO> inventories) {
|
||||
public boolean unlockStock(List<InventoryDTO> inventories) {
|
||||
inventories.forEach(item -> {
|
||||
boolean result = this.update(new LambdaUpdateWrapper<PmsSku>()
|
||||
.eq(PmsSku::getId, item.getSkuId())
|
||||
@ -62,12 +62,12 @@ public class PmsSkuServiceImpl extends ServiceImpl<PmsSkuMapper, PmsSku> impleme
|
||||
|
||||
|
||||
@Override
|
||||
public boolean minusInventory(List<InventoryDTO> inventories) {
|
||||
public boolean deductStock(List<InventoryDTO> inventories) {
|
||||
inventories.forEach(item -> {
|
||||
boolean result = this.update(new LambdaUpdateWrapper<PmsSku>()
|
||||
.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<PmsSkuMapper, PmsSku> 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<PmsSkuMapper, PmsSku> 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;
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ public interface UmsUserMapper extends BaseMapper<UmsMember> {
|
||||
|
||||
|
||||
@Select("<script>" +
|
||||
" SELECT * from ums_user " +
|
||||
" SELECT * from ums_member " +
|
||||
" <if test ='user.nickname !=null and user.nickname.trim() neq \"\" ' >" +
|
||||
" AND nickname like concat('%',#{user.nickname},'%')" +
|
||||
" </if>" +
|
||||
|
@ -9,8 +9,5 @@ spring:
|
||||
discovery:
|
||||
server-addr: http://localhost:8848
|
||||
config:
|
||||
# docker启动nacos-server需要配置
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
file-extension: yaml
|
||||
group: DEFAULT_GROUP
|
||||
prefix: ${spring.application.name}
|
||||
|
@ -10,9 +10,6 @@ spring:
|
||||
server-addr: http://c.youlai.store:8848
|
||||
namespace: prod_namespace_id
|
||||
config:
|
||||
# docker启动nacos-server需要配置
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
file-extension: yaml
|
||||
group: DEFAULT_GROUP
|
||||
prefix: ${spring.application.name}
|
||||
namespace: prod_namespace_id
|
||||
|
@ -13,5 +13,3 @@ spring:
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
file-extension: yaml
|
||||
group: DEFAULT_GROUP
|
||||
prefix: ${spring.application.name}
|
||||
|
||||
|
@ -13,5 +13,4 @@ spring:
|
||||
# docker启动nacos-server需要配置
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
file-extension: yaml
|
||||
prefix: ${spring.application.name}
|
||||
namespace: prod_namespace_id
|
||||
|
Loading…
Reference in New Issue
Block a user