def account_next(db, render): account_number = request.params.get("account_number") user = query_account(db, account_number) form = account_forms.account_next_form() form.account_number.set_value(account_number) form.old_expire.set_value(user.expire_date) form.product_id.set_value(user.product_id) return render("bus_account_next_form", user=user, form=form)
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))
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))