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