dengbiao 2 tygodni temu
rodzic
commit
9e3855ecf0
2 zmienionych plików z 103 dodań i 1 usunięć
  1. +1
    -1
      rule/egg_energy/community_dividends.go
  2. +102
    -0
      rule/public_platoon_user_relation_commission.go

+ 1
- 1
rule/egg_energy/community_dividends.go Wyświetl plik

@@ -69,7 +69,7 @@ func AddCommunityDividends(engine *xorm.Engine, amount, name string, basic model
Nums: calcPriceIncreaseFormulaResp.GetEggEnergyNums,
Amount: amount,
Name: name,
CoinId: basic.ContributionCoinId,
CoinId: basic.TeamEggPointsCoinId,
PersonsNum: 0,
IsOver: 0,
CreateAt: now.Format("2006-01-02 15:04:05"),


+ 102
- 0
rule/public_platoon_user_relation_commission.go Wyświetl plik

@@ -818,6 +818,108 @@ func DealCommonWealthPunish(engine *xorm.Engine, uid int64, reason string) (err
return
}

// DealPublicPlatoon 处理公排注销
func DealPublicPlatoon(engine *xorm.Engine, uid int64, reason string) (err error, resp []map[string]string) {
session := engine.NewSession()
defer func() {
session.Close()
if err := recover(); err != nil {
_ = zhios_order_relate_logx.Error(err)
}
}()
session.Begin()

//1、查找 `user_public_platoon_setting` 基础设置
publicPlatoonBasicSettingDb := implement.NewPublicPlatoonBasicSettingDb(engine)
PublicPlatoonBasicSetting, err := publicPlatoonBasicSettingDb.PublicPlatoonBasicSettingGetOneByParams(map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
_ = session.Rollback()
return
}

//2、查询出 `public_platoon_user_relation` 中相关记录 && 将该记录的uid置为 -1
publicPlatoonUserRelationDb := implement.NewPublicPlatoonUserRelationDb(engine)
params, err := publicPlatoonUserRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{
"key": "uid",
"value": uid,
})
if err != nil {
_ = session.Rollback()
return
}
if params == nil {
fmt.Println("未查询到公排关系记录!!!!!!!", uid)
return
}

//TODO::判断是否为推荐用户
if params.RecommendUid == 0 {
params.Uid = params.Uid - int64(time.Now().Unix())
} else {
params.Uid = params.Uid - int64(time.Now().Unix())
}

for n := 1; n <= 9; n++ {
str := "father_uid" + strconv.Itoa(n)
sql := fmt.Sprintf("UPDATE `public_platoon_user_relation` SET %s=%s where %s=%s", str, egg_system_rules.Int64ToStr(params.Uid), str, egg_system_rules.Int64ToStr(uid))
fmt.Println(">>>>>>>sql>>>>>>>", sql)
_, err = session.Exec(sql)
if err != nil {
_ = session.Rollback()
return
}
}

updateAffected, err := publicPlatoonUserRelationDb.PublicPlatoonUserRelationUpdate(session, params.Id, params)
if err != nil {
_ = session.Rollback()
return
}
if updateAffected == 0 {
err = errors.New("更新 public_platoon_user_relation 记录失败")
_ = session.Rollback()
return
}

//3、新增一条 `public_platoon_user_relation` 记录
params.Uid = uid
res, err := PublicPlatoon(engine, params.Uid, params.RecommendUid, *PublicPlatoonBasicSetting)
if err != nil {
_ = session.Rollback()
return
}

//4、新增一条 `public_platoon_user_system_punish_records` 记录
now := time.Now()
publicPlatoonUserSystemPunishRecordsDb := implement.NewPublicPlatoonUserSystemPunishRecordsDb(engine)
insertAffected, err := publicPlatoonUserSystemPunishRecordsDb.PublicPlatoonUserSystemPunishRecordsInsert(session, &model.PublicPlatoonUserSystemPunishRecords{
Uid: params.Uid,
OldPosition: params.Position,
NewPosition: res.Position,
Date: now.AddDate(0, 0, 30).Format("2006-01-02"),
Title: "用户注销",
Reason: reason,
Type: 2,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
if err != nil {
_ = session.Rollback()
return
}
if insertAffected == 0 {
err = errors.New("新增 public_platoon_user_system_punish_records 记录失败")
_ = session.Rollback()
return
}

err = session.Commit()
return
}

const DealUserPublicPlatoonPunishLockKey = "deal_user_public_platoon_lock_key"

// DealUserPublicPlatoonPunish 处理公排处罚


Ładowanie…
Anuluj
Zapisz