瀏覽代碼

推送

adv_callback
huangjiajun 4 週之前
父節點
當前提交
6e9a5538ae
共有 5 個檔案被更改,包括 108 行新增4 行删除
  1. +53
    -1
      app/task/svc/svc_aliyun_sms_record.go
  2. +52
    -0
      app/task/svc/svc_jpush_record.go
  3. +1
    -1
      app/task/svc/svc_no_login_send.go
  4. +1
    -1
      app/task/svc/svc_no_sign_send.go
  5. +1
    -1
      go.mod

+ 53
- 1
app/task/svc/svc_aliyun_sms_record.go 查看文件

@@ -1,6 +1,7 @@
package svc

import (
"applet/app/db"
"applet/app/md"
"applet/app/utils"
"applet/app/utils/cache"
@@ -35,17 +36,68 @@ func AliyunSmsRecord(eg *xorm.Engine) {
if v.Target == "0" { //全量用户
commSmsSend(eg, ch, v, p, "")
}
if v.Target == "1" { //全量用户
if v.Target == "1" || v.Target == "4" { //指定用户
MoreSmsSend(eg, ch, v)
}
if v.Target == "2" { //等级
commSmsSend(eg, ch, v, p, utils.IntToStr(v.Level))
}
if v.Target == "3" { //指定标签
tagSmsRecordSend(eg, ch, v, p)
}
v.IsRun = 1
eg.Where("id=?", v.Id).Cols("is_run").Update(&v)
}
cache.Del(key)
}
func tagSmsRecordSend(eg *xorm.Engine, ch *rabbit.Channel, data model.AliyunSmsRecord, p int) {
sql := `
SELECT * FROM user_tag_records utr
left join user u on u.id=utr.uid
WHERE %s GROUP BY u.id ORDER BY u.id asc %s
`
tagList := make([]string, 0)
json.Unmarshal([]byte(data.TagId), &tagList)
if len(tagList) == 0 {
return
}
where := "tag_id in(" + strings.Join(tagList, ",") + ")"
limit := " limit " + utils.IntToStr((p-1)*1000) + ",1000"
sql = fmt.Sprintf(sql, where, limit)
userList, _ := db.QueryNativeString(eg, sql)
uids := ""
if len(userList) == 0 {
return
}
for _, v := range userList {
if v["phone"] == "" {
continue
}
if uids == "" {
uids += v["phone"]
} else {
uids += "," + v["phone"]
}
}
if uids == "" {
return
}
arg := md.AliyunSmsRecordFundData{Phone: uids, Title: data.Title, Content: data.Content}
if len(userList) < 1000 {
arg.Id = utils.IntToStr(data.Id)
}
err := ch.PublishV2(md.EggAliyunSmsRecordQueueExchange, arg, md.EggAliyunSmsRecordQueue)
if err != nil {
ch.PublishV2(md.EggAliyunSmsRecordQueueExchange, arg, md.EggAliyunSmsRecordQueue)
}
if len(userList) == 1000 {
p++
tagSmsRecordSend(eg, ch, data, p)
return
}
return

}

func commSmsSend(eg *xorm.Engine, ch *rabbit.Channel, data model.AliyunSmsRecord, p int, level string) {
var userList []model.User


+ 52
- 0
app/task/svc/svc_jpush_record.go 查看文件

@@ -1,6 +1,7 @@
package svc

import (
"applet/app/db"
"applet/app/md"
"applet/app/utils"
"applet/app/utils/cache"
@@ -45,6 +46,9 @@ func JpushRecord(eg *xorm.Engine) {
if v.Target == "2" { //等级
commJpushRecordSend(eg, ch, v, p, utils.IntToStr(v.Level))
}
if v.Target == "3" { //标签
tagJpushRecordSend(eg, ch, v, p)
}
v.IsRun = 1
eg.Where("id=?", v.Id).Cols("is_run").Update(&v)
}
@@ -90,6 +94,54 @@ func commJpushRecordSend(eg *xorm.Engine, ch *rabbit.Channel, data model.JpushRe
}
return

}
func tagJpushRecordSend(eg *xorm.Engine, ch *rabbit.Channel, data model.JpushRecord, p int) {
sql := `
SELECT * FROM user_tag_records utr
left join user u on u.id=utr.uid
WHERE %s GROUP BY u.id ORDER BY u.id asc %s
`
tagList := make([]string, 0)
json.Unmarshal([]byte(data.TagId), &tagList)
if len(tagList) == 0 {
return
}
where := "tag_id in(" + strings.Join(tagList, ",") + ")"
limit := " limit " + utils.IntToStr((p-1)*1000) + ",1000"
sql = fmt.Sprintf(sql, where, limit)
userList, _ := db.QueryNativeString(eg, sql)
uids := ""
if len(userList) == 0 {
return
}
for _, v := range userList {
if v["phone"] == "" {
continue
}
if uids == "" {
uids += v["id"]
} else {
uids += "," + v["id"]
}
}
if uids == "" {
return
}
arg := md.JpushRecordFundData{UserId: uids, Target: data.Target, Platform: data.Platform, Title: data.Title, Content: data.Content}
if len(userList) < 1000 {
arg.Id = utils.IntToStr(data.Id)
}
err := ch.PublishV2(md.EggJpushRecordQueueExchange, arg, md.EggJpushRecordQueue)
if err != nil {
ch.PublishV2(md.EggJpushRecordQueueExchange, arg, md.EggJpushRecordQueue)
}
if len(userList) == 1000 {
p++
tagJpushRecordSend(eg, ch, data, p)
return
}
return

}
func MoreJpushRecordSend(eg *xorm.Engine, ch *rabbit.Channel, data model.JpushRecord) {
userList := make([]string, 0)


+ 1
- 1
app/task/svc/svc_no_login_send.go 查看文件

@@ -56,7 +56,7 @@ WHERE unt.login_time<'%d' and unt.login_notice_time<'%d' and unt.login_time>0 %s
data.Content = strings.ReplaceAll(data.Content, "{昵称}", v["nickname"])
data.Content = strings.ReplaceAll(data.Content, "{手机号}", v["phone"])
data.Content = strings.ReplaceAll(data.Content, "{小时}", utils.Int64ToStr(hour))
extra = "{\"hour\":\"" + utils.Int64ToStr(hour) + "\",\"name\":\"" + v["name"] + "\",\"phone\":\"" + v["phone"] + "\"}"
extra = "{\"hour\":\"" + utils.Int64ToStr(hour) + "\"}"
arg := md.JpushRecordFundData{UserId: v["id"], Target: "1", Platform: "all", Title: data.Title, Content: data.Content}
err := ch.PublishV2(md.EggJpushRecordQueueExchange, arg, md.EggJpushRecordQueue)
if err != nil {


+ 1
- 1
app/task/svc/svc_no_sign_send.go 查看文件

@@ -55,7 +55,7 @@ WHERE unt.sign_time<'%d' and unt.sign_notice_time<'%d' and unt.sign_time>0 %s
data.Content = strings.ReplaceAll(data.Content, "{昵称}", v["nickname"])
data.Content = strings.ReplaceAll(data.Content, "{手机号}", v["phone"])
data.Content = strings.ReplaceAll(data.Content, "{小时}", utils.Int64ToStr(hour))
extra = "{\"hour\":\"" + utils.Int64ToStr(hour) + "\",\"name\":\"" + v["name"] + "\",\"phone\":\"" + v["phone"] + "\"}"
extra = "{\"hour\":\"" + utils.Int64ToStr(hour) + "\"}"
arg := md.JpushRecordFundData{UserId: v["id"], Target: "1", Platform: "all", Title: data.Title, Content: data.Content}
err := ch.PublishV2(md.EggJpushRecordQueueExchange, arg, md.EggJpushRecordQueue)
if err != nil {


+ 1
- 1
go.mod 查看文件

@@ -32,7 +32,7 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241205041102-0e106357c399
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241205080507-c27ed1ab5226
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205061938-91f42710d6cd
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


Loading…
取消
儲存