1
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-print/dao"
|
||||
"time"
|
||||
)
|
||||
|
||||
// StoreInformationStatistics 门店信息统计
|
||||
func StoreInformationStatistics() (result []*model.EffectiveStores, err error) {
|
||||
func StoreInformationStatistics(db *DaoDB) (result []*model.EffectiveStores, err error) {
|
||||
sql := `
|
||||
SELECT
|
||||
gs.jx_store_id,
|
||||
@@ -21,9 +24,41 @@ func StoreInformationStatistics() (result []*model.EffectiveStores, err error) {
|
||||
`
|
||||
parma := []interface{}{time.Now().AddDate(0, -1, 0), model.VendorIDMTWM}
|
||||
|
||||
if err = GetRows(GetDB(), &result, sql, parma...); err != nil {
|
||||
if err = GetRows(db, &result, sql, parma...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func GetStatistics(db *DaoDB, startTime, endTime time.Time, storeId []int, offset, pageSize int) (pageInfo *model.PagedInfo, err error) {
|
||||
sql := ` SELECT SQL_CALC_FOUND_ROWS * FROM activity_station WHERE 1=1 `
|
||||
param := []interface{}{}
|
||||
if !utils.IsTimeZero(startTime) {
|
||||
sql += ` AND created_at >= ?`
|
||||
param = append(param, startTime)
|
||||
}
|
||||
if !utils.IsTimeZero(endTime) {
|
||||
sql += ` AND created_at <= ?`
|
||||
param = append(param, endTime)
|
||||
}
|
||||
if len(storeId) > 0 {
|
||||
sql += " AND store_id (" + dao.GenQuestionMarks(len(storeId)) + ")"
|
||||
param = append(param, storeId)
|
||||
}
|
||||
sql += ` ORDER BY created_at desc LIMIT ? OFFSET ?`
|
||||
param = append(param, jxutils.FormalizePageSize(pageSize), offset)
|
||||
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
|
||||
var data []*model.ActivityStation
|
||||
if err := GetRowsTx(txDB, &data, sql, param...); err == nil {
|
||||
pageInfo = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCount2(db, txDB),
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
return pageInfo, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user