Skip to content

货值成本表重构

货值成本表重构

1、mongo中xnn_core_product_2下增加表stock_value_2

索引:station_id, date_time, spu

{
    station_id    string    站点id
    date_time    datetime    时间
    modify_time    datetime    修改时间
    spu_id    string    商品id
    start_stock    double    期初库存    
    start_avg_price    double    期初库存均价
    end_stock    double    期末库存
    end_avg_price    double    期末库存均价
    in_stock_amount    double    入库数量
    in_stock_price    double    入库均价
    out_stock_amount    double    出库数量
    out_stock_price    double    出库均价
    return_stock_amount    double    退货出库
    return_stock_price    double    退货出库均价
    in_return_stock_amount    double    订单退货入库数量
    in_return_stock_price    double    退货入库均价
    increase_stock_amount    double    报溢数量
    increase_stock_price    double    报溢均价
    loss_stock_amount    double    报损数量
    loss_stock_price    double    报损均价
}

2、货值成本搜索接口station/report/value

请求:GET

begin    M    date    起始日期
end    M    date    结束日期
category_id_1    O    list    一级分类
category_id_2    O    list    二级分类
text    O    str    商品搜索字段
limit    O    int    分页数量
reverse    O    int    往前翻页
page_obj    O    str    分页对象
view_type    M    int    查看维度

响应:查看维度可以有一级分类,二级分类,spu,不同的查看维度的响应字段略有差异

当查看维度为spu时:

code:0
msg:ok
data:[
    {
        category_id_1    M    string    一级分类id
        category_id_1_name    M    string    一级分类名
        category_id_2    M    string    二级分类id
        category_id_2_name    M    string    二级分类名
        spu_id    M    string    商品spu_id
        spu_name    M    string    商品名
        std_unit_name    M    string    商品标准单元名
        start_stock    M    Decimal(15,4)    期初库存
        start_stock_value    M    Decimal(15,4)    期初货值
        start_avg_price    M    Decimal(15,4)    期初均价
        end_stock    M    Decimal(15,4)    期末库存
        end_stock_value    M    Decimal(15,4)    期末货值
        end_avg_price    M    Decimal(15,4)    期末均价
        in_stock_num    M    Decimal(15,4)    本期入库数量
        in_stock_price    M    Decimal(15,4)    本期入库均价
        in_stock_value    M    Decimal(15,4)    本期入库金额
        return_stock_num    M    Decimal(15,4)    本期退货出库数量
        return_stock_price    M    Decimal(15,4)    本期退货出库均价
        return_stock_value    M    Decimal(15,4)    本期退货出库金额
        out_stock_num    M    Decimal(15,4)    本期出库数量
        out_stock_price    M    Decimal(15,4)    本期出库均价
        out_stock_value    M    Decimal(15,4)    本期出库金额
        increase_stock_num    M    Decimal(15,4)    本期报溢数量
        increase_stock_price    M    Decimal(15,4)    本期报溢均价
        increase_stock_value    M    Decimal(15,4)    本期报溢金额
        loss_stock_num    M    Decimal(15,4)    本期报损数量
        loss_stock_price    M    Decimal(15,4)    本期报损均价
        loss_stock_value    M    Decimal(15,4)    本期报损金额
        in_return_stock_value    M    Decimal(15,4)    本期退货入库金额
        in_return_stock_price    M    Decimal(15,4)    本期退货入库均价
        in_return_stock_num    M    Decimal(15,4)    本期退货入库数量
    }
]

pagination: {       M   dict
        more: true,        M   bool    是否有更多数据
        page_obj: "gtyuhbgyhbvgyhgvgy",    M   string
        }

当查看维度为一级分类时:

code:0
msg:ok
data:[
    {
        category_id_1    M    string    一级分类id
        category_id_1_name    M    string    一级分类名
        start_stock_value    M    Decimal(15,4)    期初货值
        end_stock_value    M    Decimal(15,4)    期末货值
        in_stock_value    M    Decimal(15,4)    入库货值
        return_stock_value    M    Decimal(15,4)    退货出库货值
        out_stock_value    M    Decimal(15,4)    出库货值
        increase_stock_value    M    Decimal(15,4)    报溢货值
        loss_stock_value    M    Decimal(15,4)    报损货值
        in_return_stock_value    M    Decimal(15,4)    退货入库货值
    }
]

pagination: {       M   dict
        more: true,        M   bool    是否有更多数据
        page_obj: "gtyuhbgyhbvgyhgvgy",    M   string
        }

当查看维度为二级分类时:

code:0
msg:ok
data:[
    {
        category_id_2    M    string    二级分类id
        category_id_2_name    M    string    二级分类名
        start_stock_value    M    Decimal(15,4)    期初货值
        end_stock_value    M    Decimal(15,4)    期末货值
        in_stock_value    M    Decimal(15,4)    入库货值
        return_stock_value    M    Decimal(15,4)    退货出库货值
        out_stock_value    M    Decimal(15,4)    出库货值
        increase_stock_value    M    Decimal(15,4)    报溢货值
        loss_stock_value    M    Decimal(15,4)    报损货值
        in_return_stock_value    M    Decimal(15,4)    退货入库货值
    }
]

pagination: {       M   dict
        more: true,        M   bool    是否有更多数据
        page_obj: "gtyuhbgyhbvgyhgvgy",    M   string
        }

3、货值成本导出接口station/report/value_export

请求:GET

begin    M    date    起始日期
end    M    date    结束日期
category_id_1    O    list    一级分类
category_id_2    O    list    二级分类
text    O    str    商品搜索字段
view_type    M    int    查看维度
customer_export    M    bool   定制导出

响应:

响应为一个表格,表格字段跟原接口一致

4、异步货值更新任务接口station/stock/async_stock_value

请求:POST

data:{   M    dict
    serial    M    string    消息是否需要推送的验证字段
    spu_id    M    string    商品id
    type    M    int    变动类型
    amount    M    float    变动数量
    price    M    float    变动时的价格
    time    M    datetime    单据提交的时间
    station_id    M    string    站点id
    group_id    M     int     加盟商id
    stock    M     float    变动后的库存(这里用于新建记录时把该数据设为期末库存)
    avg_price    M    float    库存均价      
}

响应:

code: 0
msg" ok

5、消息发送检验接口station/stock/value_check_serial

请求:POST

spu_id    M    string    商品id
serial    M    string    校验码

响应:

code: 0
msg" ok
data:{
    result   M    bool    是否已消费
}

6、需要修改的接口(发送一条异步消息)

stock_change_map = {
    1: '入库',
    2: '入库审核不通过',
    3: '入库冲销',
    4: '出库',
    5: '出库冲销',
    6: '报损',
    7: '报溢',
    8: '供应商退货出库',
    9: '供应商退货出库审核不通过',
    10: '供应商退货出库冲销',
    17: '商品退货入库',
    18: '修复库存均价'
}

成品入库 in_stock_sheet/material/modify InStockSheetDetailModify

成品入库审核不通过 in_stock_sheet/material/review InStockSheetReview

成品入库冲销 in_stock_sheet/material/cancel InStockSheetCancel

成品出库 out_stock_sheet/modify OutStockSheetModifyView

出库冲销 out_stock_sheet/cancel OutStockSheetCancelView

批量提交出库单 out_stock_sheet/submit/batch OutStockSubmitBatchView

退货出库 return_stock_sheet/modify ReturnStockSheetModifyView

退货出库审核不通过 return_stock_sheet/review ReturnStockSheetReviewView

退货出库冲销 return_stock_sheet/cancel ReturnStockSheetCancelView​

商品退货入库 refund/edit RefundEditView

修改批次库存 check/batch_edit StockBatchEdit

修改库存 edit_stock StockEditView

批次库存审核 check/batch StockCheckBatchView

修复库存均价的脚本

批量出库的脚本

自动出库的脚本

修复库存均价脚本fix货值变动(tbl_stock_change_log)

7、定时脚本(定时补上昨天未生成货值记录但前天有货值记录的数据)

8、刷数据脚本

将今天没有数据但是有库存的(station_id, spu_id)数据刷到货值成本表里

9、拆分接口