dengbiao пре 2 недеља
родитељ
комит
8e516982b4
4 измењених фајлова са 32 додато и 2 уклоњено
  1. +1
    -1
      md/app_redis_key.go
  2. +11
    -0
      md/user_ecpm.go
  3. +19
    -1
      rule/egg_energy/give_activty_coin.go
  4. +1
    -0
      rule/egg_energy/md/mq_egg_energy.go

+ 1
- 1
md/app_redis_key.go Прегледај датотеку

@@ -5,7 +5,7 @@ const RedisDataBase = 0 //Redis 0 号库
// 缓存key统一管理
const (
EggEnergyNowPriceUpdateLock = "egg_energy_core_data_update_lock" // 当前价格(能拿到锁才能更新价格)
DealEggEnergyNowPriceRequestIdPrefix = "egg_energy_core_data:%d"
DealEggEnergyNowPriceRequestIdPrefix = "egg_energy_core_data:%d" // 制度核心数据(能拿到锁才能更新数据)

UserFinValidUpdateLock = "user_fin_valid_update_lock:%s" // 用户余额更新锁(能拿到锁才能更新余额)
UserVirtualAmountUpdateLock = "%s:user_virtual_amount_update_lock:%s" // 用户虚拟币更新锁(能拿到锁才能更新余额)


+ 11
- 0
md/user_ecpm.go Прегледај датотеку

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

const (
UserEcpmCacheKey = "user:%d:ecpm"
UserEcpmCacheTime = 60 * 30
)

type DealUserEcpmReq struct {
Uid int64 `json:"uid"`
Ecpm string `json:"ecpm"`
}

+ 19
- 1
rule/egg_energy/give_activty_coin.go Прегледај датотеку

@@ -24,7 +24,7 @@ import (
)

// SettlementGiveActivityCoin 结算观看激励广告得到蛋蛋积分
func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ch *rabbit.Channel) (err error) {
func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm string, ch *rabbit.Channel) (err error) {
uid := user.Id
now := time.Now()

@@ -62,6 +62,8 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ch *rabbit
return
}

go dealEcpm(user, ecpm, ch) //TODO::协程处理ecpm的变化

var rewardValue float64 //TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制)
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(engine, redisConn)
@@ -284,9 +286,25 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ch *rabbit
}
cache.SetEx(redisKey, watchAdDate, 60*60*24) //TODO::默认缓存1小时
}

return
}

func dealEcpm(user model.User, ecpm string, ch *rabbit.Channel) {
//查找缓存中的ecpm值和当前的ecpm是否一致
key := fmt.Sprintf(md.UserEcpmCacheKey, user.Id)
ecpmCacheValue, _ := cache.GetString(key)
if ecpmCacheValue == "" || ecpmCacheValue != ecpm {
//更新缓存值
cache.SetEx(key, ecpm, md.UserEcpmCacheTime)

//TODO::推入rabbitmq 异步处理
ch.Publish(md2.EggEnergyExchange, md.DealUserEcpmReq{
Uid: user.Id,
Ecpm: ecpm,
}, md2.EggEnergyRoutKeyForDealUserEcpm)
}
}
func ActivityCoinToAlipayRealName(engine *xorm.Engine, uid int64, amount string) (err error) {
amountValue, _ := decimal.NewFromString(amount)



+ 1
- 0
rule/egg_energy/md/mq_egg_energy.go Прегледај датотеку

@@ -10,6 +10,7 @@ const (
EggEnergyRoutKeyForEggEnergyFundData = "fund_data" // 资金汇入
EggEnergyRoutKeyForPlatformRevenueData = "platform_revenue_data" // 平台收入
EggEnergyRoutKeyForDealUserVirtualCoinData = "deal_user_virtual_coin" // 处理给用户虚拟币积分
EggEnergyRoutKeyForDealUserEcpm = "user_ecpm" // 处理给用户Ecpm值
)

type EggEnergyStructForSignIn struct {


Loading…
Откажи
Сачувај