示例#1
0
def do_add(request):

    usm = UserStateManager(request)
    #    if not usm.current_userRole_is_root():
    #        return HttpResponse('非法操作已被记录!')
    the_user = usm.get_the_user()

    pay_channel = int(
        request.GET.get('pay_channel', request.POST.get('pay_channel', 0)))
    server_id = int(
        request.GET.get('server_id', request.POST.get('server_id', 0)))
    player_id = int(
        request.GET.get('player_id', request.POST.get('player_id', 0)))
    try:
        amount = float(request.GET.get('amount', request.POST.get('amount',
                                                                  0)))
    except:
        return HttpResponse('金额只能输入数字')
    order_id = request.GET.get('order_id', request.POST.get('order_id', ''))

    if order_id.__len__() > 50:
        return HttpResponse('订单号过长')
    if amount > 9999:
        return HttpResponse('金额过多')

    ip = OperateLogManager.get_request_ipAddress(request)
    try:
        OperateLogManager.save_operate_log(
            the_user.id,
            '添加订单, pay_channel:%s server_id:%s player_id:%s  amount:%s' %
            (pay_channel, server_id, player_id, amount), '/pay/add', ip, 0)
    except Exception, ex:
        print ex
示例#2
0
def save_modify_server_log(source, target, the_user_id, ip, request_path):
    msg = []
    if source.client_ver != target.client_ver:
        msg.append(u'客户端版本')
    if source.name != target.name:
        msg.append(u'名称')
    if source.status != target.status:
        msg.append(u'状态')
    if source.commend != target.commend:
        msg.append(u'推荐')
    if source.require_ver != target.require_ver:
        msg.append(u'最低版本')
    if source.game_addr != target.game_addr:
        msg.append(u'ip')
    if source.game_port != target.game_port:
        msg.append(u'port')
    if source.report_url != target.report_url:
        msg.append(u'url')
    if source.log_db_config != target.log_db_config:
        msg.append(u'db_config')
    if source.remark != target.remark:
        msg.append(u'备注')
    if source.order != target.order:
        msg.append(u'排序')
    if source.json_data != target.json_data:
        msg.append(u'json_data')
    if source.create_time != target.create_time:
        msg.append(u'开服时间')

    if msg.__len__() == 0:
        str_msg = '无修改'
    else:
        str_msg = ','.join(msg)

    OperateLogManager.save_operate_log(the_user_id, str_msg, request_path, ip)
示例#3
0
def save_server_log(server_id, is_add, request, source, target):
    the_user_id = UserStateManager.get_the_user_id(request)
    ip = OperateLogManager.get_request_ipAddress(request)
    request_path = '/server/save/%s' % server_id
    if not is_add:
        save_modify_server_log(source, target, the_user_id, ip, request_path)
    else:
        OperateLogManager.save_operate_log(the_user_id, '新建服务器', request_path,
                                           ip)
示例#4
0
def save_server_modify_log(request, log_param, server_id):
    msg_str = u'没有操作'
    msg = []
    for key in log_param:
        msg.append(key)
    if msg.__len__() != 0:
        msg_str = ','.join(msg)
    the_user_id = UserStateManager.get_the_user_id(request)
    ip = OperateLogManager.get_request_ipAddress(request)
    request_path = '/game/server/info/%s' % server_id
    OperateLogManager.save_operate_log(the_user_id, msg_str, request_path, ip)
示例#5
0
def pay_fix(request):
    pay_id = int(request.POST.get('pay_id', '0'))
    order_id = request.POST.get('order_id', '0')
    pay_amount = float(request.POST.get('pay_amount', '0'))

    if pay_id == 0 or order_id == 0 or pay_amount == 0:
        return HttpResponse(-1)

    rate = 10
    pay_entity = PayAction.objects.using('write').get(id=pay_id)

    if PayChannel.objects.using('read').filter(
            id=pay_entity.pay_type).count() != 0:
        pay_channel_entity = PayChannel.objects.using('read').get(
            id=pay_entity.pay_type)
        rate = pay_channel_entity.exchange_rate

    #***********写日志 *********
    the_user_id = UserStateManager.get_the_user_id(request)
    OperateLogManager.save_operate_log(
        the_user_id, u'人工补单ID:%d 渠道订单%s' % (pay_id, order_id),
        '/pay/retroactively', OperateLogManager.get_request_ipAddress(request))

    #***********写日志  END **********

    pay_gold = pay_amount * rate
    pay_entity.post_time = datetime.datetime.now()
    pay_entity.order_id = order_id
    pay_entity.pay_amount = pay_amount
    pay_entity.pay_gold = pay_gold
    pay_entity.pay_status = 2
    pay_entity.remark = u'人工补单 %s' % pay_entity.remark
    if pay_entity.query_id == '':
        pay_entity.query_id = pay_entity.get_query_id()
    pay_entity.save(using='write')

    entity = {}
    entity['id'] = pay_entity.id
    entity['order_id'] = pay_entity.order_id
    entity['pay_amount'] = pay_entity.pay_amount
    entity['pay_gold'] = pay_entity.pay_gold
    entity['pay_status'] = pay_entity.pay_status
    entity['remark'] = pay_entity.remark
    return HttpResponse(json.dumps(entity))
示例#6
0
def save_group_modify_log(request, source, target, is_updateServerList,
                          post_server_list, source_server_list):
    admin_id = UserStateManager.get_the_user_id(request)
    msg = []

    msg_str = u"没有操作"

    if source.key != target.key:
        msg.append('key')
    if source.name != target.name:
        msg.append('name')
    if source.custom_url != target.custom_url:
        msg.append('custom_url')
    if source.pay_url != target.pay_url:
        msg.append('pay_url')
    if source.upgrade_url != target.upgrade_url:
        msg.append('upgrade_url')
    if source.notice_url != target.notice_url:
        msg.append('notice_url')
    if int(source.notice_select) != int(target.notice_select):
        msg.append('notice_select')
    if source.remark != target.remark:
        msg.append('remark')

    if is_updateServerList:
        msg.append(u'server(')
        tmp_list = []
        for item in source_server_list:
            tmp_list.append(str(item['id']))
        msg.append(','.join(tmp_list))
        msg.append(':')
        msg.append(','.join(post_server_list))
        msg.append(')')

    if msg.__len__() != 0:
        msg_str = ','.join(msg)

    request_path = 'group/save/%s' % source.id

    OperateLogManager.save_operate_log(
        admin_id, msg_str, request_path,
        OperateLogManager.get_request_ipAddress(request))
示例#7
0
def statistic_execute(request, statistic_id=0, server_id=0):
    #是否自动任务执行
    auto_task = int(request.GET.get('task', 0))
    model_id = int(statistic_id)
    server_id = int(server_id)
    the_date = request.GET.get('date', '')
    r_date = request.GET.get('rdate', '')

    err_msg = ''
    if 0 == model_id:
        model_id = int(request.GET.get('statistic_id', '0'))
        statistic_id = model_id

    if 0 == server_id:
        server_id = int(request.GET.get('server_id', '0'))

    if the_statistic_in_center(model_id):
        server_id = 0

    #是否Ajax批量执行
    is_ajax_batch_execute = request.GET.get('ajax_batch', False)

    model = None
    if statistic_id > 0:
        model = Statistic.objects.using('write').get(id=statistic_id)
    if model == None:
        return HttpResponse("统计对象为空!")

    statisticModule = StatisticModule('')
    #    statisticModule.getStatistic()
    #    statisticModule.getLogDefine()
    #    statisticModule.getFieldDefine()
    statisticModule.getServer(server_id)
    result = statisticModule.Result(False, the_date, '', the_date)
    is_error = True
    try:
        s_model = {}
        s_model['id'] = model.id
        s_model['log_type'] = model.log_type
        s_model['count_type'] = model.count_type
        s_model['name'] = model.name
        s_model['field_name'] = model.field_name
        s_model['where'] = model.where
        s_model['sql'] = model.sql
        s_model['exec_interval'] = model.exec_interval
        s_model['last_exec_time'] = model.last_exec_time
        s_model['is_auto_execute'] = model.is_auto_execute
        s_model['auto_exec_interval'] = model.auto_exec_interval
        s_model['remark'] = model.remark
        s_model['result_data'] = model.result_data

        result = statisticModule.statistic_execute(s_model, server_id,
                                                   the_date)

    except Exception, ex:
        result = None

        msg = u'统计出错, 服务器ID:%s' % server_id
        print 'views#log#statistic.py   exec statistic error'
        print ex
        OperateLogManager.save_operate_log(0, msg, '', '', 1)