应付产品增加状态过滤
This commit is contained in:
@@ -54,7 +54,5 @@ public interface PayProductMapper
|
||||
|
||||
Long selectEffectiveVersionId(@Param("stableId") Long stableId, @Param("bizDate") Date bizDate);
|
||||
|
||||
PayProduct selectInactiveCovering(@Param("stableId") Long stableId, @Param("bizDate") Date bizDate);
|
||||
|
||||
Long selectLatestVersionId(@Param("stableId") Long stableId);
|
||||
}
|
||||
|
||||
+33
-13
@@ -488,7 +488,7 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
term.setVersionNo(product.getVersionNo() == null ? 1 : product.getVersionNo());
|
||||
term.setEffectiveStart(product.getEffectiveDate());
|
||||
term.setFilePath(sourcePath(product.getFilePath()));
|
||||
term.setStatus("1");
|
||||
term.setStatus("0");
|
||||
term.setCreateBy(product.getCreateBy());
|
||||
payProductTermMapper.insertTerm(term);
|
||||
}
|
||||
@@ -1013,16 +1013,6 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
private PayProduct loadVersion(Long root, Date day, boolean required)
|
||||
{
|
||||
Long versionId = payProductMapper.selectEffectiveVersionId(root, day);
|
||||
if (versionId == null && required)
|
||||
{
|
||||
PayProduct blocked = payProductMapper.selectInactiveCovering(root, day);
|
||||
if (blocked != null)
|
||||
{
|
||||
String blockedName = blocked.getProductName() == null ? String.valueOf(root) : blocked.getProductName();
|
||||
String versionText = blocked.getVersionNo() == null ? "-" : String.valueOf(blocked.getVersionNo());
|
||||
throw new ServiceException("未配置应付计算规则:" + blockedName + " 第 " + versionText + " 版,取价日 " + formatDay(day));
|
||||
}
|
||||
}
|
||||
if (versionId == null && !required)
|
||||
{
|
||||
versionId = payProductMapper.selectLatestVersionId(root);
|
||||
@@ -1034,8 +1024,10 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
return null;
|
||||
}
|
||||
PayProduct rootRow = payProductMapper.selectPayProductById(root);
|
||||
String name = rootRow == null ? String.valueOf(root) : rootRow.getProductName();
|
||||
throw new ServiceException("订单时间 " + formatDay(day) + " 没有落在产品「" + name + "」的价格有效期内");
|
||||
String name = rootRow == null || rootRow.getProductName() == null
|
||||
? String.valueOf(root) : rootRow.getProductName();
|
||||
throw new ServiceException("订单时间 " + formatDay(day) + " 没有落在产品「" + name + "」的价格有效期内"
|
||||
+ savedWindows(rootRow));
|
||||
}
|
||||
PayProduct detail = selectPayProductDetail(versionId);
|
||||
if (detail == null)
|
||||
@@ -1213,6 +1205,34 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
return toLocalDate(date).toString();
|
||||
}
|
||||
|
||||
/** 订单日没落在任何一版有效期里时,把已经保存的起止带出来。 */
|
||||
private String savedWindows(PayProduct rootRow)
|
||||
{
|
||||
if (rootRow == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
List<PayProductTerm> terms = payProductTermMapper.selectByDict(termKey(rootRow));
|
||||
if (terms == null || terms.isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
StringBuilder text = new StringBuilder("。已保存的有效期:");
|
||||
for (int i = 0; i < terms.size(); i++)
|
||||
{
|
||||
PayProductTerm term = terms.get(i);
|
||||
if (i > 0)
|
||||
{
|
||||
text.append(";");
|
||||
}
|
||||
String version = term.getVersionNo() == null ? "-" : String.valueOf(term.getVersionNo());
|
||||
String start = term.getEffectiveStart() == null ? "不限" : formatDay(term.getEffectiveStart());
|
||||
String end = term.getEffectiveEnd() == null ? "不限" : formatDay(term.getEffectiveEnd());
|
||||
text.append("第 ").append(version).append(" 版 ").append(start).append(" 至 ").append(end);
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
private static String cut(String value, int max)
|
||||
{
|
||||
if (value == null || value.length() <= max)
|
||||
|
||||
@@ -320,32 +320,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where product_id = #{rootId} or origin_id = #{rootId}
|
||||
</select>
|
||||
|
||||
<!-- 取价只看有效期。生效/失效开关不参与,和历史页说明一致。 -->
|
||||
<select id="selectEffectiveVersionId" resultType="long">
|
||||
select v.product_id
|
||||
from pay_product v
|
||||
inner join pay_product_term t on t.product_id = v.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = #{stableId} or v.origin_id = #{stableId})
|
||||
and t.status = '0'
|
||||
and (t.effective_start is null or t.effective_start <= date(#{bizDate}))
|
||||
and (t.effective_end is null or t.effective_end >= date(#{bizDate}))
|
||||
order by ifnull(v.version_no, 1) desc, v.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectInactiveCovering" resultMap="PayProductResult">
|
||||
select v.product_id, v.product_name, t.version_no
|
||||
from pay_product v
|
||||
inner join pay_product_term t on t.product_id = v.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = #{stableId} or v.origin_id = #{stableId})
|
||||
and ifnull(t.status, '1') <> '0'
|
||||
and (t.effective_start is null or t.effective_start <= date(#{bizDate}))
|
||||
and (t.effective_end is null or t.effective_end >= date(#{bizDate}))
|
||||
order by ifnull(t.version_no, 1) desc, v.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectLatestVersionId" resultType="long">
|
||||
select v.product_id
|
||||
from pay_product v
|
||||
|
||||
Reference in New Issue
Block a user