Пример #1
0
class StoreSerializer(ModelSerializer):

    # id = UUIDField(required=False)
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)
    store_key = CharField(required=False)
    refresh_token_expire_time =\
        TimestampField(required=False)
    access_token_expire_time =\
        TimestampField(required=False)
    platform_id = UUIDField()
    platform_name = SerializerMethodField()

    def get_platform_name(self, obj):
        if not obj.platform_name:
            return ''
        else:
            return PLATFORM.get(obj.platform_name)

    def get(self, store_id):
        return Store.objects.get(pk=store_id)

    class Meta:
        model = Store
        fields = ('id', 'created_at', 'updated_at', 'auto_check', 'auto_merge',
                  'is_enabled', 'fetch_order_latest', 'is_deleted',
                  'store_key', 'store_development_type', 'store_name',
                  'username', 'address', 'contact_number', 'abbreviation',
                  'app_key', 'app_secret', 'access_token', 'refresh_token',
                  'expire_in', 'access_token_expire_time',
                  'refresh_token_expire_time', 'platform_name', 'platform_id')
Пример #2
0
class StockInDetailSerializer(ModelSerializer):
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)

    class Meta:
        model = StockInDetail
        fields = ('id', 'created_at', 'updated_at', 'quantity', 'sku_name',
                  'sku_spec', 'item_code', 'bar_code', 'sku_id')
Пример #3
0
class SubCategorySerializer(serializers.ModelSerializer):

    # id = UUIDField(required=False)
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)

    class Meta:
        model = SkuCategory
        fields = [
            'id', 'created_at', 'updated_at',
            'category_name'
        ]
Пример #4
0
class SkuCategorySerializer(ModelSerializer):

    # id = UUIDField(required=False)
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)
    sub_category = SubCategorySerializer(many=True)

    class Meta:
        model = SkuCategory
        fields = [
            'id', 'created_at', 'updated_at', 'sub_category',
            'category_name'
        ]
Пример #5
0
class StockInSerializer(ModelSerializer):

    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)
    estimated_to_arrival = TimestampField(required=False)
    stock_in_details = StockInDetailSerializer(many=True, required=False)
    warehouse_id = UUIDField()

    class Meta:
        model = StockIn
        fields = ('id', 'created_at', 'updated_at', 'stock_in_type',
                  'stock_in_status', 'entry_order_id', 'order_code',
                  'user_note', 'express', 'express_number',
                  'estimated_to_arrival', 'warehouse_name', 'warehouse_id',
                  'stock_in_details', 'user_mobile', 'user_id', 'user_name')
Пример #6
0
class SkuSerializer(ModelSerializer):

    # id = UUIDField(required=False)
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)
    category_name = NoneField(required=False)
    category_id = NoneField(required=True, allow_null=False)
    inventories = InvetorySerializer(many=True, required=False)

    class Meta:
        model = Sku
        fields = ('id', 'created_at', 'updated_at', 'sku_name', 'quantity',
                  'specification', 'bar_code', 'item_code',
                  'available_quantity', 'price', 'unit', 'category_id',
                  'is_deleted', 'category_name', 'inventories')
Пример #7
0
class InvetorySerializer(ModelSerializer):

    # id = UUIDField(required=False)
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)
    sku_name = StringRelatedField(source='sku.sku_name', required=False)
    item_code = StringRelatedField(source='sku.item_code', required=False)
    bar_code = StringRelatedField(source='sku.bar_code', required=False)
    specification = StringRelatedField(source='sku.specification',
                                       required=False)

    class Meta:
        model = SkuWarehouse
        fields = ('id', 'created_at', 'updated_at', 'quantity',
                  'available_quantity', 'warehouse_name', 'user_id',
                  'sku_name', 'item_code', 'bar_code', 'specification')
Пример #8
0
class StorgeReceiptSerializer(ModelSerializer):

    created_at = TimestampField()

    class Meta:
        model = StorgeReceipt
        fields = ('id', 'created_at', 'amount', 'warehouse_id',
                  'warehouse_name', 'storge_fee_id')
Пример #9
0
class OrderReceiptSerializer(ModelSerializer):

    created_at = TimestampField()

    class Meta:
        model = OrderReceipt
        fields = ('id', 'created_at', 'amount', 'warehouse_name',
                  'warehouse_id', 'express_amount', 'order_process_amount',
                  'order_id', 'order_code', 'order_process_fee_id')
Пример #10
0
class ActivityListSerializer(ModelSerializer):

    # id = UUIDField(required=False)
    # store_id = UUIDField(required=False)
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)
    begin_date = TimestampField(required=False)
    end_date = TimestampField(required=False)
    store_name = StringRelatedField(source='store.store_name')

    class Meta:
        model = ActivityRule
        fields = [
            'id', 'store_id', 'created_at', 'updated_at', 'begin_date',
            'is_enabled', 'end_date', 'is_expired', 'title', 'rule_type',
            'accord_cost', 'is_times', 'accord_amount', 'store_name',
            'is_deleted'
        ]
Пример #11
0
class OrderDetailSerializer(ModelSerializer):

    # id = UUIDField(required=False)
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)
    sku_name = StringRelatedField(source='sku.sku_name')
    specification = StringRelatedField(source='sku.specification')
    bar_code = StringRelatedField(source='sku.bar_code')
    item_code = StringRelatedField(source='sku.item_code', default='')
    price = StringRelatedField(source='sku.price')
    sku_id = CharField(source='sku.id')
    available_quantity = StringRelatedField(source='sku.available_quantity')

    class Meta:

        model = OrderDetail
        fields = [
            'id', 'created_at', 'updated_at', 'is_gift', 'price',
            'quantity', 'sku_name', 'bar_code', 'item_code',
            'available_quantity', 'specification', 'sku_id'
        ]
Пример #12
0
class DepositDetailSerializer(ModelSerializer):

    created_at = TimestampField()

    statement_type_value = SerializerMethodField()

    def get_statement_type_value(self, obj):
        return STATEMENT_TYPE.get(obj.statement_type)

    class Meta:
        model = DepositDetail
        fields = ('id', 'created_at', 'amount', 'is_receipt', 'statement_type',
                  'statement_type_value')
Пример #13
0
class OrderSerializer(ModelSerializer):

    # id = UUIDField(required=False)
    created_at = TimestampField(required=False)
    updated_at = TimestampField(required=False)
    store_name = StringRelatedField(source='store.store_name')
    order_code = CharField(read_only=True)
    store_name = StringRelatedField(source='store.store_name')
    buyer_nickname = CharField(read_only=True)
    order_details = OrderDetailSerializer(many=True, required=False)
    express = CharField(source='logistics_name')
    wms_status = StatusField()
    order_status = StatusField()
    order_mark = StatusField()
    # express_number = SerializerMethodField()

    # def get_express_number(self, obj):
    #     if hasattr(obj, 'order_express'):
    #         express_number = ','.\
    #             join([e.express_code for e in obj.order_express])
    #         return express_number
    #     else:
    #         return ''

    class Meta:

        model = Order
        fields = ['id', 'created_at', 'updated_at', 'is_locked', 'is_splited',
                  'order_mark', 'order_status', 'wms_status', 'total_price',
                  'express', 'zip_code', 'warehouse_name', 'express_number',
                  'order_code', 'store_name', 'buyer_nickname',
                  'consignee_name', 'consignee_phone', 'consignee_province',
                  'consignee_city', 'consignee_area', 'consignee_detail',
                  'buyer_note', 'user_note', 'order_details',
                  'user_id', 'user_name'
                  ]
Пример #14
0
class StorgeBillSerializer(ModelSerializer):

    created_at = TimestampField()
    bill_type = SerializerMethodField()
    bill_type_value = SerializerMethodField()

    def get_bill_type(self, obj):
        return 2

    def get_bill_type_value(self, obj):
        return '仓储账单'

    class Meta:
        model = StorgeBill
        fields = ('id', 'created_at', 'amount', 'warehouse_id', 'bill_type',
                  'bill_type_value', 'warehouse_name', 'paid', 'storge_fee_id')
Пример #15
0
class OrderBillSerializer(ModelSerializer):

    created_at = TimestampField()
    bill_type = SerializerMethodField()
    bill_type_value = SerializerMethodField()

    def get_bill_type(self, obj):
        return 1

    def get_bill_type_value(self, obj):
        return '发货账单'

    class Meta:
        model = OrderBill
        fields = ('id', 'created_at', 'amount', 'paid', 'warehouse_name',
                  'warehouse_id', 'bill_type', 'bill_type_value',
                  'express_amount', 'express_sheet_amount',
                  'order_process_amount', 'unsettle_amount', 'order_id',
                  'order_code', 'order_process_fee_id')