|
|
@@ -533,27 +533,9 @@ class InstitutionService:
|
|
|
log.error(f"支付宝接口调用失败: {result.code} - {result.msg}")
|
|
|
raise CustomException(msg=f"编辑费控制度失败: {result.msg}")
|
|
|
|
|
|
- # 第2步:同步适用员工范围
|
|
|
applicable_scope = raw_data.get("applicable_scope", "")
|
|
|
- if applicable_scope and applicable_scope not in ("NONE", "none"):
|
|
|
- ADAPTER_MAP = {"all": "EMPLOYEE_ALL", "employee": "EMPLOYEE_SELECT", "department": "DEPARTMENT_SELECT"}
|
|
|
- mapped = ADAPTER_MAP.get(applicable_scope, applicable_scope)
|
|
|
- scope_payload = {
|
|
|
- "enterprise_id": enterprise_id,
|
|
|
- "adapter_type": mapped,
|
|
|
- "owner_type": "ENTERPRISE_PAY_UID",
|
|
|
- }
|
|
|
- if applicable_scope == "employee" and raw_data.get("scope_owner_id_list"):
|
|
|
- scope_payload["add_owner_id_list"] = raw_data["scope_owner_id_list"]
|
|
|
- try:
|
|
|
- await InstitutionScopeService.scope_modify_service(
|
|
|
- auth=auth, institution_id=institution_id, data=scope_payload
|
|
|
- )
|
|
|
- log.info(f"适用员工范围已同步: {applicable_scope}")
|
|
|
- except Exception as e:
|
|
|
- log.warning(f"适用员工范围同步失败(不影响主流程): {e}")
|
|
|
|
|
|
- # 第3步:同步更新本地数据库
|
|
|
+ # 第2步:同步更新本地数据库(scope 已在 Alipay modify 请求中通过 modify_scope_info 处理)
|
|
|
try:
|
|
|
crud = InstitutionCRUD(auth)
|
|
|
update_data = {}
|
|
|
@@ -574,6 +556,11 @@ class InstitutionService:
|
|
|
update_data['effective_end_date'] = data.effective_end_date
|
|
|
if applicable_scope:
|
|
|
update_data['applicable_scope'] = applicable_scope
|
|
|
+ # 同步额外配置字段
|
|
|
+ for field in ("grant_mode", "period_type", "amount", "single_limit", "effective_time_type", "expense_type"):
|
|
|
+ val = raw_data.get(field)
|
|
|
+ if val is not None:
|
|
|
+ update_data[field] = val
|
|
|
|
|
|
if update_data:
|
|
|
await crud.update_by_institution_id(institution_id, update_data)
|