def get_stand_equip(data): # 2 #名字 configId # 强化等级 extraData > strength # 玉石 jades # 玉链 activeJadeLink jadeLinks[int(activeJadeLink)-1] if not data: return [] _result = [] stand_equip = DictDefine.get_dict_for_key("stand_equip") jades = DictDefine.get_dict_for_key("jades") jadeLinks = DictDefine.get_dict_for_key("jadelinks") for s in data: _t = [] _t.append(stand_equip.get(str(s["configId"]), s["configId"])) _t.append(s["extraData"]["strength"]) _t.append([ jades.get(str(s["extraData"]["jades"][i]), s["extraData"]["jades"][i]) for i in s["extraData"]["jades"] ]) _t.append( jadeLinks.get( str(s["extraData"]["jadeLinks"] [int(s["extraData"]["activeJadeLink"]) - 1]["id"]), s["extraData"]["jadeLinks"] [int(s["extraData"]["activeJadeLink"]) - 1]) if s["extraData"]["jadeLinks"] else 0) _result.append(_t) return _result
def get_equip_item(data): if not data: return [] daoju = DictDefine.get_dict_for_key("equipment") kernelEquip = DictDefine.get_dict_for_key("kernelEquip") _result = [] for item in data["mainBag"]: daojuId = item["configId"] _name = daoju.get(str(daojuId), daojuId) _name = kernelEquip.get(str(_name), _name) if _name == daojuId else _name _t = [_name] _t.append(item["amount"]) _result.append(_t) return _result
def query_display_process(query_analysis, list_data, page_num, page_size): '''值定义处理 ''' fields = query_analysis.query.selects # 查询的表头 field_configs = [] for field_name in fields: field_config = query_analysis.query.field_config.get(field_name, {}) field_config['field_name'] = field_name dict_key = field_config.get('dict', '') value_defs = DictDefine.get_dict_for_key(dict_key, reverse=False) field_config['value_defs'] = value_defs field_configs.append(field_config) if field_name == '排名': field_config['rank'] = True new_list_data = [] list_data = list(list_data) n = (page_num - 1) * page_size if page_num > 1 else 0 for row in list_data: item = list(row) item_len = len(item) n += 1 for i, _ in enumerate(fields): if item_len > i: field_config = field_configs[i] if field_config.get('rank', False): item[i] = n else: item[i] = display_format(field_config, item[i]) new_list_data.append(item) return new_list_data
def get_clr_equip(data): # 1 #名字 configId #词条属性 entryList > entryId ,attr[0] > value # 星级 衣服+ 武器 len(clothesStar) # 星级加成 [i["add"] for i in clothesStar] if not data or not data["artifacts"]: return [] kernelEquip = DictDefine.get_dict_for_key("kernelEquip") _result = {} _result["cloth"], _result["weapon"] = [], [] weapon = data["artifacts"][0] if int( data["artifacts"][0]["configId"]) < 210000 else data["artifacts"][1] cloth = data["artifacts"][0] if int( data["artifacts"][0]["configId"]) > 210000 else data["artifacts"][1] _t = {"weapon": weapon, "cloth": cloth} _star = {"weapon": "weaponStar", "cloth": "clothesStar"} for t in _t: _result[t].append( kernelEquip.get(str(_t[t]["configId"]), _t[t]["configId"])) _result[t].append(len(data[_star[t]])) _result[t].append([i["add"] for i in data[_star[t]]]) return _result.values()
def edit(request, id): id = int(id or request.GET.get('id', '') or 0) dict_key = request.REQUEST.get('key', '') if id: m = DictDefine.objects.using('read').get(id=id) if DictValue.objects.using("read").filter(dict_id=id): # 目前只能写这么low的语句了,有空再改 ea = DictValue.objects.using("read").get(dict_id=id) return render_to_response('log/dict_edit2.html', locals()) elif dict_key: m = DictDefine.objects.using('read').get(key=dict_key) else: m = DictDefine() ea = DictValue() m.id = 0 return render_to_response('log/dict_edit.html', locals())
def activity_setting(request, template='game/activity_setting.html'): server_id = int(request.REQUEST.get('server_id', '') or 0) is_read = request.REQUEST.get('is_read', '') model = get_activity_model(request) default_params = model.get_activity_protocol_class().get_default_msg() charge_dict = DictDefine.get_dict_for_key("recharge_type") charge_dict = OrderedDict( sorted(charge_dict.items(), key=lambda t: int(t[0]))) return render_to_response(template, locals())
def get_server_list(value): model = GroupList.objects.using('read').get(id=value) iid = [int(s.id) for s in model.server.all()] the_dict = DictDefine.get_dict_for_key('server_name ') l = [] for i in iid: name = the_dict.get(str(i),'') result = '(%s)%s' %(i,name) l.append(result) return ','.join(l)
def get_sell_item(data): if not data: return [] _result = [] daoju = DictDefine.get_dict_for_key("equipment") for i in data: _temp = [] _temp.append(daoju.get(str(i["itemId"]), i["itemId"])) _temp.append(i["count"]) _temp.append( time.strftime("%Y:%m:%d %H:%M:%S", time.localtime(i["stackTime"]))) _temp.append(i["price"]) _result.append(_temp) return _result
def battle_server_list(request, group_id=0): '''跨服列表 ''' group_id = int (request.REQUEST.get('group_id','') or 0) list_record = BattleList.objects.all().order_by('create_time') SERVER_NAME = DictDefine.get_dict_for_key("server_name") server_name = {} for k,v in SERVER_NAME.iteritems(): server_name[int(k)] = v STATUS_CHOICES = KuaFuServer.STATUS_CHOICES for item in list_record: item.score = int(item.f1 or 0) + int(item.f2 or 0) + int(item.f3 or 0) return render_to_response('server/battle_server_list.html', locals())
def get_magic(data): # strength star state 1 佩戴 2 未佩戴 3 共鸣 if not data: return [] _result = [] _state = {1: "佩戴", 2: "未佩戴", 3: "共鸣"} magicWeapon = DictDefine.get_dict_for_key("magicWeapon") for m in data: _t = [] _t.append(magicWeapon.get(str(m["configId"]), m["configId"])) _t.append(m["extraData"]["strength"]) _t.append(m["extraData"]["star"]) _t.append(_state[m["extraData"]["state"]]) _result.append(_t) return _result
def save(request, id=""): _p = lambda x, y='': request.REQUEST.get(x, y) id = int(id or request.REQUEST.get('id', '') or 0) err_msg = '' print _p('earn', "") try: if id: m = DictDefine.objects.using('read').get(id=id) else: m = DictDefine() m.key = _p('key', '') m.name = _p('name', '') m.group = _p('group', '') m.json_dict = _p('dict', '') m.type = _p('type', '0') m.remark = _p('remark', '') m.save(using='write') if _p('earn', ""): ea = DictValue.objects.using("read").get(dict_id=id) ea.json_dict = _p('earn', "") ea.dict_name = _p('name', '') ea.save(using='write') except Exception, e: err_msg = trace_msg()
def send_all_battle(log_user,params=None,send_type=None): servers = BattleList.objects.all() kuafu_map = DictDefine.get_dict_for_key("kuafu_type") result = [] save_log('logs/server/battle_server/','params',"%s"%params) for s in servers: if not s.group or not s.sort: continue if params: if s.server not in [int(x) for x in params.keys()]: continue base_query = Q(group=s.group) & Q(sort=s.sort) other_server = BattleList.objects.filter(base_query) server_list = [] master_server = 0 for _s in other_server: if int(_s.sub_group) == 1: master_server = _s.server server_list.append(_s.server) if not master_server: msg = u'%s服 没有主服 配置:大组-%s 分区-%s,分组-%s'%(s.server,s.sort,s.group,s.sub_group) save_log('logs/server/battle_server/','error',msg) result.append(s.server) for t in send_type: write_kuafu_log(log_user,t,s.server,s.sort,s.group,s.sub_group,msg,1) continue gmp = GMProtocol(int(s.server)) _result = gmp.send_battle_server(master_server,server_list,send_type) if _result == 0: s.f8 = "success" s.last_time = datetime.datetime.now() s.status = 1 s.save() msg = u'%s服 已发送 配置:大组-%s 分区-%s,分组-%s'%(s.server,s.sort,s.group,s.sub_group) print msg save_log('logs/server/battle_server/','success',msg) for t in send_type: write_kuafu_log(log_user,t,s.server,s.sort,s.group,s.sub_group,msg,0) return result
def dict_key(value,key_name): the_dict = DictDefine.get_dict_for_key(key_name) return the_dict.get(value,the_dict.get(str(value),value))
def player_list(request): '''玩家列表 ''' server_id = int(request.REQUEST.get('server_id', '') or 0) player_id = int(request.REQUEST.get('player_id', '') or 0) single = request.REQUEST.get("type", "") query_name = '玩家角色管理' charge_map = DictDefine.get_dict_for_key("recharge_type") request.POST.setlist("charge_map", charge_map.values()) print '玩家角色管理', request.POST.getlist('server_id', '') request.has_shutup = True if server_id: shutup_player_list = {} gmp = GMProtocol(server_id) result = gmp.player_shutup_list(0) resutl = json.dumps(result) for l in result[0]: try: timestamp_to_datetime_str(l[2]) except Exception as e: l[2] = l[1] + max_time shutup_player_list[l[0]] = [ timestamp_to_datetime_str(l[1]), timestamp_to_datetime_str(l[2]) ] player_ids = shutup_player_list.keys() if server_id and player_id and single == 'single': conn = Server.get_conn(server_id) cur = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor) sql = """select '',p.player_id,%s,p.player_name,CONVERT(IFNULL(pp.log_level,'1'),SIGNED) level,p.channel_id,p.other,p.user_type,p.link_key,p.login_num,p.mobile_key,p.last_time,p.last_ip,p.create_time,p.status , '' as action from player_%s p LEFT JOIN ( select log_user,MAX(log_level) as log_level from log_player_level group by log_user ) pp ON p.player_id=pp.log_user where player_id = %s""" % ( server_id, server_id, player_id) cur.execute(sql) player = cur.fetchone()[0] conn.close() if player: last_time = player["last_time"].strftime('%Y-%m-%d %H:%M:%S') create_time = player["create_time"].strftime('%Y-%m-%d %H:%M:%S') for t in Player.TYPE_CHOICES: if player["user_type"] == t[0]: user_type = t[1] for s in Player.STATUS_CHOICES: if player["status"] == s[0]: status = s[1] request.playerData = [[ "", player["player_id"], server_id, player["player_name"], player["level"], player["channel_id"], player["other"], user_type, player["link_key"], player["login_num"], player["mobile_key"], last_time, player["last_ip"], create_time, status, "" ]] def list_data_handle(list_data): new_list_data = [] for p in request.playerData: if p[1] in player_ids: new_list_data.append( list(p) + shutup_player_list.get(player_id, [0, 0])) if new_list_data: return new_list_data return request.playerData return query_view(request, query_name=query_name, list_data_handle=list_data_handle) if request.REQUEST.get('is_shutup', ''): try: player_ids = player_ids or [1] request.POST.setlist('player_id', player_ids) print shutup_player_list def list_data_handle(list_data): new_list_data = [] for row in list_data: player_id = row[1] new_list_data.append( list(row) + shutup_player_list.get(player_id, [0, 0])) return new_list_data return query_view(request, query_name=query_name, list_data_handle=list_data_handle) except: err_msg = trace_msg() return HttpResponse('{"code":-1,"msg":"%s"}' % err_msg) else: try: def list_data_handle(list_data): new_list_data = [] for row in list_data: player_id = row[1] if player_id in player_ids: new_list_data.append( list(row) + shutup_player_list.get(player_id)) else: new_list_data.append(list(row)) return new_list_data return query_view(request, query_name=query_name, list_data_handle=list_data_handle) except: err_msg = trace_msg() return HttpResponse('{"code":-1,"msg":"%s"}' % err_msg) return query_view(request, query_name)
def query_view(request, query_name='', query_model=None, is_query_do=False, list_data_handle=False, template='query/query_view.html'): '''查询视图,request 传入 @param query_name:查询名称 @param is_query_do: 是否执行查询 ''' now = datetime.datetime.now() _g = request.REQUEST.get _gl = request.REQUEST.getlist query_name = query_name or _g('query_name', '') or _g('name', '') print 'NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN', query_name query_id = int(_g('query_id', '') or _g('qid', '') or 0) # 不传id则使用查询名 if query_id: the_query = Query.objects.get(id=query_id) elif query_name: the_query = Query.objects.using('read').get(name=query_name) elif query_model: the_query = query_model else: return HttpResponse('没有 ID[%s] 或者 [%s] 的查询' % (query_id, query_name)) params = dict(request.GET) params.update(dict(request.POST)) # 必须为POST # print params log_def = the_query.log_def query_analysis = QueryAnalysis(the_query, params) is_center_query = the_query.is_center_query is_export = _g('is_export', 'False') == 'true' if is_export: # 导出 return query_export_do(request, query_analysis) if is_query_do or request.method == 'POST' or request.REQUEST.get( 'query_do') or request.GET.get('template', ''): return query_do(request, query_analysis, list_data_handle=list_data_handle) same_log_key_query_list = Query.objects.filter( log_key=the_query.log_key) # 查询的表定义 field_configs = SortedDict() conditions_configs = [] for cloumn in the_query.selects: field_config_item = the_query.field_config.get(cloumn, {}) field_configs[cloumn] = field_config_item for k in the_query.field_config.keys(): field_config_item = the_query.field_config[k] if field_config_item.get('single', ''): default_value = DictDefine.get_dict_for_key( field_config_item.get('dict', '')) else: default_value = params.get(field_config_item.get('name', ''), [''])[0] field_config_item['value'] = default_value order_num = int(field_config_item.get('order_num', 0) or 99) conditions_configs.append((k, field_config_item, order_num)) conditions_configs.sort(key=lambda x: x[2]) sd = request.REQUEST.get('sd', '') or now.strftime('%Y-%m-%d 00:00:00') ed = request.REQUEST.get('ed', '') or now.strftime('%Y-%m-%d 23:59:59') has_sd = query_analysis.has_mark('sd') has_ed = query_analysis.has_mark('ed') sdate = request.REQUEST.get('sdate', '') or now.strftime('%Y-%m-%d 00:00:00') edate = request.REQUEST.get('edate', '') or now.strftime('%Y-%m-%d 23:59:59') has_sdate = query_analysis.has_mark('sdate') has_edate = query_analysis.has_mark('edate') has_channel = query_analysis.has_mark( 'channel_id') or query_analysis.has_mark('channel_ids') has_server = query_analysis.has_mark( 'server_id') or query_analysis.has_mark('server_ids') has_server = has_server or not is_center_query has_neibuhao = query_analysis.has_mark('neibuhao') has_platform = query_analysis.has_mark( 'platform_id') or query_analysis.has_mark('platform_ids') has_conditions = query_analysis.has_conditions() if request.admin.is_agent and not has_channel: return render_to_response('block.html', {"err_msg": "'此查询非法!'"}) plugin_templates = [] if the_query.template_name: for template_name in the_query.template_name.split(','): if template_name.strip(): if template_name == "邮件列表": dj = json.dumps( eval(DictValue.objects.get(dict_id=88).json_dict)) plugin_templates.append('query/plugins/%s.html' % template_name) if has_server: # group_servers_dict = get_group_servers_dict(request) group_servers_dict = groups_servers(request) select_server_ids = [ int(sid) for sid in request.REQUEST.getlist('sid') if str(sid).isdigit() ] if has_channel: group_channels_dict = get_group_channels_dict() if has_platform: platforms = request.admin.get_resource('platform') server_id = int(request.REQUEST.get('server_id', 0)) return render_to_response(template, locals())
charge = extraInfo charge = charge.split("#") charge_id, charge_type, extra, user_id = 0, 0, "", "" try: charge_id = int(charge[0]) charge_type = int(charge[1]) extra = str(charge[2]) user_id = str(charge[3]) except Exception as e: print "get charge_id error", e # 支付通道 payType = "" chargeType = DictDefine.get_dict_for_key("charge_id_money") print '00000000000', chargeType if chargeType and amount and charge_id: need_amount = float(chargeType[str(charge_id)]) print 'vvvvvvvvvvvvvv', chargeType, need_amount if need_amount != float(amount): charge_id = 999 val = "amount%sappId%sbillno%sextraInfo%sorderId%sorderTime%sserverId%stest%suid%s" % ( amount, game_id, product_num, extraInfo, order_id, pay_time, server_id, test, uid) print 'kkkkkkkkkkkkkk', to_md5(val + app_key) if sign != to_md5(val + app_key).lower(): return {"result_msg": "check faill02"} print val, sign
fpContent[count] = ssg count += 1 all_logic = [] _keys = [] for key in fpContent: # get all logic _logic = fpContent[key]["logic"] all_logic.extend(_logic) _keys.append(key) for key in _keys: del fpContent[key] _server_group = {} tabName_map = DictDefine.get_dict_for_key('tabName') for server in all_logic: if server.has_key("tabId") and server["tabId"]: _tabId = server["tabId"] _server_group[_tabId] = _server_group[ _tabId] if _server_group.has_key( _tabId) else defaultdict(list) del server["tabId"] tabName = tabName_map[str( _tabId)] if tabName_map and tabName_map.has_key( str(_tabId)) else "" _server_group[_tabId]["tabName"] = tabName _server_group[_tabId]["logic"].append(server) count = 1 __server_group = {}