Example #1
0
def get_user(user_id):
    with thrift_client('eus') as eus_client:
        user_profile = eus_client.get_profile(user_id)
        user = eus_client.get(user_id)
        user_profile = getresult_to_raw(user_profile)
        user = getresult_to_raw(user)
        user.update(user_profile)
    return user
Example #2
0
def get_user(user_id):
    with thrift_client('eus') as eus_client:
        user_profile = eus_client.get_profile(user_id)
        user = eus_client.get(user_id)
        user_profile = getresult_to_raw(user_profile)
        user = getresult_to_raw(user)
        user.update(user_profile)
    return user
Example #3
0
def get(id_or_ids):
    with thrift_client('ers') as ers:
        if isinstance(id_or_ids, (tuple, list)):
            result = ers.mget(id_or_ids)
        else:
            result = ers.get(id_or_ids)
    result = getresult_to_raw(result)
    return result
Example #4
0
def get(id_or_ids):
    with thrift_client('ers') as ers:
        if isinstance(id_or_ids, (tuple, list)):
            result = ers.mget(id_or_ids)
        else:
            result = ers.get(id_or_ids)
    result = getresult_to_raw(result)
    return result
Example #5
0
def get(pk_or_pks):
    with thrift_client('ers') as ers:
        if isinstance(pk_or_pks, (tuple, list)):
            pk_or_pks = list(set(pk_or_pks))
            result = ers.mget_city(pk_or_pks)
            # zeus大神在这mget return了个字典-.-你大爷的不一致
            result = result.values()
        else:
            pk_or_pks = int(pk_or_pks)
            result = ers.get_city(pk_or_pks)
    result = getresult_to_raw(result)
    return result
Example #6
0
 def get_suspicious_orders(cls, restaurant_id, date, **kwargs):
     query_kwargs = {
         'restaurant_id': restaurant_id,
         'date': date
     }
     result = zeus_query('eyes', 'walle_get_suspicious_orders',
                         thirdparty_svc.eyes.TWalleSuspiciousOrderQuery,
                         **query_kwargs)
     # for order in result:
     # order['id'] = order['_id']
     order_ids = [order['id'] for order in result]
     orders = OrderBase.mget(order_ids)
     orders = {order['id']: order for order in orders}
     with thrift_client('eos') as eos:
         orders_info = eos.mget_order_info(order_ids)
         orders_info = getresult_to_raw(orders_info)
     orders_info = {info['order_id']: info for info in orders_info}
     for order in result:
         order.update(orders[order['id']])
         order.update(orders_info[order['id']])
     for order in result:
         if order['phone_rating'] == 1:
             order['is_new_user'] = True
         else:
             order['is_new_user'] = False
     phones = [order['phone'] for order in orders.values()]
     phones_ban_status_map = {phone: PhoneBanBase.get_phone_ban_status(phone)
                              for phone in phones}
     user_ids = [order['user_id'] for order in orders.values()]
     with thrift_client('eus') as eus_client:
         users = eus_client.mget(user_ids)
         users = any_to_raw(users)
     users_map = {user['id']: user for user in users}
     for order in result:
         order['phone_ban_status'] = phones_ban_status_map[order['phone']]
         order['user_is_active'] = users_map[order['user_id']]['is_active']
     for order in result:
         try:
             better_json = json.loads(order['better_json'])
             better_json = flatten(better_json)
             subsidy = 0
             for _better_what in better_json:
                 price = _better_what.get('price', 0)
                 if price < 0:
                     subsidy += price
             order['subsidy'] = abs(subsidy)
             order['id'] = unicode(order['id'])
         except:
             continue
     return result
Example #7
0
def get_struct(user_id):
    with thrift_client('ers') as ers:
        result = ers.get_direct_struct(user_id)
        result = getresult_to_raw(result)

        region_group_query = thirdparty_svc.ers.TRegionGroupQuery()
        region_group_query.city_ids = result.city_ids
        region_group_query.show_all = True

        region_groups_of_city = ers.query_region_group(region_group_query)
        region_groups_of_city = any_to_raw(region_groups_of_city)

        region_group_ids = result.region_group_ids
        region_group_ids.extend([obj['id'] for obj in region_groups_of_city])
        region_groups = ers.mget_region_group(region_group_ids).values()
        for region_group in region_groups:
            regions = ers.get_regions_by_region_group_ids([region_group.id])
            setattr(region_group,'_regions',regions)
        regions = ers.mget_region(result.region_ids).values()
        for region in regions:
            region_group_of_alone_region = ers.get_region_group_by_region(region.id)
            for region_group in region_groups:
                if region_group_of_alone_region.id == region_group.id:
                    region_group._regions.append(region)
            else:
                setattr(region_group_of_alone_region,'_regions',[region])
                region_groups.append(region_group_of_alone_region)
        region_group_group_by_city_id = defaultdict(list)
        for region_group in region_groups:
            region_group_group_by_city_id[region_group.city_id].append(region_group)
        city_ids = list(set(result.city_ids+region_group_group_by_city_id.keys()))
        cities = city_base.get(city_ids)
        for city in cities:
            setattr(city,'_region_groups',region_group_group_by_city_id.get(city.id,[]))
        cities = getresult_to_raw(cities)
        result = cities
        return result
Example #8
0
def get_struct(user_id):
    with thrift_client("ers") as ers:
        result = ers.get_direct_struct(user_id)
        result = getresult_to_raw(result)

        region_group_query = thirdparty_svc.ers.TRegionGroupQuery()
        region_group_query.city_ids = result.city_ids
        region_group_query.show_all = True

        region_groups_of_city = ers.query_region_group(region_group_query)
        region_groups_of_city = any_to_raw(region_groups_of_city)

        region_group_ids = result.region_group_ids
        region_group_ids.extend([obj["id"] for obj in region_groups_of_city])
        region_groups = ers.mget_region_group(region_group_ids).values()
        for region_group in region_groups:
            regions = ers.get_regions_by_region_group_ids([region_group.id])
            setattr(region_group, "_regions", regions)
        regions = ers.mget_region(result.region_ids).values()
        for region in regions:
            region_group_of_alone_region = ers.get_region_group_by_region(region.id)
            for region_group in region_groups:
                if region_group_of_alone_region.id == region_group.id:
                    region_group._regions.append(region)
            else:
                setattr(region_group_of_alone_region, "_regions", [region])
                region_groups.append(region_group_of_alone_region)
        region_group_group_by_city_id = defaultdict(list)
        for region_group in region_groups:
            region_group_group_by_city_id[region_group.city_id].append(region_group)
        city_ids = list(set(result.city_ids + region_group_group_by_city_id.keys()))
        cities = city_base.get(city_ids)
        for city in cities:
            setattr(city, "_region_groups", region_group_group_by_city_id.get(city.id, []))
        cities = getresult_to_raw(cities)
        result = cities
        return result
Example #9
0
 def get_suspicious_orders(cls, restaurant_id, date, **kwargs):
     query_kwargs = {'restaurant_id': restaurant_id, 'date': date}
     result = zeus_query('eyes', 'walle_get_suspicious_orders',
                         thirdparty_svc.eyes.TWalleSuspiciousOrderQuery,
                         **query_kwargs)
     # for order in result:
     # order['id'] = order['_id']
     order_ids = [order['id'] for order in result]
     orders = OrderBase.mget(order_ids)
     orders = {order['id']: order for order in orders}
     with thrift_client('eos') as eos:
         orders_info = eos.mget_order_info(order_ids)
         orders_info = getresult_to_raw(orders_info)
     orders_info = {info['order_id']: info for info in orders_info}
     for order in result:
         order.update(orders[order['id']])
         order.update(orders_info[order['id']])
     for order in result:
         if order['phone_rating'] == 1:
             order['is_new_user'] = True
         else:
             order['is_new_user'] = False
     phones = [order['phone'] for order in orders.values()]
     phones_ban_status_map = {
         phone: PhoneBanBase.get_phone_ban_status(phone)
         for phone in phones
     }
     user_ids = [order['user_id'] for order in orders.values()]
     with thrift_client('eus') as eus_client:
         users = eus_client.mget(user_ids)
         users = any_to_raw(users)
     users_map = {user['id']: user for user in users}
     for order in result:
         order['phone_ban_status'] = phones_ban_status_map[order['phone']]
         order['user_is_active'] = users_map[order['user_id']]['is_active']
     for order in result:
         try:
             better_json = json.loads(order['better_json'])
             better_json = flatten(better_json)
             subsidy = 0
             for _better_what in better_json:
                 price = _better_what.get('price', 0)
                 if price < 0:
                     subsidy += price
             order['subsidy'] = abs(subsidy)
             order['id'] = unicode(order['id'])
         except:
             continue
     return result
Example #10
0
def regions_from_struct(input_struct,his_struct):
    city_ids = input_struct.get('city_ids',[])
    region_group_ids = input_struct.get('region_group_ids',[])
    region_ids = input_struct.get('region_ids',[])
    all_region_ids = []
    for city_id in city_ids:
        for city in his_struct:
            if city_id == city.id:
                for region_group in city._region_groups:
                    for region in region_group._regions:
                        all_region_ids.append(region.id)
    for region_group_id in region_group_ids:
        for city in his_struct:
            for region_group in city._region_groups:
                if region_group.id == region_group_id:
                    for region in region_group._regions:
                        all_region_ids.append(region.id)
    for region_id in region_ids:
        all_region_ids.append(region_id)
    all_region_ids = list(set(all_region_ids))
    with thrift_client('ers') as ers:
        result = ers.mget_region(all_region_ids)
        result = getresult_to_raw(result)
        return result.values()
Example #11
0
def regions_from_struct(input_struct, his_struct):
    city_ids = input_struct.get("city_ids", [])
    region_group_ids = input_struct.get("region_group_ids", [])
    region_ids = input_struct.get("region_ids", [])
    all_region_ids = []
    for city_id in city_ids:
        for city in his_struct:
            if city_id == city.id:
                for region_group in city._region_groups:
                    for region in region_group._regions:
                        all_region_ids.append(region.id)
    for region_group_id in region_group_ids:
        for city in his_struct:
            for region_group in city._region_groups:
                if region_group.id == region_group_id:
                    for region in region_group._regions:
                        all_region_ids.append(region.id)
    for region_id in region_ids:
        all_region_ids.append(region_id)
    all_region_ids = list(set(all_region_ids))
    with thrift_client("ers") as ers:
        result = ers.mget_region(all_region_ids)
        result = getresult_to_raw(result)
        return result.values()
Example #12
0
def query_suspicous():
    args_spec = {
        'start_datetime':Arg(unicode, default=arrow.now().replace(days=-1).__str__()),
        'end_datetime':Arg(unicode, default=arrow.now().__str__()),
        'restaurant_id':Arg(int),
        'offset':Arg(int,default=0),
        'limit':Arg(int,default=100),
    }
    args = args_parser.parse(args_spec)
    if not args['restaurant_id']:
        return {
            'total':0,
            'objects':[],
    }
    client = pymongo.MongoClient(config.EYES_MONGO)
    collection = client.evileye.suspicious_order
    # db.tickets.find({"date":{$lt:ISODate("2013-01-17T01:16:33.303Z")}}).limit (5);
    start_datetime = args['start_datetime'].split('+')[0]
    end_datetime = args['end_datetime'].split('+')[0]

    start_datetime = arrow.get(start_datetime).to('local').datetime
    end_datetime = arrow.get(end_datetime).to('local').datetime
    restaurant_id = args['restaurant_id']
    offset = args['offset']
    limit = args['limit']
    query = {
        'created_at':{'$lte':end_datetime,'$gte':start_datetime},
    }
    if restaurant_id:
        query.update({'restaurant_id':restaurant_id})
    docs = collection.find(query)
    total = docs.count()
    result_docs = list(docs.limit(limit).skip(offset))
    time_fields = ['deliver_time','settled_at']
    with thrift_client('eos') as eos:
        for doc in result_docs:
            order_id = doc['_id']
            order = eos.get(int(order_id))
            order = getresult_to_raw(order)
            for k,v in order.items():
                doc.setdefault(k,v)
            doc['detail_json'] = json.loads(doc['detail_json'])
            doc['_order_id'] = doc['_id']
            for field in time_fields:
                new_value = arrow.get(doc[field]).__str__()
                doc[field] = new_value
            doc['phone'] = [doc['phone']]
            with thrift_client('eus') as eus_client:
                chaos = eus_client.get_order_payment_constitution_map([int(order_id)])
                payment_constituion = chaos.get(order['id'],[])
                doc['payment_constituion'] = order_query_helper.whatzfvcksay(payment_constituion,doc['total'])
            doc['order_id'] = unicode(doc['_id'])
    order_ids = [doc['id'] for doc in result_docs]
    with thrift_client('eyes') as eyes_client:
        suspicious_orders = eyes_client.walle_get_suspicious_order_detail(order_ids)
        suspicious_orders = getresult_to_raw(suspicious_orders)
        suspicious_orders_map = {order.id:order for order in suspicious_orders}
    for _object in result_docs:
        suspicious = suspicious_orders_map.get(_object['id'],{})
        _object['_order_suspicious_reason'] = suspicious.get('reasons',[])
    restaurant_ids = list(set([o['restaurant_id'] for o in result_docs]))
    restaurants = rst_base.get(restaurant_ids)
    for r in restaurants:
        r['_image_url'] = image_hash_to_url(r['image_hash'])
    restaurant_map = {r.id:r for r in restaurants}
    for order in result_docs:
        order['_restaurant'] = restaurant_map[order['restaurant_id']]
    result = {
        'total':total,
        'objects':result_docs,
    }
    return result
Example #13
0
def ess_search2(**args):
    def calc_index(query):
        return 'order'
    doc_type = 'eleme_order'
    query = args['query']
    index = calc_index(query)
    q = json.loads(query)
    if 'filter' not in q:
        q['filter'] = {}
    if 'bool' not in q['filter']:
        q['filter']['bool'] = {}
    struct = args['struct']
    struct = json.loads(struct)
    regions = []
    current_user_struct = get_struct(current_user.id)
    if not current_user_struct:
        return {'total':0,'objects':[]}

    #处理未分组
    is_ungroup = False
    _region_groups_ids = struct.get('region_group_ids',[])
    with thrift_client('ers') as ers:
        _result = ers.mget_region_group(_region_groups_ids)
        _result = getresult_to_raw(_result)
    for _region_group in _result.values():
        if _region_group.name.find(u'未分组') >= 0:
            is_ungroup = True
            with thrift_client('ers') as ers:
                region_query = thirdparty_svc.ers.TRegionQuery()
                region_query.city_ids = [_region_group.city_id]
                regions = ers.query_region(region_query)
                regions = any_to_raw(regions)
                regions = getresult_to_raw(regions)
            should = []
            for region in regions:
                should.append(
                    {
                        'geo_polygon':{
                            'eleme_order.location':{
                                'points':region_area_to_es_points(region.area)
                            }
                        }
                    }
                )
            q['filter']['bool']['must_not'] = [
                #{'filter':{
                {
                    'bool':{
                        'should':should,
                        #'mininum_should_match':1,
                    }
                }
                #}
            ]
            restaurant_q = {
                "fields" : [],
                "filter" : {
                    "term" : { "city_id" : _region_group.city_id}
                },
                "from" : 0,
                "size" : random.randint(100000,500000),
            }
            restaurant_q = json.dumps(restaurant_q)
            result1 = _ess_search2('restaurant','restaurant',restaurant_q)
            result1 = result1['hits']
            city_restaurant_ids = [r['_id'] for r in result1]
            q['filter']['bool']['must'].append(
                {
                    'terms':{'restaurant_id':city_restaurant_ids}
                }
            )
            break
    if not is_ungroup:
        city_ids = struct.get('city_ids',[])
        region_group_ids = struct.get('region_group_ids',[])
        region_ids = struct.get('region_ids',[])
        if struct:
            regions = regions_from_struct(input_struct=struct,his_struct=current_user_struct)
        if not city_ids and not region_group_ids and not region_ids:
            regions = []
            for city in current_user_struct:
                for region_groups in city._region_groups:
                    for region in region_groups._regions:
                        regions.append(region)
        if regions:
            should = []
            for region in regions:
                points = region_area_to_es_points(region.area)
                if points:
                    should.append(
                        {
                            'geo_polygon':{
                                'eleme_order.location':{
                                    'points':region_area_to_es_points(region.area)
                                }
                            }
                        }
                    )
            q['filter']['bool']['should'] = should

    query = json.dumps(q)

    result = _ess_search2(index,doc_type,query)
    result = extract_ess_search_result(result)

    order_ids = [order['id'] for order in result['objects']]
    with thrift_client('eos') as eos:
        orders_info = eos.mget_order_info(order_ids)
        orders_info = getresult_to_raw(orders_info)
    orders_info = {info['order_id']:info for info in orders_info}
    for order in result['objects']:
        order.update(orders_info[order['id']])
    for order in result['objects']:
        if order['phone_rating'] == 1:
            order['is_new_user'] = True
        else:
            order['is_new_user'] = False
    with thrift_client('eus') as eus_client:
        chaos = eus_client.get_order_payment_constitution_map(order_ids)
    for order in result['objects']:
        payment_constituion = chaos.get(order['id'],[])
        order['payment_constituion'] = whatzfvcksay(payment_constituion,order['total'])
    restaurant_ids = list(set([o['restaurant_id'] for o in result['objects']]))
    restaurants = rst_base.get(restaurant_ids)
    for r in restaurants:
        r['_image_url'] = image_hash_to_url(r['image_hash'])
    restaurant_map = {r.id:r for r in restaurants}
    for order in result['objects']:
        order['_restaurant'] = restaurant_map[order['restaurant_id']]
    for _object in result['objects']:
        _object['order_id'] = unicode(_object['id'])
    with thrift_client('eyes') as eyes_client:
        suspicious_orders = eyes_client.walle_get_suspicious_order_detail(order_ids)
        suspicious_orders = getresult_to_raw(suspicious_orders)
        suspicious_orders_map = {order.id:order for order in suspicious_orders}
    for _object in result['objects']:
        suspicious = suspicious_orders_map.get(_object['id'],{})
        _object['_order_suspicious_reason'] = suspicious.get('reasons',[])
    return result
Example #14
0
def ess_search2(**args):
    def calc_index(query):
        return "order"

    doc_type = "eleme_order"
    query = args["query"]
    index = calc_index(query)
    q = json.loads(query)
    if "filter" not in q:
        q["filter"] = {}
    if "bool" not in q["filter"]:
        q["filter"]["bool"] = {}
    struct = args["struct"]
    struct = json.loads(struct)
    regions = []
    current_user_struct = get_struct(current_user.id)
    if not current_user_struct:
        return {"total": 0, "objects": []}

    # 处理未分组
    is_ungroup = False
    _region_groups_ids = struct.get("region_group_ids", [])
    with thrift_client("ers") as ers:
        _result = ers.mget_region_group(_region_groups_ids)
        _result = getresult_to_raw(_result)
    for _region_group in _result.values():
        if _region_group.name.find(u"未分组") >= 0:
            is_ungroup = True
            with thrift_client("ers") as ers:
                region_query = thirdparty_svc.ers.TRegionQuery()
                region_query.city_ids = [_region_group.city_id]
                regions = ers.query_region(region_query)
                regions = any_to_raw(regions)
                regions = getresult_to_raw(regions)
            should = []
            for region in regions:
                should.append(
                    {"geo_polygon": {"eleme_order.location": {"points": region_area_to_es_points(region.area)}}}
                )
            q["filter"]["bool"]["must_not"] = [
                # {'filter':{
                {
                    "bool": {
                        "should": should,
                        #'mininum_should_match':1,
                    }
                }
                # }
            ]
            restaurant_q = {
                "fields": [],
                "filter": {"term": {"city_id": _region_group.city_id}},
                "from": 0,
                "size": random.randint(100000, 500000),
            }
            restaurant_q = json.dumps(restaurant_q)
            result1 = _ess_search2("restaurant", "restaurant", restaurant_q)
            result1 = result1["hits"]
            city_restaurant_ids = [r["_id"] for r in result1]
            q["filter"]["bool"]["must"].append({"terms": {"restaurant_id": city_restaurant_ids}})
            break
    if not is_ungroup:
        city_ids = struct.get("city_ids", [])
        region_group_ids = struct.get("region_group_ids", [])
        region_ids = struct.get("region_ids", [])
        if struct:
            regions = regions_from_struct(input_struct=struct, his_struct=current_user_struct)
        if not city_ids and not region_group_ids and not region_ids:
            regions = []
            for city in current_user_struct:
                for region_groups in city._region_groups:
                    for region in region_groups._regions:
                        regions.append(region)
        if regions:
            should = []
            for region in regions:
                points = region_area_to_es_points(region.area)
                if points:
                    should.append(
                        {"geo_polygon": {"eleme_order.location": {"points": region_area_to_es_points(region.area)}}}
                    )
            q["filter"]["bool"]["should"] = should

    query = json.dumps(q)

    result = _ess_search2(index, doc_type, query)
    result = extract_ess_search_result(result)

    order_ids = [order["id"] for order in result["objects"]]
    with thrift_client("eos") as eos:
        orders_info = eos.mget_order_info(order_ids)
        orders_info = getresult_to_raw(orders_info)
    orders_info = {info["order_id"]: info for info in orders_info}
    for order in result["objects"]:
        order.update(orders_info[order["id"]])
    for order in result["objects"]:
        if order["phone_rating"] == 1:
            order["is_new_user"] = True
        else:
            order["is_new_user"] = False
    with thrift_client("eus") as eus_client:
        chaos = eus_client.get_order_payment_constitution_map(order_ids)
    for order in result["objects"]:
        payment_constituion = chaos.get(order["id"], [])
        order["payment_constituion"] = whatzfvcksay(payment_constituion, order["total"])
    restaurant_ids = list(set([o["restaurant_id"] for o in result["objects"]]))
    restaurants = rst_base.get(restaurant_ids)
    for r in restaurants:
        r["_image_url"] = image_hash_to_url(r["image_hash"])
    restaurant_map = {r.id: r for r in restaurants}
    for order in result["objects"]:
        order["_restaurant"] = restaurant_map[order["restaurant_id"]]
    for _object in result["objects"]:
        _object["order_id"] = unicode(_object["id"])
    with thrift_client("eyes") as eyes_client:
        suspicious_orders = eyes_client.walle_get_suspicious_order_detail(order_ids)
        suspicious_orders = getresult_to_raw(suspicious_orders)
        suspicious_orders_map = {order.id: order for order in suspicious_orders}
    for _object in result["objects"]:
        suspicious = suspicious_orders_map.get(_object["id"], {})
        _object["_order_suspicious_reason"] = suspicious.get("reasons", [])
    return result
Example #15
0
def query_suspicous():
    args_spec = {
        'start_datetime':
        Arg(unicode, default=arrow.now().replace(days=-1).__str__()),
        'end_datetime':
        Arg(unicode, default=arrow.now().__str__()),
        'restaurant_id':
        Arg(int),
        'offset':
        Arg(int, default=0),
        'limit':
        Arg(int, default=100),
    }
    args = args_parser.parse(args_spec)
    if not args['restaurant_id']:
        return {
            'total': 0,
            'objects': [],
        }
    client = pymongo.MongoClient(config.EYES_MONGO)
    collection = client.evileye.suspicious_order
    # db.tickets.find({"date":{$lt:ISODate("2013-01-17T01:16:33.303Z")}}).limit (5);
    start_datetime = args['start_datetime'].split('+')[0]
    end_datetime = args['end_datetime'].split('+')[0]

    start_datetime = arrow.get(start_datetime).to('local').datetime
    end_datetime = arrow.get(end_datetime).to('local').datetime
    restaurant_id = args['restaurant_id']
    offset = args['offset']
    limit = args['limit']
    query = {
        'created_at': {
            '$lte': end_datetime,
            '$gte': start_datetime
        },
    }
    if restaurant_id:
        query.update({'restaurant_id': restaurant_id})
    docs = collection.find(query)
    total = docs.count()
    result_docs = list(docs.limit(limit).skip(offset))
    time_fields = ['deliver_time', 'settled_at']
    with thrift_client('eos') as eos:
        for doc in result_docs:
            order_id = doc['_id']
            order = eos.get(int(order_id))
            order = getresult_to_raw(order)
            for k, v in order.items():
                doc.setdefault(k, v)
            doc['detail_json'] = json.loads(doc['detail_json'])
            doc['_order_id'] = doc['_id']
            for field in time_fields:
                new_value = arrow.get(doc[field]).__str__()
                doc[field] = new_value
            doc['phone'] = [doc['phone']]
            with thrift_client('eus') as eus_client:
                chaos = eus_client.get_order_payment_constitution_map(
                    [int(order_id)])
                payment_constituion = chaos.get(order['id'], [])
                doc['payment_constituion'] = order_query_helper.whatzfvcksay(
                    payment_constituion, doc['total'])
            doc['order_id'] = unicode(doc['_id'])
    order_ids = [doc['id'] for doc in result_docs]
    with thrift_client('eyes') as eyes_client:
        suspicious_orders = eyes_client.walle_get_suspicious_order_detail(
            order_ids)
        suspicious_orders = getresult_to_raw(suspicious_orders)
        suspicious_orders_map = {
            order.id: order
            for order in suspicious_orders
        }
    for _object in result_docs:
        suspicious = suspicious_orders_map.get(_object['id'], {})
        _object['_order_suspicious_reason'] = suspicious.get('reasons', [])
    restaurant_ids = list(set([o['restaurant_id'] for o in result_docs]))
    restaurants = rst_base.get(restaurant_ids)
    for r in restaurants:
        r['_image_url'] = image_hash_to_url(r['image_hash'])
    restaurant_map = {r.id: r for r in restaurants}
    for order in result_docs:
        order['_restaurant'] = restaurant_map[order['restaurant_id']]
    result = {
        'total': total,
        'objects': result_docs,
    }
    return result