| | |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/pkg/logx" |
| | | "aps_crm/proto/product" |
| | | "aps_crm/proto/product_inventory" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/shopspring/decimal" |
| | | "github.com/spf13/cast" |
| | | "strconv" |
| | | ) |
| | | |
| | | type ProductApi struct{} |
| | |
| | | productInfo := make([]response.SalesDetailsProductInfo, 0) |
| | | amountMap := make(map[string]int64) |
| | | overMap := make(map[string]int64) |
| | | outputMap := make(map[string]int) |
| | | for _, p := range first.Products { |
| | | amountMap[p.Number] = 0 |
| | | overMap[p.Number] = 0 |
| | |
| | | logx.Errorf("grpc GetProductOrder err: %v", err.Error()) |
| | | ctx.FailWithMsg(ecode.UnknownErr, "内部错误") |
| | | return |
| | | } |
| | | //查询发货信息 |
| | | cl := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn) |
| | | operationInfo, err := cl.GetOutputOperationInfo(ctx.GetCtx(), &product_inventory.GetOutputOperationInfoRequest{Number: number}) |
| | | if err != nil { |
| | | logx.Errorf("grpc GetOutputOperationInfo err: %v", err.Error()) |
| | | ctx.FailWithMsg(ecode.UnknownErr, "内部错误") |
| | | return |
| | | } |
| | | for _, outputProduct := range operationInfo.Products { |
| | | amount, _ := strconv.Atoi(outputProduct.Amount) |
| | | outputMap[outputProduct.Number] = amount |
| | | } |
| | | var result response.Info |
| | | //制造信息 |
| | |
| | | productInfo[i].FinishAmount = productInfo[i].FinishAmount + overMap[productInfo[i].ProductId] |
| | | overMap[productInfo[i].ProductId] = 0 |
| | | } |
| | | |
| | | //发货信息 |
| | | for i := 0; i < len(productInfo); i++ { |
| | | productInfo[i].DeliveryAmount = productInfo[i].DeliveryAmount + outputMap[productInfo[i].ProductId] |
| | | } |
| | | |
| | | result.OutsourcingInfo = outsourcingList |
| | | result.ProductInfo = productInfo |
| | | ctx.OkWithDetailed(result) |