Esempio n. 1
0
def recharge_card_list(page=1, page_size=20):
    """充值卡列表"""
    g.page_type = 'search'
    g.title = u'充值卡列表'
    g.add_new = True
    g.button_name = u'新增充值卡'
    param_dict = get_params({'rc_id': int, 'amount': str, 'gift': str})

    query_dict = {
        'rc_id': param_dict['rc_id'],
        'amount': param_dict['amount'],
        'gift': param_dict['gift']
    }

    q = RechargeCard.query
    q = easy_query_filter(RechargeCard, q, query_dict)
    recharge_card_count = get_count(q)
    recharge_card_list  = q.order_by(RechargeCard.rc_id.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()

    pagination = Pagination(None, page, page_size, recharge_card_count, None)

    res = make_response(
        render_template('sys/recharge_card_list.html.j2', **locals()))
    res.set_cookie('goback_url', request.url)
    return res
Esempio n. 2
0
def column_save():
    """保存商品栏目"""

    param_dict  = get_params({'gc_id':int,'column_name':str,'column_img':None,'status':int,'sort_order':int, 'brief':str})
    required_param_list = ['column_name','status']
    form = request.form
    for param in required_param_list:
        val = request.form.get(param, '')
        val = val.strip()
        if not val:
            errmsg[param] = u'必填项'
            g.errmsg = errmsg
            log_debug('errmsg:%s'%g.errmsg)
            return render_template('goods/column_detail.html.j2', f=form,**locals())

    # 检查 - 封面原图是否合法
    column_img = param_dict['column_img']
    if column_img:
        oss = AliyunOSS('goods', current_app.config['SAVE_TARGET_PATH'])
        try:
            oss.save(column_img)
            column_img = oss.put_to_oss()
        except UploadNotAllowed, e:
            errmsg['column_img'] = u'图片只允许是图片文件'
        except Exception, e:
            errmsg['column_img'] = u'图片上传失败'
Esempio n. 3
0
def lottery_temp_detail(page=1, page_size=20):
    """一元云购活动模板详情"""
    g.page_type = ''
    g.title = u'一元云购活动模板详情'

    lt_id = toint(request.args.get('lt_id', '0'))

    lottery_temp_info = LotteryTemplate.query.filter(
        LotteryTemplate.lt_id == lt_id).first()
    goods_list = Goods.query.filter(Goods.kind == 2).\
                    filter(Goods.is_sale == 1).all()

    if lottery_temp_info is None:
        return u'一元云购活动模板不存在'

    param_dict = get_params({
        'lottery_id': int,
        'section_number': int,
        'query_goods_id': int,
        'lottery_name': str,
        'lottery_status': int,
        'begin_add_time': str,
        'end_add_time': str
    })

    query_dict = {
        'lottery_id': param_dict['lottery_id'],
        'section_number': param_dict['section_number'],
        'goods_id': param_dict['query_goods_id'],
        'lottery_name': param_dict['lottery_name'],
        'lottery_status': param_dict['lottery_status'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
    }

    q = db.session.query(Lottery.lottery_id, Lottery.section_number, Goods.goods_name, Lottery.goods_id, Lottery.lottery_name, Lottery.lottery_img, Lottery.lottery_price, Lottery.lottery_status, Lottery.schedule, Lottery.announced_time, Lottery.add_time).\
        filter(Lottery.goods_id == Goods.goods_id).\
        filter(Goods.kind == 2).\
        filter(Lottery.lt_id == lt_id)

    q = easy_query_filter(Lottery, q, query_dict)

    # 商品列表
    goods_query_list = [{'name': u'请选择……', 'value': '-1'}]
    goods_query_list_temp = db.session.query(Goods.goods_name, Goods.goods_id).\
                                group_by(Goods.goods_id).all()

    for goods in goods_query_list_temp:
        gs = {'name': goods.goods_name, 'value': goods.goods_id}
        goods_query_list.append(gs)

    lottery_count = get_count(q)
    lottery_list  = q.order_by(Lottery.lottery_id.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()
    pagination = Pagination(None, page, page_size, lottery_count, None)

    return render_template('lottery/add_template.html.j2',
                           f=lottery_temp_info,
                           **locals())
Esempio n. 4
0
def ordinary_list(page=1, page_size=20):
    """普通订单列表"""
    g.title = u'普通订单列表'
    g.page_type = 'search'

    param_dict = get_params({
        'order_id': int,
        'order_status': int,
        'pay_status': int,
        'order_amount': int,
        'begin_paid_time': str,
        'end_paid_time': str,
        'shipping_sn': str,
        'shipping_status': int,
        'deliver_status': int,
        'is_comment': int,
        'begin_add_time': str,
        'end_add_time': str
    })

    query_dict = {
        'order_id': param_dict['order_id'],
        'pay_status': param_dict['pay_status'],
        'order_status': param_dict['order_status'],
        'order_amount': param_dict['order_amount'],
        'shipping_sn': param_dict['shipping_sn'],
        'shipping_status': param_dict['shipping_status'],
        'deliver_status': param_dict['deliver_status'],
        'is_comment': param_dict['is_comment'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
        'begin_paid_time': param_dict['begin_paid_time'],
        'end_paid_time': param_dict['end_paid_time']
    }

    q = db.session.query(Order.order_id, Order.uid, Order.order_status, Order.order_desc, Order.order_amount, Order.shipping_sn, Order.shipping_status, Order.deliver_status, Order.is_comment, Order.add_time, Order.paid_time, Order.pay_status).\
        filter(Order.uid == User.uid).\
        filter(Order.order_type == 1)

    q = easy_query_filter(Order, q, query_dict)

    order_count = get_count(q)
    order_list = q.order_by(Order.add_time.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()

    (USERNAME, MOBILE, NICKNAME, AVATAR, REALNAME, GENDER) = get_user_data()
    pagination = Pagination(None, page, page_size, order_count, None)

    res = make_response(
        render_template('order/ordinary_list.html.j2',
                        f={
                            'lt_id': '',
                            'lottery_id': ''
                        },
                        **locals()))
    res.set_cookie('goback_url', request.url)
    return res
Esempio n. 5
0
def index(page=1, page_size=20):
    """一元云购活动列表"""
    g.page_type = 'search'
    g.title = u'一元云购活动列表'

    param_dict = get_params({
        'lottery_id': int,
        'section_number': int,
        'goods_id': int,
        'lottery_name': str,
        'lottery_status': int,
        'begin_add_time': str,
        'end_add_time': str
    })

    query_dict = {
        'lottery_id': param_dict['lottery_id'],
        'section_number': param_dict['section_number'],
        'goods_id': param_dict['goods_id'],
        'lottery_name': param_dict['lottery_name'],
        'lottery_status': param_dict['lottery_status'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
    }

    q = db.session.query(Lottery.lottery_id, Lottery.section_number, Goods.goods_name, Lottery.goods_id, Lottery.lottery_name, Lottery.lottery_img, Lottery.lottery_price, Lottery.lottery_status, Lottery.schedule, Lottery.announced_time, Lottery.add_time).\
        filter(Lottery.goods_id == Goods.goods_id).\
        filter(Goods.kind == 2)

    q = easy_query_filter(Lottery, q, query_dict)

    lottery_count = get_count(q)
    lottery_list  = q.order_by(Lottery.lottery_id.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()

    # 商品列表
    goods_id_list = [l.goods_id for l in lottery_list]
    goods_list = [{'name': u'请选择……', 'value': '-1'}]
    goods_list_temp = db.session.query(Goods.goods_name, Goods.goods_id).\
                                filter(Goods.goods_id.in_(goods_id_list)).\
                                group_by(Goods.goods_id).all()

    for goods in goods_list_temp:
        if goods.goods_name:
            gs = {'name': goods.goods_name, 'value': goods.goods_id}
            goods_list.append(gs)

    pagination = Pagination(None, page, page_size, lottery_count, None)

    res = make_response(render_template('lottery/index.html.j2', **locals()))
    res.set_cookie('goback_url', request.url)
    return res
Esempio n. 6
0
def order_tran_list(page=1, page_size=20):
    """订单交易列表"""
    g.title = u'订单交易列表'
    g.page_type = 'search'

    param_dict = get_params({
        'tran_id': int,
        'pay_status': int,
        'begin_paid_time': str,
        'end_paid_time': str,
        'begin_add_time': str,
        'end_add_time': str,
        'order_id': int
    })

    query_dict = {
        'tran_id': param_dict['tran_id'],
        'pay_status': param_dict['pay_status'],
        'begin_paid_time': param_dict['begin_paid_time'],
        'end_paid_time': param_dict['end_paid_time'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
    }

    q = OrderTran.query
    q = easy_query_filter(OrderTran, q, query_dict)

    order_id = param_dict['order_id']
    if order_id > 0:
        q = q.filter(
            or_(OrderTran.order_id_list.like(u'%' + '%d,' % order_id + u'%'),
                OrderTran.order_id_list.like(u'%' + ',%d,' % order_id + u'%'),
                OrderTran.order_id_list.like(u'%' + ',%d' % order_id + u'%'),
                OrderTran.order_id_list.like(u'%' + '%d' % order_id + u'%')))

    tran_count = get_count(q)
    order_tran_list = q.order_by(OrderTran.add_time.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()

    for tran in order_tran_list:
        uid = tran.uid
        user_info = User.query.get(uid)
        tran.nickname = user_info.nickname if user_info else ''

    pagination = Pagination(None, page, page_size, tran_count, None)

    res = make_response(
        render_template('order/tran_list.html.j2',
                        order_tran_list=order_tran_list,
                        pagination=pagination))
    res.set_cookie('goback_url', request.url)
    return res
Esempio n. 7
0
def lottery_detail(page=1, page_size=30):
    """一元云购活动详情"""
    g.page_type = ''
    g.title = u'一元云购活动详情'

    lottery_id = toint(request.args.get('lottery_id', '0'))

    lottery_info = Lottery.query.filter(
        Lottery.lottery_id == lottery_id).first()
    goods_list = Goods.query.filter(Goods.kind == 2).\
                    filter(Goods.is_sale == 1).all()

    if lottery_info is None:
        return u'一元云购活动不存在'

    param_dict = get_params({
        'lottery_name': str,
        'lottery_number': str,
        'nickname': str,
        'order_id': int,
        'is_prize': int,
        'add_time': str
    })
    query_dict = {
        'lottery_number': param_dict['lottery_number'],
        'order_id': param_dict['order_id'],
        'is_prize': param_dict['is_prize'],
        'add_time': param_dict['add_time']
    }

    q = db.session.query(LotteryNumber.ln_id, LotteryNumber.order_id, LotteryNumber.lottery_number, LotteryNumber.is_prize, LotteryNumber.add_time,Lottery.lottery_name,User.nickname).\
            filter(Lottery.lottery_id == LotteryNumber.lottery_id).\
            filter(LotteryNumber.uid == User.uid).\
            filter(LotteryNumber.lottery_id == lottery_id)

    q = easy_query_filter(LotteryNumber, q, query_dict)

    if param_dict['nickname']:
        q = q.filter(User.nickname.like(u'%' + param_dict['nickname'] + u'%'))

    if param_dict['lottery_name']:
        q = q.filter(
            Lottery.lottery_name.like(u'%' + param_dict['lottery_name'] +
                                      u'%'))

    lottery_count = get_count(q)
    lottery_number_list  = q.order_by(LotteryNumber.ln_id.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()
    pagination = Pagination(None, page, page_size, lottery_count, None)

    return render_template('lottery/add.html.j2', f=lottery_info, **locals())
Esempio n. 8
0
def temp_list(page=1, page_size=20):
    """一元云购模板列表"""
    g.page_type = 'search'
    g.title = u'一元云购模板列表'
    g.add_new = True
    g.button_name = u'新增一元云购模板'

    param_dict = get_params({
        'lt_id': int,
        'section_number': int,
        'goods_id': int,
        'lottery_name': str,
        'begin_add_time': str,
        'end_add_time': str
    })

    query_dict = {
        'lt_id': param_dict['lt_id'],
        'section_number': param_dict['section_number'],
        'goods_id': param_dict['goods_id'],
        'lottery_name': param_dict['lottery_name'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
    }

    q = db.session.query(LotteryTemplate.lt_id, LotteryTemplate.section_number, Goods.goods_name, LotteryTemplate.goods_id, LotteryTemplate.lottery_name, LotteryTemplate.lottery_img, LotteryTemplate.lottery_price, LotteryTemplate.add_time).\
        filter(LotteryTemplate.goods_id == Goods.goods_id).\
        filter(Goods.kind == 2)

    q = easy_query_filter(LotteryTemplate, q, query_dict)

    # 商品列表
    goods_list = [{'name': u'请选择……', 'value': '-1'}]
    goods_list_temp = db.session.query(Goods.goods_name, Goods.goods_id).\
                                group_by(Goods.goods_id).all()

    for goods in goods_list_temp:
        gs = {'name': goods.goods_name, 'value': goods.goods_id}
        goods_list.append(gs)

    lottery_temp_count = get_count(q)
    lottery_temp_list  = q.order_by(LotteryTemplate.lt_id.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()
    pagination = Pagination(None, page, page_size, lottery_temp_count, None)

    res = make_response(
        render_template('lottery/temp_list.html.j2', **locals()))
    res.set_cookie('goback_url', request.url)
    return res
Esempio n. 9
0
def save_card():
    """保存抽奖活动"""
    g.title = u'保存抽奖活动'
    g.page_type = ''
    errmsg = {}
    param_dict = get_params({
        'rc_id': int,
        'amount': Decimal,
        'gift': Decimal,
        'sort_order': str
    })
    required_param_list = ['amount', 'gift']
    form = request.form
    for param in required_param_list:
        val = request.form.get(param, '')
        val = val.strip()
        if not val:
            errmsg[param] = u'必填项'
            g.errmsg = errmsg
            log_debug('errmsg:%s' % g.errmsg)
            return render_template('sys/card_detail.html.j2',
                                   f=form,
                                   **locals())

    if param_dict['amount'] < 0:
        errmsg['amount'] = u'金额不能小于0'
        g.errmsg = errmsg
        return render_template('sys/card_detail.html.j2', f=form, **locals())

    if param_dict['gift'] < 0:
        errmsg['gift'] = u'赠送金额不能小于0'
        g.errmsg = errmsg
        return render_template('sys/card_detail.html.j2', f=form, **locals())

    rc_id = param_dict['rc_id']
    if rc_id > 0:
        recharge_card = RechargeCard.query.get_or_404(rc_id)
    else:
        recharge_card = RechargeCard.create(add_time=int(time.time()),
                                            update_time=int(time.time()))

    recharge_card.update(amount=param_dict['amount'],
                         gift=param_dict['gift'],
                         sort_order=param_dict['sort_order'],
                         commit=True)

    return redirect(url_for('sys.recharge_card_list'))
Esempio n. 10
0
def recharge_list(page=1, page_size=20):
    """充值订单列表"""
    g.title = u'充值订单列表'
    g.page_type = 'search'

    param_dict = get_params({
        'order_id': int,
        'order_status': int,
        'order_amount': int,
        'begin_paid_time': str,
        'end_paid_time': str,
        'begin_add_time': str,
        'end_add_time': str
    })

    query_dict = {
        'order_id': param_dict['order_id'],
        'order_status': param_dict['order_status'],
        'order_amount': param_dict['order_amount'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
        'begin_paid_time': param_dict['begin_paid_time'],
        'end_paid_time': param_dict['end_paid_time']
    }

    q = db.session.query(Order.order_id, Order.order_status, Order.order_desc, Order.order_amount, Order.shipping_sn, Order.shipping_status, Order.deliver_status, Order.is_comment, Order.add_time, Order.pay_type, Order.paid_time, Order.paid_amount).\
        filter(Order.order_type == 2)

    q = easy_query_filter(Order, q, query_dict)

    order_count = get_count(q)
    order_list = q.order_by(Order.add_time.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()

    pagination = Pagination(None, page, page_size, order_count, None)

    res = make_response(
        render_template('order/recharge_list.html.j2',
                        order_list=order_list,
                        pagination=pagination,
                        f={
                            'lt_id': '',
                            'lottery_id': ''
                        }))
    res.set_cookie('goback_url', request.url)
    return res
Esempio n. 11
0
def goods_edit_save():
    """保存编辑商品评价"""
    g.title = u'保存编辑商品评价'
    g.page_type = ''
    errmsg = {}

    param_dict = get_params({
        'comment_id': int,
        'goods_id': int,
        'tname': str,
        'timg': None,
        'star': int,
        'content': str,
        'add_time': str
    })

    required_param_list = [
        'comment_id', 'tname', 'star', 'content', 'add_time'
    ]

    for param in required_param_list:
        val = request.form.get(param, '')
        val = val.strip()
        if not val:
            errmsg[param] = u'必填项'
            g.errmsg = errmsg
            log_debug('errmsg:%s' % g.errmsg)
            return render_template('comment/goods_edit.html.j2',
                                   f=form,
                                   **locals())

    # 检查 - 封面原图是否合法
    timg = param_dict['timg']
    if timg:
        oss = AliyunOSS('comment', current_app.config['SAVE_TARGET_PATH'])
        try:
            oss.save(timg)
            timg = oss.put_to_oss()
        except UploadNotAllowed, e:
            errmsg['timg'] = u'图片只允许是图片文件'
        except Exception, e:
            errmsg['timg'] = u'图片上传失败'
Esempio n. 12
0
def ad_list(page=1, page_size=20):
    """广告列表"""
    g.page_type = 'search'
    g.title = u'广告列表'
    g.add_new = True
    g.button_name = u'增加广告'

    param_dict = get_params({
        'adv_id': int,
        'is_show': int,
        'begin_add_time': str,
        'end_add_time': str
    })

    query_dict = {
        'adv_id': param_dict['adv_id'],
        'is_show': param_dict['is_show'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
    }

    q = Adv.query
    q = easy_query_filter(Adv, q, query_dict)

    ad_count = get_count(q)
    ad_list  = q.order_by(Adv.add_time.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()

    pagination = Pagination(None, page, page_size, ad_count, None)

    res = make_response(
        render_template('sys/ad_list.html.j2',
                        ad_list=ad_list,
                        pagination=pagination))
    res.set_cookie('goback_url', request.url)
    return res
Esempio n. 13
0
def save_temp():
    """保存一元云购活动"""
    g.title = u'保存一元云购活动'
    g.page_type = ''
    errmsg = {}
    param_dict = get_params({
        'lt_id': int,
        'section_number': int,
        'goods_id': int,
        'lottery_name': str,
        'lottery_img': None,
        'lottery_price': Decimal,
        'max_quantity': int,
        'finish_quantity': int
    })
    lt_id = param_dict['lt_id']
    is_new = True if lt_id <= 0 else False
    goods_list = Goods.query.filter(Goods.kind == 2).\
                    filter(Goods.is_sale == 1).all()
    finish_quantity = param_dict['finish_quantity']

    if finish_quantity < 1:
        errmsg['finish_quantity'] = u'达到开奖人次数量不能小于1'

    required_param_list = [
        'goods_id', 'lottery_price', 'max_quantity', 'finish_quantity'
    ]

    form = request.form
    for param in required_param_list:
        val = request.form.get(param, '')
        val = val.strip()
        if not val:
            errmsg[param] = u'必填项'
            g.errmsg = errmsg
            log_debug('errmsg:%s' % g.errmsg)
            return render_template('lottery/add_template.html.j2',
                                   f=form,
                                   **locals())

    goods = Goods.query.get_or_404(param_dict['goods_id'])

    # 每人最多参与次数 不能大于 达到开奖人次数量
    if param_dict['max_quantity'] > finish_quantity:
        errmsg['max_quantity'] = u'每人最多参与次数 不能大于 达到开奖人次数量'
        g.errmsg = errmsg
        return render_template('lottery/add_template.html.j2',
                               f=form,
                               **locals())

    # 检查 - 封面原图是否合法
    lottery_img = param_dict['lottery_img']
    if lottery_img:
        oss = AliyunOSS('lottery', current_app.config['SAVE_TARGET_PATH'])
        try:
            oss.save(lottery_img)
            lottery_img = oss.put_to_oss()
        except UploadNotAllowed, e:
            errmsg['lottery_img'] = u'图片只允许是图片文件'
        except Exception, e:
            errmsg['lottery_img'] = u'图片上传失败'
Esempio n. 14
0
def lottery_index(page=1, page_size=20):
    """一元购订单列表"""
    g.title = u'一元购订单列表'
    g.page_type = 'search'

    param_dict = get_params({
        'order_id': int,
        'order_status': int,
        'section_number_list': str,
        'order_amount': int,
        'begin_paid_time': str,
        'end_paid_time': str,
        'shipping_sn': str,
        'shipping_status': int,
        'deliver_status': int,
        'is_comment': int,
        'begin_add_time': str,
        'end_add_time': str,
        'lt_id': int,
        'lottery_id': int,
        'is_prize': int,
        'tran_id': int,
        'pay_status': int
    })

    query_dict = {
        'order_id': param_dict['order_id'],
        'order_status': param_dict['order_status'],
        'order_amount': param_dict['order_amount'],
        'shipping_sn': param_dict['shipping_sn'],
        'shipping_status': param_dict['shipping_status'],
        'deliver_status': param_dict['deliver_status'],
        'is_comment': param_dict['is_comment'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
        'begin_paid_time': param_dict['begin_paid_time'],
        'end_paid_time': param_dict['end_paid_time'],
        'pay_status': param_dict['pay_status']
    }

    section_number = 0
    if param_dict['lottery_id']:
        lottery = Lottery.query.get(param_dict['lottery_id'])
        section_number = lottery.section_number if lottery else 0

    q = db.session.query(Order.order_id, Order.order_status, Order.order_desc, Order.pay_status, Order.section_number_list, Order.order_amount, Order.shipping_sn, Order.shipping_status, Order.deliver_status, Order.is_comment, Order.add_time, Order.paid_time, LotteryNumber.is_prize,LotteryNumber.ln_id).outerjoin(LotteryNumber,and_(Order.order_id == LotteryNumber.order_id)).\
        group_by(Order.order_id.desc())

    # 筛选是否中奖
    is_prize = param_dict['is_prize']
    is_prize_list = [is_prize] if is_prize >= 0 else [0, 1]
    if len(is_prize_list) == 1:
        q = db.session.query(LotteryNumber.is_prize,LotteryNumber.ln_id, Order.order_status, Order.order_desc, Order.section_number_list, Order.order_amount, Order.shipping_sn, Order.shipping_status, Order.deliver_status, Order.is_comment, Order.add_time, Order.paid_time, Order.order_id).\
            outerjoin(Order,and_(Order.order_id == LotteryNumber.order_id, LotteryNumber.is_prize.in_(is_prize_list)))

    if section_number > 0:
        q = q.filter(Order.section_number_list == section_number)

    if param_dict['tran_id'] > 0:
        g.title = u'交易订单列表'
        q = q.filter(Order.tran_id == param_dict['tran_id'])
    else:
        q = q.filter(Order.order_type == 3)

    q = easy_query_filter(Order, q, query_dict)

    # 一元购活动模板列表
    lottery_template_list = [{'name': u'请选择活动模板……', 'value': ''}]
    lottery_template_list_temp = db.session.query(LotteryTemplate.lt_id, LotteryTemplate.lottery_name).\
                                    filter(LotteryTemplate.lottery_name != '').all()

    for lottery_template in lottery_template_list_temp:
        template = {
            'name': lottery_template.lottery_name,
            'value': lottery_template.lt_id
        }
        lottery_template_list.append(template)

    # 活动期数列表
    section_number_list = [{'name': u'请选择活动期数……', 'value': ''}]
    section_number_list_temp = db.session.query(Lottery.lottery_id, Lottery.section_number).\
                                filter(Lottery.lt_id == param_dict['lt_id']).all()

    for section_number in section_number_list_temp:
        section_number = {
            'name': section_number.section_number,
            'value': section_number.lottery_id
        }
        section_number_list.append(section_number)

    order_count = get_count(q)
    order_list = q.order_by(Order.add_time.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()

    pagination = Pagination(None, page, page_size, order_count, None)

    res = make_response(
        render_template('order/lottery_index.html.j2',
                        lottery_template_list=lottery_template_list,
                        section_number_list=section_number_list,
                        order_list=order_list,
                        pagination=pagination,
                        is_prize_list=is_prize_list,
                        f={
                            'lt_id': '',
                            'lottery_id': ''
                        }))
    res.set_cookie('goback_url', request.url)
    return res
Esempio n. 15
0
def order_index(page=1, page_size=20):
    """订单评价列表"""
    g.title = u''
    g.page_type = 'search'

    param_dict = get_params({
        'mobile': str,
        'nickname': str,
        'user_device': str,
        'order_type': int,
        'order_status': int,
        'order_id': str,
        'order_amount': int,
        'discount_amount': int,
        'discount_desc': str,
        'pay_amount': int,
        'pay_method': str,
        'pay_type': int,
        'pay_status': int,
        'pay_tran_id': int,
        'begin_paid_time': str,
        'end_paid_time': str,
        'paid_amount': int,
        'shipping_id': int,
        'shipping_name': str,
        'shipping_amount': int,
        'shipping_sn': str,
        'shipping_status': int,
        'shipping_time': str,
        'deliver_status': int,
        'deliver_time': str,
        'milestone_status': int,
        'milestone_text': str,
        'is_comment': int,
        'begin_add_time': str,
        'end_add_time': str,
        'update_time': str
    })

    query_dict = {
        'order_id': param_dict['order_id'],
        'order_type': param_dict['order_type'],
        'order_status': param_dict['order_status'],
        'shipping_sn': param_dict['shipping_sn'],
        'shipping_status': param_dict['shipping_status'],
        'deliver_status': param_dict['deliver_status'],
        'is_comment': param_dict['is_comment'],
        'begin_add_time': param_dict['begin_add_time'],
        'end_add_time': param_dict['end_add_time'],
        'pay_type': param_dict['pay_type'],
        'begin_paid_time': param_dict['begin_paid_time'],
        'end_paid_time': param_dict['end_paid_time']
    }

    q = db.session.query(Order.order_id, User.nickname, Order.order_type, Order.order_status, Order.order_desc, Order.order_amount, Order.shipping_sn, Order.shipping_status, Order.deliver_status, Order.is_comment, Order.add_time, Order.pay_type, Order.paid_time).\
        filter(Order.uid == User.uid)

    q = easy_query_filter(Order, q, query_dict)

    order_count = get_count(q)
    order_list = q.order_by(Order.order_id.desc()).offset((page-1)*page_size).\
                    limit(page_size).all()
    pagination = Pagination(None, page, page_size, order_count, None)

    res = make_response(
        render_template('comment/order_index.html',
                        order_list=order_list,
                        pagination=pagination))
    res.set_cookie('goback_url', request.url)
    return res