From 0a3f5794c348eaab73ed6e7426d2192274a148ac Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 19 Dec 2024 15:29:00 +0800 Subject: [PATCH] update --- consume/egg_energy_team_assistance_consume.go | 28 +++++++++---------- ...egg_energy_team_assistance_consume_test.go | 4 +-- go.mod | 2 +- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/consume/egg_energy_team_assistance_consume.go b/consume/egg_energy_team_assistance_consume.go index 7438555..edf1a42 100644 --- a/consume/egg_energy_team_assistance_consume.go +++ b/consume/egg_energy_team_assistance_consume.go @@ -65,10 +65,8 @@ func handleEggEnergyTeamAssistanceDataConsume(msgData []byte) error { } // 2.查询用户是否已经助力过 - session := db.Db.NewSession() - defer session.Close() callbackDb := implement.NewAdvertisingCallbackDb(db.Db) - count, err := callbackDb.AdvertisingCallbackCountBySession(session, utils2.Int64ToStr(msg.AssistanceUid), msg.SignStart, msg.SignEnd, "") + count, err := callbackDb.AdvertisingCallbackCount(utils2.Int64ToStr(msg.AssistanceUid), msg.SignStart, msg.SignEnd, "") if err != nil { return err } @@ -77,22 +75,22 @@ func handleEggEnergyTeamAssistanceDataConsume(msgData []byte) error { assistanceDb := implement.NewEggEnergyTeamAssistanceDb(db.Db) now := time.Now() date := now.Format("2006-01-02") - teamAssistance, err := assistanceDb.EggEnergyTeamAssistanceGetOneBySession(session, msg.Uid, date) + teamAssistance, err := assistanceDb.EggEnergyTeamAssistanceGetOne(msg.Uid, date) if err != nil { return err } if teamAssistance == nil { m := model.EggEnergyTeamAssistance{ - Uid: msg.Uid, - AssistedNum: 1, - RewardScore: utils2.Float64ToStr(msg.AssistanceValue), - Date: date, - CreateAt: now.Format("2006-01-02 15:04:05"), - UpdateAt: now.Format("2006-01-02 15:04:05"), + Uid: msg.Uid, + AssistedNum: 1, + AssistedTimes: 1, + RewardScore: utils2.Float64ToStr(msg.AssistanceValue), + Date: date, + CreateAt: now.Format("2006-01-02 15:04:05"), + UpdateAt: now.Format("2006-01-02 15:04:05"), } - _, err = assistanceDb.EggEnergyTeamAssistanceInsertBySession(session, &m) + _, err = assistanceDb.EggEnergyTeamAssistanceInsert(&m) if err != nil { - session.Rollback() return err } } else { @@ -101,12 +99,12 @@ func handleEggEnergyTeamAssistanceDataConsume(msgData []byte) error { if count == 1 { teamAssistance.AssistedNum++ } - _, err = assistanceDb.EggEnergyTeamAssistanceUpdateBySession(session, teamAssistance.Id, teamAssistance, "assisted_num", "reward_score") + teamAssistance.AssistedTimes++ + _, err = assistanceDb.EggEnergyTeamAssistanceUpdate(teamAssistance.Id, teamAssistance, "assisted_num", "reward_score") if err != nil { - session.Rollback() return err } } - return session.Commit() + return nil } diff --git a/consume/egg_energy_team_assistance_consume_test.go b/consume/egg_energy_team_assistance_consume_test.go index 605b694..9376c16 100644 --- a/consume/egg_energy_team_assistance_consume_test.go +++ b/consume/egg_energy_team_assistance_consume_test.go @@ -33,8 +33,8 @@ func TestEggEnergyTeamAssistanceConsume(t *testing.T) { } defer ch.Release() ch.Publish(md2.EggEnergyExchange, md2.EggEnergyTeamAssistanceReq{ - AssistanceUid: 27, - Uid: 16, + AssistanceUid: 16, + Uid: 2, AssistanceValue: 100, SignStart: "2024-12-19 08:00:00", SignEnd: "2024-12-20 08:00:00", diff --git a/go.mod b/go.mod index d79ffcf..f7b37fd 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ go 1.19 //replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241219065721-3ff292c78b75 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241219072808-f579b7f54bab code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241219043645-3f6b3590ae75 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5