Skip to content

批量下单

数据库 mongodb

async_task 异步任务表

{
    _id string 任务ID
    status int 任务状态(1:提交、2:执行中、3:已完成、4:已关闭)
    create_time datetime 提交时间
    modify_time datetime 更新时间
    start_time datetime 开始执行时间
    end_time datetime 完成时间
    type int 任务类型(1:下单任务)
    details dict 具体任务内容
    {
        station_id string 提交任务的站点ID
        user_id int 提交任务的用户ID
        time_config_id string 服务时间ID
        data list 商户下单信息
        [{
            status int 执行状态(1:未执行;2:执行中;3:已完成)
            result dict 下单结果
            {
                code int 结果状态(0:成功;1:失败;2:超时)
                msg string 保存执行失败提示
                data dict 失败信息或成功的订单ID
            }
            address_id int 店铺ID
            uid int 商户ID
            receive_begin_time string 收货开始时间
            receive_end_time string 收货结束时间
            cart list 下单商品信息
            [{
                sku_id string 商品ID
                amount float 下单数量
                unit_price float 单价
                spu_remark string 商品备注
                spu_id string spuID
            }]
        }]
    }
}

接口

/station/order/batch/export 解析下单excel

接口: /station/order/batch/export
Method: GET
请求:
    time_config_id M string 时间配置ID
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息
    excel文件

/station/order/batch/upload 解析下单excel

接口: /station/order/batch/upload
Method: POST
请求:
    time_config_id M string 时间配置ID
    excel文件
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息
    data M dict 解析的数据
    {
        task_id M string 任务ID
        details M list 商户和商品数据
        [{
            address_id M string 商户ID
            id M string 用户ID
            resname M string 店铺名
            receiver_name M string 收货人姓名
            receiver_phone M string 收货人电话
            address M string 收货地址
            code M int 解析结果(0:正常;1:有错误)
            msg M string 错误提示
            skus M list 商品列表
            [{
                id M string 商品ID
                code M int 解析结果(0:正常;1:有错误)
                msg M string 错误提示
                name M string 商品名
                desc M string 商品描述
                supplier_name M string 供应商名称
                spu_id M string spu ID
                category_id_1 M string 一级分类ID
                category_title_1 M string 一级分类名
                category_id_2 M string 二级分类ID
                category_title_2 M string 二级分类名
                station_id M string 站点ID
                salemenu_id M string 销售单ID
                sale_unit_name M string 售卖单位
                std_unit_name M string 标准单位
                unit_price M float 单价
                sale_price M float 售卖价
                sale_ratio M float 规格
                sale_num_least float 最小下单数量
                outer_id string M string 自定义编码
                is_price_timing M bool 是否实价
                quantity M float 下单数量
                spu_remark M string 商品备注
            }]
        }]
    }
逻辑:
    解析excel,查询商户和商品信息,返回数据
    检查商户是否跟站点下的销售单有绑定关系
    检测商品是否属于对应时间配置的销售单

/station/order/batch/submit 提交批量下单任务

接口名: /station/order/batch/submit
Method: POST
请求:
    task_id M string 任务ID
    time_config_id M string 服务时间ID
    data M list 商户数据
    [{
        address_id M int 店铺ID
        uid M int 商户ID
        receive_begin_time M string 收货开始时间
        receive_end_time M string 收货结束时间
        details list 下单商品信息
        [{
            sku_id M string 商品ID
            amount M float 下单数量
            unit_price M float 单价
            spu_remark M string 商品备注
            spu_id M string spuID
        }]
    }]
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息
    data O string 返回任务ID
逻辑:
    提交下单任务

/station/order/batch/create 执行下单任务

接口名: /station/order/batch/create
Method: POST
请求:
    station_id M string 站点ID
    auth_key M string 授权key
    address_id M int 店铺ID
    uid M int 商户ID
    time_config_id M string 服务时间ID
    receive_begin_time M string 收货开始时间
    receive_end_time M string 收货结束时间
    details list 下单商品信息
    [{
        sku_id M string 商品ID
        amount M float 下单数量
        unit_price M float 单价
        spu_remark M string 商品备注
        spu_id M string spuID
    }]
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息
    data O string 返回错误信息
    {
        invalid_sku O list 无效的sku信息
        [{
            sku_id M string 商品ID
            name M string 商品名称
            count M int 数量
        }]
    }
逻辑:
    执行下单任务

/station/order/batch/result 查看下单结果

接口: /station/order/batch/result
Method: GET
请求:
    task_id M string 任务ID
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息
    data M dict 解析的数据
    {
        task_id M string 新的任务ID
        details M list 商户和商品数据
        [{
            address_id M string 商户ID
            id M string 用户ID
            resname M string 店铺名
            receiver_name M string 收货人姓名
            receiver_phone M string 收货人电话
            address M string 收货地址
            code M int 解析结果(0:正常;1:有错误)
            msg M string 错误提示
            skus M list 商品列表
            [{
                id M string 商品ID
                code M int 解析结果(0:正常;1:有错误)
                msg M string 错误提示
                name M string 商品名
                desc M string 商品描述
                supplier_name M string 供应商名称
                spu_id M string spu ID
                category_id_1 M string 一级分类ID
                category_title_1 M string 一级分类名
                category_id_2 M string 二级分类ID
                category_title_2 M string 二级分类名
                station_id M string 站点ID
                salemenu_id M string 销售单ID
                sale_unit_name M string 售卖单位
                std_unit_name M string 标准单位
                unit_price M float 单价
                sale_price M float 售卖价
                sale_ratio M float 规格
                sale_num_least float 最小下单数量
                outer_id string M string 自定义编码
                is_price_timing M bool 是否实价
                quantity M float 下单数量
                spu_remark M string 商品备注
            }]
        }]
    }
逻辑:
    查看下单结果,返回下单失败的商户跟商品信息

/station/order/batch/amend 修改下单任务

接口: /station/order/batch/amend
Method: POST
请求:
    task_id M string 任务ID
    address_id M int 商户ID
    order_id M string 订单ID
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息

/async_task/list 查看异步任务列表

接口: /async_task/list
Method: GET
请求:
    无
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息
    data M dict 任务列表信息
    [{
        id M string 任务ID
        status M int 任务状态
        status_name M string 状态名称
        type M int 任务类型
        type_name M string 任务类型名称
        create_time M datetime 任务提交时间
    }]

/async_task/detail 查看异步任务详情

接口: /async_task/detail
Method: GET
请求:
    task_id M string 任务ID
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息
    data M dict 任务信息
    {
        id M string 任务ID
        status M int 任务状态
        status_name M string 状态名称
        type M int 任务类型
        type_name M string 任务类型名称
        create_time M string 任务提交时间
        msg M string 提示信息
        start_time M string 任务开始时间
        end_time M string 任务开始时间
        total_num M int 总数
        finish_num M int 已完成数
        success_num M int 成功数
    }

/async_task/close 关闭任务

接口: /async_task/close
Method: POST
请求:
    task_id M string 任务ID
响应:
    code M int 0为成功,其它为失败
    msg M string 错误提示信息

gm_task

执行批量下单

参数:
    task_id M string 任务ID
逻辑:
    获取任务信息
    执行任务
    写入执行结果

脚本

检测任务执行状态

查看任务是否超时未执行,超时发送邮件通知