def online_stat_query(db): return render( "ops_online_stat", node_list=db.query(models.SlcNode), node_id=None, day_code=utils.get_currdate() )
def check_card(card): if not card: return dict(code=1, data=u"充值卡不存在") if card.card_status == 0: return dict(code=1, data=u"充值卡未激活") elif card.card_status == 2: return dict(code=1, data=u"充值卡已被使用") elif card.card_status == 3: return dict(code=1, data=u"充值卡已被回收") if card.expire_date < utils.get_currdate(): return dict(code=1, data=u"充值卡已过期") return dict(code=0)
def check_card(card): if not card: return dict(code=1,data=u"充值卡不存在") if card.card_status == 0: return dict(code=1,data=u"充值卡未激活") elif card.card_status == 2: return dict(code=1,data=u"充值卡已被使用") elif card.card_status == 3: return dict(code=1,data=u"充值卡已被回收") if card.expire_date < utils.get_currdate(): return dict(code=1,data=u"充值卡已过期") return dict(code=0)
def portal_auth(db): user = request.params.get("user") token = request.params.get("token") secret = get_param_value(db, "8_portal_secret") date = utils.get_currdate() _token = md5("%s%s%s" % (user, secret, date)).hexdigest() if _token == token: account = get_account_by_number(db, user) print account if not account: return render("error", msg=u"用户%s不存在!" % user) member = db.query(models.SlcMember).get(account.member_id) set_cookie('customer_id', member.member_id, path="/") set_cookie('customer', member.member_name, path="/") set_cookie('customer_login_time', utils.get_currtime(), path="/") set_cookie('customer_login_ip', request.remote_addr, path="/") redirect("/") else: return render("error", msg=u"无效的访问!")
def portal_auth(db): user = request.params.get("user") token = request.params.get("token") secret = get_param_value(db,"8_portal_secret") date = utils.get_currdate() _token = md5("%s%s%s"%(user,secret,date)).hexdigest() if _token == token: account = get_account_by_number(db,user) print account if not account: return render("error",msg=u"用户%s不存在!"%user) member = db.query(models.SlcMember).get(account.member_id) set_cookie('customer_id',member.member_id,path="/") set_cookie('customer',member.member_name,path="/") set_cookie('customer_login_time', utils.get_currtime(),path="/") set_cookie('customer_login_ip', request.remote_addr,path="/") redirect("/") else: return render("error",msg=u"无效的访问!")
def card_create(db): 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]) )] form = 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.time_length = 0 card_obj.flow_length = 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,forms.card_types[card_type]) db.add(ops_log) db.commit() path = "/card/list?card_type=%s&query_begin_time=%s"%(card_type,utils.get_currdate()) if form.d.product_id: path = "%s&product_id=%s"%(path,form.d.product_id) redirect(path)
def online_stat_query(db): return render("ops_online_stat", node_list=db.query(models.SlcNode), node_id=None, day_code=utils.get_currdate())