Просмотр исходного кода

fix: 日期字符串转datetime + 替换 to_alipay_dict

alphah 2 недель назад
Родитель
Сommit
acdf92a045
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      backend/app/plugin/module_payment/expense/institution/service.py

+ 14 - 3
backend/app/plugin/module_payment/expense/institution/service.py

@@ -1,4 +1,5 @@
 import asyncio
+from datetime import datetime
 
 from app.api.v1.module_system.auth.schema import AuthSchema
 from app.core.alipay import AlipayClient
@@ -355,7 +356,15 @@ class InstitutionService:
                 result.parse_response_content(response)
 
                 if result.is_success():
-                    result_dict = result.to_alipay_dict()
+                    result_dict = {k: getattr(result, k) for k in (
+                        "adapter_type", "consult_mode", "currency", "effective",
+                        "effective_end_date", "effective_start_date", "expense_type",
+                        "institution_desc", "institution_id", "institution_name",
+                        "issue_rule_info_list", "multi_employee_share_mode",
+                        "outer_source_id", "owner_id_list", "owner_open_id_list",
+                        "owner_type", "scene_type", "standard_info_detail_list",
+                        "standard_info_list",
+                    ) if getattr(result, k, None) is not None}
 
             if not result_dict:
                 log.warning("支付宝 detailinfo.query 失败,降级到本地DB")
@@ -577,9 +586,11 @@ class InstitutionService:
                     else InstitutionStatusEnum.INSTITUTION_INVALID.value
                 )
             if hasattr(data, 'effective_start_date') and data.effective_start_date:
-                update_data['effective_start_date'] = data.effective_start_date
+                val = data.effective_start_date
+                update_data['effective_start_date'] = datetime.fromisoformat(val.replace(' ', 'T')) if isinstance(val, str) else val
             if hasattr(data, 'effective_end_date') and data.effective_end_date:
-                update_data['effective_end_date'] = data.effective_end_date
+                val = data.effective_end_date
+                update_data['effective_end_date'] = datetime.fromisoformat(val.replace(' ', 'T')) if isinstance(val, str) else val
             if applicable_scope:
                 update_data['applicable_scope'] = applicable_scope
             # 同步额外配置字段