diff --git a/app/controller/add_approve_route.py b/app/controller/add_approve_route.py index ebbd8da..d041143 100644 --- a/app/controller/add_approve_route.py +++ b/app/controller/add_approve_route.py @@ -1,6 +1,6 @@ from fastapi import FastAPI -from app.model.ReimburseModel import ReimburseService +from app.model.ReimburseModel import ReimburseService, ReimburseModel from app.utils.db_utils import AsyncSessionDep @@ -10,7 +10,7 @@ def add_approve_route(app: FastAPI): async def submit_reimburse(reimburse: dict, session: AsyncSessionDep): reimburse_id = reimburse.get('id') # 先查一遍报销单信息 - reimburse_cls = await ReimburseService.query_item(session=session, row_dict={"id": reimburse_id}) + reimburse_cls: ReimburseModel = await ReimburseService.query_item(session=session, row_dict={"id": reimburse_id}) # 1. 没有审批单—— # 2. 审批单为审批中状态——不处理 @@ -18,6 +18,15 @@ def add_approve_route(app: FastAPI): # 4. 审批单为已驳回状态—— # 5. 审批单为已撤回状态—— + # 2,3 的情况下不再提交报销单 + + if reimburse_cls.approve: + if reimburse_cls.approve.status == 'approving': + return {"message": "报销单已提交审批,请勿重复提交!"} + if reimburse_cls.approve.status == 'approved': + return {"message": "报销单已通过审批,请勿重复提交!"} + + # 1,4,5 的情况下新建审批单 # 新建审批单,走审批流程 print(reimburse_cls.amount)