forked from free-lancers/electricity_bill_calc_service
fix(tenement):修正列举商户时的迁入迁出条件筛选。
This commit is contained in:
@@ -53,7 +53,7 @@ func (tr _TenementRepository) IsTenementBelongs(tid, uid string) (bool, error) {
|
||||
}
|
||||
|
||||
// 列出指定园区中的所有商户
|
||||
func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, building *string, startDate, endDate *types.Date, state *string) ([]*model.Tenement, int64, error) {
|
||||
func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, building *string, startDate, endDate *types.Date, state int) ([]*model.Tenement, int64, error) {
|
||||
tr.log.Info(
|
||||
"检索查询指定园区中符合条件的商户",
|
||||
zap.String("Park", pid),
|
||||
@@ -62,7 +62,7 @@ func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, buil
|
||||
zap.Stringp("Building", building),
|
||||
logger.DateFieldp("StartDate", startDate),
|
||||
logger.DateFieldp("EndDate", endDate),
|
||||
zap.Stringp("State", state),
|
||||
zap.Int("State", state),
|
||||
)
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
@@ -136,13 +136,20 @@ func (tr _TenementRepository) ListTenements(pid string, page uint, keyword, buil
|
||||
)
|
||||
}
|
||||
|
||||
if state != nil && *state == "1" {
|
||||
if state == 0 {
|
||||
tenementQuery = tenementQuery.Where(
|
||||
goqu.I("t.moved_out_at").IsNull(),
|
||||
)
|
||||
countQuery = countQuery.Where(
|
||||
goqu.I("t.moved_out_at").IsNull(),
|
||||
)
|
||||
} else {
|
||||
tenementQuery = tenementQuery.Where(
|
||||
goqu.I("t.moved_out_at").IsNotNull(),
|
||||
)
|
||||
countQuery = countQuery.Where(
|
||||
goqu.I("t.moved_out_at").IsNotNull(),
|
||||
)
|
||||
}
|
||||
|
||||
startRow := (page - 1) * config.ServiceSettings.ItemsPageSize
|
||||
|
Reference in New Issue
Block a user