def get(self, request, format=None): try: count = request.query_params.get('count', 10000) create_random_hash(count) return reformat_ret(0, {'count': count}, 'new hash success') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, 'query deposit status exception')
def post(self, request, format=None): try: user = current_user(request) theme = request.data.get('theme', 'light') if user.is_authenticated(): if hasattr(user, 'profile'): profile = user.profile profile.theme = theme profile.save() else: UserProfile.objects.create(steamer=user, theme=theme) return reformat_ret(0, {}, 'update theme success') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, 'query deposit status exception')
def query_status(self, request): try: uid = request.query_params.get('uid', None) if uid: record = SendRecord.objects.get(uid=uid) resp_data = { 'uid': record.uid, 'trade_no': record.trade_no, 'security_code': record.security_code, 'status': record.status } return reformat_ret(0, resp_data, 'Successfully') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, u'查询取回报价异常') return reformat_ret(103, {}, u"无效参数")
def query_status(self, request): try: uid = request.query_params.get('uid', None) if uid: deposit = Deposit.objects.get(uid=uid) resp_data = { 'uid': deposit.uid, 'tradeNo': deposit.trade_no, 'securityCode': deposit.security_code, 'status': deposit.status } return reformat_ret(0, resp_data, 'success') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, 'query deposit status exception') return reformat_ret(403, {}, "invalid params")
def get_inventories(self, request): try: steamer = current_user(request) s_assetid = request.query_params.get('s_assetid', None) items = get_user_inventories(steamer.steamid, s_assetid, lang=request.LANGUAGE_CODE) if items is None: return reformat_ret( 311, {}, _l("We get issues when query inventory from steam, try again later." )) resp_data = {'inventory': items} return reformat_ret(0, resp_data, 'success') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, 'exception')
def create(self, request): try: m = get_maintenance() if m: return reformat_ret( 201, [], _('The site in on maintenance, please wait for a while.')) steamer = current_user(request) if steamer: code, result = join_coinflip_game(request.data, steamer) if code == 0: return reformat_ret(0, result, 'create coinflip successfully') elif code == 201: return reformat_ret(201, {}, _l("Someone has joined the game.")) else: return reformat_ret(101, {}, result) return reformat_ret(0, {}, 'coinflip') except CoinFlipGame.DoesNotExist as e: _logger.error(e) return reformat_ret(301, {}, 'Invalid game') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, 'coinflip exception')
def query_history(self, request): try: ret = [] user = current_user(request) game = request.data.get('game', 'coinflip') q_type = request.data.get('type', 'all') page = request.data.get('page', 1) page = 1 if page < 1 else page if q_type == 'all': if game == 'coinflip': ret = get_all_coinflip_history(page=page) elif q_type == 'myself' and user: if game == 'coinflip': ret = get_my_coinflip_history(user, page=page) elif game == 'jackpot': ret = get_my_jackpot_history(user, page=page) return reformat_ret(0, ret, 'query history successfully') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, 'exception')
def get(self, request, format=None): try: params = request.query_params botid = params.get('botid') appid = params.get('appid') contextid = params.get('contextid') exclude = params.get('exclude', None) steamid = params.get('steamid', None) details = params.get('details', False) remove = params.get('remove', False) body = check_lack(botid=botid, appid=appid, contextid=contextid, steamid=steamid, exclude=exclude, details=details, remove=remove) return reformat_ret(0, body, 'ok') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, 'query deposit status exception')
def create(self, request): # _logger.debug('create deposit') try: m = get_maintenance() if m: return reformat_ret( 201, [], _('The site in on maintenance, please wait for a while.')) steamer = current_user(request) if steamer: code, result = join_jackpot_game(request.data, steamer) if code == 0: return reformat_ret(0, {'uid': result.uid}, _l('join jackpot successfully')) else: return reformat_ret(101, {}, result) return reformat_ret(0, {}, 'jackpot') except Exception as e: _logger.exception(e) return reformat_ret(500, {}, 'jackpot exception')