Ejemplo n.º 1
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))
Ejemplo n.º 2
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))
Ejemplo n.º 3
0
def account_charge(db, render):
    account_number = request.params.get("account_number")
    user = query_account(db, account_number)
    form = account_forms.account_charge_form()
    form.account_number.set_value(account_number)
    return render("bus_account_form", user=user, form=form)
Ejemplo n.º 4
0
def account_charge(db, render):
    account_number = request.params.get("account_number")
    user = query_account(db, account_number)
    form = account_forms.account_charge_form()
    form.account_number.set_value(account_number)
    return render("bus_account_form", user=user, form=form)