aa
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package weixinmsg
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
@@ -60,6 +61,7 @@ const (
|
||||
|
||||
WX_SALE_BILL_TEMPLATE_ID = "eTUuFZMWH7IsVBfcxNMpmaHYaxRkUaD6zG8wSGJDcic"
|
||||
|
||||
WX_NORMAL_STORE_ACT_MSG_TEMPLATE_ID = "eXsfOMvDOKVSht0Q0v4IsDrx3MBlRCVYwYl7Hi2uuuI"
|
||||
WX_NORMAL_STORE_MSG_TEMPLATE_ID = "EUeIJEz2TLUAn4TU2EffOGYLd3dEaYndD_y6Sw9FcSU"
|
||||
WX_CHANGE_APPROVED_TEMPLATE_ID = "gIG2olBZtQbjXmp6doNB_dESu60By5xuXYOGxksLv3Y"
|
||||
WX_CHANGE_REJECTED_TEMPLATE_ID = "OBF4-d5inK95epHcUltpdb1zq9boVp2HESpASVRh1Oo"
|
||||
@@ -604,26 +606,56 @@ func NotifyStoreOpRequestStatus(isAccepted bool, storeID, nameID int, spuName st
|
||||
return err
|
||||
}
|
||||
|
||||
func NotifyStoreMessage(storeID, msgID, msgStatusID int, title, content string) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyStoreMessage storeID:%d, msgID:%d, title:%s, content:%s", storeID, msgID, title, content)
|
||||
templateID := WX_NORMAL_STORE_MSG_TEMPLATE_ID
|
||||
func NotifyStoreMessage(storeID, msgID, msgStatusID int, msg *model.Message) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyStoreMessage storeID:%d, msgID:%d, title:%s, content:%s", storeID, msgID, msg.Title, msg.Content)
|
||||
templateID := ""
|
||||
fileURL := globals.WxBackstageHost + fmt.Sprintf(WX_TO_SHOW_MSG, msgID, msgStatusID)
|
||||
data := map[string]interface{}{
|
||||
"first": map[string]interface{}{
|
||||
"value": content,
|
||||
"color": "#333333",
|
||||
},
|
||||
"keyword1": map[string]interface{}{
|
||||
"value": title,
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"keyword2": map[string]interface{}{
|
||||
"value": utils.GetCurTimeStr(),
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"remark": map[string]interface{}{
|
||||
"value": "",
|
||||
},
|
||||
data := make(map[string]interface{})
|
||||
switch msg.Type {
|
||||
case model.MessageTypeStore:
|
||||
templateID = WX_NORMAL_STORE_MSG_TEMPLATE_ID
|
||||
data = map[string]interface{}{
|
||||
"first": map[string]interface{}{
|
||||
"value": msg.Content,
|
||||
"color": "#333333",
|
||||
},
|
||||
"keyword1": map[string]interface{}{
|
||||
"value": msg.Title,
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"keyword2": map[string]interface{}{
|
||||
"value": utils.GetCurTimeStr(),
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"remark": map[string]interface{}{
|
||||
"value": "",
|
||||
},
|
||||
}
|
||||
case model.MessageTypeStoreAct:
|
||||
actMap := make(map[string]interface{})
|
||||
err = json.Unmarshal([]byte(msg.ActInfo), &actMap)
|
||||
templateID = WX_NORMAL_STORE_ACT_MSG_TEMPLATE_ID
|
||||
data = map[string]interface{}{
|
||||
"first": map[string]interface{}{
|
||||
"value": "即将开展[" + msg.Title + "]活动,详情点击",
|
||||
"color": "#333333",
|
||||
},
|
||||
"keyword1": map[string]interface{}{
|
||||
"value": msg.Title,
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"keyword2": map[string]interface{}{
|
||||
"value": actMap["beginAt"].(string) + "-" + actMap["endAt"].(string),
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"keyword3": map[string]interface{}{
|
||||
"value": model.VendorNames[int(utils.MustInterface2Int64(actMap["vendorID"]))],
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"remark": map[string]interface{}{
|
||||
"value": msg.Content,
|
||||
},
|
||||
}
|
||||
}
|
||||
return SendMsgToStore(storeID, templateID, fileURL, fmt.Sprintf(WX_MINI_TO_SHOW_MSG, msgID, msgStatusID), data)
|
||||
}
|
||||
@@ -763,7 +795,7 @@ func NotifyStoreAlertMessage(storeID int, storeName, title, content string) (err
|
||||
return err
|
||||
}
|
||||
|
||||
func SendStoreMessage(ctx *jxcontext.Context, title, content string, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func SendStoreMessage(ctx *jxcontext.Context, title, content string, storeIDs []int, actInfo string, messageType int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
//权限
|
||||
if permission.IsRoled(ctx) {
|
||||
@@ -794,7 +826,8 @@ func SendStoreMessage(ctx *jxcontext.Context, title, content string, storeIDs []
|
||||
msg := &model.Message{
|
||||
Title: title,
|
||||
Content: content,
|
||||
Type: model.MessageTypeStore,
|
||||
Type: int8(messageType),
|
||||
ActInfo: actInfo,
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(msg, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(db, msg); err != nil {
|
||||
@@ -820,7 +853,7 @@ func SendStoreMessage(ctx *jxcontext.Context, title, content string, storeIDs []
|
||||
rootTask := tasksch.NewParallelTask("SendStoreMessage", nil, ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
db := dao.GetDB()
|
||||
msgStatus := batchItemList[0].(*model.MessageStatus)
|
||||
if err = NotifyStoreMessage(msgStatus.StoreID, msgStatus.MessageID, msgStatus.ID, msg.Title, msg.Content); err == nil {
|
||||
if err = NotifyStoreMessage(msgStatus.StoreID, msgStatus.MessageID, msgStatus.ID, msg); err == nil {
|
||||
msgStatus.Status = model.MessageStatusSendAllSuccess
|
||||
} else {
|
||||
msgStatus.Status = model.MessageStatusSendAllFailed
|
||||
|
||||
Reference in New Issue
Block a user