def open_flash_sale(): now = datetime.now() now_date = get_now_part('%Y-%m-%d') config_obj = configs.find_one({'type_num': CONFIG_TYPE_FLASH_SALE}) if not config_obj: config_obj = {'hour_list': []} hour_list = config_obj['hour_list'] if filter(lambda x: x == now.hour, hour_list): flash_sale.update_many( { 'date': now_date, 'hour': now.hour, 'status': 0 }, {'$set': { 'status': 1 }}) end_time = now - timedelta(hours=1) if end_time.hour == 23: now_date = now_date - timedelta(days=1) flash_sale.update_many({ 'date': now_date, 'hour': end_time.hour }, {'$set': { 'status': 2 }})
def configs_info_processor(config_obj): level_id = config_obj['level_id'] level_obj = configs.find_one({ '_id': level_id, 'type_num': CONFIG_TYPE_USER_LEVEL }) config_obj['level_name'] = level_obj['name'] config_obj['level'] = level_obj['level'] return config_obj
def carousel_info_processor(carousel_obj): carousel_obj['genre_name'] = model.genre_values.get(carousel_obj['genre']) carousel_obj['status_name'] = model.status_values.get(carousel_obj['status']) route_id = carousel_obj.get('route_id', '') route_name = u'无' if route_id: route_obj = configs.find_one({'_id': route_id, 'type_num': CONFIG_TYPE_APP_ROUTE}) route_name = route_obj['name'] carousel_obj['route_name'] = route_name return carousel_obj
def get_top_task_detail(): detail_obj = configs.find_one({'type_num': CONFIG_TYPE_TOP_TASK}) if not detail_obj: return model.top_default_values return detail_obj
def get_detail_obj(self, _id): detail_obj = configs.find_one(self.filter_criteria({'_id': _id})) return detail_obj
def get_detail_obj(self): detail_obj = configs.find_one(self.filter_criteria()) if not detail_obj: detail_obj = model.default_values return detail_obj
def get_detail_obj(self): filter_dict = {'type_num': CONFIG_TYPE_WITHDRAW_OPTION} detail_obj = configs.find_one(filter_dict) if not detail_obj: detail_obj = option_model.default_values return detail_obj
def get_detail_obj(self): detail_obj = configs.find_one({'type_num': self.__TYPE}) if not detail_obj: detail_obj = model.default_values return self.configs_info_processor(detail_obj)
def get_config_detail(): config_obj = configs.find_one({'type_num': CONFIG_TYPE_FLASH_SALE}) if not config_obj: config_obj = {'hour_list': list()} return config_obj