فهرست منبع

feat:自定义模板消息

wangchuanjin 1 سال پیش
والد
کامیت
7e3370c711
3فایلهای تغییر یافته به همراه19 افزوده شده و 5 حذف شده
  1. 3 2
      resourceBrushLibrary/config.json
  2. 1 0
      resourceBrushLibrary/config/config.go
  3. 15 3
      resourceBrushLibrary/entity/adp.go

+ 3 - 2
resourceBrushLibrary/config.json

@@ -32,7 +32,7 @@
   },
   "resourceEtcdConf": {
     "hosts": [
-      "127.0.0.1:2379"
+      "192.168.3.206:2379"
     ],
     "resourcesKey": "resourcescenter.rpc"
   },
@@ -46,7 +46,7 @@
   "checkPointExpirePool":5,
   "messages":{
 	"taskExpire":{
-		"expireDay":2,
+		"expireDay":3,
 		"title":"做任务赚好礼挑战即将过期",
 		"content":"请及时完成任务并领取超级订阅7天体验,获取更多采购商机!",
 		"msgType":1,
@@ -55,6 +55,7 @@
 		"mobileUrl":"/jy_mobile/points/earn"
 	},
 	"adpExpire":{
+		"wxTplId":"lnvey70BWSiqY-h6tDRxw3Ez_3fExFkIRoWRTijp5zs",
 		"expireDay":2,
 		"title":"您兑换的附件下载权益将于%d天内失效",
 		"content":"尊敬的用户,您有%d个兑换的附件下载权益将于%d天内失效,戳我使用",

+ 1 - 0
resourceBrushLibrary/config/config.go

@@ -25,6 +25,7 @@ var (
 )
 
 type MsgConf struct {
+	WxTplId     string
 	ExpireDay   int
 	Title       string
 	Content     string

+ 15 - 3
resourceBrushLibrary/entity/adp.go

@@ -26,6 +26,7 @@ func (a *Adp) Run() {
 		now := time.Now()
 		nowStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
 		end := nowStart.AddDate(0, 0, Config.Messages.AdpExpire.ExpireDay-1)
+		endTime := date.FormatDate(&end, date.Date_Full_Layout)
 		all := map[string]int{}
 		lock := &sync.Mutex{}
 		Tidb.SelectByBath(1, func(l *[]map[string]interface{}) bool {
@@ -49,7 +50,7 @@ func (a *Adp) Run() {
 				lock.Unlock()
 			}(util.ObjToString((*l)[0]["accountId"]), util.IntAll((*l)[0]["sourceType"]), util.IntAll((*l)[0]["number"]))
 			return true
-		}, `select accountId,sourceType,number from jy_user_center.account_resources where name='附件下载包' and endTime=?`, date.FormatDate(&end, date.Date_Full_Layout))
+		}, `select accountId,sourceType,number from jy_user_center.account_resources where name='附件下载包' and endTime=?`, endTime)
 		wait.Wait()
 		for k, v := range all {
 			pool <- true
@@ -71,16 +72,27 @@ func (a *Adp) Run() {
 				}
 				wxUrl := "/front/sess/" + Se.EncodeString(accountId+","+util.If(IsObjectIdHex(accountId), "_id", "positionId").(string)+","+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(Config.Messages.AdpExpire.MobileUrl)
 				appUrl := "/jyapp/free/sess/" + Se.EncodeString(accountId+","+util.If(IsObjectIdHex(accountId), "_id", "positionId").(string)+","+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(Config.Messages.AdpExpire.MobileUrl)
+				title := fmt.Sprintf(Config.Messages.AdpExpire.Title, Config.Messages.AdpExpire.ExpireDay)
+				content := fmt.Sprintf(Config.Messages.AdpExpire.Content, Config.Messages.AdpExpire.ExpireDay, number)
 				SendMsg(&message.MultipleSaveMsgReq{
 					UserIds:    mgoUserId,
-					Title:      fmt.Sprintf(Config.Messages.AdpExpire.Title, Config.Messages.AdpExpire.ExpireDay),
-					Content:    fmt.Sprintf(Config.Messages.AdpExpire.Content, Config.Messages.AdpExpire.ExpireDay, number),
+					Title:      title,
+					Content:    content,
 					MsgType:    Config.Messages.AdpExpire.MsgType,
 					Link:       Config.Messages.AdpExpire.PcUrl + "," + Config.Messages.AdpExpire.MobileUrl + "," + Config.Messages.AdpExpire.MobileUrl,
 					Appid:      Config.Messages.AdpExpire.Appid,
 					AppPushUrl: appUrl,
 					WxPushUrl:  Config.Webdomain + wxUrl,
 					IosPushUrl: appUrl,
+					CustomWxTpl: &message.CustomWxTpl{
+						TplId: Config.Messages.AdpExpire.WxTplId,
+						TmplData: map[string]*message.TmplItem{
+							"thing15": &message.TmplItem{Value: title},
+							"thing6":  &message.TmplItem{Value: content},
+							"time12":  &message.TmplItem{Value: endTime},
+							"thing11": &message.TmplItem{Value: "兑换权益即将到期,请尽快使用。"},
+						},
+					},
 				})
 			}(k, v)
 		}