1. 企业用户不限制产品目录数量,每个用户最多只能上架 5 产品
This commit is contained in:
2026-05-21 16:19:47 +08:00
parent 30fa56385c
commit 0cff78f029
4 changed files with 18 additions and 19 deletions

View File

@@ -84,7 +84,6 @@ public class MarketMerchantController {
} catch (RateLimiterException e) {
return R.fail("操作过于频繁,请稍后重试");
}
}
@GetMapping("/inventory-list")
@@ -137,6 +136,7 @@ public class MarketMerchantController {
}
}
@PostMapping("/publish-inventory")
@ApiOperationSupport(order = 12)
@Operation(summary = "上架商品")

View File

@@ -62,4 +62,5 @@ public interface IMerchantCatalogService extends BaseService<MerchantCatalogEnti
boolean increaseStock(Long id, Integer quantity);
boolean reduceStock(Long id, Integer quantity);
}

View File

@@ -29,7 +29,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.MarketInfoCache;
import org.springblade.common.cache.ParamCache;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.redis.ratelimiter.RateLimiter;
@@ -69,8 +68,6 @@ public class MerchantCatalogServiceImpl extends BaseServiceImpl<MerchantCatalogM
private final IMerchantCatalogOperateLogService operateLogService;
private static final String MERCHANT_CATALOG_QUANTITY_LIMIT = "merchant.catalog.quantity.limit";
@Override
public IPage<MerchantCatalogVO> selectMerchantCatalogPage(IPage<MerchantCatalogVO> page, MerchantCatalogVO catalogVO) {
return page.setRecords(baseMapper.selectMerchantCatalogPage(page, catalogVO));
@@ -126,18 +123,6 @@ public class MerchantCatalogServiceImpl extends BaseServiceImpl<MerchantCatalogM
throw new ServiceException("无效用户");
}
boolean isNew = (productId == null);
if (isNew) {
String limit = ParamCache.getValue(MERCHANT_CATALOG_QUANTITY_LIMIT);
if (StringUtil.isBlank(limit)) {
throw new ServiceException("系统配置异常:商品数量上限未设置");
}
long count = count(Wrappers.lambdaQuery(MerchantCatalogEntity.class).eq(MerchantCatalogEntity::getUserId, userId).eq(MerchantCatalogEntity::getIsDeleted, 0));
if (count >= Long.parseLong(limit)) {
throw new ServiceException("商品数量已经超过上限");
}
}
MerchantCatalogEntity entity = new MerchantCatalogEntity();
entity.setType(MerchantProductType.MERCHANT.getCode());
entity.setUserId(userId);
@@ -264,4 +249,5 @@ public class MerchantCatalogServiceImpl extends BaseServiceImpl<MerchantCatalogM
}
return true;
}
}

View File

@@ -29,6 +29,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.MarketInfoCache;
import org.springblade.common.cache.ParamCache;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.redis.ratelimiter.RateLimiter;
@@ -81,6 +82,9 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
private final MerchantOrderMapper orderMapper;
private static final String MERCHANT_CATALOG_QUANTITY_LIMIT = "merchant.catalog.quantity.limit";
@Override
public IPage<MerchantInventoryVO> selectProductInventoryPage(IPage<MerchantInventoryVO> page, MerchantInventoryVO inventory) {
return page.setRecords(baseMapper.selectProductInventoryPage(page, inventory));
@@ -109,7 +113,7 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
throw new IllegalArgumentException("无效数量");
}
MerchantCatalogEntity catalog = catalogService.getById(productId);
if (Objects.isNull(catalog)) {
if (Objects.isNull(catalog) || catalog.getIsDeleted() == 0) {
throw new ServiceException("无效商品");
}
@@ -256,7 +260,7 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
MerchantCatalogEntity catalog = catalogService.getById(productId);
if (Objects.isNull(catalog)) {
if (Objects.isNull(catalog) || catalog.getIsDeleted() == 0) {
throw new ServiceException("无效商品");
}
BigDecimal finalPrice = BigDecimal.ZERO;
@@ -271,6 +275,15 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
throw new ServiceException("请先绑定收款方式");
}
String limit = ParamCache.getValue(MERCHANT_CATALOG_QUANTITY_LIMIT);
if (StringUtil.isBlank(limit)) {
throw new ServiceException("系统配置异常:商品数量上限未设置");
}
long count = count(Wrappers.lambdaQuery(MerchantInventoryEntity.class).eq(MerchantInventoryEntity::getUserId, userId).eq(MerchantInventoryEntity::getStatus, MerchantProductStatus.ON_SHELF.getCode()).eq(MerchantInventoryEntity::getIsDeleted, 0));
if (count >= Long.parseLong(limit)) {
throw new ServiceException("上架的商品数量已经超过上限");
}
MerchantProductType currentType = MerchantProductType.fromCode(catalog.getType());
switch (currentType) {
case PLATFORM -> {
@@ -328,7 +341,6 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
}
inventory.setThumbImageUrl(catalog.getThumbImageUrl());
inventory.setGiftType(MerchantGiftType.BENEFIT_POINT.getCode());
}
inventory.setUnitPrice(finalPrice);
inventory.setUnitGiftAmount(giftAmount);