瀏覽代碼

update 一个圈圈

master
DengBiao 9 月之前
父節點
當前提交
1a82fe15d3
共有 1 個檔案被更改,包括 35 行新增3 行删除
  1. +35
    -3
      rule/one_circles/one_circles_available_green_energy_settlement.go

+ 35
- 3
rule/one_circles/one_circles_available_green_energy_settlement.go 查看文件

@@ -49,7 +49,7 @@ func NewCalcPriceIncreaseFormula(userAmountValue string, oneCirclesGreenEnergyBa
}

// 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",
@@ -73,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) //当前价格


Loading…
取消
儲存