仓库 库位搜索
This commit is contained in:
parent
3cb9221a95
commit
227ed703ae
@ -13,11 +13,12 @@ type GetInventoryListRequest struct {
|
||||
|
||||
// GetInventoryGroupedListRequest 获取按仓库库位分组的库存列表请求
|
||||
type GetInventoryGroupedListRequest struct {
|
||||
Page int `form:"page"` // 页码
|
||||
PageSize int `form:"page_size"` // 分页大小
|
||||
ProductId int64 `form:"product_id"` // 商品ID
|
||||
WarehouseID int64 `form:"warehouse_id"` // 仓库ID
|
||||
LocationID int64 `form:"location_id"` // 库位ID
|
||||
Page int `form:"page"` // 页码
|
||||
PageSize int `form:"page_size"` // 分页大小
|
||||
ProductId int64 `form:"product_id"` // 商品ID
|
||||
WarehouseID int64 `form:"warehouse_id"` // 仓库ID
|
||||
LocationID int64 `form:"location_id"` // 库位ID
|
||||
Keyword string `form:"keyword"` // 关键词搜索(库位编号/商品名称/条码)
|
||||
}
|
||||
|
||||
// GetInventoryDetailRequest 获取库存明细请求
|
||||
|
||||
@ -8,6 +8,7 @@ type GetOutboundOrderListRequest struct {
|
||||
Status int8 `form:"status"`
|
||||
CustomerID int64 `form:"customer_id"`
|
||||
WarehouseID int64 `form:"warehouse_id"`
|
||||
LocationID int64 `form:"location_id"`
|
||||
StartDate int64 `form:"start_date"`
|
||||
EndDate int64 `form:"end_date"`
|
||||
AssociationOrderNo string `form:"association_order_no"`
|
||||
|
||||
@ -12,6 +12,8 @@ type GetShippingOrderListRequest struct {
|
||||
AssociationOrderNo string `form:"association_order_no" json:"association_order_no"`
|
||||
LogisticsNo string `form:"logistics_no" json:"logistics_no"`
|
||||
ShopType int `form:"shop_type" json:"shop_type"`
|
||||
WarehouseID int64 `form:"warehouse_id" json:"warehouse_id"`
|
||||
LocationID int64 `form:"location_id" json:"location_id"`
|
||||
}
|
||||
|
||||
// GetShippingOrderDetailRequest 获取发货单详情请求
|
||||
@ -31,4 +33,6 @@ type GetShippingOrderDetailListRequest struct {
|
||||
AssociationOrderNo string `form:"association_order_no" json:"association_order_no"`
|
||||
LogisticsNo string `form:"logistics_no" json:"logistics_no"`
|
||||
ShopType int `form:"shop_type" json:"shop_type"`
|
||||
WarehouseID int64 `form:"warehouse_id" json:"warehouse_id"`
|
||||
LocationID int64 `form:"location_id" json:"location_id"`
|
||||
}
|
||||
|
||||
@ -145,6 +145,7 @@ func (s *InventoryService) GetInventoryGroupedList(req systemReq.GetInventoryGro
|
||||
`).
|
||||
Joins("LEFT JOIN warehouse w ON inventory_detail.warehouse_id = w.id AND w.is_del = 0").
|
||||
Joins("LEFT JOIN location l ON inventory_detail.location_id = l.id AND l.is_del = 0").
|
||||
Joins("LEFT JOIN product p ON inventory_detail.product_id = p.id AND p.is_del = 0").
|
||||
Where("inventory_detail.is_del = ?", 0).
|
||||
Group("inventory_detail.warehouse_id, w.name, w.code, inventory_detail.location_id, l.code")
|
||||
|
||||
@ -155,6 +156,11 @@ func (s *InventoryService) GetInventoryGroupedList(req systemReq.GetInventoryGro
|
||||
groupQuery = groupQuery.Where("inventory_detail.location_id = ?", req.LocationID)
|
||||
}
|
||||
|
||||
if req.Keyword != "" {
|
||||
kw := "%" + req.Keyword + "%"
|
||||
groupQuery = groupQuery.Where("(l.code LIKE ? OR p.name LIKE ? OR p.barcode LIKE ?)", kw, kw, kw)
|
||||
}
|
||||
|
||||
var total int64
|
||||
if err := groupQuery.Count(&total).Error; err != nil {
|
||||
return nil, utils.NewError("查询总数失败")
|
||||
@ -205,6 +211,10 @@ func (s *InventoryService) GetInventoryGroupedList(req systemReq.GetInventoryGro
|
||||
if req.ProductId > 0 {
|
||||
detailQuery = detailQuery.Where("inventory_detail.product_id = ?", req.ProductId)
|
||||
}
|
||||
if req.Keyword != "" {
|
||||
kw := "%" + req.Keyword + "%"
|
||||
detailQuery = detailQuery.Where("(p.name LIKE ? OR p.barcode LIKE ?)", kw, kw)
|
||||
}
|
||||
|
||||
var details []struct {
|
||||
models.InventoryDetail
|
||||
|
||||
@ -35,6 +35,12 @@ func (s *OutboundService) GetOutboundOrderList(req systemReq.GetOutboundOrderLis
|
||||
if req.WarehouseID > 0 {
|
||||
query = query.Where("outbound_order.warehouse_id = ?", req.WarehouseID)
|
||||
}
|
||||
if req.LocationID > 0 {
|
||||
subQuery := databaseConn.Table("outbound_order_item").
|
||||
Select("outbound_order_item.out_order_id").
|
||||
Where("outbound_order_item.is_del = 0 AND outbound_order_item.location_id = ?", req.LocationID)
|
||||
query = query.Where("outbound_order.id IN (?)", subQuery)
|
||||
}
|
||||
if req.OutNo != "" {
|
||||
query = query.Where("outbound_order.out_no LIKE ?", "%"+req.OutNo+"%")
|
||||
}
|
||||
|
||||
@ -65,6 +65,21 @@ func (s *ShippingService) GetShippingOrderList(req systemReq.GetShippingOrderLis
|
||||
Where("shipping_order_item.is_del = 0 AND sales_order.shop_type = ?", req.ShopType)
|
||||
query = query.Where("shipping_order.id IN (?)", subQuery)
|
||||
}
|
||||
if req.WarehouseID > 0 {
|
||||
subQuery := databaseConn.Table("shipping_order_item").
|
||||
Select("shipping_order_item.shipping_order_id").
|
||||
Joins("INNER JOIN outbound_order_item ON shipping_order_item.outbound_order_item_id = outbound_order_item.id AND outbound_order_item.is_del = 0").
|
||||
Joins("INNER JOIN location ON outbound_order_item.location_id = location.id AND location.is_del = 0").
|
||||
Where("shipping_order_item.is_del = 0 AND location.warehouse_id = ?", req.WarehouseID)
|
||||
query = query.Where("shipping_order.id IN (?)", subQuery)
|
||||
}
|
||||
if req.LocationID > 0 {
|
||||
subQuery := databaseConn.Table("shipping_order_item").
|
||||
Select("shipping_order_item.shipping_order_id").
|
||||
Joins("INNER JOIN outbound_order_item ON shipping_order_item.outbound_order_item_id = outbound_order_item.id AND outbound_order_item.is_del = 0").
|
||||
Where("shipping_order_item.is_del = 0 AND outbound_order_item.location_id = ?", req.LocationID)
|
||||
query = query.Where("shipping_order.id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
var total int64
|
||||
if err := query.Count(&total).Error; err != nil {
|
||||
@ -339,6 +354,21 @@ func (s *ShippingService) GetShippingOrderDetailList(req systemReq.GetShippingOr
|
||||
Where("shipping_order_item.is_del = 0 AND sales_order.shop_type = ?", req.ShopType)
|
||||
query = query.Where("shipping_order.id IN (?)", subQuery)
|
||||
}
|
||||
if req.WarehouseID > 0 {
|
||||
subQuery := databaseConn.Table("shipping_order_item").
|
||||
Select("shipping_order_item.shipping_order_id").
|
||||
Joins("INNER JOIN outbound_order_item ON shipping_order_item.outbound_order_item_id = outbound_order_item.id AND outbound_order_item.is_del = 0").
|
||||
Joins("INNER JOIN location ON outbound_order_item.location_id = location.id AND location.is_del = 0").
|
||||
Where("shipping_order_item.is_del = 0 AND location.warehouse_id = ?", req.WarehouseID)
|
||||
query = query.Where("shipping_order.id IN (?)", subQuery)
|
||||
}
|
||||
if req.LocationID > 0 {
|
||||
subQuery := databaseConn.Table("shipping_order_item").
|
||||
Select("shipping_order_item.shipping_order_id").
|
||||
Joins("INNER JOIN outbound_order_item ON shipping_order_item.outbound_order_item_id = outbound_order_item.id AND outbound_order_item.is_del = 0").
|
||||
Where("shipping_order_item.is_del = 0 AND outbound_order_item.location_id = ?", req.LocationID)
|
||||
query = query.Where("shipping_order.id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
var total int64
|
||||
if err := query.Count(&total).Error; err != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user