价格统计
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user