Browse Source

update

master
DengBiao 1 year ago
parent
commit
999adf6fee
1 changed files with 55 additions and 53 deletions
  1. +55
    -53
      rule/public_platoon_relate_commission.go

+ 55
- 53
rule/public_platoon_relate_commission.go View File

@@ -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
}



Loading…
Cancel
Save