Esempio n. 1
0
class ReviewListSerializers(ModelSerializer):
    goods = GoodsSaleSerializers()
    user = UserOrderSerializers()

    class Meta:
        model = OrderReview
        fields = ('id', 'user', 'created_at', 'img', 'title', 'content',
                  'goods')
        examples = [{
            "id": 1,
            "title": "test create",
            "content": "contnet create",
            "goods": {
                "id": 1,
                "title": "[KF365] 햇 감자 1kg",
                "short_desc": "믿고 먹을 수 있는 상품을 합리적인 가격에, KF365",
                "packing_status": "상온",
                "transfer": "샛별배송/택배배송",
                "price": 2380,
                "img":
                "https://pbs-13-s3.s3.amazonaws.com/goods/%5BKF365%5D%20%ED%96%87%20%EA%B0%90%EC%9E%90%201kg/KF365_%ED%96%87_%EA%B0%90%EC%9E%90_1kg_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20200930%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20200930T212332Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=d3539d90c6ef746312452ffb2dfc8d34af19b256bef3937204a66d4ff5e15664",
                "sales": 'null',
                "tagging": [],
                "discount_price": 'null'
            }
        }]
Esempio n. 2
0
    def main_page_health(self, request, *args, **kwargs):
        """
        홈 - 컬리추천 건강식품[면역력 증진] API

        ---
        정렬 데이터 api/goods/best 참고
        ```
        [
            {
                "id": 611,
                "title": "[바로이즙] ABC 착즙주스 2종",
                "short_desc": "세 가지 과채의 영양이 그대로!",
                "packing_status": "상온",
                "transfer": "샛별배송/택배배송",
                "price": 9900,
                "img": "https://pbs-13-s3.s3.amazonaws.com/goods/%5B%EB%B0%94%EB%A1%9C%EC%9D%B4%EC%A6%99%5D%20ABC%20%EC%B0%A9%EC%A6%99%EC%A3%BC%EC%8A%A4%202%EC%A2%85/%EB%B0%94%EB%A1%9C%EC%9D%B4%EC%A6%99_ABC_%EC%B0%A9%EC%A6%99%EC%A3%BC%EC%8A%A4_2%EC%A2%85_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20201001%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20201001T171717Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=a75825426c04179910b7872a9d20ae0b90287b59e87a7f83f98603eb2c52451d",
                "sales": null,
                "tagging": [
                    {
                        "tag": {
                            "name": "한정수량"
                        }
                    }
                ],
                "discount_price": null,
                "sales_count": 94,
                "stock": {
                    "id": 611,
                    "count": 77,
                    "updated_at": "2020-08-15T18:04:28.297000Z"
                }
            },
            {
                "id": 797,
                "title": "[채움] 국내산 과일채소로 만든 주스 4종 (10개입)",
                "short_desc": "[박스판매] 100% 국내산 재료로 채운 주스 한 잔",
                "packing_status": null,
                "transfer": "샛별배송/택배배송",
                "price": 10800,
                "img": "https://pbs-13-s3.s3.amazonaws.com/goods/%5B%EC%B1%84%EC%9B%80%5D%20%EA%B5%AD%EB%82%B4%EC%82%B0%20%EA%B3%BC%EC%9D%BC%EC%B1%84%EC%86%8C%EB%A1%9C%20%EB%A7%8C%EB%93%A0%20%EC%A3%BC%EC%8A%A4%204%EC%A2%85%20%2810%EA%B0%9C%EC%9E%85%29/%EC%B1%84%EC%9B%80_%EA%B5%AD%EB%82%B4%EC%82%B0_%EA%B3%BC%EC%9D%BC%EC%B1%84%EC%86%8C%EB%A1%9C_%EB%A7%8C%EB%93%A0_%EC%A3%BC%EC%8A%A4_4%EC%A2%85_10%EA%B0%9C%EC%9E%85_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20201001%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20201001T171717Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=b9a57561dc4082ad01fa716da45c02c5a051698f5e7838e6e16368b17e72d94a",
                "sales": null,
                "tagging": [],
                "discount_price": null,
                "sales_count": 68,
                "stock": {
                    "id": 797,
                    "count": 38,
                    "updated_at": "2020-07-26T18:04:30.799000Z"
                }
            },
            ...
        ]
        ```
        """
        main_health = Goods.objects.filter(types__type__category__name='건강식품').prefetch_related('event', 'tagging',
                                                                                                'stock', 'sales',
                                                                                                'tagging__tag', )
        serializer = GoodsSaleSerializers(main_health, many=True)
        return Response(serializer.data, status=status.HTTP_200_OK)
Esempio n. 3
0
    def sales_goods(self, request, *args, **kwargs):
        """
        홈 - 컬리 추천에 위치한 알뜰 상품에 대한 상품 리스트

        ---
        - 할인률을 가진 8개의 상품이 매 요청마다 다르게 출력됩니다.
        - 필터링에 필요한 요청은 /goods/best에 작성한 글을 참고 바랍니다.

        ```
        [
            {
                "id": 231,
                "title": "[마켓베라즈] 생새우 2종(냉동)",
                "short_desc": "깔끔한 손질, 다양한 쓰임새",
                "packing_status": null,
                "transfer": "샛별배송/택배배송",
                "price": 10000,
                "img": "https://pbs-13-s3.s3.amazonaws.com/goods/%5B%EB%A7%88%EC%BC%93%EB%B2%A0%EB%9D%BC%EC%A6%88%5D%20%EC%83%9D%EC%83%88%EC%9A%B0%202%EC%A2%85%28%EB%83%89%EB%8F%99%29/%EB%A7%88%EC%BC%93%EB%B2%A0%EB%9D%BC%EC%A6%88_%EC%83%9D%EC%83%88%EC%9A%B0_2%EC%A2%85%EB%83%89%EB%8F%99_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20201001%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20201001T165731Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=1fcad4fd18e17493689ff03e59ab019ad766e4ea6b168f61777b9fc44ed5d13a",
                "sales": {
                    "discount_rate": 5,
                    "contents": null
                },
                "tagging": [],
                "discount_price": 9500,
                "sales_count": 76,
                "stock": {
                    "id": 231,
                    "count": 63,
                    "updated_at": "2020-06-30T18:04:22.696000Z"
                }
            },
            ...
        ]
        ```
        """
        count_all = self.queryset.filter(sales__discount_rate__isnull=False).count()
        max_random_item_count = 8
        sales_items = []

        while True:
            # 1 , 716
            random_save = random.randint(1, count_all)
            if random_save in sales_items:
                continue
            elif random_save == 0:
                continue
            else:
                sales_items.append(random_save)
            if len(sales_items) == max_random_item_count:
                break
        save_ins = self.queryset.filter(pk__in=sales_items).prefetch_related('tagging', 'sales', 'stock',
                                                                             'tagging__tag')
        serializer = GoodsSaleSerializers(save_ins, many=True)
        return Response(serializer.data, status=status.HTTP_200_OK)
Esempio n. 4
0
class CartItemSerializer(ModelActionSerializer):
    sub_total = serializers.SerializerMethodField()
    discount_payment = serializers.SerializerMethodField()
    goods = GoodsSaleSerializers(read_only=True)

    class Meta:
        model = CartItem
        fields = ('id', 'cart', 'goods', 'quantity', 'sub_total',
                  'discount_payment')
        examples = [
            {
                "id": 5,
                "cart": 1,
                "goods": {
                    "id": 5,
                    "title": "친환경 당근 500g",
                    "short_desc": "껍질째 먹을 수 있는 친환경 흙당근 (500g 내외)",
                    "packing_status": "냉장",
                    "price": 2700,
                    "img":
                    "https://pbs-13-s3.s3.amazonaws.com/goods/%EC%B9%9C%ED%99%98%EA%B2%BD%20%EB%8B%B9%EA%B7%BC%20500g/%EC%B9%9C%ED%99%98%EA%B2%BD_%EB%8B%B9%EA%B7%BC_500g_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20200930%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20200930T183245Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=69a7d3efd0226123c485337c03cd4d60a99d8ef63e29e52cf63aeeb14867f406",
                    "sales": {
                        "discount_rate": 35,
                        "contents": 'null'
                    },
                    "tagging": [],
                    "discount_price": 1755
                },
                "quantity": 10,
                "sub_total": 27000,
                "discount_payment": 17550
            },
            {
                "id": 6,
                "cart": 1,
                "goods": {
                    "id": 6,
                    "title": "양배추 2종",
                    "short_desc": "달큰 아삭 하게 즐기는 양배추",
                    "packing_status": "냉장",
                    "price": 2600,
                    "img":
                    "https://pbs-13-s3.s3.amazonaws.com/goods/%EC%96%91%EB%B0%B0%EC%B6%94%202%EC%A2%85/%EC%96%91%EB%B0%B0%EC%B6%94_2%EC%A2%85_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20200930%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20200930T183245Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=4779d8a5f4061a05150fcd36641c191af6311374e60ed99cd6e1c17e2f835e46",
                    "sales": {
                        "discount_rate": 25,
                        "contents": 'null'
                    },
                    "tagging": [],
                    "discount_price": 1950
                },
                "quantity": 1,
                "sub_total": 2600,
                "discount_payment": 1950
            },
            {
                "id": 7,
                "cart": 1,
                "goods": {
                    "id": 7,
                    "title": "무 1통",
                    "short_desc": "시원한 무 한 통",
                    "packing_status": "냉장",
                    "price": 1980,
                    "img":
                    "https://pbs-13-s3.s3.amazonaws.com/goods/%EB%AC%B4%201%ED%86%B5/%EB%AC%B4_1%ED%86%B5_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20200930%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20200930T183245Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=7e77fd8dca14650850e131c7849ea3db3d2db4be7acaea5225e75892b1b5df77",
                    "sales": {
                        "discount_rate": 'null',
                        "contents": "+gift"
                    },
                    "tagging": [],
                    "discount_price": 'null'
                },
                "quantity": 1,
                "sub_total": 1980,
                "discount_payment": 1980
            },
        ]

    def get_sub_total(self, obj):
        return obj.sub_total

    def get_discount_payment(self, obj):
        return obj.discount_payment
Esempio n. 5
0
class GoodsEventTypeSerializers(ModelSerializer):
    goods = GoodsSaleSerializers()

    class Meta:
        model = GoodsEventType
        fields = ('goods', )
Esempio n. 6
0
class EventImageSquareSerializers(ModelSerializer):
    goods = GoodsSaleSerializers(many=True)

    class Meta:
        model = Event
        fields = ('id', 'title', 'square_image', 'goods')
Esempio n. 7
0
class EventRetrieveSerializers(ModelSerializer):
    goods = GoodsSaleSerializers(many=True)

    class Meta:
        model = Event
        fields = ('id', 'title', 'goods')
        examples = {
            "id":
            1,
            "title":
            "[모음전] 해물육수",
            "goods": [
                {
                    "id": 1217,
                    "title": "[바다원] 대관령 북어채 100g",
                    "short_desc": "반찬 걱정 덜어주는 구수한 감칠맛",
                    "packing_status": "냉장",
                    "transfer": "샛별배송/택배배송",
                    "price": 6715,
                    "img":
                    "https://pbs-13-s3.s3.amazonaws.com/goods/%5B%EB%B0%94%EB%8B%A4%EC%9B%90%5D%20%EB%8C%80%EA%B4%80%EB%A0%B9%20%EB%B6%81%EC%96%B4%EC%B1%84%20100g/%EB%B0%94%EB%8B%A4%EC%9B%90_%EB%8C%80%EA%B4%80%EB%A0%B9_%EB%B6%81%EC%96%B4%EC%B1%84_100g_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20200930%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20200930T205446Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=acb4c60f632502ec5858911f247d6473666647b11d561b7e1880b7e4d462b1c4",
                    "sales": {
                        "discount_rate": 'null',
                        "contents": "1+1"
                    },
                    "tagging": [],
                    "discount_price": 'null'
                },
                {
                    "id": 1218,
                    "title": "[바다원] 야채 국물용팩 90g",
                    "short_desc": "시원하고 깔끔한 맛",
                    "packing_status": "냉장",
                    "transfer": "샛별배송/택배배송",
                    "price": 5015,
                    "img":
                    "https://pbs-13-s3.s3.amazonaws.com/goods/%5B%EB%B0%94%EB%8B%A4%EC%9B%90%5D%20%EC%95%BC%EC%B1%84%20%EA%B5%AD%EB%AC%BC%EC%9A%A9%ED%8C%A9%2090g/%EB%B0%94%EB%8B%A4%EC%9B%90_%EC%95%BC%EC%B1%84_%EA%B5%AD%EB%AC%BC%EC%9A%A9%ED%8C%A9_90g_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20200930%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20200930T205447Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=2e4a6f8a71e9fd070a08a07fa4d6a9714d2180031a72af4d50aca0d1ce81370d",
                    "sales": {
                        "discount_rate": 5,
                        "contents": 'null'
                    },
                    "tagging": [],
                    "discount_price": 4764
                },
                {
                    "id": 1219,
                    "title": "[바다원] 꽃게 국물용팩 90g",
                    "short_desc": "손쉽게 더하는 꽃게의 감칠맛",
                    "packing_status": "냉장",
                    "transfer": "샛별배송/택배배송",
                    "price": 5015,
                    "img":
                    "https://pbs-13-s3.s3.amazonaws.com/goods/%5B%EB%B0%94%EB%8B%A4%EC%9B%90%5D%20%EA%BD%83%EA%B2%8C%20%EA%B5%AD%EB%AC%BC%EC%9A%A9%ED%8C%A9%2090g/%EB%B0%94%EB%8B%A4%EC%9B%90_%EA%BD%83%EA%B2%8C_%EA%B5%AD%EB%AC%BC%EC%9A%A9%ED%8C%A9_90g_goods_image.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXOLZAM2NBPACFGX7%2F20200930%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20200930T205447Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=0d36df5eb46a62943208f7169e461ea985bec662f3bd04852ae2e0c57a4b372a",
                    "sales": {
                        "discount_rate": 10,
                        "contents": 'null'
                    },
                    "tagging": [],
                    "discount_price": 4513
                },
            ]
        }