controller.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. from typing import Annotated
  2. import uuid
  3. from fastapi import APIRouter, Depends, Path, Query
  4. from fastapi.responses import JSONResponse
  5. from app.api.v1.module_system.auth.schema import AuthSchema
  6. from app.common.response import ResponseSchema, SuccessResponse
  7. from app.core.dependencies import AuthPermission
  8. from app.core.logger import log
  9. from app.core.router_class import OperationLogRoute
  10. from app.plugin.module_payment.expense.institution.schema import InstitutionListOutSchema
  11. from .service import InstitutionService, InstitutionScopeService, IssueruleService
  12. from alipay.aop.api.domain.AlipayEbppInvoiceInstitutionCreateModel import (
  13. AlipayEbppInvoiceInstitutionCreateModel,
  14. )
  15. from alipay.aop.api.response.AlipayEbppInvoiceInstitutionCreateResponse import (
  16. AlipayEbppInvoiceInstitutionCreateResponse,
  17. )
  18. from alipay.aop.api.domain.AlipayEbppInvoiceInstitutionDeleteModel import (
  19. AlipayEbppInvoiceInstitutionDeleteModel,
  20. )
  21. from alipay.aop.api.response.AlipayEbppInvoiceInstitutionDeleteResponse import (
  22. AlipayEbppInvoiceInstitutionDeleteResponse,
  23. )
  24. from alipay.aop.api.domain.AlipayEbppInvoiceInstitutionModifyModel import (
  25. AlipayEbppInvoiceInstitutionModifyModel,
  26. )
  27. from alipay.aop.api.response.AlipayEbppInvoiceInstitutionModifyResponse import (
  28. AlipayEbppInvoiceInstitutionModifyResponse,
  29. )
  30. InstitutionRouter = APIRouter(
  31. route_class=OperationLogRoute,
  32. prefix="/institution",
  33. tags=["费控制度"],
  34. )
  35. @InstitutionRouter.post(
  36. "",
  37. summary="创建费控制度",
  38. description="创建费控制度。支持串联调用:创建制度→设置成员→创建发放规则",
  39. )
  40. async def create_institution_controller(
  41. data: dict,
  42. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:create"]))],
  43. ) -> JSONResponse:
  44. """创建费控制度(含完整串联流程)"""
  45. enterprise_id = data.get("enterprise_id", "")
  46. if not enterprise_id:
  47. from app.plugin.module_payment.enterprise.model import EnterpriseModel
  48. from sqlalchemy import select
  49. tenant_id = auth.user.tenant_id if auth.user and auth.user.tenant_id else auth.tenant_id
  50. log.info(f"推导 enterprise_id: tenant_id={tenant_id}, user_tenant_id={getattr(auth.user, 'tenant_id', None)}")
  51. stmt = select(EnterpriseModel).where(EnterpriseModel.tenant_id == tenant_id).limit(1)
  52. result = await auth.db.execute(stmt)
  53. enterprise = result.scalar_one_or_none()
  54. log.info(f"查询 enterprise 结果: {enterprise.enterprise_id if enterprise else 'None'}")
  55. enterprise_id = enterprise.enterprise_id if enterprise else ""
  56. if enterprise_id:
  57. data["enterprise_id"] = enterprise_id
  58. # 字段映射:前端 name → Alipay institution_name
  59. if data.get("name") and not data.get("institution_name"):
  60. data["institution_name"] = data["name"]
  61. # Alipay 必填:商户外部单据号(唯一标识)
  62. if not data.get("outer_source_id"):
  63. data["outer_source_id"] = str(uuid.uuid4()).replace("-", "")
  64. # expense_type 映射:前端值 → 支付宝标准值
  65. EXPENSE_TYPE_MAP = {"GENERAL": "DEFAULT", "DEFAULT": "DEFAULT"}
  66. if data.get("expense_type") in EXPENSE_TYPE_MAP:
  67. data["expense_type"] = EXPENSE_TYPE_MAP[data["expense_type"]]
  68. # 时间格式补全:YYYY-MM-DD → YYYY-MM-DD HH:mm:ss
  69. if data.get("effective_start_date") and len(data["effective_start_date"]) == 10:
  70. data["effective_start_date"] = data["effective_start_date"] + " 00:00:00"
  71. if data.get("effective_end_date") and len(data["effective_end_date"]) == 10:
  72. data["effective_end_date"] = data["effective_end_date"] + " 23:59:59"
  73. elif not data.get("effective_end_date") and data.get("effective_time_type") == "unlimited":
  74. # 长期有效:设为2099年底
  75. data["effective_end_date"] = "2099-12-31 23:59:59"
  76. # 默认使用规则(支付宝必填)
  77. if not data.get("standard_info_list"):
  78. single_limit = data.get("single_limit", 0)
  79. period_type = data.get("period_type", "")
  80. amount = data.get("amount", 0)
  81. standard_info = {
  82. "standard_name": data.get("institution_name", "默认规则"),
  83. "standard_desc": f"单笔限额{single_limit}元" if single_limit else "通用规则",
  84. "consume_mode": "DEFAULT",
  85. "payment_policy": "PERSONAL",
  86. "personal_qrcode_mode": 0,
  87. "outer_source_id": str(uuid.uuid4()).replace("-", ""),
  88. }
  89. condition_list = []
  90. if single_limit:
  91. condition_list.append({"rule_factor": "QUOTA_TOTAL", "rule_name": "单次消费金额", "rule_value": str(single_limit)})
  92. # 定额发放时,将周期限额写入使用规则条件
  93. PERIOD_FACTOR_MAP = {
  94. "daily": "QUOTA_DAY", "weekly": "QUOTA_WEEK",
  95. "monthly": "QUOTA_MONTH", "quarterly": "QUOTA_QUARTER",
  96. "yearly": "QUOTA_YEAR",
  97. }
  98. if data.get("grant_mode") == "period" and period_type in PERIOD_FACTOR_MAP and amount:
  99. condition_list.append({
  100. "rule_factor": PERIOD_FACTOR_MAP[period_type],
  101. "rule_name": f"{period_type}限额",
  102. "rule_value": str(amount),
  103. })
  104. standard_info["standard_condition_info_list"] = condition_list
  105. data["standard_info_list"] = [standard_info]
  106. institution_create_model = AlipayEbppInvoiceInstitutionCreateModel.from_alipay_dict(data)
  107. # 解析适用成员数据
  108. scope_data = None
  109. adapter_type = data.get("applicable_scope")
  110. if adapter_type and adapter_type not in ("NONE", "none"):
  111. ADAPTER_TYPE_MAP = {"all": "EMPLOYEE_ALL", "employee": "EMPLOYEE_SELECT", "department": "EMPLOYEE_DEPARTMENT"}
  112. mapped_adapter = ADAPTER_TYPE_MAP.get(adapter_type, adapter_type)
  113. scope_data = {
  114. "adapter_type": mapped_adapter,
  115. "owner_type": data.get("scope_owner_type", "ENTERPRISE_PAY_UID"),
  116. "add_owner_id_list": data.get("scope_owner_id_list"),
  117. }
  118. # 全体员工时把 scope 写入创建请求(避免默认无scope导致支付宝后台不可操作)
  119. if adapter_type == "all":
  120. data["institution_scope_info"] = {
  121. "adapter_type": "ALL",
  122. "owner_type": "ENTERPRISE_PAY_UID",
  123. }
  124. # 解析发放规则数据
  125. issuerule_data = None
  126. if data.get("grant_mode") == "period":
  127. period_type_raw = data.get("period_type", "monthly")
  128. # 映射前端period_type到支付宝枚举
  129. ISSUE_TYPE_MAP = {
  130. "daily": "ISSUE_DAY",
  131. "weekly": "ISSUE_WEEK",
  132. "monthly": "ISSUE_MONTH",
  133. "quarterly": "ISSUE_QUARTER",
  134. "yearly": "ISSUE_YEAR",
  135. }
  136. issue_type = ISSUE_TYPE_MAP.get(period_type_raw, "ISSUE_MONTH")
  137. amount = data.get("amount", 0)
  138. # 有效时间配置
  139. effective_time_type = data.get("effective_time_type", "unlimited")
  140. if effective_time_type == "unlimited":
  141. effective_period = '{"all": true}'
  142. elif effective_time_type == "workday":
  143. workday_start = data.get("workday_start_time", "00:00")
  144. workday_end = data.get("workday_end_time", "23:59")
  145. effective_period = f'{{"regular":{{"workday":[["{workday_start}","{workday_end}"]]}}}}'
  146. else:
  147. effective_period = '{"all": true}'
  148. issuerule_data = {
  149. "quota_type": "CAP",
  150. "issue_type": issue_type,
  151. "issue_amount_value": str(amount),
  152. "issue_rule_name": data.get("name", "") + "-发放规则",
  153. "effective_period": effective_period,
  154. "invalid_mode": 1 if data.get("effective_time_type") == "unlimited" else 0,
  155. "share_mode": 0,
  156. "outer_source_id": data.get("outer_source_id") or str(uuid.uuid4()),
  157. }
  158. result = await InstitutionService.create_institution_full_flow(
  159. auth=auth,
  160. institution_model=institution_create_model,
  161. enterprise_id=enterprise_id,
  162. scope_data=scope_data,
  163. issuerule_data=issuerule_data,
  164. raw_data=data,
  165. )
  166. log.info(f"创建费控制度成功: institution_id={result.get('institution_id')}")
  167. return SuccessResponse(data=result, msg="创建费控制度成功")
  168. @InstitutionRouter.get(
  169. "",
  170. summary="查询费控制度列表",
  171. description="分页查询费控制度列表",
  172. response_model=ResponseSchema[InstitutionListOutSchema],
  173. )
  174. async def list_institution_controller(
  175. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:list"]))],
  176. page_no: Annotated[int, Query(description="页码")] = 1,
  177. page_size: Annotated[int, Query(description="每页数量")] = 20,
  178. enterprise_id: Annotated[str | None, Query(description="企业ID")] = None,
  179. name: Annotated[str | None, Query(description="制度名称")] = None,
  180. expense_type: Annotated[str | None, Query(description="费用类型")] = None,
  181. status: Annotated[str | None, Query(description="状态")] = None,
  182. ) -> JSONResponse:
  183. """查询费控制度列表"""
  184. search = {}
  185. if enterprise_id:
  186. search["enterprise_id"] = enterprise_id
  187. if name:
  188. search["name"] = name
  189. if expense_type:
  190. search["expense_type"] = expense_type
  191. if status:
  192. search["status"] = status
  193. result = await InstitutionService.list_service(
  194. auth=auth, page_no=page_no, page_size=page_size, search=search
  195. )
  196. return SuccessResponse(data=result, msg="查询费控制度列表成功")
  197. @InstitutionRouter.get(
  198. "/{institution_id}",
  199. summary="查询费控制度详情",
  200. description="查询费控制度详情 (alipay.ebpp.invoice.institution.detailinfo.query),失败时降级到本地DB",
  201. )
  202. async def detail_institution_controller(
  203. institution_id: Annotated[str, Path(description="制度ID")],
  204. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:detail"]))],
  205. enterprise_id: Annotated[str | None, Query(description="企业ID")] = None,
  206. ) -> JSONResponse:
  207. """查询费控制度详情"""
  208. if not enterprise_id:
  209. from app.plugin.module_payment.enterprise.model import EnterpriseModel
  210. from sqlalchemy import select
  211. tenant_id = auth.user.tenant_id if auth.user and auth.user.tenant_id else auth.tenant_id
  212. stmt = select(EnterpriseModel).where(EnterpriseModel.tenant_id == tenant_id).limit(1)
  213. result = await auth.db.execute(stmt)
  214. ent = result.scalar_one_or_none()
  215. enterprise_id = ent.enterprise_id if ent else ""
  216. result = await InstitutionService.detailinfo_query_service(
  217. auth=auth,
  218. institution_id=institution_id,
  219. enterprise_id=enterprise_id,
  220. )
  221. if result is None:
  222. return SuccessResponse(data=None, msg="制度不存在")
  223. return SuccessResponse(data=result, msg="查询费控制度详情成功")
  224. @InstitutionRouter.delete(
  225. "",
  226. summary="删除费控制度",
  227. description="删除费控制度 (alipay.ebpp.invoice.institution.delete)",
  228. )
  229. async def delete_institution_controller(
  230. data: dict,
  231. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:delete"]))],
  232. ) -> JSONResponse:
  233. """删除费控制度"""
  234. institution_delete_model = AlipayEbppInvoiceInstitutionDeleteModel.from_alipay_dict(data)
  235. result = await InstitutionService.delete_institution_service(auth=auth, data=institution_delete_model)
  236. log.info(f"删除费控制度成功: institution_id={institution_delete_model.institution_id}, enterprise_id={institution_delete_model.enterprise_id}")
  237. return SuccessResponse(data=result, msg="删除费控制度成功")
  238. @InstitutionRouter.post(
  239. "/modify",
  240. summary="编辑费控制度",
  241. description="编辑费控制度 (alipay.ebpp.invoice.institution.modify)",
  242. )
  243. async def modify_institution_controller(
  244. data: dict,
  245. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:modify"]))],
  246. ) -> JSONResponse:
  247. """编辑费控制度"""
  248. # enterprise_id 推导
  249. if not data.get("enterprise_id"):
  250. from app.plugin.module_payment.enterprise.model import EnterpriseModel
  251. from sqlalchemy import select
  252. tenant_id = auth.user.tenant_id if auth.user and auth.user.tenant_id else auth.tenant_id
  253. stmt = select(EnterpriseModel).where(EnterpriseModel.tenant_id == tenant_id).limit(1)
  254. result = await auth.db.execute(stmt)
  255. enterprise = result.scalar_one_or_none()
  256. if enterprise:
  257. data["enterprise_id"] = enterprise.enterprise_id
  258. # name → institution_name
  259. if data.get("name") and not data.get("institution_name"):
  260. data["institution_name"] = data["name"]
  261. # 时间格式
  262. if data.get("effective_start_date") and len(data["effective_start_date"]) == 10:
  263. data["effective_start_date"] = data["effective_start_date"] + " 00:00:00"
  264. if data.get("effective_end_date") and len(data["effective_end_date"]) == 10:
  265. data["effective_end_date"] = data["effective_end_date"] + " 23:59:59"
  266. elif not data.get("effective_end_date") and data.get("effective_time_type") == "unlimited":
  267. data["effective_end_date"] = "2099-12-31 23:59:59"
  268. # expense_type 映射
  269. EXPENSE_TYPE_MAP = {"GENERAL": "DEFAULT", "DEFAULT": "DEFAULT"}
  270. if data.get("expense_type") in EXPENSE_TYPE_MAP:
  271. data["expense_type"] = EXPENSE_TYPE_MAP[data["expense_type"]]
  272. # 提取 scope 变更数据(需与基础修改分两次请求)
  273. applicable_scope = data.get("applicable_scope", "")
  274. scope_info = None
  275. enterprise_id = data.get("enterprise_id", "")
  276. if applicable_scope and applicable_scope not in ("NONE", "none"):
  277. ADAPTER_MAP = {"all": "EMPLOYEE_ALL", "employee": "EMPLOYEE_SELECT", "department": "EMPLOYEE_DEPARTMENT"}
  278. new_adapter = ADAPTER_MAP.get(applicable_scope, applicable_scope)
  279. # 查询当前scope:计算旧→新的差异
  280. old_ids = []
  281. try:
  282. scope_old = await InstitutionScopeService.scopepageinfo_query_service(
  283. auth=auth, institution_id=institution_id, enterprise_id=enterprise_id,
  284. page_num=1, page_size=500,
  285. )
  286. old_ids = [str(i) for i in (scope_old.get("owner_id_list") or []) if i]
  287. except Exception:
  288. log.warning(f"查询旧scope失败,将全量覆盖: institution_id={institution_id}")
  289. new_ids_raw = data.get("scope_owner_id_list") or []
  290. new_ids = [str(i) for i in new_ids_raw if i is not None and str(i).strip()]
  291. # 计算差异
  292. old_set, new_set = set(old_ids), set(new_ids)
  293. add_ids = list(new_set - old_set)
  294. delete_ids = list(old_set - new_set)
  295. scope_info = {
  296. "enterprise_id": enterprise_id,
  297. "adapter_type": new_adapter,
  298. "owner_type": "ENTERPRISE_PAY_UID",
  299. }
  300. if add_ids:
  301. scope_info["add_owner_id_list"] = add_ids
  302. if delete_ids:
  303. scope_info["delete_owner_id_list"] = delete_ids
  304. log.info(
  305. f"scope 差异: add={add_ids}, delete={delete_ids}, "
  306. f"old_count={len(old_ids)}, new_count={len(new_ids)}"
  307. )
  308. if not add_ids and not delete_ids:
  309. scope_info = None
  310. log.info("scope 无变化,跳过")
  311. # 从请求中移除 scope 数据,避免与基础修改冲突
  312. data.pop("modify_scope_info", None)
  313. # 第1次请求:仅修改制度基础信息(不含 scope)
  314. base_data = {k: v for k, v in data.items() if k != "modify_scope_info"}
  315. institution_modify_model = AlipayEbppInvoiceInstitutionModifyModel.from_alipay_dict(base_data)
  316. try:
  317. result = await InstitutionService.modify_institution_service(
  318. auth=auth, data=institution_modify_model, raw_data=base_data, scope_info=scope_info
  319. )
  320. except Exception as e:
  321. err_msg = str(e)
  322. if "consult" in err_msg.lower() or "咨询" in err_msg or "发" in err_msg:
  323. raise CustomException(msg="制度下存在发放规则,咨询模式不允许修改为外部服务商,请先删除发放规则后再试")
  324. raise
  325. log.info(f"编辑费控制度成功: institution_id={institution_modify_model.institution_id}")
  326. return SuccessResponse(data=result, msg="编辑费控制度成功")
  327. # ========== 制度成员范围管理 ==========
  328. @InstitutionRouter.get(
  329. "/{institution_id}/scope",
  330. summary="查询制度成员范围",
  331. description="查询制度下成员范围 (alipay.ebpp.invoice.institution.scopepageinfo.query)",
  332. )
  333. async def list_scope_controller(
  334. institution_id: Annotated[str, Path(description="制度ID")],
  335. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:scope:list"]))],
  336. enterprise_id: Annotated[str | None, Query(description="企业ID")] = None,
  337. owner_type: Annotated[str | None, Query(description="适配ID类型")] = None,
  338. page_num: Annotated[int, Query(description="页码")] = 1,
  339. page_size: Annotated[int, Query(description="每页条数")] = 20,
  340. ) -> JSONResponse:
  341. """查询制度成员"""
  342. result = await InstitutionScopeService.scopepageinfo_query_service(
  343. auth=auth,
  344. institution_id=institution_id,
  345. enterprise_id=enterprise_id,
  346. page_num=page_num,
  347. page_size=page_size,
  348. owner_type=owner_type,
  349. )
  350. return SuccessResponse(data=result, msg="查询成功")
  351. @InstitutionRouter.post(
  352. "/{institution_id}/scope",
  353. summary="设置制度成员范围",
  354. description="设置/修改制度成员范围 (alipay.ebpp.invoice.institution.scope.modify)",
  355. )
  356. async def modify_scope_controller(
  357. institution_id: Annotated[str, Path(description="制度ID")],
  358. data: dict,
  359. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:scope:modify"]))],
  360. ) -> JSONResponse:
  361. """设置制度成员"""
  362. result = await InstitutionScopeService.scope_modify_service(
  363. auth=auth,
  364. institution_id=institution_id,
  365. data=data,
  366. )
  367. log.info(f"设置制度成员成功: institution_id={institution_id}, adapter_type={data.get('adapter_type')}")
  368. return SuccessResponse(data=result, msg="设置成功")
  369. # ========== 自动额度发放规则管理 ==========
  370. @InstitutionRouter.post(
  371. "/{institution_id}/issuerule",
  372. summary="创建自动发放规则",
  373. description="创建自动额度发放规则 (alipay.ebpp.invoice.issuerule.create)",
  374. )
  375. async def create_issuerule_controller(
  376. institution_id: Annotated[str, Path(description="制度ID")],
  377. data: dict,
  378. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:issuerule:create"]))],
  379. ) -> JSONResponse:
  380. """创建自动发放规则"""
  381. result = await IssueruleService.create_issuerule_service(
  382. auth=auth,
  383. institution_id=institution_id,
  384. enterprise_id=data.get("enterprise_id", ""),
  385. quota_type=data.get("quota_type", "CAP"),
  386. issue_type=data.get("issue_type", "ISSUE_MONTH"),
  387. issue_amount_value=data.get("issue_amount_value", "0"),
  388. outer_source_id=data.get("outer_source_id"),
  389. issue_rule_name=data.get("issue_rule_name"),
  390. effective_period=data.get("effective_period"),
  391. invalid_mode=data.get("invalid_mode"),
  392. share_mode=data.get("share_mode"),
  393. )
  394. log.info(f"创建自动发放规则成功: institution_id={institution_id}")
  395. return SuccessResponse(data=result, msg="创建自动发放规则成功")
  396. @InstitutionRouter.put(
  397. "/{institution_id}/issuerule/{issue_rule_id}",
  398. summary="编辑自动发放规则",
  399. description="编辑自动额度发放规则 (alipay.ebpp.invoice.issuerule.modify)",
  400. )
  401. async def modify_issuerule_controller(
  402. institution_id: Annotated[str, Path(description="制度ID")],
  403. issue_rule_id: Annotated[str, Path(description="发放规则ID")],
  404. data: dict,
  405. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:issuerule:modify"]))],
  406. ) -> JSONResponse:
  407. result = await IssueruleService.modify_issuerule_service(
  408. auth=auth,
  409. institution_id=institution_id,
  410. issue_rule_id=issue_rule_id,
  411. enterprise_id=data.get("enterprise_id", ""),
  412. quota_type=data.get("quota_type"),
  413. issue_type=data.get("issue_type"),
  414. issue_amount_value=data.get("issue_amount_value"),
  415. issue_rule_name=data.get("issue_rule_name"),
  416. effective=data.get("effective"),
  417. effective_period=data.get("effective_period"),
  418. invalid_mode=data.get("invalid_mode"),
  419. share_mode=data.get("share_mode"),
  420. )
  421. log.info(f"编辑自动发放规则成功: issue_rule_id={issue_rule_id}")
  422. return SuccessResponse(data=result, msg="编辑自动发放规则成功")
  423. @InstitutionRouter.delete(
  424. "/{institution_id}/issuerule",
  425. summary="删除自动发放规则",
  426. description="删除自动额度发放规则 (alipay.ebpp.invoice.issuerule.delete)",
  427. )
  428. async def delete_issuerule_controller(
  429. institution_id: Annotated[str, Path(description="制度ID")],
  430. data: dict,
  431. auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:institution:issuerule:delete"]))],
  432. ) -> JSONResponse:
  433. result = await IssueruleService.delete_issuerule_service(
  434. auth=auth,
  435. institution_id=institution_id,
  436. issue_rule_id_list=data.get("issue_rule_id_list", []),
  437. enterprise_id=data.get("enterprise_id", ""),
  438. )
  439. log.info(f"删除自动发放规则成功: institution_id={institution_id}")
  440. return SuccessResponse(data=result, msg="删除自动发放规则成功")