diff --git a/db/db_user_team_total.go b/db/db_user_team_total.go new file mode 100644 index 0000000..edf63c1 --- /dev/null +++ b/db/db_user_team_total.go @@ -0,0 +1,17 @@ +package db + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" + zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" + "xorm.io/xorm" +) + +func GetUserTeamTotal(eg *xorm.Engine, uid string) *model.UserTeamTotal { + var data model.UserTeamTotal + get, _ := eg.Where("uid=?", uid).Get(&data) + if get == false { + data = model.UserTeamTotal{Uid: zhios_order_relate_utils.StrToInt(uid)} + eg.Insert(&data) + } + return &data +} diff --git a/db/model/user_team_total.go b/db/model/user_team_total.go new file mode 100644 index 0000000..3e9304b --- /dev/null +++ b/db/model/user_team_total.go @@ -0,0 +1,7 @@ +package model + +type UserTeamTotal struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uid int `json:"uid" xorm:"default 0 unique INT(11)"` + TeamCount int `json:"team_count" xorm:"default 0 INT(11)"` +} diff --git a/lib/comm_plan/init.go b/lib/comm_plan/init.go index 30a34ff..f06c2d0 100644 --- a/lib/comm_plan/init.go +++ b/lib/comm_plan/init.go @@ -170,6 +170,7 @@ type LvUser struct { Profit float64 // 利润(金额) SubsidyFee float64 // 补贴(金额) MinLevel int + IsFreeze int //IntegralProfit float64 // 积分利润 //IntegralSubsidyFee float64 // 积分补贴 //BlockIconsProfit float64 // 区块币利润 diff --git a/lib/comm_plan/winery.go b/lib/comm_plan/winery.go index 493fd7f..6403979 100644 --- a/lib/comm_plan/winery.go +++ b/lib/comm_plan/winery.go @@ -153,7 +153,45 @@ Loop: if isNext == 0 { // 同级奖 if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum { - + if peerNum >= 1 && node.ParentUser.Lv >= 2 { + teamtotal := db.GetUserTeamTotal(eg, zhios_order_relate_utils.IntToStr(node.ParentUser.Uid)) + if teamtotal == nil || teamtotal != nil && teamtotal.TeamCount < 15 { + sql1 := `SELECT ur.uid,up.parent_uid,ur.level FROM user_relate ur + LEFT JOIN user_profile up on ur.uid=up.uid + LEFT JOIN user u on u.uid=ur.uid + WHERE ur.parent_uid=? and u.level>0 and ur.level<20 ORDER BY ur.level asc,u.first_arrive_at asc,u.uid asc + ` + nativeString1, _ := db.QueryNativeString(eg, sql1, node.ParentUser.Uid) + if len(nativeString1) > 0 { + var nMap = make(map[string][]string) + nCount := 0 + for _, v := range nativeString1 { + if zhios_order_relate_utils.StrToInt(v["uid"]) == 0 || nCount > 15 { + continue + } + if v["level"] == "1" && len(nMap[v["level"]]) < 2 { + nMap[v["level"]] = append(nMap[v["level"]], v["uid"]) + nCount++ + } else if len(nMap[v["level"]]) < 2 { + lastLevel := zhios_order_relate_utils.IntToStr(zhios_order_relate_utils.StrToInt(v["level"]) - 1) + for _, v1 := range nMap[lastLevel] { + if v["parent_uid"] == v1 { + nMap[v["level"]] = append(nMap[v["level"]], v["uid"]) + nCount++ + } + } + } + } + if teamtotal != nil { + teamtotal.TeamCount = nCount + eg.Where("uid=?", node.ParentUser.Uid).Update(teamtotal) + } + if nCount < 15 { + node.ParentUser.IsFreeze = 1 + } + } + } + } peerRate = 0 //同级奖励比例 commission, commissionRatio, amountList, ratioList := CalReturnAmountAndRatioWinery(maxLv, userList.OwnbuyReturnType, peerNum, "same_lv", sameProfit, sameProfitList, opt)