价格统计

This commit is contained in:
苏尹岚
2019-12-09 09:31:34 +08:00
parent 441fa5e3d8
commit 5d1f128e1d
4 changed files with 35 additions and 15 deletions

View File

@@ -234,12 +234,12 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
return nil, err
}
func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, snapDate time.Time, offset, pageSize int) (priceReferSnapshot []*model.PriceReferSnapshot, totalCount int, err error) {
sql := `
SELECT *
SELECT SQL_CALC_FOUND_ROWS *
FROM price_refer_snapshot
WHERE 1=1
AND delete_at = ?
AND deleted_at = ?
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
@@ -252,8 +252,16 @@ func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapsh
sql += " AND city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
sqlParams = append(sqlParams, cityCodes)
}
if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil {
return priceReferSnapshot, nil
if !utils.IsTimeZero(snapDate) {
sql += " AND snapshot_at = ?"
sqlParams = append(sqlParams, snapDate)
}
return nil, err
sql += " LIMIT ? OFFSET ?"
sqlParams = append(sqlParams, pageSize, offset)
Begin(db)
defer Commit(db)
if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil {
totalCount = GetLastTotalRowCount(db)
}
return priceReferSnapshot, totalCount, err
}