1911A 商品模組表結構分析

2022-07-15 15:30:15 字數 4612 閱讀 1172

from django.db import

models

from utils.mybasemodel import

base

#create your models here.

class

goods(base):

goods_type =(

('1', '

vip'

), ('2

', '

course')

)channel_type =(

('1', '普通'

), ('2

', '**'

) )

course = models.foreignkey('

course.course

', on_delete=models.protect)

goods_type = models.charfield('

商品種類

', choices=goods_type, max_length=8)

product_id = models.charfield('

產品id

', max_length=8)

title = models.charfield('

商品名稱

', max_length=24)

price = models.decimalfield('

商品**

', max_digits=8, decimal_places=2)

channel_type = models.charfield('

購買渠道

', choices=channel_type, max_length=8)

period = models.integerfield('

有效期', default=365)

is_launched = models.booleanfield('

是否上架

', default=true)

class

meta:

db_table = '

tb_goods

'def

__str__

(self):

return

self.title

class

orders(base):

pay_method =(

(1, "

支付寶"

), )

order_status =(

(1, "

待支付"

), (2, "

已支付"

), (3, "

已取消"

), )

user = models.foreignkey('

user.user

', on_delete=models.protect, verbose_name="

下單使用者")

goods = models.foreignkey(goods, on_delete=models.protect)

order_id = models.charfield('

訂單號', max_length=24)

trade_no = models.charfield('

支付寶訂單號

', max_length=32, null=true) #

28位 pay_time = models.datetimefield('

支付時間

', null=true)

pay_method = models.charfield('

支付方式

', choices=pay_method, default=1, max_length=8)

status = models.charfield('

支付狀態

', choices=order_status, default=1, max_length=8)

total_amount = models.decimalfield(max_digits=10, decimal_places=2, verbose_name="

商品總金額")

class

meta:

db_table = '

tb_orders

'def

__str__

(self):

return self.order_id

class

usercourse(base):

"""使用者購買的課程

"""user = models.foreignkey('

user.user

', on_delete=models.cascade, related_name='

paycourse')

course = models.foreignkey('

course.course

', on_delete=models.cascade, related_name='

payuser')

class

meta:

db_table = '

tb_usercourse

'def

__str__

(self):

return

"使用者:%s, 課程:%s

" % (self.user.username, self.course.title)

from django.db import

models

from utils.mybasemodel import

base

#建立vip表,並和使用者進行關聯

class

vip(base):

vip_choise =(

('0', '

普通使用者'),

('1', '

普通會員'),

('2', '

高階會員'),

)title = models.charfield('

vip名稱

', max_length=16)

vip_type = models.charfield('

vip種類

', choices=vip_choise, max_length=4)

desc = models.charfield('

vip描述

', max_length=255)

period = models.integerfield('

有效期', default=365)

class

meta:

db_table = '

tb_vip

'def

__str__

(self):

return

self.title

#使用者表 username: root3 password: 123

class

user(abstractuser):

phone = models.charfield('

手機號', max_length=20) #

手機號 img = models.imagefield(upload_to='

user

', null=true) #

頭像 nick_name = models.charfield('

暱稱', max_length=20) #

暱稱 address = models.charfield('

位址', max_length=255) #

位址vip = models.foreignkey(vip, on_delete=models.set_null, default=none, null=true)

vip_expiration = models.datefield('

vip到期時間

', blank=true, default=none, null=true)

#gp=models.manytomanyfield('組',gp)

class

meta:

db_table = '

tb_user

'

from django.contrib import

admin

from . import

models

#register your models here.

admin.site.register(models.goods)

admin.site.register(models.goodscourse)

admin.site.register(models.orders)

from django.contrib import

admin

from user import

models

admin.site.register(models.user)

admin.site.register(models.vip)

商品模組表結構分析

from django.db import models create your models here.class base models.model create time models.timefield auto now add true update time models.timefie...

商品模組表結構分析

商品模組表結構分析 from django.db import models from utils.mybasemodel import base class goods base goods type 1 vip 2 course channel type 1 普通 2 course models...

01 商品模組表結構分析

1.表結構分析 1.1 商品模組表結構分析 from django.db import models from utils.mybasemodel import base class goods base goods type 1 vip 2 course channel type 1 普通 2 c...