コード例 #1
0
    def post(self):
        self.set_header("Content-Type", "application/json")
        openid = self.get_secure_cookie("openid")
        if OPENID:
            openid = OPENID
        pay_infos = public_db.getPayInfo(openid)

        self.write(json.dumps({'error': '0', 'data': pay_infos}, cls=public_bz.ExtEncoder))
コード例 #2
0
    def get(self):
        self.set_header("Content-Type", "application/json")
        openid = self.get_secure_cookie("openid")
        openid = checkOpenid(openid)
        pay_infos = public_db.getPayInfo(openid, ["payed", "recharging", "recharged"])

        for pay_info in pay_infos:
            pay_info["date"] = pay_info.stat_date.strftime("%m-%d %H:%M")

        self.write(json.dumps({"error": "0", "pay_infos": pay_infos}, cls=public_bz.ExtEncoder))
コード例 #3
0
    def get(self, parm=None):
        self.set_header("Content-Type", "application/json")
        statuses = None
        user_id = None
        if parm:
            parm = json.loads(parm)
            statuses = parm.get("statuses")
            user_id = parm.get("user_id")
        if user_id:  # 如果有传user_id过来,表示要限定user_id查询
            user_id = self.get_secure_cookie("user_id")

        pay_infos = list(public_db.getPayInfo(statuses=statuses, user_id=user_id))
        for pay_info in pay_infos:
            pay_info["date"] = pay_info.stat_date.strftime("%Y年%m月%d日 %H:%M")

        self.write(json.dumps({"error": "0", "pay_infos": pay_infos}, cls=public_bz.ExtEncoder))
コード例 #4
0
    def put(self):
        self.set_header("Content-Type", "application/json")
        parm = json.loads(self.request.body)
        id = parm.get("id")
        status = parm.get("status")

        user_id = self.get_secure_cookie("user_id")
        count = self.pg.update("pay", where="id=%s and status<>'%s' " % (id, status), status=status, user_id=user_id)
        if count != 1:
            raise Exception("占位失败")
        if status == "recharged":  # 完成充值,向微信发送
            pay_info = public_db.getPayInfo(id=id)[0]
            wechat = wechat_oper.getWechat()
            content = """ %s 元已已成功冲入油卡,可以使用了!""" % (int(pay_info.total_fee) / 100.00)
            wechat.send_text_message(pay_info.openid, content)

        self.write(json.dumps({"error": "0"}, cls=public_bz.ExtEncoder))
コード例 #5
0
    def post(self):
        self.set_header("Content-Type", "application/json")
        openid = self.get_secure_cookie("openid")
        pay_infos = public_db.getPayInfo(openid, ["payed", "recharging", "recharged"])

        self.write(json.dumps({"error": "0", "data": pay_infos}, cls=public_bz.ExtEncoder))