예제 #1
0
    def get(self, merchant_id, hotel_id):

        hotel = CooperateHotelModel.get_by_id(self.db, hotel_id)
        if not hotel:
            raise JsonException(4001, 'hotel not found')

        contract_hotel = ContractHotelModel.get_by_hotel(self.db, hotel_id)
        if not contract_hotel:
            contract_hotel = ContractHotelModel.new(
                self.db,
                merchant_id=merchant_id,
                hotel_id=hotel_id,
                base_hotel_id=hotel.base_hotel_id,
                weekend="5,6")

        roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.db, hotel_id)
        contract_roomtypes = ContractRoomTypeModel.get_by_hotel(
            self.db, hotel_id)

        hotel_dict = hotel.todict()
        roomtype_dicts = [room.todict() for room in roomtypes]
        yield self.merge_base_info(hotel_dict, roomtype_dicts)

        self.finish_json(result=dict(
            hotel=hotel_dict,
            roomtypes=roomtype_dicts,
            contract_hotel=contract_hotel.todict() if contract_hotel else {},
            contract_roomtypes=[c.todict() for c in contract_roomtypes],
        ))
예제 #2
0
    def get(self, merchant_id, hotel_id):

        hotel = CooperateHotelModel.get_by_id(self.db, hotel_id)
        if not hotel:
            raise JsonException(4001, 'hotel not found')


        contract_hotel = ContractHotelModel.get_by_hotel(self.db, hotel_id)
        if not contract_hotel:
            contract_hotel = ContractHotelModel.new(self.db, merchant_id=merchant_id, hotel_id=hotel_id, base_hotel_id=hotel.base_hotel_id, weekend="5,6")

        roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.db, hotel_id)
        contract_roomtypes = ContractRoomTypeModel.get_by_hotel(self.db, hotel_id)


        hotel_dict = hotel.todict()
        roomtype_dicts = [room.todict() for room in roomtypes]
        yield self.merge_base_info(hotel_dict, roomtype_dicts)

        self.finish_json(result=dict(
            hotel=hotel_dict,
            roomtypes=roomtype_dicts,
            contract_hotel=contract_hotel.todict() if contract_hotel else {},
            contract_roomtypes = [c.todict() for c in contract_roomtypes],
            ))
예제 #3
0
 def push_room_by_hotel(self, merchant, hotel):
     from models.cooperate_roomtype import CooperateRoomTypeModel
     roomtypes = CooperateRoomTypeModel.get_by_hotel_id(
         self.session, hotel.id)
     room_datas = [
         self.generate_room_data(roomtype) for roomtype in roomtypes
     ]
     self.post_room(room_datas)
예제 #4
0
    def get_hotel_data(self, hotel):
        roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.db, hotel.id, with_delete=True)
        base_hotel, base_roomtypes = yield self.fetch_base_hotel_and_roomtypes(hotel.base_hotel_id)
        if not base_hotel:
            raise gen.Return(None)

        hotel_data = self.generate_hotel_data(hotel, roomtypes, base_hotel, base_roomtypes)
        raise gen.Return(hotel_data)
예제 #5
0
    def get_hotel_data(self, hotel):
        from models.cooperate_roomtype import CooperateRoomTypeModel
        roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.session, hotel.id, with_delete=True)
        base_hotel, base_roomtypes = self.fetch_base_hotel_and_roomtypes(hotel.base_hotel_id)
        if not base_hotel:
            return

        hotel_data = self.generate_hotel_data(hotel, roomtypes, base_hotel, base_roomtypes)
        return hotel_data
예제 #6
0
    def get_hotel_data(self, hotel):
        roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.db,
                                                           hotel.id,
                                                           with_delete=True)
        base_hotel, base_roomtypes = yield self.fetch_base_hotel_and_roomtypes(
            hotel.base_hotel_id)
        if not base_hotel:
            raise gen.Return(None)

        hotel_data = self.generate_hotel_data(hotel, roomtypes, base_hotel,
                                              base_roomtypes)
        raise gen.Return(hotel_data)
예제 #7
0
파일: stock.py 프로젝트: Hackforid/Ebooking
    def get_hotel_data(self, hotel):
        from models.cooperate_roomtype import CooperateRoomTypeModel
        roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.session,
                                                           hotel.id,
                                                           with_delete=True)
        base_hotel, base_roomtypes = self.fetch_base_hotel_and_roomtypes(
            hotel.base_hotel_id)
        if not base_hotel:
            return

        hotel_data = self.generate_hotel_data(hotel, roomtypes, base_hotel,
                                              base_roomtypes)
        return hotel_data
예제 #8
0
 def get_cooped_rooms(self, hotel_id):
     coops = CooperateRoomTypeModel.get_by_hotel_id(self.db, hotel_id)
     return coops
예제 #9
0
 def _delete_roomtypes_by_hotel(self, hotel):
     roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.db, hotel.id)
     r = yield self._delete_roomtypes(roomtypes, notify_stock=False)
     raise gen.Return(r)
예제 #10
0
 def _delete_roomtypes_by_hotel(self, hotel):
     roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.db, hotel.id)
     r = yield self._delete_roomtypes(roomtypes, notify_stock=False)
     raise gen.Return(r)
예제 #11
0
파일: poi.py 프로젝트: icyCloud/test_e_b_k
 def push_room_by_hotel(self, merchant, hotel):
     from models.cooperate_roomtype import CooperateRoomTypeModel
     roomtypes = CooperateRoomTypeModel.get_by_hotel_id(self.session, hotel.id)
     room_datas = [self.generate_room_data(roomtype) for roomtype in roomtypes]
     self.post_room(room_datas)