Пример #1
0
    def get(self, *args, **kwargs):
        try:
            user_id = self.get_argument('user_id')
            user_key = self.get_argument('user_key')
            zoneid = self.get_argument('user_pf')
        except KeyError:
            server_log.warning("Failed to get argument", exc_info=True)

        checker = check_login.LoginChecker()
        checker.check_info(user_id, user_key, zoneid, self._check_ret_callback)
Пример #2
0
    def get(self, *args, **kwargs):
        try:
            user_id = self.get_argument('user_id')
            user_key = self.get_argument('user_key')
            zoneid = self.get_argument('user_pf')
        except KeyError:
            server_log.warning("Failed to get argument", exc_info=True)

        checker = check_login.LoginChecker()
        checker.check_info(user_id, user_key, zoneid, self._check_ret_callback)
Пример #3
0
    def get(self):
        if self.application.running:
            try:
                user_id = self.get_argument('user_id')
                user_key = self.get_argument('user_key')
                zoneid = self.get_argument('user_pf')
            except KeyError:
                server_log.warning("Failed to get argument", exc_info=True)

            checker = check_login.LoginChecker()
            checker.check_info(user_id, user_key, zoneid, self._check_ret_callback)
        else:
            self.send_error()
Пример #4
0
    def get(self):
        if self.application.running:
            try:
                user_id = self.get_argument('user_id')
                user_key = self.get_argument('user_key')
                zoneid = self.get_argument('user_pf')
            except KeyError:
                server_log.warning("Failed to get argument", exc_info=True)

            checker = check_login.LoginChecker()
            checker.check_info(user_id, user_key, zoneid,
                               self._check_ret_callback)
        else:
            self.send_error()
Пример #5
0
    def get_record(self, user_uid):
        # server_log.info('get record. user_uid=' + user_uid)
        # if user_uid not in self.cache:
        #     server_log.info('not in cache')

            find_ret = self.db.user.find_one({'user_uid': user_uid})

            if find_ret:
                server_log.info('db find')
                del find_ret['_id']
                reply_dict = dict()
                if 'record' in find_ret and type(find_ret['record']) is dict:
                    # reply_dict = dict((key.encode('ascii'), value) for key, value in find_ret['record'].items())
                    reply_dict = find_ret['record']

                """attach unpushed record item to Record(old) from db"""
                if user_uid in self.batch_on_pushing:
                    server_log.warning('attach record_on_pushing: ' + user_uid +
                                    ', record: ' + str(self.batch_on_pushing[user_uid]))
                    reply_dict.update(self.batch_on_pushing[user_uid])
                if user_uid in self.batch:
                    server_log.info('attach record_batch: ' + user_uid +
                                    ', record: ' + str(self.batch[user_uid]))
                    reply_dict.update(self.batch[user_uid])

                """add unique number id"""
                if 'userno' not in reply_dict:
                    reply_dict['userno'] = self._make_userno()
            else:
                server_log.info('not find record of user_uid=' + user_uid + ', make default record !!!')
                record_doc = dict()
                record_doc['user_uid'] = user_uid
                record_doc['record'] = Record.default_record()
                record_doc['record']['userno'] = self._make_userno()
                self.db.user.insert(record_doc)
                reply_dict = record_doc['record']

            return reply_dict
Пример #6
0
    def get(self):
        if not self.application.running:
            self.send_error()
            return

        print 'api uri:', self.request.uri
        server_log.info('api uri:' + self.request.uri)
        try:
            openid = self.get_argument('openid')
            openkey = self.get_argument('openkey')
            platform = self.get_argument('platform')
            user_pf = self.get_argument('user_pf')
            api = self.get_argument('api')
            callback = self.get_argument('callback')
        except KeyError:
            server_log.warning("except KeyError: Failed to get argument",
                               exc_info=True)

        server_log.info('handle api:' + api)

        if api == 'k_userinfo':
            jdata = self.application.api.call('/v3/user/get_info', {
                'openid': openid,
                'openkey': openkey,
                'pf': platform,
            })
            jdata['is_ok'] = 1
            jdata['openid'] = openid
            jdata['openkey'] = openkey
            # reply = json.JSONEncoder().encode(jdata)
            reply = json.dumps(jdata, ensure_ascii=False).encode('utf8')
        elif api == 'k_islogin':
            jdata = self.application.api.call('/v3/user/is_login', {
                'openid': openid,
                'openkey': openkey,
                'pf': platform,
            })
            jdata['is_ok'] = 1
            reply = json.dumps(jdata, ensure_ascii=False).encode('utf8')
        elif api == 'k_playzone_userinfo':
            jdata = self.application.api.call(
                '/v3/user/get_playzone_userinfo', {
                    'openid': openid,
                    'openkey': openkey,
                    'pf': platform,
                    'zoneid': int(user_pf)
                })
            jdata['is_ok'] = 1
            jdata['openid'] = openid
            jdata['openkey'] = openkey
            reply = json.dumps(jdata, ensure_ascii=False).encode('utf8')
        elif api == 'k_buy_playzone_item':
            itemid = self.get_argument('itemid')
            count = self.get_argument('count')

            jdata = self.application.api.call(
                '/v3/user/buy_playzone_item', {
                    'openid': openid,
                    'openkey': openkey,
                    'pf': platform,
                    'zoneid': int(user_pf),
                    'itemid': itemid,
                    'count': int(count)
                })
            jdata['is_ok'] = 1
            reply = json.dumps(jdata, ensure_ascii=False).encode('utf8')
            self.application.push_billinfo_to_db(openid, user_pf, itemid,
                                                 jdata)
        else:
            reply = "{'is_ok':0, 'msg': 'invalid api'}"

        print('reply: ' + reply)
        # lkj bug: how to show unicode - chinese
        reply = callback.encode('utf8') + '(' + reply + ')'
        self.write(reply)
Пример #7
0
    def get(self):
        if not self.application.running:
            self.send_error()
            return

        print 'api uri:', self.request.uri
        server_log.info('api uri:' + self.request.uri)
        try:
            openid = self.get_argument('openid')
            openkey = self.get_argument('openkey')
            platform = self.get_argument('platform')
            user_pf = self.get_argument('user_pf')
            api = self.get_argument('api')
            callback = self.get_argument('callback')
        except KeyError:
            server_log.warning("except KeyError: Failed to get argument", exc_info=True)

        server_log.info('handle api:' + api)

        if api == 'k_userinfo':
            jdata = self.application.api.call('/v3/user/get_info', {
                'openid': openid,
                'openkey': openkey,
                'pf': platform,
            })
            jdata['is_ok'] = 1
            jdata['openid'] = openid
            jdata['openkey'] = openkey
            # reply = json.JSONEncoder().encode(jdata)
            reply = json.dumps(jdata, ensure_ascii=False).encode('utf8')
        elif api == 'k_islogin':
            jdata = self.application.api.call('/v3/user/is_login', {
                'openid': openid,
                'openkey': openkey,
                'pf': platform,
            })
            jdata['is_ok'] = 1
            reply = json.dumps(jdata, ensure_ascii=False).encode('utf8')
        elif api == 'k_playzone_userinfo':
            jdata = self.application.api.call('/v3/user/get_playzone_userinfo', {
                'openid': openid,
                'openkey': openkey,
                'pf': platform,
                'zoneid': int(user_pf)
            })
            jdata['is_ok'] = 1
            jdata['openid'] = openid
            jdata['openkey'] = openkey
            reply = json.dumps(jdata, ensure_ascii=False).encode('utf8')
        elif api == 'k_buy_playzone_item':
            itemid = self.get_argument('itemid')
            count = self.get_argument('count')

            jdata = self.application.api.call('/v3/user/buy_playzone_item', {
                'openid': openid,
                'openkey': openkey,
                'pf': platform,
                'zoneid': int(user_pf),
                'itemid': itemid,
                'count': int(count)
            })
            jdata['is_ok'] = 1
            reply = json.dumps(jdata, ensure_ascii=False).encode('utf8')
            self.application.push_billinfo_to_db(openid, user_pf, itemid, jdata)
        else:
            reply = "{'is_ok':0, 'msg': 'invalid api'}"

        print('reply: ' + reply)
        # lkj bug: how to show unicode - chinese
        reply = callback.encode('utf8') + '(' + reply + ')'
        self.write(reply)