Ejemplo n.º 1
0
 def fetch_price_detail(self, price_id):
     response = ProductResponse()
     try:
         result = self.modelProductService.fetch_price_detail(price_id)
         response.rows = result
     except Exception as e:
         response.success = False
         response.message = str(e)
     return response
Ejemplo n.º 2
0
 def get_price_by_product_id(self, merchant_id, product_id):
     response = ProductResponse()
     try:
         result = self.modelProductService.get_price_by_product_id(
             merchant_id, product_id)
         response.rows = result
     except Exception as e:
         response.success = False
         response.message = str(e)
     return response
Ejemplo n.º 3
0
 def get_page_by_merchant_id(self, merchant_id, start, row):
     response = ProductResponse()
     try:
         count = self.modelProductService.get_count_by_merchant_id(
             merchant_id)
         result = self.modelProductService.get_page_by_merchant_id(
             merchant_id, start, row)
         response.rows = {'count': count, 'result': result}
     except Exception as e:
         response.success = False
         response.message = str(e)
     return response
Ejemplo n.º 4
0
    def fetch_product_detail(self, product_id, price_id):
        response = ProductResponse()
        try:
            product_detail = self.modelProductService.fetch_product_and_merchant(
                product_id)
            price_detail = self.modelProductService.fetch_price_detail(
                price_id)
            price_list = self.modelProductService.fetch_price_list(product_id)

            image_list = self.modelProductService.fetch_image_list(product_id)
            detail_list = self.modelProductService.fetch_detail_list(
                product_id)
            comment_list = self.modelProductService.fetch_comment_list(
                product_id)

            fine = self.modelProductService.fetch_comment_count(product_id, 1)
            no_fine = self.modelProductService.fetch_comment_count(
                product_id, 2)

            response.rows = {
                'product_detail': product_detail,
                'price_detail': price_detail,
                'price_list': price_list,
                'image_list': image_list,
                'detail_list': detail_list,
                'comment_list': comment_list,
                'comment_count': {
                    'fine':
                    fine,
                    'fine_percent':
                    fine / (fine + no_fine) * 100 if fine else 0,
                    'no_fine':
                    no_fine,
                    'no_fine_percent':
                    no_fine / (fine + no_fine) * 100 if no_fine else 0,
                    'total':
                    fine + no_fine
                }
            }
        except Exception as e:
            response.success = False
            response.message = str(e)
        return response
Ejemplo n.º 5
0
    def fetch_index_product(self):
        response = ProductResponse()
        try:
            super_new_list = self.modelProductService.fetch_super_new_product()
            super_excellent_list = self.modelProductService.fetch_super_excellent_product(
            )

            a = self.modelProductService.fetch_limit_price_and_product('家具城')
            b = self.modelProductService.fetch_limit_price_and_product('建材城')
            c = self.modelProductService.fetch_limit_price_and_product('家具家装')
            response.rows = {
                'super_new_list': super_new_list,
                'super_excellent_list': super_excellent_list,
                'furniture': a,
                'building_materials': b,
                'decoration': c
            }
        except Exception as e:
            response.success = False
            response.message = str(e)
        return response
Ejemplo n.º 6
0
 def get_upv(self, merchant_id, product_id):
     response = ProductResponse()
     try:
         is_valid = self.modelProductService.get_product_by_id(
             merchant_id, product_id)
         if not is_valid:
             response.message = '无权获取PUV'
             response.success = False
         else:
             pv = self.modelProductService.get_product_pv(product_id)
             uv = self.modelProductService.get_product_uv(product_id)
             response.rows = [{
                 'name': 'pv',
                 'data': pv
             }, {
                 'name': 'uv',
                 'data': uv
             }]
     except Exception as e:
         response.success = False
         response.message = str(e)
     return response