Beispiel #1
0
def account_update_post(db, render):
    form = account_forms.account_update_form()
    if not form.validates(source=request.forms):
        return render("base_form", form=form)

    account = db.query(models.SlcRadAccount).get(form.d.account_number)
    account.ip_address = form.d.ip_address
    account.install_address = form.d.install_address
    account.user_concur_number = form.d.user_concur_number
    account.bind_mac = form.d.bind_mac
    account.bind_vlan = form.d.bind_vlan
    account.account_desc = form.d.account_desc
    if form.d.new_password:
        account.password = utils.encrypt(form.d.new_password)

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改上网账号信息:%s' % (get_cookie("username"), account.account_number)
    db.add(ops_log)

    db.commit()
    websock.update_cache("account", account_number=account.account_number)
    redirect(member_detail_url_formatter(account.account_number))
Beispiel #2
0
def account_pause(db, render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)

    if account.status != 1:
        return dict(msg=u"用户当前状态不允许停机")

    _datetime = utils.get_currtime()
    account.last_pause = _datetime
    account.status = 2

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'pause'
    accept_log.accept_source = 'console'
    accept_log.accept_desc = u"用户停机:上网账号:%s" % (account_number)
    accept_log.account_number = account.account_number
    accept_log.accept_time = _datetime
    accept_log.operator_name = get_cookie("username")
    db.add(accept_log)

    db.commit()
    websock.update_cache("account", account_number=account.account_number)

    onlines = db.query(models.SlcRadOnline).filter_by(account_number=account_number)
    for _online in onlines:
        websock.invoke_admin("coa_request",
                             nas_addr=_online.nas_addr,
                             acct_session_id=_online.acct_session_id,
                             message_type='disconnect')
    return dict(msg=u"操作成功")
Beispiel #3
0
def account_resume(db,render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)
    if account.status != 2:
        return dict(msg=u"用户当前状态不允许复机")

    account.status = 1
    _datetime = datetime.datetime.now()
    _pause_time = datetime.datetime.strptime(account.last_pause, "%Y-%m-%d %H:%M:%S")
    _expire_date = datetime.datetime.strptime(account.expire_date + ' 23:59:59', "%Y-%m-%d %H:%M:%S")
    days = (_expire_date - _pause_time).days
    new_expire = (_datetime + datetime.timedelta(days=int(days))).strftime("%Y-%m-%d")
    account.expire_date = new_expire

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'resume'
    accept_log.accept_source = 'console'
    accept_log.accept_desc = u"用户复机:上网账号:%s" % (account_number)
    accept_log.account_number = account.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    db.add(accept_log)

    db.commit()
    websock.update_cache("account", account_number=account.account_number)
    return dict(msg=u"操作成功")
Beispiel #4
0
def roster_add_post(db):
    form = forms.roster_add_form()
    if not form.validates(source=request.forms):
        return render("sys_roster_form", form=form)
    if db.query(models.SlcRadRoster.id).filter_by(
            mac_addr=form.d.mac_addr).count() > 0:
        return render("sys_roster_form", form=form, msg=u"MAC地址已经存在")
    roster = models.SlcRadRoster()
    roster.mac_addr = form.d.mac_addr.replace("-", ":").upper()
    roster.begin_time = form.d.begin_time
    roster.end_time = form.d.end_time
    roster.roster_type = form.d.roster_type
    db.add(roster)

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)新增黑白名单信息:%s' % (get_cookie("username"),
                                                    roster.mac_addr)
    db.add(ops_log)

    db.commit()
    websock.update_cache("roster", mac_addr=roster.mac_addr)
    redirect("/roster")
Beispiel #5
0
def account_pause(db, render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)

    if account.status != 1:
        return dict(msg=u"用户当前状态不允许停机")

    _datetime = utils.get_currtime()
    account.last_pause = _datetime
    account.status = 2

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'pause'
    accept_log.accept_source = 'console'
    accept_log.accept_desc = u"用户停机:上网账号:%s" % (account_number)
    accept_log.account_number = account.account_number
    accept_log.accept_time = _datetime
    accept_log.operator_name = get_cookie("username")
    db.add(accept_log)

    db.commit()
    websock.update_cache("account", account_number=account.account_number)

    onlines = db.query(models.SlcRadOnline).filter_by(account_number=account_number)
    for _online in onlines:
        websock.invoke_admin("coa_request",
                             nas_addr=_online.nas_addr,
                             acct_session_id=_online.acct_session_id,
                             message_type='disconnect')
    return dict(msg=u"操作成功")
Beispiel #6
0
def account_update_post(db, render):
    form = account_forms.account_update_form()
    if not form.validates(source=request.forms):
        return render("base_form", form=form)

    account = db.query(models.SlcRadAccount).get(form.d.account_number)
    account.ip_address = form.d.ip_address
    account.install_address = form.d.install_address
    account.user_concur_number = form.d.user_concur_number
    account.bind_mac = form.d.bind_mac
    account.bind_vlan = form.d.bind_vlan
    account.account_desc = form.d.account_desc
    if form.d.new_password:
        account.password = utils.encrypt(form.d.new_password)

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改上网账号信息:%s' % (get_cookie("username"), account.account_number)
    db.add(ops_log)

    db.commit()
    websock.update_cache("account", account_number=account.account_number)
    redirect(member_detail_url_formatter(account.account_number))
Beispiel #7
0
def account_resume(db,render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)
    if account.status != 2:
        return dict(msg=u"用户当前状态不允许复机")

    account.status = 1
    _datetime = datetime.datetime.now()
    _pause_time = datetime.datetime.strptime(account.last_pause, "%Y-%m-%d %H:%M:%S")
    _expire_date = datetime.datetime.strptime(account.expire_date + ' 23:59:59', "%Y-%m-%d %H:%M:%S")
    days = (_expire_date - _pause_time).days
    new_expire = (_datetime + datetime.timedelta(days=int(days))).strftime("%Y-%m-%d")
    account.expire_date = new_expire

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'resume'
    accept_log.accept_source = 'console'
    accept_log.accept_desc = u"用户复机:上网账号:%s" % (account_number)
    accept_log.account_number = account.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    db.add(accept_log)

    db.commit()
    websock.update_cache("account", account_number=account.account_number)
    return dict(msg=u"操作成功")
Beispiel #8
0
def product_update(db, render):
    form = product_forms.product_update_form()
    if not form.validates(source=request.forms):
        return render("sys_product_form", form=form)
    product = db.query(models.SlcRadProduct).get(form.d.id)
    product.product_name = form.d.product_name
    product.product_status = form.d.product_status
    product.fee_months = int(form.d.get("fee_months", 0))
    product.fee_times = utils.hour2sec(form.d.get("fee_times", 0))
    product.fee_flows = utils.mb2kb(form.d.get("fee_flows", 0))
    product.bind_mac = form.d.bind_mac
    product.bind_vlan = form.d.bind_vlan
    product.concur_number = form.d.concur_number
    product.fee_period = form.d.fee_period
    product.fee_price = utils.yuan2fen(form.d.fee_price)
    product.input_max_limit = utils.mbps2bps(form.d.input_max_limit)
    product.output_max_limit = utils.mbps2bps(form.d.output_max_limit)
    product.update_time = utils.get_currtime()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改资费信息:%s' % (get_cookie("username"),
                                                  product.product_name)
    db.add(ops_log)

    db.commit()
    websock.update_cache("product", product_id=product.id)
    redirect(__prefix__)
Beispiel #9
0
def product_update(db, render):
    form = product_forms.product_update_form()
    if not form.validates(source=request.forms):
        return render("sys_product_form", form=form)
    product = db.query(models.SlcRadProduct).get(form.d.id)
    product.product_name = form.d.product_name
    product.product_status = form.d.product_status
    product.fee_months = int(form.d.get("fee_months", 0))
    product.fee_times = utils.hour2sec(form.d.get("fee_times", 0))
    product.fee_flows = utils.mb2kb(form.d.get("fee_flows", 0))
    product.bind_mac = form.d.bind_mac
    product.bind_vlan = form.d.bind_vlan
    product.concur_number = form.d.concur_number
    product.fee_period = form.d.fee_period
    product.fee_price = utils.yuan2fen(form.d.fee_price)
    product.input_max_limit = utils.mbps2bps(form.d.input_max_limit)
    product.output_max_limit = utils.mbps2bps(form.d.output_max_limit)
    product.update_time = utils.get_currtime()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改资费信息:%s' % (
        get_cookie("username"), product.product_name)
    db.add(ops_log)

    db.commit()
    websock.update_cache("product", product_id=product.id)
    redirect(__prefix__)
Beispiel #10
0
def clear_cache(db,render):
    def cbk(resp):
        print 'cbk',resp
    bottle.TEMPLATES.clear()
    for _cache in cache_managers.values():
        _cache.clear()
    websock.update_cache("all",callback=cbk)
    return dict(code=0,msg=u"已刷新缓存")
Beispiel #11
0
def clear_cache():
    def cbk(resp):
        print 'cbk',resp
    bottle.TEMPLATES.clear()
    for _cache in cache_managers.values():
        _cache.clear()
    websock.update_cache("all",callback=cbk)
    return dict(code=0,msg=u"已刷新缓存")
Beispiel #12
0
def roster_delete(db):     
    roster_id = request.params.get("roster_id")
    mac_addr = db.query(models.SlcRadRoster).get(roster_id).mac_addr
    db.query(models.SlcRadRoster).filter_by(id=roster_id).delete()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)删除黑白名单信息:%s'%(get_cookie("username"),roster_id)
    db.add(ops_log)

    db.commit() 
    websock.update_cache("roster",mac_addr=mac_addr)
    redirect("/roster")        
Beispiel #13
0
def roster_delete(db):
    roster_id = request.params.get("roster_id")
    mac_addr = db.query(models.SlcRadRoster).get(roster_id).mac_addr
    db.query(models.SlcRadRoster).filter_by(id=roster_id).delete()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)删除黑白名单信息:%s' % (get_cookie("username"),
                                                    roster_id)
    db.add(ops_log)

    db.commit()
    websock.update_cache("roster", mac_addr=mac_addr)
    redirect("/roster")
Beispiel #14
0
def product_attr_update(db): 
    attr_id = request.params.get("attr_id")
    attr = db.query(models.SlcRadProductAttr).get(attr_id)
    product_id = attr.product_id
    db.query(models.SlcRadProductAttr).filter_by(id=attr_id).delete()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)删除资费属性信息:%s'%(get_cookie("username"),serial_json(attr))
    db.add(ops_log)

    db.commit()
    websock.update_cache("product",product_id=product_id)
    redirect("%s/detail?product_id=%s"%(__prefix__,product_id))
Beispiel #15
0
def product_attr_update(db, render):
    attr_id = request.params.get("attr_id")
    attr = db.query(models.SlcRadProductAttr).get(attr_id)
    product_id = attr.product_id
    db.query(models.SlcRadProductAttr).filter_by(id=attr_id).delete()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)删除资费属性信息:%s' % (get_cookie("username"),
                                                    serial_json(attr))
    db.add(ops_log)

    db.commit()
    websock.update_cache("product", product_id=product_id)
    redirect("%s/detail?product_id=%s" % (__prefix__, product_id))
Beispiel #16
0
def user_release(db, render):
    account_number = request.params.get("account_number")
    user = db.query(models.SlcRadAccount).filter_by(account_number=account_number).first()
    user.mac_addr = ""
    user.vlan_id = 0
    user.vlan_id2 = 0

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u"释放用户账号(%s)绑定信息" % (account_number,)
    db.add(ops_log)

    db.commit()
    websock.update_cache("account", account_number=account_number)
    return dict(code=0, msg=u"解绑成功")
Beispiel #17
0
def user_release(db, render):
    account_number = request.params.get('account_number')
    user = db.query(
        models.SlcRadAccount).filter_by(account_number=account_number).first()
    user.mac_addr = ''
    user.vlan_id = 0
    user.vlan_id2 = 0

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'释放用户账号(%s)绑定信息' % (account_number, )
    db.add(ops_log)

    db.commit()
    websock.update_cache("account", account_number=account_number)
    return dict(code=0, msg=u"解绑成功")
Beispiel #18
0
def product_delete(db):     
    product_id = request.params.get("product_id")
    if db.query(models.SlcRadAccount).filter_by(product_id=product_id).count()>0:
        return render("error",msg=u"该套餐有用户使用,不允许删除") 
    if db.query(models.SlcRechargerCard).filter_by(product_id=product_id).count()>0:
        return render("error",msg=u"该套餐有发行充值卡,不允许删除")   
        
    db.query(models.SlcRadProduct).filter_by(id=product_id).delete()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)删除资费信息:%s'%(get_cookie("username"),product_id)
    db.add(ops_log)

    db.commit() 
    websock.update_cache("product",product_id=product_id)
    redirect(__prefix__)   
Beispiel #19
0
def roster_add_update(db): 
    form=forms.roster_update_form()
    if not form.validates(source=request.forms):
        return render("sys_roster_form", form=form)       
    roster = db.query(models.SlcRadRoster).get(form.d.id)
    roster.begin_time = form.d.begin_time
    roster.end_time = form.d.end_time
    roster.roster_type = form.d.roster_type

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改黑白名单信息:%s'%(get_cookie("username"),roster.mac_addr)
    db.add(ops_log)

    db.commit()
    websock.update_cache("roster",mac_addr=roster.mac_addr)
    redirect("/roster")    
Beispiel #20
0
def product_attr_update(db): 
    form = forms.product_attr_update_form()
    if not form.validates(source=request.forms):
        return render("pattr_form", form=form,pattrs=radius_attrs)   
    attr = db.query(models.SlcRadProductAttr).get(form.d.id)
    attr.attr_name = form.d.attr_name
    attr.attr_value = form.d.attr_value
    attr.attr_desc = form.d.attr_desc

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改资费属性信息:%s'%(get_cookie("username"),attr.attr_name)
    db.add(ops_log)

    db.commit()
    websock.update_cache("product",product_id=form.d.product_id)
    redirect("%s/detail?product_id=%s"%(__prefix__,form.d.product_id))
Beispiel #21
0
def roster_add_update(db):
    form = forms.roster_update_form()
    if not form.validates(source=request.forms):
        return render("sys_roster_form", form=form)
    roster = db.query(models.SlcRadRoster).get(form.d.id)
    roster.begin_time = form.d.begin_time
    roster.end_time = form.d.end_time
    roster.roster_type = form.d.roster_type

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改黑白名单信息:%s' % (get_cookie("username"),
                                                    roster.mac_addr)
    db.add(ops_log)

    db.commit()
    websock.update_cache("roster", mac_addr=roster.mac_addr)
    redirect("/roster")
Beispiel #22
0
def product_attr_update(db, render):
    form = product_forms.product_attr_update_form()
    if not form.validates(source=request.forms):
        return render("pattr_form", form=form, pattrs=radius_attrs)
    attr = db.query(models.SlcRadProductAttr).get(form.d.id)
    attr.attr_name = form.d.attr_name
    attr.attr_value = form.d.attr_value
    attr.attr_desc = form.d.attr_desc

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改资费属性信息:%s' % (get_cookie("username"),
                                                    attr.attr_name)
    db.add(ops_log)

    db.commit()
    websock.update_cache("product", product_id=form.d.product_id)
    redirect("%s/detail?product_id=%s" % (__prefix__, form.d.product_id))
Beispiel #23
0
def product_delete(db):
    product_id = request.params.get("product_id")
    if db.query(models.SlcRadAccount).filter_by(product_id=product_id).count() > 0:
        return render("error", msg=u"该套餐有用户使用,不允许删除")
    if db.query(models.SlcRechargerCard).filter_by(product_id=product_id).count() > 0:
        return render("error", msg=u"该套餐有发行充值卡,不允许删除")

    db.query(models.SlcRadProduct).filter_by(id=product_id).delete()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)删除资费信息:%s' % (
        get_cookie("username"), product_id)
    db.add(ops_log)

    db.commit()
    websock.update_cache("product", product_id=product_id)
    redirect(__prefix__)
Beispiel #24
0
def bas_add_update(db): 
    form=forms.bas_update_form()
    if not form.validates(source=request.forms):
        return render("base_form", form=form)
    bas = db.query(models.SlcRadBas).get(form.d.id)
    bas.bas_name = form.d.bas_name
    bas.time_type = form.d.time_type
    bas.vendor_id = form.d.vendor_id
    bas.bas_secret = form.d.bas_secret
    bas.coa_port = form.d.coa_port

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改BAS信息:%s'%(get_cookie("username"),bas.ip_addr)
    db.add(ops_log)

    db.commit()
    websock.update_cache("bas",ip_addr=bas.ip_addr)
    redirect("/bas")    
Beispiel #25
0
def param_update(db):
    params = db.query(models.SlcParam)
    for param in params:
        if param.param_name in request.forms:
            _value = request.forms.get(param.param_name)
            if _value:
                param.param_value = _value

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改参数' % (get_cookie("username"))
    db.add(ops_log)
    db.commit()

    websock.reconnect(
        request.forms.get('radiusd_address'),
        request.forms.get('radiusd_admin_port'),
    )

    is_debug = request.forms.get('is_debug')
    bottle.debug(is_debug == '1')

    websock.update_cache("is_debug", is_debug=is_debug)
    websock.update_cache("reject_delay",
                         reject_delay=request.forms.get('reject_delay'))
    websock.update_cache("param")
    redirect("/param")
Beispiel #26
0
def param_update(db): 
    params = db.query(models.SlcParam)
    for param in params:
        if param.param_name in request.forms:
            _value = request.forms.get(param.param_name)
            if _value: 
                param.param_value = _value  
                
    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改参数'%(get_cookie("username"))
    db.add(ops_log)
    db.commit()
    
    websock.reconnect(
        request.forms.get('radiusd_address'),
        request.forms.get('radiusd_admin_port'),
    )
        
    is_debug = request.forms.get('is_debug')
    bottle.debug(is_debug == '1')
    
    websock.update_cache("is_debug",is_debug=is_debug)
    websock.update_cache("reject_delay",reject_delay=request.forms.get('reject_delay'))
    websock.update_cache("param")
    redirect("/param")
Beispiel #27
0
def bas_add_update(db):
    form = forms.bas_update_form()
    if not form.validates(source=request.forms):
        return render("base_form", form=form)
    bas = db.query(models.SlcRadBas).get(form.d.id)
    bas.bas_name = form.d.bas_name
    bas.time_type = form.d.time_type
    bas.vendor_id = form.d.vendor_id
    bas.bas_secret = form.d.bas_secret
    bas.coa_port = form.d.coa_port

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改BAS信息:%s' % (get_cookie("username"),
                                                   bas.ip_addr)
    db.add(ops_log)

    db.commit()
    websock.update_cache("bas", ip_addr=bas.ip_addr)
    redirect("/bas")
Beispiel #28
0
def password_update_post(db, render):
    form = forms.password_update_form()
    if not form.validates(source=request.forms):
        return render("base_form", form=form)
        
    account = db.query(models.SlcRadAccount).filter_by(account_number=form.d.account_number).first()
    if not account:
        return render("base_form", form=form,msg=u'没有这个账号')
        
    if account.member_id != get_cookie("customer_id"):
        return render("base_form", form=form,msg=u'该账号用用户不匹配')
    
    if utils.decrypt(account.password) !=  form.d.old_password:
        return render("base_form", form=form,msg=u'旧密码不正确')
        
    if form.d.new_password != form.d.new_password2:
        return render("base_form", form=form,msg=u'确认新密码不匹配')
    
    account.password =  utils.encrypt(form.d.new_password)
    db.commit()
    websock.update_cache("account",account_number=account.account_number)
    redirect("/")
Beispiel #29
0
def password_update_post(db):
    form = forms.password_update_form()
    if not form.validates(source=request.forms):
        return render("base_form", form=form)

    account = db.query(models.SlcRadAccount).filter_by(
        account_number=form.d.account_number).first()
    if not account:
        return render("base_form", form=form, msg=u'没有这个账号')

    if account.member_id != get_cookie("customer_id"):
        return render("base_form", form=form, msg=u'该账号用用户不匹配')

    if utils.decrypt(account.password) != form.d.old_password:
        return render("base_form", form=form, msg=u'旧密码不正确')

    if form.d.new_password != form.d.new_password2:
        return render("base_form", form=form, msg=u'确认新密码不匹配')

    account.password = utils.encrypt(form.d.new_password)
    db.commit()
    websock.update_cache("account", account_number=account.account_number)
    redirect("/")
Beispiel #30
0
def roster_add_post(db): 
    form=forms.roster_add_form()
    if not form.validates(source=request.forms):
        return render("sys_roster_form", form=form)  
    if db.query(models.SlcRadRoster.id).filter_by(mac_addr=form.d.mac_addr).count()>0:
        return render("sys_roster_form", form=form,msg=u"MAC地址已经存在")     
    roster = models.SlcRadRoster()
    roster.mac_addr = form.d.mac_addr.replace("-",":").upper()
    roster.begin_time = form.d.begin_time
    roster.end_time = form.d.end_time
    roster.roster_type = form.d.roster_type
    db.add(roster)

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)新增黑白名单信息:%s'%(get_cookie("username"),roster.mac_addr)
    db.add(ops_log)

    db.commit()
    websock.update_cache("roster",mac_addr=roster.mac_addr)
    redirect("/roster")
Beispiel #31
0
def param_update(db, render):
    params = db.query(models.SlcParam)
    active = request.params.get("active", "syscfg")
    for param_name in request.forms:
        if param_name in ("active", "submit"):
            continue

        param = db.query(
            models.SlcParam).filter_by(param_name=param_name).first()
        if not param:
            param = models.SlcParam()
            param.param_name = param_name
            param.param_value = request.forms.get(param_name)
            db.add(param)
        else:
            param.param_value = request.forms.get(param_name)

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改参数' % (get_cookie("username"))
    db.add(ops_log)
    db.commit()

    if "radiusd_address" in request.forms:
        websock.reconnect(
            request.forms.get('radiusd_address'),
            request.forms.get('radiusd_admin_port'),
        )

    if "is_debug" in request.forms:
        is_debug = request.forms.get('is_debug')
        bottle.debug(is_debug == '1')
        websock.update_cache("is_debug", is_debug=is_debug)
    if "reject_delay" in request.forms:
        websock.update_cache("reject_delay",
                             reject_delay=request.forms.get('reject_delay'))

    websock.update_cache("param")
    redirect("/param?active=%s" % active)
Beispiel #32
0
def param_update(db, render):
    params = db.query(models.SlcParam)
    active = request.params.get("active", "syscfg")
    for param_name in request.forms:
        if param_name in ("active", "submit"):
            continue

        param = db.query(models.SlcParam).filter_by(param_name=param_name).first()
        if not param:
            param = models.SlcParam()
            param.param_name = param_name
            param.param_value = request.forms.get(param_name)
            db.add(param)
        else:
            param.param_value = request.forms.get(param_name)

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改参数' % (get_cookie("username"))
    db.add(ops_log)
    db.commit()

    if "radiusd_address" in request.forms:
        websock.reconnect(
            request.forms.get('radiusd_address'),
            request.forms.get('radiusd_admin_port'),
        )

    if "is_debug" in request.forms:
        is_debug = request.forms.get('is_debug')
        bottle.debug(is_debug == '1')
        websock.update_cache("is_debug", is_debug=is_debug)
    if "reject_delay" in request.forms:
        websock.update_cache("reject_delay", reject_delay=request.forms.get('reject_delay'))

    websock.update_cache("param")
    redirect("/param?active=%s"% active)
Beispiel #33
0
def account_next(db, render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)
    user = query_account(db, account_number)
    form = account_forms.account_next_form()
    form.product_id.set_value(user.product_id)
    if account.status not in (1, 4):
        return render("bus_account_next_form", user=user, form=form, msg=u"无效用户状态")
    if not form.validates(source=request.forms):
        return render("bus_account_next_form", user=user, form=form)

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'next'
    accept_log.accept_source = 'console'
    accept_log.accept_desc = u"用户续费:上网账号:%s,续费%s元" % (account_number, form.d.fee_value)
    accept_log.account_number = form.d.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    db.add(accept_log)
    db.flush()
    db.refresh(accept_log)

    history = models.SlcRadAccountHistory()
    history.accept_id = accept_log.id
    history.account_number = account.account_number
    history.member_id = account.member_id
    history.product_id = account.product_id
    history.group_id = account.group_id
    history.password = account.password
    history.install_address = account.install_address
    history.expire_date = account.expire_date
    history.user_concur_number = account.user_concur_number
    history.bind_mac = account.bind_mac
    history.bind_vlan = account.bind_vlan
    history.account_desc = account.account_desc
    history.create_time = account.create_time
    history.operate_time = accept_log.accept_time

    order_fee = 0
    product = db.query(models.SlcRadProduct).get(user.product_id)

    # 预付费包月
    if product.product_policy == PPMonth:
        order_fee = decimal.Decimal(product.fee_price) * decimal.Decimal(form.d.months)
        order_fee = int(order_fee.to_integral_value())
    # 买断包月,买断流量,买断时长
    elif product.product_policy in (BOMonth, BOTimes, BOFlows):
        order_fee = int(product.fee_price)

    order = models.SlcMemberOrder()
    order.order_id = utils.gen_order_id()
    order.member_id = user.member_id
    order.product_id = user.product_id
    order.account_number = form.d.account_number
    order.order_fee = order_fee
    order.actual_fee = utils.yuan2fen(form.d.fee_value)
    order.pay_status = 1
    order.accept_id = accept_log.id
    order.order_source = 'console'
    order.create_time = utils.get_currtime()


    account.status = 1
    account.expire_date = form.d.expire_date
    if product.product_policy == BOTimes:
        account.time_length += product.fee_times
    elif product.product_policy == BOFlows:
        account.flow_length += product.fee_flows

    history.new_expire_date = account.expire_date
    history.new_product_id = account.product_id
    db.add(history)

    order.order_desc = u"用户续费,续费前到期:%s,续费后到期:%s" % (history.expire_date, history.new_expire_date)
    db.add(order)

    db.commit()
    websock.update_cache("account", account_number=account_number)
    redirect(member_detail_url_formatter(account_number))
Beispiel #34
0
def account_charge(db, render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)
    user = query_account(db, account_number)
    form = account_forms.account_charge_form()
    if account.status != 1:
        return render("bus_account_form", user=user, form=form, msg=u"无效用户状态")

    if not form.validates(source=request.forms):
        return render("bus_account_form", user=user, form=form)

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'charge'
    accept_log.accept_source = 'console'
    accept_log.account_number = form.d.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    _new_fee = account.balance + utils.yuan2fen(form.d.fee_value)
    accept_log.accept_desc = u"用户充值:充值前%s元,充值后%s元;%s" % (
        utils.fen2yuan(account.balance),
        utils.fen2yuan(_new_fee),
        form.d.operate_desc
    )
    db.add(accept_log)
    db.flush()
    db.refresh(accept_log)

    history = models.SlcRadAccountHistory()
    history.accept_id = accept_log.id
    history.account_number = account.account_number
    history.member_id = account.member_id
    history.product_id = account.product_id
    history.group_id = account.group_id
    history.password = account.password
    history.install_address = account.install_address
    history.expire_date = account.expire_date
    history.user_concur_number = account.user_concur_number
    history.bind_mac = account.bind_mac
    history.bind_vlan = account.bind_vlan
    history.account_desc = account.account_desc
    history.create_time = account.create_time
    history.operate_time = accept_log.accept_time
    db.add(history)

    order = models.SlcMemberOrder()
    order.order_id = utils.gen_order_id()
    order.member_id = user.member_id
    order.product_id = user.product_id
    order.account_number = form.d.account_number
    order.order_fee = 0
    order.actual_fee = utils.yuan2fen(form.d.fee_value)
    order.pay_status = 1
    order.accept_id = accept_log.id
    order.order_source = 'console'
    order.create_time = utils.get_currtime()
    order.order_desc = accept_log.accept_desc
    db.add(order)

    account.balance += order.actual_fee

    db.commit()
    websock.update_cache("account", account_number=account_number)
    redirect(member_detail_url_formatter(account_number))
Beispiel #35
0
def account_next(db, render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)
    user = query_account(db, account_number)
    form = account_forms.account_next_form()
    form.product_id.set_value(user.product_id)
    if account.status not in (1, 4):
        return render("bus_account_next_form", user=user, form=form, msg=u"无效用户状态")
    if not form.validates(source=request.forms):
        return render("bus_account_next_form", user=user, form=form)

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'next'
    accept_log.accept_source = 'console'
    accept_log.accept_desc = u"用户续费:上网账号:%s,续费%s元;%s" % (account_number, form.d.fee_value,form.d.operate_desc)
    accept_log.account_number = form.d.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    db.add(accept_log)
    db.flush()
    db.refresh(accept_log)

    history = models.SlcRadAccountHistory()
    history.accept_id = accept_log.id
    history.account_number = account.account_number
    history.member_id = account.member_id
    history.product_id = account.product_id
    history.group_id = account.group_id
    history.password = account.password
    history.install_address = account.install_address
    history.expire_date = account.expire_date
    history.user_concur_number = account.user_concur_number
    history.bind_mac = account.bind_mac
    history.bind_vlan = account.bind_vlan
    history.account_desc = account.account_desc
    history.create_time = account.create_time
    history.operate_time = accept_log.accept_time

    order_fee = 0
    product = db.query(models.SlcRadProduct).get(user.product_id)

    # 预付费包月
    if product.product_policy == PPMonth:
        order_fee = decimal.Decimal(product.fee_price) * decimal.Decimal(form.d.months)
        order_fee = int(order_fee.to_integral_value())
    # 买断包月,买断流量,买断时长
    elif product.product_policy in (BOMonth, BOTimes, BOFlows):
        order_fee = int(product.fee_price)

    order = models.SlcMemberOrder()
    order.order_id = utils.gen_order_id()
    order.member_id = user.member_id
    order.product_id = user.product_id
    order.account_number = form.d.account_number
    order.order_fee = order_fee
    order.actual_fee = utils.yuan2fen(form.d.fee_value)
    order.pay_status = 1
    order.accept_id = accept_log.id
    order.order_source = 'console'
    order.create_time = utils.get_currtime()


    account.status = 1
    account.expire_date = form.d.expire_date
    if product.product_policy == BOTimes:
        account.time_length += product.fee_times
    elif product.product_policy == BOFlows:
        account.flow_length += product.fee_flows

    history.new_expire_date = account.expire_date
    history.new_product_id = account.product_id
    db.add(history)

    order.order_desc = u"用户续费,续费前到期:%s,续费后到期:%s" % (history.expire_date, history.new_expire_date)
    db.add(order)

    db.commit()
    websock.update_cache("account", account_number=account_number)
    redirect(member_detail_url_formatter(account_number))
Beispiel #36
0
def account_charge(db, render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)
    user = query_account(db, account_number)
    form = account_forms.account_charge_form()
    if account.status != 1:
        return render("bus_account_form", user=user, form=form, msg=u"无效用户状态")

    if not form.validates(source=request.forms):
        return render("bus_account_form", user=user, form=form)

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'charge'
    accept_log.accept_source = 'console'
    accept_log.account_number = form.d.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    _new_fee = account.balance + utils.yuan2fen(form.d.fee_value)
    accept_log.accept_desc = u"用户充值:充值前%s元,充值后%s元" % (
        utils.fen2yuan(account.balance),
        utils.fen2yuan(_new_fee)
    )
    db.add(accept_log)
    db.flush()
    db.refresh(accept_log)

    history = models.SlcRadAccountHistory()
    history.accept_id = accept_log.id
    history.account_number = account.account_number
    history.member_id = account.member_id
    history.product_id = account.product_id
    history.group_id = account.group_id
    history.password = account.password
    history.install_address = account.install_address
    history.expire_date = account.expire_date
    history.user_concur_number = account.user_concur_number
    history.bind_mac = account.bind_mac
    history.bind_vlan = account.bind_vlan
    history.account_desc = account.account_desc
    history.create_time = account.create_time
    history.operate_time = accept_log.accept_time
    db.add(history)

    order = models.SlcMemberOrder()
    order.order_id = utils.gen_order_id()
    order.member_id = user.member_id
    order.product_id = user.product_id
    order.account_number = form.d.account_number
    order.order_fee = 0
    order.actual_fee = utils.yuan2fen(form.d.fee_value)
    order.pay_status = 1
    order.accept_id = accept_log.id
    order.order_source = 'console'
    order.create_time = utils.get_currtime()
    order.order_desc = accept_log.accept_desc
    db.add(order)

    account.balance += order.actual_fee

    db.commit()
    websock.update_cache("account", account_number=account_number)
    redirect(member_detail_url_formatter(account_number))
Beispiel #37
0
def account_cancel(db, render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)
    user = query_account(db, account_number)
    form = account_forms.account_cancel_form()
    if account.status != 1:
        return render("bus_account_form", user=user, form=form, msg=u"无效用户状态")
    if not form.validates(source=request.forms):
        return render("bus_account_form", user=user, form=form)

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'cancel'
    accept_log.accept_source = 'console'
    accept_log.account_number = form.d.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    accept_log.accept_desc = u"用户销户退费%s(元)" % (form.d.fee_value)
    db.add(accept_log)
    db.flush()
    db.refresh(accept_log)

    history = models.SlcRadAccountHistory()
    history.accept_id = accept_log.id
    history.account_number = account.account_number
    history.member_id = account.member_id
    history.product_id = account.product_id
    history.group_id = account.group_id
    history.password = account.password
    history.install_address = account.install_address
    history.expire_date = account.expire_date
    history.user_concur_number = account.user_concur_number
    history.bind_mac = account.bind_mac
    history.bind_vlan = account.bind_vlan
    history.account_desc = account.account_desc
    history.create_time = account.create_time
    history.operate_time = accept_log.accept_time
    db.add(history)

    order = models.SlcMemberOrder()
    order.order_id = utils.gen_order_id()
    order.member_id = user.member_id
    order.product_id = user.product_id
    order.account_number = form.d.account_number
    order.order_fee = 0
    order.actual_fee = -utils.yuan2fen(form.d.fee_value)
    order.pay_status = 1
    order.order_source = 'console'
    order.accept_id = accept_log.id
    order.create_time = utils.get_currtime()
    order.order_desc = accept_log.accept_desc
    db.add(order)

    account.status = 3

    db.commit()

    websock.update_cache("account", account_number=account_number)
    onlines = db.query(models.SlcRadOnline).filter_by(account_number=account_number)
    for _online in onlines:
        websock.invoke_admin("coa_request",
                             nas_addr=_online.nas_addr,
                             acct_session_id=_online.acct_session_id,
                             message_type='disconnect')
    redirect(member_detail_url_formatter(account_number))
Beispiel #38
0
def account_cancel(db, render):
    account_number = request.params.get("account_number")
    account = db.query(models.SlcRadAccount).get(account_number)
    user = query_account(db, account_number)
    form = account_forms.account_cancel_form()
    if account.status != 1:
        return render("bus_account_form", user=user, form=form, msg=u"无效用户状态")
    if not form.validates(source=request.forms):
        return render("bus_account_form", user=user, form=form)

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'cancel'
    accept_log.accept_source = 'console'
    accept_log.account_number = form.d.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    accept_log.accept_desc = u"用户销户退费%s(元);%s" % (form.d.fee_value, form.d.operate_desc)
    db.add(accept_log)
    db.flush()
    db.refresh(accept_log)

    history = models.SlcRadAccountHistory()
    history.accept_id = accept_log.id
    history.account_number = account.account_number
    history.member_id = account.member_id
    history.product_id = account.product_id
    history.group_id = account.group_id
    history.password = account.password
    history.install_address = account.install_address
    history.expire_date = account.expire_date
    history.user_concur_number = account.user_concur_number
    history.bind_mac = account.bind_mac
    history.bind_vlan = account.bind_vlan
    history.account_desc = account.account_desc
    history.create_time = account.create_time
    history.operate_time = accept_log.accept_time
    db.add(history)

    order = models.SlcMemberOrder()
    order.order_id = utils.gen_order_id()
    order.member_id = user.member_id
    order.product_id = user.product_id
    order.account_number = form.d.account_number
    order.order_fee = 0
    order.actual_fee = -utils.yuan2fen(form.d.fee_value)
    order.pay_status = 1
    order.order_source = 'console'
    order.accept_id = accept_log.id
    order.create_time = utils.get_currtime()
    order.order_desc = accept_log.accept_desc
    db.add(order)

    account.status = 3

    db.commit()

    websock.update_cache("account", account_number=account_number)
    onlines = db.query(models.SlcRadOnline).filter_by(account_number=account_number)
    for _online in onlines:
        websock.invoke_admin("coa_request",
                             nas_addr=_online.nas_addr,
                             acct_session_id=_online.acct_session_id,
                             message_type='disconnect')
    redirect(member_detail_url_formatter(account_number))
Beispiel #39
0
def account_change(db, render):
    account_number = request.params.get("account_number")
    products = [(n.id, n.product_name) for n in get_opr_products(db)]
    form = account_forms.account_change_form(products=products)
    account = db.query(models.SlcRadAccount).get(account_number)
    user = query_account(db, account_number)
    if account.status not in (1, 4):
        return render("bus_account_change_form", user=user, form=form, msg=u"无效用户状态")
    if not form.validates(source=request.forms):
        return render("bus_account_change_form", user=user, form=form)

    product = db.query(models.SlcRadProduct).get(form.d.product_id)

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'change'
    accept_log.accept_source = 'console'
    accept_log.account_number = form.d.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    accept_log.accept_desc = u"用户资费变更为:%s" % (product.product_name)
    db.add(accept_log)
    db.flush()
    db.refresh(accept_log)

    history = models.SlcRadAccountHistory()
    history.accept_id = accept_log.id
    history.account_number = account.account_number
    history.member_id = account.member_id
    history.product_id = account.product_id
    history.group_id = account.group_id
    history.password = account.password
    history.install_address = account.install_address
    history.expire_date = account.expire_date
    history.user_concur_number = account.user_concur_number
    history.bind_mac = account.bind_mac
    history.bind_vlan = account.bind_vlan
    history.account_desc = account.account_desc
    history.create_time = account.create_time
    history.operate_time = accept_log.accept_time

    account.product_id = product.id
    # (PPMonth,PPTimes,BOMonth,BOTimes,PPFlow,BOFlows)
    if product.product_policy in (PPMonth, BOMonth):
        account.expire_date = form.d.expire_date
        account.balance = 0
        account.time_length = 0
        account.flow_length = 0
    elif product.product_policy in (PPTimes, PPFlow):
        account.expire_date = MAX_EXPIRE_DATE
        account.balance = utils.yuan2fen(form.d.balance)
        account.time_length = 0
        account.flow_length = 0
    elif product.product_policy == BOTimes:
        account.expire_date = MAX_EXPIRE_DATE
        account.balance = 0
        account.time_length = utils.hour2sec(form.d.time_length)
        account.flow_length = 0
    elif product.product_policy == BOFlows:
        account.expire_date = MAX_EXPIRE_DATE
        account.balance = 0
        account.time_length = 0
        account.flow_length = utils.mb2kb(form.d.flow_length)

    order = models.SlcMemberOrder()
    order.order_id = utils.gen_order_id()
    order.member_id = account.member_id
    order.product_id = account.product_id
    order.account_number = account.account_number
    order.order_fee = 0
    order.actual_fee = utils.yuan2fen(form.d.add_value) - utils.yuan2fen(form.d.back_value)
    order.pay_status = 1
    order.accept_id = accept_log.id
    order.order_source = 'console'
    order.create_time = utils.get_currtime()

    history.new_expire_date = account.expire_date
    history.new_product_id = account.product_id
    db.add(history)

    order.order_desc = u"用户变更资费,变更前到期:%s,变更后到期:%s" % (history.expire_date, history.new_expire_date)
    db.add(order)

    db.commit()
    websock.update_cache("account", account_number=account_number)
    redirect(member_detail_url_formatter(account_number))
Beispiel #40
0
def account_change(db, render):
    account_number = request.params.get("account_number")
    products = [(n.id, n.product_name) for n in get_opr_products(db)]
    form = account_forms.account_change_form(products=products)
    account = db.query(models.SlcRadAccount).get(account_number)
    user = query_account(db, account_number)
    if account.status not in (1, 4):
        return render("bus_account_change_form", user=user, form=form, msg=u"无效用户状态")
    if not form.validates(source=request.forms):
        return render("bus_account_change_form", user=user, form=form)

    product = db.query(models.SlcRadProduct).get(form.d.product_id)

    accept_log = models.SlcRadAcceptLog()
    accept_log.accept_type = 'change'
    accept_log.accept_source = 'console'
    accept_log.account_number = form.d.account_number
    accept_log.accept_time = utils.get_currtime()
    accept_log.operator_name = get_cookie("username")
    accept_log.accept_desc = u"用户资费变更为:%s;%s" % (product.product_name, form.d.operate_desc)
    db.add(accept_log)
    db.flush()
    db.refresh(accept_log)

    history = models.SlcRadAccountHistory()
    history.accept_id = accept_log.id
    history.account_number = account.account_number
    history.member_id = account.member_id
    history.product_id = account.product_id
    history.group_id = account.group_id
    history.password = account.password
    history.install_address = account.install_address
    history.expire_date = account.expire_date
    history.user_concur_number = account.user_concur_number
    history.bind_mac = account.bind_mac
    history.bind_vlan = account.bind_vlan
    history.account_desc = account.account_desc
    history.create_time = account.create_time
    history.operate_time = accept_log.accept_time

    account.product_id = product.id
    # (PPMonth,PPTimes,BOMonth,BOTimes,PPFlow,BOFlows)
    if product.product_policy in (PPMonth, BOMonth):
        account.expire_date = form.d.expire_date
        account.balance = 0
        account.time_length = 0
        account.flow_length = 0
    elif product.product_policy in (PPTimes, PPFlow):
        account.expire_date = MAX_EXPIRE_DATE
        account.balance = utils.yuan2fen(form.d.balance)
        account.time_length = 0
        account.flow_length = 0
    elif product.product_policy == BOTimes:
        account.expire_date = MAX_EXPIRE_DATE
        account.balance = 0
        account.time_length = utils.hour2sec(form.d.time_length)
        account.flow_length = 0
    elif product.product_policy == BOFlows:
        account.expire_date = MAX_EXPIRE_DATE
        account.balance = 0
        account.time_length = 0
        account.flow_length = utils.mb2kb(form.d.flow_length)

    order = models.SlcMemberOrder()
    order.order_id = utils.gen_order_id()
    order.member_id = account.member_id
    order.product_id = account.product_id
    order.account_number = account.account_number
    order.order_fee = 0
    order.actual_fee = utils.yuan2fen(form.d.add_value) - utils.yuan2fen(form.d.back_value)
    order.pay_status = 1
    order.accept_id = accept_log.id
    order.order_source = 'console'
    order.create_time = utils.get_currtime()

    history.new_expire_date = account.expire_date
    history.new_product_id = account.product_id
    db.add(history)

    order.order_desc = u"用户变更资费,变更前到期:%s,变更后到期:%s" % (history.expire_date, history.new_expire_date)
    db.add(order)

    db.commit()
    websock.update_cache("account", account_number=account_number)
    redirect(member_detail_url_formatter(account_number))