liujiandao
2024-02-06 fe675a31074e9ff012d29387336dc35de3ba46f2
销售明细不推送wms
2个文件已修改
127 ■■■■ 已修改文件
api/v1/salesDetails.go 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
proto/crm_aps/server.go 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesDetails.go
@@ -310,15 +310,15 @@
    if !ok {
        return
    }
    clientName := ""
    if params.ClientId > 0 {
        first, err := model.NewClientSearch(nil).SetId(params.ClientId).First()
        if err != nil {
            ctx.FailWithMsg(ecode.UnknownErr, "客户信息查询失败")
            return
        }
        clientName = first.Name
    }
    //clientName := ""
    //if params.ClientId > 0 {
    //    first, err := model.NewClientSearch(nil).SetId(params.ClientId).First()
    //    if err != nil {
    //        ctx.FailWithMsg(ecode.UnknownErr, "客户信息查询失败")
    //        return
    //    }
    //    clientName = first.Name
    //}
    m := make(map[string]interface{})
    m["status"] = params.Status
    m["project_id"] = params.ProjectId
@@ -329,28 +329,28 @@
    }
    //推送到wms
    wmsProducts := make([]*product_inventory.InventoryProduct, 0)
    for _, product := range params.Products {
        var p product_inventory.InventoryProduct
        p.Id = product.Number
        p.Amount = product.Amount.String()
        wmsProducts = append(wmsProducts, &p)
    }
    clientWms := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn)
    _, err = clientWms.CreateOperation(ctx.GetCtx(), &product_inventory.CreateOperationRequest{
        Number:      params.Number,
        Addressee:   params.Addressee,
        Address:     params.Address,
        Phone:       params.Phone,
        DeliverType: int32(params.DeliverType),
        Source:      "CRM",
        ClientId:    int64(params.ClientId),
        ClientName:  clientName,
        ProductList: wmsProducts,
    })
    if err != nil {
        logx.Errorf("grpc CreateOperation err: %v", err.Error())
    }
    //wmsProducts := make([]*product_inventory.InventoryProduct, 0)
    //for _, product := range params.Products {
    //    var p product_inventory.InventoryProduct
    //    p.Id = product.Number
    //    p.Amount = product.Amount.String()
    //    wmsProducts = append(wmsProducts, &p)
    //}
    //clientWms := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn)
    //_, err = clientWms.CreateOperation(ctx.GetCtx(), &product_inventory.CreateOperationRequest{
    //    Number:      params.Number,
    //    Addressee:   params.Addressee,
    //    Address:     params.Address,
    //    Phone:       params.Phone,
    //    DeliverType: int32(params.DeliverType),
    //    Source:      "CRM",
    //    ClientId:    int64(params.ClientId),
    //    ClientName:  clientName,
    //    ProductList: wmsProducts,
    //})
    //if err != nil {
    //    logx.Errorf("grpc CreateOperation err: %v", err.Error())
    //}
    //推送到aps
    ApsProducts := make([]*crm_aps.SalesDetailsProduct, 0)
proto/crm_aps/server.go
@@ -5,7 +5,6 @@
    "aps_crm/model"
    "aps_crm/model/grpc_init"
    "aps_crm/pkg/ecode"
    "aps_crm/proto/product_inventory"
    "aps_crm/service"
    "context"
    "errors"
@@ -77,38 +76,38 @@
        }
        //推送到wms
        clientName := ""
        if detail.ClientId > 0 {
            first, err := model.NewClientSearch(nil).SetId(detail.ClientId).First()
            if err == nil {
                clientName = first.Name
            }
        }
        wmsProducts := make([]*product_inventory.InventoryProduct, 0)
        for _, product := range detail.Products {
            var p product_inventory.InventoryProduct
            p.Id = product.Number
            p.Amount = product.Amount.String()
            wmsProducts = append(wmsProducts, &p)
        }
        clientWms := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn)
        _, err = clientWms.CreateOperation(ctx, &product_inventory.CreateOperationRequest{
            Number:      detail.Number,
            Addressee:   detail.Addressee,
            Address:     detail.Address,
            Phone:       detail.Phone,
            DeliverType: int32(detail.DeliverType),
            Source:      "CRM",
            ClientId:    int64(detail.ClientId),
            ClientName:  clientName,
            ProductList: wmsProducts,
        })
        if err != nil {
            //状态还原
            m["status"] = constvar.WaitConfirmed
            _ = model.NewSalesDetailsSearch().SetNumber(detail.Number).UpdateByMap(m)
            return nil, err
        }
        //clientName := ""
        //if detail.ClientId > 0 {
        //    first, err := model.NewClientSearch(nil).SetId(detail.ClientId).First()
        //    if err == nil {
        //        clientName = first.Name
        //    }
        //}
        //wmsProducts := make([]*product_inventory.InventoryProduct, 0)
        //for _, product := range detail.Products {
        //    var p product_inventory.InventoryProduct
        //    p.Id = product.Number
        //    p.Amount = product.Amount.String()
        //    wmsProducts = append(wmsProducts, &p)
        //}
        //clientWms := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn)
        //_, err = clientWms.CreateOperation(ctx, &product_inventory.CreateOperationRequest{
        //    Number:      detail.Number,
        //    Addressee:   detail.Addressee,
        //    Address:     detail.Address,
        //    Phone:       detail.Phone,
        //    DeliverType: int32(detail.DeliverType),
        //    Source:      "CRM",
        //    ClientId:    int64(detail.ClientId),
        //    ClientName:  clientName,
        //    ProductList: wmsProducts,
        //})
        //if err != nil {
        //    //状态还原
        //    m["status"] = constvar.WaitConfirmed
        //    _ = model.NewSalesDetailsSearch().SetNumber(detail.Number).UpdateByMap(m)
        //    return nil, err
        //}
        //推送到aps
        products := make([]*SalesDetailsProduct, 0)