Procházet zdrojové kódy

代用户下单去掉推送wx app

renjiaojiao před 1 rokem
rodič
revize
4d2a3be3eb

+ 3 - 25
rpc/internal/common/appPush.go

@@ -13,6 +13,9 @@ import (
 )
 
 func AppPushMsg(userInfo map[string]interface{}, sth, appPushUrl, title, detail string, msgType int64) error {
+	if userInfo == nil {
+		return fmt.Errorf("为查询到用户信息")
+	}
 	//限制
 	//校验发送间隔
 	userId := mongodb.BsonIdToSId(userInfo["_id"])
@@ -102,28 +105,3 @@ func AppGrpcPush(pushData map[string]interface{}, otherPushId, jgPushId, phoneTy
 	}
 	return nil
 }
-
-func (stm *WxTmplPush) GetUserAppPushState() error {
-	uData := stm.GetUserPushInfo()
-	if uData == nil {
-		return fmt.Errorf("未查询到用户信息")
-	}
-	stm.OpushId = qutil.InterfaceToStr(uData["s_opushid"])
-	stm.JpushId = qutil.InterfaceToStr(uData["s_jpushid"])
-	stm.AppPoneType = qutil.InterfaceToStr(uData["s_appponetype"])
-	appVersion := qutil.InterfaceToStr(uData["s_appversion"])
-	if stm.OpushId == "" || stm.JpushId == "" || stm.AppPoneType == "" {
-		return fmt.Errorf("未查询到用户app信息")
-	}
-	if appVersion < "3.0.3" {
-		return fmt.Errorf("用户app版本低于(3.0.3)")
-	}
-	if pushSetMap := qutil.ObjToMap(uData["o_pushset"]); pushSetMap != nil && len(*pushSetMap) > 0 {
-		if pushKeyMap := qutil.ObjToMap((*pushSetMap)[stm.Config.Switch]); pushKeyMap != nil && len(*pushKeyMap) > 0 {
-			if qutil.Int64All((*pushKeyMap)["i_apppush"]) == 1 {
-				return nil
-			}
-		}
-	}
-	return fmt.Errorf("未开启推送设置")
-}

+ 17 - 8
rpc/internal/common/sendMsg.go

@@ -480,16 +480,25 @@ func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
 					nTime = this.OrderMoney
 				}
 				// 消息模版 工单类型 {{thing19.DATA}} 工单标题 {{thing6.DATA}} 项目名称 {{thing13.DATA}} 服务时间 {{time25.DATA}} 服务地址 {{thing26.DATA}}
-				err = p.SendMsg(this.WxPushUrl, this.Title, this.Content, nTime, this.Row4)
-				if err != nil {
-					logx.Error(fmt.Sprintf("SendWxTmplMsg uId %s  Error %s", v, err.Error()))
-				} else {
-					logx.Infof("SendWxTmplMsg uId success %s ", v)
+				if !(this.MsgType == 1) && this.MsgType != 10 {
+					err = p.SendMsg(this.WxPushUrl, this.Title, this.Content, nTime, this.Row4)
+					if err != nil {
+						logx.Error(fmt.Sprintf("SendWxTmplMsg uId %s  Error %s", v, err.Error()))
+					} else {
+						logx.Infof("SendWxTmplMsg uId success %s ", v)
+					}
+				}
+				if this.MsgType == 1 {
+					mst := new(WxTmplConfig)
+					mst.Switch = AppPushMsgType[group_id]
+					p.Config = mst
 				}
 				//app推送
-				uData := p.GetUserPushInfo()
-				if err = AppPushMsg(uData, pushConfig.Switch, this.AppPushUrl, this.Title, this.Content, this.MsgType); err != nil {
-					logx.Error(fmt.Sprintf("SendWxTmplMsg uId %s  Error %s", v, err.Error()))
+				if this.MsgType != 10 {
+					uData := p.GetUserPushInfo()
+					if err = AppPushMsg(uData, AppPushMsgType[group_id], this.AppPushUrl, this.Title, this.Content, this.MsgType); err != nil {
+						logx.Error(fmt.Sprintf("SendAppMsg uId %s  Error %s", v, err.Error()))
+					}
 				}
 			}
 		}(userIdArr[i], name, positionId)

+ 10 - 2
rpc/internal/common/sendWxTmplMsg.go

@@ -11,6 +11,7 @@ import (
 	qrpc "app.yhyue.com/moapp/jybase/rpc"
 	"encoding/json"
 	"fmt"
+	"log"
 	"net/url"
 	"regexp"
 	"strings"
@@ -24,6 +25,7 @@ type WxTmplPush struct {
 
 var AllMsgType func() map[int64]WxTmplConfig
 var allMsgValueKeys = []string{"$class", "$title", "$detail", "$date", "$row4", "$note"}
+var AppPushMsgType map[int]string
 
 type WxTmplConfig struct {
 	Name      string //信息名称
@@ -38,8 +40,15 @@ func MessageType() (func() map[int64]WxTmplConfig, []map[string]interface{}) {
 	var data []map[string]interface{}
 	rData1 := entity.Mysql.SelectBySql(`SELECT * FROM message_group ORDER BY sequence ASC`)
 	switchName := map[int64]WxTmplConfig{}
+	appMsgType := map[int]string{}
 	if rData1 != nil && len(*rData1) > 0 {
 		data = *rData1
+		for _, v := range *rData1 {
+			groupId := util.IntAll(v["group_id"])
+			switchs := util.ObjToString(v["switch"])
+			appMsgType[groupId] = switchs
+		}
+		AppPushMsgType = appMsgType
 	}
 
 	rData2 := entity.Mysql.SelectBySql(`SELECT g.switch,c.wxtmpl_Id,c.msg_type,c.msg_name,c.wxtmp_value FROM message_class c INNER JOIN message_group g on c.group_id =g.group_id WHERE c.wxtmpl_Id IS NOT NULL`)
@@ -195,6 +204,7 @@ func (stm *WxTmplPush) getUserOpenIdAndWxPushState() error {
 	if stm.OpenId == "" {
 		return fmt.Errorf("未查询到用户微信信息")
 	}
+	log.Println("======", stm.Config.Switch)
 	if pushSetMap := common.ObjToMap(uData["o_pushset"]); pushSetMap != nil && len(*pushSetMap) > 0 {
 		if pushKeyMap := common.ObjToMap((*pushSetMap)[stm.Config.Switch]); pushKeyMap != nil && len(*pushKeyMap) > 0 {
 			if common.Int64All((*pushKeyMap)["i_wxpush"]) == 1 {
@@ -228,9 +238,7 @@ func (stm *WxTmplPush) GetUserPushInfo() map[string]interface{} {
 		}
 		return nil
 	}()
-	if uData != nil {
 
-	}
 	return uData
 }