def get_package_count(self, merchant_id, series_service=None): ''' todo:获取商户套系数量 :param merchant_id: :return: ''' my_key = 'package_count_' + str(merchant_id) count = self.mcache.get(my_key) if not count: if series_service is None: series_service = SeriesServices() series_service.set_db(self.db) query = series_service.query_series(merchant_id=merchant_id) count = query.count() self.mcache.set(my_key, count) return count
def get_essence(self, page_size, series_service=None): ''' todo:获取精品推荐 :return: ''' lst_series = self.mcache.get('new_essence_series') if not lst_series: if series_service is None: series_service = SeriesServices() series_service.set_db(self.db) query = series_service.get_essence_series() lst_series = [] for s in query: lst_series.append({ 'cover_img': s.Fcover_img, 'package_name': s.Fpackage_name, 'price': s.Fsale_price }) self.mcache.set('new_essence_series', lst_series) return lst_series
#encoding:utf-8 __author__ = 'binpo' from common.base import BaseApiHandler from services.series.series_services import SeriesServices from services.company.company_services import CompanyServices company_service = CompanyServices() series_service = SeriesServices() class SeriesQueryhandler(BaseApiHandler): def get(self, *args, **kwargs): pass class SeriesDetailhandler(BaseApiHandler): def get(self, series_id, **kwargs): series_service.set_db(self.db) company_service.set_db(self.db) series = series_service.get_series_by_id(series_id) images = series_service.get_series_iamges_by_id(series_id) recommend_series = series_service.query_series( order_by='Fcreate_time').limit(3).offset(0) conpany = company_service.get_company_by_uid( series.Fmerchant_id) #公司信息 company_gift = company_service.get_gift(series.Fmerchant_id, 1).scalar() #到店礼 order_gift = company_service.get_gift(series.Fmerchant_id,