update:
1.fix
This commit is contained in:
@@ -35,8 +35,10 @@ import org.springblade.core.redis.ratelimiter.RateLimiter;
|
||||
import org.springblade.core.tool.sensitive.SensitiveUtil;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.modules.api.vo.*;
|
||||
import org.springblade.modules.common.eums.OrderStatus;
|
||||
import org.springblade.modules.market.eums.*;
|
||||
import org.springblade.modules.market.mapper.MerchantInventoryMapper;
|
||||
import org.springblade.modules.market.mapper.MerchantOrderMapper;
|
||||
import org.springblade.modules.market.pojo.dto.MarketBenefitPointApiDTO;
|
||||
import org.springblade.modules.market.pojo.dto.MarketCashCouponApiDTO;
|
||||
import org.springblade.modules.market.pojo.entity.*;
|
||||
@@ -77,6 +79,8 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
||||
|
||||
private final IMerchantStoreFavoriteService favoriteService;
|
||||
|
||||
private final MerchantOrderMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public IPage<MerchantInventoryVO> selectProductInventoryPage(IPage<MerchantInventoryVO> page, MerchantInventoryVO inventory) {
|
||||
return page.setRecords(baseMapper.selectProductInventoryPage(page, inventory));
|
||||
@@ -189,8 +193,6 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
||||
@RateLimiter(value = "inventory:limiter", param = "#userId", max = 1, ttl = 10, timeUnit = TimeUnit.SECONDS)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean unlist(Long userId, Long productId) {
|
||||
//todo: 检查是否有未完成的订单,考虑如有未完成的订单则不予下架
|
||||
|
||||
if (Objects.isNull(userId) || Objects.isNull(productId)) {
|
||||
throw new ServiceException("无效参数");
|
||||
}
|
||||
@@ -205,9 +207,14 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
||||
throw new ServiceException("商品不存在");
|
||||
}
|
||||
|
||||
if(orderMapper.exists(Wrappers.lambdaQuery(MerchantOrderEntity.class).eq(MerchantOrderEntity::getInventoryId, inventory).notIn(MerchantOrderEntity::getStatus, List.of(OrderStatus.COMPLETED.getCode(),OrderStatus.CANCELLED.getCode())))){
|
||||
throw new ServiceException("当前商品有为完成订单,无法进行下架操作");
|
||||
}
|
||||
|
||||
if (baseMapper.unlistInventory(inventory.getId(), inventory.getStock(), userId, inventory.getVersion()) < 1) {
|
||||
throw new ServiceException("下架失败");
|
||||
}
|
||||
|
||||
if (inventory.getStock() > 0) {
|
||||
MerchantProductType inventoryType = MerchantProductType.fromCode(inventory.getType());
|
||||
MerchantCatalogEntity catalog = catalogService.getById(inventory.getProductId());
|
||||
|
||||
Reference in New Issue
Block a user