Esempio n. 1
0
    def get_active_configs(self,cr,uid,room_type_id,context=None):
        """
        获取当前有效的钟点费打折设置信息
        :params room_type_id integer 包厢类别id M
        :params context['price_class_id'] integer 价格类别id O
        :params context['member_class_id'] integer 会员类别id O
        :return array 有效的钟点费打折信息数组
        """
        ret = []
        #1 获取所有钟点费打折信息,并逐个进行判断
        domain = [["room_type_id","=",room_type_id]]
        price_class_id = context and "price_class_id" in context and context['price_class_id']
        if price_class_id:
            domain.append(["price_class_id","=",price_class_id])
        member_class_id = context and "member_class_id" in context and context['member_class_id']
        if member_class_id:
            domain.append(["member_class_id","=",member_class_id])

        ids = self.search(cr,uid,domain)
        configs = self.browse(cr,uid,ids)
        #2 判断当日设置是否启用
        context_now = ktv_helper.user_context_now(self,cr,uid)
        #判断是周几
        weekday_str = ktv_helper.weekday_str(context_now.weekday())
        now_str = datetime.now().strftime("%H:%M:00")
        #判断特殊日设置
        which_fee =  context and 'which_fee' in context and context['which_fee'] or "hourly_fee_discount"
        osv_name = "ktv.%s_special_day" % which_fee
        s_day_ids = self.pool.get(osv_name).search(cr,uid,[("room_type_id",'=',room_type_id)])
        s_days = self.pool.get(osv_name).read(cr,uid,s_day_ids,['room_type_id','special_day'])
        s_days_list = [s_day['special_day'] for s_day in s_days]

        #如果当日是特殊日,则直接返回所有买断设置
        in_sp_day = datetime.today() in s_days_list
        #根据设置的星期是否有效来得到返回的设置
        for c in configs:
            in_time_range = ktv_helper.utc_time_between(c.time_from,c.time_to,now_str)
            #是否忽略时间段判断,用于显示全天的钟点费打折信息
            ignore_time_range = context and 'ignore_time_range' in context and context['ignore_time_range']
            if ignore_time_range:
                in_time_range = True
            if  (in_sp_day and in_time_range) or in_time_range:
                hourly_fee = getattr(c,weekday_str + "_hourly_fee",0.0)
                hourly_discount = getattr(c,weekday_str + "_hourly_discount",0.0)
                if in_sp_day:
                    hourly_fee = getattr(c,"special_day_hourly_fee")
                    hourly_discount = getattr(c,"special_day_hourly_discount")

                ret.append({
                    "id" : c.id,
                    "price_class_id" : c.price_class_id.id,
                    "room_type_id" : c.room_type_id.id,
                    "time_from" : c.time_from,
                    "time_to" : c.time_to,
                    "hourly_fee" : hourly_fee,
                    "hourly_discount" : hourly_discount,
                    })
        return ret
Esempio n. 2
0
    def get_active_configs(self,cr,uid,room_type_id):
        '''
        获取当前有效的买断设置信息
        :params integer room_type_id 包厢类型id
        :return array 符合条件的买断信息数组
        '''
        ret = []
        #1 获取所有买断信息,并逐个进行判断
        ids = self.search(cr,uid,[("room_type_id",'=',room_type_id)])
        configs = self.browse(cr,uid,ids)
        #2 判断当日买断是否启用
        context_now = ktv_helper.user_context_now(self,cr,uid)
        #判断是周几
        weekday_str = ktv_helper.weekday_str(context_now.weekday())
        #判断特殊日设置
        s_day_ids = self.pool.get('ktv.buffet_config_special_day').search(cr,uid,[("room_type_id",'=',room_type_id)])
        s_days = self.pool.get('ktv.buffet_config_special_day').read(cr,uid,s_day_ids,['room_type_id','special_day'])
        s_days_list = [s_day['special_day'] for s_day in s_days]

        #买断起止时间
        #time_from 当前时间
        #time_to 买断结束时间
        #如果当日是特殊日,则直接返回所有买断设置
        in_sp_day = datetime.today() in s_days_list
        #根据设置的星期是否有效来得到返回的设置
        for c in configs:
            buyout_enable = getattr(c,weekday_str + '_buyout_enable',False)
            in_time_range = ktv_helper.utc_time_between(c.time_from,c.time_to,datetime.now())
            time_from = datetime.now()
            time_to = ktv_helper.float_time_to_datetime(c.time_to)
            #判断时间设置是否跨天
            if time_to < time_from:
                time_to = time_to + timedelta(days = 1)

            if  (in_sp_day and in_time_range) or (buyout_enable and in_time_range):
                buyout_fee = getattr(c,weekday_str + "_buyout_fee",0.0)
                child_buyout_fee = getattr(c,weekday_str + "_child_buyout_fee",0.0)
                if in_sp_day:
                    buyout_fee = getattr(c,"special_day_buyout_fee")
                    child_buyout_fee = getattr(c,"special_day_child_buyout_fee")
                ret.append({
                    "id" : c.id,
                    "room_type_id" : c.room_type_id.id,
                    "name" : getattr(c,"name"),
                    #起始时间是当前时间
                    "time_from" : time_from.strftime('%Y-%m-%d %H:%M:%S'),
                    "time_to" : time_to.strftime('%Y-%m-%d %H:%M:%S'),
                    "is_member" : getattr(c,'is_member'),
                    "buyout_fee" : buyout_fee,
                    "child_buyout_fee" : buyout_fee,
                    #计算实际买断分钟数量
                    "buyout_time" : ktv_helper.float_time_minutes_delta(c.time_from,c.time_to),
                    })
        return ret
Esempio n. 3
0
    def get_active_configs(self, cr, uid, room_type_id):
        """
        获取当前设定的包厢类别可用的低消设置信息
        params: room_type_id integer 包厢类别id
        return: array 符合条件的低消设置信息
        """
        ret = []
        #1 获取所有买断信息,并逐个进行判断
        ids = self.search(cr, uid, [("room_type_id", '=', room_type_id)])
        configs = self.browse(cr, uid, ids)
        #2 判断当日买断是否启用
        context_now = ktv_helper.user_context_now(self, cr, uid)
        #判断是周几
        weekday_str = ktv_helper.weekday_str(context_now.weekday())
        now_str = datetime.now().strftime("%H:%M:00")
        #判断特殊日设置
        s_day_ids = self.pool.get('ktv.minimum_fee_config_special_day').search(
            cr, uid, [("room_type_id", '=', room_type_id)])
        s_days = self.pool.get('ktv.minimum_fee_config_special_day').read(
            cr, uid, s_day_ids, ['room_type_id', 'special_day'])
        s_days_list = [s_day['special_day'] for s_day in s_days]

        #如果当日是特殊日,则直接返回所有买断设置
        in_sp_day = datetime.today() in s_days_list
        #根据设置的星期是否有效来得到返回的设置
        for c in configs:
            in_time_range = ktv_helper.utc_time_between(
                c.time_from, c.time_to, now_str)
            if (in_sp_day and in_time_range) or in_time_range:
                room_fee = getattr(c, weekday_str + "_room_fee", 0.0)
                minimum_fee = getattr(c, weekday_str + "_minimum_fee", 0.0)
                minimum_fee_p = getattr(c, weekday_str + "_minimum_fee_p", 0.0)
                if in_sp_day:
                    room_fee = getattr(c, "special_day_room_fee", 0.0)
                    minimum_fee = getattr(c, "special_day_minimum_fee", 0.0)
                    minimum_fee_p = getattr(c, "special_day_minimum_fee_p",
                                            0.0)
                ret.append({
                    "id": c.id,
                    "room_type_id": c.room_type_id.id,
                    "room_fee": room_fee,
                    "minimum_fee": minimum_fee,
                    "minimum_fee_p": minimum_fee_p,
                })
        return ret
Esempio n. 4
0
    def get_active_configs(self,cr,uid):
        """
        获取当前有效的买钟优惠设置信息
        """
        #默认情况下,所有设置都起效
        ret = []
        ids = self.search(cr,uid,[])
        configs = self.browse(cr,uid,ids)

        context_now = ktv_helper.user_context_now(self,cr,uid)
        #判断是周几
        weekday_str = ktv_helper.weekday_str(context_now.weekday())
        datetime_now_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        for c in configs:
            json_c = {
                    "id": c.id,
                    "name" : c.name,
                    "is_member" : c.is_member,
                    "buy_minutes": c.buy_minutes,
                    "present_minutes": c.present_minutes,
                    "active_datetime_limit" : c.active_datetime_limit,
                    "datetime_from" : c.datetime_from,
                    "datetime_to" : c.datetime_to,
                    "active_time_limit": c.active_time_limit,
                    "time_from": c.time_from,
                    "time_to": c.time_to,

                    }
            #判断是否在日期区间内
            if c.active_datetime_limit and not (datetime_now_str >= c.datetime_from and datetime_now_str <= c.datetime_to):
                json_c = None
            #判断是否在时间区间内
            if c.active_time_limit and ktv_helper.utc_time_between(c.time_from,c.time_to,datetime.now()):
                json_c = None
            #判断是否启用了星期设置
            if c.mon_active or c.tue_active or c.wed_active or c.thu_active or c.fri_active or c.sat_active or c.sun_active:
                if not getattr(c,"%s_active" % weekday_str):
                    json_c = None

            if json_c:
                ret.append(json_c)

        return ret
    def get_active_configs(self,cr,uid,room_type_id):
        """
        获取当前设定的包厢类别可用的低消设置信息
        params: room_type_id integer 包厢类别id
        return: array 符合条件的低消设置信息
        """
        ret = []
        #1 获取所有买断信息,并逐个进行判断
        ids = self.search(cr,uid,[("room_type_id",'=',room_type_id)])
        configs = self.browse(cr,uid,ids)
        #2 判断当日买断是否启用
        context_now = ktv_helper.user_context_now(self,cr,uid)
        #判断是周几
        weekday_str = ktv_helper.weekday_str(context_now.weekday())
        now_str = datetime.now().strftime("%H:%M:00")
        #判断特殊日设置
        s_day_ids = self.pool.get('ktv.minimum_fee_config_special_day').search(cr,uid,[("room_type_id",'=',room_type_id)])
        s_days = self.pool.get('ktv.minimum_fee_config_special_day').read(cr,uid,s_day_ids,['room_type_id','special_day'])
        s_days_list = [s_day['special_day'] for s_day in s_days]

        #如果当日是特殊日,则直接返回所有买断设置
        in_sp_day = datetime.today() in s_days_list
        #根据设置的星期是否有效来得到返回的设置
        for c in configs:
            in_time_range = ktv_helper.utc_time_between(c.time_from,c.time_to,now_str)
            if  (in_sp_day and in_time_range) or in_time_range:
                room_fee = getattr(c,weekday_str + "_room_fee",0.0)
                minimum_fee = getattr(c,weekday_str + "_minimum_fee",0.0)
                minimum_fee_p = getattr(c,weekday_str + "_minimum_fee_p",0.0)
                if in_sp_day:
                    room_fee = getattr(c,"special_day_room_fee",0.0)
                    minimum_fee = getattr(c,"special_day_minimum_fee",0.0)
                    minimum_fee_p = getattr(c,"special_day_minimum_fee_p",0.0)
                ret.append({
                    "id" : c.id,
                    "room_type_id" : c.room_type_id.id,
                    "room_fee" : room_fee,
                    "minimum_fee" : minimum_fee,
                    "minimum_fee_p" : minimum_fee_p,
                    })
        return ret
Esempio n. 6
0
    def get_active_configs(self, cr, uid, room_type_id):
        '''
        获取当前有效的买断设置信息
        :params integer room_type_id 包厢类型id
        :params integer buyout_config_id 买断设置id
        :return array 符合条件的买断信息数组
        '''
        ret = []
        #1 获取所有买断信息,并逐个进行判断
        ids = self.search(cr, uid, [("room_type_id", '=', room_type_id)])
        configs = self.browse(cr, uid, ids)
        #2 判断当日买断是否启用
        context_now = ktv_helper.user_context_now(self, cr, uid)
        #判断是周几
        weekday_str = ktv_helper.weekday_str(context_now.weekday())
        now_str = datetime.now().strftime("%H:%M:00")
        #判断特殊日设置
        s_day_ids = self.pool.get('ktv.buyout_config_special_day').search(
            cr, uid, [("room_type_id", '=', room_type_id)])
        s_days = self.pool.get('ktv.buyout_config_special_day').read(
            cr, uid, s_day_ids, ['room_type_id', 'special_day'])
        s_days_list = [s_day['special_day'] for s_day in s_days]

        #买断起止时间
        #time_from 当前时间
        #time_to 买断结束时间
        #如果当日是特殊日,则直接返回所有买断设置
        in_sp_day = datetime.today() in s_days_list
        #根据设置的星期是否有效来得到返回的设置
        for c in configs:
            buyout_enable = getattr(c, weekday_str + '_buyout_enable', False)
            in_time_range = ktv_helper.utc_time_between(
                c.time_from, c.time_to, now_str)
            time_from = datetime.now()
            time_to = ktv_helper.str_to_today_time(c.time_to)

            if (in_sp_day and in_time_range) or (buyout_enable
                                                 and in_time_range):
                buyout_fee = getattr(c, weekday_str + "_buyout_fee", 0.0)
                if in_sp_day:
                    buyout_fee = getattr(c, "special_day_buyout_fee")
                ret.append({
                    "id":
                    c.id,
                    "room_type_id":
                    c.room_type_id.id,
                    "name":
                    getattr(c, "name"),
                    #起始时间是当前时间
                    "time_from":
                    time_from.strftime('%Y-%m-%d %H:%M:%S'),
                    "time_to":
                    time_to.strftime('%Y-%m-%d %H:%M:%S'),
                    "is_member":
                    getattr(c, 'is_member'),
                    "buyout_fee":
                    buyout_fee,
                    #计算实际买断分钟数量
                    "buyout_time": (time_to.hour - time_from.hour) * 60 +
                    (time_to.minute - time_from.minute)
                })
        return ret