|
@@ -1144,18 +1144,28 @@ func FindAllStockOutList(orgId int64, page int64, limit int64, startTime int64,
|
1144
|
1144
|
return
|
1145
|
1145
|
}
|
1146
|
1146
|
|
1147
|
|
-func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string) (list []*models.StockInfo, total int64, err error) {
|
|
1147
|
+func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, startime int64, endtime int64, type_name int64) (list []*models.StockInfo, total int64, err error) {
|
1148
|
1148
|
|
1149
|
1149
|
db := readDb.Model(&models.StockInfo{})
|
|
1150
|
+ if startime > 0 {
|
|
1151
|
+ db = db.Where("ctime >=?", startime)
|
|
1152
|
+ }
|
|
1153
|
+ if endtime > 0 {
|
|
1154
|
+ db = db.Where("ctime<=?", endtime)
|
|
1155
|
+ }
|
1150
|
1156
|
db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgId)
|
1151
|
1157
|
db = db.Group("xt_good_information.id")
|
1152
|
1158
|
db = db.Preload("QueryWarehousingInfo", func(db *gorm.DB) *gorm.DB {
|
1153
|
1159
|
return db.Where("org_id = ? AND status = 1", orgId)
|
1154
|
1160
|
})
|
1155
|
1161
|
db = db.Preload("QuerySalesReturnInfo", "org_id = ? AND status = 1", orgId)
|
1156
|
|
- db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
|
1157
|
|
- return db.Where("org_id = ? AND status = 1", orgId)
|
1158
|
|
- })
|
|
1162
|
+
|
|
1163
|
+ if startime == 0 || endtime == 0 {
|
|
1164
|
+ db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
|
|
1165
|
+ return db.Where("org_id = ? AND status = 1", orgId)
|
|
1166
|
+ })
|
|
1167
|
+ }
|
|
1168
|
+
|
1159
|
1169
|
db = db.Preload("QueryCancelStockInfo", "org_id = ? AND status = 1", orgId)
|
1160
|
1170
|
db = db.Preload("GoodsType", "org_id = ? AND status = 1", orgId)
|
1161
|
1171
|
|
|
@@ -1165,6 +1175,11 @@ func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string) (lis
|
1165
|
1175
|
db = db.Where("xt_good_information.good_code LIKE ? OR xt_good_information.specification_name LIKE ? OR xt_goods_type.type_name LIKE ?", likeKey, likeKey, likeKey).Group("xt_good_information.id")
|
1166
|
1176
|
}
|
1167
|
1177
|
|
|
1178
|
+ if type_name > 0 {
|
|
1179
|
+
|
|
1180
|
+ db = db.Joins("join xt_goods_type on xt_goods_type.id = xt_good_information.good_type_id AND xt_goods_type.org_id = ? AND xt_goods_type.status = 1 and xt_goods_type.id = ?", orgId, type_name)
|
|
1181
|
+ }
|
|
1182
|
+
|
1168
|
1183
|
db = db.Count(&total)
|
1169
|
1184
|
offset := (page - 1) * limit
|
1170
|
1185
|
err = db.Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
|