소스 검색

Merge remote-tracking branch 'origin/master'

master
huangjiajun 8 달 전
부모
커밋
28a064dda9
3개의 변경된 파일81개의 추가작업 그리고 37개의 파일을 삭제
  1. +1
    -1
      rule/one_circles/md/one_circles_public_platoon.go
  2. +79
    -35
      rule/one_circles/one_circles_available_green_energy_settlement.go
  3. +1
    -1
      rule/one_circles/one_circles_public_platoon_give_activty_coin.go

+ 1
- 1
rule/one_circles/md/one_circles_public_platoon.go 파일 보기

@@ -3,7 +3,7 @@ package md
type VideoRewardSystemStruct struct {
RewardValue string `json:"reward_value"` //奖励X个活跃积分
RewardTotalNum string `json:"reward_total_num"` //一共X个奖励视屏
IntervalMinutes string `json:"interval_minutes"` //间隔X分钟
IntervalMinutes string `json:"interval_minutes"` //间隔X
EachRoundHour string `json:"each_round_hour"` //每一轮X个小时
}



+ 79
- 35
rule/one_circles/one_circles_available_green_energy_settlement.go 파일 보기

@@ -48,8 +48,84 @@ 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, uid int) (err error, values, greenEnergy, greenEnergyFee, nowPriceValue, afterPriceValue string) {
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",
@@ -73,40 +149,8 @@ func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string
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)
}
}

decimalRate := decimal.NewFromInt(100) //百分比
exchangeAccountBalanceFee, _ := decimal.NewFromString(exchangeAccountBalanceFeeValue) //兑换手续费
userExchangeNums, _ := decimal.NewFromString(userExchangeNumsValue) //用户兑换绿色能量
originalQuantityNums, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalQuantityNums) //原始数量
nowPrice, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) //当前价格


+ 1
- 1
rule/one_circles/one_circles_public_platoon_give_activty_coin.go 파일 보기

@@ -213,7 +213,7 @@ func SettlementPublicGiveActivityCoin(engine *xorm.Engine, masterId string, uid
watchAdDate = oneCirclesUserWatchRecords.NextWatchAdDate.Format("2006-01-02 15:04:05")
}
} else {
watchAdDate = time.Now().Add(time.Duration(zhios_order_relate_utils.StrToInt64(videoRewardSystem.IntervalMinutes)) * time.Minute).Format("2006-01-02 15:04:05")
watchAdDate = time.Now().Add(time.Duration(zhios_order_relate_utils.StrToInt64(videoRewardSystem.IntervalMinutes)) * time.Second).Format("2006-01-02 15:04:05")
//watchAdDate = oneCirclesUserWatchRecords.NextWatchAdDate.Format("2006-01-02 15:04:05")
}
cache.SetEx(redisKey, watchAdDate, 60*60*24) //TODO::默认缓存1小时


불러오는 중...
취소
저장