Browse Source

feat:类目微信模板消息字数截取

wangchuanjin 1 năm trước cách đây
mục cha
commit
59e5f0a24a
1 tập tin đã thay đổi với 9 bổ sung0 xóa
  1. 9 0
      src/jfw/modules/weixin/src/jrpc/jrpc.go

+ 9 - 0
src/jfw/modules/weixin/src/jrpc/jrpc.go

@@ -375,6 +375,15 @@ func (w *WeiXinRpc) GetPrepayId(param map[string]string, res *[]byte) error {
 func (w *WeiXinRpc) SendTmplMsg(param *qrpc.WxTmplMsg, ret *qrpc.RpcResult) error {
 	tmplData := make(weixin.TmplData)
 	for k, v := range param.TmplData {
+		if strings.HasPrefix(k, "thing") {
+			v.Value = util.ShortenTxt(20, "", v.Value)
+		} else if strings.HasPrefix(k, "character_string") {
+			v.Value = util.ShortenTxt(32, "", v.Value)
+		} else if strings.HasPrefix(k, "phone_number") {
+			v.Value = util.ShortenTxt(17, "", v.Value)
+		} else if strings.HasPrefix(k, "car_number") {
+			v.Value = util.ShortenTxt(8, "", v.Value)
+		}
 		tmplData[k] = weixin.TmplItem{
 			Value: v.Value,
 			Color: v.Color,