's'
This commit is contained in:
21
app/main.py
21
app/main.py
@@ -36,9 +36,15 @@ def get_pb_client():
|
||||
raise e
|
||||
return client
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(filename='xorpay_notify.log', level=logging.INFO,
|
||||
format='%(asctime)s - %(message)s')
|
||||
# 配置日志(添加控制台输出,便于调试)
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(message)s',
|
||||
handlers=[
|
||||
logging.FileHandler('xorpay_notify.log'),
|
||||
logging.StreamHandler() # 新增:同时输出到控制台
|
||||
]
|
||||
)
|
||||
|
||||
# 全局已处理订单
|
||||
processed_orders = set()
|
||||
@@ -116,7 +122,7 @@ async def payh5(item: dict):
|
||||
pay_type = item.get('type', 'unknown').lower()
|
||||
|
||||
random_suffix = ''.join(random.choices(string.hexdigits.lower(), k=8))
|
||||
timestamp = int(time.time()) # 修正:去掉多余字符
|
||||
timestamp = int(time.time())
|
||||
order_id = f"{user_id}_{pay_type}_order_{timestamp}_{random_suffix}"
|
||||
|
||||
type_map = {
|
||||
@@ -242,7 +248,12 @@ async def xorpay_notify(request: Request):
|
||||
|
||||
if pay_type == "meetup":
|
||||
solan = pb_client.collection("solan")
|
||||
existing = solan.get_list(1, 1, {"filter": f'user_id="{user_id}"'})
|
||||
# 修复 filter 语法:添加空格和 '=' 操作符(PocketBase 要求)
|
||||
# 同时添加 sort 以取最新记录(防止同一 user_id 多条)
|
||||
existing = solan.get_list(1, 1, {
|
||||
"filter": f'user_id = "{user_id}"',
|
||||
"sort": "-created" # 按创建时间倒序,取最新一条
|
||||
})
|
||||
if existing.items:
|
||||
record_id = existing.items[0].id
|
||||
solan.update(record_id, {
|
||||
|
||||
Reference in New Issue
Block a user