def add_annouce_game(): title = request.form.get('title') content_image_url = request.form.get('content_image_url') push_times = request.form.get('push_times') priority = request.form.get('priority') date1 = request.form.get('date1') date2 = request.form.get('date2') channel_id = session['select_channel'] # 校验并处理参数参数 if not all([title, content_image_url, push_times, priority, date1, date2]): return jsonify(result=0, msg=u'请填入所有内容!') try: int(push_times) int(priority) except ValueError: return jsonify(result=0, msg=u'每日展示次数与优先级为整数纯数字!') date1 = time_util.formatTimestamp(date1) date2 = time_util.formatTimestamp(date2) if date1 > date2: return jsonify(result=0, msg=u'开始日期不能大于结束日期!') sql = "select ifnull(max(id), 1) + 1 from admin_announcement" notice_id = int(LogQry(channel_id).qry(sql)[0][0]) channel = redis_conn.hget(CHANNEL_CONFIG_TABLE + str(channel_id), "name") payload = { "start_time": date1, "end_time": date2, "channel": channel, "notice_id": notice_id, "push_times": push_times, "priority": priority, "content_img": content_image_url } redis_conn.hset(NOTICE_TABLE + channel, notice_id, payload) create_sql = """ INSERT INTO admin_announcement (id,channel,title,priority,content_image_url, push_times,start_date,end_date) VALUES (%d,%s,'%s',%s,'%s', %s,%s,%s) """ % (notice_id, channel_id, title, priority, content_image_url, push_times, date1, date2) LogQry(channel_id).execute(create_sql) return jsonify(result=1, msg=u'新建公告成功!')
def alarm_count(): begin_time = request.args.get('beginDate') end_time = request.args.get('endDate') begin_time = time_util.formatTimestamp(begin_time) end_time = time_util.formatTimestamp(end_time) + 86400 channel = session['select_channel'] sql = ''' select count(1) from admin_game_alarm where time >= %d and time <= %d and state = %d ''' % (begin_time, end_time, STATE_UNREAD) total_count = LogQry(channel).qry(sql) return jsonify(count = total_count)
def alarm_list(): begin_time = request.args.get('beginDate') end_time = request.args.get('endDate') begin_time = time_util.formatTimestamp(begin_time) end_time = time_util.formatTimestamp(end_time) + 86400 channel = session['select_channel'] size = int(request.args.get('size', '')) offset = int(request.args.get('offset', '')) subgame = game_parameter.get_subgame_list() datas = [] sql = ''' select id, pid, time, stype, val, state, ifnull((select nick from player where id = pid), "") from admin_game_alarm where time >= %d and time <= %d order by state, time desc limit %d, %d ''' % (begin_time, end_time, offset, size) print sql for idx, pid, time, stype, val, \ state, name in LogQry(channel).qry(sql): d = { "id": idx, "pid": pid, "time": time, "name": name, "state": state, "content": html(channel, pid, name, stype, val, subgame), } datas.append(d) sql = 'select count(1) from admin_game_alarm where time >= %d and time <= %d' % (begin_time, end_time) total = LogQry(channel).qry(sql)[0][0] return jsonify(data = datas, total = total)
def withdrawal_order_retrieve(): """提现订单管理查询""" # 获取参数 channel_id = session['select_channel'] status = request.args.get('status') begin_time = request.args.get('beginDate') end_time = request.args.get('endDate') player_id = request.args.get('PlayerID') player_name = request.args.get('Account') # 校验参数 if player_id: try: int(player_id) except ValueError as e: return jsonify(result=0, msg=u'玩家ID为整数纯数字!') if player_id and player_name: return jsonify(result=0, msg=u'玩家ID、玩家账号只能填其一!') # 处理数据 begin_time = time_util.formatTimestamp(begin_time) end_time = time_util.formatTimestamp(end_time) player_id_str = '' if player_id: player_id_str = ' AND pid=%s' % player_id if player_name: retrieve_sql = """SELECT id FROM player WHERE account_id='%s';""" % player_name player_id = LogQry(int(channel_id)).qry(retrieve_sql)[0][0] player_id_str = ' AND pid=%s' % player_id type_str = '' status_str = '' if status != '0': status_str = ' AND status=%s' % status ## 查询操作员 sql = 'select id, name from user' user_dict = {0: ""} for k, v in SqlOperate().select(sql): user_dict[k] = v # 从数据库获取数据 retrieve_sql = """ SELECT pid,withdraw_deposit_id,withdraw_deposit_type,withdraw_deposit_money,application_time, service_charge,platform_withhold,status,dispose_time,remark, payee,due_bank,gathering_account,open_account_address,failed_reason, id,(select member_level_name from admin_member_level where id=member_level), dispose_user,(select nick from player where id=pid) FROM admin_withdraw WHERE application_time>%s AND application_time<%s %s%s%s ORDER BY status DESC,application_time DESC; """ % (begin_time, end_time, player_id_str, type_str, status_str) datas = LogQry(channel_id).qry(retrieve_sql) # 处理数据 datas_list = list() for pid, withdraw_deposit_id, withdraw_deposit_type, withdraw_deposit_money, application_time, \ service_charge, platform_withhold, status, dispose_time, remark, \ payee, due_bank, gathering_account, open_account_address, failed_reason, \ order_id, level_name, dispose_user, nick in datas: # 整理数据为字典 data_dict = dict() data_dict['pid'] = pid data_dict['nick'] = nick data_dict['member_level'] = level_name data_dict['withdraw_deposit_id'] = withdraw_deposit_id data_dict['withdraw_deposit_type'] = withdraw_deposit_type data_dict['withdraw_deposit_money'] = withdraw_deposit_money data_dict['application_time'] = application_time data_dict['service_charge'] = service_charge data_dict['platform_withhold'] = platform_withhold data_dict['status'] = status_map[status] data_dict['dispose_time'] = dispose_time if dispose_time else 0 data_dict['dispose_user'] = user_dict[dispose_user] data_dict['remark'] = remark data_dict['payee'] = payee data_dict['due_bank'] = due_bank data_dict['gathering_account'] = gathering_account data_dict['open_account_address'] = open_account_address data_dict['failed_reason'] = failed_reason data_dict['order_id'] = order_id datas_list.append(data_dict) # 返回数据 return jsonify(result=1, datas=datas_list)
def game_detail_retrieve(): """每局游戏详情查询""" # 获取参数 channel = session['select_channel'] gameid = request.args.get('game') auto_id = request.args.get('code') pid = request.args.get('PlayerID') account_id = request.args.get('Account') begin_date = request.args.get('beginDate') end_date = request.args.get('endDate') time_start = request.args.get('time_start') time_end = request.args.get('time_end') size = request.args.get('size') offset = request.args.get('offset') # 校验参数 if auto_id: try: int(auto_id) except ValueError as e: return jsonify(result=0, msg=u'局号为整数纯数字!') if pid: try: int(pid) except ValueError as e: return jsonify(result=0, msg=u'玩家ID为整数纯数字!') if pid and account_id: return jsonify(result=0, msg=u'玩家ID与玩家账号只能填其一!') # 处理参数 where = '' if pid: where += ' AND pid=%s' % pid if account_id: where += " AND pid=(select id from player where account_id='%s')" % account_id if auto_id: where += ' AND auto_id=%s' % auto_id if gameid != '0': where += ' AND gameid=%s' % gameid # right_date = begin_date # 用于返回当天23点59分59秒 # begin_date_str = begin_date + ' ' + time_start + ':00' # end_date_str = begin_date + ' ' + time_end + ':00' # try: # begin_date = time_util.formatTimestamp(begin_date_str) # except ValueError: # begin_date = time_util.formatDatestamp(begin_date) # 当天0点0分0秒 # try: # end_date = time_util.formatTimestamp(end_date_str) # except ValueError: # end_date = time_util.formatDatestamp(right_date) + 86399 # 当天23点59分59秒 begin_date = time_util.formatTimestamp(begin_date) end_date = time_util.formatTimestamp(end_date) data_table_name = log_table.get_table_log_player_subgame(begin_date) # 校验开始时间是否小于结束时间 if begin_date >= end_date: return jsonify(result=0, msg=u'开始时间必须小于结束时间!') # 查询数据总量 retrieve_sql = """SELECT count(1),ifnull(sum(stake_coin), 0),ifnull(sum(output_coin), 0),ifnull(sum(pump), 0) FROM %s force index(time) WHERE time>=%s AND time<=%s %s;""" \ % (data_table_name, begin_date, end_date, where) try: total_all = LogQry(int(channel)).qry(retrieve_sql)[0] except Exception as e: print e return jsonify(result=0, msg=u'无数据!') total_count = total_all[0] total_stake_coin = total_all[1] total_output_coin = total_all[2] total_pump = total_all[3] # 从数据库获取数据 retrieve_sql = """SELECT time,pid,gameid,roomtype,stake_coin, output_coin,pump,auto_id,(select account_id from player where id=pid), (select nick from player where id=pid) FROM %s force index(time) WHERE time>=%s AND time<=%s %s ORDER BY time DESC LIMIT %s,%s;""" \ % (data_table_name, begin_date, end_date, where, offset, size) datas = LogQry(int(channel)).qry(retrieve_sql) # 处理数据 game_dict = game_parameter.get_subgame_list() datas_list = list() for time, pid, gameid, roomtype, stake_coin, \ output_coin, pump, auto_id, account_id, nick in datas: data_dict = dict() data_dict['time'] = time data_dict['account'] = account_id data_dict['pid'] = pid data_dict['nick'] = nick data_dict['game_name'] = game_parameter.get_subgame_by_id( game_dict, gameid) data_dict['room_type'] = roomtype data_dict['stake_coin'] = stake_coin data_dict['output_coin'] = output_coin data_dict['pump'] = pump data_dict['margin'] = output_coin - stake_coin data_dict['auto_id'] = auto_id data_dict['channel'] = channel datas_list.append(data_dict) total_dict = dict() total_dict['total_stake_coin'] = int(total_stake_coin) total_dict['total_output_coin'] = int(total_output_coin) total_dict['total_pump'] = int(total_pump) total_dict['total_margin'] = int(total_output_coin - total_stake_coin) # 返回数据 return jsonify(result=1, dataLength=total_count, rowDatas=datas_list, total_all=total_dict)
def search_coin_change_data(): player_id = request.args.get('PlayerID', '') Account = request.args.get('Account', '') gameid = request.args.get('game') start = request.args.get('beginDate', '') end = request.args.get('endDate', '') channel = session['select_channel'] size = int(request.args.get('size', '')) offset = int(request.args.get('offset', '')) start_date = time_util.formatTimestamp(start) end_date = time_util.formatTimestamp(end) use_index = "force index(time)" if player_id: use_index = "force index(pid)" play_id_str = " AND pid=%s" % player_id else: play_id_str = '' if Account: use_index = "force index(pid)" play_id_str = " AND pid = (select id from player where account_id = '%s') " % Account if gameid == '0': subgame_str = "" else: subgame_ename = game_parameter.get_subgame_enname(int(gameid)) subgame_str = " AND subgame LIKE '%s%%'" % subgame_ename search_sql = """ SELECT time, pid, (SELECT nick FROM player WHERE id=pid), log_type, subgame, val, rest FROM %s %s WHERE time>=%d AND time<%d%s%s ORDER BY time DESC LIMIT %s,%s; """ % (get_table_log_coin(start_date), use_index, start_date, end_date, play_id_str, subgame_str, offset, size) count_sql = """ SELECT count(1), ifnull(sum(val) , 0) FROM %s %s WHERE time >= %d AND time < %d%s%s """ % (get_table_log_coin(start_date), use_index, start_date, end_date, play_id_str, subgame_str) log_db = LogQry(channel) item_change_data = log_db.qry(search_sql) total_count = log_db.qry(count_sql)[0][0] total_val = int(log_db.qry(count_sql)[0][1]) page_datas = list() log_coin_dict = game_parameter.get_coin_log_define() subgame_dict = game_parameter.get_subgame_name_enname_d() for timeStamp, pid, nick, log_type, subgame, \ val, rest in item_change_data: item_change_dict = dict() item_change_dict['timeStamp'] = time_util.formatDateTime(timeStamp) item_change_dict['pid'] = pid item_change_dict['nick'] = nick item_change_dict['log_type'] = game_parameter.get_coin_log_name(log_coin_dict, log_type) if subgame: subgame_k = subgame.split('-')[0] room = subgame.split('-')[1] subgame_name = game_parameter.get_subgame_name_by_ename(subgame_dict, subgame_k) item_change_dict['subgame'] = "%s(%s)" % (subgame_name, room) else: subgame_k = "" room = "" item_change_dict['subgame'] = "" item_change_dict['val'] = val item_change_dict['rest'] = rest page_datas.append(item_change_dict) ## 做下特殊处理 排序下 page_datas.sort(key=lambda x: [x['timeStamp'], x['val']], reverse=True) return jsonify({"errcode": 0, "dataLength": total_count, "rowDatas": page_datas, "total_val": total_val})
def search_topup_order_detail(): start = request.args.get('beginDate') end = request.args.get('endDate') player_id = request.args.get('PlayerID', '') account = request.args.get('Account', '') stype = request.args.get('type') pay_state = request.args.get('pay_state') offset = int(request.args.get("offset", "0")) pagesize = int(request.args.get("size", "100")) # 接收渠道id channel = session['select_channel'] start_date = time_util.formatTimestamp(start) end_date = time_util.formatTimestamp(end) where = "" use_index = "force index(time)" if stype != "0": where += "and type = %s " % stype if pay_state != "-1": where += "and state = %s " % pay_state if player_id != "": use_index = "force index(pid)" where += "and pid = %s " % player_id if account != "": use_index = "force index(pid)" where += "and pid = (select id from player where account_id = '%s') " % account ## 查询满足条件的总数 count_sql = ''' select count(1) from admin_recharge %s where time >= %d and time <= %d %s ''' % (use_index, start_date, end_date, where) total_count = LogQry(channel).qry(count_sql)[0][0] ## 查询支付通道名字 pc = {} sql = ''' select id, name, config from admin_pay_channel ''' for line in LogQry(channel).qry(sql): pc[line[0]] = [line[1], line[2]] sql = ''' select id, api_name from admin_online_payment where channel_id = %d ''' % (channel) for line in LogQry(channel).qry(sql): pc[line[0]] = [line[1], ""] ml = {} ml[0] = u"默认" sql = ''' select id, member_level_name from admin_member_level where channel_id = %d ''' % channel for line in LogQry(channel).qry(sql): ml[line[0]] = line[1] ## 操作员查询 operator = {0: ""} sql = ''' select id, name from user ''' for line in SqlOperate().select(sql): operator[line[0]] = line[1] ## 查询满足条件的订单详情 sql = ''' select time, pid, vip, (select account_id from player where id = pid), (select nick from player where id = pid), orderno, platformno, cost, state, type, pay_channel, request_pid, review_time, review_pid, memo, coin, pay_name from admin_recharge %s where time >= %d and time <= %d %s order by state desc, time desc limit %s, %s ''' % (use_index, start_date, end_date, where, offset, pagesize) datas = [] for line in LogQry(channel).qry(sql): d = {} d["request_time"] = line[0] d["id"] = line[1] d["vip"] = ml.get(line[2]) d["account"] = line[3] d["nick"] = line[4] d["order_no"] = line[5] d["cost"] = line[7] d["state"] = line[8] d["pay_type"] = line[9] d["pay_chanel"] = pc[line[10]][0] d["request_pid"] = operator[line[11]] d["review_time"] = line[12] d["review_pid"] = operator[line[13]] d["memo"] = line[14] d["coin"] = line[15] d["name"] = line[16] d["pay_chanel_config"] = pc[line[10]][1] datas.append(d) return jsonify({ "errcode": 0, "dataLength": total_count, "rowDatas": datas })
def search_game_user_data(): start = request.args.get('beginDate', '') end = request.args.get('endDate', '') player_id = request.args.get('PlayerID', '') nick = request.args.get('NickName', '') reg_ip = request.args.get('reg_ip', '') # 接收渠道id channel = session['select_channel'] level = int(request.args.get('level', '')) offset = int(request.args.get("offset")) pagesize = int(request.args.get("size")) Where = "" if player_id: Where += " AND p.id='%s'" % player_id if nick: Where += " AND p.nick='%s'" % nick if level > 0: Where += " AND p.vip=%d" % level if reg_ip: Where += " AND p.reg_ip='%s'" % reg_ip ## 判断是否是当日查询 start_date = time_util.formatTimestamp(start) end_date = time_util.formatTimestamp(end) Where += ' AND p.reg_time >= %d ' % start_date Where += ' AND p.reg_time <= %d ' % end_date ## 查询满足条件的所有玩家 sql = ''' select count(1) from player p where 1 = 1 %s ''' % Where total_count = LogQry(channel).qry(sql)[0][0] ## 查询所有层级 memberl_lv = {} sql = ''' select id, member_level_name from admin_member_level ''' for k, v in LogQry(channel).qry(sql): memberl_lv[k] = v sql = ''' select p.id, p.nick, p.reg_time, p.coin, ifnull((select invite_id from player_agent where pid = p.id), ""), p.counter, p.last_login_time, p.account_id, p.vip, p.reg_ip from player as p where 1 =1 %s order by p.reg_time desc limit %d,%d ''' % (Where, offset, pagesize) pdatas = [] for line in LogQry(channel).qry(sql): try: memberl_lv_name = memberl_lv[max(line[8], 1)] except: memberl_lv_name = line[8] d = { "id": line[0], "nick": line[1].encode("utf-8"), "reg_time": line[2], "coin": line[3] + game_util.get_bank_coin(line[5]), "agent": line[4], "last_login_time": line[6], "account_id": line[7], "memberl_lv": memberl_lv_name, "reg_ip": line[9] } pdatas.append(d) return jsonify({ "errcode": 0, "dataLength": total_count, "rowDatas": pdatas })
def recharge_discounts_create_update(): """充值优惠设置新建/修改""" # 获取参数 channel_id = session['select_channel'] user_id = g.user_id activity_title = request.form.get('activity_title') show_picture_url = request.form.get('show_picture_url') tab1_url = request.form.get('tab1_url') tab2_url = request.form.get('tab2_url') activity_type = request.form.get('activity_type') participation_member = request.form.get('participation_member') participation_level = request.form.get('participation_level') activity_content = request.form.get('activity_content') recharge_detail = request.form.get('recharge_detail') journal_require = request.form.get('journal_require') request_times = request.form.get('request_times') max_add_recharge = request.form.get('max_add_recharge') begin_time = request.form.get('begin_time') end_time = request.form.get('end_time') priority = request.form.get('priority') activity_id = request.form.get('activity_id') # 校验并处理参数 if not all([begin_time, end_time, priority, activity_content]): return jsonify(result=0, msg=u'请输入所有必填项!') try: int(priority) int(journal_require) int(request_times) max_add_recharge = int(max_add_recharge) * 100 except ValueError: return jsonify(result=0, msg=u'流水要求、申请次数、最高赠送、优先级为整数纯数字!') try: recharge_detail = eval(recharge_detail) except Exception: return jsonify(result=0, msg=u'所有充值梯度里的项都是必填项,且为整数纯数字!') for one in recharge_detail: i = 0 for one_in_one in one: try: one[i] = int(one_in_one) * 100 except ValueError: return jsonify(result=0, msg=u'所有充值梯度里的项都是必填项,且为整数纯数字!') i += 1 if participation_level == ']': participation_level = '' begin_time = time_util.formatTimestamp(begin_time) end_time = time_util.formatTimestamp(end_time) if begin_time > end_time: return jsonify(result=0, msg=u'开始时间不能大于结束时间!') # 向游戏服发送请求 times = [begin_time] + [end_time] game_status = GameWeb(channel_id).post( '/api/up_activity', { 'id': int(activity_type), 'icon1': tab1_url, 'icon2': tab2_url, 'mark': activity_title, 'ord': int(priority), 'detail': show_picture_url, 'times': times, 'rules': activity_content }) if game_status['result'] != 'ok': return jsonify(result=0, msg='创建失败!') # 根据当前时间判定新建的活动的状态 if begin_time < time_util.now_sec() < end_time: status = TAKE_EFFECT else: status = LOSE_EFFICACY # 查询账号名 retrieve_sql = """SELECT name FROM user WHERE id=%s;""" % user_id user_id = SqlOperate().select(retrieve_sql)[0][0] # 新建充值优惠 if not activity_id: # 先把同活动类型为生效状态的活动改状态为失效 update_sql = """UPDATE admin_recharge_discounts SET status=%s WHERE status=%s AND activity_type=%s;""" \ % (LOSE_EFFICACY, TAKE_EFFECT, activity_type) LogQry(channel_id).execute(update_sql) # 再新建新的活动 create_sql = """INSERT INTO admin_recharge_discounts VALUES (0,'%s',%s,'%s','%s',%s, %s,'%s','%s','%s',%s, %s,'%s','%s',%s,%s, %s,%s);""" \ % (user_id, priority, activity_title, activity_content, activity_type, participation_member, show_picture_url, tab1_url, tab2_url, begin_time, end_time, participation_level, recharge_detail, request_times, max_add_recharge, journal_require, status) LogQry(channel_id).execute(create_sql) return jsonify(result=1, msg=u'新建成功!') # 修改充值优惠 else: # 先把同活动类型为生效状态的活动改状态为失效 update_sql = """UPDATE admin_recharge_discounts SET status=%s WHERE status=%s AND activity_type=%s;""" \ % (LOSE_EFFICACY, TAKE_EFFECT, activity_type) LogQry(channel_id).execute(update_sql) # 再修改活动 update_sql = """UPDATE admin_recharge_discounts SET priority=%s,activity_title='%s',activity_content='%s',activity_type=%s,participation_member=%s, show_picture_url='%s',tab1_url='%s',tab2_url='%s',begin_time=%s,end_time=%s, participation_level='%s',recharge_detail='%s',request_times=%s,max_add_recharge=%s,journal_require=%s, status=%s,user_id='%s' WHERE id=%s;""" \ % (priority, activity_title, activity_content, activity_type, participation_member, show_picture_url, tab1_url, tab2_url, begin_time, end_time, participation_level, recharge_detail, request_times, max_add_recharge, journal_require, status, user_id, activity_id) LogQry(channel_id).execute(update_sql) return jsonify(result=1, msg=u'修改成功!')
def update_activity(): """修改活动""" # 获取参数 picture_url = request.form.get('picture_url') activity_title = request.form.get('activity_title') tab1_url = request.form.get('tab1_url') tab2_url = request.form.get('tab2_url') begin_time = request.form.get('begin_time') end_time = request.form.get('end_time') entry_fee = request.form.get('entry_fee') activity_content = request.form.get('activity_content') priority = request.form.get('priority') activity_type = request.form.get('activity_type') activity_id = request.form.get('activity_id') user_id = g.user_id channel_id = session['select_channel'] # 校验并处理参数 if not all([begin_time, end_time, priority, activity_content]): return jsonify(result=2, errormsg=u'请输入必填项!') if entry_fee: try: int(entry_fee) except ValueError as e: return jsonify(result=2, errormsg=u'报名费为整数纯数字!') else: entry_fee = 'null' try: int(priority) except ValueError as e: return jsonify(result=2, errormsg=u'优先级为整数纯数字!') begin_time = time_util.formatTimestamp(begin_time) end_time = time_util.formatTimestamp(end_time) # 向游戏服发送请求 times = [begin_time] + [end_time] if activity_type == '2': game_status = GameWeb(channel_id).post( '/api/up_activity', { 'id': int(activity_type), 'icon1': tab1_url, 'icon2': tab2_url, 'mark': activity_title, 'ord': int(priority), 'detail': picture_url, 'entry_fee': int(entry_fee), 'times': times, 'rules': activity_content }) else: game_status = GameWeb(channel_id).post( '/api/up_activity', { 'id': int(activity_type), 'icon1': tab1_url, 'icon2': tab2_url, 'mark': activity_title, 'ord': int(priority), 'detail': picture_url, 'times': times, 'rules': activity_content }) if game_status['result'] != 'ok': return jsonify(result=2, msg='修改失败!') # 根据当前时间判定新建的活动的状态 if begin_time < time_util.now_sec() < end_time: status = TAKE_EFFECT else: status = LOSE_EFFICACY # 同活动类型为生效状态的活动改状态为失效 update_sql = """UPDATE admin_activity SET status=%s WHERE status=%s AND activity_type=%s;""" \ % (LOSE_EFFICACY, TAKE_EFFECT, activity_type) LogQry(channel_id).execute(update_sql) # 查询账号名 retrieve_sql = """SELECT name FROM user WHERE id=%s;""" % user_id user_id = SqlOperate().select(retrieve_sql)[0][0] # 存进数据库 update_activity_sql = """UPDATE admin_activity SET activity_title='%s',activity_content='%s',picture_url='%s',tab1_url='%s',tab2_url='%s', begin_time=%s,end_time=%s,entry_fee=%s,priority=%s,activity_type=%s, status=%s,user_id='%s' WHERE id=%s;""" \ % (activity_title, activity_content, picture_url, tab1_url, tab2_url, begin_time, end_time, entry_fee, priority, activity_type, status, user_id, activity_id) LogQry(channel_id).execute(update_activity_sql) # 返回应答 return jsonify(result=1)
def create_marquee(): """新建跑马灯""" # 获取参数 channel_id = session['select_channel'] user_id = g.user_id marquee_content = request.form.get('marquee_content') push_times = request.form.get('push_times') begin_time = request.form.get('begin_time') end_time = request.form.get('end_time') # 校验并处理数据 if not all([marquee_content, push_times, begin_time, end_time]): return jsonify(result=2) try: push_times = int(push_times) except ValueError as e: return jsonify(result=3) if int(push_times) < -1: return jsonify(result=3) begin_time = time_util.formatTimestamp(begin_time) end_time = time_util.formatTimestamp(end_time) if begin_time > end_time: return jsonify(result=5) # 根据时间戳和账号ID生成公告ID key_id = int(str(time_util.now_sec()) + str(user_id)) # 向游戏端发送请求 if push_times == -1: game_push_times = 88888 else: game_push_times = push_times game_status = GameWeb(channel_id).post( '/api/send_notice', { 'notice': marquee_content, 'start': begin_time, 'end': end_time, 'max': game_push_times, 'id': key_id }) if game_status['result'] != 'succ': return jsonify(result=4) # 查询账号名 retrieve_sql = """SELECT name FROM user WHERE id=%s;""" % user_id user_id = SqlOperate().select(retrieve_sql)[0][0] # 存进数据库 create_marquee_sql = """INSERT INTO admin_marquee (user_id,marquee_content,push_times,begin_time,end_time, status,id) VALUE('%s','%s',%s,%s,%s, %s,%s);""" \ % (user_id, marquee_content, push_times, begin_time, end_time, TAKE_EFFECT, key_id) LogQry(channel_id).execute(create_marquee_sql) # 返回应答 return jsonify(result=1)
def card_data_retrieve(): """卡号数据查询""" # 获取参数 channel_id = session['select_channel'] code = request.args.get('code') pid = request.args.get('PlayerID') begin_date = request.args.get('beginDate') end_date = request.args.get('endDate') size = request.args.get('size') offset = request.args.get('offset') # 校验并处理参数 where_str = '' if code: code_list = list() for i in code: code_list.append(ord(i)) code_str = str(code_list).replace(' ', '') where_str += " AND detail LIKE '%%,%s,%%'" % code_str elif pid: try: int(pid) except ValueError: return jsonify(result=0, msg=u'玩家ID为整数纯数字!') where_str += " AND detail like '[%s,[%%'" % pid elif begin_date and end_date: begin_date = time_util.formatTimestamp(begin_date) end_date = time_util.formatTimestamp(end_date) where_str += " AND time>=%s AND time<=%s" % (begin_date, end_date) # 从数据库获取数据 retrieve_sql = """SELECT count(*) FROM log_activity WHERE activity_type=4 %s;""" % where_str total_count = LogQry(int(channel_id)).qry(retrieve_sql)[0][0] retrieve_sql = """SELECT detail,time FROM log_activity WHERE activity_type=4 %s ORDER BY time DESC LIMIT %s,%s;""" \ % (where_str, offset, size) datas = LogQry(int(channel_id)).qry(retrieve_sql) # 如果有数据就处理数据并返回 if datas: datas_list = list() for detail, time in datas: data_dict = dict() detail_list = eval(detail) activation_code = '' for i in detail_list[1]: activation_code += chr(int(i)) data_dict['activation_code'] = activation_code data_dict['type'] = detail_list[2] data_dict['award'] = id_map_property(str(detail_list[3])) data_dict['overdue_time'] = overdue_map_id[detail_list[2]] data_dict['player'] = detail_list[0] data_dict['use_time'] = time_util.formatDateTime(time) datas_list.append(data_dict) return jsonify(result=1, data=datas_list, dataLength=total_count) # 如果没有数据并且输入了激活码就调用游戏服接口判断该激活码的状态 elif not datas and code: status = GameWeb(int(channel_id)).post('/api/code_stat', {'code': code}) if status['result'] == 0: return jsonify(result=0, msg=u'该激活码未使用!', data=[], dataLength=total_count) else: return jsonify(result=0, msg=u'该激活码不存在!', data=[], dataLength=total_count) # 其余情况均返回提示无数据 else: return jsonify(result=0, msg=u'无数据!', data=[], dataLength=total_count)