|
|
@@ -169,19 +169,18 @@ func AddPublicPlatoonRelateCommission(engine *xorm.Engine, AddPublicPlatoonRelat |
|
|
|
*/ |
|
|
|
func publicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPlatoonSetting model.UserPublicPlatoonSetting) (model.UserPublicPlatoonRelation, error) { |
|
|
|
var userPublicPlatoonRelation model.UserPublicPlatoonRelation |
|
|
|
//1、 查找当前 user_public_platoon_relation 中 `newest_public_platoon` 的位置 |
|
|
|
m, err := db.UserPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{ |
|
|
|
"key": "newest_public_platoon", |
|
|
|
"value": 1, |
|
|
|
}) |
|
|
|
|
|
|
|
//1、 查找当前 user_public_platoon_relation 中 `position` 最大的记录 |
|
|
|
var m model.UserPublicPlatoonRelation |
|
|
|
has, err := engine.OrderBy("newest_public_platoon desc").Get(&m) |
|
|
|
if err != nil { |
|
|
|
return userPublicPlatoonRelation, err |
|
|
|
} |
|
|
|
if m == nil { |
|
|
|
if has == false { |
|
|
|
return userPublicPlatoonRelation, errors.New("查询 user_public_platoon_relation 记录失败") |
|
|
|
} |
|
|
|
|
|
|
|
//TODO::判断 `newest_public_platoon + userPublicPlatoonSetting.SeveralTimes(几乘)` OR `newest_public_platoon + 1` |
|
|
|
//TODO::判断 `position + userPublicPlatoonSetting.SeveralTimes(几乘)` OR `position + 1` |
|
|
|
var position, position1, position2 int |
|
|
|
position1 = m.Position + 1 |
|
|
|
position2 = m.Position + userPublicPlatoonSetting.SeveralTimes |
|
|
@@ -243,7 +242,7 @@ func publicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPlatoon |
|
|
|
userPublicPlatoonRelation.JoinAt = now |
|
|
|
userPublicPlatoonRelation.CreateAt = now |
|
|
|
userPublicPlatoonRelation.UpdateAt = now |
|
|
|
userPublicPlatoonRelation.NewestPublicPlatoon = 1 |
|
|
|
userPublicPlatoonRelation.NewestPublicPlatoon = m.NewestPublicPlatoon + 1 |
|
|
|
_, err = db.UserPublicPlatoonRelationInsert(engine, &userPublicPlatoonRelation) |
|
|
|
if err != nil { |
|
|
|
return model.UserPublicPlatoonRelation{}, err |
|
|
|