You've already forked FrameTour-BE
添加景区、删除子类型
This commit is contained in:
@@ -9,7 +9,7 @@ import com.ycwl.basic.pricing.mapper.PriceBundleConfigMapper;
|
||||
import com.ycwl.basic.pricing.service.IPriceBundleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -71,11 +71,18 @@ public class PriceBundleServiceImpl implements IPriceBundleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "active-bundles")
|
||||
// @Cacheable(value = "active-bundles")
|
||||
public List<PriceBundleConfig> getActiveBundles() {
|
||||
return bundleConfigMapper.selectActiveBundles();
|
||||
}
|
||||
|
||||
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||
|
||||
@Override
|
||||
public List<PriceBundleConfig> getAllBundlesForAdmin() {
|
||||
return bundleConfigMapper.selectAllBundlesForAdmin();
|
||||
}
|
||||
|
||||
private boolean isProductsMatchBundle(Set<String> productTypes, PriceBundleConfig bundle) {
|
||||
try {
|
||||
List<String> includedProducts = objectMapper.readValue(
|
||||
|
@@ -140,7 +140,7 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
|
||||
// 优先使用基于product_id的阶梯定价
|
||||
PriceTierConfig tierConfig = productConfigService.getTierConfig(
|
||||
productType.getCode(), productId, product.getProductSubType(), product.getQuantity());
|
||||
productType.getCode(), productId, product.getQuantity());
|
||||
|
||||
if (tierConfig != null) {
|
||||
log.debug("使用阶梯定价: productType={}, productId={}, quantity={}, price={}",
|
||||
@@ -186,7 +186,7 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
|
||||
// 优先使用基于product_id的阶梯定价
|
||||
PriceTierConfig tierConfig = productConfigService.getTierConfig(
|
||||
productType.getCode(), productId, product.getProductSubType(), product.getQuantity());
|
||||
productType.getCode(), productId, product.getQuantity());
|
||||
|
||||
if (tierConfig != null) {
|
||||
actualPrice = tierConfig.getPrice();
|
||||
|
@@ -104,4 +104,50 @@ public class PricingManagementServiceImpl implements IPricingManagementService {
|
||||
config.setUpdatedTime(LocalDateTime.now());
|
||||
return bundleConfigMapper.updateBundleConfig(config) > 0;
|
||||
}
|
||||
|
||||
// ==================== 状态管理 ====================
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateProductConfigStatus(Long id, Boolean isActive) {
|
||||
log.info("更新商品配置状态: id={}, isActive={}", id, isActive);
|
||||
return productConfigMapper.updateProductConfigStatus(id, isActive) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateTierConfigStatus(Long id, Boolean isActive) {
|
||||
log.info("更新阶梯配置状态: id={}, isActive={}", id, isActive);
|
||||
return tierConfigMapper.updateTierConfigStatus(id, isActive) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateBundleConfigStatus(Long id, Boolean isActive) {
|
||||
log.info("更新一口价配置状态: id={}, isActive={}", id, isActive);
|
||||
return bundleConfigMapper.updateBundleConfigStatus(id, isActive) > 0;
|
||||
}
|
||||
|
||||
// ==================== 删除操作 ====================
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deleteProductConfig(Long id) {
|
||||
log.info("删除商品配置: id={}", id);
|
||||
return productConfigMapper.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deleteTierConfig(Long id) {
|
||||
log.info("删除阶梯配置: id={}", id);
|
||||
return tierConfigMapper.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deleteBundleConfig(Long id) {
|
||||
log.info("删除一口价配置: id={}", id);
|
||||
return bundleConfigMapper.deleteById(id) > 0;
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@ import com.ycwl.basic.pricing.mapper.PriceTierConfigMapper;
|
||||
import com.ycwl.basic.pricing.service.IProductConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,13 +25,13 @@ public class ProductConfigServiceImpl implements IProductConfigService {
|
||||
private final PriceTierConfigMapper tierConfigMapper;
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "product-config", key = "#productType")
|
||||
// @Cacheable(value = "product-config", key = "#productType")
|
||||
public List<PriceProductConfig> getProductConfig(String productType) {
|
||||
return productConfigMapper.selectByProductType(productType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "product-config", key = "#productType + '_' + #productId")
|
||||
// @Cacheable(value = "product-config", key = "#productType + '_' + #productId")
|
||||
public PriceProductConfig getProductConfig(String productType, String productId) {
|
||||
PriceProductConfig config = productConfigMapper.selectByProductTypeAndId(productType, productId);
|
||||
if (config == null) {
|
||||
@@ -41,38 +41,59 @@ public class ProductConfigServiceImpl implements IProductConfigService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "tier-config", key = "#productType + '_' + #productId + '_' + (#productSubType ?: 'default') + '_' + #quantity")
|
||||
public PriceTierConfig getTierConfig(String productType, String productId, String productSubType, Integer quantity) {
|
||||
PriceTierConfig config = tierConfigMapper.selectByProductTypeAndQuantity(productType, productId, productSubType, quantity);
|
||||
// @Cacheable(value = "tier-config", key = "#productType + '_' + #productId + '_' + #quantity")
|
||||
public PriceTierConfig getTierConfig(String productType, String productId, Integer quantity) {
|
||||
PriceTierConfig config = tierConfigMapper.selectByProductTypeAndQuantity(productType, productId, quantity);
|
||||
if (config == null) {
|
||||
log.warn("阶梯定价配置未找到: productType={}, productId={}, productSubType={}, quantity={}",
|
||||
productType, productId, productSubType, quantity);
|
||||
log.warn("阶梯定价配置未找到: productType={}, productId={}, quantity={}",
|
||||
productType, productId, quantity);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public PriceTierConfig getTierConfig(String productType, String productSubType, Integer quantity) {
|
||||
// 兼容旧接口,使用默认productId
|
||||
return getTierConfig(productType, "default", productSubType, quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "active-product-configs")
|
||||
// @Cacheable(value = "active-product-configs")
|
||||
public List<PriceProductConfig> getActiveProductConfigs() {
|
||||
return productConfigMapper.selectActiveConfigs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "tier-configs", key = "#productType")
|
||||
// @Cacheable(value = "tier-configs", key = "#productType")
|
||||
public List<PriceTierConfig> getTierConfigs(String productType) {
|
||||
return tierConfigMapper.selectByProductType(productType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "tier-configs", key = "#productType + '_' + #productId")
|
||||
// @Cacheable(value = "tier-configs", key = "#productType + '_' + #productId")
|
||||
public List<PriceTierConfig> getTierConfigs(String productType, String productId) {
|
||||
return tierConfigMapper.selectByProductTypeAndId(productType, productId);
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Cacheable(value = "all-tier-configs")
|
||||
public List<PriceTierConfig> getAllTierConfigs() {
|
||||
return tierConfigMapper.selectAllActiveConfigs();
|
||||
}
|
||||
|
||||
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||
|
||||
@Override
|
||||
public List<PriceProductConfig> getAllProductConfigsForAdmin() {
|
||||
return productConfigMapper.selectAllConfigsForAdmin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PriceTierConfig> getAllTierConfigsForAdmin() {
|
||||
return tierConfigMapper.selectAllConfigsForAdmin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PriceTierConfig> getTierConfigsForAdmin(String productType) {
|
||||
return tierConfigMapper.selectByProductTypeForAdmin(productType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PriceTierConfig> getTierConfigsForAdmin(String productType, String productId) {
|
||||
return tierConfigMapper.selectByProductTypeAndIdForAdmin(productType, productId);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user