diff --git a/db/db_user_small_public_platoon_relation.go b/db/db_user_small_public_platoon_relation.go index 9009b18..f2974a6 100644 --- a/db/db_user_small_public_platoon_relation.go +++ b/db/db_user_small_public_platoon_relation.go @@ -94,7 +94,7 @@ func UserSmallPublicPlatoonRelationFindByEmptyPosition(Db *xorm.Engine) (*model. func UserSmallPublicPlatoonRelationGetOneByPid(Db *xorm.Engine, recommendUid string, params map[string]interface{}) (*model.UserSmallPublicPlatoonRelation, error) { 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 { return nil, zhios_order_relate_logx.Error(err) } diff --git a/rule/small_public_platoon_relate_commission.go b/rule/small_public_platoon_relate_commission.go index f9337c4..799b1c6 100644 --- a/rule/small_public_platoon_relate_commission.go +++ b/rule/small_public_platoon_relate_commission.go @@ -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_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" "errors" + "fmt" "math" "strconv" "strings" @@ -42,12 +43,13 @@ func AddSmallPublicPlatoonRelateCommission(engine *xorm.Engine, AddSmallPublicPl //判断是否有uid为-2 (代表等待新用户填充) 的记录 userSmallPublicPlatoonRelation, err := db.UserSmallPublicPlatoonRelationGetOneByPid(engine, param.RecommendUid, map[string]interface{}{ "key": "uid", - "value": -2, + "value": -1, }) if err != nil { return nil, err } if userSmallPublicPlatoonRelation != nil { + oldUid := userSmallPublicPlatoonRelation.Uid userSmallPublicPlatoonRelation.Uid = zhios_order_relate_utils.StrToInt(param.Uid) updateAffected, err := db.UserSmallPublicPlatoonRelationUpdate(engine.NewSession(), userSmallPublicPlatoonRelation.Id, userSmallPublicPlatoonRelation) if err != nil { @@ -57,6 +59,15 @@ func AddSmallPublicPlatoonRelateCommission(engine *xorm.Engine, AddSmallPublicPl err = errors.New("更新 user_public_platoon_relation 记录失败") return nil, err } 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 } continue @@ -975,11 +986,24 @@ func SmallDealCommonWealthPunish(engine *xorm.Engine, uid int, reason string) (e err = errors.New("未查询到公排关系记录") _ = session.Rollback() } + oldUid := params.Uid + //TODO::判断是否为推荐用户 if params.RecommendUid == 0 { - params.Uid = -1 + params.Uid = params.Uid - 9999999999 } 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)