diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 36f8e8a6f..e401b6464 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -305,29 +305,29 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa sql += sqlWhere + ` GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53 ORDER BY t1.id DESC - LIMIT ? OFFSET ?` + /*LIMIT ? OFFSET ?*/` pageSize = jxutils.FormalizePageSize(pageSize) if offset < 0 { offset = 0 } sqlParams = append(sqlParams, sqlWhereParams...) - sqlParams = append(sqlParams, pageSize, offset) + // sqlParams = append(sqlParams, pageSize, offset) retVal = &StoresInfo{} db := dao.GetDB() - dao.Begin(db) - defer func() { - if r := recover(); r != nil { - dao.Rollback(db) - panic(r) - } - }() + // dao.Begin(db) + // defer func() { + // if r := recover(); r != nil { + // dao.Rollback(db) + // panic(r) + // } + // }() // globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) // globals.SugarLogger.Debug(sql) var storeList []*StoreExt mapLimit := false if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil { - retVal.TotalCount = dao.GetLastTotalRowCount(db) - dao.Commit(db) + // retVal.TotalCount = dao.GetLastTotalRowCount(db) + // dao.Commit(db) // globals.SugarLogger.Debugf("GetStores, len(storeList):%d", len(storeList)) var ( mapLatitude, mapLongitude float64 @@ -359,11 +359,20 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa } } retVal.Stores, err = filterStoreByOrderInfo(db, retVal.Stores, orderTimeFrom, orderTimeTo, orderCountFrom, orderCountTo) - if mapLimit { - retVal.TotalCount = len(retVal.Stores) + retVal.TotalCount = len(retVal.Stores) + if offset >= retVal.TotalCount { + retVal.Stores = nil + } else { + if offset+pageSize > retVal.TotalCount { + pageSize = retVal.TotalCount - offset + } + retVal.Stores = retVal.Stores[offset : offset+pageSize] } + // if mapLimit { + // retVal.TotalCount = len(retVal.Stores) + // } } else { - dao.Rollback(db) + // dao.Rollback(db) } if mapLimit && len(retVal.Stores) > 0 { retVal.MapCenterLng, retVal.MapCenterLat = getMapCenter(retVal.Stores)