update
This commit is contained in:
parent
73d1c3eef2
commit
b5093519bc
@ -16,7 +16,7 @@ import logging
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
class CreateOrderRequest(BaseModel):
|
class CreateOrderRequest(BaseModel):
|
||||||
subscribe_type: int
|
subscribe_type: int
|
||||||
@ -105,22 +105,25 @@ async def create_order(request: CreateOrderRequest,
|
|||||||
|
|
||||||
|
|
||||||
class NotifyRequest(BaseModel):
|
class NotifyRequest(BaseModel):
|
||||||
order_no: str
|
code: int
|
||||||
merchant_order_no: str
|
message: str
|
||||||
status: str
|
data: dict
|
||||||
amount: str
|
# order_no: str
|
||||||
currency: str
|
# merchant_order_no: str
|
||||||
chain_type: str
|
# status: str
|
||||||
|
# amount: str
|
||||||
|
# currency: str
|
||||||
|
# chain_type: str
|
||||||
|
|
||||||
@router.post("/notify")
|
@router.post("/notify")
|
||||||
async def notify(request: NotifyRequest, session: Session = Depends(get_db)):
|
async def notify(request: NotifyRequest, session: Session = Depends(get_db)):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
data = request.data
|
||||||
# 更新订单状态
|
# 更新订单状态
|
||||||
subscription_order_manager = SubscriptionOrderManager(session)
|
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:
|
if order is None:
|
||||||
return {
|
return {
|
||||||
@ -142,13 +145,10 @@ async def notify(request: NotifyRequest, session: Session = Depends(get_db)):
|
|||||||
user_subscription_manager.create_subscription(user_id,
|
user_subscription_manager.create_subscription(user_id,
|
||||||
member_type,
|
member_type,
|
||||||
time_type,
|
time_type,
|
||||||
request.merchant_order_no,
|
data['merchantOrderNo'],
|
||||||
expire_time)
|
expire_time)
|
||||||
|
|
||||||
return {
|
return "ok"
|
||||||
"code": 200,
|
|
||||||
"message": "success"
|
|
||||||
}
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"创建用户订阅失败: {e}")
|
logger.error(f"创建用户订阅失败: {e}")
|
||||||
raise e
|
raise e
|
||||||
@ -29,7 +29,7 @@ services:
|
|||||||
cryptoai-api:
|
cryptoai-api:
|
||||||
build: .
|
build: .
|
||||||
container_name: cryptoai-api
|
container_name: cryptoai-api
|
||||||
image: cryptoai-api:0.2.0
|
image: cryptoai-api:0.2.1
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user