Ver código fonte

Merge remote-tracking branch 'origin/master'

master
huangjiajun 1 semana atrás
pai
commit
3725dfe0cb
16 arquivos alterados com 95 adições e 103 exclusões
  1. +2
    -4
      app/hdl/ModuleSetting.go
  2. +1
    -8
      app/hdl/comm/hdl_comm.go
  3. +2
    -4
      app/hdl/hdl_add_friend.go
  4. +1
    -8
      app/hdl/hdl_login.go
  5. +12
    -2
      app/hdl/hdl_points_center.go
  6. +2
    -10
      app/hdl/hdl_wallet.go
  7. +3
    -9
      app/lib/alipay/face.go
  8. +3
    -9
      app/lib/gopay/init_alipay.go
  9. +2
    -14
      app/svc/svc_aliyun_base.go
  10. +3
    -19
      app/svc/svc_common.go
  11. +44
    -0
      app/svc/svc_file_img_format.go
  12. +8
    -4
      app/svc/svc_home_page.go
  13. +4
    -8
      app/svc/svc_im.go
  14. +4
    -2
      app/svc/svc_points_center.go
  15. +2
    -0
      app/svc/svc_withdraw_apply.go
  16. +2
    -2
      go.mod

+ 2
- 4
app/hdl/ModuleSetting.go Ver arquivo

@@ -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,8 +58,7 @@ func GetModuleSetting(c *gin.Context) {
return
}
var dataMap interface{}
redisConn := cache.GetPool().Get()
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{


+ 1
- 8
app/hdl/comm/hdl_comm.go Ver arquivo

@@ -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())


+ 2
- 4
app/hdl/hdl_add_friend.go Ver arquivo

@@ -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,8 +668,7 @@ func MyFansUserList(c *gin.Context) {
}
}

redisConn := cache.GetPool().Get()
scheme, domain := svc.ImageBucket(db.Db, redisConn)
scheme, domain := svc.ImageBucket(db.Db)
var data []md.OneLineUserNode
for _, v := range results {
isOnline := false


+ 1
- 8
app/hdl/hdl_login.go Ver arquivo

@@ -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 != "" {


+ 12
- 2
app/hdl/hdl_points_center.go Ver arquivo

@@ -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
}


+ 2
- 10
app/hdl/hdl_wallet.go Ver arquivo

@@ -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"
@@ -364,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
}
@@ -413,13 +410,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())


+ 3
- 9
app/lib/alipay/face.go Ver arquivo

@@ -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


+ 3
- 9
app/lib/gopay/init_alipay.go Ver arquivo

@@ -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,


+ 2
- 14
app/svc/svc_aliyun_base.go Ver arquivo

@@ -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


+ 3
- 19
app/svc/svc_common.go Ver arquivo

@@ -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)

}


+ 44
- 0
app/svc/svc_file_img_format.go Ver arquivo

@@ -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
}

+ 8
- 4
app/svc/svc_home_page.go Ver arquivo

@@ -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)


+ 4
- 8
app/svc/svc_im.go Ver arquivo

@@ -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,13 +225,12 @@ func DetailGrabRedPackage(redPackageId string) (resp []md.RedPackageDetailUserNo
receivedTimes := strings.Split(imSendRedPackageOrd.ReceivedTimes, ",")
receivedUserAmount := strings.Split(imSendRedPackageOrd.ReceivedUserAmount, ",")

redisConn := cache.GetPool().Get()
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],
})
@@ -341,8 +338,7 @@ func BalancePayForRedPackage(user *model.User, money string, req md.SendRedPacka
return nil, redPackageOrdId, err
}

redisConn := cache.GetPool().Get()
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),
@@ -357,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)


+ 4
- 2
app/svc/svc_points_center.go Ver arquivo

@@ -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()


+ 2
- 0
app/svc/svc_withdraw_apply.go Ver arquivo

@@ -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 = ""
}
}



+ 2
- 2
go.mod Ver arquivo

@@ -4,7 +4,7 @@ go 1.19

//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
@@ -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.20241211143147-17b736995b8f
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


Carregando…
Cancelar
Salvar