Пример #1
0
def restaurant_activity(restaurant_id):
    """
    获取餐厅活动
    """
    restaurant_id = int(restaurant_id)
    TRestaurantActivity = thirdparty_svc.ers.TRestaurantActivity
    with thrift_client('ers') as ers:
        zeus_result = ers.javis_query_restaurant_activity_by_restaurant(
            restaurant_id)
        result = {}
        for activity in zeus_result:
            activity_type_value = activity.type
            if activity_type_value in RestaurantActivityConstType._v2n.keys():
                result[activity_type_value] = activity
        for activity_type_value in RestaurantActivityConstType._v2n.keys():
            result.setdefault(activity_type_value, TRestaurantActivity())
        for type_name, type_value in RestaurantActivityConstType._n2v.iteritems(
        ):
            status = ers.get_restaurant_activity_status(
                restaurant_id, type_value)
            setattr(result[type_value], '_status', status)
            activity = result[type_value]
            activity_id = activity.id
            amount = rst_act_base.get_amount(restaurant_id, activity_id)
            setattr(activity, '_amount', amount)
        return result
Пример #2
0
def participatable_restaurant_activity(restaurant_id):
    """
    获取可参加的餐厅活动
    返回值为活动+补贴的组合-.-
    """
    restaurant_id = int(restaurant_id)
    result = {}
    with thrift_client('ers') as ers:
        for type_name,type_value in RestaurantActivityConstType._n2v.iteritems():
            zeus_result = ers.get_participatable_restaurant_activity_ids(restaurant_id,type_value)
            zeus_result = [rst_act_base.get(_id) for _id in zeus_result]
            result[type_value] = zeus_result
        for type_name,type_value in RestaurantActivityConstType._n2v.iteritems():
            for activity in result[type_value]:
                activity_id = activity.id
                amount = rst_act_base.get_amount(restaurant_id,activity_id)
                setattr(activity,'_amount',amount)
    return result
Пример #3
0
def participatable_restaurant_activity(restaurant_id):
    """
    获取可参加的餐厅活动
    返回值为活动+补贴的组合-.-
    """
    restaurant_id = int(restaurant_id)
    result = {}
    with thrift_client('ers') as ers:
        for type_name, type_value in RestaurantActivityConstType._n2v.iteritems(
        ):
            zeus_result = ers.get_participatable_restaurant_activity_ids(
                restaurant_id, type_value)
            zeus_result = [rst_act_base.get(_id) for _id in zeus_result]
            result[type_value] = zeus_result
        for type_name, type_value in RestaurantActivityConstType._n2v.iteritems(
        ):
            for activity in result[type_value]:
                activity_id = activity.id
                amount = rst_act_base.get_amount(restaurant_id, activity_id)
                setattr(activity, '_amount', amount)
    return result
Пример #4
0
def restaurant_activity(restaurant_id):
    """
    获取餐厅活动
    """
    restaurant_id = int(restaurant_id)
    TRestaurantActivity = thirdparty_svc.ers.TRestaurantActivity
    with thrift_client('ers') as ers:
        zeus_result = ers.javis_query_restaurant_activity_by_restaurant(restaurant_id)
        result = {}
        for activity in zeus_result:
            activity_type_value = activity.type
            if activity_type_value in RestaurantActivityConstType._v2n.keys():
                result[activity_type_value] = activity
        for activity_type_value in RestaurantActivityConstType._v2n.keys():
            result.setdefault(activity_type_value,TRestaurantActivity())
        for type_name,type_value in RestaurantActivityConstType._n2v.iteritems():
            status = ers.get_restaurant_activity_status(restaurant_id,type_value)
            setattr(result[type_value],'_status',status)
            activity = result[type_value]
            activity_id = activity.id
            amount = rst_act_base.get_amount(restaurant_id,activity_id)
            setattr(activity,'_amount',amount)
        return result