feat(pay): 增加支付状态paid 已支付
This commit is contained in:
@@ -7,12 +7,10 @@
|
||||
import logging
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from fastapi import Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from core.base.schema import ProductCategory, ProductAction, OrderStatusType
|
||||
from core.db.crud import CRUD
|
||||
from core.db.engine import get_async_session
|
||||
from core.db.models import User, Order, Product, PointsTransaction
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -54,6 +52,13 @@ async def actions_after_payment(
|
||||
)
|
||||
await actions_handler(db_crud, gift_product, user)
|
||||
|
||||
record = {
|
||||
'order_id': notify_params['out_trade_no'],
|
||||
'transaction_id': notify_params['transaction_id'],
|
||||
'status': OrderStatusType.OK,
|
||||
}
|
||||
await db_crud.update(data=record, filters={'order_id': record['order_id']})
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f'Payment Actions Exception occurred -> {e}')
|
||||
logger.exception(e)
|
||||
|
||||
@@ -126,7 +126,7 @@ async def wechat_notify(
|
||||
if params['return_code'] == 'SUCCESS' and params['result_code'] == 'SUCCESS':
|
||||
record.update({
|
||||
'notify_total_fee': params['total_fee'],
|
||||
'status': base_schema.OrderStatusType.OK
|
||||
'status': base_schema.OrderStatusType.PAID
|
||||
})
|
||||
result = {'status': 200, 'message': 'OK'}
|
||||
background_tasks.add_task(actions_after_payment, notify_params=params, db_session=db_session)
|
||||
|
||||
Reference in New Issue
Block a user