From 62e7a9ea46fe72330bc7698751fdbfe5d28e7441 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Tue, 3 Sep 2024 14:02:55 +0800 Subject: [PATCH] update --- md/mq.go | 1 + rule/honey_dividend/dividend.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/md/mq.go b/md/mq.go index edeb5ec..4541be4 100644 --- a/md/mq.go +++ b/md/mq.go @@ -46,6 +46,7 @@ type HoneyDividendForUserDividend struct { Amount string `json:"amount"` DestroyHoneyValues string `json:"destroy_honey_values"` CoinId int `json:"coin_id"` + DividendVipLevel int `json:"dividend_vip_level"` } type HoneyContributionExchangeForUserDividend struct { diff --git a/rule/honey_dividend/dividend.go b/rule/honey_dividend/dividend.go index e4296b4..3abc655 100644 --- a/rule/honey_dividend/dividend.go +++ b/rule/honey_dividend/dividend.go @@ -42,7 +42,7 @@ func CollectDividendData(eg *xorm.Engine, masterId string, ch *rabbit.Channel) ( nowHoneys := results1[0]["total"] //当前蜂蜜总量 //2、统计当前`可以分红`的用户数量 - var sql2 = fmt.Sprintf("SELECT COUNT(*)AS total FROM `user_virtual_amount` WHERE coin_id = %d and amount >= %s", base.CoinId, base.DestroyHoneyValues) + var sql2 = fmt.Sprintf("SELECT COUNT(*)AS total FROM `user_virtual_amount` uva LEFT JOIN user u on u.uid=uva.uid WHERE uva.coin_id = %d AND uva.amount >= %s and u.level > %d", base.CoinId, base.DestroyHoneyValues, base.DividendVipLevel) results2, _ := db.QueryNativeString(eg, sql2) nowUsers := results2[0]["total"] //当前用户总量 @@ -92,6 +92,7 @@ func CollectDividendData(eg *xorm.Engine, masterId string, ch *rabbit.Channel) ( Amount: amount, DestroyHoneyValues: base.DestroyHoneyValues, CoinId: base.CoinId, + DividendVipLevel: base.DividendVipLevel, }, md2.HoneyDividendRoutKeyForUserDividend) } time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) @@ -111,8 +112,17 @@ func CollectDividendData(eg *xorm.Engine, masterId string, ch *rabbit.Channel) ( } func DealDividendReward(session *xorm.Session, data md2.HoneyDividendForUserDividend) error { + userData, err := db.UserFindByID(session.Engine(), data.Uid) + if err != nil || userData == nil { + return errors.New("查询用户数据失败") + } + if userData.Level < data.DividendVipLevel { + //TODO::用户等级不够,不参与分红 + return nil + } + //1、进行蜂蜜销毁 - err := rule.DealUserCoin(session, md2.DealUserCoinReq{ + err = rule.DealUserCoin(session, md2.DealUserCoinReq{ Kind: "sub", Mid: data.MasterId, Title: md2.HoneyDividendForDestroy,