hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
288 stars 24 forks source link

E-Commerce(B2B2C): SKU/SPU design #80

Open hhstore opened 6 years ago

hhstore commented 6 years ago

B2B2C:

django:

hhstore commented 6 years ago

SKU:

SPU:

hhstore commented 6 years ago

product表设计:

image

image

hhstore commented 6 years ago

saleor:

product 产品表设计:

-saleor.saleor.product.models.Product()


# 集合:
class Collection(SeoModel):
    name = models.CharField(max_length=128, unique=True)
    slug = models.SlugField(max_length=128)
    # 商品
    products = models.ManyToManyField(
        Product, blank=True, related_name='collections')
    background_image = VersatileImageField(
        upload_to='collection-backgrounds', blank=True, null=True)
    is_published = models.BooleanField(default=False)

    objects = CollectionQuerySet.as_manager()

    class Meta:
        ordering = ['pk']

# 单个商品:
class Product(SeoModel):
    product_type = models.ForeignKey(
        ProductType, related_name='products', on_delete=models.CASCADE)
    name = models.CharField(max_length=128)
    description = models.TextField()
    category = models.ForeignKey(
        Category, related_name='products', on_delete=models.CASCADE)
    price = MoneyField(
        currency=settings.DEFAULT_CURRENCY, max_digits=12,
        decimal_places=settings.DEFAULT_DECIMAL_PLACES)
    available_on = models.DateField(blank=True, null=True)
    is_published = models.BooleanField(default=True)
    attributes = HStoreField(default={}, blank=True)
    updated_at = models.DateTimeField(auto_now=True, null=True)
    is_featured = models.BooleanField(default=False)
    charge_taxes = models.BooleanField(default=True)
    tax_rate = models.CharField(
        max_length=128, default=DEFAULT_TAX_RATE_NAME, blank=True)

    objects = ProductQuerySet.as_manager()

    class Meta:
        app_label = 'product'
        permissions = ((
            'manage_products', pgettext_lazy(
                'Permission description',
                'Manage products.')),)

graphql API 设计: