413bd29390
- FinanceService:opc_add_finance 直写 ORM 改为走 Repository.create(修复四层依赖违规) - SettlementService:结算佣金(5%)/电子合同幂等/争议联动/投资撮合评分 - SubsidyService:政务三级审批状态机(区县→市→省→发放) - rbac_ecosystem/rbac_government/rbac_opc 接线,路由瘦身
26 lines
905 B
Python
26 lines
905 B
Python
# -*- coding: utf-8 -*-
|
|
"""业务层 · 财务服务(OPC 收支流水)。
|
|
|
|
业务层只处理业务逻辑,依赖基础设施层 Repository;不反向依赖接口层。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from ..infrastructure.repositories import Database
|
|
|
|
|
|
class FinanceService:
|
|
"""OPC 财务流水管理。"""
|
|
|
|
def __init__(self, db: Database):
|
|
self.db = db
|
|
|
|
async def add_record(self, user_id: str, category: str, amount: int, date: str, note: str = "") -> dict:
|
|
"""记一笔收支(收入为正、支出为负由调用方给定金额符号)。"""
|
|
return await self.db.finance.create(
|
|
user_id=user_id, category=category, amount=amount,
|
|
date=date, note=note,
|
|
)
|
|
|
|
async def list_by_user(self, user_id: str, category: str | None = None) -> list[dict]:
|
|
return await self.db.finance.list_by_user(user_id, category)
|