Kaynağa Gözat

邀请

master
huangjiajun 11 saat önce
ebeveyn
işleme
d9030679dd
4 değiştirilmiş dosya ile 107 ekleme ve 60 silme
  1. +8
    -3
      app/hdl/hdl_config.go
  2. +44
    -46
      app/hdl/hdl_user.go
  3. +13
    -11
      app/md/md_config.go
  4. +42
    -0
      app/svc/svc_common.go

+ 8
- 3
app/hdl/hdl_config.go Dosyayı Görüntüle

@@ -55,9 +55,14 @@ func Config(c *gin.Context) {
SeoLogo: svc.GetOssUrl(svc.GetSysCfgStr("seo_logo")),
WebLogo: svc.GetOssUrl(svc.GetSysCfgStr("web_logo")),
}
link := svc.GetSysCfgStr("kuaizhan_url")
link += "?type=download"
res.DownViewUrl = link

res.DownViewUrl, res.RegisterViewUrl = svc.DownUrl(c)
if res.DownViewUrl == "" {
link := svc.GetSysCfgStr("kuaizhan_url")
link += "?type=download"
res.DownViewUrl = link
}
res.DownWebOpen = svc.GetSysCfgStr("down_web_open")
e.OutSuc(c, res, nil)
return
}


+ 44
- 46
app/hdl/hdl_user.go Dosyayı Görüntüle

@@ -3,8 +3,6 @@ package hdl
import (
"applet/app/db"
"applet/app/e"
"applet/app/es/hdl"
md2 "applet/app/es/md"
"applet/app/lib/auth"
"applet/app/md"
"applet/app/svc"
@@ -13,19 +11,15 @@ import (
"applet/app/utils/qrcode"
"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/baidu"
md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
md4 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
es2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/es"
"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/gin-gonic/gin"
"github.com/olivere/elastic/v7"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"strings"
"time"
)
@@ -323,7 +317,7 @@ func UpdatePasscode(c *gin.Context) {
func InviteUrl(c *gin.Context) {
user := svc.GetUser(c)

link := svc.GetSysCfgStr("kuaizhan_url")
link := svc.GetSysCfgStr("kuaizhan_url") + "?type="
res := md.InviteUrl{
Link: "",
InviteCode: user.SystemInviteCode,
@@ -331,45 +325,49 @@ func InviteUrl(c *gin.Context) {
if user.CustomInviteCode != "" {
res.InviteCode = user.CustomInviteCode
}
link += "?inviteCode=" + res.InviteCode
EggUserShortLink := md2.EggUserShortLink
boolQueryToItem := elastic.NewBoolQuery() // 创建bool查询
aggsMatch := elastic.NewMatchQuery("link", link) //设置查询条件
boolQueryToItem.Must(aggsMatch)
result, _ := hdl.EsSelectOne(context.Background(), EggUserShortLink, boolQueryToItem, false)
isHas := 0
if result != nil && len(result.Hits.Hits) > 0 {
for _, hit := range result.Hits.Hits {
if hit == nil {
continue
}
jsonByte, _ := hit.Source.MarshalJSON()
if gjson.Get(string(jsonByte), "short_link").String() != "" && gjson.Get(string(jsonByte), "date").Int() > time.Now().Unix() {
isHas = 1
link = gjson.Get(string(jsonByte), "short_link").String()
}
}
}
if isHas == 0 {
url, _ := baidu.BaiduShortenUrl(svc.GetSysCfgStr("baidu_token"), link)
if url != "" {
var uniqueId = php2go.Md5(link)
oldLink := link
link = url
tmp := map[string]interface{}{
"uid": user.Id,
"link": oldLink,
"short_link": link,
"date": time.Now().Unix() + 365*86400,
}
doc, _ := es.FirstDoc(EggUserShortLink, uniqueId)
if doc == nil {
es.CreateDoc(EggUserShortLink, uniqueId, tmp)
} else {
es.UpdateDoc(EggUserShortLink, uniqueId, tmp)
}
}
}
_, registerViewUrl := svc.DownUrl(c)
if registerViewUrl != "" {
link = registerViewUrl
}
link += "&inviteCode=" + res.InviteCode
//EggUserShortLink := md2.EggUserShortLink
//boolQueryToItem := elastic.NewBoolQuery() // 创建bool查询
//aggsMatch := elastic.NewMatchQuery("link", link) //设置查询条件
//boolQueryToItem.Must(aggsMatch)
//result, _ := hdl.EsSelectOne(context.Background(), EggUserShortLink, boolQueryToItem, false)
//isHas := 0
//if result != nil && len(result.Hits.Hits) > 0 {
// for _, hit := range result.Hits.Hits {
// if hit == nil {
// continue
// }
// jsonByte, _ := hit.Source.MarshalJSON()
// if gjson.Get(string(jsonByte), "short_link").String() != "" && gjson.Get(string(jsonByte), "date").Int() > time.Now().Unix() {
// isHas = 1
// link = gjson.Get(string(jsonByte), "short_link").String()
// }
// }
//}
//if isHas == 0 {
// url, _ := baidu.BaiduShortenUrl(svc.GetSysCfgStr("baidu_token"), link)
// if url != "" {
// var uniqueId = php2go.Md5(link)
// oldLink := link
// link = url
// tmp := map[string]interface{}{
// "uid": user.Id,
// "link": oldLink,
// "short_link": link,
// "date": time.Now().Unix() + 365*86400,
// }
// doc, _ := es.FirstDoc(EggUserShortLink, uniqueId)
// if doc == nil {
// es.CreateDoc(EggUserShortLink, uniqueId, tmp)
// } else {
// es.UpdateDoc(EggUserShortLink, uniqueId, tmp)
// }
// }
//}
res.Link = link
QRcode := qrcode.GetPNGBase64(link)
QRcode = strings.ReplaceAll(QRcode, "\u0000", "")


+ 13
- 11
app/md/md_config.go Dosyayı Görüntüle

@@ -1,17 +1,19 @@
package md

type ConfigResp struct {
Title string `json:"title" example:"软件使用协议标题"`
Content string `json:"content" example:"软件使用协议内容"`
UserTitle string `json:"user_title" example:"用户协议标题"`
UserUrl string `json:"user_url" example:"用户协议链接"`
PrivacyTitle string `json:"privacy_title" example:"隐私协议标题"`
PrivacyUrl string `json:"privacy_url" example:"隐私协议链接"`
OssUrl string `json:"oss_url" example:"阿里云图片链接"`
Guide []Guide `json:"guide"`
DownUrl string `json:"down_url"`
DownViewUrl string `json:"down_view_url"`
Seo Seo `json:"seo"`
Title string `json:"title" example:"软件使用协议标题"`
Content string `json:"content" example:"软件使用协议内容"`
UserTitle string `json:"user_title" example:"用户协议标题"`
UserUrl string `json:"user_url" example:"用户协议链接"`
PrivacyTitle string `json:"privacy_title" example:"隐私协议标题"`
PrivacyUrl string `json:"privacy_url" example:"隐私协议链接"`
OssUrl string `json:"oss_url" example:"阿里云图片链接"`
Guide []Guide `json:"guide"`
DownUrl string `json:"down_url"`
DownViewUrl string `json:"down_view_url"`
RegisterViewUrl string `json:"register_view_url"`
DownWebOpen string `json:"down_web_open"`
Seo Seo `json:"seo"`
}
type Seo struct {
SeoTitle string `json:"seo_title" example:"seo"`


+ 42
- 0
app/svc/svc_common.go Dosyayı Görüntüle

@@ -7,7 +7,10 @@ import (
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"math/rand"
"strings"
"time"
)
@@ -135,3 +138,42 @@ func GetWeekInfo(dateStr string) (string, string, string, string) {
weekEnd := weekStart.AddDate(0, 0, 6)
return utils.IntToStr(year), utils.IntToStr(week), weekStart.Format("2006-01-02"), weekEnd.Format("2006-01-02")
}

func DownUrl(c *gin.Context) (string, string) {
downDomainStr := GetSysCfgStr("down_web_domain")
registerDomainStr := GetSysCfgStr("down_register_domain")
var downDomainArr = make([]string, 0)
json.Unmarshal([]byte(downDomainStr), &downDomainArr)
downDomain := ""
registerDomain := ""
if len(downDomainArr) > 0 {
rand.Seed(time.Now().UnixNano())
num := rand.Intn(len(downDomainArr))
if num == 0 {
num = 1
}
num--
downDomain = downDomainArr[num]
}
var registerDomainArr = make([]string, 0)
json.Unmarshal([]byte(registerDomainStr), &registerDomainArr)
if len(registerDomainArr) > 0 {
rand.Seed(time.Now().UnixNano())
num := rand.Intn(len(registerDomainArr))
if num == 0 {
num = 1
}
num--
registerDomain = registerDomainArr[num]
}
downUrl := ""
registerUrl := ""
if downDomain != "" {
downUrl = fmt.Sprintf("%s%s%s", "https://", downDomain, "/#/pages/down-page/down-page?type=download")
}
if registerDomain != "" {
registerUrl = fmt.Sprintf("%s%s%s", "https://", registerDomain, "/#/pages/down-page/down-page?type=")
}

return downUrl, registerUrl
}

Yükleniyor…
İptal
Kaydet