From 411c6eb679bc419b3f5d366a089eb37875f29734 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Mon, 3 Jul 2023 15:54:56 +0800 Subject: [PATCH] Update cp_pairs_stat.go --- script/cp_pairs_stat.go | 90 +++++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/script/cp_pairs_stat.go b/script/cp_pairs_stat.go index 4540411..4c6cc9a 100644 --- a/script/cp_pairs_stat.go +++ b/script/cp_pairs_stat.go @@ -67,17 +67,25 @@ func getChargeMoneyDiamond(uid uint64, sinceTime time.Time) int64 { } type CpInfo struct { - Id uint64 - UserId1 uint64 - UserId2 uint64 - Code1 string - Code2 string - UserId1Area string - UserId2Area string - Level uint64 - Points uint64 - CreatedTime time.Time - Charge float64 + Id uint64 + UserId1 uint64 + UserId2 uint64 + Code1 string + Code2 string + UserId1Area string + UserId2Area string + Level uint64 + Points uint64 + CreatedTime time.Time + Charge float64 + M1 int + M2 int + M3 int + M4 int + M5 int + M6 int + M7 int + ModifyAnniversary int } type CpLevel struct { @@ -128,6 +136,7 @@ func main() { cpInfos[i].UserId2Area = getAreaByCode2(uM[v.UserId2].Code) cpInfos[i].Points = v.Points + CpLevelPoints[v.Level] cpInfos[i].Charge = float64(getChargeMoneyDiamond(v.UserId1, v.CreatedTime)+getChargeMoneyDiamond(v.UserId2, v.CreatedTime)) / 100 + cpInfos[i].ModifyAnniversary, cpInfos[i].M1, cpInfos[i].M2, cpInfos[i].M3, cpInfos[i].M4, cpInfos[i].M5, cpInfos[i].M6, cpInfos[i].M7 = modifyAnniversary(v.Id) } excelFileName := fmt.Sprintf("./cp数据.xlsx") xlFile := xlsx.NewFile() @@ -136,16 +145,65 @@ func main() { panic(err) } row := sheet.AddRow() - c1, c2, c3, c4, c5, c6, c7, c8, c9 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() - c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value, c8.Value, c9.Value = "cp ID", "userId1", "userId2", "user1区域", "user2区域", "等级", "积分", "绑定后充值金额 $", "绑定时间" + c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() + c11, c12, c13, c14, c15, c16, c17 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() + c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value, c8.Value, c9.Value, c10.Value = "cp ID", "userId1", "userId2", "user1区域", "user2区域", "等级", "积分", "绑定后充值金额 $", "绑定时间", "是否修改纪念日" + c11.Value, c12.Value, c13.Value, c14.Value, c15.Value, c16.Value, c17.Value = "我们在一起", "XXX的生日", "XXX的生日", "第一次说我爱你", "第一次亲吻", "结婚纪念日", "用户自行编辑" + for _, d := range cpInfos { row := sheet.AddRow() - c1, c2, c3, c4, c5, c6, c7, c8, c9 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() - c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value, c8.Value, c9.Value = - ats26(d.Id), ats26(d.Code1), ats26(d.Code2), ats26(d.UserId1Area), ats26(d.UserId2Area), ats26(d.Level), ats26(d.Points), ats26(d.Charge), ats26(d.CreatedTime.Format("2006-01-02 15:04:05")) + c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() + c11, c12, c13, c14, c15, c16, c17 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() + c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value, c8.Value, c9.Value, c10.Value = + ats26(d.Id), ats26(d.Code1), ats26(d.Code2), ats26(d.UserId1Area), ats26(d.UserId2Area), ats26(d.Level), ats26(d.Points), ats26(d.Charge), ats26(d.CreatedTime.Format("2006-01-02 15:04:05")), ats26(d.ModifyAnniversary) + c11.Value, c12.Value, c13.Value, c14.Value, c15.Value, c16.Value, c17.Value = ats26(d.M1), ats26(d.M2), ats26(d.M3), ats26(d.M4), ats26(d.M5), ats26(d.M6), ats26(d.M7) } _ = xlFile.Save(excelFileName) //var data []CpPairData } + +type CpAnniversary struct { + CpId uint64 + Sort int + Type int + MsgId int + Timestamp int + CreatedTime time.Time `gorm:"->"` + UpdatedTime time.Time `gorm:"->"` +} + +func modifyAnniversary(cpId uint64) (t, m1, m2, m3, m4, m5, m6, m7 int) { + var an []CpAnniversary + if err := mysql.ProdReadOnlyDB.Model(CpAnniversary{}).Where("cp_id = ? AND timestamp > 0 ", cpId).Find(&an).Error; err != nil { + panic(err) + } + for _, a := range an { + if a.MsgId == 259 && a.UpdatedTime.Second() != 0 { + m1 = 1 + } + if a.MsgId == 260 && a.Type == 2 { + m2 = 1 + } + if a.MsgId == 260 && a.Type == 3 { + m3 = 1 + } + if a.MsgId == 261 { + m4 = 1 + } + if a.MsgId == 262 { + m5 = 1 + } + if a.MsgId == 263 { + m6 = 1 + } + if a.MsgId == 0 { + m7++ + } + } + if m1 > 0 || m2 > 0 || m3 > 0 || m4 > 0 || m5 > 0 || m6 > 0 || m7 > 0 { + t = 1 + } + return +} -- 2.22.0