fix: cicle import
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
from abc import ABC,abstractmethod
|
||||
|
||||
from src.infrastructure.database.models.payment import Payment
|
||||
|
||||
|
||||
class IPaymentRepository(ABC):
|
||||
@abstractmethod
|
||||
async def create_completed(self,*,user_id:str,order_id:str,itpay_payment_id:str,itpay_paid_amount:str|None,transaction_id:str|None,paid_at:str|None,expired_date:str|None) -> Payment:
|
||||
async def create_completed(self,*,user_id:str,order_id:str,itpay_payment_id:str,itpay_paid_amount:str|None,transaction_id:str|None,paid_at:str|None,expired_date:str|None) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ class PaymentRepository(IPaymentRepository):
|
||||
self._logger=logger
|
||||
|
||||
|
||||
async def create_completed(self,*,user_id:str,order_id:str,itpay_payment_id:str,itpay_paid_amount:str|None,transaction_id:str|None,paid_at:str|None,expired_date:str|None) -> Payment:
|
||||
async def create_completed(self,*,user_id:str,order_id:str,itpay_payment_id:str,itpay_paid_amount:str|None,transaction_id:str|None,paid_at:str|None,expired_date:str|None) -> None:
|
||||
stmt=select(Payment).where(Payment.order_id==order_id)
|
||||
existing=await self._session.scalar(stmt)
|
||||
if existing is not None:
|
||||
return existing
|
||||
return
|
||||
paid_at_dt=datetime.fromisoformat(paid_at.replace('Z','+00:00')) if paid_at else None
|
||||
expired_dt=datetime.fromisoformat(expired_date.replace('Z','+00:00')) if expired_date else None
|
||||
paid_amount_dec=Decimal(str(itpay_paid_amount)) if itpay_paid_amount is not None else None
|
||||
@@ -37,5 +37,5 @@ class PaymentRepository(IPaymentRepository):
|
||||
)
|
||||
self._session.add(model)
|
||||
await self._session.flush()
|
||||
return model
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user