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