This commit is contained in:
aaron 2025-06-12 10:01:20 +08:00
parent 73d1c3eef2
commit b5093519bc
2 changed files with 16 additions and 16 deletions

View File

@ -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

View File

@ -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"