实现休眠账户大额启用打标规则
This commit is contained in:
@@ -1259,10 +1259,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectDormantAccountLargeActivationObjects" resultMap="BankTagObjectHitResultMap">
|
||||
select
|
||||
'STAFF_ID_CARD' AS objectType,
|
||||
'' AS objectKey,
|
||||
'占位SQL,待补充真实规则' AS reasonDetail
|
||||
from ccdi_bank_statement bs
|
||||
where 1 = 0
|
||||
t.objectKey AS objectKey,
|
||||
CONCAT(
|
||||
'账户', t.accountNo,
|
||||
'开户于', DATE_FORMAT(t.effectiveDate, '%Y-%m-%d'),
|
||||
',首次交易日期', DATE_FORMAT(t.firstTxDate, '%Y-%m-%d'),
|
||||
',沉睡时长', CAST(t.dormantMonths AS CHAR),
|
||||
'个月,启用后累计交易金额', CAST(t.windowTotalAmount AS CHAR),
|
||||
'元,单笔最大金额', CAST(t.windowMaxSingleAmount AS CHAR),
|
||||
'元'
|
||||
) AS reasonDetail
|
||||
from (
|
||||
select
|
||||
staff.id_card AS objectKey,
|
||||
ai.account_no AS accountNo,
|
||||
ai.effective_date AS effectiveDate,
|
||||
min(tx.txDate) AS firstTxDate,
|
||||
timestampdiff(MONTH, ai.effective_date, min(tx.txDate)) AS dormantMonths,
|
||||
round(sum(tx.tradeTotalAmount), 2) AS windowTotalAmount,
|
||||
round(max(tx.tradeMaxSingleAmount), 2) AS windowMaxSingleAmount
|
||||
from ccdi_account_info ai
|
||||
inner join ccdi_base_staff staff
|
||||
on staff.id_card = ai.owner_id
|
||||
inner join (
|
||||
select
|
||||
trim(bs.LE_ACCOUNT_NO) AS accountNo,
|
||||
COALESCE(
|
||||
STR_TO_DATE(LEFT(TRIM(bs.TRX_DATE), 19), '%Y-%m-%d %H:%i:%s'),
|
||||
STR_TO_DATE(LEFT(TRIM(bs.TRX_DATE), 10), '%Y-%m-%d')
|
||||
) AS txDate,
|
||||
IFNULL(bs.AMOUNT_DR, 0) + IFNULL(bs.AMOUNT_CR, 0) AS tradeTotalAmount,
|
||||
GREATEST(IFNULL(bs.AMOUNT_DR, 0), IFNULL(bs.AMOUNT_CR, 0)) AS tradeMaxSingleAmount
|
||||
from ccdi_bank_statement bs
|
||||
where bs.project_id = #{projectId}
|
||||
and trim(IFNULL(bs.LE_ACCOUNT_NO, '')) != ''
|
||||
) tx
|
||||
on tx.accountNo = trim(ai.account_no)
|
||||
where ai.owner_type = 'EMPLOYEE'
|
||||
and ai.status = 1
|
||||
and ai.effective_date is not null
|
||||
group by staff.id_card, ai.account_no, ai.effective_date
|
||||
having min(tx.txDate) >= DATE_ADD(ai.effective_date, INTERVAL 6 MONTH)
|
||||
) t
|
||||
where t.windowTotalAmount >= 500000
|
||||
or t.windowMaxSingleAmount >= 100000
|
||||
</select>
|
||||
|
||||
<select id="selectLargeStockTradingStatements" resultMap="BankTagStatementHitResultMap">
|
||||
|
||||
@@ -502,6 +502,18 @@ class CcdiBankTagServiceImplTest {
|
||||
assertTrue(xml.contains("select id=\"selectDormantAccountLargeActivationObjects\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void dormantAccountLargeActivationMapperXml_shouldContainDormantAccountConditions() throws Exception {
|
||||
String xml = Files.readString(Path.of("src/main/resources/mapper/ccdi/project/CcdiBankTagAnalysisMapper.xml"));
|
||||
|
||||
assertTrue(xml.contains("select id=\"selectDormantAccountLargeActivationObjects\""));
|
||||
assertTrue(xml.contains("ai.owner_type = 'EMPLOYEE'"));
|
||||
assertTrue(xml.contains("ai.status = 1"));
|
||||
assertTrue(xml.contains("ai.effective_date is not null"));
|
||||
assertTrue(xml.contains("DATE_ADD(ai.effective_date, INTERVAL 6 MONTH)"));
|
||||
assertTrue(xml.contains("windowTotalAmount >= 500000") || xml.contains("windowMaxSingleAmount >= 100000"));
|
||||
}
|
||||
|
||||
private CcdiBankTagRule buildRule(String modelCode, String modelName, String ruleCode, String ruleName, String resultType) {
|
||||
CcdiBankTagRule rule = new CcdiBankTagRule();
|
||||
rule.setModelCode(modelCode);
|
||||
|
||||
Reference in New Issue
Block a user