Browse Source

更新

tags/v4.3.1
huangjiajun 1 year ago
parent
commit
cf508102ca
2 changed files with 86 additions and 40 deletions
  1. +5
    -3
      db/model/user_team_total.go
  2. +81
    -37
      lib/comm_plan/winery.go

+ 5
- 3
db/model/user_team_total.go View File

@@ -1,7 +1,9 @@
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)"`
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)"`
FirstCount int `json:"first_count" xorm:"default 0 INT(11)"`
SecondCount int `json:"second_count" xorm:"default 0 INT(11)"`
}

+ 81
- 37
lib/comm_plan/winery.go View File

@@ -2,6 +2,7 @@ package comm_plan

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
"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"
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
"fmt"
@@ -158,43 +159,8 @@ Loop:
// 同级奖
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 < teamCountMin {
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 >= teamCountMin {
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 < teamCountMin {
node.ParentUser.IsFreeze = 1
}
}
}
checkCond(eg, node.ParentUser.Uid, teamCountMin)
Check(eg, node.ParentUser.Uid, teamCountMin)
}
peerRate = 0
//同级奖励比例
@@ -268,6 +234,84 @@ Loop:

return nil
}
func Check(eg *xorm.Engine, uid, teamCountMin int) int {
//找出前两个人 如果不是就分团队奖 如果是就再找
sql := `SELECT u.uid,u.first_arrive_at FROM user_profile up
LEFT JOIN user u on u.uid=up.uid
WHERE up.parent_uid=? and u.level>0 ORDER BY u.first_arrive_at asc,u.uid asc LIMIT 2`
nativeString, err := db.QueryNativeString(eg, sql, uid)
if err != nil {
return 1
}
isAllFreeze := 1
firstCount := 0
secondCount := 0
for k, v := range nativeString {
isfreeze, count := checkCond(eg, zhios_order_relate_utils.StrToInt(v["uid"]), teamCountMin)
if isfreeze == 0 {
isAllFreeze = 0
} else {
isAllFreeze = 1
}
if k == 0 {
firstCount = count
}
if k == 1 {
secondCount = count
}
}
eg.Where("uid=?", uid).Cols("first_count,second_count").Update(&model.UserTeamTotal{FirstCount: firstCount, SecondCount: secondCount})
if len(nativeString) < 2 {
return 1
}
return isAllFreeze
}
func checkCond(eg *xorm.Engine, uid, teamCountMin int) (int, int) {
isfreeze := 0
teamtotal := db.GetUserTeamTotal(eg, zhios_order_relate_utils.IntToStr(uid))
total := 0
if teamtotal == nil || teamtotal != nil && teamtotal.TeamCount < teamCountMin {
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, 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 >= teamCountMin {
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=?", uid).Update(teamtotal)
}
if nCount < teamCountMin {
isfreeze = 1
}
total = nCount
}
} else {
total = teamtotal.TeamCount
}
return isfreeze, total
}

func teamDiffMoneyWinery(profit float64, payMode, isOnlySubsidy int, totalAmt, restAmt, teamRatio, totalRatio, peerRate, subsidyFee, subsidyRatio float64) (float64, float64, float64, float64, bool) {
// 如果是团队内部支出团队比例大于同级累计比例 或站长支出
if payMode == 1 || teamRatio > peerRate {


Loading…
Cancel
Save