|
|
@@ -4,7 +4,6 @@ import ( |
|
|
|
"applet/app/cfg" |
|
|
|
"applet/app/db" |
|
|
|
utils2 "applet/app/utils" |
|
|
|
"applet/app/utils/cache" |
|
|
|
"applet/app/utils/logx" |
|
|
|
"applet/consume/md" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
@@ -57,6 +56,7 @@ func EggEnergyTeamAssistanceConsume(queue md.MqQueue) { |
|
|
|
} |
|
|
|
|
|
|
|
func handleEggEnergyTeamAssistanceDataConsume(msgData []byte) error { |
|
|
|
return nil |
|
|
|
time.Sleep(time.Duration(10) * time.Millisecond) //休眠100毫秒 |
|
|
|
// 1.解析mq中queue的数据结构体 |
|
|
|
var msg *md2.EggEnergyTeamAssistanceReq |
|
|
@@ -65,14 +65,6 @@ func handleEggEnergyTeamAssistanceDataConsume(msgData []byte) error { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
// 2.查询用户是否已经助力过 |
|
|
|
//typesPrefix := "incentive_eggSmash" |
|
|
|
//callbackDb := implement.NewAdvertisingCallbackDb(db.Db) |
|
|
|
//count, err := callbackDb.AdvertisingCallbackCount(utils2.Int64ToStr(msg.AssistanceUid), msg.SignStart, msg.SignEnd, typesPrefix) |
|
|
|
//if err != nil { |
|
|
|
// return err |
|
|
|
//} |
|
|
|
|
|
|
|
// 2.查询数据库数据用户是否已经助力过 |
|
|
|
detailDb := implement.NewEggEnergyAssistanceDetailDb(db.Db) |
|
|
|
exist, err := detailDb.AssistanceDetailExist(msg.Uid, msg.AssistanceUid, msg.SignId) |
|
|
@@ -81,36 +73,22 @@ func handleEggEnergyTeamAssistanceDataConsume(msgData []byte) error { |
|
|
|
} |
|
|
|
now := time.Now() |
|
|
|
if !exist { |
|
|
|
// 数据库显示没有助力过才需要二次确认 |
|
|
|
cacheKey := fmt.Sprintf("EggEnergyTeamAssistance:%d", msg.Uid) |
|
|
|
if cache.Exists(cacheKey) { |
|
|
|
// 3. 判断 redis 该用户是否助力过 |
|
|
|
count, err1 := cache.GetBit(cacheKey, msg.AssistanceUid) |
|
|
|
if err1 != nil { |
|
|
|
return err1 |
|
|
|
} |
|
|
|
if count != 0 { |
|
|
|
// 3.1 该用户已经助力过 |
|
|
|
exist = true |
|
|
|
// 3.2 插入助力数据 |
|
|
|
detail := model.EggEnergyAssistanceDetail{ |
|
|
|
Uid: msg.Uid, |
|
|
|
AssistedUid: msg.AssistanceUid, |
|
|
|
SignId: msg.SignId, |
|
|
|
CreatedAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
UpdatedAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
} |
|
|
|
_, err = detailDb.AssistanceDetailInsert(&detail) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
//插入助力数据 |
|
|
|
detail := model.EggEnergyAssistanceDetail{ |
|
|
|
Uid: msg.Uid, |
|
|
|
AssistedUid: msg.AssistanceUid, |
|
|
|
SignId: msg.SignId, |
|
|
|
CreatedAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
UpdatedAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
} |
|
|
|
_, err = detailDb.AssistanceDetailInsert(&detail) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 4. 变更数据 |
|
|
|
// 3. 变更数据 |
|
|
|
assistanceDb := implement.NewEggEnergyTeamAssistanceDb(db.Db) |
|
|
|
|
|
|
|
date := now.Format("2006-01-02") |
|
|
|
session := db.Db.Where("") |
|
|
|
teamAssistance, err := assistanceDb.EggEnergyTeamAssistanceGetOneByParamsBySession(session, map[string]interface{}{ |
|
|
|