async def post(self, *args, **kwargs): content = self.request.body.decode("utf-8") data = async_weixin_pay.to_dict(content) self.set_header('Content-Type', 'application/xml') if not async_weixin_pay.check(data): self.finish(async_weixin_pay.reply("签名验证失败", False)) result_code = data['result_code'] if result_code == 'SUCCESS': out_trade_no = data['out_trade_no'] gift_data = redis.hgetall(out_trade_no) if gift_data: async with objects.database.atomic_async(): vote_event = await objects.create( VoteEvent, gift_id=gift_data['gift_id'], candidate_id=gift_data['candidate_id'], amount=gift_data['amount'], number_of_gifts=gift_data['number_of_gifts'], voter_id=gift_data['voter_id'], voter_nickname=gift_data['voter_nickname'], voter_avatar=gift_data['voter_avatar'], vote_id=gift_data['vote_id'], reach=gift_data['reach'], image=gift_data['image'], gift_name=gift_data['gift_name'], out_trade_no=out_trade_no) candidate = await objects.get(Candidate, id=vote_event.candidate_id) candidate.number_of_votes += vote_event.reach await objects.update(candidate) redis.delete(out_trade_no) self.finish(async_weixin_pay.reply('OK', True)) self.finish(async_weixin_pay.reply('OK', True))
def delete(self): redis.delete("player:{0}".format(self.uuid)) redis.delete("token:{0}".format(self.uuid))
def delete(self): self.player_dict = {} self.seat_dict = {} redis.delete("table:{0}".format(self.room_id))