修复Mock流水按数据库员工及亲属绑定身份证

This commit is contained in:
wkc
2026-03-19 16:07:28 +08:00
parent 627886f711
commit 0457c8f3a6
12 changed files with 426 additions and 34 deletions

View File

@@ -5,8 +5,8 @@ import uuid
from datetime import datetime, timedelta
from services.statement_rule_samples import (
IDENTITY_CARD_POOL,
build_large_transaction_seed_statements,
resolve_identity_cards,
)
# 配置日志
@@ -39,6 +39,7 @@ class StatementService:
log_id: int,
primary_enterprise_name: str,
primary_account_no: str,
allowed_identity_cards: tuple,
rng: random.Random,
) -> Dict:
"""生成单条随机噪声流水记录。"""
@@ -87,7 +88,7 @@ class StatementService:
"crAmount": cr_amount,
"createDate": reference_now.strftime("%Y-%m-%d %H:%M:%S"),
"createdBy": "902001",
"cretNo": rng.choice(IDENTITY_CARD_POOL),
"cretNo": rng.choice(allowed_identity_cards),
"currency": "CNY",
"customerAccountMaskNo": str(rng.randint(100000000, 999999999)),
"customerBank": "",
@@ -140,12 +141,19 @@ class StatementService:
def _generate_statements(self, group_id: int, log_id: int, count: int) -> List[Dict]:
"""生成指定数量的流水记录。"""
primary_enterprise_name, primary_account_no = self._resolve_primary_binding(log_id)
record = self.file_service.get_file_record(log_id) if self.file_service is not None else None
if record is not None and record.staff_id_card:
allowed_identity_cards = tuple([record.staff_id_card, *record.family_id_cards])
else:
allowed_identity_cards = resolve_identity_cards(log_id)
rng = random.Random(f"statement:{log_id}")
seeded_statements = build_large_transaction_seed_statements(
group_id=group_id,
log_id=log_id,
primary_enterprise_name=primary_enterprise_name,
primary_account_no=primary_account_no,
staff_id_card=record.staff_id_card if record is not None else None,
family_id_cards=record.family_id_cards if record is not None else None,
)
total_count = max(count, len(seeded_statements))
@@ -157,6 +165,7 @@ class StatementService:
log_id,
primary_enterprise_name,
primary_account_no,
allowed_identity_cards,
rng,
)
)