def post(self):
user_id = g.user_id
data = request.form.to_dict()
if not isinstance(data, dict):
return response_data(RET.THIRDERR)
trade_data = self.alipay.get_wap_trade(data)
trade_data = dict(get_data(trade_data))
# user_data = self.arangodb.query(UserMember).filter(f"order_id IN '{trade_data.get('order_id')}'")
number = vip_information.get(trade_data.get("type"))
filter = (
f"FOR o IN ordermember "
f"FILTER o.order_id=='{trade_data.get('order_id')}'"
f"FILTER o.user_key==doc.user_key")
user_member_filter = (
f"FOR o IN ordermember "
f"FILTER o.order_id=='{trade_data.get('order_id')}'"
)
try:
if trade_data.get('trade_status') == 'TRADE_SUCCESS':
trade_data['trade_status'] = '支付成功'
# if user_data.first():
duration = expire_date(user_data.first().duration, number)
where = f"{{order_id: PUSH(doc.order_id, o.order_id),duration: '{duration}' }}"
self.db.update(where, filter, "usermember")
else:
duration = expire_date('', number)
member_number = get_time(10)
where = (f"{{duration:'{duration}',member_number:'{member_number}',"
f" order_id:'{trade_data.get('order_id')}',user_key:'{user_id}' }}")
data = self.db.insert(where, "usermember")
user_where = f"{{vip_key:'{data.get('key')}'}}"
self.db.update(user_where, user_member_filter, "users")
self.db.update(f"{{trade_data:'{trade_data}'}}", filter, "usermember")
return response_data(RET.OK)
except Exception:
return response_data(RET.THIRDERR)
异步通知
最新推荐文章于 2024-07-15 18:05:22 发布