Skip to content

新品需求

新品需求接口文档

项目需求变更申请

变更概述

当用户所需的商品不在站点的商品库时,可向站点提出「新品需求」

在 bshop 的用户管理界面添加:「新品需求」入口
在 station 中添加:开启和管理「新品需求」入口

本需求涉及到两个工程:bshop 和 station
bshop 的涉及的代码写在「bshop/website/product/views/new_merchandise.py」中
station 中涉及的代码写在「station/website/product/views/new_merchandise.py」中

有数据库的改动

影响功能列表

bshop
    > 用户界面新增入口: 新品需求
        > 查看 当前用户已提交的新品需求
        > 增加 新增新品需求给站点
station
    > 系统/店铺运营设置: 新品需求入口开关
    > 用户管理/角色管理<业务平台>/角色权限: 查看和修改新品需求
    > 商品/商品管理: 新品需求管理入口
        > 查看 当前登录站点的新品需求列表
        > 修改 新品需求状态<添加/拒绝>
        > 导出 当前登录站点的新品需求列表

后端模块变更

bshop
    > 新增接口
        > product/station/list 
        > product/image/upload
        > product/new_merchandise/list
        > product/new_merchandise/create
station
    > 新增接口
        > product/new_merchandise/list
        > product/new_merchandise/update
        > product/new_merchandise/export

其他接口的修改请参考接口文档:新品需求

前端模块变更

> 待添加

数据库变更

> mongo > product 
    新增集合 new_merchandise_demand
> mysql > xnn_core_product_2
    修改表格 auth_permission 
        增加两种角色权限:查看新品需求,修改新品需求
    修改表格 tbl_permission_class
        增加一种二级权限分类:新品需求

数据库改动

「新增表」新品需求数据表: new_merchandise_demand

new_merchandise_demand 表用于存储商户的新品需求,以及需求的处理状态等数据

{
    id              String       需求商品id(主键)
    station_id      String       站点id--> cms_key 绑定的站点
    username        String       用户名称
    address_id      String       店铺id
    res_name        String       店铺名称
    create_time     DateTime     创建时间
    name            String       商品名称
    desc            String       商品描述
    image           String       商品图片
    status          Int          商品需求的处理状态「1 待处理,2 已添加,3 已拒绝」
    modify_time     DateTime     修改时间
    delete_time     DateTime     删除时间
}

数据表(集合)的位置:mongo -> product -> new_merchandise_demand

「修改表」角色权限表

业务平台 station 涉及的权限表在「mysql -> xnn_core_product_2」库中

在「tbl_permission_class」表中添加一条 level2 数据
    SQL 语句:
        INSERT INTO 
            tbl_permission_class 
        SET
            id=50,                  # 这里的 id 需要在执行操作的时候根据表格中的数据id设定
            name='新品需求',
            name_en='demand for new merchandise',
            level=2,
            parent_id=1,
            create_time=NOW(),        
            update_time=NOW(),
            `delete`=0,             # 这里的 delete 关键字需要转义一下,否则会报错
            sort_no=525;

    # sort_no   决定页面展示的位置
        level1: 商品 sort_no:5
        商品下的 level2
        报价单管理   505
        商品库索引   510
        营销        515
        积分        520
        新品需求     525 

在「django_content_tyoe」表中插入一条数据
    SQL 语句:
        INSERT INTO 
            django_content_type 
        SET
            id=76,                   # 这里的 id 需要在执行操作的时候根据表格中的数据id设定
            name='新品需求',
            app_label='demand_for_new_merchandise',
            model='demand_for_new_merchandise';

在「auth_permission」权限表中添加两条数据
    SQL 语句:
    # 注意: id 值要根据表中的实际数据修改
        INSERT INTO auth_permission
            (id,name,name_en,codename,content_type_id,level2_id)
        VALUE
            (602,'查看新品需求','view demand for new merchandise','view_demand_for_new_merchandise',76,50),
            (603,'编辑新品需求','edit demand for new merchandise','edit_demand_for_new_merchandise',76,50);

    content_type_id 
        关联的是 django_content_type 这张表的 id -> 76 新品需求
    level2_id  
        关联的是 tbl_permission_class 中的 id -> 48 新品需求

给 station 角色添加权限
    auth_role 和 auth_permission 是多对多的关系,在 auth_role_permission 表中体现

bshop 工程

product/image/upload 「新增接口:商品需求描述图片上传」

接口:
    product/image/upload
class:
    website/product/new_merchandise_demand.py/UploadImageView
方法:
    POST
请求:
    image_file    M    Binary    商品需求描述图片
响应:
    code          M    Int       状态码
    msg           M    String    状态信息
    data          M    Dict      图片存储信息字典
        {
            image_url      M    String    图片的url
            img_path_id    M    String    图片的名称
        }
示例:
    请求:
        {"image_file": (binary)}
    响应:
        {
            "code": 0,
            "msg": "ok",
            "data":
                {
                    "image_url": "http://gmfiles-1251112841.file.myqcloud.com/new_merchandise_demand_pic/50e7682e36396b36.png"
                    "img_path_id": "50e7682e36396b36.png"
                }
        }
说明:
    这个需要在腾讯云上新建一个文件夹来保存,图片的要限制在 1MB 以内

product/station/list 「新增接口:使用 cms_key 和 店铺绑定的 salemenu_id 获取服务站点」

接口:
    product/station_id/list
class:
    website/product/new_merchandise_demand.py/GetStationIDView
方法:
    GET
请求:
    无
响应:
    code          M    Int       状态码
    msg           M    String    状态信息
    data          M    Dict      cms_key 绑定的站点信息列表
        {
            station_id(站点id): name(站点名称),
            ...
        }
示例:
    请求:
        无
    响应:
        {
            "code": 0,
            "msg": "ok",
            "data":
                {
                    "T7936": "喵喵"
                }
        }
说明:
    cms_key 可以从 cookie 中获取,address_id 可以从选择的 request 中获取
    通过 cms_key 进入 station「mongo」中查询绑定的 station_id 和 name
    通过 address_id 进入 tbl_address_salemenu 中查询绑定的 station_id,然后过滤第一步中获得数据
    如果站点并未开启这个入口,那么站点的id不应该出现返回的数据中

product/new_merchandise/creat 「新增接口:新建商品需求」

接口:
    product/new_merchandise/create
class:
    website/product/new_merchandise_demand.py/CreateNewMerchandiseDemandView
方法:
    POST
请求:
    station_id    M    String    站点id(服务仓)
    name          M    String    商品名
    desc          O    String    商品描述
    image         O    String    商品图片url

响应:
    code          M    Int       状态码
    msg           M    String    状态消息
    data
示例:
    请求:
        {
            "station_id": "T7936",
            "name": "22222222222",
            "desc": "33333333333",
            "image": "http://gmfiles-1251112841.file.myqcloud.com/new_merchandise_demand_pic/50e7682e36396b36.png"
        }
    响应:
        {
            "code": 0,
            "msg": "ok",
            "data": "需求创建成功"
        }
说明:
    新建商品需求时,先根据「cms_key」获取绑定的「站点id」数据
    图片上传:需要用图片上传的接口,将图片保存的地址放在请求的参数中
    username 从 request.user 获取
    店铺id 也可以从 request 中获取

product/new_merchandise/list 「新增接口:bshop 中获取商品需求列表」

接口:
    product/new_merchandise/list
class:
    website/product/new_merchandise_demand.py/ListNewMerchandiseDemandView
方法:
    GET
请求:
    分页参数
    page_obj      O    String    起始页(不包含),默认第0页
    reverse       O    Bool      是否反向查询。1:是,0:不是。默认为否。
    limit         O    Int       返回条数,默认10。传0表示返回所有数据。
    offset        O    Int       查询起点偏移条数,默认 0 
    peek          O    Int       是否需要 peek,默认不需要 peek。peek 必须大于 limit。
    count         O    Bool      是否需要 count,默认不需要 count

响应:
    code          M    Int       状态码
    msg           M    String    状态消息
    data          M    List      商品需求列表
        [
            {
                res_name     M    String    店铺名字 
                name         M    String    新品名      
                desc         M    String    新品描述
                image        M    String    新品图片
                status       M    int       需求处理状态
            },
            ...
        ]
    pageination   M    dict      分页信息
        {
            peek       O   Int      前端传 peek 的话,后端就会返回这个字段
            more       M   Bool     是否有更多数据
            page_obj   M   String
            count      O   Int      前端传 count 的话,后端就会返回这个字段
        }
示例:
    请求:
        {
            "limit": 5,
            "more": false
        }
    响应:
        {
            "code": 0,
            "msg": "ok",
            "data": 
                [
                    {
                        "desc": "33333333333"
                        "image": "http://gmfiles-1251112841.file.myqcloud.com/new_merchandise_demand_pic/50e7682e36396b36.png"
                        "name": "22222222222"
                        "res_name": "海底捞南头店"
                        "status": 1
                    },
                    ...
                ],
            "pagination":
                {
                    "more": true,
                    "page_obj": "{"next": {"create_time": {"$date": 1565270256751}}, "previous": {"create_time": {"$date": 1565350020174}}}"
                }
        }
说明:
    根据「username」来获取所有已添加的商品需求,有分页需要
    username 从 request 中获取

station 工程

product/new_merchandise/list 「新增接口:station 中获取商品需求列表」

接口:
    product/new_merchandise/list
class:
    website/product/new_merchandise_demand.py/ListNewMerchandiseDemandView
方法:
    POST
请求:
    status        O    Int         需求状态
    start_time    O    Date        起始时间
    end_time      O    Date        结束时间
    search_text   O    String      搜索关键字

    分页参数
    page_obj      O    String      起始页(不包含),默认第0页
    reverse       O    Bool        是否反向查询。1:是,0:不是。默认为否。
    limit         O    Int         返回条数,默认10。传0表示返回所有数据。
    offset        O    Int         查询起点偏移条数,默认 0 
    peek          O    Int         是否需要 peek,默认不需要 peek。peek 必须大于 limit。
    count         O    Bool        是否需要 count,默认不需要 count
响应:
    code          M    Int         状态码
    msg           M    String      状态消息
    data          M    List        商品需求列表
        [
            {
                _id            M    String     需求id
                username       M    String     账户名(bshop 登录账号)
                k_name         M    String     公司名(bshop 账号名<昵称>)
                k_id           M    String     账户id 
                res_name       M    String     店铺名(商户名)
                name           M    String     需求名称
                desc           M    String     需求描述
                image          M    String     描述图片url
                create_time    M    Date       需求创建时间 
            },
            ...
        ]
    pageination   M    Dict        分页信息
        {
            peek         O    Int        前端传 peek 的话,后端就会返回这个字段
            more         M    Bool       是否有更多数据
            page_obj     M    String
            count        O    Int        前端传 count 的话,后端就会返回这个字段
        }
示例:
    请求:
        {
            "start_time": "2019-08-08,
            "end_time": "2019-08-08",
            "ids": ["5d4b92a1357a1656896ac40d", "5d4b92a1357a1656896ac40c"],
            "status": 2
        }
    响应:
        {
            "pagination": {
                "page_obj": "{\"next\": {}, \"previous\": {\"_id\": {\"$oid\": \"5d4b92a1357a1656896ac40d\"}, \"create_time\": {\"$date\": 1565262625708}}}",
                "more": false
            },
            "data": 
                [
                    {
                        "k_id": "K73655",
                        "name": "gCRt4",
                        "res_name": "海底捞南头店",
                        "_id": "5d4b92a1357a1656896ac40d",
                        "image": "http://gmfiles-1251112841.file.myqcloud.com/new_merchandise_demand_pic/5737e7c44babda73.png",
                        "username": "mmsh01",
                        "desc": "tJAhK7WTS1Ynlzw",
                        "status": 2,
                        "k_name": "商户1",
                        "create_time": "2019-08-08"
                    },
                    ...
                ],
            "code": 0,
            "msg": "ok"
        }
说明:
    查询结果按日期倒序

product/new_merchandise/updata 「新增接口:station 修改需求列表」

接口:
    product/new_merchandise/updata
class:
    website/product/new_merchandise_demand.py/UpdateNewMerchandiseDemandView
方法:
    POST
请求:
    new_status    M    Int         需求处理状态(将要更改成的状态)「2 已添加  3 已拒绝」
    status        O    Int         需求状态(搜索框中传入的值)
    ids           O    List        需要修改商品需求id列表
        [
            id1, id2....
        ]
    start_time    O    Date        起始时间
    end_time      O    Date        结束时间
    search_text   0    String      搜索关键字
响应:
    code          M    Int         状态码
    msg           M    String      状态消息
    data
    ...
示例:
    请求:
        {
            "start_time": "2019-08-08,
            "end_time": "2019-08-08",
            "ids": ["5d4b92a1357a1656896ac40d", "5d4b92a1357a1656896ac40c"],
            "new_status": 2
        }
    响应:
        {
            "data": "所选需求处理成功",
            "code": 0,
            "msg": "ok"
        }
说明:
    非全选,detail 列表中存储的是勾选的 m_ids
    全选的情况下,返回的是筛选条件,需要通过筛选条件查询
    station_id 可以在 request 中获取

product/new_merchandise/export 「新增接口:商品需求数据导出功能」

接口:
    product/new_merchandise/export
class:
    website/product/new_merchandise_demand.py/ExportNewMerchandiseDemandView
方法:
    POST
请求:
    start_time    O    Date        起始时间
    end_time      O    Date        结束时间
    search_text   O    String      搜索关键字
响应:
    code          M    Int         状态码
    msg           M    String      状态消息
    data          M    List        商品需求列表
        [
            {
                _id            M    String     需求id
                username       M    String     账户名(bshop 登录账号)
                k_name         M    String     公司名(bshop 账号名<昵称>)
                k_id           M    String     账户id 
                res_name       M    String     店铺名(商户名)
                name           M    String     需求名称
                desc           M    String     需求描述
                image          M    String     描述图片url
                create_time    M    Date       需求创建时间
                status         M    Int        需求状态
                station_id     M    String     站点id
            },
            ...
        ]
示例:
    请求:
        {
            'start_time': "2019-08-08",
            'end_time': "2019-08-08"
        }
    响应:
        {
            "code": 0,
            "msg": "ok",
            "data":
                [
                    {
                        "k_id": "K73655",
                        "name": "gCRt4",
                        "res_name": "海底捞南头店",
                        "_id": "5d4b92a1357a1656896ac40d",
                        "username": "mmsh01",
                        "station_id": "T7936",
                        "desc": "tJAhK7WTS1Ynlzw",
                        "address_id": 77839,
                        "status": 2,
                        "create_time": "2019-08-08",
                        "k_name": "商户1"
                    },
                    ...
                ]
        }
说明:
    station_id 在 request 中获取

customized 「修改接口:获取 station 店铺运营设置」

接口:
    customized
class:

方法:
    GET
请求:
    无
响应:
    code          M    Int         状态码
    msg           M    String      状态消息
    data          M    Dict        响应数据
        {
                is_open_new_merchandise         M    Int             新增:是否开启新品需求
          all_banner_ids                  M    List<String>    轮播图片的id列表
              [
                  banner_id1, banner_id2, ....
              ]
          all_banner_urls                 M    List<String>    轮播图片的url列表
              [
                  banner_url1, banner_url2, ....
              ]
          app_secret                      M    String           
          appid                           M    String
          banner                          M    String
          banners                         M    List<String>
              [
                  banner_id1, banner_id2, ....
              ]
          banners_with_url                M    List<Dict>
              [
                  {
                      id                  M    String
                      name                M    String
                      url                 M    String
                  }
              ]
          customer_regist_type            M    Int           商户注册类型
          daily_selection_type            M    Int    
          default_salemenu_id             M    String        默认报价单
          exchange_reward_min_money       M    String        起兑积分
          homepage                        M    List             
          is_customiszed                  M    
          is_need_invitation_code         M    Int           是否需要注册码
          is_open_manage_stock            M    Int
          is_open_order_edit              M    Int           是否开启下单后商户自主改单
          is_open_sku_detail              M    Int           是否开启商品详情
          is_user_change_own_pwd          M    Int           是否开启自助修改密码
          is_verify_phone_on_register     M    Int           是否验证手机号码
          key                             M    String        cms_key
          label_size                      M    String        标签图标大小
          labels                          M    List<Dict>    标签位数据
              [
                  {
                      rank                M    Int
                      name                M    String
                      show_method         M    Int
                      url                 M    String 
                      promotion_id        M    Int
                  },
                  ...
              ]

          logo                            M    String         店铺logo
          manager                         M    String         管理站点id
          name                            M    String         管理员名称
          optional_receive_way            M    Int            收货方式
          order_edit_time_limit           M    String         订单修改时间限制
          phone                           M    String         客服电话
          show_daily_selection            M    
          show_driver_location            M    Int            司机定位
          support_point_exchange          M    Int            是否开启积分兑换
          title                           M    String         店铺名称
        }
示例:
    请求:
        无
    响应:
        {   
            "code": 0,
            "msg": "ok",
            "data":
                {
                    "all_banner_ids": 
                        [
                            "69fd483a7dba7db3.jpeg", ...
                        ],
                    "all_banner_urls": 
                        [
                            "//img.guanmai.cn/station_pic/69fd483a7dba7db3.jpeg", ...
                        ],
                    "app_secret": "d4fbdce4fe3efbfbd6506d64896cf111",
                    "appid": "wx4b71f3d3b055bdee",
                    "banner": "//img.guanmai.cn/station_pic/gm_banner.jpg",
                    "banners": 
                        [
                            "sha1_6f6bd1497f8e5c1db37593110af99437589a570f.jpg", ...
                        ],
                    "banners_with_url": 
                        [
                            {
                                "name": "//img.guanmai.cn/station_pic/sha1_6f6bd1497f8e5c1db37593110af99437589a570f.jpg",
                                ...
                            },
                            ...
                        ],
                    "customer_regist_type": 1,
                    "default_salemenu_id": "S12731",
                    "exchange_reward_min_money": 0,
                    "homepage":
                        [
                            {
                                "ad_imgs_with_url": 
                                    [
                                        {
                                            "img_id": "04bff905a46054cd.jpeg"
                                            "img_url": "//img.guanmai.cn/station_pic/04bff905a46054cd.jpeg"
                                            "url": ""
                                         },
                                         ...
                                    ],
                                "category": "ad",
                                "type": 1
                            },
                            ...
                        ],
                    "is_customiszed": true,
                    "is_need_invitation_code": 0,
                    "is_open_manage_stock": 0,
                    "is_open_new_merchandise": 1,       # 新增的字段
                    "is_open_order_edit": 1,
                    "is_open_sku_detail": 1,
                    "is_user_change_own_pwd": 0,
                    "is_verify_phone_on_register": 0,
                    "key": "miaotest",
                    "label_size": "large",
                    "labels": 
                        [
                            {
                                "children":
                                    [
                                        {
                                            "first_category_id": "A7662",
                                            "id": "B37081",
                                            "name": "蛋品类",
                                            "rank": 0
                                        },
                                        ...
                                    ],
                                "id": "A7662"
                                "name": "蛋品类"
                                "rank": 0
                                "url": "//img.guanmai.cn/icon/icon-veg.4fa23256.png"
                            },
                            ...
                        ],
                    "logo": "//img.guanmai.cn/station_pic/3871681768a6188a.jpeg",
                    "manager": "T7936",
                    "name": "喵喵总仓",
                    "optional_receive_way": 1,
                    "order_edit_time_limit": 999,
                    "phone": "611928888",
                    "price_diversification": 1,
                    "show_daily_selection": true,
                    "show_driver_location": 0,
                    "support_point_exchange": 0,
                    "title": "1233"
                }
        }
说明:
    在响应中增加了一个字段
        is_open_new_merchandise:用于标识是否在 bshop 中开启新品需求

        目前表中还没有这个字段,返回的响应中的该字段是代码中添加的,默认关闭。
        用户通过该接口保存数据后,数据库会更新写入该字段。

    数据保存在「mongo -> xnn_core_product_2 -> customized_info」表中

customized/update 「修改接口:更新 station 店铺运营设置」

接口:
    customized/update
class:

方法:
    POST
请求:
    title                            M    String   店铺名称
    phone                            M    Int      店铺号码
    default_salemenu_id              M    Sting    默认报价单
    customer_regist_type             M    Int      用户注册类型
    optional_receive_way             M    Int      收货方式
    order_edit_time_limit            M    Int      订单修改有效时间

    # 带开启的参 「0 -> 关闭  1 -> 开启」
    is_need_invitation_code          M    Int      开启邀请码
    is_open_sku_detail               M    Int      开启商品详情
    is_open_order_edit               M    Int      开启订单编辑
    is_open_manage_stock             M    Int      开启用户自主管理进销存
    is_user_change_own_pwd           M    Int      开启用户自助修改密码
    is_verify_phone_on_register      M    Int      开启注册时验证手机
    support_point_exchange           M    Int      开启积分兑换
    show_driver_location             M    Int      开启显示司机定位
    price_diversification            M    Int      开启价格多样化

    增加一个参数:
    is_open_new_merchandise          M    Int      开启新品需求
响应:
    code                             M    Int      状态码
    msg                              M    String   状态消息
    data
示例:
    请求:
        {
            "title": 1233,
            "phone: 611928888",
            "is_need_invitation_code": 0,
            "is_open_sku_detail": 1,
            "is_open_order_edit": 1,
            "is_open_manage_stock": 0,
            "is_open_new_merchandise": 1,
            "is_user_change_own_pwd": 0,
            "is_verify_phone_on_register": 0,
            "customer_regist_type": 1,
            "optional_receive_way": 1,
            "support_point_exchange": 0,
            "show_driver_location": 0,
            "order_edit_time_limit": 999,
            "default_salemenu_id": S12731,
            "price_diversification": 1
        }
    响应:
        {
            {   
            "code": 0,
            "msg": "ok",
            "data": null
        }

角色权限的修改

数据库的的配置可查看:权限、角色和账号

登录 admin 为站点添加权限