学习⽹站项⽬学习-Django-优惠券系统、结算系统⽬录
money_equivalent_value = models.IntegerField(verbose_name="等值货币", blank=True, null=True)
off_percent = models.PositiveSmallIntegerField("折扣百分⽐", help_text="只针对折扣券,例7.9折,写79", blank=True, null=True) minimum_consume = models.PositiveIntegerField("最低消费", default=0, help_text="仅在满减券时填写此字段")
content_type = models.ForeignKey(ContentType, blank=True, null=True, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField("绑定课程", blank=True, null=True, help_text="可以把优惠券跟课程绑定")
content_object = GenericForeignKey('content_type', 'object_id')
quantity = models.PositiveIntegerField("数量(张)", default=1)
open_date = models.DateField("优惠券领取开始时间")
close_date = models.DateField("优惠券领取结束时间")
valid_begin_date = models.DateField(verbose_name="有效期开始时间", blank=True, null=True)
valid_end_date = models.DateField(verbose_name="有效结束时间", blank=True, null=True)
coupon_valid_days = models.PositiveIntegerField(verbose_name="优惠券有效期(天)", blank=True, null=True,
help_text="⾃券被领时开始算起")
date = models.DateTimeField(auto_now_add=True)
class Meta:
verbose_name_plural = "31. 优惠券⽣成规则"
def __str__(self):
return "%s(%s)" % (_coupon_type_display(), self.name)
class CouponRecord(models.Model):
"""优惠券发放、消费纪录 - ⾯向⽤户"""
# 跟优惠券⽣成规则是⼀对多的关系 - ⼀种优惠券有30张,则发放记录就有30条
coupon = models.ForeignKey("Coupon", on_delete=models.CASCADE)
number = models.CharField(max_length=64)
# ⼀对多,⼀个⽤户有多张优惠券,⼀张优惠券只能给⼀个⽤户
user = models.ForeignKey("UserInfo", verbose_name="拥有者", on_delete=models.CASCADE)
status_choices = ((0, '未使⽤'), (1, '已使⽤'), (2, '已过期'))
status = models.SmallIntegerField(choices=status_choices, default=0)
get_time = models.DateTimeField(verbose_name="领取时间", help_text="⽤户领取时间")
used_time = models.DateTimeField(blank=True, null=True, verbose_name="使⽤时间")
class Meta:
verbose_name_plural = "32. 优惠券发放、消费纪录"
def __str__(self):
return '%s-%s-%s' % (self.user, self.number, _status_display())
django怎么学
⼆、结算页⾯
2-1 前端数据渲染需求
2-2 购物车数据
2-3 结算系统
2-3-1 增加(post)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论