优化小程序部分
This commit is contained in:
1 parent
727319a6eb
commit
d4e89788c5
46 files changed
+4906
-63
No files matched your search
@@ -7,8 +7,11 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"server/models"
|
||||
"server/services/wechatmini"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
// GetSiteReminderConfig 获取站内信配置(从 yz_platform_normal_setting 读取)
|
||||
@@ -296,8 +299,29 @@ func SendSiteReminder(title, content string, senderID uint64, senderType string,
|
||||
}
|
||||
|
||||
// 批量插入
|
||||
_, err = models.Orm.InsertMulti(100, reminders)
|
||||
return err
|
||||
if _, err = models.Orm.InsertMulti(100, reminders); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 同步推送到小程序订阅消息(异步执行,不拖慢站内信本身)
|
||||
// 只有用户在小程序端授权过订阅、且平台配了对应场景模板时才会真正下发。
|
||||
for _, r := range receivers {
|
||||
if r.Type != "tenant" {
|
||||
continue // 平台端用户没有小程序 openid
|
||||
}
|
||||
tenantUserID := r.ID
|
||||
titleCopy, contentCopy := title, content
|
||||
go func(uid uint64, t, c string) {
|
||||
res := wechatmini.PushTenantNotice(uid, t, c)
|
||||
if res.Sent > 0 {
|
||||
logs.Info("[wechat-mini] 站内信已推送订阅消息: user=%d sent=%d", uid, res.Sent)
|
||||
}
|
||||
for _, e := range res.Errors {
|
||||
logs.Info("[wechat-mini] 订阅消息推送失败: user=%d err=%v", uid, e)
|
||||
}
|
||||
}(tenantUserID, titleCopy, contentCopy)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListReminders 列表查询
|
||||
|
||||
Reference in new issue
Block a user