Ejemplo n.º 1
0
    def new_roomtype_coops(self, merchant_id, hotel_id, roomtype_ids):
        hotel = CooperateHotelModel.get_by_id(self.db, hotel_id)
        if not hotel:
            raise JsonException(1000, 'hotel not found')
        if hotel.merchant_id != merchant_id:
            raise JsonException(2000, 'merchant not valid')


        coops = CooperateRoomTypeModel.get_by_merchant_hotel_base_rooms_id(self.db,
                merchant_id, hotel_id, roomtype_ids)
        if coops:
            raise JsonException(1000, 'room has cooped')

        coops = CooperateRoomTypeModel.new_roomtype_coops(self.db,
                merchant_id, hotel.id,  hotel.base_hotel_id, roomtype_ids, commit=False)

        for coop in coops:
            InventoryModel.insert_in_months(self.db,
                    merchant_id, hotel_id, coop.id, hotel.base_hotel_id, coop.base_roomtype_id, 13, commit=False)

        r = yield HotelPusher(self.db).push_hotel_by_id(hotel_id)
        if not r:
            raise JsonException(3000, 'push hotel to stock fail')

        for coop in coops:
            r = yield InventoryAsyncPusher(self.db).push_by_roomtype(coop)
            if not r:
                raise JsonException(3001, 'push inventory to stock fail')

            r = yield POIRoomTypePusher(self.db).push_roomtype(coop.id)
            if not r:
                raise JsonException(3001, 'push roomtype to poi fail')

        self.db.commit()
        raise gen.Return(coops)
Ejemplo n.º 2
0
def submit_order(self, order_json):
    Log.info(order_json)
    session = self.session
    try:
        submit_order = SubmitOrder(order_json)
    except ValueError as e:
        raise CeleryException(errcode=2000, errmsg=e.message)
    Log.info(submit_order)

    if not valid_arguments(submit_order):
        raise CeleryException(200, 'invalid_arguments')

    rate_plan = get_rateplan(session, submit_order)
    if not rate_plan:
        raise CeleryException(300, 'no rate plan')

    submit_order.pay_type = rate_plan.pay_type
    submit_order.merchant_id = rate_plan.merchant_id
    submit_order.cancel_type = rate_plan.cancel_type
    submit_order.punish_type = rate_plan.punish_type
    submit_order.punish_value = rate_plan.punish_value
    submit_order.guarantee_type = rate_plan.guarantee_type
    submit_order.guarantee_start_time = rate_plan.guarantee_start_time

    order = create_order(session, submit_order)
    if not order:
        raise CeleryException(session, 'create order fail')

    if order.status != 0:
        return order

    # valid is roomtype online
    roomtype = CooperateRoomTypeModel.get_by_id(self.session, order.roomtype_id)
    if roomtype.is_online != 1:
        Log.info('roomtype is not online')
        order.status = 200
        session.commit()

        OrderHistoryModel.set_order_status_by_server(session, order, 0, 200)
        return order


    # valid is inventory enough
    if not valid_inventory(session, submit_order):
        Log.info('more room please')
        order.status = 200
        session.commit()

        OrderHistoryModel.set_order_status_by_server(session, order, 0, 200)
        return order


    # second valid in spec queue
    task = start_order.apply_async(args=[order.id])
    result = task.get()
    if task.status == 'SUCCESS':
        send_order_sms.delay(result.merchant_id, result.hotel_name, result.id, result.confirm_type)
        return result
    else:
        raise result
Ejemplo n.º 3
0
    def push_inventory_by_merchant(self, merchant_id):
        from models.cooperate_roomtype import CooperateRoomTypeModel
        self.log.info(">> push inventories by merchant {}".format(merchant_id))
        roomtypes = CooperateRoomTypeModel.get_by_merchant_id(self.session, merchant_id)

        for roomtype in roomtypes:
            self.push_inventory(roomtype.id)
Ejemplo n.º 4
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],
        ))
Ejemplo n.º 5
0
    def pre_check_order(self, order_entity):

        order = self.create_order(order_entity)
        if not order:
            raise JsonException(1, 'create order fail')

        if order.status != 0:
            return order

        # valid is roomtype online
        roomtype = CooperateRoomTypeModel.get_by_id(self.db, order.roomtype_id)
        if roomtype.is_online != 1:
            Log.info('roomtype is not online')
            order.status = 200
            order.exception_info = 'roomtype is not online'
            self.db.commit()
            OrderHistoryModel.set_order_status_by_server(self.db, order, 0, 200)
            return order

        # valid is inventory enough
        if not self.valid_inventory(order_entity):
            Log.info('more room please')
            order.status = 200
            order.exception_info = 'inventory not enough'
            self.db.commit()

            OrderHistoryModel.set_order_status_by_server(self.db, order, 0, 200)
            return order

        return order
Ejemplo n.º 6
0
    def new_rate_plan(self, merchant_id, hotel_id, roomtype_id, name, meal_num, punish_type, ahead_days, stay_days, pay_type=None, guarantee_type=None, guarantee_start_time=None):
        room = CooperateRoomTypeModel.get_by_id(self.db, roomtype_id)
        if not room:
            raise JsonException(errcode=404, errmsg='room not exist')

        rate_plan = RatePlanModel.get_by_merchant_hotel_room_name(
            self.db, merchant_id, hotel_id, roomtype_id, name)
        if rate_plan:
            raise JsonException(errcode=405, errmsg="name exist")

        new_rateplan = RatePlanModel.new_rate_plan(self.db,
                                                   merchant_id, hotel_id, roomtype_id, room.base_hotel_id, room.base_roomtype_id,  name, meal_num, punish_type, ahead_days, stay_days, pay_type, guarantee_type, guarantee_start_time, commit=False)
        self.db.flush()
        new_roomrate = RoomRateModel.new_roomrate(
            self.db, hotel_id, roomtype_id, room.base_hotel_id, room.base_roomtype_id, new_rateplan.id, meal_num, commit=False)
        self.db.flush()

        rateplan_pusher = RatePlanPusher(self.db)
        roomrate_pusher = RoomRatePusher(self.db)
        try:
            if not (yield rateplan_pusher.post_rateplan(new_rateplan)):
                raise JsonException(2000, 'rateplan push fail')
            if not (yield rateplan_pusher.post_cancel_rule(new_rateplan)):
                raise JsonException(2001, 'cancel rule push fail')
            if not (yield roomrate_pusher.push_roomrate(new_rateplan.merchant_id, new_roomrate)):
                raise JsonException(2002, 'roomrate push fail')
            self.db.commit()

        except JsonException, e:
            self.db.rollback()
            raise e
Ejemplo n.º 7
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],
            ))
Ejemplo n.º 8
0
    def pre_check_order(self, order_entity):

        order = self.create_order(order_entity)
        if not order:
            raise JsonException(1, 'create order fail')

        if order.status != 0:
            return order

        # valid is roomtype online
        roomtype = CooperateRoomTypeModel.get_by_id(self.db, order.roomtype_id)
        if roomtype.is_online != 1:
            Log.info('roomtype is not online')
            order.status = 200
            order.exception_info = 'roomtype is not online'
            self.db.commit()
            OrderHistoryModel.set_order_status_by_server(
                self.db, order, 0, 200)
            return order

        # valid is inventory enough
        if not self.valid_inventory(order_entity):
            Log.info('more room please')
            order.status = 200
            order.exception_info = 'inventory not enough'
            self.db.commit()

            OrderHistoryModel.set_order_status_by_server(
                self.db, order, 0, 200)
            return order

        return order
Ejemplo n.º 9
0
def start_order(self, order_id):
    session = self.session
    order = get_order(session, order_id)
    if not order:
        Log.info("query order {} is None".format(order_id))
        return None
    if order.status != 0:
        return order

    # valid is roomtype online
    roomtype = CooperateRoomTypeModel.get_by_id(self.session,
                                                order.roomtype_id)
    if roomtype.is_online != 1:
        Log.info('roomtype is not online')
        order.status = 200
        order.exception_info = 'roomtype is not online'
        session.commit()
        OrderHistoryModel.set_order_status_by_server(session, order, 0, 200)
        return order

    order = modify_inventory(session, order)
    if order.status != 0:
        OrderHistoryModel.set_order_status_by_server(session, order, 0,
                                                     order.status)

    return order
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
    def push_inventory_by_merchant(self, merchant_id):
        from models.cooperate_roomtype import CooperateRoomTypeModel
        self.log.info(">> push inventories by merchant {}".format(merchant_id))
        roomtypes = CooperateRoomTypeModel.get_by_merchant_id(
            self.session, merchant_id)

        for roomtype in roomtypes:
            self.push_inventory(roomtype.id)
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
    def put(self):

        args = self.get_json_arguments()
        is_online, = get_and_valid_arguments(args, 'is_online')
        if is_online not in [0, 1]:
            raise JsonException(errmsg='wrong arg is_online', errcode=2001)

        CooperateRoomTypeModel.set_online_by_merchant(self.db, self.merchant.id, is_online, commit=False)
        self.db.flush()

        r = yield InventoryAsyncPusher(self.db).push_inventory_by_merchant(self.merchant.id)
        if r:
            self.db.commit()
            self.finish_json()
        else:
            self.db.rollback()
            yield InventoryAsyncPusher(self.db).push_inventory_by_merchant(self.merchant.id)
            raise JsonException(1000, "push stock error")
Ejemplo n.º 14
0
    def merge_roomtypes_online_count(self, hotels):
        hotel_ids = [hotel['id'] for hotel in hotels]
        roomtypes = CooperateRoomTypeModel.get_by_hotel_ids(self.db, hotel_ids)

        for hotel in hotels:
            rooms = [roomtype for roomtype in roomtypes if roomtype.hotel_id == hotel['id']]
            online_rooms = [room for room in rooms if room.is_online == 1]
            hotel['roomtype_count'] = len(rooms)
            hotel['online_roomtype_count'] = len(online_rooms)
Ejemplo n.º 15
0
    def push_inventory_by_merchant(self, merchant_id):
        Log.info(">> push inventories by merchant {}".format(merchant_id))
        roomtypes = CooperateRoomTypeModel.get_by_merchant_id(self.db, merchant_id)

        for roomtype in roomtypes:
            r = yield self.push_by_roomtype(roomtype)
            if not r:
                raise gen.Return(False)
        raise gen.Return(True)
Ejemplo n.º 16
0
    def merge_roomtypes_online_count(self, hotels):
        hotel_ids = [hotel['id'] for hotel in hotels]
        roomtypes = CooperateRoomTypeModel.get_by_hotel_ids(self.db, hotel_ids)

        for hotel in hotels:
            rooms = [roomtype for roomtype in roomtypes if roomtype.hotel_id == hotel['id']]
            online_rooms = [room for room in rooms if room.is_online == 1]
            hotel['roomtype_count'] = len(rooms)
            hotel['online_roomtype_count'] = len(online_rooms)
Ejemplo n.º 17
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
Ejemplo n.º 18
0
    def push_inventory_by_merchant(self, merchant_id):
        Log.info(">> push inventories by merchant {}".format(merchant_id))
        roomtypes = CooperateRoomTypeModel.get_by_merchant_id(
            self.db, merchant_id)

        for roomtype in roomtypes:
            r = yield self.push_by_roomtype(roomtype)
            if not r:
                raise gen.Return(False)
        raise gen.Return(True)
Ejemplo n.º 19
0
    def modify_cooped_roomtype(self, merchant_id, hotel_id, roomtype_id, prefix_name, remark_name):
        coop = CooperateRoomTypeModel.get_by_id(self.db, roomtype_id)
        if not coop:
            return JsonException(404, 'coop not found')
        if coop.merchant_id != merchant_id:
            return JsonException(1000, 'merchant not valid')

        coop.prefix_name = prefix_name
        coop.remark_name = remark_name
        self.db.commit()
        return coop
Ejemplo n.º 20
0
    def push_roomtype(self, roomtype_id):
        Log.info("<<POI push room mapping {}>> start".format(roomtype_id))

        room = CooperateRoomTypeModel.get_by_id(self.db, roomtype_id)
        if not room:
            Log.error("<<POI push room mapping {}>> no roomtype".format(roomtype_id))
            raise gen.Return(False)

        room_data = self.generate_data(room)
        r = yield self.post_room(room_data)
        raise gen.Return(r)
Ejemplo n.º 21
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)
Ejemplo n.º 22
0
    def push_roomtype(self, roomtype_id):
        Log.info("<<POI push room mapping {}>> start".format(roomtype_id))

        room = CooperateRoomTypeModel.get_by_id(self.db, roomtype_id)
        if not room:
            Log.error(
                "<<POI push room mapping {}>> no roomtype".format(roomtype_id))
            raise gen.Return(False)

        room_data = self.generate_data(room)
        r = yield self.post_room(room_data)
        raise gen.Return(r)
Ejemplo n.º 23
0
    def merge_roomtypes(self, hotels):
        cooped_rooms = CooperateRoomTypeModel.get_by_merchant_id(self.db, self.merchant.id)
        cooped_rooms_base_ids = [room.base_roomtype_id for room in cooped_rooms]

        for hotel in hotels:
            _rooms = []
            for roomtype in hotel['roomtypes']:
                if roomtype['id'] in cooped_rooms_base_ids:
                    _rooms.append(roomtype)
            hotel['roomtypes'] = _rooms

        return hotels
Ejemplo n.º 24
0
    def push_by_roomtype_id(self, roomtype_id):

        roomtype = CooperateRoomTypeModel.get_by_id(self.db, roomtype_id)
        if not roomtype:
            return True

        start_day = datetime.date.today()
        days = [start_day + datetime.timedelta(days=i) for i in xrange(90)]
        days = [(day.year, day.month) for day in days]
        days = {}.fromkeys(days).keys()

        inventories = InventoryModel.get_by_roomtype_and_dates(self.db, roomtype_id, days)
        return self.post_inventory(inventories, roomtype.is_online)
Ejemplo n.º 25
0
    def delete(self, hotel_id, roomtype_id):
        room = CooperateRoomTypeModel.get_by_merchant_hotel_and_id(self.db, self.merchant.id, hotel_id, roomtype_id)
        if not room:
            raise JsonException(1001, 'roomtype not found')

        r = yield self.delete_roomtype(room)
        if r:
            self.db.commit()
            self.finish_json(result=dict(
                roomtype=room.todict()))
        else:
            self.db.rollback()
            raise JsonException(2000, 'delete fail')
Ejemplo n.º 26
0
    def push_roomtype(self, roomtype_id):
        Log.info("<<POI push room mapping {}>> start".format(roomtype_id))
        if not IS_PUSH_TO_POI:
            return
        from models.cooperate_roomtype import CooperateRoomTypeModel

        room = CooperateRoomTypeModel.get_by_id(self.session, roomtype_id)
        if not room:
            Log.error("no roomtype")
            return

        room_data = self.generate_data(room)
        self.post_room(room_data)
Ejemplo n.º 27
0
    def push_roomtype(self, roomtype_id):
        Log.info("<<POI push room mapping {}>> start".format(roomtype_id))
        if not IS_PUSH_TO_POI:
            return
        from models.cooperate_roomtype import CooperateRoomTypeModel

        room = CooperateRoomTypeModel.get_by_id(self.session, roomtype_id)
        if not room:
            Log.error("no roomtype")
            return

        room_data = self.generate_data(room)
        self.post_room(room_data)
Ejemplo n.º 28
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
Ejemplo n.º 29
0
    def push_inventory(self, roomtype_id):
        self.log.info("<< push inventory (roomtype {})>>".format(roomtype_id))
        from models.inventory import InventoryModel
        from models.cooperate_roomtype import CooperateRoomTypeModel

        roomtype = CooperateRoomTypeModel.get_by_id(self.session, roomtype_id)

        start_day = datetime.date.today()
        days = [start_day + datetime.timedelta(days=i) for i in xrange(90)]
        days = [(day.year, day.month) for day in days]
        days = {}.fromkeys(days).keys()

        inventories = InventoryModel.get_by_roomtype_and_dates(self.session, roomtype_id, days)
        self.post_inventory(inventories, roomtype.is_online)
Ejemplo n.º 30
0
    def push_by_roomtype_id(self, roomtype_id):

        roomtype = CooperateRoomTypeModel.get_by_id(self.db, roomtype_id)
        if not roomtype:
            return True

        start_day = datetime.date.today()
        days = [start_day + datetime.timedelta(days=i) for i in xrange(90)]
        days = [(day.year, day.month) for day in days]
        days = {}.fromkeys(days).keys()

        inventories = InventoryModel.get_by_roomtype_and_dates(
            self.db, roomtype_id, days)
        return self.post_inventory(inventories, roomtype.is_online)
Ejemplo n.º 31
0
    def merge_roomtypes(self, hotels):
        cooped_rooms = CooperateRoomTypeModel.get_by_merchant_id(
            self.db, self.merchant.id)
        cooped_rooms_base_ids = [
            room.base_roomtype_id for room in cooped_rooms
        ]

        for hotel in hotels:
            _rooms = []
            for roomtype in hotel['roomtypes']:
                if roomtype['id'] in cooped_rooms_base_ids:
                    _rooms.append(roomtype)
            hotel['roomtypes'] = _rooms

        return hotels
Ejemplo n.º 32
0
    def push_inventory(self, roomtype_id):
        self.log.info("<< push inventory (roomtype {})>>".format(roomtype_id))
        from models.inventory import InventoryModel
        from models.cooperate_roomtype import CooperateRoomTypeModel

        roomtype = CooperateRoomTypeModel.get_by_id(self.session, roomtype_id)

        start_day = datetime.date.today()
        days = [start_day + datetime.timedelta(days=i) for i in xrange(90)]
        days = [(day.year, day.month) for day in days]
        days = {}.fromkeys(days).keys()

        inventories = InventoryModel.get_by_roomtype_and_dates(
            self.session, roomtype_id, days)
        self.post_inventory(inventories, roomtype.is_online)
Ejemplo n.º 33
0
    def put(self, hotel_id, roomtype_id):

        args = self.get_json_arguments()
        is_online, = get_and_valid_arguments(args, 'is_online')
        if is_online not in [0, 1]:
            raise JsonException(errmsg='wrong arg is_online', errcode=2001)

        roomtype =  CooperateRoomTypeModel.get_by_merchant_hotel_and_id(self.db, self.merchant.id, hotel_id, roomtype_id)
        if not roomtype:
            raise JsonException(errmsg='roomtype not found', errcode=2002)

        roomtype.is_online = is_online
        self.db.flush()

        r = yield InventoryAsyncPusher(self.db).push_by_roomtype(roomtype)
        if r:
            self.db.commit()
            self.finish_json(result=dict(
                roomtype = roomtype.todict(),
                ))
        else:
            self.db.rollback()
            raise JsonException(1000, 'push stock fail')
Ejemplo n.º 34
0
def start_order(self, order_id):
    session = self.session
    order = get_order(session, order_id)
    if not order:
        Log.info("query order {} is None".format(order_id))
        return None
    if order.status != 0:
        return order

    # valid is roomtype online
    roomtype = CooperateRoomTypeModel.get_by_id(self.session, order.roomtype_id)
    if roomtype.is_online != 1:
        Log.info('roomtype is not online')
        order.status = 200
        order.exception_info = 'roomtype is not online'
        session.commit()
        OrderHistoryModel.set_order_status_by_server(session, order, 0, 200)
        return order

    order = modify_inventory(session, order)
    if order.status != 0:
        OrderHistoryModel.set_order_status_by_server(session, order, 0, order.status)

    return order
Ejemplo n.º 35
0
def complete_in_four_months(self):
    roomtypes = CooperateRoomTypeModel.get_all(self.session)
    InventoryModel.insert_all_in_months(self.session, roomtypes, 13)
Ejemplo n.º 36
0
 def push_by_roomtype_id(self, roomtype_id):
     roomtype = CooperateRoomTypeModel.get_by_id(self.db, roomtype_id)
     r = yield self.push_by_roomtype(roomtype)
     raise gen.Return(r)
Ejemplo n.º 37
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)
Ejemplo n.º 38
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)
Ejemplo n.º 39
0
def complete_in_four_months(self):
    roomtypes = CooperateRoomTypeModel.get_all(self.session)
    InventoryModel.insert_all_in_months(self.session, roomtypes, 13)
Ejemplo n.º 40
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)
Ejemplo n.º 41
0
 def get_cooped_rooms(self, hotel_id):
     coops = CooperateRoomTypeModel.get_by_hotel_id(self.db, hotel_id)
     return coops
Ejemplo n.º 42
0
 def push_by_roomtype_id(self, roomtype_id):
     roomtype = CooperateRoomTypeModel.get_by_id(self.db, roomtype_id)
     r = yield self.push_by_roomtype(roomtype)
     raise gen.Return(r)