Esempio n. 1
0
def apply_clients():
    """
      @api {get} /seller/apply_clients/ 05. 获取我的申请用户列表
      @apiGroup S_商家_Seller
      @apiVersion 1.0.0
      @apiPermission 访问授权
      @apiParam {str} next_start 分页起始ID 默认值: null
      @apiSuccessExample {json} JSON.result 对象
      {
        apply_clients:[{
           "_id": String # 主键,用户ID,其它地方为: user_id
           "name": String # 姓名/昵称
           "phone": String #联系方式
        }]
      }
    """
    lists = []
    code = 0
    try:
        list = users.find({"type": 0, "apply_status": 0}).limit(item_count()).skip(next_start()).sort("timed", pymongo.DESCENDING)
        for user in list:
            us = {}
            us['_id'] = user['_id']
            us['name'] = user['name']
            us['phone'] = user['phone']
            lists.append(us)
    except:
        code = -1
    data = {"apply_clients": lists}
    return apiresult(data, code)
Esempio n. 2
0
def my_clients():
    """
       @api {POST} /seller/my_clients/ 03. 获取我的客户列表
       @apiGroup S_商家_Seller
       @apiVersion 1.0.0
       @apiParam {int} next_start 分页起始ID 默认值: 0
       @apiPermission 访问授权
       @apiSuccessExample {json} JSON.result 对象
       {
         "users" : [
                "_id": String # 主键,用户ID,其它地方为: user_id
                "name": String # 姓名/昵称
                "diet_timed" : Long #最新饮食日报发布时间,根据时间判断是否已报
                "is_report" : Long #最新食谱发布时间,根据时间判断商家是否配餐
            ]
       }
    """

    if not next_start:
        return "请求参数错误"
    code = 0
    try:
        members = users.find({'type': 0, "apply_status": 1, "status": 0}).limit(item_count()).skip(next_start()).sort("timed", pymongo.DESCENDING)
    except:
        code = -1
    data = []
    for mem in members:
        member = {}
        member['_id'] = mem['_id']
        member['name'] = mem['name']
        member['diet_timed'] = mem['diet_timed']
        member['is_report'] = mem['is_report']
        data.append(member)

    us = {"users": data}
    # return jsonify(code=code,result=us,timestamp=timestamp())
    return apiresult(us, code)
Esempio n. 3
0
def sell_comprehensive_daily(user_id):
    """
       @api {GET} /seller/sell_comprehensive_daily/<user_id>/ 10. 获取用户综合日报列表信息
       @apiGroup S_商家_Seller
       @apiVersion 1.0.0
       @apiPermission 访问授权
       @apiParam {str} next_start 分页起始ID 默认值: null
       @apiSuccessExample {json} JSON.result 对象
       {
            "local_weight" : Double # 原始体重 [单位:kg]
            "arrange_weight" : Double # 变化体重 [单位:kg,备注:结果小于0瘦了,大于0胖了]
            "today_weight" : Double # 今日体重 [单位:kg]
             "comprehensive" : [{
                "weight": Double # 今日体重
                "arrange_weight" : Double # 变化体重 [单位:kg]
                "timed": Long # 创建时间
             }]
       }
    """

    if not user_id:
        return "请求参数不能为空"
    lists = []
    code = 0
    result = {}
    try:
        list = DB.comprehensive_daily.find(filter={"user_id": user_id}, projection={"weight": 1, "timed": 1, "_id": 1}).limit(item_count()).skip(next_start()).sort("timed", pymongo.DESCENDING)
        user = users.find_one(filter={"_id": user_id}, projection={"_id": 1, "weight": 1, "local_weight": 1})
        for comprehen in list:
            com = {}
            com['_id'] = comprehen['_id']
            com['weight'] = comprehen['weight']
            if "weight" in comprehen and "weight" in user:
                com['arrange_weight'] = comprehen['weight'] - user['local_weight']
            else:
                com['arrange_weight'] = float(0)
            com['timed'] = comprehen['timed']
            lists.append(com)
        arrange_weight = float(0)
        if user:
            if ("weight" in user) and ("local_weight" in user):
                arrange_weight = user['weight'] - user['local_weight']
                result = {"local_weight": user['local_weight'], "arrange_weight": arrange_weight, "today_weight": user['weight'], "comprehensive": lists}
        else:
            result = {"local_weight": float(0), "arrange_weight": arrange_weight, "today_weight": float(0), "comprehensive": lists}
    except:
        code = -1

    return apiresult(result, code)
Esempio n. 4
0
def sell_dietetic_daily(user_id):
    """
       @api {GET} /seller/sell_dietetic_daily/<user_id>/ 09. 获取用户饮食日报列表
       @apiGroup S_商家_Seller
       @apiVersion 1.0.0
       @apiPermission 访问授权
       @apiParam {str} user_id 用户ID
       @apiParam {int} next_start 分页起始ID 默认值: null
       @apiSuccessExample {json} JSON.result 对象
       {
         dietetic_daily:[
            {
                id: String # 饮食日报ID
                timed : Long 时间
            }
         ]
       }
    """
    if not user_id:
        return "请求参数错误"
    code = 0
    lists = []
    try:
        lists = DB.dietetic_daily.find(filter={"user_id": user_id}, projection={"_id": 1, "timed": 1}).limit(item_count()).skip(next_start()).sort("timed", pymongo.DESCENDING)
    except:
        code = -1
    list = []
    for rec in lists:
        reci = {}
        reci['_id'] = rec['_id']
        reci['timed'] = rec['timed']
        list.append(reci)
    return apiresult({"dietetic_daily": list}, code)
Esempio n. 5
0
def user_recipes(user_id):
    """
       @api {GET} /seller/user_recipes/<user_id>/ 08. 获取用户食谱列表
       @apiGroup S_商家_Seller
       @apiVersion 1.0.0
       @apiPermission 访问授权
       @apiParam {str} user_id 用户ID
       @apiParam {str} next_start 分页起始ID 默认值: null
       @apiSuccessExample {json} JSON.result 对象
       {
         today_recipes:[
            {
                id: String # 食谱ID
                content: String # 食谱内容
                timed : Long 时间
            }
         ]
       }
    """

    if not user_id:
        return "请求参数错误"
    code = 0
    lists = []
    try:
        lists = DB.recipes.find(filter={"user_id": user_id}, projection={"_id": 1, "content": 1, "timed": 1}).limit(item_count()).skip(next_start()).sort("timed", pymongo.DESCENDING)
    except:
        code = -1
    list = []
    for rec in lists:
        reci = {}
        reci['_id'] = rec['_id']
        reci['content'] = rec['content']
        reci['timed'] = rec['timed']
        list.append(reci)
    return apiresult({"today_recipes": list}, code)