渠道管理增加应收关联

This commit is contained in:
wuweihua
2026-11-09 17:27:21 +08:00
parent ace1eb06c0
commit 2632e5aa78
10 changed files with 131 additions and 28 deletions
@@ -15,6 +15,9 @@ public class ChannelProductMap
/** 渠道表主键 srv_service_channel.id */
private String channelId;
/** 渠道编码,对应 srv_service_channel.channel_code */
private String channelCode;
private Long productId;
/** 应收套餐 prc_price_set.price_set_id */
@@ -22,7 +22,7 @@ public interface PayProductMapper
Long selectTemplateId(@Param("dictValue") String dictValue);
List<PayProduct> selectTemplateOptions();
List<PayProduct> selectTemplateOptions(@Param("payType") String payType);
Integer selectMaxVersion(@Param("originId") Long originId);
@@ -47,10 +47,13 @@ public interface IPayProductService
/** 公共模板下拉。payType 为空时按应付 AP */
List<PayProduct> selectTemplateOptions(String payType);
/** 渠道绑定的产品。返回的 originId 是不变的产品编号,价格是当前有效版 */
/** 渠道绑定的产品。返回的 originId 是不变的产品编号,价格是当前有效版;默认应付 AP */
PayProduct selectChannelPrice(String channelId);
/** 只绑定产品编号,不产生新版本。payType 为空时按应付 AP */
/** 按收付类型查询渠道绑定产品,payType 为空时按应付 AP */
PayProduct selectChannelPrice(String channelId, String payType);
/** 只绑定产品编号,不产生新版本;同时落 channel_code。payType 为空时按应付 AP */
void bindChannel(String channelId, Long productId, Long priceSetId, String payType);
/** 取消渠道上指定收付类型的产品。payType 为空时按应付 AP */
@@ -35,6 +35,8 @@ import com.bms.price.domain.PayProductTerm;
import com.bms.price.domain.PaySaveCommand;
import com.bms.price.domain.PaySurcharge;
import com.bms.price.domain.PayWeightBand;
import com.bms.masterdata.domain.ServiceChannel;
import com.bms.masterdata.mapper.ServiceChannelMapper;
import com.bms.price.mapper.ChannelProductMapMapper;
import com.bms.price.mapper.PayProductMapper;
import com.bms.price.mapper.PayProductTermMapper;
@@ -63,6 +65,9 @@ public class PayProductServiceImpl implements IPayProductService
@Autowired
private ChannelProductMapMapper channelProductMapMapper;
@Autowired
private ServiceChannelMapper serviceChannelMapper;
@Autowired
private PayProductTermMapper payProductTermMapper;
@@ -276,21 +281,23 @@ public class PayProductServiceImpl implements IPayProductService
@Override
public List<PayProduct> selectTemplateOptions(String payType)
{
if (!PAY_TYPE_AP.equals(payTypeOf(payType)))
{
return Collections.emptyList();
}
return payProductMapper.selectTemplateOptions();
return payProductMapper.selectTemplateOptions(payTypeOf(payType));
}
@Override
public PayProduct selectChannelPrice(String channelId)
{
return selectChannelPrice(channelId, PAY_TYPE_AP);
}
@Override
public PayProduct selectChannelPrice(String channelId, String payType)
{
if (isBlank(channelId))
{
return null;
}
Long root = channelProductRoot(channelId);
Long root = channelProductRoot(channelId, payTypeOf(payType));
if (root == null)
{
return null;
@@ -937,10 +944,16 @@ public class PayProductServiceImpl implements IPayProductService
{
throw new ServiceException("请先保存渠道,再选择产品");
}
ServiceChannel channel = serviceChannelMapper.selectServiceChannelById(channelId);
if (channel == null || isBlank(channel.getChannelCode()))
{
throw new ServiceException("渠道不存在或渠道编码为空");
}
String type = payTypeOf(payType);
Long storedId = PAY_TYPE_AP.equals(type) ? resolveRoot(productId) : productId;
Long storedId = resolveRoot(productId);
ChannelProductMap row = new ChannelProductMap();
row.setChannelId(channelId);
row.setChannelCode(channel.getChannelCode());
row.setProductId(storedId);
row.setPriceSetId(priceSetId);
row.setPayType(type);
@@ -1035,10 +1048,15 @@ public class PayProductServiceImpl implements IPayProductService
return saved;
}
/** 渠道应付绑定记在映射表,产品编号是不变的根产品。 */
/** 渠道产品绑定记在映射表,产品编号是不变的根产品。 */
private Long channelProductRoot(String channelId)
{
ChannelProductMap link = channelProductMapMapper.selectByChannelAndType(channelId, PAY_TYPE_AP);
return channelProductRoot(channelId, PAY_TYPE_AP);
}
private Long channelProductRoot(String channelId, String payType)
{
ChannelProductMap link = channelProductMapMapper.selectByChannelAndType(channelId, payType);
if (link == null || link.getProductId() == null)
{
return null;
@@ -5,8 +5,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.bms.price.mapper.ChannelProductMapMapper">
<select id="selectByChannelAndType" resultType="com.bms.price.domain.ChannelProductMap">
select id, channel_id as channelId, product_id as productId, price_set_id as priceSetId,
pay_type as payType, create_by as createBy, create_time as createTime,
select id, channel_id as channelId, channel_code as channelCode, product_id as productId,
price_set_id as priceSetId, pay_type as payType, create_by as createBy, create_time as createTime,
update_by as updateBy, update_time as updateTime
from srv_channel_product_map
where channel_id = #{channelId} and pay_type = #{payType}
@@ -15,11 +15,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="upsert">
insert into srv_channel_product_map (
channel_id, product_id, price_set_id, pay_type, create_by, create_time, update_by, update_time
channel_id, channel_code, product_id, price_set_id, pay_type, create_by, create_time, update_by, update_time
) values (
#{channelId}, #{productId}, #{priceSetId}, #{payType}, #{createBy}, sysdate(), #{updateBy}, sysdate()
#{channelId}, #{channelCode}, #{productId}, #{priceSetId}, #{payType}, #{createBy}, sysdate(), #{updateBy}, sysdate()
)
on duplicate key update
channel_code = values(channel_code),
product_id = values(product_id),
price_set_id = values(price_set_id),
update_by = values(update_by),
@@ -212,7 +212,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectTemplateOptions" resultMap="PayProductResult">
select p.product_id, p.product_name, p.dict_value, p.sheet_name, p.supplier_name, p.effective_date,
select p.product_id, p.product_name, p.product_type, p.dict_value, p.sheet_name, p.supplier_name, p.effective_date,
p.currency, ifnull(cur.version_no, p.version_no) as version_no
from pay_product p
left join pay_product_term t on t.term_id = (
@@ -227,6 +227,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join pay_product cur on cur.product_id = t.product_id
where (p.channel_id is null or p.channel_id = '')
and p.origin_id is null
and ifnull(p.product_type, 'AP') = #{payType}
order by p.product_name
</select>