fix: 优化官方产品统计数据处理逻辑
This commit is contained in:
parent
5c2d7176c7
commit
c478e9f43d
|
|
@ -428,7 +428,7 @@ func (b *BbxtTools) GetStatisOfficialProductSum(now time.Time, productName []str
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var total = make([][]string, len(ids))
|
var total = make([][]string, 0)
|
||||||
for _, v := range data.OfficialProductSum {
|
for _, v := range data.OfficialProductSum {
|
||||||
var (
|
var (
|
||||||
yeterDatyDiff string
|
yeterDatyDiff string
|
||||||
|
|
@ -444,16 +444,16 @@ func (b *BbxtTools) GetStatisOfficialProductSum(now time.Time, productName []str
|
||||||
} else {
|
} else {
|
||||||
lastWeekDiff = fmt.Sprintf("%s↓%d", GreenStyle, v.HistoryTwoDiff)
|
lastWeekDiff = fmt.Sprintf("%s↓%d", GreenStyle, v.HistoryTwoDiff)
|
||||||
}
|
}
|
||||||
total[productMap[v.OfficialProductName]] = []string{
|
total = append(total, []string{
|
||||||
fmt.Sprintf("%s", v.OfficialProductName),
|
fmt.Sprintf("%s", v.OfficialProductName),
|
||||||
fmt.Sprintf("%d", v.CurrentNum),
|
fmt.Sprintf("%d", v.CurrentNum),
|
||||||
fmt.Sprintf("%d", v.HistoryOneNum),
|
fmt.Sprintf("%d", v.HistoryOneNum),
|
||||||
yeterDatyDiff,
|
yeterDatyDiff,
|
||||||
fmt.Sprintf("%d", v.HistoryTwoNum),
|
fmt.Sprintf("%d", v.HistoryTwoNum),
|
||||||
lastWeekDiff,
|
lastWeekDiff,
|
||||||
}
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timeCh := now.Format("1月2日15点")
|
timeCh := now.Format("1月2日15点")
|
||||||
title := "截至" + timeCh + "销售同比分析"
|
title := "截至" + timeCh + "销售同比分析"
|
||||||
//总量生成excel
|
//总量生成excel
|
||||||
|
|
|
||||||
|
|
@ -79,14 +79,22 @@ func Test_GetStatisOfficialProductSumDecline(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_GetStatisOfficialProductSum(t *testing.T) {
|
func Test_GetStatisOfficialProductSum(t *testing.T) {
|
||||||
|
run()
|
||||||
configs := configConfig
|
configs := configConfig
|
||||||
o, err := NewBbxtTools(nil, lsxd.NewLogin(configs, utils.NewRdb(configConfig)))
|
o, err := NewBbxtTools(nil, lsxd.NewLogin(configs, utils.NewRdb(configConfig)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
s := "官方--美团外卖红包5元,官方--美团外卖红包10元,官方--饿了么超级会员月卡,官方--网易云黑胶vip月卡,官方--喜马拉雅巅峰会员月卡,官方--芒果-PC季卡,官方--芒果-PC月卡,官方--芒果-PC周卡,官方--腾讯-周卡,官方--优酷周卡,官方--QQ音乐-绿钻月卡,官方--爱奇艺-周卡,官方--腾讯-月卡,官方--腾讯-季卡,官方--腾讯-年卡,官方--优酷月卡,官方--优酷季卡,官方--优酷年卡,官方--爱奇艺-月卡,官方--爱奇艺-季卡,官方--爱奇艺-年卡"
|
s := "官方--腾讯-周卡,官方--腾讯-月卡,官方--腾讯-季卡,官方--腾讯-年卡,官方--优酷周卡,官方--优酷月卡,官方--优酷季卡,官方--优酷年卡,官方--爱奇艺-周卡,官方--爱奇艺-月卡,官方--爱奇艺-季卡,官方--爱奇艺-年卡,官方--芒果-PC周卡,官方--芒果-PC月卡,官方--芒果-PC季卡,官方--美团外卖红包5元,官方--美团外卖红包10元,官方--QQ音乐-绿钻月卡,官方--饿了么超级会员月卡,官方--网易云黑胶vip月卡,官方--喜马拉雅巅峰会员月卡"
|
||||||
report, err := o.GetStatisOfficialProductSum(time.Now(), strings.Split(s, ","))
|
now := time.Now()
|
||||||
|
noon := time.Date(
|
||||||
|
now.Year(),
|
||||||
|
now.Month(),
|
||||||
|
now.Day(),
|
||||||
|
12, 0, 0, 0,
|
||||||
|
now.Location(),
|
||||||
|
)
|
||||||
|
report, err := o.GetStatisOfficialProductSum(noon, strings.Split(s, ","))
|
||||||
|
|
||||||
t.Log(report, err)
|
t.Log(report, err)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue