'data'
This commit is contained in:
@@ -111,7 +111,8 @@ def handle_payment_success(
|
||||
if not user_id:
|
||||
return
|
||||
|
||||
# meetup/salon 新用户:支付成功后才创建用户
|
||||
# meetup/salon 新用户:支付成功后才创建用户。solanRed 记录创建时用的是 pending_xxx,查找需用原值
|
||||
solan_lookup_user_id = user_id
|
||||
if pay_type in ("meetup", "salon") and user_id.startswith("pending_"):
|
||||
email = _decode_pending_email(user_id)
|
||||
if email:
|
||||
@@ -151,25 +152,30 @@ def handle_payment_success(
|
||||
solan_collection = None
|
||||
|
||||
if solan is not None:
|
||||
update_payload = {
|
||||
"order_id": order_id,
|
||||
"amount": amount_cents,
|
||||
}
|
||||
if pay_type == "salon":
|
||||
update_payload["vip"] = True
|
||||
elif pay_type == "meetup":
|
||||
update_payload["type"] = pay_type
|
||||
existing = solan.get_list(1, 1, {
|
||||
"filter": f'user_id = "{user_id}"',
|
||||
"filter": f'user_id = "{solan_lookup_user_id}"',
|
||||
"sort": "-created",
|
||||
})
|
||||
if existing.items:
|
||||
record_id = existing.items[0].id
|
||||
solan.update(record_id, {
|
||||
"type": pay_type,
|
||||
"order_id": order_id,
|
||||
"amount": amount_cents,
|
||||
})
|
||||
patch = dict(update_payload)
|
||||
if solan_lookup_user_id != user_id:
|
||||
patch["user_id"] = user_id
|
||||
solan.update(record_id, patch)
|
||||
logging.info(f"{solan_collection} 支付字段补齐成功 - user_id: {user_id}, record_id: {record_id}")
|
||||
else:
|
||||
solan.create({
|
||||
"user_id": user_id,
|
||||
"type": pay_type,
|
||||
"order_id": order_id,
|
||||
"amount": amount_cents,
|
||||
})
|
||||
create_payload = {"user_id": user_id, **update_payload}
|
||||
if pay_type == "salon":
|
||||
create_payload["type"] = ""
|
||||
solan.create(create_payload)
|
||||
logging.info(f"{solan_collection} 完整记录创建(兜底) - user_id: {user_id}")
|
||||
elif pay_type not in ("meetup", "salon"):
|
||||
existing = pb_client.collection("payments").get_list(1, 1, {
|
||||
|
||||
Reference in New Issue
Block a user