80 lines
3.4 KiB
Python
80 lines
3.4 KiB
Python
from django.db import models
|
|
from django.utils.translation import gettext_lazy
|
|
from ulid import ULID
|
|
from uuid6 import uuid8
|
|
|
|
from wechat_数据库.用户数据库.小程序登陆用户 import models_app_name
|
|
from wechat_数据库.雪花算法.雪花算法工具 import generator
|
|
|
|
|
|
|
|
|
|
|
|
class goods商品Choices( models.TextChoices ):
|
|
幸运拼团 = "幸运拼团", gettext_lazy( "幸运拼团" )
|
|
商城商品 = "商城商品", gettext_lazy( "商城商品" )
|
|
赢免单 = "赢免单", gettext_lazy( "赢免单" )
|
|
|
|
|
|
|
|
|
|
class goods商品( models.Model ):
|
|
"""城市信息表"""
|
|
|
|
objects = models.Manager( ) #
|
|
id_主键_goods商品 = models.UUIDField( primary_key=True, default=uuid8 )
|
|
id_str = models.CharField( max_length=128, default=generator.generate_str )
|
|
goods商品数据 = models.JSONField( )
|
|
goods商品类型 = models.CharField( max_length=128, choices=goods商品Choices,
|
|
default=goods商品Choices.商城商品.value )
|
|
dateAndTime = models.DateTimeField( auto_now_add=True, db_comment="创建时间" ) # 数据创建时间
|
|
updateTime = models.DateTimeField( auto_now=True, db_comment="更新时间" ) # 更新时间(需要用 save() )
|
|
|
|
class Meta:
|
|
db_table = "goods商品" # 给数据表自定义一个名称;默认的会是在 应用名+类名
|
|
app_label = models_app_name
|
|
ordering = [ "dateAndTime", "updateTime" ]
|
|
|
|
|
|
|
|
|
|
|
|
class Goods( models.Model ):
|
|
"""城市信息表"""
|
|
objects = models.Manager( ) #
|
|
|
|
idKey = models.UUIDField( primary_key=True, default=uuid8 )
|
|
goods_id商品 = models.CharField( max_length=128, default=ULID)
|
|
goods_商品品牌 = models.CharField( max_length=128, )
|
|
goods_商品标题 = models.CharField( max_length=128, )
|
|
goods_商品信息 = models.JSONField( default=dict, null=True, blank=True )
|
|
goods_商品标签 = models.JSONField( default=list, null=True, blank=True )
|
|
goods_商品销售规格 = models.JSONField( null=True, blank=True, default=list )
|
|
goods_商品销售场景 = models.CharField( max_length=128, choices=goods商品Choices, null=True, blank=True )
|
|
goods_商品搜索标签 = models.JSONField( null=True, blank=True, default=list )
|
|
goods_商家推荐标签 = models.JSONField( null=True, blank=True, default=list )
|
|
goods_其它参数 = models.JSONField( null=True, blank=True )
|
|
dateAndTime = models.DateTimeField( auto_now_add=True, db_comment="创建时间" ) # 数据创建时间
|
|
updateTime = models.DateTimeField( auto_now=True, db_comment="更新时间" ) # 更新时间(需要用 save() )
|
|
|
|
class Meta:
|
|
db_table = "Goods" # 给数据表自定义一个名称;默认的会是在 应用名+类名
|
|
app_label = models_app_name
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pass
|
|
洗衣液商品数据 = {
|
|
"商品销售参数": [ { "价格": 300, "会员价": 280, "销售规格": "8斤装" },
|
|
{ "价格": 500, "会员价": 380, "销售规格": "20斤装" }, ],
|
|
"销售数量": 1,
|
|
"商品标题": "六果香 8斤装(超划算) 源自天然酵素迅速渗入衣物,去除99种污渍99%除菌🦠一洗即净,守护健康",
|
|
"商品信息参数": {
|
|
"品牌": "六果香", "净重": "8斤装", "香型": "熏衣草",
|
|
"洁净": "源自天然酵素迅速渗入衣物,去除99种污渍", "除菌🦠": "99%除菌🦠,污渍菌螨,一洗即净,守护健康",
|
|
},
|
|
}
|