From 5bedad4e38aa9b9d708f0ee126f5985581f4043a Mon Sep 17 00:00:00 2001 From: dengbiao Date: Thu, 12 Dec 2024 11:35:15 +0800 Subject: [PATCH 1/8] update --- app/hdl/ModuleSetting.go | 1 + app/hdl/comm/hdl_comm.go | 9 +-------- app/hdl/hdl_add_friend.go | 1 + app/hdl/hdl_login.go | 9 +-------- app/hdl/hdl_wallet.go | 9 +-------- app/lib/alipay/face.go | 12 +++--------- app/lib/gopay/init_alipay.go | 12 +++--------- app/svc/svc_aliyun_base.go | 16 ++-------------- app/svc/svc_common.go | 22 +++------------------- app/svc/svc_im.go | 2 ++ go.mod | 4 ++-- 11 files changed, 20 insertions(+), 77 deletions(-) diff --git a/app/hdl/ModuleSetting.go b/app/hdl/ModuleSetting.go index b5f5211..6d20d72 100644 --- a/app/hdl/ModuleSetting.go +++ b/app/hdl/ModuleSetting.go @@ -60,6 +60,7 @@ func GetModuleSetting(c *gin.Context) { } var dataMap interface{} redisConn := cache.GetPool().Get() + defer redisConn.Close() scheme, domain := svc.ImageBucket(db.Db, redisConn) moduleStyle.Data = svc.ImageFormatWithBucketForDataInfo(scheme, domain, moduleStyle.Data) utils.Unserialize([]byte(moduleStyle.Data), &dataMap) diff --git a/app/hdl/comm/hdl_comm.go b/app/hdl/comm/hdl_comm.go index b46db4e..57c6e05 100644 --- a/app/hdl/comm/hdl_comm.go +++ b/app/hdl/comm/hdl_comm.go @@ -8,8 +8,6 @@ import ( "applet/app/svc" "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" enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" @@ -40,13 +38,8 @@ func GetOssUrl(c *gin.Context) { return } redisConn := cache.GetPool().Get() + defer redisConn.Close() 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) sysCfgs, err := sysCfgDb.SysCfgGetAll() if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) diff --git a/app/hdl/hdl_add_friend.go b/app/hdl/hdl_add_friend.go index c14a45a..6f95030 100644 --- a/app/hdl/hdl_add_friend.go +++ b/app/hdl/hdl_add_friend.go @@ -670,6 +670,7 @@ func MyFansUserList(c *gin.Context) { } redisConn := cache.GetPool().Get() + defer redisConn.Close() scheme, domain := svc.ImageBucket(db.Db, redisConn) var data []md.OneLineUserNode for _, v := range results { diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 00ba5cb..2baa645 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -9,8 +9,6 @@ import ( "applet/app/svc" "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" "code.fnuoos.com/EggPlanet/egg_system_rules.git/aliyun" @@ -322,13 +320,8 @@ func commReq(c *gin.Context, req md.RegisterReq) { var parentUser *model.User var inviteCode string redisConn := cache.GetPool().Get() + defer redisConn.Close() 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) sysCfg := sysCfgDb.SysCfgFindWithDb(enum.AppInviteType, enum.AppInviteLength) inviteCode = svc.ReturnCode(utils.StrToInt(sysCfg[enum.AppInviteLength]), utils.StrToInt(sysCfg[enum.AppInviteType]), 0) if req.InviteCode != "" { diff --git a/app/hdl/hdl_wallet.go b/app/hdl/hdl_wallet.go index e025741..a64d053 100644 --- a/app/hdl/hdl_wallet.go +++ b/app/hdl/hdl_wallet.go @@ -9,8 +9,6 @@ import ( "applet/app/svc" "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" rule2 "code.fnuoos.com/EggPlanet/egg_system_rules.git" @@ -413,13 +411,8 @@ func LaunchBindAlipayAccount(c *gin.Context) { scope := "auth_user" redisConn := cache.GetPool().Get() + defer redisConn.Close() 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) sysCfgs, err := sysCfgDb.SysCfgGetAll() if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) diff --git a/app/lib/alipay/face.go b/app/lib/alipay/face.go index 62b476b..eb0ee63 100644 --- a/app/lib/alipay/face.go +++ b/app/lib/alipay/face.go @@ -3,21 +3,15 @@ package alipay import ( "applet/app/db" "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_system_rules.git/enum" "errors" ) func FacePrepareAlipayCode(method string, params map[string]string) (interface{}, error) { - sysCfgDb := implement.NewSysCfgDb(db.Db, cache.GetPool().Get()) - defer func(sysCfgDb dao.SysCfgDao) { - err := sysCfgDb.Close() - if err != nil { - logx.Error("redis close err:" + err.Error()) // 记录错误信息 - } - }(sysCfgDb) + redisConn := cache.GetPool().Get() + defer redisConn.Close() + sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn) sysCfgMap := sysCfgDb.SysCfgFindWithDb("alipay_face_url", enum.AlipayAppId, enum.AlipayPrivateKey, enum.AlipayPublicKey, enum.AlipayPublicContentRSA2, enum.AlipayRootContent, enum.AppPublicContent) // 获取私钥和APPID diff --git a/app/lib/gopay/init_alipay.go b/app/lib/gopay/init_alipay.go index a2761c3..4d4969e 100644 --- a/app/lib/gopay/init_alipay.go +++ b/app/lib/gopay/init_alipay.go @@ -3,8 +3,6 @@ package alipay import ( "applet/app/db" "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_system_rules.git/enum" "github.com/go-pay/gopay" @@ -28,13 +26,9 @@ type InitAlipayStruct struct { // isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。 func InitAlipay(initData *InitAlipayStruct) (client *alipay.Client, err error) { if initData == nil { - sysCfgDb := implement.NewSysCfgDb(db.Db, cache.GetPool().Get()) - defer func(sysCfgDb dao.SysCfgDao) { - err = sysCfgDb.Close() - if err != nil { - logx.Error("redis close err:" + err.Error()) // 记录错误信息 - } - }(sysCfgDb) + redisConn := cache.GetPool().Get() + defer redisConn.Close() + sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn) sysCfgMap := sysCfgDb.SysCfgFindWithDb(enum.AlipayAppId, enum.AlipayPrivateKey, enum.AlipayPublicKey, enum.AlipayPublicContentRSA2, enum.AlipayRootContent, enum.AppPublicContent) initData = &InitAlipayStruct{ IsProd: true, diff --git a/app/svc/svc_aliyun_base.go b/app/svc/svc_aliyun_base.go index 1f07052..e8b91d0 100644 --- a/app/svc/svc_aliyun_base.go +++ b/app/svc/svc_aliyun_base.go @@ -3,8 +3,6 @@ package svc import ( "applet/app/db" "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" "github.com/gin-gonic/gin" "github.com/tidwall/gjson" @@ -12,13 +10,8 @@ import ( func AliyunCaptchBase(c *gin.Context) (string, string) { redisConn := cache.GetPool().Get() + defer redisConn.Close() 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) data := sysCfgDb.SysCfgFindWithDb("aliyun_captch_id_android", "aliyun_captch_key_android", "aliyun_captch_id_ios", "aliyun_captch_key_ios", "aliyun_captch_id_h5", "aliyun_captch_key_h5") if c.GetHeader("platform") == "android" { return data["aliyun_captch_id_android"], data["aliyun_captch_key_android"] @@ -33,13 +26,8 @@ func AliyunCaptchBase(c *gin.Context) (string, string) { } func AliyunSmsBase(c *gin.Context, types string) map[string]string { redisConn := cache.GetPool().Get() + defer redisConn.Close() 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) data := sysCfgDb.SysCfgFindWithDb("aliyun_sms_id", "aliyun_sms_secret", "aliyun_sms_code", "aliyun_sms_sign_name") data["aliyun_sms_code"] = gjson.Get(data["aliyun_sms_code"], types).String() return data diff --git a/app/svc/svc_common.go b/app/svc/svc_common.go index d114545..51c6004 100644 --- a/app/svc/svc_common.go +++ b/app/svc/svc_common.go @@ -5,7 +5,6 @@ import ( "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/gin-gonic/gin" @@ -27,26 +26,16 @@ func UserImg(user *model.User) *model.User { } func GetOssDomain() string { redisConn := cache.GetPool().Get() + defer redisConn.Close() 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) sysCfg := sysCfgDb.SysCfgFindWithDb("oss_domain", "oss_bucket_scheme") http := sysCfg["oss_bucket_scheme"] return http + "://" + sysCfg["oss_domain"] + "/" } func GetOssUrl(img string) string { redisConn := cache.GetPool().Get() + defer redisConn.Close() 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) sysCfg := sysCfgDb.SysCfgFindWithDb("oss_domain", "oss_bucket_scheme") if strings.Contains(img, "http") == false && img != "" { http := sysCfg["oss_bucket_scheme"] @@ -63,13 +52,8 @@ func NumFormat(num int) string { } func GetSysCfgStr(key string) string { redisConn := cache.GetPool().Get() + defer redisConn.Close() 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) } diff --git a/app/svc/svc_im.go b/app/svc/svc_im.go index 4e84f1e..03d1875 100644 --- a/app/svc/svc_im.go +++ b/app/svc/svc_im.go @@ -228,6 +228,7 @@ func DetailGrabRedPackage(redPackageId string) (resp []md.RedPackageDetailUserNo receivedUserAmount := strings.Split(imSendRedPackageOrd.ReceivedUserAmount, ",") redisConn := cache.GetPool().Get() + defer redisConn.Close() scheme, domain := svc.ImageBucket(db.Db, redisConn) for k, v := range receivedUserIds { resp = append(resp, md.RedPackageDetailUserNode{ @@ -342,6 +343,7 @@ func BalancePayForRedPackage(user *model.User, money string, req md.SendRedPacka } redisConn := cache.GetPool().Get() + defer redisConn.Close() scheme, domain := svc.ImageBucket(db.Db, redisConn) msg := &pb.RED_PACKAGE{ RedMessageType: pb.RedPacketMessageType_RMT_SEND, diff --git a/go.mod b/go.mod index d883a8b..96376b3 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module applet go 1.19 -//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models +replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models -// replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules +replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules require ( github.com/boombuler/barcode v1.0.1 From 100ef3c1f7f377b214e6d091a6a07c665ded6e3e Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 12 Dec 2024 12:03:18 +0800 Subject: [PATCH 2/8] update --- app/svc/svc_home_page.go | 12 ++++++++---- go.mod | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/svc/svc_home_page.go b/app/svc/svc_home_page.go index ec8b1f0..f8187b0 100644 --- a/app/svc/svc_home_page.go +++ b/app/svc/svc_home_page.go @@ -19,18 +19,22 @@ func CalcTodayEggEnergyPriceRises(engine *xorm.Engine, now time.Time) (err error priceDb := implement.NewEggEnergyPriceDb(db.Db) m, err = priceDb.EggEnergyPriceGetOneByParams(dateStr, hourStr) if err != nil { - return err, 0, false, "", "" + return err, 0, false, "0", "0" } initialPrice = m.Price - // todo 有数据后不需要此判断 if initialPrice == "" { - initialPrice = "1" + settingDb := implement.NewEggEnergyBasicSettingDb(db.Db) + basicSetting, err1 := settingDb.EggEnergyBasicSettingGetOne() + if err1 != nil { + return err1, 0, false, "0", "0" + } + initialPrice = basicSetting.InitialPrice } yesterdayPrice, _ := decimal.NewFromString(initialPrice) coreDataDb := implement.NewEggEnergyCoreDataDb(db.Db) coreData, err := coreDataDb.EggEnergyCoreDataGet() if err != nil { - return err, 0, false, "", "" + return err, 0, false, "0", "0" } nowPrice = coreData.NowPrice todayPrice, _ := decimal.NewFromString(coreData.NowPrice) diff --git a/go.mod b/go.mod index d883a8b..f943f46 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,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 v1.9.2 + github.com/gomodule/redigo v2.0.0+incompatible 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 @@ -37,6 +37,7 @@ require ( 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/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible + github.com/gin-contrib/sessions v1.0.1 github.com/go-pay/crypto v0.0.1 github.com/go-pay/gopay v1.5.101 github.com/go-pay/xlog v0.0.2 @@ -76,6 +77,7 @@ require ( github.com/clbanning/mxj/v2 v2.5.5 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect + github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect @@ -100,7 +102,6 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/nxadm/tail v1.4.8 // indirect github.com/pelletier/go-toml/v2 v2.2.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect From e03fa269ae22594862c488898fdaa99bf77dcd95 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Thu, 12 Dec 2024 12:19:30 +0800 Subject: [PATCH 3/8] update --- go.mod | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index bf2642d..0facc32 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module applet go 1.19 -replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models +//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models -replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules +//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules require ( github.com/boombuler/barcode v1.0.1 @@ -15,7 +15,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,11 +33,10 @@ require ( require ( code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211055111-7c47b67b46d2 - code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241211143147-17b736995b8f + code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212040618-f4422da40bfb 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/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible - github.com/gin-contrib/sessions v1.0.1 github.com/go-pay/crypto v0.0.1 github.com/go-pay/gopay v1.5.101 github.com/go-pay/xlog v0.0.2 From 478c9a4e05aba75fdd1c863a32a0e2a9298c7560 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Thu, 12 Dec 2024 14:20:10 +0800 Subject: [PATCH 4/8] update --- app/hdl/ModuleSetting.go | 7 ++---- app/hdl/hdl_add_friend.go | 7 ++---- app/svc/svc_file_img_format.go | 44 ++++++++++++++++++++++++++++++++++ app/svc/svc_im.go | 14 ++++------- go.mod | 5 ++-- 5 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 app/svc/svc_file_img_format.go diff --git a/app/hdl/ModuleSetting.go b/app/hdl/ModuleSetting.go index 6d20d72..10a4e1d 100644 --- a/app/hdl/ModuleSetting.go +++ b/app/hdl/ModuleSetting.go @@ -4,10 +4,9 @@ import ( "applet/app/db" "applet/app/e" "applet/app/md" + "applet/app/svc" "applet/app/utils" - "applet/app/utils/cache" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" - "code.fnuoos.com/EggPlanet/egg_system_rules.git/svc" "github.com/gin-gonic/gin" ) @@ -59,9 +58,7 @@ func GetModuleSetting(c *gin.Context) { return } var dataMap interface{} - redisConn := cache.GetPool().Get() - defer redisConn.Close() - scheme, domain := svc.ImageBucket(db.Db, redisConn) + scheme, domain := svc.ImageBucket(db.Db) moduleStyle.Data = svc.ImageFormatWithBucketForDataInfo(scheme, domain, moduleStyle.Data) utils.Unserialize([]byte(moduleStyle.Data), &dataMap) resp := md.GetModuleSettingResp{ diff --git a/app/hdl/hdl_add_friend.go b/app/hdl/hdl_add_friend.go index 6f95030..aa56d49 100644 --- a/app/hdl/hdl_add_friend.go +++ b/app/hdl/hdl_add_friend.go @@ -4,13 +4,12 @@ import ( "applet/app/db" "applet/app/e" "applet/app/md" + "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" enum "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" - "code.fnuoos.com/EggPlanet/egg_system_rules.git/svc" "encoding/json" "fmt" "github.com/gin-gonic/gin" @@ -669,9 +668,7 @@ func MyFansUserList(c *gin.Context) { } } - redisConn := cache.GetPool().Get() - defer redisConn.Close() - scheme, domain := svc.ImageBucket(db.Db, redisConn) + scheme, domain := svc.ImageBucket(db.Db) var data []md.OneLineUserNode for _, v := range results { isOnline := false diff --git a/app/svc/svc_file_img_format.go b/app/svc/svc_file_img_format.go new file mode 100644 index 0000000..0e7e9c3 --- /dev/null +++ b/app/svc/svc_file_img_format.go @@ -0,0 +1,44 @@ +package svc + +import ( + "applet/app/utils/cache" + "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" + "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" + "fmt" + "strings" + "xorm.io/xorm" +) + +// ImageBucket is 获取域名 +func ImageBucket(engine *xorm.Engine) (string, string) { + redisConn := cache.GetPool().Get() + defer redisConn.Close() + sysCfgDb := implement.NewSysCfgDb(engine, redisConn) + 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 +} diff --git a/app/svc/svc_im.go b/app/svc/svc_im.go index 03d1875..38c64a9 100644 --- a/app/svc/svc_im.go +++ b/app/svc/svc_im.go @@ -7,7 +7,6 @@ import ( "applet/app/md" "applet/app/pkg/pb" "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" rule2 "code.fnuoos.com/EggPlanet/egg_system_rules.git" @@ -15,7 +14,6 @@ import ( md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule" md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" - "code.fnuoos.com/EggPlanet/egg_system_rules.git/svc" "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "errors" "github.com/google/uuid" @@ -227,14 +225,12 @@ func DetailGrabRedPackage(redPackageId string) (resp []md.RedPackageDetailUserNo receivedTimes := strings.Split(imSendRedPackageOrd.ReceivedTimes, ",") receivedUserAmount := strings.Split(imSendRedPackageOrd.ReceivedUserAmount, ",") - redisConn := cache.GetPool().Get() - defer redisConn.Close() - scheme, domain := svc.ImageBucket(db.Db, redisConn) + scheme, domain := ImageBucket(db.Db) for k, v := range receivedUserIds { resp = append(resp, md.RedPackageDetailUserNode{ ImUserId: receivedImUserIds[k], UserNickName: usersMap[v].Nickname, - UserAvatarUrl: svc.ImageFormatWithBucket(scheme, domain, usersMap[v].Avatar), + UserAvatarUrl: ImageFormatWithBucket(scheme, domain, usersMap[v].Avatar), Amount: receivedUserAmount[k], ReceiveAt: receivedTimes[k], }) @@ -342,9 +338,7 @@ func BalancePayForRedPackage(user *model.User, money string, req md.SendRedPacka return nil, redPackageOrdId, err } - redisConn := cache.GetPool().Get() - defer redisConn.Close() - scheme, domain := svc.ImageBucket(db.Db, redisConn) + scheme, domain := ImageBucket(db.Db) msg := &pb.RED_PACKAGE{ RedMessageType: pb.RedPacketMessageType_RMT_SEND, RedPacketType: pb.RedPacketType(req.RedPacketType), @@ -359,7 +353,7 @@ func BalancePayForRedPackage(user *model.User, money string, req md.SendRedPacka RedPacketId: redPackageOrdId, SendRedPacketUid: utils.StrToInt64(req.UserId), SendRedPacketNickname: user.Nickname, - SendRedPacketAvatarUrl: svc.ImageFormatWithBucket(scheme, domain, user.Avatar), + SendRedPacketAvatarUrl: ImageFormatWithBucket(scheme, domain, user.Avatar), RedPacketSmallContent: req.RedPacketSmallContent, } resp, err = proto.Marshal(msg) diff --git a/go.mod b/go.mod index 0facc32..75f68b8 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,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 v1.9.2 + github.com/gomodule/redigo v2.0.0+incompatible 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,10 +33,11 @@ require ( require ( code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211055111-7c47b67b46d2 - code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212040618-f4422da40bfb + code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212061625-6194cb8f4125 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/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible + github.com/gin-contrib/sessions v1.0.1 github.com/go-pay/crypto v0.0.1 github.com/go-pay/gopay v1.5.101 github.com/go-pay/xlog v0.0.2 From de53ac55419e79841eed4ddeb1537c826dae55cb Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 12 Dec 2024 15:49:23 +0800 Subject: [PATCH 5/8] update --- app/hdl/hdl_points_center.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/hdl/hdl_points_center.go b/app/hdl/hdl_points_center.go index d59a56f..acb67cc 100644 --- a/app/hdl/hdl_points_center.go +++ b/app/hdl/hdl_points_center.go @@ -581,7 +581,12 @@ func GetContributionValue(c *gin.Context) { } var contributionValue string if virtualAmount != nil { - contributionValue = virtualAmount.Amount + contributionValueDecimal, err := decimal.NewFromString(virtualAmount.Amount) + if err != nil { + e.OutErr(c, e.ERR_UNMARSHAL, err.Error()) + return + } + contributionValue = contributionValueDecimal.StringFixed(0) } coinDb := implement.NewVirtualCoinDb(db.Db) @@ -650,7 +655,12 @@ func GetContributionValueFlow(c *gin.Context) { list := make([]md.ContributionValueFlowNode, len(flows)) for i, flow := range flows { list[i].Title = flow.Title - list[i].Amount = flow.Amount + amountDecimal, err1 := decimal.NewFromString(flow.Amount) + if err1 != nil { + e.OutErr(c, e.ERR_UNMARSHAL, err1.Error()) + return + } + list[i].Amount = amountDecimal.StringFixed(0) list[i].Direction = utils.IntToStr(flow.Direction) list[i].CreateAt = flow.CreateAt } From b78e9cb8495880247da78f8eb6fda88db5e4dbed Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 12 Dec 2024 15:58:47 +0800 Subject: [PATCH 6/8] update egg score --- app/svc/svc_points_center.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/svc/svc_points_center.go b/app/svc/svc_points_center.go index 5c8c603..9306a95 100644 --- a/app/svc/svc_points_center.go +++ b/app/svc/svc_points_center.go @@ -92,9 +92,11 @@ func GetEggPointRecordBase(now time.Time, uid int64, page int, limit int) ([]md. for i := 0; i < limit; i++ { var tempDays int if getLastWeek { - tempDays = 7 * ((page-1)*limit + i + 1) + // 未到周三下午两点,从上上周开始查询 + tempDays = 7 * ((page-1)*limit + i + 2) } else { - tempDays = 7 * ((page-1)*limit + i) + // 已过周三下午两点,从上周开始查询 + tempDays = 7 * ((page-1)*limit + i + 1) } tempTime := now.AddDate(0, 0, -tempDays) tempYear, tempWeek := tempTime.ISOWeek() From edd9d85b37bb12df46860f41dc8be348e9eec4e3 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 12 Dec 2024 16:01:03 +0800 Subject: [PATCH 7/8] update rule --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 75f68b8..3f7d7b4 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( require ( code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211055111-7c47b67b46d2 - code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212061625-6194cb8f4125 + code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212075956-ecd20b280216 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/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible From 799c052779d3d111e43491107f22dac8da6e5227 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 12 Dec 2024 17:40:33 +0800 Subject: [PATCH 8/8] update --- app/hdl/hdl_wallet.go | 3 +-- app/svc/svc_withdraw_apply.go | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/hdl/hdl_wallet.go b/app/hdl/hdl_wallet.go index a64d053..400dfaa 100644 --- a/app/hdl/hdl_wallet.go +++ b/app/hdl/hdl_wallet.go @@ -362,8 +362,7 @@ func GetWithdrawCondition(c *gin.Context) { //1. 判断是否为第一次提现 isFirst := false - has, err := db.Db.Where("uid = ?", user.Id). - Get(model.FinWithdrawApply{}) + has, err := db.Db.Where("uid = ?", user.Id).Get(model.FinWithdrawApply{}) if !has { //第一次提现 isFirst = true } diff --git a/app/svc/svc_withdraw_apply.go b/app/svc/svc_withdraw_apply.go index dbb16e1..b6f39d6 100644 --- a/app/svc/svc_withdraw_apply.go +++ b/app/svc/svc_withdraw_apply.go @@ -250,6 +250,8 @@ func GetWithdrawCondition(user *model.User, setting *model.FinWithdrawSetting, i utils.Unserialize([]byte(setting.FirstWithdrawSet), &firstWithdrawSet) if firstWithdrawSet.IsNeedRealName == 0 { resp.IsNeedRealName = false + resp.IsCanWithdraw = true + resp.NotWithdrawReason = "" } }