Article From:https://www.cnblogs.com/kaiping23/p/9736841.html

Contents

  • 1.Business model specification
  • 2.Introduction of development process
  • 3.Project requirement analysis
  • 4.Project architecture analysis
  • 5.Database design
  • 6.Model class specification
  • 7.Create dailyfresh project
  • 8.Display registration page
  • 9.Get and post request processing for view functions
  • 10.Class view

 

1.B2B– business to business”

  • B2B (Business to Business)It means that both the supplier and the demander are businessmen (or enterprises, companies) who use Internet technology or various business network platforms to complete business transactions. Electronic commerce is a concrete manifestation of modern B2B marketing.

  • Case: Alibaba, HC

2.C2C– person to person”

  • C2C That is, Customer to Customer, which means the behavior of e-commerce among consumers. For example, a consumer has a computer, through the network transactions, it is sold to another consumer, this type of transaction is called C2C e-commerce. ` ` ` ` ` ` ` ` ` ‘.

  • Case: Taobao, eBay and melon seeds used cars

3.B2C– enterprise to individual”

  • B2C It is the abbreviation of Business to Customer, and its Chinese is referred to as “business to customer”. “Business to Customer” is a mode of e-commerce, that is to say, the commercial retail mode of selling products and services directly to consumers. This form of e-commerce is generally based on network zero.Selling is the main business, and online sales activities are mainly based on the Internet. B2C means that enterprises provide consumers with a new shopping environment through the Internet – online stores, consumers through the Internet shopping, online payment and other consumer behavior.

  • Case: vip.com, Lok bee net

4.C2B– personal to business”

  • C2B(Consumer to Business,That is, consumers to enterprises, is a new business mode in the era of Internet economy. This model changes the relationship between producers (businesses and institutions) and consumers. It is a kind of Create Value, a kind of Consume Value.. The C2B model is the opposite of the well-known DSM (Demand Supply Model). The real C2B should be produced first by the consumer demand and then by the enterprise production, that is, first by the consumer demand, then by the enterprise production organization according to the demand.. Usually consumers customize products and prices according to their own needs, or actively participate in product design, production and pricing, products, prices and other highlights the individual needs of consumers, customized production enterprises.

  • Case: Haier mall, Shangpin home delivery

5.O2O– online to offline”

  • O2O Online To Offline refers to the combination of offline business opportunities with the Internet, making the Internet a platform for offline transactions. The concept originated in the United States. The concept of O2O is very extensive. It can involve both online and related.Under the line, it can be called O2O. The mainstream business management course introduces and focuses on the new business model of O2O. ` ` ` ` ` ` ` ` ` ‘.

  • Case: American regiment, hungry?

6.F2C– factories to individuals”

  • F2C Refers to the Factory to customer, that is, from the manufacturer to the consumer e-commerce mode.

  • Case: DELL

7.B2B2C– Enterprises — Enterprises — individuals.

  • B2B2C E-commerce is a type of online shopping business model, B is the abbreviation of BUSINESS, C is the abbreviation of CUSTOMER, the first B refers to the supplier of goods or services, the second B refers to the enterprise engaged in e-commerce, C is the consumer.. The first BUSINESS is not limited to brand suppliers, film and television production companies and Book publishers, any supplier of goods or services can become the first BUSINESS; the second B B2C model of e-commerce enterprises, through unificationThe operation and management of goods and services, consumer terminals at the same time integration, is a bridge between the vast number of suppliers and consumers, suppliers and consumers to provide quality services, Internet e-commerce service providers. C represents consumers, shopping in a unified e-commerce platform built on second B.Consumers. B2B2C originates from the evolution and perfection of the current B2B and B2C mode. It combines B2C and C2C perfectly, and builds its own logistics supply chain system through B2B2C e-commerce enterprises to provide unified services.

  • Case: Jingdong mall, Tmall mall


 

 

project requirement analysis

function module explanation.

1. user module”

  • register.html login.html user_center_info.html user_center_order.htmluser_center_site.html
  • Registration page
    • Display registration page
    • Realizing user’s registration logic
  • Login page
    • Display login page
    • Realizing user login logic
  • User center
    • User center information page:
      • Displays user information, including user name, phone number, and address, while the bottom of the page shows the product information that the user recently browsed
    • User center address page:
      • Displays the current address of the user, and the form at the bottom of the page can add the address of the user.
    • User center order page:
      • Displays current user order information

2. commodity module”

  • index.html list.html detail.html
  • home page
    • Click on the corresponding product category link on the page and jump to the corresponding merchandise list page.
    • Each category of goods displays 4, and displays according to the default sort.
    • 3 latest product titles are displayed behind each category of merchandise.
    • Click on a product to jump to the details page of the product.
    • If the user is logged in, the information on the login user is displayed at the top of the page.
  • Product details page
    • Showing the details of a particular product.
    • The bottom left part of the page shows 2 latest product information of the commodity.
  • List of goods
    • Display list data of a particular commodity.
    • The bottom left part of the page shows 2 latest product information of the commodity.
  • Other
    • Search for merchandise information through page search box

3. Shopping Cart module”

  • cart.html
  • List page and detail page add goods to shopping cart.
  • After the user logs in, in addition to the registration page and login page, other pages display the number of items in the logged-in user’s shopping cart
  • Shopping cart page: the operation of goods in the user’s shopping cart. If you choose a product, increase or decrease the number of goods in the shopping cart.

4. order module”

  • place_order.html
  • Submit order page: display merchandise information that users are prepared to purchase.
  • User center information page displays user order information.


 

> prompt

  • Project development requires data to drive, so we need to think about how to design the database table first.
  • Only when the database table is designed, can the backstage operators publish data to the database through the backstage management platform
  • DjangoEmbedded ORM framework, we manipulate database through object oriented thinking through model classes.
  • A model class maps a table in the database.

> database table details

base class: BaseModel

  • Model class supplementary fields are used as base classes.
Field nameField typefield optionField description
create_timeDateTimeFieldauto_now_add=TrueCreation time
update_timeDateTimeFieldauto_now=TrueUpdate time

commodity list

  • Model class name:GoodsCategory;Table name:df_goods_category
Field nameField typefield optionField description
idIntegerFieldprimary_key=TruePhotoID
nameCharFieldmax_length=20Name of commodity category
logoCharFieldmax_length=100Commodity category identification
imageImageFieldupload_to=”category”Picture of commodity category

> commodity SKU table

  • Model class name:GoodsSKU;Table name:df_goods_sku
Field nameField typefield optionField description
idIntegerFieldprimary_key=TruePhotoID
categoryForeignKeyThe foreign key is the GoodsCategory model.Restrict the category of the commodity
goodsForeignKeyThe foreign key is the Goods model.SPU that constrains the product
nameCharFieldmax_length=100Commodity name
titleCharFieldmax_length=200Commodity introduction
unitCharFieldmax_length=10Sales unit
priceDecimalFieldmax_digits=10, decimal_places=2commodity price
stockIntegerFielddefault=0Commodity stock
salesIntegerFielddefault=0Commodity sales
default_imageImageFieldupload_to=”goods”Default picture of merchandise
statusBooleanFielddefault=TrueWhether or not to go online

  • Model class name:IndexGoodsBanner;Table name:df_index_goods
Field nameField typefield optionField description
idIntegerFieldprimary_key=TruePhotoID
skuForeignKeyThe foreign key is the GoodsSKU model.SKU that constrains the product
imageImageFieldupload_to=”banner”Commodity picture
indexSmallIntegerFielddefault=0Broadcast sequence

> home sales promotion display form

  • Model class name:IndexCategoryGoodsBanner;Table name:df_index_category_goods
Field nameField typefield optionField description
idIntegerFieldprimary_key=TruePhotoID
nameCharFieldmax_length=50Activity name
urlURLField Activity link
imageImageFieldupload_to=”banner”Active merchandise pictures
indexSmallIntegerFielddefault=0Active commodity order

order form

  • Model class name:OrderGoods;Table name:df_order_goods
Field nameField typefield optionField description
idIntegerFieldprimary_key=TruePhotoID
orderForeignKeyThe foreign key is the OrderInfo model.Which commodity order is the constraint?
skuForeignKeyThe foreign key is the GoodsSKU model.SKU for ordering goods
countIntegerFielddefault=1Order quantity
priceDecimalFieldmax_digits=10, decimal_places=2item pricing
commentTextFielddefault=””Evaluation information

> model class specification.

from django.db import models
from django.contrib.auth.models import AbstractUser
from utils.models import BaseModel
from django.conf import settings
from goods.models import GoodsSKU
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer

class User(AbstractUser, BaseModel):
    """The user "" "Class Meta:Db_table = "df_users"Def generate_active_token (self):"""Generate activation token" ""Serializer = Serializer (settings.SECRET_KEY, 3600)Token = serializer.dumPS ({"confirm": self.id}) self.id} returns to typeReturn token.decode ()Class Address (BaseModel):"" "address" "" "User = models.ForeignKey (User, verbose_name= "user")Receiver_name = models.CharFielD (max_length=20, verbose_name= "Recipient")Receiver_mobile = models.CharField (max_length=11, verbose_n)Ame= "contact phone")Detail_addr = models.CharField (max_length=256, verbose_name= "detailed address")Zip_code = mOdels.CharField (max_length=6, verbose_name= "zip code")Class Meta:Db_table = "df_address"

  


from django.db import models
from utils.models import BaseModel
from tinymce.models import HTMLField

class GoodsCategory(BaseModel):
    """Commodity category table"""
    name = models.CharField(max_length=20, verbose_name="Name")
    logo = models.CharField(max_length=100, verbose_name="Identification")
    image = models.ImageField(upload_to="category", verbose_name="picture")

    class Meta:
        db_table = "df_goods_category"
        verbose_name = "Category of goods"  # adminSite use
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Goods(BaseModel):
    """Commodity SPU table"""
    name = models.CharField(max_length=100, verbose_name="Name")
    desc = HTMLField(verbose_name="Detailed introduction", default="", blank=True)

    class Meta:
        db_table = "df_goods"
        verbose_name = "commodity"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class GoodsSKU(BaseModel):
    """Commodity SKU table"""
    category = models.ForeignKey(GoodsCategory, verbose_name="category")
    goods = models.ForeignKey(Goods, verbose_name="commodity")
    name = models.CharField(max_length=100, verbose_name="Name")
    title = models.CharField(max_length=200, verbose_name="brief introduction")
    unit = models.CharField(max_length=10, verbose_name="Sales unit")
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="Price")
    stock = models.IntegerField(default=0, verbose_name="Stock")
    sales = models.IntegerField(default=0, verbose_name="Sales volume")
    default_image = models.ImageField(upload_to="goods", verbose_name="picture")
    status = models.BooleanField(default=True, verbose_name="Whether or not to go online")

    class Meta:
        db_table = "df_goods_sku"
        verbose_name = "Commodity SKU"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class GoodsImage(BaseModel):
    """Commodity picture"""
    sku = models.ForeignKey(GoodsSKU, verbose_name="Commodity SKU")
    image = models.ImageField(upload_to="goods", verbose_name="picture")

    class Meta:
        db_table = "df_goods_image"
        verbose_name = "Commodity picture"
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.sku)


class IndexGoodsBanner(BaseModel):
    """Homepage display"""
    sku = models.ForeignKey(GoodsSKU, verbose_name="Commodity SKU")
    image = models.ImageField(upload_to="banner", verbose_name="picture")
    index = models.SmallIntegerField(default=0, verbose_name="order")

    class Meta:
        db_table = "df_index_goods"
        verbose_name = "Home page merchandise"
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.sku)


class IndexCategoryGoodsBanner(BaseModel):
    """Homepage classification merchandise display"""
    DISPLAY_TYPE_CHOICES = (
        (0, "Title"),
        (1, "picture")
    )
    category = models.ForeignKey(GoodsCategory, verbose_name="Category of goods")
    sku = models.ForeignKey(GoodsSKU, verbose_name="Commodity SKU")
    display_type = models.SmallIntegerField(choices=DISPLAY_TYPE_CHOICES, verbose_name="Display type")
    index = models.SmallIntegerField(default=0, verbose_name="order")

    class Meta:
        db_table = "df_index_category_goods"
        verbose_name = "Homepage classification display merchandise"
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.sku)


class IndexPromotionBanner(BaseModel):
    """Home sales promotion exhibition"""
    name = models.CharField(max_length=50, verbose_name="Activity name")
    url = models.URLField(verbose_name="Active connection")
    image = models.ImageField(upload_to="banner", verbose_name="picture")
    index = models.SmallIntegerField(default=0, verbose_name="order")

    class Meta:
        db_table = "df_index_promotion"
        verbose_name = "Home page promotion activities"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

 


 

from django.db import models
from utils.models import BaseModel
from users.models import User, Address
from goods.models import GoodsSKU

class OrderInfo(BaseModel):
    """Order information"""
    PAY_METHODS = {
        1: "Cash on Delivery",
        2: "Alipay",
    }

    PAY_METHODS_ENUM = {
        "CASH": 1,
        "ALIPAY": 2
    }

    PAY_METHOD_CHOICES = (
        (1, "Cash on Delivery"),
        (2, "Alipay"),
    )

    ORDER_STATUS = {
        1: "To be paid",
        2: "Pending delivery",
        3: "Goods to be received",
        4: "To be evaluated",
        5: "Completed",
    }

    ORDER_STATUS_ENUM = {
        "UNPAID": 1,
        "UNSEND": 2,
        "UNRECEIVED": 3,
        "UNCOMMENT": 4,
        "FINISHED": 5
    }

    ORDER_STATUS_CHOICES = (
        (1, "To be paid"),
        (2, "Pending delivery"),
        (3, "Goods to be received"),
        (4, "To be evaluated"),
        (5, "Completed"),
    )

    order_id = models.CharField(max_length=64, primary_key=True, verbose_name="Order number")
    user = models.ForeignKey(User, verbose_name="Single user")
    address = models.ForeignKey(Address, verbose_name="Harvest address")
    total_count = models.IntegerField(default=1, verbose_name="Total number of goods")
    total_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="Total commodity value")
    trans_cost = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="freight")
    pay_method = models.SmallIntegerField(choices=PAY_METHOD_CHOICES, default=1, verbose_name="Payment method")
    status = models.SmallIntegerField(choices=ORDER_STATUS_CHOICES, default=1, verbose_name="Order status")
    trade_id = models.CharField(max_length=100, unique=True, null=True, blank=True, verbose_name="Payment number")

    class Meta:
        db_table = "df_order_info"


class OrderGoods(BaseModel):
    """Order goods"""
    order = models.ForeignKey(OrderInfo, verbose_name="Order")
    sku = models.ForeignKey(GoodsSKU, verbose_name="Order goods")
    count = models.IntegerField(default=1, verbose_name="Number")
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="Unit Price")
    comment = models.TextField(default="", verbose_name="Evaluation information")

    class Meta:
        db_table = "df_order_goods"