shenjiachi vor 3 Tagen
Ursprung
Commit
0a3f5794c3
3 geänderte Dateien mit 16 neuen und 18 gelöschten Zeilen
  1. +13
    -15
      consume/egg_energy_team_assistance_consume.go
  2. +2
    -2
      consume/egg_energy_team_assistance_consume_test.go
  3. +1
    -1
      go.mod

+ 13
- 15
consume/egg_energy_team_assistance_consume.go Datei anzeigen

@@ -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
}

+ 2
- 2
consume/egg_energy_team_assistance_consume_test.go Datei anzeigen

@@ -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",


+ 1
- 1
go.mod Datei anzeigen

@@ -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


Laden…
Abbrechen
Speichern