Browse Source

Merge remote-tracking branch 'origin/master'

master
huangjiajun 5 days ago
parent
commit
ee5503a822
23 changed files with 394 additions and 194 deletions
  1. +3
    -20
      app/hdl/comm/hdl_comm.go
  2. +5
    -8
      app/hdl/friend_circle/hdl_dynamic.go
  3. +37
    -0
      app/hdl/institutional_management/egg_energy/hdl_egg_point.go
  4. +3
    -21
      app/hdl/institutional_management/egg_energy/hdl_platform_revenue.go
  5. +5
    -7
      app/hdl/institutional_management/module_setting/hdl_basic.go
  6. +3
    -21
      app/hdl/setCenter/oss/aliyun/hdl_basic.go
  7. +2
    -5
      app/hdl/website/hdl_website.go
  8. +2
    -12
      app/svc/cloud_bundle/svc_img_base.go
  9. +2
    -13
      app/svc/cloud_bundle/svc_version_info.go
  10. +3
    -4
      app/svc/content_reward/svc_playlet.go
  11. +2
    -4
      app/svc/content_reward/svc_video.go
  12. +3
    -21
      app/svc/notice/svc_aliyun_sms.go
  13. +5
    -40
      app/svc/svc_comm.go
  14. +41
    -0
      app/svc/svc_file_img_format.go
  15. +14
    -0
      app/svc/sys_cfg/sys_cfg_dao.go
  16. +118
    -0
      app/svc/sys_cfg/sys_cfg_implement.go
  17. +2
    -12
      app/svc/user_real_name/svc_base.go
  18. +1
    -1
      app/task/init.go
  19. +1
    -1
      app/task/md/cron_key.go
  20. +116
    -0
      app/task/svc/svc_egg_energy_automatic_scoring.go
  21. +22
    -0
      app/task/task_egg_energy_automatic_scoring.go
  22. +1
    -0
      etc/cfg.yml
  23. +3
    -4
      go.mod

+ 3
- 20
app/hdl/comm/hdl_comm.go View File

@@ -6,10 +6,9 @@ import (
"applet/app/enum"
"applet/app/md"
"applet/app/svc"
"applet/app/svc/sys_cfg"
"applet/app/utils"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
"fmt"
@@ -156,15 +155,7 @@ func GetOssUrl(c *gin.Context) {
CommOss(c, args)
}
func CommOss(c *gin.Context, args ImgReqUploadReq) {
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(sysCfgDb dao.SysCfgDao) {
err := sysCfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(sysCfgDb)

sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
sysCfgs, err := sysCfgDb.SysCfgGetAll()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
@@ -231,15 +222,7 @@ type GetSTSVoucherResp struct {
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/getSTSVoucher [GET]
func GetSTSVoucher(c *gin.Context) {
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(sysCfgDb dao.SysCfgDao) {
err := sysCfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(sysCfgDb)

sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
sysCfgs, err := sysCfgDb.SysCfgGetAll()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())


+ 5
- 8
app/hdl/friend_circle/hdl_dynamic.go View File

@@ -6,10 +6,8 @@ import (
md "applet/app/md/friend_circle"
"applet/app/svc"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
svc2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/svc"
"code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
"context"
"encoding/json"
@@ -134,8 +132,7 @@ func GetDynamic(c *gin.Context) {
for _, user := range users {
userMap[user.Id] = user.Nickname
}
redisConn := cache.GetPool().Get()
scheme, domain := svc2.ImageBucket(db.Db, redisConn)
scheme, domain := svc.ImageBucket(db.Db)
list := make([]md.DynamicRespNode, len(docs))
for _, doc := range docs {
switch doc.Kind {
@@ -144,8 +141,8 @@ func GetDynamic(c *gin.Context) {
case 2:
doc.Username = adminMap[doc.Uid]
}
imageStr := svc2.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image)
videoStr := svc2.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video)
imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image)
videoStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video)
images := strings.Split(imageStr, ";")
videos := strings.Split(videoStr, ";")
temp := md.DynamicRespNode{
@@ -289,8 +286,8 @@ func ReleaseDynamic(c *gin.Context) {
if req.IsTopUp == 0 {
req.IsTopUp = 2
}
redisConn := cache.GetPool().Get()
scheme, domain := svc2.ImageBucket(db.Db, redisConn)
scheme, domain := svc.ImageBucket(db.Db)
var imageStr string
if len(req.Image) > 0 {
imageStr = strings.Join(req.Image, ";")


+ 37
- 0
app/hdl/institutional_management/egg_energy/hdl_egg_point.go View File

@@ -5,10 +5,14 @@ import (
"applet/app/e"
md "applet/app/md/institutional_management/egg_energy"
"applet/app/svc/egg_energy"
"applet/app/utils"
"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"
"fmt"
"github.com/gin-gonic/gin"
"time"
)

// UserEggIndex
@@ -259,5 +263,38 @@ func ManualScore(c *gin.Context) {
e.OutErr(c, e.ERR, err.Error())
return
}

var scoreDoc md2.EggEnergyUserEggScoreEs
utils.Unserialize(doc.Source, &scoreDoc)
now := time.Now()
year, week, _, _ := utils.GetWeekInfo(scoreDoc.CreatedAt)
m := model.UserEggScoreData{
Uid: scoreDoc.Uid,
Ecpm: utils.Float64ToStr(scoreDoc.Ecpm),
InviteUserNums: scoreDoc.InviteUserNums,
TeamActivityNums: scoreDoc.TeamActivityNums,
SignInNums: scoreDoc.SignInNums,
ImActivityNums: scoreDoc.ImActivityNums,
SendRedPackageNums: scoreDoc.SendRedPackageNums,
EggEnergyExchangeAccountBalance: scoreDoc.EggEnergyExchangeAccountBalance,
AccountBalanceExchangeEggEnergyNums: scoreDoc.AccountBalanceExchangeEggEnergyNums,
SendCircleOfFriendNums: scoreDoc.SendCircleOfFriendNums,
ForumCommentsNums: scoreDoc.ForumCommentsNums,
CollegeLearningNums: scoreDoc.CollegeLearningNums,
ViolateNums: scoreDoc.ViolateNums,
BrowseInterfaceNums: scoreDoc.BrowseInterfaceNums,
PersonAddActivityValue: scoreDoc.PersonAddActivityValue,
Score: req.Score,
Date: fmt.Sprintf("%s-%s", year, week),
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}
// 插入手动打分记录
scoreDataDb := implement.NewUserEggScoreDataDb(db.Db)
_, err = scoreDataDb.UserEggScoreDataInsert(&m)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
e.OutSuc(c, "success", nil)
}

+ 3
- 21
app/hdl/institutional_management/egg_energy/hdl_platform_revenue.go View File

@@ -4,9 +4,7 @@ import (
"applet/app/db"
"applet/app/e"
md "applet/app/md/institutional_management/egg_energy"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"applet/app/svc/sys_cfg"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
@@ -27,15 +25,7 @@ import (
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/institutionalManagement/eggEnergy/platformRevenue/getVideoReward [post]
func GetVideoReward(c *gin.Context) {
conn := cache.GetPool().Get()
cfgDb := implement.NewSysCfgDb(db.Db, conn)
defer func(cfgDb dao.SysCfgDao) {
err := cfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(cfgDb)

cfgDb := sys_cfg.NewSysCfgDb(db.Db)
unitPrice, err2 := cfgDb.SysCfgGetOneNoDataNoErr(enum2.VideoRewardUnitPrice)
if err2 != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err2.Error())
@@ -78,15 +68,7 @@ func SetVideoReward(c *gin.Context) {
return
}

conn := cache.GetPool().Get()
cfgDb := implement.NewSysCfgDb(db.Db, conn)
defer func(cfgDb dao.SysCfgDao) {
err := cfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(cfgDb)

cfgDb := sys_cfg.NewSysCfgDb(db.Db)
if !cfgDb.SysCfgUpdate(enum2.VideoRewardUnitPrice, req.UnitPrice) {
e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum2.VideoReward.String(enum2.VideoRewardUnitPrice)+"失败!")
return


+ 5
- 7
app/hdl/institutional_management/module_setting/hdl_basic.go View File

@@ -5,11 +5,10 @@ import (
"applet/app/e"
md2 "applet/app/md"
"applet/app/md/institutional_management/module_setting"
svc2 "applet/app/svc"
"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"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/svc"
"errors"
"fmt"
"github.com/gin-gonic/gin"
@@ -70,9 +69,9 @@ func ModuleSettingGet(c *gin.Context) {
return
}
}
redisConn := cache.GetPool().Get()
scheme, domain := svc.ImageBucket(db.Db, redisConn)
moduleStyleStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, moduleStyle.Data)
scheme, domain := svc2.ImageBucket(db.Db)
moduleStyleStr := svc2.ImageFormatWithBucketForDataInfo(scheme, domain, moduleStyle.Data)
utils.Unserialize([]byte(moduleStyleStr), &data)

resp := md.ModuleSettingGetResp{
@@ -123,8 +122,7 @@ func ModuleSettingUpdate(c *gin.Context) {
moduleStyle.Data = utils.SerializeStr(req.Data)

// 替换所有 host
redisConn := cache.GetPool().Get()
scheme, domain := svc.ImageBucket(db.Db, redisConn)
scheme, domain := svc2.ImageBucket(db.Db)
moduleStyle.Data = strings.ReplaceAll(moduleStyle.Data, fmt.Sprintf("%s://%s/", scheme, domain), "{{tempHost}}")
affected, err := moduleStyleDb.ModuleStyleUpdate(moduleStyle.ModId, moduleStyle, forceColumns...)
if err != nil {


+ 3
- 21
app/hdl/setCenter/oss/aliyun/hdl_basic.go View File

@@ -4,10 +4,7 @@ import (
"applet/app/db"
"applet/app/e"
md "applet/app/md/setCenter/oss/aliyun"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"applet/app/svc/sys_cfg"
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
"github.com/gin-gonic/gin"
)
@@ -23,15 +20,7 @@ import (
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/settCenter/oss/aliYun/getBasic [get]
func GetBasic(c *gin.Context) {
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(sysCfgDb dao.SysCfgDao) {
err := sysCfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(sysCfgDb)

sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
sysCfg, err := sysCfgDb.SysCfgGetAll()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
@@ -122,14 +111,7 @@ func SetBasic(c *gin.Context) {
return
}

redisConn := cache.GetPool().Get()
cfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(cfgDb dao.SysCfgDao) {
err := cfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(cfgDb)
cfgDb := sys_cfg.NewSysCfgDb(db.Db)

if req.OssAccessKeyId != "" {
cfgDb.SysCfgUpdate(enum2.AliyunOssAccessKeyID, req.OssAccessKeyId)


+ 2
- 5
app/hdl/website/hdl_website.go View File

@@ -6,9 +6,7 @@ import (
"applet/app/md"
"applet/app/svc"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
svc2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/svc"
"github.com/gin-gonic/gin"
)

@@ -69,9 +67,8 @@ func GetModuleSetting(c *gin.Context) {
return
}
var dataMap interface{}
redisConn := cache.GetPool().Get()
scheme, domain := svc2.ImageBucket(db.Db, redisConn)
moduleStyle.Data = svc2.ImageFormatWithBucketForDataInfo(scheme, domain, moduleStyle.Data)
scheme, domain := svc.ImageBucket(db.Db)
moduleStyle.Data = svc.ImageFormatWithBucketForDataInfo(scheme, domain, moduleStyle.Data)
utils.Unserialize([]byte(moduleStyle.Data), &dataMap)
resp := md.GetModuleSettingResp{
ModName: moduleStyle.ModName,


+ 2
- 12
app/svc/cloud_bundle/svc_img_base.go View File

@@ -5,11 +5,8 @@ import (
"applet/app/e"
"applet/app/md"
"applet/app/svc"
"applet/app/svc/sys_cfg"
"applet/app/utils"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"encoding/json"
"github.com/gin-gonic/gin"
)
@@ -27,14 +24,7 @@ func ImgBaseSave(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
conn := cache.GetPool().Get()
cfgDb := implement.NewSysCfgDb(db.Db, conn)
defer func(cfgDb dao.SysCfgDao) {
err := cfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(cfgDb)
cfgDb := sys_cfg.NewSysCfgDb(db.Db)

cfgDb.SysCfgUpdate("app_cloud_bundle_data", utils.SerializeStr(req))
e.OutSuc(c, "success", nil)


+ 2
- 13
app/svc/cloud_bundle/svc_version_info.go View File

@@ -5,11 +5,8 @@ import (
"applet/app/e"
"applet/app/md"
"applet/app/svc"
"applet/app/svc/sys_cfg"
"applet/app/utils"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"encoding/json"
"github.com/gin-gonic/gin"
)
@@ -50,15 +47,7 @@ func VersionBaseSave(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
conn := cache.GetPool().Get()
cfgDb := implement.NewSysCfgDb(db.Db, conn)
defer func(cfgDb dao.SysCfgDao) {
err := cfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(cfgDb)

cfgDb := sys_cfg.NewSysCfgDb(db.Db)
cfgDb.SysCfgUpdate("app_version", utils.SerializeStr(req))
e.OutSuc(c, "success", nil)
return


+ 3
- 4
app/svc/content_reward/svc_playlet.go View File

@@ -5,9 +5,8 @@ import (
"applet/app/e"
"applet/app/md"
"applet/app/svc"
"applet/app/svc/sys_cfg"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"github.com/gin-gonic/gin"
"github.com/tidwall/gjson"
)
@@ -39,8 +38,8 @@ func PlayletBaseSave(c *gin.Context) {
e.OutErr(c, err1.Code, err1.Error())
return
}
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
sysCfgDb.SysCfgUpdate("playlet_base", utils.SerializeStr(req))
e.OutSuc(c, "success", nil)
return


+ 2
- 4
app/svc/content_reward/svc_video.go View File

@@ -5,9 +5,8 @@ import (
"applet/app/e"
"applet/app/md"
"applet/app/svc"
"applet/app/svc/sys_cfg"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"github.com/gin-gonic/gin"
"github.com/tidwall/gjson"
)
@@ -33,8 +32,7 @@ func VideoBaseSave(c *gin.Context) {
e.OutErr(c, err1.Code, err1.Error())
return
}
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
sysCfgDb.SysCfgUpdate("video_base", utils.SerializeStr(req))
e.OutSuc(c, "success", nil)
return


+ 3
- 21
app/svc/notice/svc_aliyun_sms.go View File

@@ -4,10 +4,8 @@ import (
"applet/app/db"
"applet/app/e"
"applet/app/md"
"applet/app/svc/sys_cfg"
"applet/app/utils"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"github.com/360EntSecGroup-Skylar/excelize"
@@ -119,16 +117,7 @@ func AliyunSmsDel(c *gin.Context) {
return
}
func AliyunSmsSaleBase(c *gin.Context) {

redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(sysCfgDb dao.SysCfgDao) {
err := sysCfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(sysCfgDb)

sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
aliyunSmsNotice := sysCfgDb.SysCfgGetWithDb("aliyun_sms_sale_code")
res := map[string]string{
"aliyun_sms_sale_code": aliyunSmsNotice,
@@ -142,14 +131,7 @@ func AliyunSmsSaleSave(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(sysCfgDb dao.SysCfgDao) {
err := sysCfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(sysCfgDb)
sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)

sysCfgDb.SysCfgUpdate("aliyun_sms_sale_code", req["aliyun_sms_sale_code"])
e.OutSuc(c, "success", nil)


+ 5
- 40
app/svc/svc_comm.go View File

@@ -2,11 +2,8 @@ package svc

import (
"applet/app/db"
"applet/app/svc/sys_cfg"
"applet/app/utils"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
ram20150501 "github.com/alibabacloud-go/ram-20150501/v2/client"
@@ -19,14 +16,7 @@ import (
)

func GetOssUrl(img string) string {
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(sysCfgDb dao.SysCfgDao) {
err := sysCfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(sysCfgDb)
sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
sysCfg := sysCfgDb.SysCfgFindWithDb("oss_domain", "oss_bucket_scheme")
if strings.Contains(img, "http") == false && img != "" {
http := sysCfg["oss_bucket_scheme"]
@@ -35,41 +25,16 @@ func GetOssUrl(img string) string {
return img
}
func GetOssDomain() string {
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(sysCfgDb dao.SysCfgDao) {
err := sysCfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(sysCfgDb)

sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
sysCfg := sysCfgDb.SysCfgFindWithDb("oss_domain", "oss_bucket_scheme")
http := sysCfg["oss_bucket_scheme"]
return http + "://" + sysCfg["oss_domain"] + "/"
}
func GetSysCfgStr(key string) string {
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(sysCfgDb dao.SysCfgDao) {
err := sysCfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(sysCfgDb)

return sysCfgDb.SysCfgGetWithDb(key)
return sys_cfg.NewSysCfgDb(db.Db).SysCfgGetWithDb(key)
}
func SetSysCfgStr(key, val string) bool {
redisConn := cache.GetPool().Get()
cfgDb := implement.NewSysCfgDb(db.Db, redisConn)
defer func(cfgDb dao.SysCfgDao) {
err := cfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(cfgDb)

cfgDb := sys_cfg.NewSysCfgDb(db.Db)
var bools bool
if val != "" {
data, _ := cfgDb.SysCfgGetOne(key)


+ 41
- 0
app/svc/svc_file_img_format.go View File

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

import (
"applet/app/svc/sys_cfg"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
"fmt"
"strings"
"xorm.io/xorm"
)

// ImageBucket is 获取域名
func ImageBucket(engine *xorm.Engine) (string, string) {
sysCfgDb := sys_cfg.NewSysCfgDb(engine)
res := sysCfgDb.SysCfgFindWithDb(enum.AliyunOssBucketScheme, enum.AliyunOssDomain)
return res[enum.AliyunOssBucketScheme], res[enum.AliyunOssDomain]
}

// ImageFormatWithBucket is 格式化成oss 域名
func ImageFormatWithBucket(scheme, domain, name string) string {
if strings.Contains(name, "http") || name == "" {
return name
}
return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
}

// ImageFormatWithBucketNew is 格式化成oss 域名
func ImageFormatWithBucketNew(scheme, domain, name string) string {
if strings.Contains(name, "http") {
return name
}

name = strings.ReplaceAll(name, "{{tempHost}}", "")
return fmt.Sprintf("%s://%s/%s", scheme, domain, name)
}

// ImageFormatWithBucketForDataInfo is 格式化成oss 域名 (只格式化内容中的 url)
func ImageFormatWithBucketForDataInfo(scheme, domain, name string) string {
prefix := fmt.Sprintf("%s://%s/", scheme, domain)
name = strings.ReplaceAll(name, "{{tempHost}}", prefix)
return name
}

+ 14
- 0
app/svc/sys_cfg/sys_cfg_dao.go View File

@@ -0,0 +1,14 @@
package sys_cfg

import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"

type SysCfgDao interface {
SysCfgGetAll() (*[]model.SysCfg, error)
SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error)
SysCfgGetOne(key string) (*model.SysCfg, error)
SysCfgInsert(key, val, memo string) bool
SysCfgUpdate(key, val string) bool
SysCfgGetWithDb(HKey string) string
SysCfgDel(HKey string) error
SysCfgFindWithDb(keys ...string) map[string]string
}

+ 118
- 0
app/svc/sys_cfg/sys_cfg_implement.go View File

@@ -0,0 +1,118 @@
package sys_cfg

import (
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/md"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"fmt"
"xorm.io/xorm"
)

func NewSysCfgDb(engine *xorm.Engine) SysCfgDao {
return &SysCfgDb{
Db: engine,
}
}

type SysCfgDb struct {
Db *xorm.Engine
}

func (s SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) {
var cfgList []model.SysCfg
if err := s.Db.Cols("key,val,memo").Find(&cfgList); err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &cfgList, nil
}

func (s SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) {
var cfgList model.SysCfg
_, err := s.Db.Where("`key`=?", key).Get(&cfgList)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return &cfgList, nil
}

func (s SysCfgDb) SysCfgGetOne(key string) (*model.SysCfg, error) {
var cfgList model.SysCfg
if has, err := s.Db.Where("`key`=?", key).Get(&cfgList); err != nil || has == false {
return nil, zhios_order_relate_logx.Error(err)
}
return &cfgList, nil
}

func (s SysCfgDb) SysCfgInsert(key, val, memo string) bool {
cfg := model.SysCfg{Key: key, Val: val, Memo: memo}
_, err := s.Db.InsertOne(&cfg)
if err != nil {
zhios_order_relate_logx.Error(err)
return false
}
return true
}

func (s SysCfgDb) SysCfgUpdate(key, val string) bool {
cfg := model.SysCfg{Key: key, Val: val}
_, err := s.Db.Where("`key`=?", key).Cols("val").Update(&cfg)
if err != nil {
zhios_order_relate_logx.Error(err)
return false
}
s.SysCfgDel(key)
return true
}

func (s SysCfgDb) SysCfgGetWithDb(HKey string) string {
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, HKey[0:1])
get, err := cache.HGetString(cacheKey, HKey)
if err != nil || get == "" {
cfg, err := s.SysCfgGetOne(HKey)
if err != nil || cfg == nil {
_ = zhios_order_relate_logx.Error(err)
return ""
}

// key是否存在
cacheKeyExist := false
if cache.Exists(cacheKey) {
cacheKeyExist = true
}

// 设置缓存
_, err = cache.HSet(cacheKey, HKey, cfg.Val)
if err != nil {
_ = zhios_order_relate_logx.Error(err)
return ""
}
if !cacheKeyExist { // 如果是首次设置 设置过期时间
_, err := cache.Expire(cacheKey, md.CfgCacheTime)
if err != nil {
_ = zhios_order_relate_logx.Error(err)
return ""
}
}
return cfg.Val
}
return get
}

func (s SysCfgDb) SysCfgDel(HKey string) error {
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, HKey[0:1])
_, err := cache.HDel(cacheKey, HKey)
if err != nil {
return err
}
return nil
}

func (s SysCfgDb) SysCfgFindWithDb(keys ...string) map[string]string {
res := map[string]string{}
for _, v := range keys {
val := s.SysCfgGetWithDb(v)
res[v] = val
}
return res
}

+ 2
- 12
app/svc/user_real_name/svc_base.go View File

@@ -5,10 +5,7 @@ import (
"applet/app/e"
"applet/app/md"
"applet/app/svc"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"applet/app/svc/sys_cfg"
"github.com/gin-gonic/gin"
)

@@ -25,15 +22,8 @@ func BaseSave(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
conn := cache.GetPool().Get()
cfgDb := implement.NewSysCfgDb(db.Db, conn)
defer func(cfgDb dao.SysCfgDao) {
err := cfgDb.Close()
if err != nil {
logx.Error("redis close err:" + err.Error()) // 记录错误信息
}
}(cfgDb)

cfgDb := sys_cfg.NewSysCfgDb(db.Db)
cfgDb.SysCfgUpdate("user_real_name_money", req.UserRealNameMoney)
cfgDb.SysCfgUpdate("user_real_name_rule", req.UserRealNameRule)
e.OutSuc(c, "success", nil)


+ 1
- 1
app/task/init.go View File

@@ -96,5 +96,5 @@ func initTasks() {
jobs[taskMd.CornEggEnergyDealUserPublicPlatoonPunish] = taskEggEnergyDealUserPublicPlatoonPunish // 蛋蛋能量-公排处罚
jobs[taskMd.CornEggEnergyAutoAdjustPrice] = taskEggEnergyAutoAdjustPrice // 蛋蛋能量-自动调整价格
jobs[taskMd.CornEggEnergyAutoCommunityDividends] = taskEggEnergyCommunityDividends // 蛋蛋能量-社区分红
jobs[taskMd.CornEggEnergyAutomaticScoring] = taskEggEnergyAutomaticScoring // 蛋蛋能量-自动打分
}

+ 1
- 1
app/task/md/cron_key.go View File

@@ -10,5 +10,5 @@ const (
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" // 自动打分
)

+ 116
- 0
app/task/svc/svc_egg_energy_automatic_scoring.go View File

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

import (
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/es"
es2 "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"context"
"encoding/json"
"fmt"
"github.com/olivere/elastic/v7"
"time"
"xorm.io/xorm"
)

const LockKey = "egg_energy_auto_automatic_scoring_lock_key"

func EggEnergyAutomaticScoring(engine *xorm.Engine) {
fmt.Println("svc_egg_energy_auto_update_user_access...")
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
return
}
}()

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

now := time.Now()
fmt.Println(now.Hour())
weekday := now.Weekday()
if !(weekday != time.Wednesday && now.Hour() >= 0 && now.Hour() < 4) {
//TODO::只在周三凌晨零点 ~ 凌晨六点运行 (预计六点可以全部更新完,减少查询次数)
return
}

ch, err := rabbit.Cfg.Pool.GetChannel()
if err != nil {
fmt.Println("EggEnergyAutomaticScoringGetRabbitChannel_ERR:::::", err.Error())
return
}
defer ch.Release()

lastWeek := now.AddDate(0, 0, -7)
year, week := lastWeek.ISOWeek()
yearString := utils.IntToStr(year)
weekString := utils.IntToStr(week)
LastWeekIndex := es.GetAppointIndexFromAlias(yearString, weekString)
// 1. 获取上周未被打分的文档
page := 1
limit := 100
var limit64 int64
limit64 = int64(limit)
for {
boolQuery := elastic.NewBoolQuery()
boolQuery.Filter(elastic.NewTermQuery("score_value", "0"))
searchResult, err := es2.EsClient.Search().
Index(LastWeekIndex).
Query(boolQuery).
From((page-1)*limit).Size(limit).
Sort("created_at", true).
Pretty(true).
Do(context.Background())
if err != nil {
fmt.Println("EggEnergyAutomaticScoring_ERR:::::", err.Error())
return
}
// 检查是否有结果
if searchResult.Hits.TotalHits.Value != 0 {
// 解析结果
for _, hit := range searchResult.Hits.Hits {
var doc md.EggEnergyUserEggScoreEs
err = json.Unmarshal(hit.Source, &doc)
if err != nil {
return
}
m := md2.EggStructForAutoScoreData{
DocId: hit.Id,
Ecpm: doc.Ecpm,
InviteUserNums: doc.InviteUserNums,
TeamActivityNums: doc.TeamActivityNums,
SignInNums: doc.SignInNums,
ImActivityNums: doc.ImActivityNums,
SendRedPackageNums: doc.SendRedPackageNums,
EggEnergyExchangeAccountBalance: doc.EggEnergyExchangeAccountBalance,
AccountBalanceExchangeEggEnergyNums: doc.AccountBalanceExchangeEggEnergyNums,
SendCircleOfFriendNums: doc.SendCircleOfFriendNums,
ForumCommentsNums: doc.ForumCommentsNums,
CollegeLearningNums: doc.CollegeLearningNums,
ViolateNums: doc.ViolateNums,
BrowseInterfaceNums: doc.BrowseInterfaceNums,
PersonAddActivityValue: doc.PersonAddActivityValue,
}
// 推入队列异步处理
ch.Publish(md2.EggAppExchange, m, md2.EggRoutKeyForAutoScoreData)
}
}
if searchResult.Hits.TotalHits.Value < limit64 {
break
} else {
page++
}
}
fmt.Println("------------------EggEnergyAutomaticScoring_end:finish automatic scoring------------------")
return
}

+ 22
- 0
app/task/task_egg_energy_automatic_scoring.go View File

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

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

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

+ 1
- 0
etc/cfg.yml View File

@@ -20,6 +20,7 @@ db:
max_idle_conns: 100
path: 'tmp/%s.log'


im_db:
host: '119.23.182.117:3306'
name: 'egg-im'


+ 3
- 4
go.mod View File

@@ -16,7 +16,7 @@ require (
github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.20.0
github.com/go-redis/redis v6.15.9+incompatible
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gomodule/redigo v1.9.2
github.com/jinzhu/copier v0.4.0
github.com/makiuchi-d/gozxing v0.0.0-20210324052758-57132e828831
github.com/qiniu/api.v7/v7 v7.8.2
@@ -33,8 +33,8 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211152610-0c5e1e903c99
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212114007-477fc46cda14
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241212120727-3681308aeb14
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212140020-c99f60b4f868
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
github.com/360EntSecGroup-Skylar/excelize v1.4.1
@@ -44,7 +44,6 @@ require (
github.com/alibabacloud-go/tea v1.2.2
github.com/alibabacloud-go/tea-utils/v2 v2.0.6
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
github.com/gin-contrib/sessions v1.0.1
github.com/go-pay/gopay v1.5.98
github.com/go-sql-driver/mysql v1.8.1
github.com/gocolly/colly v1.2.0


Loading…
Cancel
Save