예제 #1
0
파일: audit.py 프로젝트: liuzelei/walis
 def filter_suspicious_orders_amount(cls, auditor_id, status, date,
                                     **kwargs):
     query_kwargs = {
         'auditor_id': auditor_id,
         'status': status,
         'date': date,
     }
     result = zeus_query('eyes', 'walle_filter_suspicious_orders_amount',
                         thirdparty_svc.eyes.TWalleSuspiciousOrderAmountQuery,
                         **query_kwargs)
     # temp fix-.-
     result = json.loads(result)
     return result
예제 #2
0
 def filter_suspicious_orders_amount(cls, auditor_id, status, date,
                                     **kwargs):
     query_kwargs = {
         'auditor_id': auditor_id,
         'status': status,
         'date': date,
     }
     result = zeus_query(
         'eyes', 'walle_filter_suspicious_orders_amount',
         thirdparty_svc.eyes.TWalleSuspiciousOrderAmountQuery,
         **query_kwargs)
     # temp fix-.-
     result = json.loads(result)
     return result
예제 #3
0
파일: audit.py 프로젝트: liuzelei/walis
 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
예제 #4
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
예제 #5
0
    def get(self, pk=None):
        result = None
        with thrift_client('eus') as eus:
            if pk is None:
                # 2 是客服人员-.-
                all_permissions = current_user.has_permissions(
                    'walle_all_user_manage', True)
                parial_permissions = current_user.has_permissions(
                    'walle_partial_user_manage', True)
                user_ids = None
                if not all_permissions:
                    user_ids = eus.get_managed_user_ids(current_user.id)
                    if parial_permissions and len(user_ids):
                        pass
                    else:
                        user_ids = [current_user.id]
                query_kwargs = {
                    'limit': 1000,
                    'offset': 0,
                    'keyword': None,
                    'is_active': None,
                    'is_super_admin': None,
                    'group_ids': None,
                    'category': 2,
                    'mobile': None,
                    'email': None,
                    'name': None,
                    'region_ids': None,
                    'region_group_ids': None,
                    'city_ids': None,
                    'user_ids': user_ids,
                }
                _result = zeus_query('eus', 'walle_get_user_list',
                                     thirdparty_svc.eus.TUserQuery,
                                     **query_kwargs)
                _result = json.loads(_result)
                users = _result['list']

                dop_users = eus.mget_dop_user([user['id'] for user in users])

                # dop_users = eus.mget_dop_user(range(0,500))
                dop_users = any_to_raw(dop_users)

                # user_ids = [dop_user['user_id'] for dop_user in dop_users]
                # _result = zeus_query('eus','walle_get_user_list',eus_thrift.TUserQuery,user_ids=user_ids)
                # _result = json.loads(_result)
                # users = _result['list']

                user_id_name_map = {
                    user['id']: user['username']
                    for user in users
                }
                for dop_user in dop_users:
                    dop_user['username'] = user_id_name_map[
                        dop_user['user_id']]
                result = dop_users
                # mongo update allow_order_audit
                _dop_users = mongo.dop_user.find()
                _dop_users_map = {doc['user_id']: doc for doc in _dop_users}
                for dop_user in dop_users:
                    _dop_user = _dop_users_map.get(dop_user['user_id'], {})
                    dop_user['allow_order_audit'] = _dop_user.get(
                        'allow_order_audit', False)
        return result
예제 #6
0
파일: audit.py 프로젝트: liuzelei/walis
    def get(self, pk=None):
        result = None
        with thrift_client('eus') as eus:
            if pk is None:
                # 2 是客服人员-.-
                all_permissions = current_user.has_permissions(
                    'walle_all_user_manage', True)
                parial_permissions = current_user.has_permissions(
                    'walle_partial_user_manage', True)
                user_ids = None
                if not all_permissions:
                    user_ids = eus.get_managed_user_ids(current_user.id)
                    if parial_permissions and len(user_ids):
                        pass
                    else:
                        user_ids = [current_user.id]
                query_kwargs = {
                    'limit': 1000,
                    'offset': 0,
                    'keyword': None,

                    'is_active': None,
                    'is_super_admin': None,
                    'group_ids': None,
                    'category': 2,
                    'mobile': None,
                    'email': None,
                    'name': None,

                    'region_ids': None,
                    'region_group_ids': None,
                    'city_ids': None,
                    'user_ids': user_ids,
                }
                _result = zeus_query('eus', 'walle_get_user_list',
                                     thirdparty_svc.eus.TUserQuery, **query_kwargs)
                _result = json.loads(_result)
                users = _result['list']

                dop_users = eus.mget_dop_user([user['id'] for user in users])

                # dop_users = eus.mget_dop_user(range(0,500))
                dop_users = any_to_raw(dop_users)

                # user_ids = [dop_user['user_id'] for dop_user in dop_users]
                # _result = zeus_query('eus','walle_get_user_list',eus_thrift.TUserQuery,user_ids=user_ids)
                # _result = json.loads(_result)
                # users = _result['list']

                user_id_name_map = {user['id']: user['username'] for user in
                                    users}
                for dop_user in dop_users:
                    dop_user['username'] = user_id_name_map[dop_user['user_id']]
                result = dop_users
                # mongo update allow_order_audit
                _dop_users = mongo.dop_user.find()
                _dop_users_map = {doc['user_id']: doc for doc in _dop_users}
                for dop_user in dop_users:
                    _dop_user = _dop_users_map.get(dop_user['user_id'], {})
                    dop_user['allow_order_audit'] = _dop_user.get(
                        'allow_order_audit', False)
        return result