Beispiel #1
0
def print_shopping_history(userobj):
    """
    个人中心 - 购物历史记录打印模块
    :param userobj:    用户对象
    :return:  显示指定时间段的购物历史记录
    """
    date_between = get_date()
    start = date_between["start"]
    end = date_between["end"]
    # 通过dbapi获得要查询的记录列表,结果为dict_list类型
    history_list = dbapi.load_shop_history(userobj.username, start, end)
    # 获取模板文件样式
    _template = templates.shopping_history
    common.show_message(
        _template.format(username=userobj.username,
                         startdate=start,
                         enddate=end), "NOTICE")

    if not history_list:
        common.show_message("无购物记录!", "NOTICE")
    else:
        for record in history_list:
            # 获取消费信息
            _tmprec = list(record.values())[0]
            common.show_message(
                "\n流水号:{0}       时间:{1}     消费金额:{2}\n".format(
                    _tmprec["serno"], _tmprec["time"], _tmprec["cost"]),
                "NOTICE")
            # 调用Shopping的类方法打印详单
            Shopping.print_goods_list(_tmprec["detail"])
Beispiel #2
0
def print_shopping_history(userobj):
    """
    个人中心 - 购物历史记录打印模块
    :param userobj:    用户对象
    :return:  显示指定时间段的购物历史记录
    """
    date_between = get_date()
    start = date_between["start"]
    end = date_between["end"]
    # 通过dbapi获得要查询的记录列表,结果为dict_list类型
    history_list = dbapi.load_shop_history(userobj.username, start, end)
    # 获取模板文件样式
    _template = template.shopping_history
    common.show_message(_template.format(username=userobj.username,
                                         startdate=start,
                                         enddate=end), "NOTICE")

    if not history_list:
        common.show_message("无购物记录!", "NOTICE")
    else:
        for record in history_list:
            # 获取消费信息
            _tmprec = list(record.values())[0]
            common.show_message("\n流水号:{0}       时间:{1}     消费金额:{2}\n".format(_tmprec["serno"],
                                                                               _tmprec["time"],
                                                                               _tmprec["cost"]), "NOTICE")
            # 调用Shopping的类方法打印详单
            Shopping.print_goods_list(_tmprec["detail"])