Browse Source

update

master
dengbiao 1 month ago
parent
commit
62e7a9ea46
2 changed files with 13 additions and 2 deletions
  1. +1
    -0
      md/mq.go
  2. +12
    -2
      rule/honey_dividend/dividend.go

+ 1
- 0
md/mq.go View File

@@ -46,6 +46,7 @@ type HoneyDividendForUserDividend struct {
Amount string `json:"amount"` Amount string `json:"amount"`
DestroyHoneyValues string `json:"destroy_honey_values"` DestroyHoneyValues string `json:"destroy_honey_values"`
CoinId int `json:"coin_id"` CoinId int `json:"coin_id"`
DividendVipLevel int `json:"dividend_vip_level"`
} }


type HoneyContributionExchangeForUserDividend struct { type HoneyContributionExchangeForUserDividend struct {


+ 12
- 2
rule/honey_dividend/dividend.go View File

@@ -42,7 +42,7 @@ func CollectDividendData(eg *xorm.Engine, masterId string, ch *rabbit.Channel) (
nowHoneys := results1[0]["total"] //当前蜂蜜总量 nowHoneys := results1[0]["total"] //当前蜂蜜总量


//2、统计当前`可以分红`的用户数量 //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) results2, _ := db.QueryNativeString(eg, sql2)
nowUsers := results2[0]["total"] //当前用户总量 nowUsers := results2[0]["total"] //当前用户总量


@@ -92,6 +92,7 @@ func CollectDividendData(eg *xorm.Engine, masterId string, ch *rabbit.Channel) (
Amount: amount, Amount: amount,
DestroyHoneyValues: base.DestroyHoneyValues, DestroyHoneyValues: base.DestroyHoneyValues,
CoinId: base.CoinId, CoinId: base.CoinId,
DividendVipLevel: base.DividendVipLevel,
}, md2.HoneyDividendRoutKeyForUserDividend) }, md2.HoneyDividendRoutKeyForUserDividend)
} }
time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) 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 { 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、进行蜂蜜销毁 //1、进行蜂蜜销毁
err := rule.DealUserCoin(session, md2.DealUserCoinReq{
err = rule.DealUserCoin(session, md2.DealUserCoinReq{
Kind: "sub", Kind: "sub",
Mid: data.MasterId, Mid: data.MasterId,
Title: md2.HoneyDividendForDestroy, Title: md2.HoneyDividendForDestroy,


Loading…
Cancel
Save