| | |
| | | } |
| | | 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 _, v := range list { |
| | | if m[v.Number] == nil { |
| | | continue |
| | | } |
| | | v.OrderAmount = m[v.Number].Amount.String() |
| | | } |
| | | |
| | | ctx.OkWithDetailed(list) |
| | | } |
| | | |
| | |
| | | |
| | | if err != nil { |
| | | logx.Errorf("product_inventory.OrderProductOutput err:%v, params:%v", err, params) |
| | | ctx.FailWithMsg(ecode.UnknownErr, "发货失败") |
| | | ctx.FailWithMsg(ecode.UnknownErr, "发货失败"+err.Error()) |
| | | return |
| | | } |
| | | |
| | |
| | | "GrpcServiceAddr": { |
| | | "Aps": "192.168.20.119:9091", |
| | | "Admin": "192.168.20.119:50051", |
| | | "WMS": "192.168.20.119:8006", |
| | | "WMS": "192.168.20.120:8006", |
| | | "SRM": "192.168.20.119:9093" |
| | | } |
| | | } |
| | |
| | | if len(slf.ProductIds) > 0 { |
| | | db = db.Where("product_id in (?)", slf.ProductIds) |
| | | } |
| | | if slf.SalesDetailsId != 0 { |
| | | db = db.Where("sales_details_id = ?", slf.SalesDetailsId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SalesDetailsProductSearch) SetSalesDetailsId(id int) *SalesDetailsProductSearch { |
| | | slf.SalesDetailsId = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SalesDetailsProductSearch) Create(record *SalesDetailsProduct) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | |
| | | orders, err := model.NewDeliveryOrderSearch().SetSalesDetailsID(saleDetailID).FindAll() |
| | | return orders, err |
| | | } |
| | | |
| | | func (slf SalesDetailsService) GetProducts(saleDetailNumber string) (products []*model.Product, err error) { |
| | | salesDetails, err := slf.GetSalesDetailsByNumber(saleDetailNumber) |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | | // get contact list |
| | | salesDetailsProducts, err := model.NewSalesDetailsProductSearch().SetSalesDetailsId(salesDetails.Id).FindAll() |
| | | if err != nil { |
| | | return |
| | | } |
| | | productIDs := make([]uint, 0) |
| | | for _, v := range salesDetailsProducts { |
| | | productIDs = append(productIDs, v.ProductId) |
| | | } |
| | | return model.NewProductSearch(nil).SetIds(productIDs).FindAll() |
| | | } |