异步通知

    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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值