| | |
| | | } |
| | | number := c.Param("number") |
| | | client := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn) |
| | | info, err := client.GetInventoryProductInfo(ctx.GetCtx(), &product_inventory.GetInventoryProductInfoRequest{Number: number}) |
| | | info, err := client.GetOrderInputAndOutputInfo(ctx.GetCtx(), &product_inventory.GetOrderInputAndOutputInfoRequest{Number: number}) |
| | | if err != nil { |
| | | if strings.Contains(err.Error(), "record not found") { |
| | | ctx.Ok() |
| | |
| | | return |
| | | } |
| | | var list []response.ProductInfo |
| | | err = structx.AssignTo(info.ProductList, &list) |
| | | err = structx.AssignTo(info.OutputList, &list) |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "转换错误") |
| | | return |
| | | } |
| | | |
| | | products, err := salesDetailsService.GetProducts(number) |
| | | m := make(map[string]*model.Product) |
| | | |
| | | for _, product := range products { |
| | | m[product.Number] = product |
| | | } |
| | | for k, v := range list { |
| | | if m[v.Number] == nil { |
| | | continue |
| | | } |
| | | list[k].OrderAmount = m[v.Number].Amount.String() |
| | | } |
| | | |
| | | ctx.OkWithDetailed(list) |
| | | } |
| | | |
| | |
| | | inputProductMap := make(map[string]*response.StoreInfo) |
| | | outputProductMap := make(map[string]*response.OutputSimpleInfo) |
| | | for _, v := range grpcOutputList { |
| | | if productMap[v.Number] == nil { |
| | | continue |
| | | } |
| | | if outputProductMap[v.Number] == nil { |
| | | simpleInfo := &response.OutputSimpleInfo{ |
| | | Number: v.Number, |
| | |
| | | } |
| | | } |
| | | for _, v := range grpcInputList { |
| | | if productMap[v.Number] == nil { |
| | | continue |
| | | } |
| | | if inputProductMap[v.Number] == nil { |
| | | storeInfo := &response.StoreInfo{ |
| | | Number: v.Number, |
| | |
| | | return |
| | | } |
| | | |
| | | products := make([]*product_inventory.OutputProduct, 0, len(params.Products)) |
| | | for _, product := range params.Products { |
| | | products = append(products, &product_inventory.OutputProduct{ |
| | | Number: product.Number, |
| | | Amount: product.OutputAmount.String(), |
| | | }) |
| | | } |
| | | client := product_inventory.NewProductInventoryServiceClient(grpc_init.ProductInventoryServiceConn) |
| | | _, err := client.OrderProductOutput(ctx.GetCtx(), &product_inventory.OrderProductOutputRequest{ |
| | | OrderNumber: params.SaleDetailNumber, |
| | | Products: products, |
| | | }) |
| | | |
| | | if err != nil { |
| | | logx.Errorf("product_inventory.OrderProductOutput err:%v, params:%v", err, params) |
| | | ctx.FailWithMsg(ecode.UnknownErr, "发货失败"+err.Error()) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(nil) |
| | | } |
| | | |