From 999adf6feece749e98cab44604b5c0780661a7e5 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 28 Nov 2023 17:18:55 +0800 Subject: [PATCH] update --- rule/public_platoon_relate_commission.go | 108 ++++++++++++----------- 1 file changed, 55 insertions(+), 53 deletions(-) diff --git a/rule/public_platoon_relate_commission.go b/rule/public_platoon_relate_commission.go index 8fa0ca1..e36c7c4 100644 --- a/rule/public_platoon_relate_commission.go +++ b/rule/public_platoon_relate_commission.go @@ -382,62 +382,64 @@ func DealCommonWealthPunish(engine *xorm.Engine, uid int, reason string) (err er 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 - } + 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 - } + //3、新增一条 `user_public_platoon_relation` 记录 + params.Uid = uid + res, err := publicPlatoon(engine, params.Uid, params.RecommendUid, *userPublicPlatoonSetting) + if err != nil { + _ = 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 - } + //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() + err = session.Commit() + } return }