Browse Source

update 一个圈圈

master
DengBiao 10 months ago
parent
commit
90649135bc
2 changed files with 48 additions and 41 deletions
  1. +31
    -20
      rule/one_circles/one_circles_sign_in_green_energy_settlement.go
  2. +17
    -21
      rule/public_platoon_double_network_relate_commission.go

+ 31
- 20
rule/one_circles/one_circles_sign_in_green_energy_settlement.go View File

@@ -86,27 +86,29 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string) (err erro
return err1 return err1
} }
var parentRewardValue = zhios_order_relate_utils.StrToFloat64(rewardValue) var parentRewardValue = zhios_order_relate_utils.StrToFloat64(rewardValue)
for _, relate := range *relates {
if parentRewardValue <= rewardEndValue {
break
if relates != nil {
for _, relate := range *relates {
if parentRewardValue <= rewardEndValue {
break
}
parentRewardValue = parentRewardValue * rewardDecrement
err = DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: masterId,
Title: md.OneCirclesGreenEnergySignInSettlementTeamReward,
TransferType: md.OneCirclesGreenEnergySignInSettlementTeamRewardForUserVirtualCoinFlow,
OrdId: "",
CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId,
Uid: relate.Uid,
Amount: parentRewardValue,
})
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::44444", err)
return err
}
reduceTotalGreenEnergy += parentRewardValue
} }
parentRewardValue = parentRewardValue * rewardDecrement
err = DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: masterId,
Title: md.OneCirclesGreenEnergySignInSettlementTeamReward,
TransferType: md.OneCirclesGreenEnergySignInSettlementTeamRewardForUserVirtualCoinFlow,
OrdId: "",
CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId,
Uid: relate.Uid,
Amount: parentRewardValue,
})
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::44444", err)
return err
}
reduceTotalGreenEnergy += parentRewardValue
} }
} }


@@ -119,6 +121,15 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string) (err erro
return err return err
} }
} }

//6、更新 `one_circles_green_energy_sign_in` 中的 is_completed 状态
_, err = engine.Where("start_time <= ?", startTime).And("is_completed =?", 0).Update(&model.OneCirclesGreenEnergySignIn{
IsCompleted: 1,
})
if err != nil {
fmt.Println("err:::::1111", err)
return
}
err = session.Commit() err = session.Commit()
if err != nil { if err != nil {
_ = session.Rollback() _ = session.Rollback()


+ 17
- 21
rule/public_platoon_double_network_relate_commission.go View File

@@ -27,12 +27,12 @@ func AddPublicPlatoonDoubleNetworkRelateCommission(engine *xorm.Engine, AddPubli
} }
for _, param := range AddPublicPlatoonDoubleNetworkRelateCommissionReqList { for _, param := range AddPublicPlatoonDoubleNetworkRelateCommissionReqList {
//TODO::判断是否有uid为-1 (代表等待新用户填充) 的记录 //TODO::判断是否有uid为-1 (代表等待新用户填充) 的记录
userPublicPlatoonDoubleNetworkRelation, err := db.UserPublicPlatoonDoubleNetworkRelationGetOneByParams(engine, map[string]interface{}{
userPublicPlatoonDoubleNetworkRelation, err2 := db.UserPublicPlatoonDoubleNetworkRelationGetOneByParams(engine, map[string]interface{}{
"key": "uid", "key": "uid",
"value": -1, "value": -1,
}) })
if err != nil {
return nil, err
if err2 != nil {
return nil, err2
} }
if userPublicPlatoonDoubleNetworkRelation != nil { if userPublicPlatoonDoubleNetworkRelation != nil {
now := time.Now() now := time.Now()
@@ -46,21 +46,21 @@ func AddPublicPlatoonDoubleNetworkRelateCommission(engine *xorm.Engine, AddPubli
userPublicPlatoonDoubleNetworkRelation.JoinAt = now userPublicPlatoonDoubleNetworkRelation.JoinAt = now
userPublicPlatoonDoubleNetworkRelation.CreateAt = now userPublicPlatoonDoubleNetworkRelation.CreateAt = now
userPublicPlatoonDoubleNetworkRelation.UpdateAt = now userPublicPlatoonDoubleNetworkRelation.UpdateAt = now
updateAffected, err := db.UserPublicPlatoonDoubleNetworkRelationUpdate(engine.NewSession(), userPublicPlatoonDoubleNetworkRelation.Id, userPublicPlatoonDoubleNetworkRelation)
if err != nil {
return nil, err
updateAffected, err1 := db.UserPublicPlatoonDoubleNetworkRelationUpdate(engine.NewSession(), userPublicPlatoonDoubleNetworkRelation.Id, userPublicPlatoonDoubleNetworkRelation)
if err1 != nil {
return nil, err1
} }
if updateAffected == 0 { if updateAffected == 0 {
err = errors.New("更新 user_public_platoon_relation 记录失败")
return nil, err
err1 = errors.New("更新 user_public_platoon_double_network_relation 记录失败")
return nil, err1
} else { } else {
resp[param.Uid] = userPublicPlatoonDoubleNetworkRelation resp[param.Uid] = userPublicPlatoonDoubleNetworkRelation
} }
continue continue
} }
res, err := publicPlatoonDoubleNetwork(engine, zhios_order_relate_utils.StrToInt(param.Uid), zhios_order_relate_utils.StrToInt(param.RecommendUid), *userPublicPlatoonDoubleNetworkSetting)
if err != nil {
return nil, err
res, err1 := publicPlatoonDoubleNetwork(engine, zhios_order_relate_utils.StrToInt(param.Uid), zhios_order_relate_utils.StrToInt(param.RecommendUid), *userPublicPlatoonDoubleNetworkSetting)
if err1 != nil {
return nil, err1
} }
resp[param.Uid] = &res resp[param.Uid] = &res
} }
@@ -78,14 +78,14 @@ func AddPublicPlatoonDoubleNetworkRelateCommission(engine *xorm.Engine, AddPubli
func publicPlatoonDoubleNetwork(engine *xorm.Engine, uid, recommendUid int, userPublicPlatoonDoubleNetworkSetting model.UserPublicPlatoonDoubleNetworkSetting) (model.UserPublicPlatoonDoubleNetworkRelation, error) { func publicPlatoonDoubleNetwork(engine *xorm.Engine, uid, recommendUid int, userPublicPlatoonDoubleNetworkSetting model.UserPublicPlatoonDoubleNetworkSetting) (model.UserPublicPlatoonDoubleNetworkRelation, error) {
var userPublicPlatoonDoubleNetworkRelation model.UserPublicPlatoonDoubleNetworkRelation var userPublicPlatoonDoubleNetworkRelation model.UserPublicPlatoonDoubleNetworkRelation


//1、 查找当前 user_public_platoon_relation 中 `position` 最大的记录
//1、 查找当前 user_public_platoon_double_network_relation 中 `position` 最大的记录
var m model.UserPublicPlatoonDoubleNetworkRelation var m model.UserPublicPlatoonDoubleNetworkRelation
has, err := engine.OrderBy("id desc").Get(&m) has, err := engine.OrderBy("id desc").Get(&m)
if err != nil { if err != nil {
return userPublicPlatoonDoubleNetworkRelation, err return userPublicPlatoonDoubleNetworkRelation, err
} }
if has == false { if has == false {
return userPublicPlatoonDoubleNetworkRelation, errors.New("查询 user_public_platoon_relation 记录失败")
return userPublicPlatoonDoubleNetworkRelation, errors.New("查询 user_public_platoon_double_network_relation 记录失败")
} }


//TODO::判断 `position + userPublicPlatoonDoubleNetworkSetting.SeveralTimes(几乘)` OR `position + 1` //TODO::判断 `position + userPublicPlatoonDoubleNetworkSetting.SeveralTimes(几乘)` OR `position + 1`
@@ -98,11 +98,7 @@ func publicPlatoonDoubleNetwork(engine *xorm.Engine, uid, recommendUid int, user
level = level1 + 1 //TODO::根据公式需要 + 1 level = level1 + 1 //TODO::根据公式需要 + 1
if level > 2 { if level > 2 {
if level1 != level2 { if level1 != level2 {
//if position1 == getLevelForLastPositionDoubleNetwork(int(level), userPublicPlatoonDoubleNetworkSetting.SeveralTimes) {
// position = position1
//} else {
position = reverseDeductionPositionDoubleNetwork(m.Position, getLevelForFirstPositionDoubleNetwork(int(level), userPublicPlatoonDoubleNetworkSetting.SeveralTimes), userPublicPlatoonDoubleNetworkSetting.SeveralTimes) position = reverseDeductionPositionDoubleNetwork(m.Position, getLevelForFirstPositionDoubleNetwork(int(level), userPublicPlatoonDoubleNetworkSetting.SeveralTimes), userPublicPlatoonDoubleNetworkSetting.SeveralTimes)
//}
} else { } else {
if position1 == getLevelForFirstPositionDoubleNetwork(int(level), userPublicPlatoonDoubleNetworkSetting.SeveralTimes) { if position1 == getLevelForFirstPositionDoubleNetwork(int(level), userPublicPlatoonDoubleNetworkSetting.SeveralTimes) {
position = position1 position = position1
@@ -116,7 +112,7 @@ func publicPlatoonDoubleNetwork(engine *xorm.Engine, uid, recommendUid int, user


pid := makeSearchPidDoubleNetwork(position, userPublicPlatoonDoubleNetworkSetting.SeveralTimes) pid := makeSearchPidDoubleNetwork(position, userPublicPlatoonDoubleNetworkSetting.SeveralTimes)


//2、查找对应pid的 user_public_platoon_relation 记录
//2、查找对应pid的 user_public_platoon_double_network_relation 记录
var m1 model.UserPublicPlatoonDoubleNetworkRelation var m1 model.UserPublicPlatoonDoubleNetworkRelation
if has, err := engine.Where("position=?", pid).Get(&m1); err != nil || has == false { if has, err := engine.Where("position=?", pid).Get(&m1); err != nil || has == false {
return userPublicPlatoonDoubleNetworkRelation, err return userPublicPlatoonDoubleNetworkRelation, err
@@ -136,7 +132,7 @@ func publicPlatoonDoubleNetwork(engine *xorm.Engine, uid, recommendUid int, user


//唯一标识符(父级id-uid-等级-位置) //唯一标识符(父级id-uid-等级-位置)
var uniqueIdentifier = zhios_order_relate_utils.IntToStr(pid) + "-" + zhios_order_relate_utils.IntToStr(uid) + "-" + zhios_order_relate_utils.IntToStr(int(level)) + "-" + zhios_order_relate_utils.IntToStr(position) var uniqueIdentifier = zhios_order_relate_utils.IntToStr(pid) + "-" + zhios_order_relate_utils.IntToStr(uid) + "-" + zhios_order_relate_utils.IntToStr(int(level)) + "-" + zhios_order_relate_utils.IntToStr(position)
// 3、插入 user_public_platoon_relation 记录
// 3、插入 user_public_platoon_double_network_relation 记录
now := time.Now() now := time.Now()
userPublicPlatoonDoubleNetworkRelation.Uid = uid userPublicPlatoonDoubleNetworkRelation.Uid = uid
userPublicPlatoonDoubleNetworkRelation.FatherUid = fatherUid userPublicPlatoonDoubleNetworkRelation.FatherUid = fatherUid
@@ -172,7 +168,7 @@ func getLevelForFirstPositionDoubleNetwork(level, severalTimes int) (position in
} }


// getLevelForLastPositionDoubleNetwork 每个等级的结束值 // getLevelForLastPositionDoubleNetwork 每个等级的结束值
func getLevelForLastPositionDoubleNetwork(level, severalTimes int) (position int) {
func etLevelForLastPositionDoubleNetwork(level, severalTimes int) (position int) {
for n := 0; n <= (level - 1); n++ { for n := 0; n <= (level - 1); n++ {
position += int(math.Pow(float64(severalTimes), float64(n))) position += int(math.Pow(float64(severalTimes), float64(n)))
} }
@@ -209,7 +205,7 @@ func makeSearchPidDoubleNetwork(position int, row int) (pid int) {
} }


// JudgeUserBelowLevelDoubleNetwork 判断当前用户下几级排满 // JudgeUserBelowLevelDoubleNetwork 判断当前用户下几级排满
func JudgeUserBelowLevelDoubleNetworkDoubleNetwork(engine *xorm.Engine, uid int) (level int, err error) {
func JudgeUserBelowLevelDoubleNetwork(engine *xorm.Engine, uid int) (level int, err error) {
//1、查找 `user_public_platoon_setting` 基础设置 //1、查找 `user_public_platoon_setting` 基础设置
userPublicPlatoonDoubleNetworkSetting, err := db.UserPublicPlatoonDoubleNetworkSettingGetOneByParams(engine, map[string]interface{}{ userPublicPlatoonDoubleNetworkSetting, err := db.UserPublicPlatoonDoubleNetworkSettingGetOneByParams(engine, map[string]interface{}{
"key": "is_open", "key": "is_open",


Loading…
Cancel
Save