Exemple #1
0
def product_update(db, render):
    product_id = request.params.get("product_id")
    form = product_forms.product_update_form()
    product = db.query(models.SlcRadProduct).get(product_id)
    form.fill(product)
    form.product_policy_name.set_value(
        product_forms.product_policy[product.product_policy])
    form.fee_times.set_value(utils.sec2hour(product.fee_times))
    form.fee_flows.set_value(utils.kb2mb(product.fee_flows))
    form.input_max_limit.set_value(utils.bps2mbps(product.input_max_limit))
    form.output_max_limit.set_value(utils.bps2mbps(product.output_max_limit))
    form.fee_price.set_value(utils.fen2yuan(product.fee_price))
    return render("sys_product_form", form=form)
Exemple #2
0
def product_update(db, render):
    product_id = request.params.get("product_id")
    form = product_forms.product_update_form()
    product = db.query(models.SlcRadProduct).get(product_id)
    form.fill(product)
    form.product_policy_name.set_value(
        product_forms.product_policy[product.product_policy])
    form.fee_times.set_value(utils.sec2hour(product.fee_times))
    form.fee_flows.set_value(utils.kb2mb(product.fee_flows))
    form.input_max_limit.set_value(utils.bps2mbps(product.input_max_limit))
    form.output_max_limit.set_value(utils.bps2mbps(product.output_max_limit))
    form.fee_price.set_value(utils.fen2yuan(product.fee_price))
    return render("sys_product_form", form=form)
Exemple #3
0
def card_list(db, render):
    product_id = request.params.get('product_id')
    card_type = request.params.get('card_type') 
    card_status = request.params.get('card_status')
    batch_no = request.params.get('batch_no')
    query_begin_time = request.params.get('query_begin_time')
    query_end_time = request.params.get('query_end_time')
    
    _query = db.query(models.SlcRechargerCard)
    if product_id and card_type == '0':
        _query = _query.filter(models.SlcRechargerCard.product_id==product_id)
    if card_type:
        _query = _query.filter(models.SlcRechargerCard.card_type==card_type)
    if batch_no:
        _query = _query.filter(models.SlcRechargerCard.batch_no==batch_no)
    if card_status:
        _query = _query.filter(models.SlcRechargerCard.card_status==card_status)
    if query_begin_time:
        _query = _query.filter(models.SlcRechargerCard.create_time >= query_begin_time+' 00:00:00')
    if query_end_time:
        _query = _query.filter(models.SlcRechargerCard.create_time <= query_end_time+' 23:59:59')
    
    products = db.query(models.SlcRadProduct).filter(
        models.SlcRadProduct.product_status == 0,
        models.SlcRadProduct.product_policy.in_([0,2,3,5])
    )
    if request.path == '/list':
        print "total:",_query.count()
        return render("card_list", 
            page_data = get_page_data(_query),
            card_types = card_forms.card_types,
            card_states = card_forms.card_states,
            products = products,
            colors = {0:'',1:'class="success"',2:'class="warning"',3:'class="danger"'},
            **request.params
        )
    elif request.path == '/export':
        data = Dataset()
        data.append((
            u'批次号',u'充值卡号',u'充值卡密码',u'充值卡类型',u'状态',
            u'资费id', u'面值/售价',u"授权月数",u"授权时长(小时)",u"授权流量(MB)",u"过期时间",u'创建时间'
         ))
        print "total:",_query.count()
        for i in _query:
            data.append((
                i.batch_no, i.card_number, utils.decrypt(i.card_passwd),card_forms.card_types[i.card_type],
                card_forms.card_states[i.card_status],get_product_name(db,i.product_id),utils.fen2yuan(i.fee_value),
                i.months,utils.sec2hour(i.times),utils.kb2mb(i.flows),i.expire_date,i.create_time
            ))
        name = u"RADIUS-CARD-" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") + ".xls"
        return export_file(name,data)
Exemple #4
0
def card_calc(db, render):
    product_id = request.params.get('product_id')
    product = db.query(models.SlcRadProduct).get(product_id)
    #预付费包月
    if product and product.product_policy == 0:
        return dict(code=0,data={
            'fee_value' : utils.fen2yuan(product.fee_price),
            'months' : 1
        })
    # 买断包月 买断时长 买断流量
    elif product and product.product_policy in (2,3,5):
        return dict(code=0,data={
            'fee_value' : utils.fen2yuan(product.fee_price),
            'months' : product.fee_months,
            'times' : utils.sec2hour(product.fee_times),
            'flows' : utils.kb2mb(product.fee_flows)
        })
    else:
        return dict(code=1,data=u"不支持的资费")
Exemple #5
0
def card_calc(db, render):
    product_id = request.params.get('product_id')
    product = db.query(models.SlcRadProduct).get(product_id)
    #预付费包月
    if product and product.product_policy == 0:
        return dict(code=0,
                    data={
                        'fee_value': utils.fen2yuan(product.fee_price),
                        'months': 1
                    })
    # 买断包月 买断时长 买断流量
    elif product and product.product_policy in (2, 3, 5):
        return dict(code=0,
                    data={
                        'fee_value': utils.fen2yuan(product.fee_price),
                        'months': product.fee_months,
                        'times': utils.sec2hour(product.fee_times),
                        'flows': utils.kb2mb(product.fee_flows)
                    })
    else:
        return dict(code=1, data=u"不支持的资费")
Exemple #6
0
def member_query(db, render):
    node_id = request.params.get('node_id')
    realname = request.params.get('realname')
    idcard = request.params.get('idcard')
    mobile = request.params.get('mobile')
    user_name = request.params.get('user_name')
    status = request.params.get('status')
    product_id = request.params.get('product_id')
    address = request.params.get('address')
    expire_days = request.params.get('expire_days')
    opr_nodes = get_opr_nodes(db)
    _query = db.query(
        models.SlcMember,
        models.SlcRadAccount,
        models.SlcRadProduct.product_name,
        models.SlcNode.node_desc
    ).filter(
        models.SlcRadProduct.id == models.SlcRadAccount.product_id,
        models.SlcMember.member_id == models.SlcRadAccount.member_id,
        models.SlcNode.id == models.SlcMember.node_id
    )

    _now = datetime.datetime.now()

    if idcard:
        _query = _query.filter(models.SlcMember.idcard == idcard)
    if mobile:
        _query = _query.filter(models.SlcMember.mobile == mobile)
    if node_id:
        _query = _query.filter(models.SlcMember.node_id == node_id)
    else:
        _query = _query.filter(models.SlcMember.node_id.in_([i.id for i in opr_nodes]))
    if realname:
        _query = _query.filter(models.SlcMember.realname.like('%' + realname + '%'))
    if user_name:
        _query = _query.filter(models.SlcRadAccount.account_number.like('%' + user_name + '%'))

    #用户状态判断
    if status:
        if status == '4':
            _query = _query.filter(models.SlcRadAccount.expire_date <= _now.strftime("%Y-%m-%d"))
        elif status == '1':
            _query = _query.filter(
                models.SlcRadAccount.status == status,
                models.SlcRadAccount.expire_date >= _now.strftime("%Y-%m-%d")
            )
        else:
            _query = _query.filter(models.SlcRadAccount.status == status)

    if product_id:
        _query = _query.filter(models.SlcRadAccount.product_id == product_id)
    if address:
        _query = _query.filter(models.SlcMember.address.like('%' + address + '%'))
    if expire_days:
        _days = int(expire_days)
        td = datetime.timedelta(days=_days)
        edate = (_now + td).strftime("%Y-%m-%d")
        _query = _query.filter(models.SlcRadAccount.expire_date <= edate)
        _query = _query.filter(models.SlcRadAccount.expire_date >= _now.strftime("%Y-%m-%d"))

    if request.path == '/':
        return render("bus_member_list",
                      page_data=get_page_data(_query),
                      node_list=opr_nodes,
                      products=db.query(models.SlcRadProduct),
                      **request.params)
    elif request.path == "/export":
        data = Dataset()
        data.append((
            u'区域', u'姓名', u'证件号', u'邮箱', u'联系电话', u'地址',
            u'用户账号', u'密码', u'资费', u'过期时间', u'余额(元)',
            u'时长(小时)', u'流量(MB)', u'并发数', u'ip地址', u'状态', u'创建时间'
        ))
        for i, j, _product_name, _node_desc in _query:
            data.append((
                _node_desc, i.realname, i.idcard, i.email, i.mobile, i.address,
                j.account_number, utils.decrypt(j.password), _product_name,
                j.expire_date, utils.fen2yuan(j.balance),
                utils.sec2hour(j.time_length), utils.kb2mb(j.flow_length), j.user_concur_number, j.ip_address,
                forms.user_state[j.status], j.create_time
            ))
        name = u"RADIUS-USER-" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") + ".xls"
        return export_file(name, data)
Exemple #7
0
def card_list(db, render):
    product_id = request.params.get('product_id')
    card_type = request.params.get('card_type')
    card_status = request.params.get('card_status')
    batch_no = request.params.get('batch_no')
    query_begin_time = request.params.get('query_begin_time')
    query_end_time = request.params.get('query_end_time')

    _query = db.query(models.SlcRechargerCard)
    if product_id and card_type == '0':
        _query = _query.filter(
            models.SlcRechargerCard.product_id == product_id)
    if card_type:
        _query = _query.filter(models.SlcRechargerCard.card_type == card_type)
    if batch_no:
        _query = _query.filter(models.SlcRechargerCard.batch_no == batch_no)
    if card_status:
        _query = _query.filter(
            models.SlcRechargerCard.card_status == card_status)
    if query_begin_time:
        _query = _query.filter(
            models.SlcRechargerCard.create_time >= query_begin_time +
            ' 00:00:00')
    if query_end_time:
        _query = _query.filter(
            models.SlcRechargerCard.create_time <= query_end_time +
            ' 23:59:59')

    products = db.query(models.SlcRadProduct).filter(
        models.SlcRadProduct.product_status == 0,
        models.SlcRadProduct.product_policy.in_([0, 2, 3, 5]))
    if request.path == '/list':
        print "total:", _query.count()
        return render("card_list",
                      page_data=get_page_data(_query),
                      card_types=card_forms.card_types,
                      card_states=card_forms.card_states,
                      products=products,
                      colors={
                          0: '',
                          1: 'class="success"',
                          2: 'class="warning"',
                          3: 'class="danger"'
                      },
                      **request.params)
    elif request.path == '/export':
        data = Dataset()
        data.append(
            (u'批次号', u'充值卡号', u'充值卡密码', u'充值卡类型', u'状态', u'资费id', u'面值/售价',
             u"授权月数", u"授权时长(小时)", u"授权流量(MB)", u"过期时间", u'创建时间'))
        print "total:", _query.count()
        for i in _query:
            data.append(
                (i.batch_no, i.card_number, utils.decrypt(i.card_passwd),
                 card_forms.card_types[i.card_type],
                 card_forms.card_states[i.card_status],
                 get_product_name(db, i.product_id), utils.fen2yuan(
                     i.fee_value), i.months, utils.sec2hour(i.times),
                 utils.kb2mb(i.flows), i.expire_date, i.create_time))
        name = u"RADIUS-CARD-" + datetime.datetime.now().strftime(
            "%Y%m%d-%H%M%S") + ".xls"
        return export_file(name, data)
Exemple #8
0
def member_query(db, render):
    node_id = request.params.get('node_id')
    realname = request.params.get('realname')
    idcard = request.params.get('idcard')
    mobile = request.params.get('mobile')
    user_name = request.params.get('user_name')
    status = request.params.get('status')
    product_id = request.params.get('product_id')
    address = request.params.get('address')
    expire_days = request.params.get('expire_days')
    opr_nodes = get_opr_nodes(db)
    _query = db.query(
        models.SlcMember, models.SlcRadAccount,
        models.SlcRadProduct.product_name, models.SlcNode.node_desc).filter(
            models.SlcRadProduct.id == models.SlcRadAccount.product_id,
            models.SlcMember.member_id == models.SlcRadAccount.member_id,
            models.SlcNode.id == models.SlcMember.node_id)

    _now = datetime.datetime.now()

    if idcard:
        _query = _query.filter(models.SlcMember.idcard == idcard)
    if mobile:
        _query = _query.filter(models.SlcMember.mobile == mobile)
    if node_id:
        _query = _query.filter(models.SlcMember.node_id == node_id)
    else:
        _query = _query.filter(
            models.SlcMember.node_id.in_([i.id for i in opr_nodes]))
    if realname:
        _query = _query.filter(
            models.SlcMember.realname.like('%' + realname + '%'))
    if user_name:
        _query = _query.filter(
            models.SlcRadAccount.account_number.like('%' + user_name + '%'))

    #用户状态判断
    if status:
        if status == '4':
            _query = _query.filter(
                models.SlcRadAccount.expire_date <= _now.strftime("%Y-%m-%d"))
        elif status == '1':
            _query = _query.filter(
                models.SlcRadAccount.status == status,
                models.SlcRadAccount.expire_date >= _now.strftime("%Y-%m-%d"))
        else:
            _query = _query.filter(models.SlcRadAccount.status == status)

    if product_id:
        _query = _query.filter(models.SlcRadAccount.product_id == product_id)
    if address:
        _query = _query.filter(
            models.SlcMember.address.like('%' + address + '%'))
    if expire_days:
        _days = int(expire_days)
        td = datetime.timedelta(days=_days)
        edate = (_now + td).strftime("%Y-%m-%d")
        _query = _query.filter(models.SlcRadAccount.expire_date <= edate)
        _query = _query.filter(
            models.SlcRadAccount.expire_date >= _now.strftime("%Y-%m-%d"))

    if request.path == '/':
        return render("bus_member_list",
                      page_data=get_page_data(_query),
                      node_list=opr_nodes,
                      products=db.query(models.SlcRadProduct),
                      **request.params)
    elif request.path == "/export":
        data = Dataset()
        data.append((u'区域', u'姓名', u'证件号', u'邮箱', u'联系电话', u'地址', u'用户账号',
                     u'密码', u'资费', u'过期时间', u'余额(元)', u'时长(小时)', u'流量(MB)',
                     u'并发数', u'ip地址', u'状态', u'创建时间'))
        for i, j, _product_name, _node_desc in _query:
            data.append(
                (_node_desc, i.realname, i.idcard, i.email,
                 i.mobile, i.address, j.account_number,
                 utils.decrypt(j.password), _product_name, j.expire_date,
                 utils.fen2yuan(j.balance), utils.sec2hour(j.time_length),
                 utils.kb2mb(j.flow_length), j.user_concur_number,
                 j.ip_address, member_forms.user_state[j.status],
                 j.create_time))
        name = u"RADIUS-USER-" + datetime.datetime.now().strftime(
            "%Y%m%d-%H%M%S") + ".xls"
        return export_file(name, data)