dengbiao vor 6 Monaten
Ursprung
Commit
8fe47c4d1a
11 geänderte Dateien mit 280 neuen und 83 gelöschten Zeilen
  1. +2
    -0
      db/model/one_circles_available_green_energy_points_flow.go
  2. +12
    -0
      db/model/one_circles_community_dividends.go
  3. +9
    -0
      db/model/one_circles_community_dividends_with_user.go
  4. +11
    -0
      db/model/one_circles_community_dividends_with_user_records.go
  5. +2
    -0
      db/model/one_circles_green_energy_basic_setting.go
  6. +2
    -0
      md/block_star_chain.go
  7. +3
    -0
      rule/one_circles/enum/one_circles_available_green_energy_points_flow.go
  8. +1
    -0
      rule/one_circles/md/one_circles_green_energy.go
  9. +79
    -79
      rule/one_circles/one_circles_available_green_energy_settlement.go
  10. +99
    -0
      rule/one_circles/one_circles_community_dividends.go
  11. +60
    -4
      rule/one_circles/one_circles_deal_available_green_energy_points.go

+ 2
- 0
db/model/one_circles_available_green_energy_points_flow.go Datei anzeigen

@@ -35,5 +35,7 @@ type OneCirclesAvailableGreenEnergyPointsFlow struct {
AfterStarLevelDividendsValues string `json:"after_star_level_dividends_values" xorm:"not null default 0.0000000000 comment('变更后-星级分红区块币数量') DECIMAL(28,10)"`
BeforeDestructionQuantityValues string `json:"before_destruction_quantity_values" xorm:"not null default 0.0000000000 comment('变更前-销毁区块币数量') DECIMAL(28,10)"`
AfterDestructionQuantityValues string `json:"after_destruction_quantity_values" xorm:"not null default 0.0000000000 comment('变更后-销毁区块币数量') DECIMAL(28,10)"`
BeforeCommunityDividends string `json:"before_community_dividends" xorm:"not null default 0.0000000000 comment('变更前-社区分红区块币数量') DECIMAL(28,10)"`
AfterCommunityDividends string `json:"after_community_dividends" xorm:"not null default 0.0000000000 comment('变更后-社区分红区块币数量') DECIMAL(28,10)"`
CreateTime time.Time `json:"create_time" xorm:"default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
}

+ 12
- 0
db/model/one_circles_community_dividends.go Datei anzeigen

@@ -0,0 +1,12 @@
package model

type OneCirclesCommunityDividends struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Nums int `json:"nums" xorm:"not null default 0 comment('分红数量') INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"`
CoinId int `json:"coin_id" xorm:"not null default 0 comment('虚拟币id') INT(11)"`
PersonsNum int `json:"persons_num" xorm:"not null default 0 comment('分红人数') INT(11)"`
IsOver int32 `json:"is_over" xorm:"not null default 0 comment('是否分红完毕') TINYINT(1)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 9
- 0
db/model/one_circles_community_dividends_with_user.go Datei anzeigen

@@ -0,0 +1,9 @@
package model

type OneCirclesCommunityDividendsWithUser struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 11
- 0
db/model/one_circles_community_dividends_with_user_records.go Datei anzeigen

@@ -0,0 +1,11 @@
package model

type OneCirclesCommunityDividendsWithUserRecords struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
Value string `json:"value" xorm:"not null default 0.0000000000 comment('数量') DECIMAL(28,10)"`
RecordsId int `json:"records_id" xorm:"not null default 0 comment('记录id') INT(11)"`
CoinId int `json:"coin_id" xorm:"not null default 0 comment('虚拟币id') INT(11)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 2
- 0
db/model/one_circles_green_energy_basic_setting.go Datei anzeigen

@@ -23,6 +23,7 @@ type OneCirclesGreenEnergyBasicSetting struct {
DevelopmentCommittee string `json:"development_committee" xorm:"not null comment('发展委员会') DECIMAL(28,8)"`
PublicWelfareAndCharity string `json:"public_welfare_and_charity" xorm:"not null comment('公益慈善') DECIMAL(28,8)"`
StarLevelDividends string `json:"star_level_dividends" xorm:"not null comment('星级分红') DECIMAL(28,8)"`
CommunityDividends string `json:"community_dividends" xorm:"not null comment('社区分红') DECIMAL(28,8)"`
DestructionQuantityNums string `json:"destruction_quantity_nums" xorm:"not null comment('销毁数量') DECIMAL(28,8)"`
DestructionSetting string `json:"destruction_setting" xorm:"not null comment('销毁设置') TEXT"`
IsLimitDividend int `json:"is_limit_dividend" xorm:"not null default 1 comment('是否限制分红(会员本人不活跃,没有绿色能量分红)') TINYINT(1)"`
@@ -35,4 +36,5 @@ type OneCirclesGreenEnergyBasicSetting struct {
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
IsOpenWelfareOrders int `json:"is_open_welfare_orders" xorm:"not null default 0 comment('是否开启福利订单') TINYINT(1)"`
CommunityDividendsCoinId int `json:"community_dividends_coin_id" xorm:"not null default 0 comment('社区分红对应虚拟币id') INT(11)"`
}

+ 2
- 0
md/block_star_chain.go Datei anzeigen

@@ -74,6 +74,7 @@ const (
OneCirclesTeamActiveCoinExchangeToBeGreenEnergy = "T兑换绿色能量"
OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergy = "绿色能量释放"
OneCirclesSettlementStarLevelDividends = "绿色能量分红"
OneCirclesCommunityDividends = "社区分红"

GreenCoinDoubleChainExchangeByCoin1 = "绿色积分双链兑换账户余额-减少绿色积分"
GreenCoinDoubleChainExchangeByCoin2 = "绿色积分双链兑换账户余额-减少贡献积分"
@@ -149,6 +150,7 @@ const (
OneCirclesTeamActiveCoinExchangeToBeGreenEnergyForUserVirtualCoinFlow = 167 //T兑换绿色能量
OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergyForUserVirtualCoinFlow = 168 //绿色能量释放
OneCirclesSettlementStarLevelDividendsForUserVirtualCoinFlow = 169 //绿色能量分红(结算星级分红-得到结算绿色能量)
OneCirclesCommunityDividendsForUserVirtualCoinFlow = 172 //社区分红

GreenCoinDoubleChainExchangeByCoin1ForForUserVirtualCoinFlow = 170 //绿色积分双链兑换账户余额-减少绿色积分
GreenCoinDoubleChainExchangeByCoin2ForForUserVirtualCoinFlow = 171 //绿色积分双链兑换账户余额-减少贡献积分


+ 3
- 0
rule/one_circles/enum/one_circles_available_green_energy_points_flow.go Datei anzeigen

@@ -13,6 +13,7 @@ const (
SettlementStarLevelDividends
MarketplaceMerchantNumsAutoExchangeMarketplaceMerchantFunds
MarketplaceMerchantFundsAutoExchangeMarketplaceMerchantNums
CommunityDividends
)

func (kind OneCirclesAvailableGreenEnergyPointsFlowKind) String() string {
@@ -35,6 +36,8 @@ func (kind OneCirclesAvailableGreenEnergyPointsFlowKind) String() string {
return "市商数量自动兑换市商资金"
case MarketplaceMerchantFundsAutoExchangeMarketplaceMerchantNums:
return "市商资金自动兑换市商数量"
case CommunityDividends:
return "社区分红"
default:
return "未知状态"
}


+ 1
- 0
rule/one_circles/md/one_circles_green_energy.go Datei anzeigen

@@ -32,6 +32,7 @@ type DestructionSettingStruct struct {
DevelopmentCommittee string `json:"development_committee"` //发展委员会百分比
StarLevelDividends string `json:"star_level_dividends"` //星级分红百分比
MarketplaceMerchant string `json:"marketplace_merchant"` //市商数量百分比
CommunityDividends string `json:"community_dividends"` //社区分红百分比
}

type WelfareOrdersLimit struct {


+ 79
- 79
rule/one_circles/one_circles_available_green_energy_settlement.go Datei anzeigen

@@ -48,84 +48,8 @@ func NewCalcPriceIncreaseFormula(userAmountValue string, oneCirclesGreenEnergyBa
return
}

//// CalcPriceReductionFormula 计算降价公式(【用户需兑换绿能色量数量*{原始资金÷(用户需兑换绿色数量+原始数量}*(1 - 扣比例50% ~ 23%) = 用户获得钱)
//func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string, levelId string, uid int) (err error, values, greenEnergy, greenEnergyFee, nowPriceValue, afterPriceValue string) {
// //1、查找 `one_circles_green_energy_basic_setting` 基础设置
// oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{
// "key": "is_open",
// "value": 1,
// })
// if err != nil {
// return
// }
// var vipEquitySetting []*md2.VipEquitySettingStruct
// err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.VipEquitySetting), &vipEquitySetting)
// if err != nil {
// return
// }
// var exchangeAccountBalanceFeeValue string
// for _, v := range vipEquitySetting {
// if v.VipLevelId == levelId {
// exchangeAccountBalanceFeeValue = v.ExchangeAccountBalanceFee
// }
// }
// if exchangeAccountBalanceFeeValue == "" {
// err = errors.New("未查询到当前会员等级兑换余额手续费")
// return
// }
// decimalRate := decimal.NewFromInt(100) //百分比
// exchangeAccountBalanceFee, _ := decimal.NewFromString(exchangeAccountBalanceFeeValue) //兑换手续费
// //TODO::统计当前有多少直推用户昨天签到了
// userRelates, err := db.DbsUserRelateByParentUid(engine, uid, 1)
// if err != nil {
// return
// }
// var userRelatesUids []int
// if userRelates != nil {
// for _, userRelate := range *userRelates {
// userRelatesUids = append(userRelatesUids, userRelate.Uid)
// }
// }
// if len(userRelatesUids) > 0 {
// now := time.Now()
// startDate := now.AddDate(0, 0, -1).Format("2006-01-02") + " 00:00:00"
// endDate := now.Format("2006-01-02") + " 00:00:00"
// var oneCirclesGreenEnergySignIns []*model.OneCirclesGreenEnergySignIn
// err = engine.Where("start_time >= ?", startDate).And("start_time <=?", endDate).In("uid", userRelatesUids).And("is_completed =?", 0).Find(&oneCirclesGreenEnergySignIns)
// if err != nil {
// return
// }
//
// decimalRateV2 := decimal.NewFromInt(10) //百分比
// if len(oneCirclesGreenEnergySignIns) > 0 {
// decimalBase := decimal.NewFromInt(1) //基数
// userRelatesUidsValue := decimal.NewFromInt(int64(len(userRelatesUids)))
// oneCirclesGreenEnergySignInsValue := decimal.NewFromInt(int64(len(oneCirclesGreenEnergySignIns)))
// exchangeAccountBalanceFee = exchangeAccountBalanceFee.Add(decimalBase.Sub(oneCirclesGreenEnergySignInsValue.Div(userRelatesUidsValue)).Mul(decimalRateV2))
// } else {
// exchangeAccountBalanceFee = exchangeAccountBalanceFee.Add(decimalRateV2)
// }
// }
//
// userExchangeNums, _ := decimal.NewFromString(userExchangeNumsValue) //用户兑换绿色能量
// originalQuantityNums, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalQuantityNums) //原始数量
// nowPrice, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) //当前价格
// originalQuantityFunds, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalFunds) //原始资金
// afterPrice := originalQuantityFunds.Div(userExchangeNums.Add(originalQuantityNums)) //降价后的价格
//
// greenEnergyValues := userExchangeNums.Mul(afterPrice) //绿色能量个数
// greenEnergyFeeValues := greenEnergyValues.Mul(exchangeAccountBalanceFee.Div(decimalRate)) //绿色能量个数扣除手续费价值
//
// values = greenEnergyValues.Sub(greenEnergyFeeValues).Truncate(8).String() //用户实际得到的钱
// greenEnergy = greenEnergyValues.Truncate(8).String() //原本兑换到的钱
// greenEnergyFee = userExchangeNums.Mul(exchangeAccountBalanceFee.Div(decimalRate)).Truncate(8).String() //绿色能量手续费
// nowPriceValue = nowPrice.String()
// afterPriceValue = afterPrice.String()
// return
//}

// CalcPriceReductionFormula 计算降价公式(【用户需兑换绿能色量数量*{原始资金÷(用户需兑换绿色数量+原始数量}*(1 - 扣比例50% ~ 23%) = 用户获得钱)
func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string, levelId string) (err error, values, greenEnergy, greenEnergyFee, nowPriceValue, afterPriceValue string) {
func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string, levelId string, uid int) (err error, values, greenEnergy, greenEnergyFee, nowPriceValue, afterPriceValue string) {
//1、查找 `one_circles_green_energy_basic_setting` 基础设置
oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{
"key": "is_open",
@@ -149,8 +73,40 @@ func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string
err = errors.New("未查询到当前会员等级兑换余额手续费")
return
}
decimalRate := decimal.NewFromInt(100) //百分比
exchangeAccountBalanceFee, _ := decimal.NewFromString(exchangeAccountBalanceFeeValue) //兑换手续费
decimalRate := decimal.NewFromInt(100) //百分比
exchangeAccountBalanceFee, _ := decimal.NewFromString(exchangeAccountBalanceFeeValue) //兑换手续费
//TODO::统计当前有多少直推用户昨天签到了
userRelates, err := db.DbsUserRelateByParentUid(engine, uid, 1)
if err != nil {
return
}
var userRelatesUids []int
if userRelates != nil {
for _, userRelate := range *userRelates {
userRelatesUids = append(userRelatesUids, userRelate.Uid)
}
}
if len(userRelatesUids) > 0 {
now := time.Now()
startDate := now.AddDate(0, 0, -1).Format("2006-01-02") + " 00:00:00"
endDate := now.Format("2006-01-02") + " 00:00:00"
var oneCirclesGreenEnergySignIns []*model.OneCirclesGreenEnergySignIn
err = engine.Where("start_time >= ?", startDate).And("start_time <=?", endDate).In("uid", userRelatesUids).And("is_completed =?", 0).Find(&oneCirclesGreenEnergySignIns)
if err != nil {
return
}

decimalRateV2 := decimal.NewFromInt(10) //百分比
if len(oneCirclesGreenEnergySignIns) > 0 {
decimalBase := decimal.NewFromInt(1) //基数
userRelatesUidsValue := decimal.NewFromInt(int64(len(userRelatesUids)))
oneCirclesGreenEnergySignInsValue := decimal.NewFromInt(int64(len(oneCirclesGreenEnergySignIns)))
exchangeAccountBalanceFee = exchangeAccountBalanceFee.Add(decimalBase.Sub(oneCirclesGreenEnergySignInsValue.Div(userRelatesUidsValue)).Mul(decimalRateV2))
} else {
exchangeAccountBalanceFee = exchangeAccountBalanceFee.Add(decimalRateV2)
}
}

userExchangeNums, _ := decimal.NewFromString(userExchangeNumsValue) //用户兑换绿色能量
originalQuantityNums, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalQuantityNums) //原始数量
nowPrice, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) //当前价格
@@ -168,6 +124,50 @@ func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string
return
}

// CalcPriceReductionFormula 计算降价公式(【用户需兑换绿能色量数量*{原始资金÷(用户需兑换绿色数量+原始数量}*(1 - 扣比例50% ~ 23%) = 用户获得钱)
//func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string, levelId string) (err error, values, greenEnergy, greenEnergyFee, nowPriceValue, afterPriceValue string) {
// //1、查找 `one_circles_green_energy_basic_setting` 基础设置
// oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{
// "key": "is_open",
// "value": 1,
// })
// if err != nil {
// return
// }
// var vipEquitySetting []*md2.VipEquitySettingStruct
// err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.VipEquitySetting), &vipEquitySetting)
// if err != nil {
// return
// }
// var exchangeAccountBalanceFeeValue string
// for _, v := range vipEquitySetting {
// if v.VipLevelId == levelId {
// exchangeAccountBalanceFeeValue = v.ExchangeAccountBalanceFee
// }
// }
// if exchangeAccountBalanceFeeValue == "" {
// err = errors.New("未查询到当前会员等级兑换余额手续费")
// return
// }
// decimalRate := decimal.NewFromInt(100) //百分比
// exchangeAccountBalanceFee, _ := decimal.NewFromString(exchangeAccountBalanceFeeValue) //兑换手续费
// userExchangeNums, _ := decimal.NewFromString(userExchangeNumsValue) //用户兑换绿色能量
// originalQuantityNums, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalQuantityNums) //原始数量
// nowPrice, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) //当前价格
// originalQuantityFunds, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalFunds) //原始资金
// afterPrice := originalQuantityFunds.Div(userExchangeNums.Add(originalQuantityNums)) //降价后的价格
//
// greenEnergyValues := userExchangeNums.Mul(afterPrice) //绿色能量个数
// greenEnergyFeeValues := greenEnergyValues.Mul(exchangeAccountBalanceFee.Div(decimalRate)) //绿色能量个数扣除手续费价值
//
// values = greenEnergyValues.Sub(greenEnergyFeeValues).Truncate(8).String() //用户实际得到的钱
// greenEnergy = greenEnergyValues.Truncate(8).String() //原本兑换到的钱
// greenEnergyFee = userExchangeNums.Mul(exchangeAccountBalanceFee.Div(decimalRate)).Truncate(8).String() //绿色能量手续费
// nowPriceValue = nowPrice.String()
// afterPriceValue = afterPrice.String()
// return
//}

// NewCalcPriceReductionFormula 计算降价公式(【用户需兑换绿能色量数量*{原始资金÷(用户需兑换绿色数量+原始数量}*(1 - 扣比例50% ~ 23%) = 用户获得钱)
func NewCalcPriceReductionFormula(userExchangeNumsValue string, oneCirclesGreenEnergyBasicSetting *model.OneCirclesGreenEnergyBasicSetting) (err error, greenEnergy, nowPriceValue, afterPriceValue string) {
userExchangeNums, _ := decimal.NewFromString(userExchangeNumsValue) //用户兑换绿色能量


+ 99
- 0
rule/one_circles/one_circles_community_dividends.go Datei anzeigen

@@ -0,0 +1,99 @@
package one_circles

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum"
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
"errors"
"fmt"
"github.com/shopspring/decimal"
"xorm.io/xorm"
)

// CommunityDividends 社区分红
func CommunityDividends(engine *xorm.Engine, masterId string, ch *rabbit.Channel) (err error) {
//1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置
oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
return
}

//2、查找当前是否有待分红的记录 "个人活跃积分"可以自动兑换的用户数据 && "团队活跃积分"可以自动兑换的用户数据
var m model.OneCirclesCommunityDividends
has, err := engine.Where("is_over = 0").Get(&m)
if err != nil {
fmt.Println("err::::::2222", err.Error())
return
}
if has {
//3、查找 `one_circles_community_dividends_with_user` 数据
var list []model.OneCirclesCommunityDividendsWithUser
err = engine.Where("1 = 1").Find(&list)
totalValue := decimal.NewFromInt(int64(m.Nums))
singleValue, _ := totalValue.Div(decimal.NewFromInt(int64(len(list)))).Float64()
session := engine.NewSession()
defer func() {
session.Close()
if err := recover(); err != nil {

_ = zhios_order_relate_logx.Error(err)
}
}()
session.Begin()

for _, v := range list {
//4、 给相应的用户加上分红权益
err = DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: masterId,
Title: md.OneCirclesCommunityDividends,
TransferType: md.OneCirclesCommunityDividendsForUserVirtualCoinFlow,
OrdId: "",
CoinId: m.CoinId,
Uid: v.Uid,
Amount: singleValue,
})
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::33333", err)
return err
}
}
//5、 减少“社区分红”钱包中的值
totalDividend, _ := totalValue.Float64()
err = DealAvailableGreenEnergyCoin(session, int(enum.CommunityDividends), totalDividend, 0, enum.CommunityDividends.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice)
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::444444", err)
return err
}

//6、修改 one_circles_community_dividends 记录
m.IsOver = 1
m.PersonsNum = len(list)
affected, err := session.Where("id=?", m.Id).Cols("is_over", "persons_num").Update(m)
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::5555555", err)
return err
}
if affected == 0 {
_ = session.Rollback()
fmt.Println("err:::::6666666", errors.New("更新 one_circles_community_dividends 记录失败"))
return err
}

err = session.Commit()
if err != nil {
_ = session.Rollback()
return errors.New("事务提交失败")
}
}
return
}

+ 60
- 4
rule/one_circles/one_circles_deal_available_green_energy_points.go Datei anzeigen

@@ -79,6 +79,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = chain.CommunityDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums

@@ -111,6 +113,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = chain.CommunityDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金
@@ -139,6 +143,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = chain.CommunityDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金
@@ -169,6 +175,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = chain.CommunityDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums

@@ -206,6 +214,13 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
starLevelDividends, _ := decimal.NewFromString(destructionSetting.StarLevelDividends) //星级分红百分比
afterStarLevelDividendsValues := starLevelDividendsNums.Add(amountFeeValue.Mul(starLevelDividends.Div(decimalRate))).RoundFloor(8).String()

var afterCommunityDividendsValues = chain.CommunityDividends
if chain.CommunityDividends != "" {
communityDividendsNums, _ := decimal.NewFromString(chain.CommunityDividends)
communityDividends, _ := decimal.NewFromString(destructionSetting.CommunityDividends) //社区分红百分比
afterCommunityDividendsValues = communityDividendsNums.Add(amountFeeValue.Mul(communityDividends.Div(decimalRate))).RoundFloor(8).String()
}

destructionQuantityNums, _ := decimal.NewFromString(chain.DestructionQuantityNums)
destructionQuantity, _ := decimal.NewFromString(destructionSetting.DestructionQuantity) //销毁百分比
afterDestructionQuantityValues := destructionQuantityNums.Add(amountFeeValue.Mul(destructionQuantity.Div(decimalRate))).RoundFloor(8).String()
@@ -236,6 +251,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = afterPublicWelfareAndCharityValues
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = afterStarLevelDividendsValues
oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红百分比
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = afterCommunityDividendsValues
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = afterDestructionQuantityValues

@@ -294,6 +311,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = beforeStarLevelDividends.Sub(amountValue).RoundFloor(8).String()
oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = chain.CommunityDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums

@@ -326,8 +345,10 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.AfterDevelopmentCommitteeValues = chain.DevelopmentCommittee
oneCirclesAvailableGreenEnergyPointsFlow.BeforePublicWelfareAndCharityValues = chain.PublicWelfareAndCharity //公益慈善
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = chain.CommunityDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums

@@ -361,8 +382,10 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.AfterDevelopmentCommitteeValues = chain.DevelopmentCommittee
oneCirclesAvailableGreenEnergyPointsFlow.BeforePublicWelfareAndCharityValues = chain.PublicWelfareAndCharity //公益慈善
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = chain.CommunityDividends
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums

@@ -373,6 +396,38 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = beforeMarketplaceMerchantFunds.Sub(amountFeeValue).String()
break
case int(enum.CommunityDividends): //社区分红
beforeCommunityDividends, _ := decimal.NewFromString(chain.CommunityDividends)

oneCirclesAvailableGreenEnergyPointsFlow.Direction = 2
oneCirclesAvailableGreenEnergyPointsFlow.BeforeEcologicalApplicationValues = chain.EcologicalApplication //生态应用
oneCirclesAvailableGreenEnergyPointsFlow.AfterEcologicalApplicationValues = chain.EcologicalApplication
oneCirclesAvailableGreenEnergyPointsFlow.BeforeTechnicalTeamValues = chain.TotalTechnologyTeam //技术团队
oneCirclesAvailableGreenEnergyPointsFlow.AfterTechnicalTeamValues = chain.TotalTechnologyTeam
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOperateTeamValues = chain.TotalOperateTeam //运营团队
oneCirclesAvailableGreenEnergyPointsFlow.AfterOperateTeamValues = chain.TotalOperateTeam
oneCirclesAvailableGreenEnergyPointsFlow.BeforeActiveGiveawaysValues = chain.TotalActiveGiveaways //活跃赠送
oneCirclesAvailableGreenEnergyPointsFlow.AfterActiveGiveawaysValues = chain.TotalActiveGiveaways
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityValues = chain.OriginalQuantityNums //原始数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityValues = chain.OriginalQuantityNums
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantValues = chain.MarketplaceMerchantNums //市商数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantValues = chain.MarketplaceMerchantNums
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDevelopmentCommitteeValues = chain.DevelopmentCommittee //发展委员会
oneCirclesAvailableGreenEnergyPointsFlow.AfterDevelopmentCommitteeValues = chain.DevelopmentCommittee
oneCirclesAvailableGreenEnergyPointsFlow.BeforePublicWelfareAndCharityValues = chain.PublicWelfareAndCharity //公益慈善
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends //星级分红
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = chain.OriginalFunds
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds

oneCirclesAvailableGreenEnergyPointsFlow.BeforeCommunityDividends = chain.CommunityDividends //社区分红
oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends = beforeCommunityDividends.Sub(amountValue).RoundFloor(8).String()
break
}

chain.EcologicalApplication = oneCirclesAvailableGreenEnergyPointsFlow.AfterEcologicalApplicationValues //生态应用
@@ -384,6 +439,7 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
chain.DevelopmentCommittee = oneCirclesAvailableGreenEnergyPointsFlow.AfterDevelopmentCommitteeValues //发展委员会
chain.PublicWelfareAndCharity = oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues //公益慈善
chain.StarLevelDividends = oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues //星级分红
chain.CommunityDividends = oneCirclesAvailableGreenEnergyPointsFlow.AfterCommunityDividends //社区分红
chain.DestructionQuantityNums = oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues //销毁数量

chain.OriginalFunds = oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues //原始资金


Laden…
Abbrechen
Speichern