From cdd5206f3f0b14a062860c96c80970f7782ae46b Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 28 Nov 2023 17:27:01 +0800 Subject: [PATCH] update --- rule/public_platoon_relate_commission.go | 111 ++++++++++++----------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/rule/public_platoon_relate_commission.go b/rule/public_platoon_relate_commission.go index e36c7c4..a735df2 100644 --- a/rule/public_platoon_relate_commission.go +++ b/rule/public_platoon_relate_commission.go @@ -381,65 +381,66 @@ func DealCommonWealthPunish(engine *xorm.Engine, uid int, reason string) (err er _ = session.Rollback() return } + if userPublicPlatoonSetting.SystemPunishReplace != 1 { //TODO::未开启处罚 + return + } - if userPublicPlatoonSetting.SystemPunishReplace == 1 { - //2、查询出 `user_public_platoon_relation` 中相关记录 && 将该记录的uid置为 -1 - params, err := db.UserPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{ - "key": "uid", - "value": uid, - }) - if err != nil { - _ = session.Rollback() - return - } - if params == nil { - err = errors.New("未查询到公排关系记录") - _ = session.Rollback() - } - params.Uid = -1 - updateAffected, err := db.UserPublicPlatoonRelationUpdate(session, params.Id, params, "uid") - if err != nil { - _ = session.Rollback() - return - } - if updateAffected == 0 { - err = errors.New("更新 user_public_platoon_relation 记录失败") - _ = session.Rollback() - return - } - - //3、新增一条 `user_public_platoon_relation` 记录 - params.Uid = uid - res, err := publicPlatoon(engine, params.Uid, params.RecommendUid, *userPublicPlatoonSetting) - if err != nil { - _ = session.Rollback() - return - } + //2、查询出 `user_public_platoon_relation` 中相关记录 && 将该记录的uid置为 -1 + params, err := db.UserPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{ + "key": "uid", + "value": uid, + }) + if err != nil { + _ = session.Rollback() + return + } + if params == nil { + err = errors.New("未查询到公排关系记录") + _ = session.Rollback() + } + params.Uid = -1 + updateAffected, err := db.UserPublicPlatoonRelationUpdate(session, params.Id, params, "uid") + if err != nil { + _ = session.Rollback() + return + } + if updateAffected == 0 { + err = errors.New("更新 user_public_platoon_relation 记录失败") + _ = session.Rollback() + return + } - //4、新增一条 `user_public_platoon_system_punish_records` 记录 - now := time.Now() - insertAffected, err := db.UserPublicPlatoonSystemPunishRecordsInsert(session, &model.UserPublicPlatoonSystemPunishRecords{ - Uid: params.Uid, - OldPostion: params.Position, - NewPostion: res.Position, - Date: now.AddDate(0, 0, 30).Format("2006-01-02"), - Title: "共富收益-系统处罚记录", - Reason: reason, - CreateAt: now, - UpdateAt: now, - }) - if err != nil { - _ = session.Rollback() - return - } - if insertAffected == 0 { - err = errors.New("新增 user_public_platoon_system_punish_records 记录失败") - _ = session.Rollback() - return - } + //3、新增一条 `user_public_platoon_relation` 记录 + params.Uid = uid + res, err := publicPlatoon(engine, params.Uid, params.RecommendUid, *userPublicPlatoonSetting) + if err != nil { + _ = session.Rollback() + return + } - err = session.Commit() + //4、新增一条 `user_public_platoon_system_punish_records` 记录 + now := time.Now() + insertAffected, err := db.UserPublicPlatoonSystemPunishRecordsInsert(session, &model.UserPublicPlatoonSystemPunishRecords{ + Uid: params.Uid, + OldPostion: params.Position, + NewPostion: res.Position, + Date: now.AddDate(0, 0, 30).Format("2006-01-02"), + Title: "共富收益-系统处罚记录", + Reason: reason, + CreateAt: now, + UpdateAt: now, + }) + if err != nil { + _ = session.Rollback() + return + } + if insertAffected == 0 { + err = errors.New("新增 user_public_platoon_system_punish_records 记录失败") + _ = session.Rollback() + return } + + err = session.Commit() return }