diff --git a/md/mq.go b/md/mq.go index 04476c0..153407d 100644 --- a/md/mq.go +++ b/md/mq.go @@ -4,6 +4,7 @@ const OneCirclesExchange = "one.circles" const ( OneCirclesRoutKeyForSignIn = "sign_in" // 签到 + OneCirclesRoutKeyForSignInUpdateRecords = "sign_in_update_records" // 签到更新记录 OneCirclesRoutKeyForStarLevelDividend = "star_level_dividend" // 星级分红 OneCirclesRoutKeyForAutoExchangeGreenEnergyToPerson = "auto_exchange_green_energy_to_person_1" // 自动兑换个人绿色能量 OneCirclesRoutKeyForAutoExchangeGreenEnergyToTeam = "auto_exchange_green_energy_to_team" // 自动兑换团队绿色能量 @@ -17,6 +18,10 @@ type OneCirclesStructForSignIn struct { Id int64 `json:"id"` EndTime string `json:"end_time"` } +type UpdateOneCirclesStructForSignInRecords struct { + Id int64 `json:"id"` + Uid int `json:"uid"` +} type OneCirclesStructForAutoExchangeGreenEnergy struct { MasterId string `json:"master_id"` diff --git a/rule/one_circles/one_circles_sign_in_green_energy_settlement.go b/rule/one_circles/one_circles_sign_in_green_energy_settlement.go index 36d4a80..095183b 100644 --- a/rule/one_circles/one_circles_sign_in_green_energy_settlement.go +++ b/rule/one_circles/one_circles_sign_in_green_energy_settlement.go @@ -72,18 +72,7 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string, ch *rabbi return } -func HandleSettlementSignInGreenEnergy(engine *xorm.Engine, masterId string, id int64, uid int, endTime string) (err error) { - //var signRecord model.OneCirclesGreenEnergySignIn - //has, err00000 := engine.Where("id =?", id).Get(&signRecord) - //if err00000 != nil { - // fmt.Println("err:::::0000000", err00000) - // return err00000 - //} - //if !has { - // //不活跃不需要奖励 - // return errors.New("未查询到对应记录") - //} - +func HandleSettlementSignInGreenEnergy(ch *rabbit.Channel, engine *xorm.Engine, masterId string, id int64, uid int, endTime string) (err error) { //1、查找 `one_circles_green_energy_basic_setting` 基础设置 oneCirclesGreenEnergyBasicSetting, cb, err := svc.GetPrice(engine, masterId) if err != nil { @@ -214,9 +203,14 @@ func HandleSettlementSignInGreenEnergy(engine *xorm.Engine, masterId string, id } //6、更新 `one_circles_green_energy_sign_in` 中的 is_completed 状态 - _, err = session.Where("id = ?", id).Update(&model.OneCirclesGreenEnergySignIn{ - IsCompleted: 1, - }) + //_, err = session.Where("id = ?", id).Update(&model.OneCirclesGreenEnergySignIn{ + // IsCompleted: 1, + //}) + //TODO::推入rabbitmq 异步处理 + ch.Publish(md.OneCirclesExchange, md.UpdateOneCirclesStructForSignInRecords{ + Uid: uid, + Id: id, + }, md.OneCirclesRoutKeyForSignInUpdateRecords) err = session.Commit() if err != nil {