|
@@ -3228,7 +3228,23 @@ func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime in
|
3228
|
3228
|
db = db.Where("x.good_type_id = ?", good_type)
|
3229
|
3229
|
}
|
3230
|
3230
|
|
3231
|
|
- err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Preload("StWarehousingInfo", "status= 1 and org_id =? and ctime>=? and ctime<=?", orgid, startime, endtime).Preload("CancelStockInfo", "status= 1 and org_id =? and ctime>=? and ctime<=?", orgid, startime, endtime).Find(&info).Error
|
|
3231
|
+ err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Preload("StWarehousingInfo", func(db *gorm.DB) *gorm.DB {
|
|
3232
|
+ if startime > 0 {
|
|
3233
|
+ db = db.Where("ctime>=?", startime)
|
|
3234
|
+ }
|
|
3235
|
+ if endtime > 0 {
|
|
3236
|
+ db = db.Where("ctime<=?", endtime)
|
|
3237
|
+ }
|
|
3238
|
+ return db.Where("status = 1")
|
|
3239
|
+ }).Preload("CancelStockInfo", func(db *gorm.DB) *gorm.DB {
|
|
3240
|
+ if startime > 0 {
|
|
3241
|
+ db = db.Where("ctime>=?", startime)
|
|
3242
|
+ }
|
|
3243
|
+ if endtime > 0 {
|
|
3244
|
+ db = db.Where("ctime<=?", endtime)
|
|
3245
|
+ }
|
|
3246
|
+ return db.Where("status = 1")
|
|
3247
|
+ }).Find(&info).Error
|
3232
|
3248
|
return info, total, err
|
3233
|
3249
|
}
|
3234
|
3250
|
|
|
@@ -3324,14 +3340,14 @@ func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (auto
|
3324
|
3340
|
//} else {
|
3325
|
3341
|
// err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1) as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
|
3326
|
3342
|
//}
|
3327
|
|
- //
|
3328
|
|
- //if endtime > 0 {
|
3329
|
|
- // err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time <=? and `status` = 1) as b GROUP BY good_id", orgid, endtime).Scan(&autoMatic).Error
|
3330
|
|
- //} else {
|
3331
|
|
- // err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1) as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
|
3332
|
|
- //}
|
3333
|
3343
|
|
3334
|
|
- err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and `status` = 1) as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
|
|
3344
|
+ if startime > 0 || endtime > 0 {
|
|
3345
|
+ err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time <=? and `status` = 1) as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
|
|
3346
|
+ } else {
|
|
3347
|
+ err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1) as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
|
|
3348
|
+ }
|
|
3349
|
+
|
|
3350
|
+ //err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and `status` = 1) as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
|
3335
|
3351
|
|
3336
|
3352
|
return autoMatic, err
|
3337
|
3353
|
|