Esempio n. 1
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__)
Esempio n. 2
0
def product_add_post(db, render):
    form = product_forms.product_add_form()
    if not form.validates(source=request.forms):
        return render("sys_product_form", form=form)
    product = models.SlcRadProduct()
    product.product_name = form.d.product_name
    product.product_policy = form.d.product_policy
    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)
    _datetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    product.create_time = _datetime
    product.update_time = _datetime
    db.add(product)

    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()
    redirect(__prefix__)
Esempio n. 3
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__)
Esempio n. 4
0
def product_add_post(db, render):
    form = product_forms.product_add_form()
    if not form.validates(source=request.forms):
        return render("sys_product_form", form=form)
    product = models.SlcRadProduct()
    product.product_name = form.d.product_name
    product.product_policy = form.d.product_policy
    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)
    _datetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    product.create_time = _datetime
    product.update_time = _datetime
    db.add(product)

    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()
    redirect(__prefix__)
Esempio n. 5
0
def member_import_post(db, render):
    nodes = [(n.id, n.node_desc) for n in get_opr_nodes(db)]
    products = [(n.id, n.product_name) for n in get_opr_products(db)]
    iform = member_forms.user_import_form(nodes, products)
    node_id = request.params.get('node_id')
    product_id = request.params.get('product_id')
    upload = request.files.get('import_file')
    impctx = upload.file.read()
    lines = impctx.split("\n")
    _num = 0
    impusers = []
    for line in lines:
        _num += 1
        line = line.strip()
        if not line or "用户姓名" in line: continue
        attr_array = line.split(",")
        if len(attr_array) < 11:
            return render("bus_import_form", form=iform, msg=u"line %s error: length must 11 " % _num)

        vform = member_forms.user_import_vform()
        if not vform.validates(dict(
            realname=attr_array[0],
            idcard=attr_array[1],
            mobile=attr_array[2],
            address=attr_array[3],
            account_number=attr_array[4],
            password=attr_array[5],
            begin_date=attr_array[6],
            expire_date=attr_array[7],
            balance=attr_array[8],
            time_length=utils.hour2sec(attr_array[9]),
            flow_length=utils.mb2kb(attr_array[10]))):
            return render("bus_import_form", form=iform, msg=u"line %s error: %s" % (_num, vform.errors))

        impusers.append(vform)

    for form in impusers:
        try:
            member = models.SlcMember()
            member.node_id = node_id
            member.realname = form.d.realname
            member.idcard = form.d.idcard
            member.member_name = form.d.account_number
            member.password = md5(form.d.password.encode()).hexdigest()
            member.sex = '1'
            member.age = '0'
            member.email = ''
            member.mobile = form.d.mobile
            member.address = form.d.address
            member.create_time = form.d.begin_date + ' 00:00:00'
            member.update_time = utils.get_currtime()
            member.email_active = 0
            member.mobile_active = 0
            member.active_code = utils.get_uuid()
            db.add(member)
            db.flush()
            db.refresh(member)

            accept_log = models.SlcRadAcceptLog()
            accept_log.accept_type = 'open'
            accept_log.accept_source = 'console'
            _desc = u"用户导入账号:%s" % form.d.account_number
            accept_log.accept_desc = _desc
            accept_log.account_number = form.d.account_number
            accept_log.accept_time = member.update_time
            accept_log.operator_name = get_cookie("username")
            db.add(accept_log)
            db.flush()
            db.refresh(accept_log)

            order_fee = 0
            actual_fee = 0
            balance = 0
            time_length = 0
            flow_length = 0
            expire_date = form.d.expire_date
            product = db.query(models.SlcRadProduct).get(product_id)
            # 买断时长
            if product.product_policy == 3:
                time_length = int(form.d.time_length)
            # 买断流量
            elif product.product_policy == 5:
                flow_length = int(form.d.flow_length)
            # 预付费时长,预付费流量
            elif product.product_policy in (1, 4):
                balance = utils.yuan2fen(form.d.balance)
                expire_date = '3000-11-11'

            order = models.SlcMemberOrder()
            order.order_id = utils.gen_order_id()
            order.member_id = member.member_id
            order.product_id = product.id
            order.account_number = form.d.account_number
            order.order_fee = order_fee
            order.actual_fee = actual_fee
            order.pay_status = 1
            order.accept_id = accept_log.id
            order.order_source = 'console'
            order.create_time = member.update_time
            order.order_desc = u"用户导入开户"
            db.add(order)

            account = models.SlcRadAccount()
            account.account_number = form.d.account_number
            account.member_id = member.member_id
            account.product_id = order.product_id
            account.install_address = member.address
            account.ip_address = ''
            account.mac_addr = ''
            account.password = utils.encrypt(form.d.password)
            account.status = 1
            account.balance = balance
            account.time_length = time_length
            account.flow_length = flow_length
            account.expire_date = expire_date
            account.user_concur_number = product.concur_number
            account.bind_mac = product.bind_mac
            account.bind_vlan = product.bind_vlan
            account.vlan_id = 0
            account.vlan_id2 = 0
            account.create_time = member.create_time
            account.update_time = member.update_time
            db.add(account)

        except Exception as e:
            return render("bus_import_form", form=iform, msg=u"error : %s" % str(e))

    db.commit()
    redirect("/member")
Esempio n. 6
0
def card_create(db, render):
    def gencardpwd(clen=8):
        r = list('1234567890abcdefghijklmnopqrstuvwxyz')
        rg = utils.random_generator
        return utils.encrypt(''.join([rg.choice(r) for _ in range(clen)]))

    products = [(n.id, n.product_name)
                for n in db.query(models.SlcRadProduct).filter(
                    models.SlcRadProduct.product_status == 0,
                    models.SlcRadProduct.product_policy.in_([0, 2, 3, 5]))]
    form = card_forms.recharge_card_form(products)
    if not form.validates(source=request.forms):
        return render("card_form", form=form)
    card_type = int(form.d.card_type)
    batch_no = form.d.batch_no
    if len(batch_no) != 8:
        return render("card_form", form=form, msg=u"批次号必须是8位数字")

    pwd_len = int(form.d.pwd_len)
    if pwd_len > 16:
        pwd_len = 16

    start_card = int(form.d.start_no)
    stop_card = int(form.d.stop_no)
    if start_card > stop_card:
        return render("card_form", form=form, msg=u"开始卡号不能大于结束卡号")

    if form.d.expire_date < utils.get_currdate():
        return render("card_form", form=form, msg=u"过期时间不能小于今天")

    fee_value = utils.yuan2fen(form.d.fee_value)
    if fee_value == 0 and card_type == 1:
        return render("card_form", form=form, msg=u"不能发行余额为0的余额卡")

    for _card in range(start_card, stop_card + 1):
        card_number = "%s%s" % (batch_no, str(_card).zfill(5))
        card_obj = models.SlcRechargerCard()
        card_obj.batch_no = batch_no
        card_obj.card_number = card_number
        card_obj.card_passwd = gencardpwd(pwd_len)
        card_obj.card_type = card_type
        card_obj.card_status = 0
        card_obj.product_id = card_type == 0 and form.d.product_id or -1
        card_obj.fee_value = fee_value
        card_obj.months = card_type == 0 and int(form.d.months) or 0
        card_obj.times = card_type == 0 and utils.hour2sec(form.d.times) or 0
        card_obj.flows = card_type == 0 and utils.mb2kb(form.d.flows) or 0
        card_obj.expire_date = form.d.expire_date
        card_obj.create_time = utils.get_currtime()
        db.add(card_obj)

    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]的[%s]' % (
        get_cookie("username"), batch_no, card_forms.card_types[card_type])
    db.add(ops_log)
    db.commit()
    path = "%s/list?card_type=%s&query_begin_time=%s" % (__prefix__, card_type,
                                                         utils.get_currdate())
    if form.d.product_id:
        path = "%s&product_id=%s" % (path, form.d.product_id)
    redirect(path)
Esempio n. 7
0
def card_create(db, render):
    def gencardpwd(clen=8):
        r = list('1234567890abcdefghijklmnopqrstuvwxyz')
        rg = utils.random_generator
        return utils.encrypt(''.join([rg.choice(r) for _ in range(clen)]))
        
    products = [ (n.id,n.product_name) for n in db.query(models.SlcRadProduct).filter(
        models.SlcRadProduct.product_status == 0,
        models.SlcRadProduct.product_policy.in_([0,2,3,5])
    )]
    form = card_forms.recharge_card_form(products)
    if not form.validates(source=request.forms):
        return render("card_form",form=form)
    card_type = int(form.d.card_type)
    batch_no = form.d.batch_no
    if len(batch_no) != 8:
        return render("card_form",form=form,msg=u"批次号必须是8位数字")
    
    pwd_len = int(form.d.pwd_len)
    if pwd_len > 16:
        pwd_len = 16

    start_card = int(form.d.start_no)
    stop_card = int(form.d.stop_no)
    if start_card > stop_card:
        return render("card_form",form=form,msg=u"开始卡号不能大于结束卡号")
    
    if form.d.expire_date < utils.get_currdate():
        return render("card_form",form=form,msg=u"过期时间不能小于今天")
    
    fee_value = utils.yuan2fen(form.d.fee_value)
    if fee_value == 0 and card_type == 1:
        return render("card_form",form=form,msg=u"不能发行余额为0的余额卡")
    
    for _card in range(start_card,stop_card+1):
        card_number = "%s%s"%(batch_no,str(_card).zfill(5))
        card_obj = models.SlcRechargerCard()
        card_obj.batch_no = batch_no
        card_obj.card_number = card_number
        card_obj.card_passwd = gencardpwd(pwd_len)
        card_obj.card_type = card_type
        card_obj.card_status = 0
        card_obj.product_id = card_type==0 and form.d.product_id or -1
        card_obj.fee_value = fee_value
        card_obj.months = card_type==0 and int(form.d.months) or 0
        card_obj.times = card_type==0 and utils.hour2sec(form.d.times) or 0
        card_obj.flows = card_type==0 and utils.mb2kb(form.d.flows) or 0
        card_obj.expire_date = form.d.expire_date
        card_obj.create_time = utils.get_currtime()
        db.add(card_obj)
    
    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]的[%s]'%(get_cookie("username"),batch_no,card_forms.card_types[card_type])
    db.add(ops_log)
    db.commit()
    path = "%s/list?card_type=%s&query_begin_time=%s"%(__prefix__,card_type,utils.get_currdate())
    if form.d.product_id:
        path = "%s&product_id=%s"%(path,form.d.product_id)
    redirect(path)
Esempio n. 8
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))
Esempio n. 9
0
def member_import_post(db, render):
    nodes = [(n.id, n.node_desc) for n in get_opr_nodes(db)]
    products = [(n.id, n.product_name) for n in get_opr_products(db)]
    iform = member_forms.user_import_form(nodes, products)
    node_id = request.params.get('node_id')
    product_id = request.params.get('product_id')
    upload = request.files.get('import_file')
    impctx = upload.file.read()
    lines = impctx.split("\n")
    _num = 0
    impusers = []
    for line in lines:
        _num += 1
        line = line.strip()
        if not line or "用户姓名" in line: continue
        attr_array = line.split(",")
        if len(attr_array) < 11:
            return render("bus_import_form",
                          form=iform,
                          msg=u"line %s error: length must 11 " % _num)

        vform = member_forms.user_import_vform()
        if not vform.validates(
                dict(realname=attr_array[0],
                     idcard=attr_array[1],
                     mobile=attr_array[2],
                     address=attr_array[3],
                     account_number=attr_array[4],
                     password=attr_array[5],
                     begin_date=attr_array[6],
                     expire_date=attr_array[7],
                     balance=attr_array[8],
                     time_length=utils.hour2sec(attr_array[9]),
                     flow_length=utils.mb2kb(attr_array[10]))):
            return render("bus_import_form",
                          form=iform,
                          msg=u"line %s error: %s" % (_num, vform.errors))

        impusers.append(vform)

    for form in impusers:
        try:
            member = models.SlcMember()
            member.node_id = node_id
            member.realname = form.d.realname
            member.idcard = form.d.idcard
            member.member_name = form.d.account_number
            member.password = md5(form.d.password.encode()).hexdigest()
            member.sex = '1'
            member.age = '0'
            member.email = ''
            member.mobile = form.d.mobile
            member.address = form.d.address
            member.create_time = form.d.begin_date + ' 00:00:00'
            member.update_time = utils.get_currtime()
            member.email_active = 0
            member.mobile_active = 0
            member.active_code = utils.get_uuid()
            db.add(member)
            db.flush()
            db.refresh(member)

            accept_log = models.SlcRadAcceptLog()
            accept_log.accept_type = 'open'
            accept_log.accept_source = 'console'
            _desc = u"用户导入账号:%s" % form.d.account_number
            accept_log.accept_desc = _desc
            accept_log.account_number = form.d.account_number
            accept_log.accept_time = member.update_time
            accept_log.operator_name = get_cookie("username")
            db.add(accept_log)
            db.flush()
            db.refresh(accept_log)

            order_fee = 0
            actual_fee = 0
            balance = 0
            time_length = 0
            flow_length = 0
            expire_date = form.d.expire_date
            product = db.query(models.SlcRadProduct).get(product_id)
            # 买断时长
            if product.product_policy == 3:
                time_length = int(form.d.time_length)
            # 买断流量
            elif product.product_policy == 5:
                flow_length = int(form.d.flow_length)
            # 预付费时长,预付费流量
            elif product.product_policy in (1, 4):
                balance = utils.yuan2fen(form.d.balance)
                expire_date = '3000-11-11'

            order = models.SlcMemberOrder()
            order.order_id = utils.gen_order_id()
            order.member_id = member.member_id
            order.product_id = product.id
            order.account_number = form.d.account_number
            order.order_fee = order_fee
            order.actual_fee = actual_fee
            order.pay_status = 1
            order.accept_id = accept_log.id
            order.order_source = 'console'
            order.create_time = member.update_time
            order.order_desc = u"用户导入开户"
            db.add(order)

            account = models.SlcRadAccount()
            account.account_number = form.d.account_number
            account.member_id = member.member_id
            account.product_id = order.product_id
            account.install_address = member.address
            account.ip_address = ''
            account.mac_addr = ''
            account.password = utils.encrypt(form.d.password)
            account.status = 1
            account.balance = balance
            account.time_length = time_length
            account.flow_length = flow_length
            account.expire_date = expire_date
            account.user_concur_number = product.concur_number
            account.bind_mac = product.bind_mac
            account.bind_vlan = product.bind_vlan
            account.vlan_id = 0
            account.vlan_id2 = 0
            account.create_time = member.create_time
            account.update_time = member.update_time
            db.add(account)

        except Exception as e:
            return render("bus_import_form",
                          form=iform,
                          msg=u"error : %s" % str(e))

    db.commit()
    redirect("/member")
Esempio n. 10
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))