diff --git a/cryptoai/routes/payment.py b/cryptoai/routes/payment.py index 4d764e9..be90f25 100644 --- a/cryptoai/routes/payment.py +++ b/cryptoai/routes/payment.py @@ -16,7 +16,7 @@ import logging router = APIRouter() logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) +logger.setLevel(logging.DEBUG) class CreateOrderRequest(BaseModel): subscribe_type: int @@ -105,22 +105,25 @@ async def create_order(request: CreateOrderRequest, class NotifyRequest(BaseModel): - order_no: str - merchant_order_no: str - status: str - amount: str - currency: str - chain_type: str + code: int + message: str + data: dict + # order_no: str + # merchant_order_no: str + # status: str + # amount: str + # currency: str + # chain_type: str @router.post("/notify") async def notify(request: NotifyRequest, session: Session = Depends(get_db)): - try: + data = request.data # 更新订单状态 subscription_order_manager = SubscriptionOrderManager(session) - subscription_order_manager.update_order_status(request.merchant_order_no, 2) + subscription_order_manager.update_order_status(data['merchantOrderNo'], 2) - order = subscription_order_manager.get_order_by_id(request.merchant_order_no) + order = subscription_order_manager.get_order_by_id(data['merchantOrderNo']) if order is None: return { @@ -142,13 +145,10 @@ async def notify(request: NotifyRequest, session: Session = Depends(get_db)): user_subscription_manager.create_subscription(user_id, member_type, time_type, - request.merchant_order_no, + data['merchantOrderNo'], expire_time) - return { - "code": 200, - "message": "success" - } + return "ok" except Exception as e: logger.error(f"创建用户订阅失败: {e}") raise e \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d3e2a03..19a62d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: cryptoai-api: build: . container_name: cryptoai-api - image: cryptoai-api:0.2.0 + image: cryptoai-api:0.2.1 restart: always ports: - "8000:8000"