Browse Source

update 共富制度

tags/v1.7.8
DengBiao 2 years ago
parent
commit
9bc6ec730a
2 changed files with 173 additions and 60 deletions
  1. +6
    -5
      db/db_user_small_public_platoon_relation.go
  2. +167
    -55
      rule/small_public_platoon_relate_commission.go

+ 6
- 5
db/db_user_small_public_platoon_relation.go View File

@@ -101,24 +101,25 @@ func UserSmallPublicPlatoonRelationGetOneByPid(Db *xorm.Engine, recommendUid str
return &m, nil return &m, nil
} }


func UserSmallPublicPlatoonRelationFindByPid(Db *xorm.Engine, pid, fatherUid int, pidName, fatherName, positionName string) ([]model.UserSmallPublicPlatoonRelation, error) {
func UserSmallPublicPlatoonRelationFindByPid(Db *xorm.Engine, fatherUid int, fatherName, positionName string) ([]model.UserSmallPublicPlatoonRelation, error) {
var m []model.UserSmallPublicPlatoonRelation var m []model.UserSmallPublicPlatoonRelation
var query1 = fmt.Sprintf("%s >= ?", pidName)
//var query1 = fmt.Sprintf("%s >= ?", pidName)
var query2 = fmt.Sprintf("%s = ?", fatherName) var query2 = fmt.Sprintf("%s = ?", fatherName)
var order = fmt.Sprintf("%s Desc", positionName) var order = fmt.Sprintf("%s Desc", positionName)
if err := Db.Where(query1, pid).And(query2, fatherUid).OrderBy(order).
if err := Db.Where(query2, fatherUid).OrderBy(order).
Find(&m); err != nil { Find(&m); err != nil {
return nil, zhios_order_relate_logx.Warn(err) return nil, zhios_order_relate_logx.Warn(err)
} }
return m, nil return m, nil
} }


func UserSmallPublicPlatoonRelationFindCountByPosition(Db *xorm.Engine, positionName string, startPosition, endPosition int64) ([]model.UserSmallPublicPlatoonRelation, int64, error) {
func UserSmallPublicPlatoonRelationFindCountByPosition(Db *xorm.Engine, fatherUid int, fatherName, positionName string, startPosition, endPosition int64) ([]model.UserSmallPublicPlatoonRelation, int64, error) {
var m []model.UserSmallPublicPlatoonRelation var m []model.UserSmallPublicPlatoonRelation
var count int64 var count int64
var query1 = fmt.Sprintf("%s >= ?", positionName) var query1 = fmt.Sprintf("%s >= ?", positionName)
var query2 = fmt.Sprintf("%s <= ?", positionName) var query2 = fmt.Sprintf("%s <= ?", positionName)
if count, err := Db.Where(query1, startPosition).And(query2, endPosition).OrderBy("has_son_num ASC").
var query3 = fmt.Sprintf("%s = ?", fatherName)
if count, err := Db.Where(query3, fatherUid).And(query1, startPosition).And(query2, endPosition).OrderBy("has_son_num ASC").
FindAndCount(&m); err != nil { FindAndCount(&m); err != nil {
return nil, count, zhios_order_relate_logx.Warn(err) return nil, count, zhios_order_relate_logx.Warn(err)
} }


+ 167
- 55
rule/small_public_platoon_relate_commission.go View File

@@ -141,9 +141,16 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
if err != nil { if err != nil {
return model.UserSmallPublicPlatoonRelation{}, err return model.UserSmallPublicPlatoonRelation{}, err
} }
//if m == nil {
// recommendUid = 3
// m, err = db.UserSmallPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{
// "key": "uid",
// "value": recommendUid,
// })
//}


//2、 查找当前 user_small_public_platoon_relation 中 recommendUid 所有的子记录 //2、 查找当前 user_small_public_platoon_relation 中 recommendUid 所有的子记录
userSmallPublicPlatoonRelations, err := db.UserSmallPublicPlatoonRelationFindByPid(engine, m.Position1, m.Uid, "pid1", "father_uid1", "position1")
userSmallPublicPlatoonRelations, err := db.UserSmallPublicPlatoonRelationFindByPid(engine, m.Uid, "father_uid1", "position1")
if err != nil { if err != nil {
return model.UserSmallPublicPlatoonRelation{}, err return model.UserSmallPublicPlatoonRelation{}, err
} }
@@ -182,6 +189,33 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
standardSmallPublicPlatoonRelation.Position8 = smallReverseDeductionPositionByFather(m.Position7, m.Level7, userPublicPlatoonSetting.SeveralTimes, 0) standardSmallPublicPlatoonRelation.Position8 = smallReverseDeductionPositionByFather(m.Position7, m.Level7, userPublicPlatoonSetting.SeveralTimes, 0)
standardSmallPublicPlatoonRelation.Position9 = smallReverseDeductionPositionByFather(m.Position8, m.Level8, userPublicPlatoonSetting.SeveralTimes, 0) standardSmallPublicPlatoonRelation.Position9 = smallReverseDeductionPositionByFather(m.Position8, m.Level8, userPublicPlatoonSetting.SeveralTimes, 0)


if m.Level1 == 0 {
m.Level1--
}
if m.Level2 == 0 {
m.Level2--
}
if m.Level3 == 0 {
m.Level3--
}
if m.Level4 == 0 {
m.Level4--
}
if m.Level5 == 0 {
m.Level5--
}
if m.Level6 == 0 {
m.Level6--
}
if m.Level7 == 0 {
m.Level7--
}
if m.Level8 == 0 {
m.Level8--
}
if m.Level9 == 0 {
m.Level9--
}
standardSmallPublicPlatoonRelation.Level1 = m.Level + 1 standardSmallPublicPlatoonRelation.Level1 = m.Level + 1
standardSmallPublicPlatoonRelation.Level2 = m.Level1 + 1 standardSmallPublicPlatoonRelation.Level2 = m.Level1 + 1
standardSmallPublicPlatoonRelation.Level3 = m.Level2 + 1 standardSmallPublicPlatoonRelation.Level3 = m.Level2 + 1
@@ -197,8 +231,8 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
if len(userSmallPublicPlatoonRelations) == userPublicPlatoonSetting.SeveralTimes { if len(userSmallPublicPlatoonRelations) == userPublicPlatoonSetting.SeveralTimes {
var fatherLevel float64 var fatherLevel float64
smallMakeSearchLevel(&m.Position, float64(userPublicPlatoonSetting.SeveralTimes), &fatherLevel) smallMakeSearchLevel(&m.Position, float64(userPublicPlatoonSetting.SeveralTimes), &fatherLevel)
var times = 1
data, father, err := smallFindSuitablePosition(engine, &m.Position, float64(userPublicPlatoonSetting.SeveralTimes), int(fatherLevel), &times)
var times = 0
data, father, err := smallFindSuitablePosition(engine, &m.Position, float64(userPublicPlatoonSetting.SeveralTimes), m.Uid, int(fatherLevel), &times)
if err != nil { if err != nil {
return model.UserSmallPublicPlatoonRelation{}, err return model.UserSmallPublicPlatoonRelation{}, err
} }
@@ -207,35 +241,51 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
} else { } else {
fatherUid = m.Uid fatherUid = m.Uid


standardSmallPublicPlatoonRelation.FatherUid1 = m.Uid
standardSmallPublicPlatoonRelation.FatherUid2 = m.FatherUid1
standardSmallPublicPlatoonRelation.FatherUid3 = m.FatherUid2
standardSmallPublicPlatoonRelation.FatherUid4 = m.FatherUid3
standardSmallPublicPlatoonRelation.FatherUid5 = m.FatherUid4
standardSmallPublicPlatoonRelation.FatherUid6 = m.FatherUid5
standardSmallPublicPlatoonRelation.FatherUid7 = m.FatherUid6
standardSmallPublicPlatoonRelation.FatherUid8 = m.FatherUid7
standardSmallPublicPlatoonRelation.FatherUid9 = m.FatherUid8
standardSmallPublicPlatoonRelation.Pid1 = m.Position
standardSmallPublicPlatoonRelation.Pid2 = m.Position1
standardSmallPublicPlatoonRelation.Pid3 = m.Position2
standardSmallPublicPlatoonRelation.Pid4 = m.Position3
standardSmallPublicPlatoonRelation.Pid5 = m.Position4
standardSmallPublicPlatoonRelation.Pid6 = m.Position5
standardSmallPublicPlatoonRelation.Pid7 = m.Position6
standardSmallPublicPlatoonRelation.Pid8 = m.Position7
standardSmallPublicPlatoonRelation.Pid9 = m.Position8
standardSmallPublicPlatoonRelation.FatherUid1 = userSmallPublicPlatoonRelations[0].FatherUid1
standardSmallPublicPlatoonRelation.FatherUid2 = userSmallPublicPlatoonRelations[0].FatherUid2
standardSmallPublicPlatoonRelation.FatherUid3 = userSmallPublicPlatoonRelations[0].FatherUid3
standardSmallPublicPlatoonRelation.FatherUid4 = userSmallPublicPlatoonRelations[0].FatherUid4
standardSmallPublicPlatoonRelation.FatherUid5 = userSmallPublicPlatoonRelations[0].FatherUid5
standardSmallPublicPlatoonRelation.FatherUid6 = userSmallPublicPlatoonRelations[0].FatherUid6
standardSmallPublicPlatoonRelation.FatherUid7 = userSmallPublicPlatoonRelations[0].FatherUid7
standardSmallPublicPlatoonRelation.FatherUid8 = userSmallPublicPlatoonRelations[0].FatherUid8
standardSmallPublicPlatoonRelation.FatherUid9 = userSmallPublicPlatoonRelations[0].FatherUid9
standardSmallPublicPlatoonRelation.Pid1 = userSmallPublicPlatoonRelations[0].Pid1
standardSmallPublicPlatoonRelation.Pid2 = userSmallPublicPlatoonRelations[0].Pid2
standardSmallPublicPlatoonRelation.Pid3 = userSmallPublicPlatoonRelations[0].Pid3
standardSmallPublicPlatoonRelation.Pid4 = userSmallPublicPlatoonRelations[0].Pid4
standardSmallPublicPlatoonRelation.Pid5 = userSmallPublicPlatoonRelations[0].Pid5
standardSmallPublicPlatoonRelation.Pid6 = userSmallPublicPlatoonRelations[0].Pid6
standardSmallPublicPlatoonRelation.Pid7 = userSmallPublicPlatoonRelations[0].Pid7
standardSmallPublicPlatoonRelation.Pid8 = userSmallPublicPlatoonRelations[0].Pid8
standardSmallPublicPlatoonRelation.Pid9 = userSmallPublicPlatoonRelations[0].Pid9


standardSmallPublicPlatoonRelation.Position1 = userSmallPublicPlatoonRelations[0].Position1 + 1 standardSmallPublicPlatoonRelation.Position1 = userSmallPublicPlatoonRelations[0].Position1 + 1
standardSmallPublicPlatoonRelation.Position2 = userSmallPublicPlatoonRelations[0].Position2 + 1
standardSmallPublicPlatoonRelation.Position3 = userSmallPublicPlatoonRelations[0].Position3 + 1
standardSmallPublicPlatoonRelation.Position4 = userSmallPublicPlatoonRelations[0].Position4 + 1
standardSmallPublicPlatoonRelation.Position5 = userSmallPublicPlatoonRelations[0].Position5 + 1
standardSmallPublicPlatoonRelation.Position6 = userSmallPublicPlatoonRelations[0].Position6 + 1
standardSmallPublicPlatoonRelation.Position7 = userSmallPublicPlatoonRelations[0].Position7 + 1
standardSmallPublicPlatoonRelation.Position8 = userSmallPublicPlatoonRelations[0].Position8 + 1
standardSmallPublicPlatoonRelation.Position9 = userSmallPublicPlatoonRelations[0].Position9 + 1
if userSmallPublicPlatoonRelations[0].Position2 != 0 {
standardSmallPublicPlatoonRelation.Position2 = userSmallPublicPlatoonRelations[0].Position2 + 1
}
if userSmallPublicPlatoonRelations[0].Position3 != 0 {
standardSmallPublicPlatoonRelation.Position3 = userSmallPublicPlatoonRelations[0].Position3 + 1
}
if userSmallPublicPlatoonRelations[0].Position4 != 0 {
standardSmallPublicPlatoonRelation.Position4 = userSmallPublicPlatoonRelations[0].Position4 + 1
}
if userSmallPublicPlatoonRelations[0].Position5 != 0 {
standardSmallPublicPlatoonRelation.Position5 = userSmallPublicPlatoonRelations[0].Position5 + 1
}
if userSmallPublicPlatoonRelations[0].Position6 != 0 {
standardSmallPublicPlatoonRelation.Position6 = userSmallPublicPlatoonRelations[0].Position6 + 1
}
if userSmallPublicPlatoonRelations[0].Position7 != 0 {
standardSmallPublicPlatoonRelation.Position7 = userSmallPublicPlatoonRelations[0].Position7 + 1
}
if userSmallPublicPlatoonRelations[0].Position8 != 0 {
standardSmallPublicPlatoonRelation.Position8 = userSmallPublicPlatoonRelations[0].Position8 + 1
}
if userSmallPublicPlatoonRelations[0].Position9 != 0 {
standardSmallPublicPlatoonRelation.Position9 = userSmallPublicPlatoonRelations[0].Position9 + 1
}


standardSmallPublicPlatoonRelation.Level1 = userSmallPublicPlatoonRelations[0].Level1 standardSmallPublicPlatoonRelation.Level1 = userSmallPublicPlatoonRelations[0].Level1
standardSmallPublicPlatoonRelation.Level2 = userSmallPublicPlatoonRelations[0].Level2 standardSmallPublicPlatoonRelation.Level2 = userSmallPublicPlatoonRelations[0].Level2
@@ -280,14 +330,14 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
userSmallPublicPlatoonRelation.FatherUid = fatherUidStr userSmallPublicPlatoonRelation.FatherUid = fatherUidStr


userSmallPublicPlatoonRelation.FatherUid1 = standardSmallPublicPlatoonRelation.FatherUid1 userSmallPublicPlatoonRelation.FatherUid1 = standardSmallPublicPlatoonRelation.FatherUid1
userSmallPublicPlatoonRelation.FatherUid2 = standardSmallPublicPlatoonRelation.FatherUid1
userSmallPublicPlatoonRelation.FatherUid3 = standardSmallPublicPlatoonRelation.FatherUid2
userSmallPublicPlatoonRelation.FatherUid4 = standardSmallPublicPlatoonRelation.FatherUid3
userSmallPublicPlatoonRelation.FatherUid5 = standardSmallPublicPlatoonRelation.FatherUid4
userSmallPublicPlatoonRelation.FatherUid6 = standardSmallPublicPlatoonRelation.FatherUid5
userSmallPublicPlatoonRelation.FatherUid7 = standardSmallPublicPlatoonRelation.FatherUid6
userSmallPublicPlatoonRelation.FatherUid8 = standardSmallPublicPlatoonRelation.FatherUid7
userSmallPublicPlatoonRelation.FatherUid9 = standardSmallPublicPlatoonRelation.FatherUid8
userSmallPublicPlatoonRelation.FatherUid2 = standardSmallPublicPlatoonRelation.FatherUid2
userSmallPublicPlatoonRelation.FatherUid3 = standardSmallPublicPlatoonRelation.FatherUid3
userSmallPublicPlatoonRelation.FatherUid4 = standardSmallPublicPlatoonRelation.FatherUid4
userSmallPublicPlatoonRelation.FatherUid5 = standardSmallPublicPlatoonRelation.FatherUid5
userSmallPublicPlatoonRelation.FatherUid6 = standardSmallPublicPlatoonRelation.FatherUid6
userSmallPublicPlatoonRelation.FatherUid7 = standardSmallPublicPlatoonRelation.FatherUid7
userSmallPublicPlatoonRelation.FatherUid8 = standardSmallPublicPlatoonRelation.FatherUid8
userSmallPublicPlatoonRelation.FatherUid9 = standardSmallPublicPlatoonRelation.FatherUid9
userSmallPublicPlatoonRelation.Pid1 = standardSmallPublicPlatoonRelation.Pid1 userSmallPublicPlatoonRelation.Pid1 = standardSmallPublicPlatoonRelation.Pid1
userSmallPublicPlatoonRelation.Pid2 = standardSmallPublicPlatoonRelation.Pid2 userSmallPublicPlatoonRelation.Pid2 = standardSmallPublicPlatoonRelation.Pid2
userSmallPublicPlatoonRelation.Pid3 = standardSmallPublicPlatoonRelation.Pid3 userSmallPublicPlatoonRelation.Pid3 = standardSmallPublicPlatoonRelation.Pid3
@@ -297,6 +347,7 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
userSmallPublicPlatoonRelation.Pid7 = standardSmallPublicPlatoonRelation.Pid7 userSmallPublicPlatoonRelation.Pid7 = standardSmallPublicPlatoonRelation.Pid7
userSmallPublicPlatoonRelation.Pid8 = standardSmallPublicPlatoonRelation.Pid8 userSmallPublicPlatoonRelation.Pid8 = standardSmallPublicPlatoonRelation.Pid8
userSmallPublicPlatoonRelation.Pid9 = standardSmallPublicPlatoonRelation.Pid9 userSmallPublicPlatoonRelation.Pid9 = standardSmallPublicPlatoonRelation.Pid9
userSmallPublicPlatoonRelation.Position = 1
userSmallPublicPlatoonRelation.Position1 = standardSmallPublicPlatoonRelation.Position1 userSmallPublicPlatoonRelation.Position1 = standardSmallPublicPlatoonRelation.Position1
userSmallPublicPlatoonRelation.Position2 = standardSmallPublicPlatoonRelation.Position2 userSmallPublicPlatoonRelation.Position2 = standardSmallPublicPlatoonRelation.Position2
userSmallPublicPlatoonRelation.Position3 = standardSmallPublicPlatoonRelation.Position3 userSmallPublicPlatoonRelation.Position3 = standardSmallPublicPlatoonRelation.Position3
@@ -306,6 +357,7 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
userSmallPublicPlatoonRelation.Position7 = standardSmallPublicPlatoonRelation.Position7 userSmallPublicPlatoonRelation.Position7 = standardSmallPublicPlatoonRelation.Position7
userSmallPublicPlatoonRelation.Position8 = standardSmallPublicPlatoonRelation.Position8 userSmallPublicPlatoonRelation.Position8 = standardSmallPublicPlatoonRelation.Position8
userSmallPublicPlatoonRelation.Position9 = standardSmallPublicPlatoonRelation.Position9 userSmallPublicPlatoonRelation.Position9 = standardSmallPublicPlatoonRelation.Position9
userSmallPublicPlatoonRelation.Level = 1
userSmallPublicPlatoonRelation.Level1 = standardSmallPublicPlatoonRelation.Level1 userSmallPublicPlatoonRelation.Level1 = standardSmallPublicPlatoonRelation.Level1
userSmallPublicPlatoonRelation.Level2 = standardSmallPublicPlatoonRelation.Level2 userSmallPublicPlatoonRelation.Level2 = standardSmallPublicPlatoonRelation.Level2
userSmallPublicPlatoonRelation.Level3 = standardSmallPublicPlatoonRelation.Level3 userSmallPublicPlatoonRelation.Level3 = standardSmallPublicPlatoonRelation.Level3
@@ -315,6 +367,7 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
userSmallPublicPlatoonRelation.Level7 = standardSmallPublicPlatoonRelation.Level7 userSmallPublicPlatoonRelation.Level7 = standardSmallPublicPlatoonRelation.Level7
userSmallPublicPlatoonRelation.Level8 = standardSmallPublicPlatoonRelation.Level8 userSmallPublicPlatoonRelation.Level8 = standardSmallPublicPlatoonRelation.Level8
userSmallPublicPlatoonRelation.Level9 = standardSmallPublicPlatoonRelation.Level9 userSmallPublicPlatoonRelation.Level9 = standardSmallPublicPlatoonRelation.Level9
userSmallPublicPlatoonRelation.LevelTotal = standardSmallPublicPlatoonRelation.LevelTotal
userSmallPublicPlatoonRelation.RecommendUid = recommendUid userSmallPublicPlatoonRelation.RecommendUid = recommendUid
userSmallPublicPlatoonRelation.WaitForSettlementDate = now.AddDate(0, 0, userPublicPlatoonSetting.SettleDay).Format("2006-01-02") userSmallPublicPlatoonRelation.WaitForSettlementDate = now.AddDate(0, 0, userPublicPlatoonSetting.SettleDay).Format("2006-01-02")
userSmallPublicPlatoonRelation.JoinAt = now userSmallPublicPlatoonRelation.JoinAt = now
@@ -419,28 +472,34 @@ func smallReverseDeductionPosition(calcPosition, levelFirstPosition, severalTime
} }


func smallReverseDeductionPositionByFather(fatherPosition, level, severalTimes, remainder int) (position int) { func smallReverseDeductionPositionByFather(fatherPosition, level, severalTimes, remainder int) (position int) {
if fatherPosition == 0 {
position = 0
return
}
firstPosition := smallGetLevelForFirstPosition(level, severalTimes) firstPosition := smallGetLevelForFirstPosition(level, severalTimes)
endPosition := firstPosition + int(math.Pow(float64(severalTimes), float64(level))) - 1
position = fatherPosition + (fatherPosition-firstPosition)*severalTimes + (endPosition - fatherPosition) + remainder
endPosition := firstPosition + int(math.Pow(float64(severalTimes), float64(level-1))) - 1
position = fatherPosition + (fatherPosition-firstPosition)*severalTimes + (endPosition - fatherPosition) + 1
return return
} }


func smallFindSuitablePosition(engine *xorm.Engine, position *int, severalTimes float64, fatherLevel int, times *int) (standardSmallPublicPlatoonRelation md.StandardSmallPublicPlatoonRelation, fatherUid int, err error) {
func smallFindSuitablePosition(engine *xorm.Engine, position *int, severalTimes float64, fuid, fatherLevel int, times *int) (standardSmallPublicPlatoonRelation md.StandardSmallPublicPlatoonRelation, fatherUid int, err error) {
*times++ *times++
positionName := "position" + zhios_order_relate_utils.IntToStr(*times) positionName := "position" + zhios_order_relate_utils.IntToStr(*times)
fatherName := "father_uid" + zhios_order_relate_utils.IntToStr(*times)
firstSonPosition := smallSearchPositionFirstSonPosition(*position, int(severalTimes)) firstSonPosition := smallSearchPositionFirstSonPosition(*position, int(severalTimes))
var tempLevel float64 var tempLevel float64
smallMakeSearchLevel(&firstSonPosition, severalTimes, &tempLevel) smallMakeSearchLevel(&firstSonPosition, severalTimes, &tempLevel)
firstSonLevel := int(tempLevel) firstSonLevel := int(tempLevel)
endSonPosition := firstSonPosition + int(math.Pow(severalTimes, float64(firstSonLevel-fatherLevel))) - 1 endSonPosition := firstSonPosition + int(math.Pow(severalTimes, float64(firstSonLevel-fatherLevel))) - 1
list, _, err := db.UserSmallPublicPlatoonRelationFindCountByPosition(engine, positionName, int64(firstSonPosition), int64(endSonPosition))
list, _, err := db.UserSmallPublicPlatoonRelationFindCountByPosition(engine, fuid, fatherName, positionName, int64(firstSonPosition), int64(endSonPosition))
if err != nil { if err != nil {
return standardSmallPublicPlatoonRelation, fatherUid, err return standardSmallPublicPlatoonRelation, fatherUid, err
} }

if list[0].HasSonNum == int(severalTimes) { if list[0].HasSonNum == int(severalTimes) {
//TODO::则证明该层直属下级无空位 //TODO::则证明该层直属下级无空位
position = &firstSonPosition position = &firstSonPosition
return smallFindSuitablePosition(engine, position, severalTimes, fatherLevel, times)
return smallFindSuitablePosition(engine, position, severalTimes, fuid, fatherLevel, times)
} else if list[0].HasSonNum == 0 { } else if list[0].HasSonNum == 0 {
fatherUid = list[0].Uid fatherUid = list[0].Uid


@@ -475,6 +534,33 @@ func smallFindSuitablePosition(engine *xorm.Engine, position *int, severalTimes
standardSmallPublicPlatoonRelation.Position8 = smallReverseDeductionPositionByFather(list[0].Position7, list[0].Level7, int(severalTimes), 0) standardSmallPublicPlatoonRelation.Position8 = smallReverseDeductionPositionByFather(list[0].Position7, list[0].Level7, int(severalTimes), 0)
standardSmallPublicPlatoonRelation.Position9 = smallReverseDeductionPositionByFather(list[0].Position8, list[0].Level8, int(severalTimes), 0) standardSmallPublicPlatoonRelation.Position9 = smallReverseDeductionPositionByFather(list[0].Position8, list[0].Level8, int(severalTimes), 0)


if list[0].Level1 == 0 {
list[0].Level1--
}
if list[0].Level2 == 0 {
list[0].Level2--
}
if list[0].Level3 == 0 {
list[0].Level3--
}
if list[0].Level4 == 0 {
list[0].Level4--
}
if list[0].Level5 == 0 {
list[0].Level5--
}
if list[0].Level6 == 0 {
list[0].Level6--
}
if list[0].Level7 == 0 {
list[0].Level7--
}
if list[0].Level8 == 0 {
list[0].Level8--
}
if list[0].Level9 == 0 {
list[0].Level9--
}
standardSmallPublicPlatoonRelation.Level1 = list[0].Level + 1 standardSmallPublicPlatoonRelation.Level1 = list[0].Level + 1
standardSmallPublicPlatoonRelation.Level2 = list[0].Level1 + 1 standardSmallPublicPlatoonRelation.Level2 = list[0].Level1 + 1
standardSmallPublicPlatoonRelation.Level3 = list[0].Level2 + 1 standardSmallPublicPlatoonRelation.Level3 = list[0].Level2 + 1
@@ -488,14 +574,40 @@ func smallFindSuitablePosition(engine *xorm.Engine, position *int, severalTimes
} else { } else {
fatherUid = list[0].Uid fatherUid = list[0].Uid


getPositionValue, _, _, _, getPositionName, gePidName, _, fatherUidName := getPosition(list[0], *times+1)
userSmallPublicPlatoonRelations, err := db.UserSmallPublicPlatoonRelationFindByPid(engine, getPositionValue, list[0].Uid, gePidName, fatherUidName, getPositionName)
//userSmallPublicPlatoonRelations, err := db.UserSmallPublicPlatoonRelationFindByPid(engine, m.Position1, m.Uid, "pid1", "father_uid1", "position1")
_, _, _, _, getPositionName, _, _, _ := getPosition(list[0], *times+1)
//userSmallPublicPlatoonRelations, err := db.UserSmallPublicPlatoonRelationFindByPid(engine, m.Position, m.Uid, "pid1", "father_uid1", "position1")

userSmallPublicPlatoonRelations, err := db.UserSmallPublicPlatoonRelationFindByPid(engine, list[0].Uid, "father_uid1", getPositionName)


if err != nil { if err != nil {
return standardSmallPublicPlatoonRelation, fatherUid, err return standardSmallPublicPlatoonRelation, fatherUid, err
} }


if userSmallPublicPlatoonRelations[0].Position2 == 0 {
userSmallPublicPlatoonRelations[0].Position2 = -1
}
if userSmallPublicPlatoonRelations[0].Position3 == 0 {
standardSmallPublicPlatoonRelation.Position3 = -1
}
if userSmallPublicPlatoonRelations[0].Position4 == 0 {
standardSmallPublicPlatoonRelation.Position4 = -1
}
if userSmallPublicPlatoonRelations[0].Position5 == 0 {
standardSmallPublicPlatoonRelation.Position5 = -1
}
if userSmallPublicPlatoonRelations[0].Position6 == 0 {
standardSmallPublicPlatoonRelation.Position6 = -1
}
if userSmallPublicPlatoonRelations[0].Position7 == 0 {
standardSmallPublicPlatoonRelation.Position7 = -1
}
if userSmallPublicPlatoonRelations[0].Position8 == 0 {
standardSmallPublicPlatoonRelation.Position8 = -1
}
if userSmallPublicPlatoonRelations[0].Position9 == 0 {
standardSmallPublicPlatoonRelation.Position9 = -1
}

standardSmallPublicPlatoonRelation = md.StandardSmallPublicPlatoonRelation{ standardSmallPublicPlatoonRelation = md.StandardSmallPublicPlatoonRelation{
FatherUid1: userSmallPublicPlatoonRelations[0].FatherUid1, FatherUid1: userSmallPublicPlatoonRelations[0].FatherUid1,
FatherUid2: userSmallPublicPlatoonRelations[0].FatherUid2, FatherUid2: userSmallPublicPlatoonRelations[0].FatherUid2,
@@ -549,7 +661,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level1 level = m.Level1
levelName = "level1" levelName = "level1"
fatherUid = m.FatherUid1 fatherUid = m.FatherUid1
levelName = "father_uid1"
fatherUidName = "father_uid1"
} }
if times == 2 { if times == 2 {
position = m.Position2 position = m.Position2
@@ -559,7 +671,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level2 level = m.Level2
levelName = "level2" levelName = "level2"
fatherUid = m.FatherUid2 fatherUid = m.FatherUid2
levelName = "father_uid2"
fatherUidName = "father_uid2"
} }
if times == 3 { if times == 3 {
position = m.Position3 position = m.Position3
@@ -569,7 +681,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level3 level = m.Level3
levelName = "level3" levelName = "level3"
fatherUid = m.FatherUid3 fatherUid = m.FatherUid3
levelName = "father_uid3"
fatherUidName = "father_uid3"
} }
if times == 4 { if times == 4 {
position = m.Position4 position = m.Position4
@@ -579,7 +691,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level4 level = m.Level4
levelName = "level4" levelName = "level4"
fatherUid = m.FatherUid4 fatherUid = m.FatherUid4
levelName = "father_uid4"
fatherUidName = "father_uid4"
} }
if times == 5 { if times == 5 {
position = m.Position5 position = m.Position5
@@ -589,7 +701,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level5 level = m.Level5
levelName = "level5" levelName = "level5"
fatherUid = m.FatherUid5 fatherUid = m.FatherUid5
levelName = "father_uid5"
fatherUidName = "father_uid5"
} }
if times == 6 { if times == 6 {
position = m.Position6 position = m.Position6
@@ -599,7 +711,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level6 level = m.Level6
levelName = "level6" levelName = "level6"
fatherUid = m.FatherUid6 fatherUid = m.FatherUid6
levelName = "father_uid6"
fatherUidName = "father_uid6"
} }
if times == 7 { if times == 7 {
position = m.Position7 position = m.Position7
@@ -609,7 +721,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level7 level = m.Level7
levelName = "level7" levelName = "level7"
fatherUid = m.FatherUid7 fatherUid = m.FatherUid7
levelName = "father_uid7"
fatherUidName = "father_uid7"
} }
if times == 8 { if times == 8 {
position = m.Position8 position = m.Position8
@@ -619,7 +731,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level8 level = m.Level8
levelName = "level8" levelName = "level8"
fatherUid = m.FatherUid8 fatherUid = m.FatherUid8
levelName = "father_uid8"
fatherUidName = "father_uid8"
} }
if times == 9 { if times == 9 {
position = m.Position9 position = m.Position9
@@ -629,7 +741,7 @@ func getPosition(m model.UserSmallPublicPlatoonRelation, times int) (position, p
level = m.Level9 level = m.Level9
levelName = "level9" levelName = "level9"
fatherUid = m.FatherUid9 fatherUid = m.FatherUid9
levelName = "father_uid9"
fatherUidName = "father_uid9"
} }
return return
} }


Loading…
Cancel
Save