Esempio n. 1
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)]
    user = query_account(db, account_number)
    form = account_forms.account_change_form(products=products)
    form.expire_date.set_value(user.expire_date)
    form.account_number.set_value(account_number)
    return render("bus_account_change_form", user=user, form=form)
Esempio n. 2
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)]
    user = query_account(db, account_number)
    form = account_forms.account_change_form(products=products)
    form.expire_date.set_value(user.expire_date)
    form.account_number.set_value(account_number)
    return render("bus_account_change_form", user=user, form=form)
Esempio n. 3
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. 4
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))