# jiaozi **Repository Path**: techbrew/jiaozi ## Basic Information - **Project Name**: jiaozi - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-12 - **Last Updated**: 2021-08-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 1. 运行环境 Python3.8 ### 1.1. 安装系统依赖 ```shell script sudo apt-get update sudo apt-get install -y python3-venv build-essential git nano nginx supervisor ``` ### 1.2. 安装 PostgreSQL 数据库 ```shell script # 添加 key sudo apt-get install curl ca-certificates gnupg curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - # 添加源 sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' # 安装数据库 sudo apt-get update sudo apt-get install postgresql-11 ``` ### 1.3. 更新 pip 及安装 uwsgi ```shell script pip3 install --upgrade setuptools pip pip install uwsgi ``` ### 1.4. 安装 redis ```shell script sudo apt update sudo apt install redis-server nano /etc/redis/redis.conf sudo service redis restart ``` ## 2. 服务安装 ### 2.1. 进入目录,拉取代码 ```sh cd /opt git clone https://gitee.com/techbrew/jiaozi.git ``` ### 2.2. 进入项目路径 ```sh cd /opt/jiaozi ``` ### 2.3. 创建虚拟环境并启动虚拟环境 ```sh python3 -m venv venv source venv/bin/activate ``` ### 2.4. 安装依赖 ```sh pip install --upgrade setuptools pip pip install -r requirements.txt ``` ### 2.5. 启动 uwsgi ```shell script cd /opt/jiaozi && source venv/bin/activate uwsgi --ini /opt/jiaozi/jiaozi_uwsgi.ini uwsgi --ini /opt/jiaozi_home/jiaozi_home_uwsgi.ini ``` ### 2.6. 更新服务 ```shell script cd /opt/jiaozi && source venv/bin/activate git pull python3 manage.py migrate ps auxw | grep jiaozi_uwsgi uwsgi --reload /opt/jiaozi/uwsgi/uwsgi.pid ps auxw | grep jiaozi_uwsgi ps auxw | grep jiaozi_home_uwsgi uwsgi --reload /opt/jiaozi_home/uwsgi/uwsgi.pid ps auxw | grep jiaozi_home_uwsgi ``` ### 2.7. Supervisor 服务配置 输入以下命令可得到配置文件: ```sh echo_supervisord_conf ``` 或者: ```shell cat /etc/supervisor/supervisord.conf ``` 在目录/etc/supervisor/conf.d/下创建 jiaozi_supervisord.conf ```sh cd /etc/supervisor/conf.d/ ``` 配置文件 ```sh nano /etc/supervisor/conf.d/jiaozi_supervisord.conf ``` supervisor基本命令(后四个命令可以省略“-c supervisor.conf”): ```shell supervisord -c /etc/supervisor/supervisord.conf 通过配置文件启动supervisor ``` ```shell supervisorctl update 更新新的配置到supervisord supervisorctl status 查看状态 supervisorctl reload 重新载入配置文件 supervisorctl start [all]|[x] 启动所有/指定的程序进程 supervisorctl stop [all]|[x] 关闭所有/指定的程序进程 supervisorctl restart uwsgi.product 重新载入配置文件 supervisorctl -c /etc/supervisor/supervisor.conf status 查看状态 supervisorctl -c /etc/supervisor/supervisor.conf reload 重新载入配置文件 supervisorctl -c /etc/supervisor/supervisor.conf start [all]|[x] 启动所有/指定的程序进程 supervisorctl -c /etc/supervisor/supervisor.conf stop [all]|[x] 关闭所有/指定的程序进程 ``` 查看运行状态 ```sh supervisorctl status ``` 安装 redis ## 3. 数据库介绍 ```mermaid flowchart TB VipLevel[会员等级] --> WxUser[用户] WxUser --> UserPoint[用户积分] & FeedBack[用户反馈] & UserAddress[用户地址] VipLevel --> VipSales[会员出售] --> VipSalesOrder((会员销售订单)) WxUser --> ProductSalesOrder & VipSalesOrder ProductStyle[产品风格] -->ProductInfo[产品信息] ProductInfo --> ProductBatch[产品批次] & Banner[置顶广告] ProductBatch --> ProductIn[产品入库] & ProductSales((在售商品)) UserAddress --> ProductSalesOrder((产品销售订单)) --> OrderItem[订单明细] ProductSales --> OrderItem ProductSales -.- ProductCategory[产品归类] MoneyIo -.- ProductSalesOrder VipSalesOrder -.- MoneyIo[收支流水] MoneyIo -.- ProductIn ``` ## 4. 接口说明 需要登录的接口 ```mermaid flowchart LR /api/ --> main main--> wx_login[//api/main/wx_login//] --> 1[用户登录 通过code换取jwt token] main --> get_code[//api/main/get_code//] --> 4[获取短信验证码] main --> bind_mobile[//api/main/bind_mobile//] --> 2[用户绑定手机号] main --> home_page[//api/main/home_page//] --> 5[首页信息接口] main --> feedback[//api/main/feedback//] --> 3[用户反馈接口] /api/ --> user user --> user_address(/api/user/address/) --> 8[用户地址列表及添加] user --> user_address_id(/api/user/address/id/) --> 9[用户地址列表及添加] user --> vip_info(/api/user/vip_info/) --> 12[用户的 VIP 信息获取] /api/ -->product product --> product_sales[//api/product/product_sales//] --> 6[在售产品列表] product --> product_sales_id[//api/product/product_sales/id//] --> 7[在售产品详情] /api/ -->vip vip --> buy_vip(/api/vip/buy_vip/) --> 10[用户购买 VIP 及记录查询] vip --> vip_sales[//api/vip/vip_sales//] --> 11[在售的 VIP 列表] ``` ### 4.1. 登录模块 ```mermaid flowchart TB wx.login[wx.login获取code] --> wx_login[wx_login 获取用户信息 ] --> has_mobile{user是否有mobile} has_mobile -- 是 --> has_login(用户已经注册) has_mobile -- 否 --> show_mobile[显示手机号和验证码输入框] show_mobile --> get_code[get_code 获取短信验证码] get_code --> bind_mobile[bind_mobile 用户绑定手机号] --> has_login ```