|
|
@@ -321,6 +321,8 @@ def _party_to_dict(p: BizResearchDonationParty) -> Dict[str, Any]:
|
|
|
"id": p.id,
|
|
|
"researchDonationId": p.research_donation_id,
|
|
|
"customerId": p.customer_id or "",
|
|
|
+ "fatherCustomerId": p.father_customer_id or "",
|
|
|
+ "newbornCustomerId": p.newborn_customer_id or "",
|
|
|
"motherName": p.mother_name or "",
|
|
|
"motherPhone": p.mother_phone or "",
|
|
|
"motherIdCard": p.mother_id_card or "",
|
|
|
@@ -955,7 +957,10 @@ def create_donation(
|
|
|
donation_id = obj.id
|
|
|
|
|
|
# party
|
|
|
+ from app.services.party_customer_sync import sync_party_customers
|
|
|
+
|
|
|
party_raw = _normalize_fields(raw.get("party") or {})
|
|
|
+ party_raw = sync_party_customers(db, party_raw, tenant_no=tenant_no, user_id=user_id or "")
|
|
|
_create_party(db, donation_id, tenant_no, user_id, party_raw, now)
|
|
|
|
|
|
# collection
|
|
|
@@ -1039,8 +1044,11 @@ def update_donation(
|
|
|
|
|
|
# party upsert: 软删旧 → 创建新
|
|
|
if "party" in raw:
|
|
|
+ from app.services.party_customer_sync import sync_party_customers
|
|
|
+
|
|
|
_soft_delete_party(db, donation_id, tenant_no, user_id)
|
|
|
party_raw = _normalize_fields(raw["party"] or {})
|
|
|
+ party_raw = sync_party_customers(db, party_raw, tenant_no=tenant_no, user_id=user_id or "")
|
|
|
_create_party(db, donation_id, tenant_no, user_id, party_raw, now)
|
|
|
|
|
|
# collection upsert
|
|
|
@@ -1480,6 +1488,8 @@ def convert_from_storage(
|
|
|
id=generate_uuid(),
|
|
|
research_donation_id=did,
|
|
|
customer_id=src_party.customer_id,
|
|
|
+ father_customer_id=getattr(src_party, "father_customer_id", None),
|
|
|
+ newborn_customer_id=getattr(src_party, "newborn_customer_id", None),
|
|
|
mother_name=src_party.mother_name,
|
|
|
mother_phone=src_party.mother_phone,
|
|
|
mother_id_card=src_party.mother_id_card,
|
|
|
@@ -1724,6 +1734,8 @@ def convert_to_storage(
|
|
|
id=generate_uuid(),
|
|
|
collection_protocol_id=pid,
|
|
|
customer_id=src_party.customer_id,
|
|
|
+ father_customer_id=getattr(src_party, "father_customer_id", None),
|
|
|
+ newborn_customer_id=getattr(src_party, "newborn_customer_id", None),
|
|
|
mother_name=src_party.mother_name,
|
|
|
mother_phone=src_party.mother_phone,
|
|
|
mother_id_card=src_party.mother_id_card,
|
|
|
@@ -1863,7 +1875,8 @@ def convert_to_storage(
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
_PARTY_STR_FIELDS = [
|
|
|
- "customer_id", "mother_name", "mother_phone", "mother_id_card",
|
|
|
+ "customer_id", "father_customer_id", "newborn_customer_id",
|
|
|
+ "mother_name", "mother_phone", "mother_id_card",
|
|
|
"mother_birth_ym", "mother_ethnic", "mother_email", "mother_address",
|
|
|
"father_name", "father_phone", "father_id_card",
|
|
|
"newborn_name", "newborn_id_card", "newborn_sex",
|