This commit is contained in:
邹宗楠
2024-01-16 16:24:50 +08:00
parent e3eff8739b
commit 1fe0ca13b0
7 changed files with 85 additions and 41 deletions

View File

@@ -1698,7 +1698,7 @@ type StatisticsStore struct {
}
// StatisticsStoreInfo 统计所有的门店信息
func StatisticsStoreInfo(db *DaoDB, brandId []int, vendorId []int) ([]*StatisticsStore, error) {
func StatisticsStoreInfo(db *DaoDB, brandId, vendorId, storeList []int) ([]*StatisticsStore, error) {
statistics := make([]*StatisticsStore, 0, 0)
sql := ` SELECT count(s.status) count, s.status FROM store s `
@@ -1708,6 +1708,12 @@ func StatisticsStoreInfo(db *DaoDB, brandId []int, vendorId []int) ([]*Statistic
param = append(param, vendorId)
}
sql += ` WHERE 1=1 `
if len(storeList) > model.NO {
sql += ` AND s.id IN (` + GenQuestionMarks(len(storeList)) + `)`
param = append(param, storeList)
}
if len(brandId) > model.NO {
sql += ` AND s.brand_id IN (` + GenQuestionMarks(len(brandId)) + `)`
param = append(param, brandId)
@@ -1727,7 +1733,7 @@ type StatisticsOrder struct {
}
// StatisticsOrderInfo 统计订单信息
func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId []int) ([]*StatisticsOrder, error) {
func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId, storeList []int) ([]*StatisticsOrder, error) {
parma := []interface{}{}
sql := ` SELECT count(g.vendor_order_id) count,g.status status ,sum(g.total_shop_money) total_shop_money FROM goods_order g `
@@ -1741,21 +1747,25 @@ func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, b
if storeId != model.NO {
sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) = ?`
parma = append(parma, storeId)
} else if len(storeList) != model.NO {
sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) IN (` + GenQuestionMarks(len(storeList)) + `)`
parma = append(parma, storeList)
}
if len(vendorId) > model.NO {
sql += ` AND g.vendor_id IN (` + GenQuestionMarks(len(vendorId)) + `)`
parma = append(parma, vendorId)
}
sql += ` GROUP BY g.status `
orderStatistics := make([]*StatisticsOrder, 0, 0)
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil {
if err := GetRows(db, &orderStatistics, sql, parma...); err != nil {
return nil, err
}
return orderStatistics, nil
}
// StatisticsAfsOrderInfo 售后单信息统计
func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId []int) ([]*StatisticsOrder, error) {
func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId, storeList []int) ([]*StatisticsOrder, error) {
parma := []interface{}{}
sql := `SELECT count(a.vendor_order_id) count,a.status status ,sum(a.afs_total_shop_money) total_shop_money FROM afs_order a `
@@ -1769,6 +1779,9 @@ func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int
if storeId != model.NO {
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) = ?`
parma = append(parma, storeId)
} else if len(storeList) != model.NO {
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) IN (` + GenQuestionMarks(len(storeList)) + `)`
parma = append(parma, storeList)
}
if len(vendorId) > 0 {
@@ -1778,7 +1791,7 @@ func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int
sql += ` GROUP BY a.status`
orderStatistics := make([]*StatisticsOrder, 0, 0)
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil {
if err := GetRows(db, &orderStatistics, sql, parma...); err != nil {
return nil, err
}
return orderStatistics, nil