增加一个渠道绑定
This commit is contained in:
@@ -20,6 +20,15 @@ public class ChannelProductMap
|
||||
|
||||
private Long productId;
|
||||
|
||||
/** 打单套餐 ID,对应 prc_price_set.price_set_id(应收可填) */
|
||||
private Long priceSetId;
|
||||
|
||||
/** 渠道名称(列表回显) */
|
||||
private String channelName;
|
||||
|
||||
/** 产品名称(列表回显) */
|
||||
private String productName;
|
||||
|
||||
/** AR 应收,AP 应付 */
|
||||
private String payType;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.ChannelProductMap;
|
||||
|
||||
@@ -10,9 +11,14 @@ public interface ChannelProductMapMapper
|
||||
{
|
||||
ChannelProductMap selectByChannelAndType(@Param("channelId") String channelId, @Param("payType") String payType);
|
||||
|
||||
List<ChannelProductMap> selectByPriceSetId(@Param("priceSetId") Long priceSetId);
|
||||
|
||||
int upsert(ChannelProductMap row);
|
||||
|
||||
int deleteByChannelAndType(@Param("channelId") String channelId, @Param("payType") String payType);
|
||||
|
||||
int deleteByChannelTypeAndPriceSet(@Param("channelId") String channelId, @Param("payType") String payType,
|
||||
@Param("priceSetId") Long priceSetId);
|
||||
|
||||
int deleteByProductId(@Param("productId") Long productId);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ public interface PayProductTermMapper
|
||||
|
||||
PayProductTerm selectByProductId(Long productId);
|
||||
|
||||
/** 打单产品所属套餐 ID */
|
||||
Long selectLabelPriceSetIdByProduct(@Param("productId") Long productId);
|
||||
|
||||
List<PayProductTerm> selectByPriceSetId(@Param("priceSetId") Long priceSetId);
|
||||
|
||||
List<PayProductTerm> selectByPriceSetIdAndVersion(@Param("priceSetId") Long priceSetId,
|
||||
@@ -68,6 +71,9 @@ public interface PayProductTermMapper
|
||||
int restorePrematureClosed(@Param("priceSetId") Long priceSetId, @Param("today") Date today,
|
||||
@Param("updateBy") String updateBy);
|
||||
|
||||
/** 打单:删除待生效版后,清掉旧版预约失效日 */
|
||||
int clearScheduledEnd(@Param("priceSetId") Long priceSetId, @Param("updateBy") String updateBy);
|
||||
|
||||
int deleteByProductIds(@Param("productIds") List<Long> productIds);
|
||||
|
||||
int deleteByTermIds(@Param("termIds") List<Long> termIds);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.bms.price.domain.LabelPackageVersion;
|
||||
import com.bms.price.domain.PayParseProgress;
|
||||
import com.bms.price.domain.PayPreview;
|
||||
import com.bms.price.domain.PayPriceCompare;
|
||||
import com.bms.price.domain.ChannelProductMap;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.domain.PayProductTerm;
|
||||
import com.bms.price.domain.PaySaveCommand;
|
||||
@@ -57,6 +58,9 @@ public interface IPayProductService
|
||||
/** 只绑定产品编号,不产生新版本;同时落 channel_code。payType 为空时按应付 AP */
|
||||
void bindChannel(String channelId, Long productId, String payType);
|
||||
|
||||
/** 批量绑定渠道应收/应付产品;未传的产品不改原绑定 */
|
||||
String batchBindChannel(java.util.List<String> channelIds, Long apProductId, Long arProductId);
|
||||
|
||||
/**
|
||||
* 打单套餐预览:解析复用应付解析器,但「已存在」只按本套餐 price_set_id 判断,
|
||||
* 不与应付公共模板互相挡导入。
|
||||
@@ -72,6 +76,9 @@ public interface IPayProductService
|
||||
/** 启动/修改打单套餐某一版生效时间,并视情况启用套餐 */
|
||||
String activateLabelVersion(Long priceSetId, Integer versionNo, Date effectiveTime);
|
||||
|
||||
/** 删除打单套餐待生效版本(仅 status=0) */
|
||||
int deleteLabelVersion(Long priceSetId, Integer versionNo);
|
||||
|
||||
/** 打单套餐内当前生效/待生效产品列表 */
|
||||
List<PayProduct> selectLabelProducts(Long priceSetId);
|
||||
|
||||
@@ -84,6 +91,15 @@ public interface IPayProductService
|
||||
/** 从打单套餐移除产品(失效/清理对应 term 明细) */
|
||||
int removeLabelProducts(Long priceSetId, Long[] productIds);
|
||||
|
||||
/** 打单套餐已绑定渠道列表 */
|
||||
java.util.List<ChannelProductMap> listLabelChannels(Long priceSetId);
|
||||
|
||||
/** 打单套餐批量绑定渠道(写 AR + price_set_id) */
|
||||
String bindLabelChannels(Long priceSetId, java.util.List<String> channelIds, Long productId);
|
||||
|
||||
/** 打单套餐解绑渠道 */
|
||||
int unbindLabelChannel(Long priceSetId, String channelId);
|
||||
|
||||
/** 取消渠道上指定收付类型的产品。payType 为空时按应付 AP */
|
||||
void unbindChannel(String channelId, String payType);
|
||||
|
||||
|
||||
+232
-25
@@ -890,8 +890,8 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
boolean editPendingVersion = command.getVersionNo() != null;
|
||||
if (editPendingVersion)
|
||||
{
|
||||
// 编辑待生效版:清掉该 version 后按原号重写,保留原生效日
|
||||
LabelVersionKeep keep = clearPendingLabelVersion(priceSetId, command.getVersionNo(), operator);
|
||||
// 编辑待生效/已生效版:清掉该 version 后按原号重写,保留原生效日与状态
|
||||
LabelVersionKeep keep = clearEditableLabelVersion(priceSetId, command.getVersionNo(), operator);
|
||||
keepStart = keep.effectiveStart;
|
||||
keepStatus = keep.status == null ? TERM_PENDING : keep.status;
|
||||
nextVersionNo = command.getVersionNo();
|
||||
@@ -968,8 +968,8 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
private String status;
|
||||
}
|
||||
|
||||
/** 仅允许清待生效版;返回原生效日便于编辑后回写 */
|
||||
private LabelVersionKeep clearPendingLabelVersion(Long priceSetId, Integer versionNo, String operator)
|
||||
/** 编辑版本:允许待生效或已生效;返回原生效日与状态便于回写 */
|
||||
private LabelVersionKeep clearEditableLabelVersion(Long priceSetId, Integer versionNo, String operator)
|
||||
{
|
||||
if (priceSetId == null || versionNo == null)
|
||||
{
|
||||
@@ -984,15 +984,13 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
List<Long> termIds = new ArrayList<>();
|
||||
for (PayProductTerm term : terms)
|
||||
{
|
||||
if (!TERM_PENDING.equals(term.getStatus()))
|
||||
boolean pending = TERM_PENDING.equals(term.getStatus());
|
||||
boolean effect = TERM_EFFECT.equals(term.getStatus());
|
||||
boolean futureStart = term.getEffectiveStart() != null
|
||||
&& toLocalDate(term.getEffectiveStart()).isAfter(toLocalDate(today()));
|
||||
if (!pending && !effect && !futureStart)
|
||||
{
|
||||
// 兼容:生效日未到但 status 误为 1,仍允许编辑
|
||||
boolean futureStart = term.getEffectiveStart() != null
|
||||
&& toLocalDate(term.getEffectiveStart()).isAfter(toLocalDate(today()));
|
||||
if (!futureStart)
|
||||
{
|
||||
throw new ServiceException("只能编辑待生效版本");
|
||||
}
|
||||
throw new ServiceException("只能编辑待生效或已生效版本");
|
||||
}
|
||||
if (keep.effectiveStart == null && term.getEffectiveStart() != null)
|
||||
{
|
||||
@@ -1000,7 +998,7 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
}
|
||||
if (keep.status == null)
|
||||
{
|
||||
keep.status = TERM_PENDING;
|
||||
keep.status = term.getStatus() == null ? TERM_PENDING : term.getStatus();
|
||||
}
|
||||
termIds.add(term.getTermId());
|
||||
}
|
||||
@@ -1011,6 +1009,148 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
return keep;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteLabelVersion(Long priceSetId, Integer versionNo)
|
||||
{
|
||||
if (priceSetId == null || versionNo == null)
|
||||
{
|
||||
throw new ServiceException("请选择要删除的版本");
|
||||
}
|
||||
PrcPriceSet set = priceSetMapper.selectPrcPriceSetById(priceSetId);
|
||||
if (set == null)
|
||||
{
|
||||
throw new ServiceException("打单套餐不存在");
|
||||
}
|
||||
if (!PrcPriceSet.CATEGORY_LABEL.equalsIgnoreCase(String.valueOf(set.getSetCategory())))
|
||||
{
|
||||
throw new ServiceException("只能删除打单套餐版本");
|
||||
}
|
||||
List<PayProductTerm> terms = payProductTermMapper.selectByPriceSetIdAndVersion(priceSetId, versionNo);
|
||||
if (terms == null || terms.isEmpty())
|
||||
{
|
||||
throw new ServiceException("该版本不存在或没有产品");
|
||||
}
|
||||
List<Long> termIds = new ArrayList<>();
|
||||
for (PayProductTerm term : terms)
|
||||
{
|
||||
boolean pending = TERM_PENDING.equals(term.getStatus());
|
||||
boolean futureStart = term.getEffectiveStart() != null
|
||||
&& toLocalDate(term.getEffectiveStart()).isAfter(toLocalDate(today()));
|
||||
if (!pending && !futureStart)
|
||||
{
|
||||
throw new ServiceException("只能删除待生效版本");
|
||||
}
|
||||
termIds.add(term.getTermId());
|
||||
}
|
||||
String operator = SecurityUtils.getUsername();
|
||||
payProductMapper.deleteWeightBandsByTerm(termIds);
|
||||
payProductMapper.deleteSurchargesByTerm(termIds);
|
||||
payProductMapper.deleteExtraLinesByTerm(termIds);
|
||||
int n = payProductTermMapper.deleteByTermIds(termIds);
|
||||
payProductTermMapper.restorePrematureClosed(priceSetId, today(), operator);
|
||||
payProductTermMapper.clearScheduledEnd(priceSetId, operator);
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChannelProductMap> listLabelChannels(Long priceSetId)
|
||||
{
|
||||
if (priceSetId == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ChannelProductMap> list = channelProductMapMapper.selectByPriceSetId(priceSetId);
|
||||
return list == null ? Collections.emptyList() : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String bindLabelChannels(Long priceSetId, List<String> channelIds, Long productId)
|
||||
{
|
||||
if (priceSetId == null)
|
||||
{
|
||||
throw new ServiceException("请选择打单套餐");
|
||||
}
|
||||
if (channelIds == null || channelIds.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请选择要绑定的渠道");
|
||||
}
|
||||
if (productId == null)
|
||||
{
|
||||
throw new ServiceException("请选择套餐内应收产品");
|
||||
}
|
||||
PrcPriceSet set = priceSetMapper.selectPrcPriceSetById(priceSetId);
|
||||
if (set == null || !PrcPriceSet.CATEGORY_LABEL.equalsIgnoreCase(String.valueOf(set.getSetCategory())))
|
||||
{
|
||||
throw new ServiceException("打单套餐不存在");
|
||||
}
|
||||
Long root = resolveRoot(productId);
|
||||
boolean inSet = false;
|
||||
List<PayProduct> products = selectLabelProducts(priceSetId);
|
||||
for (PayProduct p : products)
|
||||
{
|
||||
if (p != null && root.equals(p.getProductId()))
|
||||
{
|
||||
inSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inSet)
|
||||
{
|
||||
throw new ServiceException("所选产品不属于本打单套餐");
|
||||
}
|
||||
String operator = SecurityUtils.getUsername();
|
||||
int n = 0;
|
||||
for (String channelId : channelIds)
|
||||
{
|
||||
if (isBlank(channelId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ServiceChannel channel = serviceChannelMapper.selectServiceChannelById(channelId.trim());
|
||||
if (channel == null || isBlank(channel.getChannelCode()))
|
||||
{
|
||||
throw new ServiceException("渠道不存在或渠道编码为空:" + channelId);
|
||||
}
|
||||
ChannelProductMap row = new ChannelProductMap();
|
||||
row.setChannelId(channelId.trim());
|
||||
row.setChannelCode(channel.getChannelCode());
|
||||
row.setProductId(root);
|
||||
row.setPriceSetId(priceSetId);
|
||||
row.setPayType(PAY_TYPE_AR);
|
||||
row.setCreateBy(operator);
|
||||
row.setUpdateBy(operator);
|
||||
channelProductMapMapper.upsert(row);
|
||||
n++;
|
||||
}
|
||||
if (n <= 0)
|
||||
{
|
||||
throw new ServiceException("没有可绑定的渠道");
|
||||
}
|
||||
return "已绑定 " + n + " 个渠道";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int unbindLabelChannel(Long priceSetId, String channelId)
|
||||
{
|
||||
if (priceSetId == null || isBlank(channelId))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return channelProductMapMapper.deleteByChannelTypeAndPriceSet(channelId.trim(), PAY_TYPE_AR, priceSetId);
|
||||
}
|
||||
|
||||
private Long resolveLabelPriceSetId(Long productId)
|
||||
{
|
||||
if (productId == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return payProductTermMapper.selectLabelPriceSetIdByProduct(productId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayProduct> selectLabelProducts(Long priceSetId)
|
||||
{
|
||||
@@ -1196,9 +1336,9 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Date now = today();
|
||||
Date now = nowDateTime();
|
||||
// 纠正历史:未来生效版启动时把旧版提前标成已失效
|
||||
payProductTermMapper.restorePrematureClosed(priceSetId, now, "system");
|
||||
payProductTermMapper.restorePrematureClosed(priceSetId, today(), "system");
|
||||
List<LabelPackageVersion> groups = payProductTermMapper.selectLabelVersionGroups(priceSetId);
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
@@ -1212,16 +1352,16 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
int pending = ver.getPendingCount() == null ? 0 : ver.getPendingCount();
|
||||
Date start = ver.getEffectiveTime();
|
||||
Date end = ver.getExpireTime();
|
||||
// 按日期判定:未到生效日=待生效;已过失效日=已失效;中间段=生效
|
||||
// 按时间(到小时)判定:未到生效=待生效;已过失效=已失效;中间段=生效
|
||||
if (start == null)
|
||||
{
|
||||
ver.setStatus(pending > 0 ? TERM_PENDING : (active > 0 ? TERM_EFFECT : TERM_EXPIRED));
|
||||
}
|
||||
else if (toLocalDate(start).isAfter(toLocalDate(now)))
|
||||
else if (toLocalDateTime(start).isAfter(toLocalDateTime(now)))
|
||||
{
|
||||
ver.setStatus(TERM_PENDING);
|
||||
}
|
||||
else if (end != null && toLocalDate(end).isBefore(toLocalDate(now)))
|
||||
else if (end != null && !toLocalDateTime(end).isAfter(toLocalDateTime(now)))
|
||||
{
|
||||
ver.setStatus(TERM_EXPIRED);
|
||||
}
|
||||
@@ -1255,20 +1395,22 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
throw new ServiceException("只能启动打单套餐版本");
|
||||
}
|
||||
String operator = SecurityUtils.getUsername();
|
||||
boolean future = toLocalDate(effectiveTime).isAfter(toLocalDate(today()));
|
||||
Date endDate = toDate(toLocalDate(effectiveTime).minusDays(1));
|
||||
Date effectiveHour = truncateToHour(effectiveTime);
|
||||
boolean future = toLocalDateTime(effectiveHour).isAfter(toLocalDateTime(nowDateTime()));
|
||||
// 旧版失效时间 = 新版生效时间(取价按 start <= biz < end)
|
||||
Date endDate = effectiveHour;
|
||||
if (future)
|
||||
{
|
||||
// 未到生效日:本版保持待生效;旧版只预约失效日,当前仍生效
|
||||
// 未到生效时间:本版保持待生效;旧版只预约失效时间,当前仍生效
|
||||
payProductTermMapper.scheduleEndExceptVersion(priceSetId, versionNo, endDate, today(), operator);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 当天或已过:本版立刻生效,旧版关掉
|
||||
// 已到/已过:本版立刻生效,旧版关掉
|
||||
payProductTermMapper.closeEffectExceptVersion(priceSetId, versionNo, endDate, operator);
|
||||
}
|
||||
String termStatus = future ? TERM_PENDING : TERM_EFFECT;
|
||||
int n = payProductTermMapper.updateLabelVersionPeriod(priceSetId, versionNo, effectiveTime, null, termStatus, operator);
|
||||
int n = payProductTermMapper.updateLabelVersionPeriod(priceSetId, versionNo, effectiveHour, null, termStatus, operator);
|
||||
if (n <= 0)
|
||||
{
|
||||
throw new ServiceException("该版本没有可启动的产品价卡");
|
||||
@@ -1611,12 +1753,52 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
row.setChannelCode(channel.getChannelCode());
|
||||
row.setProductId(storedId);
|
||||
row.setPayType(type);
|
||||
if (PAY_TYPE_AR.equals(type))
|
||||
{
|
||||
row.setPriceSetId(resolveLabelPriceSetId(storedId));
|
||||
}
|
||||
String operator = SecurityUtils.getUsername();
|
||||
row.setCreateBy(operator);
|
||||
row.setUpdateBy(operator);
|
||||
channelProductMapMapper.upsert(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String batchBindChannel(List<String> channelIds, Long apProductId, Long arProductId)
|
||||
{
|
||||
if (channelIds == null || channelIds.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请先勾选渠道");
|
||||
}
|
||||
if (apProductId == null && arProductId == null)
|
||||
{
|
||||
throw new ServiceException("请至少选择应付或应收产品");
|
||||
}
|
||||
int n = 0;
|
||||
for (String channelId : channelIds)
|
||||
{
|
||||
if (isBlank(channelId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (apProductId != null)
|
||||
{
|
||||
bindChannel(channelId.trim(), apProductId, PAY_TYPE_AP);
|
||||
}
|
||||
if (arProductId != null)
|
||||
{
|
||||
bindChannel(channelId.trim(), arProductId, PAY_TYPE_AR);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
if (n <= 0)
|
||||
{
|
||||
throw new ServiceException("没有可绑定的渠道");
|
||||
}
|
||||
return "已为 " + n + " 个渠道绑定产品";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unbindChannel(String channelId, String payType)
|
||||
{
|
||||
@@ -1971,6 +2153,12 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
return toDate(java.time.LocalDate.now(java.time.ZoneId.of("GMT+8")));
|
||||
}
|
||||
|
||||
private static Date nowDateTime()
|
||||
{
|
||||
return java.util.Date.from(java.time.LocalDateTime.now(java.time.ZoneId.of("GMT+8"))
|
||||
.atZone(java.time.ZoneId.of("GMT+8")).toInstant());
|
||||
}
|
||||
|
||||
private static Date toDate(java.time.LocalDate day)
|
||||
{
|
||||
return java.sql.Date.valueOf(day);
|
||||
@@ -1978,11 +2166,30 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
|
||||
private static java.time.LocalDate toLocalDate(Date date)
|
||||
{
|
||||
return toLocalDateTime(date).toLocalDate();
|
||||
}
|
||||
|
||||
private static java.time.LocalDateTime toLocalDateTime(Date date)
|
||||
{
|
||||
if (date == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (date instanceof java.sql.Date sql)
|
||||
{
|
||||
return sql.toLocalDate();
|
||||
return sql.toLocalDate().atStartOfDay();
|
||||
}
|
||||
return date.toInstant().atZone(java.time.ZoneId.of("GMT+8")).toLocalDate();
|
||||
if (date instanceof java.sql.Timestamp ts)
|
||||
{
|
||||
return ts.toLocalDateTime();
|
||||
}
|
||||
return date.toInstant().atZone(java.time.ZoneId.of("GMT+8")).toLocalDateTime();
|
||||
}
|
||||
|
||||
private static Date truncateToHour(Date date)
|
||||
{
|
||||
java.time.LocalDateTime dt = toLocalDateTime(date).withMinute(0).withSecond(0).withNano(0);
|
||||
return java.util.Date.from(dt.atZone(java.time.ZoneId.of("GMT+8")).toInstant());
|
||||
}
|
||||
|
||||
private static String formatDay(Date date)
|
||||
|
||||
@@ -6,22 +6,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectByChannelAndType" resultType="com.bms.price.domain.ChannelProductMap">
|
||||
select id, channel_id as channelId, channel_code as channelCode, product_id as productId,
|
||||
pay_type as payType, create_by as createBy, create_time as createTime,
|
||||
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}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectByPriceSetId" resultType="com.bms.price.domain.ChannelProductMap">
|
||||
select m.id, m.channel_id as channelId, m.channel_code as channelCode, m.product_id as productId,
|
||||
m.price_set_id as priceSetId, m.pay_type as payType,
|
||||
c.channel_name as channelName, p.product_name as productName,
|
||||
m.create_by as createBy, m.create_time as createTime,
|
||||
m.update_by as updateBy, m.update_time as updateTime
|
||||
from srv_channel_product_map m
|
||||
left join srv_service_channel c on c.id = m.channel_id
|
||||
left join pay_product p on p.product_id = m.product_id
|
||||
where m.price_set_id = #{priceSetId}
|
||||
and m.pay_type = 'AR'
|
||||
order by m.update_time desc, m.id desc
|
||||
</select>
|
||||
|
||||
<insert id="upsert">
|
||||
insert into srv_channel_product_map (
|
||||
channel_id, channel_code, product_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}, #{channelCode}, #{productId}, #{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),
|
||||
update_time = sysdate()
|
||||
</insert>
|
||||
@@ -31,6 +46,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where channel_id = #{channelId} and pay_type = #{payType}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByChannelTypeAndPriceSet">
|
||||
delete from srv_channel_product_map
|
||||
where channel_id = #{channelId}
|
||||
and pay_type = #{payType}
|
||||
and price_set_id = #{priceSetId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByProductId">
|
||||
delete from srv_channel_product_map where product_id = #{productId}
|
||||
</delete>
|
||||
|
||||
@@ -274,9 +274,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 渠道下拉:AP=应付公共模板;AR=pay_product 应收(含打单套餐产品) -->
|
||||
<select id="selectTemplateOptions" resultMap="PayProductResult">
|
||||
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
|
||||
p.currency, ifnull(ifnull(t.version_no, cur.version_no), p.version_no) as version_no
|
||||
from pay_product p
|
||||
left join pay_product_term t on t.term_id = (
|
||||
select t2.term_id
|
||||
@@ -284,14 +285,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
inner join pay_product v on v.product_id = t2.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = p.product_id or v.origin_id = p.product_id)
|
||||
and t2.price_set_id is null
|
||||
order by case when t2.status = '1' then 0 when t2.status = '0' then 1 else 2 end, ifnull(v.version_no, 1) desc, t2.term_id desc
|
||||
<if test='payType == null or "AP".equals(payType)'>
|
||||
and t2.price_set_id is null
|
||||
</if>
|
||||
order by case when t2.status = '1' then 0 when t2.status = '0' then 1 else 2 end,
|
||||
ifnull(t2.version_no, ifnull(v.version_no, 1)) desc, t2.term_id desc
|
||||
limit 1
|
||||
)
|
||||
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}
|
||||
<if test='payType == null or "AP".equals(payType)'>
|
||||
and not (
|
||||
exists (
|
||||
select 1 from pay_product_term t_label
|
||||
@@ -304,6 +309,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and t_pay.price_set_id is null
|
||||
)
|
||||
)
|
||||
</if>
|
||||
order by p.product_name
|
||||
</select>
|
||||
|
||||
|
||||
@@ -41,6 +41,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectLabelPriceSetIdByProduct" resultType="long">
|
||||
select price_set_id
|
||||
from pay_product_term
|
||||
where product_id = #{productId}
|
||||
and price_set_id is not null
|
||||
order by case when status = '1' then 0 when status = '0' then 1 else 2 end, version_no desc, term_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 打单套餐产品列表:待生效+生效 -->
|
||||
<select id="selectByPriceSetId" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select t.term_id as termId, t.dict_value as dictValue, t.product_id as productId, t.price_set_id as priceSetId,
|
||||
@@ -76,8 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where t.price_set_id = #{priceSetId}
|
||||
and t.product_id = #{productId}
|
||||
and t.effective_start is not null
|
||||
and t.effective_start <= date(#{bizDate})
|
||||
and (t.effective_end is null or t.effective_end >= date(#{bizDate}))
|
||||
and t.effective_start <= #{bizDate}
|
||||
and (t.effective_end is null or t.effective_end > #{bizDate})
|
||||
order by ifnull(t.version_no, 1) desc, t.term_id desc
|
||||
limit 1
|
||||
</select>
|
||||
@@ -236,6 +245,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and effective_end >= #{today}
|
||||
</update>
|
||||
|
||||
<update id="clearScheduledEnd">
|
||||
update pay_product_term
|
||||
set effective_end = null,
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where price_set_id = #{priceSetId}
|
||||
and status = '1'
|
||||
and effective_end is not null
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductIds">
|
||||
delete from pay_product_term where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
|
||||
Reference in New Issue
Block a user