|
|
@@ -302,24 +302,6 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//2、查找对应pid的 user_public_platoon_relation 记录 |
|
|
|
var m1 model.UserSmallPublicPlatoonRelation |
|
|
|
if has, err := engine.Where("uid=?", fatherUid).Get(&m1); err != nil || has == false { |
|
|
|
return userSmallPublicPlatoonRelation, err |
|
|
|
} |
|
|
|
var fatherUidStr string |
|
|
|
if m1.FatherUid == "" { |
|
|
|
//TODO::顶级 |
|
|
|
fatherUidStr = zhios_order_relate_utils.IntToStr(m1.Uid) |
|
|
|
} else { |
|
|
|
fatherUids := strings.Split(m1.FatherUid, "-") |
|
|
|
if len(fatherUids) > userPublicPlatoonSetting.SeveralRows { |
|
|
|
fatherUidStr = zhios_order_relate_utils.IntToStr(m1.Uid) + "-" + strings.Join(fatherUids[0:userPublicPlatoonSetting.SeveralRows:len(fatherUids)], "-") |
|
|
|
} else { |
|
|
|
fatherUidStr = zhios_order_relate_utils.IntToStr(m1.Uid) + "-" + m1.FatherUid |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if userPublicPlatoonSetting.SettleDay == 0 { |
|
|
|
userPublicPlatoonSetting.SettleDay = 30 |
|
|
|
} |
|
|
@@ -327,7 +309,6 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl |
|
|
|
// 3、插入 user_public_platoon_relation 记录 |
|
|
|
now := time.Now() |
|
|
|
userSmallPublicPlatoonRelation.Uid = uid |
|
|
|
userSmallPublicPlatoonRelation.FatherUid = fatherUidStr |
|
|
|
|
|
|
|
userSmallPublicPlatoonRelation.FatherUid1 = standardSmallPublicPlatoonRelation.FatherUid1 |
|
|
|
userSmallPublicPlatoonRelation.FatherUid2 = standardSmallPublicPlatoonRelation.FatherUid2 |
|
|
@@ -374,12 +355,38 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl |
|
|
|
userSmallPublicPlatoonRelation.CreateAt = now // |
|
|
|
userSmallPublicPlatoonRelation.UpdateAt = now |
|
|
|
userSmallPublicPlatoonRelation.HasSonNum = 0 |
|
|
|
_, err = db.UserSmallPublicPlatoonRelationInsert(engine, &userSmallPublicPlatoonRelation) |
|
|
|
insertId, err := db.UserSmallPublicPlatoonRelationInsert(engine, &userSmallPublicPlatoonRelation) |
|
|
|
if err != nil { |
|
|
|
return model.UserSmallPublicPlatoonRelation{}, err |
|
|
|
} |
|
|
|
|
|
|
|
// 4、改变直属父级的 has_son_num 数量 |
|
|
|
// 4、回更 father_uid 字段 |
|
|
|
var m1 model.UserSmallPublicPlatoonRelation |
|
|
|
if has, err := engine.Where("uid=?", fatherUid).Get(&m1); err != nil || has == false { |
|
|
|
return userSmallPublicPlatoonRelation, err |
|
|
|
} |
|
|
|
var fatherUidStr string |
|
|
|
if m1.FatherUid == "" { |
|
|
|
//TODO::顶级 |
|
|
|
fatherUidStr = zhios_order_relate_utils.IntToStr(insertId) |
|
|
|
} else { |
|
|
|
fatherUids := strings.Split(m1.FatherUid, "-") |
|
|
|
if len(fatherUids) > userPublicPlatoonSetting.SeveralRows { |
|
|
|
fatherUidStr = zhios_order_relate_utils.IntToStr(insertId) + "-" + strings.Join(fatherUids[0:userPublicPlatoonSetting.SeveralRows:len(fatherUids)], "-") |
|
|
|
} else { |
|
|
|
fatherUidStr = zhios_order_relate_utils.IntToStr(insertId) + "-" + m1.FatherUid |
|
|
|
} |
|
|
|
} |
|
|
|
userSmallPublicPlatoonRelation.FatherUid = fatherUidStr |
|
|
|
affected, err := db.UserSmallPublicPlatoonRelationUpdate(engine.NewSession(), userSmallPublicPlatoonRelation.Id, &userSmallPublicPlatoonRelation, "father_uid") |
|
|
|
if err != nil { |
|
|
|
return model.UserSmallPublicPlatoonRelation{}, err |
|
|
|
} |
|
|
|
if affected == 0 { |
|
|
|
return model.UserSmallPublicPlatoonRelation{}, errors.New("更新 user_small_public_platoon_relation 记录失败") |
|
|
|
} |
|
|
|
|
|
|
|
// 5、改变直属父级的 has_son_num 数量 |
|
|
|
update, err := engine.Where("uid = ?", fatherUid).SetExpr("has_son_num", "has_son_num + 1").Update(new(model.UserSmallPublicPlatoonRelation)) |
|
|
|
if err != nil { |
|
|
|
return userSmallPublicPlatoonRelation, err |
|
|
|