from django.db import models
# create your models here.
class base(models.model):
create_time = models.timefield(auto_now_add=true)
update_time = models.timefield(auto_now=true)
class meta:
abstract = true
# 商品表
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)
produce_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.charfield('購買渠道',max_length=365)
is_launched = models.booleanfield(default=true)
class meta:
db_table = 'goods'
def __str__(self):
return self.title
# 訂單表
class order(base):
pay_method = (
(1, "支付寶"),
)order_status=(
(1, "待支付"),
(2, "已支付"),
(3, "已取消"),
)goods = models.foreignkey(goods,on_delete=models.protect)
order_id = models.charfield(max_length=24)
trade_no = models.charfield(max_length=32,null=true)
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 user_course(base):
course = models.foreignkey('course.course', on_delete=models.cascade, related_name='paycourse',default=none)
class meta:
db_table = 'usercourse'
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
class user(abstractuser):
phone = models.charfield('手機號', max_length=20)
img = models.imagefield(upload_to='user', null=true, blank=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)
class meta:
db_table = 'tb_user'
verbose_name_plural = '使用者'
from django.contrib import admin
from .models import *
# register your models here.
for model in [goods,order]:
admin.site.register(model)
from django.contrib import admin
from .models import user,vip
# register your models here.
admin.site.register(user)
admin.site.register(vip)
商品模組表結構分析
商品模組表結構分析 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...
商品模組表結構分析 1
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...