Beispiel #1
0
def info():
    resp_data = {}
    req = request.args
    id = int(req.get('id', 0))

    if id < 1:
        return redirect(UrlManager.buildUrl("/member/index"))

    info = Member.query.filter_by(id=id).first()
    if not info:
        return redirect(UrlManager.buildUrl("/member/index"))
    address_info = MemberAddres.query.filter_by(member_id=id).first()

    ids = [id]
    pay_order_map = getDictList(PayOrder, PayOrder.member_id, "member_id", ids)
    pay_order_list = []
    if pay_order_map:
        pay_order_list = pay_order_map[id]

    food_map = getDictList(Food, Food.member_id, "member_id", ids)
    food_list = []
    if food_map:
        food_list = food_map[id]

    resp_data['search_con'] = req
    resp_data['info'] = info
    resp_data['pay_order_list'] = pay_order_list
    resp_data['food_list'] = food_list
    resp_data['address_info'] = address_info
    resp_data['current'] = 'index'

    return ops_render("member/info.html", resp_data)
Beispiel #2
0
def info():
    resp_data = {}
    req = request.args
    id = int(req.get('id', 0))

    if id < 1:
        return redirect(UrlManager.buildUrl("/food/index"))

    info = Food.query.filter_by(id=id).first()
    if not info:
        return redirect(UrlManager.buildUrl("/food/index"))

    ids = [id]
    order_item_map = getDictList(PayOrderItem, PayOrderItem.food_id, "food_id",
                                 ids)
    order_item_list = []
    if order_item_map:
        order_item_list = order_item_map[id]

    count = 0
    for item in order_item_list:
        count += item.quantity
    info.total_count = count

    cat_mapping = getDict(FoodCat, 'id', 'id', [])
    member_mapping = getDict(Member, 'id', 'id', [])
    resp_data['cat_mapping'] = cat_mapping
    resp_data['member_mapping'] = member_mapping
    resp_data['info'] = info
    resp_data['order_item_list'] = order_item_list

    return ops_render("food/info.html", resp_data)
Beispiel #3
0
def dataList(pay_list):

    data_list = []

    if pay_list:
        pay_order_ids = selectFilter(pay_list, "id")
        pay_order_item_map = getDictList(PayOrderItem,
                                         PayOrderItem.pay_order_id,
                                         "pay_order_id", pay_order_ids)

        food_mapping = {}
        if pay_order_item_map:
            food_ids = []
            for item in pay_order_item_map:
                food_id = selectFilter(pay_order_item_map[item], "food_id")
                # food_ids_tmp = {}.fromkeys(food_ids_tmp).values()
                food_ids += food_id

            food_mapping = getDict(Food, Food.id, "id", food_ids)

            for item in pay_list:
                member_info = Member.query.filter_by(id=item.member_id).first()
                data_tmp = {
                    "id": item.id,
                    "nickname": member_info.nickname,
                    "status_desc": item.status_desc,
                    "order_number": item.order_sn,
                    "price": item.total_price
                }

                food_tmp = []
                pay_order_item = pay_order_item_map[item.id]
                for tmp in pay_order_item:
                    food_info = food_mapping[tmp.food_id]
                    member_info = Member.query.filter_by(
                        id=food_info.member_id).first()
                    food_tmp.append({
                        "name": food_info.name,
                        "quantity": tmp.quantity,
                        "merchants": member_info.nickname
                    })
                data_tmp['foods'] = food_tmp
                data_list.append(data_tmp)

    return data_list
Beispiel #4
0
def ops():
    prompt = {'code': 200, 'msg': '操作成功', 'data': {}}
    req = request.values

    id = req['id'] if 'id' in req else ''
    act = req['act'] if 'act' in req else ''

    if not id:
        prompt['code'] = -1
        prompt['msg'] = "请选择要操作的账号!"
        return jsonify(prompt)

    if act not in ["remove", "recover"]:
        prompt['code'] = -1
        prompt['msg'] = "操作有误!"
        return jsonify(prompt)

    member_info = Member.query.filter_by(id=id).first()
    if not member_info:
        prompt['code'] = -1
        prompt['msg'] = "账号不存在!"
        return jsonify(prompt)

    if act == "remove":
        member_info.status = 0
    elif act == "recover":
        member_info.status = 1

    if member_info.status == 0:
        ids = [id]
        food_map = getDictList(Food, Food.member_id, "member_id", ids)
        food_list = food_map[member_info.id]
        for item in food_list:
            item.status = 0

    db.session.add(member_info)
    db.session.commit()
    return jsonify(prompt)
Beispiel #5
0
def payInfo():
    resp_data = {}
    req = request.args
    id = int(req.get('id', 0))

    if id < 1:
        return redirect(UrlManager.buildUrl("/finance/index"))

    pay_info = PayOrder.query.filter_by(id=id).first()
    member_info = Member.query.filter_by(id=pay_info.member_id).first()
    pay_item_info = PayOrderItem.query.filter_by(pay_order_id=id).first()
    address_info = MemberAddres.query.filter_by(
        member_id=member_info.id).first()

    if not pay_info:
        return redirect(UrlManager.buildUrl("/finance/index"))
    if not member_info:
        return redirect(UrlManager.buildUrl("/finance/index"))
    if not pay_item_info:
        return redirect(UrlManager.buildUrl("/finance/index"))

    ids = [id]
    pay_item_map = getDictList(PayOrderItem, PayOrderItem.pay_order_id,
                               "pay_order_id", ids)
    pay_item_list = []
    if pay_item_map:
        pay_item_list = pay_item_map[id]

    food_mapping = getDict(Food, Food.id, "id", [])

    resp_data['pay_info'] = pay_info
    resp_data['pay_item_list'] = pay_item_list
    resp_data['food_mapping'] = food_mapping
    resp_data['member_info'] = member_info
    resp_data['address_info'] = address_info
    resp_data['current'] = 'index'
    return ops_render("finance/pay_info.html", resp_data)