huangjiajun 1 год назад
Родитель
Сommit
39075d9bda
4 измененных файлов: 64 добавлений и 1 удалений
  1. +17
    -0
      db/db_user_team_total.go
  2. +7
    -0
      db/model/user_team_total.go
  3. +1
    -0
      lib/comm_plan/init.go
  4. +39
    -1
      lib/comm_plan/winery.go

+ 17
- 0
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
}

+ 7
- 0
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)"`
}

+ 1
- 0
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 // 区块币利润


+ 39
- 1
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)


Загрузка…
Отмена
Сохранить