diff --git a/db/model/user_public_platoon_relation.go b/db/model/user_public_platoon_relation.go index 62fe1a4..c690b65 100644 --- a/db/model/user_public_platoon_relation.go +++ b/db/model/user_public_platoon_relation.go @@ -18,5 +18,5 @@ type UserPublicPlatoonRelation struct { WaitForSettlementDate string `json:"wait_for_settlement_date" xorm:"not null default '' comment('待结算时间(0000-00)') CHAR(50)"` CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - NewestPublicPlatoon int `json:"newest_public_platoon" xorm:"not null default 0 comment('最新公排') TINYINT(1)"` + NewestPublicPlatoon int `json:"newest_public_platoon" xorm:"not null default 1 comment('最新公排') INT(11)"` } diff --git a/rule/public_platoon_relate_commission.go b/rule/public_platoon_relate_commission.go index c94cd12..61b6c7f 100644 --- a/rule/public_platoon_relate_commission.go +++ b/rule/public_platoon_relate_commission.go @@ -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