-- 项目40大额交易测试流水初始化脚本
SET NAMES utf8mb4;
-- 依赖默认参数：
-- SINGLE_TRANSACTION_AMOUNT = 100000
-- CUMULATIVE_TRANSACTION_AMOUNT = 50000001
-- annual_turnover = 50000001
-- LARGE_CASH_DEPOSIT = 2000001
-- FREQUENT_CASH_DEPOSIT = 5
-- FREQUENT_TRANSFER = 100001

DELETE FROM ccdi_bank_statement
WHERE project_id = 40;

INSERT INTO ccdi_bank_statement (
    project_id, LE_ID, ACCOUNT_ID, group_id,
    LE_ACCOUNT_NAME, LE_ACCOUNT_NO, ACCOUNTING_DATE_ID, ACCOUNTING_DATE,
    TRX_DATE, CURRENCY, AMOUNT_DR, AMOUNT_CR, AMOUNT_BALANCE,
    CASH_TYPE, CUSTOMER_LE_ID, CUSTOMER_ACCOUNT_NAME, CUSTOMER_ACCOUNT_NO,
    customer_bank, customer_reference, USER_MEMO, BANK_COMMENTS,
    BANK_TRX_NUMBER, BANK, TRX_FLAG, TRX_TYPE, EXCEPTION_TYPE,
    internal_flag, batch_id, batch_sequence, CREATE_DATE, created_by,
    meta_json, no_balance, begin_balance, end_balance,
    override_bs_id, payment_method, cret_no
) VALUES
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400001, '2026-03-01', '2026-03-01 10:12:00', 'CNY', 680000.00, 0.00, 5420000.00, '对公转账', 0, '杭州贝壳房地产经纪有限公司', '913301001234000001', '中国银行杭州分行', '', '购买房产首付款', '购买房产首付款', 'P40-0001', 'BOC', '0', 0, '', 0, 40001, 1, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000102, 40, '模型测试家属', '6222024000000002', 400002, '2026-03-02', '2026-03-02 11:05:00', 'CNY', 258000.00, 0.00, 3165000.00, '对私转账', 0, '兰溪星耀汽车销售服务有限公司', '913307811234000002', '工商银行兰溪支行', '', '购车首付款', '购车首付款', 'P40-0002', 'ICBC', '0', 0, '', 0, 40001, 2, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101199001010022'),
    (40, 0, 4000103, 40, '模型二测试员工', '6222024000000003', 400003, '2026-03-03', '2026-03-03 09:15:00', 'CNY', 52000.00, 0.00, 4680000.00, '税费缴纳', 0, '国家金库兰溪支库', 'TG000000000000003', '中国建设银行兰溪支行', '', '个人所得税税款', '个人所得税税款', 'P40-0003', 'CCB', '0', 0, '', 0, 40001, 3, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198802020033'),
    (40, 0, 4000104, 40, '模型二测试家属', '6222024000000004', 400004, '2026-03-04', '2026-03-04 14:40:00', 'CNY', 18800.00, 0.00, 2230000.00, '税费缴纳', 0, '兰溪市税务局第一税务分局', 'TG000000000000004', '农业银行兰溪支行', '', '房产税务缴税', '房产税务缴税', 'P40-0004', 'ABC', '0', 0, '', 0, 40001, 4, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101199202020044'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400005, '2026-03-05', '2026-03-05 13:25:00', 'CNY', 0.00, 188000.00, 5608000.00, '来账', 0, '杭州启明咨询有限公司', '913301001234000005', '招商银行杭州分行', '', '项目合作分成', '项目合作分成', 'P40-0005', 'CMB', '0', 0, '', 0, 40001, 5, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000103, 40, '模型二测试员工', '6222024000000003', 400006, '2025-11-18', '2025-11-18 10:08:00', 'CNY', 0.00, 20500000.00, 25180000.00, '来账', 0, '浙江远望贸易有限公司', '913300001234000006', '交通银行杭州分行', '', '经营往来收入', '经营往来收入', 'P40-0006', 'BCM', '0', 0, '', 0, 40001, 6, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198802020033'),
    (40, 0, 4000103, 40, '模型二测试员工', '6222024000000003', 400007, '2026-01-15', '2026-01-15 15:18:00', 'CNY', 0.00, 20000000.00, 45180000.00, '来账', 0, '浙江远望贸易有限公司', '913300001234000006', '交通银行杭州分行', '', '经营往来收入', '经营往来收入', 'P40-0007', 'BCM', '0', 0, '', 0, 40001, 7, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198802020033'),
    (40, 0, 4000103, 40, '模型二测试员工', '6222024000000003', 400008, '2026-02-20', '2026-02-20 16:22:00', 'CNY', 0.00, 19800000.00, 64980000.00, '来账', 0, '浙江远望贸易有限公司', '913300001234000006', '交通银行杭州分行', '', '经营往来收入', '经营往来收入', 'P40-0008', 'BCM', '0', 0, '', 0, 40001, 8, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198802020033'),
    (40, 0, 4000103, 40, '模型二测试员工', '6222024000000003', 400009, '2026-02-25', '2026-02-25 11:41:00', 'CNY', 8000000.00, 0.00, 56980000.00, '对公转账', 0, '浙江腾越供应链有限公司', '913300001234000009', '中国银行义乌支行', '', '材料采购转账', '材料采购转账', 'P40-0009', 'BOC', '0', 0, '', 0, 40001, 9, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198802020033'),
    (40, 0, 4000103, 40, '模型二测试员工', '6222024000000003', 400010, '2026-03-06', '2026-03-06 12:05:00', 'CNY', 6000000.00, 0.00, 50980000.00, '对公转账', 0, '杭州诚誉科技有限公司', '913301001234000010', '宁波银行杭州分行', '', '服务采购转账', '服务采购转账', 'P40-0010', 'NBCB', '0', 0, '', 0, 40001, 10, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198802020033'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400011, '2026-03-10', '2026-03-10 09:00:00', 'CNY', 0.00, 2500000.00, 7598000.00, '现金存款', 0, '', '', '兰溪农商行营业部', '', '柜面现金存款', '柜面现金存款', 'P40-0011', 'LXNRCB', '0', 0, '', 0, 40001, 11, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400012, '2026-03-10', '2026-03-10 09:20:00', 'CNY', 0.00, 2100000.00, 9698000.00, '现金存款', 0, '', '', '兰溪农商行营业部', '', 'ATM现金存款', 'ATM现金存款', 'P40-0012', 'LXNRCB', '0', 0, '', 0, 40001, 12, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400013, '2026-03-10', '2026-03-10 10:05:00', 'CNY', 0.00, 2200000.00, 11898000.00, '现金存款', 0, '', '', '兰溪农商行营业部', '', '自助存款现金存入', '自助存款现金存入', 'P40-0013', 'LXNRCB', '0', 0, '', 0, 40001, 13, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400014, '2026-03-10', '2026-03-10 11:16:00', 'CNY', 0.00, 2300000.00, 14198000.00, '现金存款', 0, '', '', '兰溪农商行营业部', '', '柜面现金存款', '柜面现金存款', 'P40-0014', 'LXNRCB', '0', 0, '', 0, 40001, 14, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400015, '2026-03-10', '2026-03-10 13:02:00', 'CNY', 0.00, 2400000.00, 16598000.00, '现金存款', 0, '', '', '兰溪农商行营业部', '', 'CRS存款', 'CRS存款', 'P40-0015', 'LXNRCB', '0', 0, '', 0, 40001, 15, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400016, '2026-03-10', '2026-03-10 15:08:00', 'CNY', 0.00, 2350000.00, 18948000.00, '现金存款', 0, '', '', '兰溪农商行营业部', '', '本行ATM存款', '本行ATM存款', 'P40-0016', 'LXNRCB', '0', 0, '', 0, 40001, 16, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000103, 40, '模型二测试员工', '6222024000000003', 400017, '2026-03-11', '2026-03-11 10:33:00', 'CNY', 360000.00, 0.00, 50620000.00, '转账', 0, '杭州弘信商贸有限公司', '913301001234000017', '浦发银行杭州分行', '', '手机银行转账', '手机银行转账', 'P40-0017', 'SPDB', '0', 0, '', 0, 40001, 17, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198802020033'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400018, '2026-03-12', '2026-03-12 08:30:00', 'CNY', 0.00, 15000.00, 18963000.00, '代发工资', 0, '浙江兰溪农村商业银行股份有限公司', 'PAYROLL0000000018', '兰溪农商行营业部', '', '代发工资', '代发工资', 'P40-0018', 'LXNRCB', '0', 0, '', 0, 40001, 18, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000101, 40, '模型测试员工', '6222024000000001', 400019, '2026-03-12', '2026-03-12 18:15:00', 'CNY', 368.00, 0.00, 18962632.00, '消费', 0, '兰溪市银泰超市', 'SHOP000000000019', '工商银行兰溪支行', '', '超市消费', '超市消费', 'P40-0019', 'ICBC', '0', 0, '', 0, 40001, 19, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198801010011'),
    (40, 0, 4000102, 40, '模型测试家属', '6222024000000002', 400020, '2026-03-13', '2026-03-13 19:10:00', 'CNY', 220.00, 0.00, 3164780.00, '生活缴费', 0, '兰溪市供电公司', 'UTIL000000000020', '建设银行兰溪支行', '', '水电费', '水电费', 'P40-0020', 'CCB', '0', 0, '', 0, 40001, 20, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101199001010022'),
    (40, 0, 4000103, 40, '模型二测试员工', '6222024000000003', 400021, '2026-03-14', '2026-03-14 09:55:00', 'CNY', 0.00, 500000.00, 51120000.00, '内部划转', 0, '模型二测试员工', 'SELF000000000021', '兰溪农商行营业部', '', '本人账户划转', '本人账户划转', 'P40-0021', 'LXNRCB', '0', 0, '', 0, 40001, 21, '2026-03-16 16:00:00', 1, NULL, 0, 0, 0, 0, NULL, '330101198802020033');

SELECT 'project_40_total' AS check_name, COUNT(*) AS hit_count
FROM ccdi_bank_statement
WHERE project_id = 40;

SELECT 'house_or_car_expense' AS check_name, COUNT(*) AS hit_count
FROM (
    SELECT t2.bank_statement_id
    FROM ccdi_base_staff t1
    INNER JOIN ccdi_bank_statement t2 ON t1.id_card = t2.cret_no
    WHERE t2.project_id = 40
      AND (
        t2.user_memo LIKE '%购%房%'
        OR t2.user_memo LIKE '%买%房%'
        OR t2.user_memo LIKE '%购%车%'
        OR t2.user_memo LIKE '%买%车%'
        OR t2.user_memo LIKE '%车款%'
        OR t2.user_memo LIKE '%房款%'
        OR t2.user_memo LIKE '%首付%'
        OR t2.user_memo LIKE '%房贷%'
        OR t2.user_memo LIKE '%车贷%'
        OR t2.customer_account_name LIKE '%汽车销售%'
        OR t2.customer_account_name LIKE '%汽车金融%'
        OR t2.customer_account_name LIKE '%4S店%'
        OR t2.customer_account_name LIKE '%汽贸%'
        OR t2.customer_account_name LIKE '%车行%'
        OR t2.customer_account_name LIKE '%房地产%'
        OR t2.customer_account_name LIKE '%置业%'
        OR t2.customer_account_name LIKE '%置地%'
        OR t2.customer_account_name LIKE '%地产%'
        OR t2.customer_account_name LIKE '%房产%'
        OR t2.customer_account_name LIKE '%不动产%'
        OR t2.customer_account_name LIKE '%链家%'
        OR t2.customer_account_name LIKE '%贝壳%'
        OR t2.customer_account_name LIKE '%我爱我家%'
        OR t2.customer_account_name LIKE '%房管局%'
      )
      AND t2.amount_dr > 0
    UNION ALL
    SELECT t2.bank_statement_id
    FROM ccdi_staff_fmy_relation t1
    INNER JOIN ccdi_bank_statement t2 ON t1.relation_cert_no = t2.cret_no
    WHERE t1.status = 1
      AND t2.project_id = 40
      AND (
        t2.user_memo LIKE '%购%房%'
        OR t2.user_memo LIKE '%买%房%'
        OR t2.user_memo LIKE '%购%车%'
        OR t2.user_memo LIKE '%买%车%'
        OR t2.user_memo LIKE '%车款%'
        OR t2.user_memo LIKE '%房款%'
        OR t2.user_memo LIKE '%首付%'
        OR t2.user_memo LIKE '%房贷%'
        OR t2.user_memo LIKE '%车贷%'
        OR t2.customer_account_name LIKE '%汽车销售%'
        OR t2.customer_account_name LIKE '%汽车金融%'
        OR t2.customer_account_name LIKE '%4S店%'
        OR t2.customer_account_name LIKE '%汽贸%'
        OR t2.customer_account_name LIKE '%车行%'
        OR t2.customer_account_name LIKE '%房地产%'
        OR t2.customer_account_name LIKE '%置业%'
        OR t2.customer_account_name LIKE '%置地%'
        OR t2.customer_account_name LIKE '%地产%'
        OR t2.customer_account_name LIKE '%房产%'
        OR t2.customer_account_name LIKE '%不动产%'
        OR t2.customer_account_name LIKE '%链家%'
        OR t2.customer_account_name LIKE '%贝壳%'
        OR t2.customer_account_name LIKE '%我爱我家%'
        OR t2.customer_account_name LIKE '%房管局%'
      )
      AND t2.amount_dr > 0
) s;

SELECT 'tax_expense' AS check_name, COUNT(*) AS hit_count
FROM (
    SELECT t2.bank_statement_id
    FROM ccdi_base_staff t1
    INNER JOIN ccdi_bank_statement t2 ON t1.id_card = t2.cret_no
    WHERE t2.project_id = 40
      AND (
        t2.user_memo LIKE '%税务%'
        OR t2.user_memo LIKE '%缴税%'
        OR t2.user_memo LIKE '%税款%'
        OR t2.customer_account_name LIKE '%税务%'
        OR t2.customer_account_name LIKE '%税务局%'
        OR t2.customer_account_name LIKE '%国库%'
        OR t2.customer_account_name LIKE '%国家金库%'
        OR t2.customer_account_name LIKE '%财政%'
      )
      AND t2.amount_dr > 0
    UNION ALL
    SELECT t2.bank_statement_id
    FROM ccdi_staff_fmy_relation t1
    INNER JOIN ccdi_bank_statement t2 ON t1.relation_cert_no = t2.cret_no
    WHERE t1.status = 1
      AND t2.project_id = 40
      AND (
        t2.user_memo LIKE '%税务%'
        OR t2.user_memo LIKE '%缴税%'
        OR t2.user_memo LIKE '%税款%'
        OR t2.customer_account_name LIKE '%税务%'
        OR t2.customer_account_name LIKE '%税务局%'
        OR t2.customer_account_name LIKE '%国库%'
        OR t2.customer_account_name LIKE '%国家金库%'
        OR t2.customer_account_name LIKE '%财政%'
      )
      AND t2.amount_dr > 0
) s;

SELECT 'single_large_income' AS check_name, COUNT(*) AS hit_count
FROM (
    SELECT t2.bank_statement_id
    FROM ccdi_base_staff t1
    INNER JOIN ccdi_bank_statement t2 ON t1.id_card = t2.cret_no
    LEFT JOIN ccdi_staff_fmy_relation t3
      ON t1.id_card = t3.person_id
     AND t2.customer_account_name = t3.relation_name
    WHERE t2.project_id = 40
      AND t2.le_account_name <> t2.customer_account_name
      AND NOT (
        t2.customer_account_name = '浙江兰溪农村商业银行股份有限公司'
        AND (
          t2.user_memo LIKE '%代发%'
          OR t2.user_memo LIKE '%工资%'
          OR t2.user_memo LIKE '%奖金%'
          OR t2.user_memo LIKE '%薪酬%'
          OR t2.user_memo LIKE '%薪金%'
          OR t2.user_memo LIKE '%补贴%'
          OR t2.user_memo LIKE '%薪%'
          OR t2.user_memo LIKE '%年终奖%'
          OR t2.user_memo LIKE '%年金%'
          OR t2.user_memo LIKE '%加班费%'
          OR t2.user_memo LIKE '%劳务费%'
          OR t2.user_memo LIKE '%劳务外包%'
          OR t2.user_memo LIKE '%提成%'
          OR t2.user_memo LIKE '%劳务派遣%'
          OR t2.user_memo LIKE '%绩效%'
          OR t2.user_memo LIKE '%酬劳%'
          OR t2.cash_type LIKE '%代发%'
          OR t2.cash_type LIKE '%工资%'
          OR t2.cash_type LIKE '%劳务费%'
        )
      )
      AND t2.amount_cr > 100000
      AND t3.person_id IS NULL
) s;

SELECT 'cumulative_large_income' AS check_name, COUNT(*) AS hit_count
FROM (
    SELECT t1.id_card, t2.customer_account_name, SUM(t2.amount_cr) AS sum_amount_cr
    FROM ccdi_base_staff t1
    INNER JOIN ccdi_bank_statement t2 ON t1.id_card = t2.cret_no
    LEFT JOIN ccdi_staff_fmy_relation t3
      ON t1.id_card = t3.person_id
     AND t2.customer_account_name = t3.relation_name
    WHERE t2.project_id = 40
      AND t2.le_account_name <> t2.customer_account_name
      AND NOT (
        t2.customer_account_name = '浙江兰溪农村商业银行股份有限公司'
        AND (
          t2.user_memo LIKE '%代发%'
          OR t2.user_memo LIKE '%工资%'
          OR t2.cash_type LIKE '%代发%'
          OR t2.cash_type LIKE '%工资%'
        )
      )
      AND t2.amount_cr > 0
      AND t3.person_id IS NULL
    GROUP BY t1.id_card, t2.customer_account_name
    HAVING SUM(t2.amount_cr) > 50000001
) s;

SELECT 'annual_turnover' AS check_name, COUNT(*) AS hit_count
FROM (
    SELECT t1.id_card, SUM(t2.amount_dr + t2.amount_cr) AS annual_trans_amount
    FROM ccdi_base_staff t1
    INNER JOIN ccdi_bank_statement t2 ON t1.id_card = t2.cret_no
    WHERE t2.project_id = 40
      AND STR_TO_DATE(LEFT(t2.TRX_DATE, 10), '%Y-%m-%d') >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
      AND t2.le_account_name <> t2.customer_account_name
    GROUP BY t1.id_card
    HAVING SUM(t2.amount_dr + t2.amount_cr) > 50000001
) s;

SELECT 'large_cash_deposit' AS check_name, COUNT(*) AS hit_count
FROM (
    SELECT t2.bank_statement_id
    FROM ccdi_base_staff t1
    INNER JOIN ccdi_bank_statement t2 ON t1.id_card = t2.cret_no
    WHERE t2.project_id = 40
      AND t2.amount_cr > 2000001
      AND (
        (
          (
            (t2.user_memo LIKE '%现金%' AND t2.user_memo NOT LIKE '%金管理%' AND t2.user_memo NOT LIKE '%金添利%' AND t2.user_memo NOT LIKE '%现金利%' AND t2.user_memo NOT LIKE '%现金宝%' AND t2.user_memo NOT LIKE '%金分析%')
            OR t2.user_memo LIKE '%存现%'
            OR t2.user_memo LIKE '%现存%'
            OR t2.cash_type LIKE '%现金%'
            OR t2.cash_type LIKE '%存现%'
            OR t2.cash_type LIKE '%现存%'
            OR t2.cash_type LIKE '%金存入%'
            OR t2.user_memo LIKE '%金存入%'
            OR (t2.user_memo LIKE '%ATM%' AND (t2.user_memo LIKE '%存款%' OR t2.user_memo LIKE '%转入%'))
            OR (t2.cash_type LIKE '%ATM%' AND (t2.cash_type LIKE '%存款%' OR t2.cash_type LIKE '%转入%'))
          )
          AND (t2.customer_account_name = '' OR t2.customer_account_name = '无' OR t2.customer_account_name LIKE '%存现%')
        )
        OR t2.user_memo LIKE '%DEPOSIT%'
        OR (
          t2.customer_account_name = '库存现金'
          OR (((t2.user_memo LIKE '%现金存款%' OR t2.user_memo LIKE '%自助存款%' OR t2.user_memo LIKE '%CRS存款%' OR t2.cash_type LIKE '%现金存款%' OR t2.cash_type LIKE '%自助存款%' OR t2.cash_type LIKE '%本行CRS存款%' OR t2.cash_type LIKE '%柜面%' OR t2.user_memo LIKE '%柜面%') AND t2.customer_account_name = ''))
          OR (t2.customer_account_name = '现金' AND t2.user_memo NOT LIKE '%借款%')
          OR t2.user_memo LIKE '%本行ATM%'
        )
      )
) s;

SELECT 'frequent_cash_deposit' AS check_name, COUNT(*) AS hit_count
FROM (
    SELECT t1.id_card, LEFT(t2.trx_date, 10) AS cash_trans_date, COUNT(1) AS cash_count
    FROM ccdi_base_staff t1
    INNER JOIN ccdi_bank_statement t2 ON t1.id_card = t2.cret_no
    WHERE t2.project_id = 40
      AND t2.amount_cr > 2000001
      AND (
        (
          (
            (t2.user_memo LIKE '%现金%' AND t2.user_memo NOT LIKE '%金管理%' AND t2.user_memo NOT LIKE '%金添利%' AND t2.user_memo NOT LIKE '%现金利%' AND t2.user_memo NOT LIKE '%现金宝%' AND t2.user_memo NOT LIKE '%金分析%')
            OR t2.user_memo LIKE '%存现%'
            OR t2.user_memo LIKE '%现存%'
            OR t2.cash_type LIKE '%现金%'
            OR t2.cash_type LIKE '%存现%'
            OR t2.cash_type LIKE '%现存%'
            OR t2.cash_type LIKE '%金存入%'
            OR t2.user_memo LIKE '%金存入%'
            OR (t2.user_memo LIKE '%ATM%' AND (t2.user_memo LIKE '%存款%' OR t2.user_memo LIKE '%转入%'))
            OR (t2.cash_type LIKE '%ATM%' AND (t2.cash_type LIKE '%存款%' OR t2.cash_type LIKE '%转入%'))
          )
          AND (t2.customer_account_name = '' OR t2.customer_account_name = '无' OR t2.customer_account_name LIKE '%存现%')
        )
        OR t2.user_memo LIKE '%DEPOSIT%'
        OR (
          t2.customer_account_name = '库存现金'
          OR (((t2.user_memo LIKE '%现金存款%' OR t2.user_memo LIKE '%自助存款%' OR t2.user_memo LIKE '%CRS存款%' OR t2.cash_type LIKE '%现金存款%' OR t2.cash_type LIKE '%自助存款%' OR t2.cash_type LIKE '%本行CRS存款%' OR t2.cash_type LIKE '%柜面%' OR t2.user_memo LIKE '%柜面%') AND t2.customer_account_name = ''))
          OR (t2.customer_account_name = '现金' AND t2.user_memo NOT LIKE '%借款%')
          OR t2.user_memo LIKE '%本行ATM%'
        )
      )
    GROUP BY t1.id_card, LEFT(t2.trx_date, 10)
    HAVING COUNT(1) > 5
) s;

SELECT 'large_transfer' AS check_name, COUNT(*) AS hit_count
FROM (
    SELECT t2.bank_statement_id
    FROM ccdi_base_staff t1
    INNER JOIN ccdi_bank_statement t2 ON t1.id_card = t2.cret_no
    WHERE t2.project_id = 40
      AND t2.amount_dr > 100001
      AND (
        t2.customer_account_name LIKE '%转账%'
        OR t2.user_memo LIKE '%转帐%'
        OR t2.user_memo LIKE '%转账%'
        OR t2.user_memo LIKE '%汇入%'
        OR t2.user_memo LIKE '%转存%'
        OR t2.user_memo LIKE '%红包%'
        OR t2.user_memo LIKE '%汇款%'
        OR t2.user_memo LIKE '%网转%'
        OR t2.user_memo LIKE '%转入%'
        OR t2.cash_type LIKE '%转帐%'
        OR t2.cash_type LIKE '%转账%'
        OR t2.cash_type LIKE '%汇入%'
        OR t2.cash_type LIKE '%转存%'
        OR t2.cash_type LIKE '%红包%'
        OR t2.cash_type LIKE '%汇款%'
        OR t2.cash_type LIKE '%网转%'
        OR t2.cash_type LIKE '%转入%'
      )
      AND t2.user_memo NOT LIKE '%款%'
      AND t2.le_account_name <> t2.customer_account_name
) s;
