aa
This commit is contained in:
@@ -69,6 +69,6 @@ func notifyWxNewFakeJdOrder(order *model.GoodsOrder, storeID int) (err error) {
|
||||
title := fmt.Sprintf("你有到家菜市新订单%d", order.OrderSeq)
|
||||
content := sb.String()
|
||||
// globals.SugarLogger.Debugf("notifyWxNewFakeJdOrder, orderID:%s, content:%s", order.VendorOrderID, content)
|
||||
_, err = weixinmsg.SendStoreMessage(jxcontext.AdminCtx, title, content, []int{storeID}, true, true)
|
||||
_, err = weixinmsg.SendStoreMessage(jxcontext.AdminCtx, title, content, []int{storeID}, "", model.MessageTypeStore, true, true)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3992,3 +3992,17 @@ func RefreshMTWMToken(ctx *jxcontext.Context) (err error) {
|
||||
// dao.GetStoresMapList(db, []int{model.VendorIDMTWM}, nil, nil, status, isSync, "", "", globals.Mtwm2Code)
|
||||
return err
|
||||
}
|
||||
|
||||
func StoreConfirmAct(ctx *jxcontext.Context, msgStatusID int) (err error) {
|
||||
msgStatus := &model.MessageStatus{}
|
||||
msgStatus.ID = msgStatusID
|
||||
db := dao.GetDB()
|
||||
if err = dao.GetEntity(db, msgStatus); err != nil {
|
||||
return err
|
||||
}
|
||||
msgStatus.ReadCount++
|
||||
msgStatus.ConfirmStatus = model.YES
|
||||
dao.WrapUpdateULEntity(msgStatus, ctx.GetUserName())
|
||||
_, err = dao.UpdateEntity(db, msgStatus, "ReadCount", "ConfirmStatus")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -49,11 +49,12 @@ type MessageActInfo struct {
|
||||
|
||||
type MessageStatus struct {
|
||||
ModelIDCULD
|
||||
MessageID int `orm:"column(message_id)" json:"messageID"`
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
Status int8 `json:"status"`
|
||||
ReadCount int `json:"readCount"`
|
||||
UserID string `orm:"column(user_id)" json:"userID"`
|
||||
MessageID int `orm:"column(message_id)" json:"messageID"`
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
Status int8 `json:"status"`
|
||||
ReadCount int `json:"readCount"`
|
||||
UserID string `orm:"column(user_id)" json:"userID"`
|
||||
ConfirmStatus int `json:"confirmStatus"` //商家确认活动,默认0不确认,1确认
|
||||
}
|
||||
|
||||
func (*MessageStatus) TableIndex() [][]string {
|
||||
|
||||
@@ -21,6 +21,8 @@ type MsgController struct {
|
||||
// @Param storeIDs formData string true "门店 ID列表"
|
||||
// @Param title formData string true "消息标题"
|
||||
// @Param content formData string true "消息内容"
|
||||
// @Param messageType formData int true "消息类型,1为普通给商家发的消息,3为活动内容通知"
|
||||
// @Param actInfo formData string true "如果是活动内容通知需传"
|
||||
// @Param isAsync formData bool false "是否异步操作,缺省否"
|
||||
// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -32,7 +34,7 @@ func (c *MsgController) SendStoreMessage() {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = weixinmsg.SendStoreMessage(params.Ctx, params.Title, params.Content, storeIDs, params.IsAsync, params.IsContinueWhenError)
|
||||
retVal, err = weixinmsg.SendStoreMessage(params.Ctx, params.Title, params.Content, storeIDs, params.ActInfo, params.MessageType, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1038,3 +1038,17 @@ func (c *StoreController) GetBrandStore() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 商家确认参与活动
|
||||
// @Description 商家确认参与活动
|
||||
// @Param token header string false "认证token"
|
||||
// @Param msgStatusID formData int true "消息状态ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /StoreConfirmAct [post]
|
||||
func (c *StoreController) StoreConfirmAct() {
|
||||
c.callStoreConfirmAct(func(params *tStoreStoreConfirmActParams) (retVal interface{}, errCode string, err error) {
|
||||
err = cms.StoreConfirmAct(params.Ctx, params.MsgStatusID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2304,6 +2304,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "StoreConfirmAct",
|
||||
Router: `/StoreConfirmAct`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "SyncJdStore",
|
||||
|
||||
Reference in New Issue
Block a user