Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

master
huangjiajun před 2 dny
rodič
revize
bf1ecd80c3
14 změnil soubory, kde provedl 321 přidání a 119 odebrání
  1. +1
    -0
      app/hdl/institutional_management/egg_energy/hdl_basic.go
  2. +78
    -68
      app/hdl/institutional_management/egg_energy/hdl_egg_point.go
  3. +5
    -5
      app/hdl/institutional_management/egg_energy/hdl_platform_revenue.go
  4. +1
    -0
      app/md/institutional_management/egg_energy/md_basic.go
  5. +2
    -0
      app/md/institutional_management/egg_energy/md_egg_point.go
  6. +2
    -1
      app/task/init.go
  7. +11
    -10
      app/task/md/cron_key.go
  8. +0
    -3
      app/task/md/md_deal_platform_revenue_data.go
  9. +132
    -0
      app/task/svc/svc_auto_caching_egg_point_statistics.go
  10. +20
    -21
      app/task/svc/svc_egg_energy_auto_record_price.go
  11. +1
    -1
      app/task/svc/svc_egg_energy_auto_update_user_access.go
  12. +4
    -4
      app/task/svc/svc_egg_energy_automatic_scoring.go
  13. +22
    -0
      app/task/task_auto_caching_egg_point_statistics.go
  14. +42
    -6
      etc/cfg.yml

+ 1
- 0
app/hdl/institutional_management/egg_energy/hdl_basic.go Zobrazit soubor

@@ -204,6 +204,7 @@ func GetEggEnergyBasic(c *gin.Context) {
resp := md.GetEggEnergyBasicResp{
BasicSetting: md.BasicSetting{
IsOpen: basicSettings.IsOpen,
InitialPrice: basicSettings.InitialPrice,
PersonEggEnergyCoinId: basicSettings.PersonEggEnergyCoinId,
TeamEggEnergyCoinId: basicSettings.TeamEggEnergyCoinId,
PersonEggPointsCoinId: basicSettings.PersonEggPointsCoinId,


+ 78
- 68
app/hdl/institutional_management/egg_energy/hdl_egg_point.go Zobrazit soubor

@@ -6,12 +6,15 @@ import (
md "applet/app/md/institutional_management/egg_energy"
"applet/app/svc/egg_energy"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis"
"time"
)

@@ -96,77 +99,84 @@ func StatisticsUserEggIndex(c *gin.Context) {
esIndexName = md2.EggEnergyUserEggScoreEsAlias + "_" + req.Year + req.Week
resp.Year, resp.Week = req.Year, req.Week
}

//统计用户"ecpm"范围
resp.StatisticsUserEggEcpmRange, err = egg_energy.StatisticsUserEggEcpmRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"拉新人数"范围
resp.StatisticsUserEggInviteUserNumsRange, err = egg_energy.StatisticsUserEggInviteUserNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"团队活跃次数"范围
resp.StatisticsUserEggTeamActivityNumsRange, err = egg_energy.StatisticsUserEggTeamActivityNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"签到次数"范围
resp.StatisticsUserEggSignInNumsRange, err = egg_energy.StatisticsUserEggSignInNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"发红包次数"范围
resp.StatisticsUserEggSendRedPackageNumsRange, err = egg_energy.StatisticsUserEggSendRedPackageNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"蛋蛋能量兑换余额数量"范围
resp.StatisticsUserEggEggEnergyExchangeAccountBalanceRange, err = egg_energy.StatisticsUserEggEggEnergyExchangeAccountBalanceRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"蛋蛋能量兑换余额数量"范围
resp.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange, err = egg_energy.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"发朋友圈次数"范围
resp.StatisticsUserEggSendCircleOfFriendNumsRange, err = egg_energy.StatisticsUserEggSendCircleOfFriendNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"论坛评论次数"范围
resp.StatisticsUserEggForumCommentsNumsRange, err = egg_energy.StatisticsUserEggForumCommentsNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"学院学习次数"范围
resp.StatisticsUserEggCollegeLearningNumsRange, err = egg_energy.StatisticsUserEggCollegeLearningNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"违规次数"范围
resp.StatisticsUserEggViolateNumsRange, err = egg_energy.StatisticsUserEggViolateNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"浏览界面次数"范围
resp.StatisticsUserEggBrowseInterfaceNumsRange, err = egg_energy.StatisticsUserEggBrowseInterfaceNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"个人活跃积分增量值"范围
resp.StatisticsUserEggPersonAddActivityValueRange, err = egg_energy.StatisticsUserEggPersonAddActivityValueRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
yearAndWeekStr := req.Year + req.Week
redisKey := fmt.Sprintf(md.AutoCachingEggPointRedisKey, yearAndWeekStr)
err1 := cache.GetJson(redisKey, &resp)
if err1 != nil && !errors.Is(err1, redis.Nil) {
e.OutErr(c, e.ERR, err1.Error())
return
} else if errors.Is(err1, redis.Nil) {
// 缓存不存在数据直接查询
//统计用户"ecpm"范围
resp.StatisticsUserEggEcpmRange, err = egg_energy.StatisticsUserEggEcpmRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"拉新人数"范围
resp.StatisticsUserEggInviteUserNumsRange, err = egg_energy.StatisticsUserEggInviteUserNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"团队活跃次数"范围
resp.StatisticsUserEggTeamActivityNumsRange, err = egg_energy.StatisticsUserEggTeamActivityNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"签到次数"范围
resp.StatisticsUserEggSignInNumsRange, err = egg_energy.StatisticsUserEggSignInNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"发红包次数"范围
resp.StatisticsUserEggSendRedPackageNumsRange, err = egg_energy.StatisticsUserEggSendRedPackageNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"蛋蛋能量兑换余额数量"范围
resp.StatisticsUserEggEggEnergyExchangeAccountBalanceRange, err = egg_energy.StatisticsUserEggEggEnergyExchangeAccountBalanceRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"蛋蛋能量兑换余额数量"范围
resp.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange, err = egg_energy.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"发朋友圈次数"范围
resp.StatisticsUserEggSendCircleOfFriendNumsRange, err = egg_energy.StatisticsUserEggSendCircleOfFriendNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"论坛评论次数"范围
resp.StatisticsUserEggForumCommentsNumsRange, err = egg_energy.StatisticsUserEggForumCommentsNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"学院学习次数"范围
resp.StatisticsUserEggCollegeLearningNumsRange, err = egg_energy.StatisticsUserEggCollegeLearningNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"违规次数"范围
resp.StatisticsUserEggViolateNumsRange, err = egg_energy.StatisticsUserEggViolateNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"浏览界面次数"范围
resp.StatisticsUserEggBrowseInterfaceNumsRange, err = egg_energy.StatisticsUserEggBrowseInterfaceNumsRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
//统计用户"个人活跃积分增量值"范围
resp.StatisticsUserEggPersonAddActivityValueRange, err = egg_energy.StatisticsUserEggPersonAddActivityValueRange(esIndexName)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}
// 更新缓存
cache.SetJson(redisKey, resp, -1)
}

resp.YearAndWeekList, err = egg_energy.GetYearsAndWeeks()
if err != nil {
return
}
if err != nil {
e.OutErr(c, e.ERR, err.Error())
}


+ 5
- 5
app/hdl/institutional_management/egg_energy/hdl_platform_revenue.go Zobrazit soubor

@@ -170,17 +170,17 @@ func AddPlatformRevenue(c *gin.Context) {

platformRevenueDataDb := implement.NewPlatformRevenueDataDb(db.Db)
now := time.Now()
hour := now.Hour()
if req.Hours > 24 {
hour = 24
}
//hour := now.Hour()
//if req.Hours > 24 {
// hour = 24
//}

times := req.Hours * 60 / req.Frequency
m := model.PlatformRevenueData{
Kind: req.Kind,
TotalAmount: req.TotalAmount,
BalanceAmount: req.TotalAmount,
Hours: hour,
Hours: req.Hours,
BalanceTimes: times,
Frequency: req.Frequency,
Memo: req.Memo,


+ 1
- 0
app/md/institutional_management/egg_energy/md_basic.go Zobrazit soubor

@@ -20,6 +20,7 @@ type VirtualCoin struct {
// BasicSetting 基础设置
type BasicSetting struct {
IsOpen int `json:"is_open" ` // 是否开启(1:开启 0:关闭)
InitialPrice string `json:"initial_price" ` // 初始价格
PersonEggEnergyCoinId int `json:"person_egg_energy_coin_id" ` // 个人蛋蛋能量对应虚拟币 id
TeamEggEnergyCoinId int `json:"team_egg_energy_coin_id" ` // 团队蛋蛋能量对应虚拟币 id
PersonEggPointsCoinId int `json:"person_egg_points_coin_id" ` // 个人蛋蛋积分对应虚拟币 id


+ 2
- 0
app/md/institutional_management/egg_energy/md_egg_point.go Zobrazit soubor

@@ -12,6 +12,8 @@ type UserEggIndexReq struct {
Week string `json:"week" example:"周份"`
}

const AutoCachingEggPointRedisKey = "EggEnergy:AutoCachingEggPoint:%s" // 年-周

type StatisticsEggPointResp struct {
Year string `json:"year" example:"年份"`
Week string `json:"week" example:"周份"`


+ 2
- 1
app/task/init.go Zobrazit soubor

@@ -43,7 +43,7 @@ func Run() {
func reload() {
cronTaskDb := implement.NewCronTaskDb(db.Db)
taskCfgList = cronTaskDb.MapCrontabCfg()
fmt.Println("taskCfgList>>>>>>>>>>>>>", taskCfgList)
if len(*taskCfgList) > 0 {
// 删除原有所有任务
if len(entryIds) > 0 {
@@ -97,4 +97,5 @@ func initTasks() {
jobs[taskMd.CornEggEnergyAutoAdjustPrice] = taskEggEnergyAutoAdjustPrice // 蛋蛋能量-自动调整价格
jobs[taskMd.CornEggEnergyAutoCommunityDividends] = taskEggEnergyCommunityDividends // 蛋蛋能量-社区分红
jobs[taskMd.CornEggEnergyAutomaticScoring] = taskEggEnergyAutomaticScoring // 蛋蛋能量-自动打分
jobs[taskMd.CornEggEnergyAutoCachingEggPointStatistics] = taskAutoCachingEggPointStatistics // 蛋蛋分统计落地页-缓存
}

+ 11
- 10
app/task/md/cron_key.go Zobrazit soubor

@@ -1,14 +1,15 @@
package md

const (
CronEggEnergyAutoRecordPrices = "cron_egg_energy_auto_record_price" // 自动记录价格
CronEggEnergyDealPlatformRevenueData = "cron_egg_energy_deal_platform_revenue_data" // 处理平台收益
CronEggEnergyDealFundData = "cron_egg_energy_deal_fund_data" // 处理价值投入
CronEggEnergyUserEggScore = "cron_egg_energy_user_egg_score" // 处理蛋蛋分
CornEggEnergyAutoReleaseTeamEggEnergy = "cron_egg_energy_auto_release_team_egg_energy" // 处理团队蛋蛋能量释放到个人蛋蛋能量
CornSettlementStarLevelDividends = "cron_egg_energy_settlement_star_level_dividends" // 结算星级分红
CornEggEnergyDealUserPublicPlatoonPunish = "cron_egg_energy_deal_user_public_platoon_punish" // 公排处罚
CornEggEnergyAutoAdjustPrice = "cron_egg_energy_auto_adjust_price" // 自动调整价格
CornEggEnergyAutoCommunityDividends = "cron_egg_energy_community_dividends" // 社区分红
CornEggEnergyAutomaticScoring = "corn_egg_energy_automatic_score" // 自动打分
CronEggEnergyAutoRecordPrices = "cron_egg_energy_auto_record_price" // 自动记录价格
CronEggEnergyDealPlatformRevenueData = "cron_egg_energy_deal_platform_revenue_data" // 处理平台收益
CronEggEnergyDealFundData = "cron_egg_energy_deal_fund_data" // 处理价值投入
CronEggEnergyUserEggScore = "cron_egg_energy_user_egg_score" // 处理蛋蛋分
CornEggEnergyAutoReleaseTeamEggEnergy = "cron_egg_energy_auto_release_team_egg_energy" // 处理团队蛋蛋能量释放到个人蛋蛋能量
CornSettlementStarLevelDividends = "cron_egg_energy_settlement_star_level_dividends" // 结算星级分红
CornEggEnergyDealUserPublicPlatoonPunish = "cron_egg_energy_deal_user_public_platoon_punish" // 公排处罚
CornEggEnergyAutoAdjustPrice = "cron_egg_energy_auto_adjust_price" // 自动调整价格
CornEggEnergyAutoCommunityDividends = "cron_egg_energy_community_dividends" // 社区分红
CornEggEnergyAutomaticScoring = "cron_egg_energy_automatic_score" // 自动打分
CornEggEnergyAutoCachingEggPointStatistics = "cron_egg_energy_auto_caching_egg_point_statistics" // 缓存蛋蛋分统计落地页
)

+ 0
- 3
app/task/md/md_deal_platform_revenue_data.go Zobrazit soubor

@@ -8,6 +8,3 @@ type RevenueDataNode struct {
Data model.PlatformRevenueData `json:"data"`
EveryAmount string `json:"every_amount" ` // 每次结算金额
}

type name struct {
}

+ 132
- 0
app/task/svc/svc_auto_caching_egg_point_statistics.go Zobrazit soubor

@@ -0,0 +1,132 @@
package svc

import (
md2 "applet/app/md/institutional_management/egg_energy"
"applet/app/svc/egg_energy"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
"context"
"fmt"
"strings"
"time"
"xorm.io/xorm"
)

const AutoCachingEggPointStatisticsLockKey = "egg_energy_auto_automatic_scoring_lock_key"

func AutoCachingEggPointStatistics(engine *xorm.Engine) {
fmt.Println("svc_egg_energy_auto_caching_egg_point_statistics...")
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
return
}
}()
fmt.Println("----------------------------AutoCachingEggPointStatistics_begin-------------------------------")

getString, _ := cache.GetString(AutoCachingEggPointStatisticsLockKey)
if getString != "" {
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次蛋蛋分统计未执行完")
return
}
cache.SetEx(AutoCachingEggPointStatisticsLockKey, "running", 10*60) // 10 min

// 1. 查询所有蛋蛋分索引
aliasName := md.EggEnergyUserEggScoreEsAlias
aliases, err := es.EsClient.Aliases().
Index(aliasName). // 指定别名
Do(context.Background())
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_GetAllIndexFailed_ERR:::::", err.Error())
return
}
now := time.Now()
year, week := now.ISOWeek()
currentWeekIndex := fmt.Sprintf(md.EggEnergyUserEggScoreEsAlias+"_%d%d", year, week)
// 2. 按周处理蛋蛋分记录
for esIndexName, _ := range aliases.Indices {
// 2.1 查询是否有此周且不为当周记录
egg_energy.GetYearsAndWeekStr(esIndexName)
if esIndexName != currentWeekIndex {
exists := cache.Exists(md2.AutoCachingEggPointRedisKey)
if exists {
continue
}
}

// 2.2 更新记录
var tempWeek md2.StatisticsEggPointResp
//统计用户"ecpm"范围
tempWeek.StatisticsUserEggEcpmRange, err = egg_energy.StatisticsUserEggEcpmRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"拉新人数"范围
tempWeek.StatisticsUserEggInviteUserNumsRange, err = egg_energy.StatisticsUserEggInviteUserNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"团队活跃次数"范围
tempWeek.StatisticsUserEggTeamActivityNumsRange, err = egg_energy.StatisticsUserEggTeamActivityNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"签到次数"范围
tempWeek.StatisticsUserEggSignInNumsRange, err = egg_energy.StatisticsUserEggSignInNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"发红包次数"范围
tempWeek.StatisticsUserEggSendRedPackageNumsRange, err = egg_energy.StatisticsUserEggSendRedPackageNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"蛋蛋能量兑换余额数量"范围
tempWeek.StatisticsUserEggEggEnergyExchangeAccountBalanceRange, err = egg_energy.StatisticsUserEggEggEnergyExchangeAccountBalanceRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"蛋蛋能量兑换余额数量"范围
tempWeek.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange, err = egg_energy.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"发朋友圈次数"范围
tempWeek.StatisticsUserEggSendCircleOfFriendNumsRange, err = egg_energy.StatisticsUserEggSendCircleOfFriendNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"论坛评论次数"范围
tempWeek.StatisticsUserEggForumCommentsNumsRange, err = egg_energy.StatisticsUserEggForumCommentsNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"学院学习次数"范围
tempWeek.StatisticsUserEggCollegeLearningNumsRange, err = egg_energy.StatisticsUserEggCollegeLearningNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"违规次数"范围
tempWeek.StatisticsUserEggViolateNumsRange, err = egg_energy.StatisticsUserEggViolateNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"浏览界面次数"范围
tempWeek.StatisticsUserEggBrowseInterfaceNumsRange, err = egg_energy.StatisticsUserEggBrowseInterfaceNumsRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}
//统计用户"个人活跃积分增量值"范围
tempWeek.StatisticsUserEggPersonAddActivityValueRange, err = egg_energy.StatisticsUserEggPersonAddActivityValueRange(esIndexName)
if err != nil {
fmt.Println("AutoCachingEggPointStatistics_StatisticsFailed_ERR:::::", err.Error())
}

parts := strings.Split(esIndexName, "_")
yearAndWeekStr := parts[len(parts)-1]
redisKey := fmt.Sprintf(md2.AutoCachingEggPointRedisKey, yearAndWeekStr)
cache.SetJson(redisKey, tempWeek, -1)
}
fmt.Println("----------------------------AutoCachingEggPointStatistics_end-------------------------------")
}

+ 20
- 21
app/task/svc/svc_egg_energy_auto_record_price.go Zobrazit soubor

@@ -28,7 +28,7 @@ func EggEnergyAutoRecordPrices(engine *xorm.Engine) {

// 1. 获取最后一条记录
priceDb := implement.NewEggEnergyPriceDb(engine)
lastPrice, has, err := priceDb.EggEnergyPriceGetLastOne()
lastPrice, err := priceDb.EggEnergyPriceGetOneByParams(dateNowStr, now.Hour())
if err != nil {
fmt.Println("EggEnergyAutoRecordPrices_ERR:::::", err.Error())
return
@@ -45,27 +45,26 @@ func EggEnergyAutoRecordPrices(engine *xorm.Engine) {
defer cb() // 释放锁
}

if has {
if lastPrice.Date == dateNowStr && lastPrice.Hour == hourNowStr {
return
// 3. 当前时间已经有记录 更新价格
if lastPrice.Date == dateNowStr && lastPrice.Hour == hourNowStr {
lastPrice.Price = eggEnergyCoreData.NowPrice
_, err2 := priceDb.EggEnergyPriceUpdate(lastPrice)
if err2 != nil {
fmt.Println("SaveEggEnergyPrice_ERR:::::", err2.Error())
return
}
} else {
// 4. 保存当前价格
priceData := model.EggEnergyPrice{
Price: eggEnergyCoreData.NowPrice,
Date: dateNowStr,
Hour: hourNowStr,
}
_, err2 := priceDb.EggEnergyPriceInsert(&priceData)
if err2 != nil {
fmt.Println("SaveEggEnergyPrice_ERR:::::", err2.Error())
return
}
lastPrice.Price = eggEnergyCoreData.NowPrice
_, err2 := priceDb.EggEnergyPriceUpdate(lastPrice)
if err2 != nil {
fmt.Println("SaveEggEnergyPrice_ERR:::::", err2.Error())
return
}
} else {
// 4. 当前时间还没有记录 保存当前价格
priceData := model.EggEnergyPrice{
Price: eggEnergyCoreData.NowPrice,
Date: dateNowStr,
Hour: hourNowStr,
}
_, err2 := priceDb.EggEnergyPriceInsert(&priceData)
if err2 != nil {
fmt.Println("SaveEggEnergyPrice_ERR:::::", err2.Error())
return
}
}
return


+ 1
- 1
app/task/svc/svc_egg_energy_auto_update_user_access.go Zobrazit soubor

@@ -46,7 +46,7 @@ func EggEnergyAutoUpdateUserAccess(engine *xorm.Engine) {
updateInfoMap := make([]interface{}, 0, len(list))
for _, node := range list {
uid := node.Uid
id := fmt.Sprintf("%d%d-%d", year, week, uid)
id := fmt.Sprintf("%d%d_%d", year, week, uid)
ids = append(ids, id)
updateInfoMap = append(updateInfoMap, map[string]interface{}{
"browse_interface_nums": node.Total,


+ 4
- 4
app/task/svc/svc_egg_energy_automatic_scoring.go Zobrazit soubor

@@ -16,10 +16,10 @@ import (
"xorm.io/xorm"
)

const LockKey = "egg_energy_auto_automatic_scoring_lock_key"
const EggEnergyAutomaticScoringLockKey = "egg_energy_auto_automatic_scoring_lock_key"

func EggEnergyAutomaticScoring(engine *xorm.Engine) {
fmt.Println("svc_egg_energy_auto_update_user_access...")
fmt.Println("svc_egg_energy_auto_score...")
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
@@ -29,12 +29,12 @@ func EggEnergyAutomaticScoring(engine *xorm.Engine) {

fmt.Println("----------------------------EggEnergyAutomaticScoring_begin-------------------------------")
// 增加“悲观锁”防止串行
getString, _ := cache.GetString(LockKey)
getString, _ := cache.GetString(EggEnergyAutomaticScoringLockKey)
if getString != "" {
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次蛋蛋分自动打分未执行完")
return
}
cache.SetEx(LockKey, "running", 3600*6) // 6小时
cache.SetEx(EggEnergyAutomaticScoringLockKey, "running", 3600*6) // 6小时

now := time.Now()
fmt.Println(now.Hour())


+ 22
- 0
app/task/task_auto_caching_egg_point_statistics.go Zobrazit soubor

@@ -0,0 +1,22 @@
package task

import (
"applet/app/task/svc"
"math/rand"
"time"
"xorm.io/xorm"
)

func taskAutoCachingEggPointStatistics(eg *xorm.Engine) {
for {
if len(ch) > workerNum {
time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000)))
} else {
goto START
}
}
START:
ch <- 1
svc.AutoCachingEggPointStatistics(eg)
<-ch
}

+ 42
- 6
etc/cfg.yml Zobrazit soubor

@@ -9,23 +9,59 @@ srv_addr: ':4001'
redis_addr: '127.0.0.1:6379'
redis_password: ''

#db:
# host: '119.23.182.117:3306'
# name: 'egg'
# user: 'root'
# psw: 'Fnuo123com@'
# show_log: true
# max_lifetime: 30
# max_open_conns: 100
# max_idle_conns: 100
# path: 'tmp/%s.log'
db:
host: '119.23.182.117:3306'
host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
name: 'egg'
user: 'root'
psw: 'Fnuo123com@'
user: 'canal'
psw: 'DengBiao@1997'
show_log: true
max_lifetime: 30
max_open_conns: 100
max_idle_conns: 100
path: 'tmp/%s.log'

#db_back:
# host: '119.23.182.117:3306'
# name: 'egg-data-back-up'
# user: 'root'
# psw: 'Fnuo123com@'
# show_log: true
# path: 'tmp/%s.log'

db_back:
host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
name: 'egg-data-back-up'
user: 'canal'
psw: 'DengBiao@1997'
show_log: true
path: 'tmp/%s.log'

#im_db:
# host: '119.23.182.117:3306'
# name: 'egg-im'
# user: 'root'
# psw: 'Fnuo123com@'
# show_log: true
# max_lifetime: 30
# max_open_conns: 100
# max_idle_conns: 100
# path: 'tmp/%s.log'

im_db:
host: '119.23.182.117:3306'
host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
name: 'egg-im'
user: 'root'
psw: 'Fnuo123com@'
user: 'canal'
psw: 'DengBiao@1997'
show_log: true
max_lifetime: 30
max_open_conns: 100


Načítá se…
Zrušit
Uložit