|
@@ -381,65 +381,66 @@ func DealCommonWealthPunish(engine *xorm.Engine, uid int, reason string) (err er |
|
|
_ = session.Rollback() |
|
|
_ = session.Rollback() |
|
|
return |
|
|
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 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|