update
This commit is contained in:
parent
347e171849
commit
f4d9bc7b73
@ -105,38 +105,43 @@ async def create_order(request: CreateOrderRequest,
|
|||||||
|
|
||||||
class NotifyRequest(BaseModel):
|
class NotifyRequest(BaseModel):
|
||||||
merchantOrderNo: str
|
merchantOrderNo: str
|
||||||
|
status: str
|
||||||
|
|
||||||
@router.post("/notify")
|
@router.post("/notify")
|
||||||
async def notify(notify: NotifyRequest, session: Session = Depends(get_db)):
|
async def notify(notify: NotifyRequest, session: Session = Depends(get_db)):
|
||||||
try:
|
try:
|
||||||
# 更新订单状态
|
|
||||||
subscription_order_manager = SubscriptionOrderManager(session)
|
subscription_order_manager = SubscriptionOrderManager(session)
|
||||||
subscription_order_manager.update_order_status(notify.merchantOrderNo, 2)
|
## 订单完成
|
||||||
|
if notify.status == "1":
|
||||||
|
# 更新订单状态
|
||||||
|
subscription_order_manager.update_order_status(notify.merchantOrderNo, 2)
|
||||||
|
|
||||||
order = subscription_order_manager.get_order_by_id(notify.merchantOrderNo)
|
order = subscription_order_manager.get_order_by_id(notify.merchantOrderNo)
|
||||||
|
|
||||||
if order is None:
|
if order is None:
|
||||||
return {
|
return {
|
||||||
"code": 500,
|
"code": 500,
|
||||||
"message": "Order not found"
|
"message": "Order not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
user_id = order['user_id']
|
user_id = order['user_id']
|
||||||
member_type = order['member_type']
|
member_type = order['member_type']
|
||||||
time_type = order['time_type']
|
time_type = order['time_type']
|
||||||
|
|
||||||
if time_type == 1:
|
if time_type == 1:
|
||||||
expire_time = datetime.now() + timedelta(days=30)
|
expire_time = datetime.now() + timedelta(days=30)
|
||||||
elif time_type == 2:
|
elif time_type == 2:
|
||||||
expire_time = datetime.now() + timedelta(days=365)
|
expire_time = datetime.now() + timedelta(days=365)
|
||||||
|
|
||||||
#增加用户订阅记录
|
#增加用户订阅记录
|
||||||
user_subscription_manager = UserSubscriptionManager(session)
|
user_subscription_manager = UserSubscriptionManager(session)
|
||||||
user_subscription_manager.create_subscription(user_id,
|
user_subscription_manager.create_subscription(user_id,
|
||||||
member_type,
|
member_type,
|
||||||
time_type,
|
time_type,
|
||||||
notify.merchantOrderNo,
|
notify.merchantOrderNo,
|
||||||
expire_time)
|
expire_time)
|
||||||
|
else:
|
||||||
|
subscription_order_manager.update_order_status(notify.merchantOrderNo, 4)
|
||||||
|
|
||||||
return "ok"
|
return "ok"
|
||||||
except Exception as e:
|
except Exception as 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.8
|
image: cryptoai-api:0.2.9
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user