Browse Source

update 共富制度

tags/v1.8.1
DengBiao 2 years ago
parent
commit
0dcb62cdf9
2 changed files with 28 additions and 4 deletions
  1. +1
    -1
      db/db_user_small_public_platoon_relation.go
  2. +27
    -3
      rule/small_public_platoon_relate_commission.go

+ 1
- 1
db/db_user_small_public_platoon_relation.go View File

@@ -94,7 +94,7 @@ func UserSmallPublicPlatoonRelationFindByEmptyPosition(Db *xorm.Engine) (*model.


func UserSmallPublicPlatoonRelationGetOneByPid(Db *xorm.Engine, recommendUid string, params map[string]interface{}) (*model.UserSmallPublicPlatoonRelation, error) { func UserSmallPublicPlatoonRelationGetOneByPid(Db *xorm.Engine, recommendUid string, params map[string]interface{}) (*model.UserSmallPublicPlatoonRelation, error) {
var m model.UserSmallPublicPlatoonRelation var m model.UserSmallPublicPlatoonRelation
var query = fmt.Sprintf("%s =?", params["key"])
var query = fmt.Sprintf("%s <=?", params["key"])
if has, err := Db.Where("recommend_uid = ?", recommendUid).And(query, params["value"]).Get(&m); err != nil || has == false { if has, err := Db.Where("recommend_uid = ?", recommendUid).And(query, params["value"]).Get(&m); err != nil || has == false {
return nil, zhios_order_relate_logx.Error(err) return nil, zhios_order_relate_logx.Error(err)
} }


+ 27
- 3
rule/small_public_platoon_relate_commission.go View File

@@ -8,6 +8,7 @@ import (
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" 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" zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
"errors" "errors"
"fmt"
"math" "math"
"strconv" "strconv"
"strings" "strings"
@@ -42,12 +43,13 @@ func AddSmallPublicPlatoonRelateCommission(engine *xorm.Engine, AddSmallPublicPl
//判断是否有uid为-2 (代表等待新用户填充) 的记录 //判断是否有uid为-2 (代表等待新用户填充) 的记录
userSmallPublicPlatoonRelation, err := db.UserSmallPublicPlatoonRelationGetOneByPid(engine, param.RecommendUid, map[string]interface{}{ userSmallPublicPlatoonRelation, err := db.UserSmallPublicPlatoonRelationGetOneByPid(engine, param.RecommendUid, map[string]interface{}{
"key": "uid", "key": "uid",
"value": -2,
"value": -1,
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }
if userSmallPublicPlatoonRelation != nil { if userSmallPublicPlatoonRelation != nil {
oldUid := userSmallPublicPlatoonRelation.Uid
userSmallPublicPlatoonRelation.Uid = zhios_order_relate_utils.StrToInt(param.Uid) userSmallPublicPlatoonRelation.Uid = zhios_order_relate_utils.StrToInt(param.Uid)
updateAffected, err := db.UserSmallPublicPlatoonRelationUpdate(engine.NewSession(), userSmallPublicPlatoonRelation.Id, userSmallPublicPlatoonRelation) updateAffected, err := db.UserSmallPublicPlatoonRelationUpdate(engine.NewSession(), userSmallPublicPlatoonRelation.Id, userSmallPublicPlatoonRelation)
if err != nil { if err != nil {
@@ -57,6 +59,15 @@ func AddSmallPublicPlatoonRelateCommission(engine *xorm.Engine, AddSmallPublicPl
err = errors.New("更新 user_public_platoon_relation 记录失败") err = errors.New("更新 user_public_platoon_relation 记录失败")
return nil, err return nil, err
} else { } else {
for n := 1; n <= 9; n++ {
str := "father_uid" + strconv.Itoa(n)
sql := fmt.Sprintf("UPDATE `user_small_public_platoon_relation` SET %s=%s where %s=%s", str, strconv.Itoa(oldUid), str, param.Uid)
fmt.Println(">>>>>>>sql>>>>>>>", sql)
_, err = engine.Exec(sql)
if err != nil {
return nil, err
}
}
resp[param.Uid] = userSmallPublicPlatoonRelation resp[param.Uid] = userSmallPublicPlatoonRelation
} }
continue continue
@@ -975,11 +986,24 @@ func SmallDealCommonWealthPunish(engine *xorm.Engine, uid int, reason string) (e
err = errors.New("未查询到公排关系记录") err = errors.New("未查询到公排关系记录")
_ = session.Rollback() _ = session.Rollback()
} }
oldUid := params.Uid

//TODO::判断是否为推荐用户 //TODO::判断是否为推荐用户
if params.RecommendUid == 0 { if params.RecommendUid == 0 {
params.Uid = -1
params.Uid = params.Uid - 9999999999
} else { } else {
params.Uid = -2
params.Uid = params.Uid - 9999999999
}

for n := 1; n <= 9; n++ {
str := "father_uid" + strconv.Itoa(n)
sql := fmt.Sprintf("UPDATE `user_small_public_platoon_relation` SET %s=%s where %s=%s", str, strconv.Itoa(oldUid), str, strconv.Itoa(params.Uid))
fmt.Println(">>>>>>>sql>>>>>>>", sql)
_, err = session.Exec(sql)
if err != nil {
_ = session.Rollback()
return
}
} }


updateAffected, err := db.UserSmallPublicPlatoonRelationUpdate(session, params.Id, params) updateAffected, err := db.UserSmallPublicPlatoonRelationUpdate(session, params.Id, params)


Loading…
Cancel
Save