产品列表配置附加费

This commit is contained in:
wuweihua
2026-09-08 11:55:31 +08:00
parent 38796d8683
commit 520fc32a4e
12 changed files with 569 additions and 3 deletions
@@ -30,6 +30,7 @@ public class BmsProduct extends BaseEntity
private String sourceSheet;
private Long tmsId;
private Integer countryCount;
private Integer surchargeCount;
private List<BmsProductCountry> countries;
/**
* 查询用:ACTIVE已生效 / PENDING待生效 / EXPIRED已失效
@@ -0,0 +1,44 @@
package com.ruoyi.price.domain;
import java.math.BigDecimal;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 附加费与产品/明细关联 prc_surcharge_rel
* 同时携带附加费展示字段(JOIN prc_surcharge)与明细展示字段(LEFT JOIN bms_product_country),
* 便于产品列表抽屉直接渲染。
*
* 语义:
* detail_id 为空 = 产品级附加费(作用于该产品全部明细)
* detail_id 有值 = 明细级附加费(作用于该产品某个 国家×重量段 明细)
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class PrcSurchargeRel extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long relId;
private Long scId;
private Long productId;
private String productCode;
private Long detailId;
/** 附加费冗余展示字段 */
private String scName;
private String feeType;
private String chargeType;
private BigDecimal chargeValue;
private String currency;
private String roundMode;
private String ssCode;
private String countryCode;
private String scNote;
/** 明细展示字段 */
private String countryName;
private BigDecimal weightMin;
private BigDecimal weightMax;
}
@@ -0,0 +1,24 @@
package com.ruoyi.price.mapper;
import java.util.List;
import com.ruoyi.price.domain.PrcSurchargeRel;
/**
* 附加费与产品/明细关联 数据层
*
* @author ruoyi
*/
public interface PrcSurchargeRelMapper
{
/**
* 查询关联列表(JOIN 附加费 + 明细),支持按 productCode / scId 过滤
*/
public List<PrcSurchargeRel> selectPrcSurchargeRelList(PrcSurchargeRel rel);
public int insertPrcSurchargeRel(PrcSurchargeRel rel);
public int deletePrcSurchargeRelByIds(Long[] relIds);
/** 删除产品时清理其关联 */
public int deleteRelByProductCodes(String[] productCodes);
}
@@ -0,0 +1,24 @@
package com.ruoyi.price.service;
import java.util.List;
import com.ruoyi.price.domain.PrcSurchargeRel;
/**
* 附加费与产品/明细关联 服务层
*
* @author ruoyi
*/
public interface IPrcSurchargeRelService
{
/** 查询某产品已关联的附加费(含附加费与明细展示字段) */
public List<PrcSurchargeRel> selectRelByProductCode(String productCode);
public List<PrcSurchargeRel> selectPrcSurchargeRelList(PrcSurchargeRel rel);
public int insertPrcSurchargeRel(PrcSurchargeRel rel);
public int deletePrcSurchargeRelByIds(Long[] relIds);
/** 删除产品时清理其关联 */
public int deleteRelByProductCodes(String[] productCodes);
}
@@ -32,6 +32,7 @@ import com.ruoyi.price.domain.BmsProductCountry;
import com.ruoyi.price.mapper.BmsProductCountryMapper;
import com.ruoyi.price.mapper.BmsProductMapper;
import com.ruoyi.price.service.IBmsProductService;
import com.ruoyi.price.service.IPrcSurchargeRelService;
import com.ruoyi.system.domain.BmsRegion;
import com.ruoyi.system.mapper.BmsRegionMapper;
@@ -64,6 +65,9 @@ public class BmsProductServiceImpl implements IBmsProductService
@Autowired
private BmsRegionMapper regionMapper;
@Autowired
private IPrcSurchargeRelService surchargeRelService;
@Override
public BmsProduct selectBmsProductById(Long productId)
{
@@ -116,6 +120,7 @@ public class BmsProductServiceImpl implements IBmsProductService
if (!codes.isEmpty())
{
countryMapper.deleteByProductCodes(codes.toArray(new String[0]));
surchargeRelService.deleteRelByProductCodes(codes.toArray(new String[0]));
}
return productMapper.deleteBmsProductByIds(productIds);
}
@@ -0,0 +1,79 @@
package com.ruoyi.price.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.price.domain.PrcSurchargeRel;
import com.ruoyi.price.mapper.PrcSurchargeRelMapper;
import com.ruoyi.price.service.IPrcSurchargeRelService;
/**
* 附加费与产品/明细关联 服务层实现
*
* @author ruoyi
*/
@Service
public class PrcSurchargeRelServiceImpl implements IPrcSurchargeRelService
{
@Autowired
private PrcSurchargeRelMapper relMapper;
@Override
public List<PrcSurchargeRel> selectRelByProductCode(String productCode)
{
PrcSurchargeRel query = new PrcSurchargeRel();
query.setProductCode(productCode);
return relMapper.selectPrcSurchargeRelList(query);
}
@Override
public List<PrcSurchargeRel> selectPrcSurchargeRelList(PrcSurchargeRel rel)
{
return relMapper.selectPrcSurchargeRelList(rel);
}
@Override
public int insertPrcSurchargeRel(PrcSurchargeRel rel)
{
validate(rel);
return relMapper.insertPrcSurchargeRel(rel);
}
@Override
public int deletePrcSurchargeRelByIds(Long[] relIds)
{
if (relIds == null || relIds.length == 0)
{
return 0;
}
return relMapper.deletePrcSurchargeRelByIds(relIds);
}
@Override
public int deleteRelByProductCodes(String[] productCodes)
{
if (productCodes == null || productCodes.length == 0)
{
return 0;
}
return relMapper.deleteRelByProductCodes(productCodes);
}
private void validate(PrcSurchargeRel rel)
{
if (rel.getScId() == null)
{
throw new ServiceException("附加费ID不能为空");
}
if (rel.getProductId() == null)
{
throw new ServiceException("产品ID不能为空");
}
if (StringUtils.isEmpty(rel.getProductCode()))
{
throw new ServiceException("产品代码不能为空");
}
}
}