fix(tenement):修正列举商户时的迁入迁出条件筛选。

This commit is contained in:
徐涛
2023-06-27 15:11:46 +08:00
parent 0c389e440a
commit 4df3efacd8
3 changed files with 13 additions and 6 deletions

View File

@@ -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