zoukankan      html  css  js  c++  java
  • 实验楼第三方支付,订单

    #创建商品表模型
    
    
    from django.db import models
    # Create your models here.
    from utils.MyBaseModel import Base
    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 Order(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
    #在admin  里注册
    
    from django.contrib import admin
    from . import models
    # Register your models here.
    
    admin.site.register(models.Goods)
    admin.site.register(models.Order)
    #注册路游
    from django.urls import path, re_path
    from . import views
    urlpatterns = [
    
    ]
    做最野的狼
  • 相关阅读:
    1393 0和1相等串 鸽笼原理 || 化简dp公式
    C. Coin Troubles 有依赖的背包 + 完全背包变形
    D. PolandBall and Polygon BIT + 欧拉公式
    51NOD 1639 绑鞋带 数学
    D. Fedor and coupons 二分暴力
    hdu 4104 Discount
    bnu 51640 Training Plan DP
    hdu 5745 La Vie en rose DP + bitset优化
    hdu 5036 Explosion bitset优化floyd
    1354 选数字 DP背包 + 数学剪枝
  • 原文地址:https://www.cnblogs.com/shanjiaaa/p/13817403.html
Copyright © 2011-2022 走看看