|
@@ -662,7 +662,7 @@ func SendMsg(param *Message, sendStatus int, loginUserName string, loginUserId i
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Println("迭代数据出错", err)
|
|
log.Println("迭代数据出错", err)
|
|
}
|
|
}
|
|
- //log.Println("单条数据:", user.UserId)
|
|
|
|
|
|
+
|
|
userId := user.UserId
|
|
userId := user.UserId
|
|
if config.SysConfigs.UserIdMap[userId] != "" {
|
|
if config.SysConfigs.UserIdMap[userId] != "" {
|
|
userId = config.SysConfigs.UserIdMap[userId]
|
|
userId = config.SysConfigs.UserIdMap[userId]
|
|
@@ -673,6 +673,7 @@ func SendMsg(param *Message, sendStatus int, loginUserName string, loginUserId i
|
|
} else {
|
|
} else {
|
|
projectIdMap.Store(userId, true)
|
|
projectIdMap.Store(userId, true)
|
|
}
|
|
}
|
|
|
|
+ log.Println("单条数据用户id:", user.UserId)
|
|
i++
|
|
i++
|
|
userIds += userId + ","
|
|
userIds += userId + ","
|
|
|
|
|
|
@@ -717,9 +718,12 @@ func SendMsg(param *Message, sendStatus int, loginUserName string, loginUserId i
|
|
if appVersion > "3.0.3" {
|
|
if appVersion > "3.0.3" {
|
|
go util.AppGrpcPush(dt, otherPushId, jgPushId, phoneType, appPushUrl)
|
|
go util.AppGrpcPush(dt, otherPushId, jgPushId, phoneType, appPushUrl)
|
|
}
|
|
}
|
|
|
|
+ log.Println("用户数量:", i)
|
|
if i == 100 {
|
|
if i == 100 {
|
|
|
|
+ log.Println("100用户开始发送消息:", len(userIds))
|
|
//调用消息中台
|
|
//调用消息中台
|
|
util.MultipleSaveMessage(msg, userIds, userNames)
|
|
util.MultipleSaveMessage(msg, userIds, userNames)
|
|
|
|
+ log.Println("100个用户发送消息完成......")
|
|
userNames = ""
|
|
userNames = ""
|
|
userIds = ""
|
|
userIds = ""
|
|
i = 0
|
|
i = 0
|
|
@@ -727,8 +731,10 @@ func SendMsg(param *Message, sendStatus int, loginUserName string, loginUserId i
|
|
|
|
|
|
}
|
|
}
|
|
if i > 0 {
|
|
if i > 0 {
|
|
|
|
+ log.Println("最后一批用户开始发送消息:", len(userIds))
|
|
//调用中台接口
|
|
//调用中台接口
|
|
util.MultipleSaveMessage(msg, userIds, userNames)
|
|
util.MultipleSaveMessage(msg, userIds, userNames)
|
|
|
|
+ log.Println("最后一批用户发送消息:完成")
|
|
userNames = ""
|
|
userNames = ""
|
|
userIds = ""
|
|
userIds = ""
|
|
i = 0
|
|
i = 0
|
|
@@ -795,3 +801,133 @@ func test_getGroup(ids string) (int, error) {
|
|
log.Println("获取分组及分组下用户耗时:", tc)
|
|
log.Println("获取分组及分组下用户耗时:", tc)
|
|
return 0, nil
|
|
return 0, nil
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//呼叫中心发送消息
|
|
|
|
+func pushMsg(param *SendMessage, sendStatus int) (int, error) {
|
|
|
|
+ var msgLogId string
|
|
|
|
+ if param.SendMode == 2 {
|
|
|
|
+ param.SendTime = time.Now().Format(qutil.Date_Full_Layout)
|
|
|
|
+ }
|
|
|
|
+ //保存发送的消息
|
|
|
|
+ log.Println("发送消息发送时间:", param.SendTime)
|
|
|
|
+ msgId := util.JysqlDB.Insert("message_send_log", map[string]interface{}{
|
|
|
|
+ "send_usergroup_id": "",
|
|
|
|
+ "send_usergroup_name": "",
|
|
|
|
+ "msg_type": param.MsgType,
|
|
|
|
+ "title": param.Title,
|
|
|
|
+ "content": param.Content,
|
|
|
|
+ "send_mode": param.SendMode,
|
|
|
|
+ "send_time": param.SendTime,
|
|
|
|
+ "send_status": sendStatus,
|
|
|
|
+ "update_time": time.Now().Format(qutil.Date_Full_Layout),
|
|
|
|
+ "createtime": time.Now().Format(qutil.Date_Full_Layout),
|
|
|
|
+ "link": param.Link,
|
|
|
|
+ "isdel": 1,
|
|
|
|
+ "send_userid": "hjzx", //呼叫中心
|
|
|
|
+ })
|
|
|
|
+ msgLogId = strconv.FormatInt(msgId, 10)
|
|
|
|
+ //立即发送
|
|
|
|
+ if param.SendMode == 2 {
|
|
|
|
+ //j := 0
|
|
|
|
+ projectIdMap := sync.Map{}
|
|
|
|
+ orm := util.Tidb.NewSession()
|
|
|
|
+ err := orm.Begin()
|
|
|
|
+ if err != nil {
|
|
|
|
+ log.Println("简历数据库连接出错:", err)
|
|
|
|
+ }
|
|
|
|
+ userNames := ""
|
|
|
|
+ userIds := ""
|
|
|
|
+ i := 0
|
|
|
|
+ msgType := strconv.Itoa(param.MsgType)
|
|
|
|
+ msg := map[string]interface{}{
|
|
|
|
+ "sendUserId": "hjzx",
|
|
|
|
+ "sendName": "呼叫中心",
|
|
|
|
+ "title": param.Title,
|
|
|
|
+ "content": param.Content,
|
|
|
|
+ "msgType": msgType,
|
|
|
|
+ "link": param.Link,
|
|
|
|
+ "appid": util.AppId,
|
|
|
|
+ "msgLogId": msgLogId,
|
|
|
|
+ }
|
|
|
|
+ userIdsArr := strings.Split(param.UserIds, ",")
|
|
|
|
+ for _, v := range userIdsArr {
|
|
|
|
+
|
|
|
|
+ userId := v
|
|
|
|
+
|
|
|
|
+ if config.SysConfigs.UserIdMap[userId] != "" {
|
|
|
|
+ userId = config.SysConfigs.UserIdMap[userId]
|
|
|
|
+ }
|
|
|
|
+ if _, ok := projectIdMap.Load(userId); ok {
|
|
|
|
+ log.Println("########################已发送,本次跳过。。。。。。。。。。。。。", userId)
|
|
|
|
+ continue
|
|
|
|
+ } else {
|
|
|
|
+ projectIdMap.Store(userId, true)
|
|
|
|
+ }
|
|
|
|
+ i++
|
|
|
|
+ userIds += userId + ","
|
|
|
|
+
|
|
|
|
+ //查询mongo库用户信息
|
|
|
|
+ userData := &map[string]interface{}{}
|
|
|
|
+ ok := false
|
|
|
|
+ var otherPushId, jgPushId, phoneType, name = "", "", "", ""
|
|
|
|
+ appVersion := ""
|
|
|
|
+ userData, ok = util.MQFW.FindById("user", userId, `"s_name":1,"s_opushid":1,"s_jpushid":1,"s_appponetype":1,"s_appversion":1`)
|
|
|
|
+ if userData != nil && len(*userData) > 0 && ok {
|
|
|
|
+ otherPushId = qutil.ObjToString((*userData)["s_opushid"])
|
|
|
|
+ jgPushId = qutil.ObjToString((*userData)["s_jpushid"])
|
|
|
|
+ phoneType = qutil.ObjToString((*userData)["s_appponetype"])
|
|
|
|
+ name = qutil.ObjToString((*userData)["s_name"])
|
|
|
|
+ appVersion = qutil.ObjToString((*userData)["s_appversion"])
|
|
|
|
+ }
|
|
|
|
+ userNames += name + ","
|
|
|
|
+ appPushUrl := "/jyapp/frontPage/messageCenter/sess/index"
|
|
|
|
+ if strings.Contains(phoneType, "iPhone") {
|
|
|
|
+ if param.IosUrl != "" {
|
|
|
|
+ appPushUrl = param.IosUrl
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if param.AndroidUrl != "" {
|
|
|
|
+ appPushUrl = param.AndroidUrl
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //实时发送发送时间为当前时间
|
|
|
|
+ param.SendTime = time.Now().Format(qutil.Date_Full_Layout)
|
|
|
|
+ dt := map[string]interface{}{
|
|
|
|
+ "receiveUserId": userId,
|
|
|
|
+ "receiveName": name,
|
|
|
|
+ "sendUserId": "qmx",
|
|
|
|
+ "sendName": "剑鱼后台",
|
|
|
|
+ "title": param.Title,
|
|
|
|
+ "content": param.Content,
|
|
|
|
+ "msgType": msgType,
|
|
|
|
+ "link": param.Link,
|
|
|
|
+ "appid": util.AppId,
|
|
|
|
+ }
|
|
|
|
+ //推送消息
|
|
|
|
+ if appVersion > "3.0.3" {
|
|
|
|
+ go util.AppGrpcPush(dt, otherPushId, jgPushId, phoneType, appPushUrl)
|
|
|
|
+ }
|
|
|
|
+ if i == 100 {
|
|
|
|
+ //调用消息中台
|
|
|
|
+ log.Println("100个用户开始发送消息:", i)
|
|
|
|
+ util.MultipleSaveMessage(msg, userIds, userNames)
|
|
|
|
+ log.Println("100个用户发送消息完成")
|
|
|
|
+ userNames = ""
|
|
|
|
+ userIds = ""
|
|
|
|
+ i = 0
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if i > 0 {
|
|
|
|
+ //调用中台接口
|
|
|
|
+ log.Println("最后一批用户开始发送消息:", i)
|
|
|
|
+ util.MultipleSaveMessage(msg, userIds, userNames)
|
|
|
|
+ log.Println("最后一批用户发送消息完成")
|
|
|
|
+ userNames = ""
|
|
|
|
+ userIds = ""
|
|
|
|
+ i = 0
|
|
|
|
+ }
|
|
|
|
+ return 1, nil
|
|
|
|
+ }
|
|
|
|
+ return 0, errors.New("发送消息出错")
|
|
|
|
+}
|