| | |
| | | locationIds []int, |
| | | err error) { |
| | | productAmounts = make([]*models.LocationProductAmount, 0) |
| | | locationSearch := models.NewLocationSearch() |
| | | if params.WarehouseCode != "" { |
| | | locations, err := models.NewLocationSearch().SetJointName(params.WarehouseCode).FindNotTotal() |
| | | if err != nil { |
| | | return nil, nil, nil, nil, err |
| | | } |
| | | locationSearch.SetJointName(params.WarehouseCode) |
| | | } |
| | | |
| | | for _, location := range locations { |
| | | locationIds = append(locationIds, location.Id) |
| | | } |
| | | productAmounts, err = models.NewLocationProductAmountSearch().SetLocationIds(locationIds).SetQuery("amount > 0").Find() |
| | | if err != nil { |
| | | return nil, nil, nil, nil, err |
| | | } |
| | | for _, amount := range productAmounts { |
| | | productIds = append(productIds, amount.ProductId) |
| | | } |
| | | locations, err := locationSearch.FindNotTotal() |
| | | if err != nil { |
| | | return nil, nil, nil, nil, err |
| | | } |
| | | |
| | | for _, location := range locations { |
| | | locationIds = append(locationIds, location.Id) |
| | | } |
| | | productAmounts, err = models.NewLocationProductAmountSearch(). |
| | | SetLocationIds(locationIds).SetQuery("amount > 0"). |
| | | Find() |
| | | if err != nil { |
| | | return nil, nil, nil, nil, err |
| | | } |
| | | for _, amount := range productAmounts { |
| | | productIds = append(productIds, amount.ProductId) |
| | | } |
| | | |
| | | //查询产品 |