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)
|
title := fmt.Sprintf("你有到家菜市新订单%d", order.OrderSeq)
|
||||||
content := sb.String()
|
content := sb.String()
|
||||||
// globals.SugarLogger.Debugf("notifyWxNewFakeJdOrder, orderID:%s, content:%s", order.VendorOrderID, content)
|
// 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
|
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)
|
// dao.GetStoresMapList(db, []int{model.VendorIDMTWM}, nil, nil, status, isSync, "", "", globals.Mtwm2Code)
|
||||||
return err
|
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
|
package weixinmsg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -60,6 +61,7 @@ const (
|
|||||||
|
|
||||||
WX_SALE_BILL_TEMPLATE_ID = "eTUuFZMWH7IsVBfcxNMpmaHYaxRkUaD6zG8wSGJDcic"
|
WX_SALE_BILL_TEMPLATE_ID = "eTUuFZMWH7IsVBfcxNMpmaHYaxRkUaD6zG8wSGJDcic"
|
||||||
|
|
||||||
|
WX_NORMAL_STORE_ACT_MSG_TEMPLATE_ID = "eXsfOMvDOKVSht0Q0v4IsDrx3MBlRCVYwYl7Hi2uuuI"
|
||||||
WX_NORMAL_STORE_MSG_TEMPLATE_ID = "EUeIJEz2TLUAn4TU2EffOGYLd3dEaYndD_y6Sw9FcSU"
|
WX_NORMAL_STORE_MSG_TEMPLATE_ID = "EUeIJEz2TLUAn4TU2EffOGYLd3dEaYndD_y6Sw9FcSU"
|
||||||
WX_CHANGE_APPROVED_TEMPLATE_ID = "gIG2olBZtQbjXmp6doNB_dESu60By5xuXYOGxksLv3Y"
|
WX_CHANGE_APPROVED_TEMPLATE_ID = "gIG2olBZtQbjXmp6doNB_dESu60By5xuXYOGxksLv3Y"
|
||||||
WX_CHANGE_REJECTED_TEMPLATE_ID = "OBF4-d5inK95epHcUltpdb1zq9boVp2HESpASVRh1Oo"
|
WX_CHANGE_REJECTED_TEMPLATE_ID = "OBF4-d5inK95epHcUltpdb1zq9boVp2HESpASVRh1Oo"
|
||||||
@@ -604,17 +606,21 @@ func NotifyStoreOpRequestStatus(isAccepted bool, storeID, nameID int, spuName st
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func NotifyStoreMessage(storeID, msgID, msgStatusID int, title, content string) (err error) {
|
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, title, content)
|
globals.SugarLogger.Debugf("NotifyStoreMessage storeID:%d, msgID:%d, title:%s, content:%s", storeID, msgID, msg.Title, msg.Content)
|
||||||
templateID := WX_NORMAL_STORE_MSG_TEMPLATE_ID
|
templateID := ""
|
||||||
fileURL := globals.WxBackstageHost + fmt.Sprintf(WX_TO_SHOW_MSG, msgID, msgStatusID)
|
fileURL := globals.WxBackstageHost + fmt.Sprintf(WX_TO_SHOW_MSG, msgID, msgStatusID)
|
||||||
data := map[string]interface{}{
|
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{}{
|
"first": map[string]interface{}{
|
||||||
"value": content,
|
"value": msg.Content,
|
||||||
"color": "#333333",
|
"color": "#333333",
|
||||||
},
|
},
|
||||||
"keyword1": map[string]interface{}{
|
"keyword1": map[string]interface{}{
|
||||||
"value": title,
|
"value": msg.Title,
|
||||||
"color": "#2E408E",
|
"color": "#2E408E",
|
||||||
},
|
},
|
||||||
"keyword2": map[string]interface{}{
|
"keyword2": map[string]interface{}{
|
||||||
@@ -625,6 +631,32 @@ func NotifyStoreMessage(storeID, msgID, msgStatusID int, title, content string)
|
|||||||
"value": "",
|
"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)
|
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
|
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()
|
db := dao.GetDB()
|
||||||
//权限
|
//权限
|
||||||
if permission.IsRoled(ctx) {
|
if permission.IsRoled(ctx) {
|
||||||
@@ -794,7 +826,8 @@ func SendStoreMessage(ctx *jxcontext.Context, title, content string, storeIDs []
|
|||||||
msg := &model.Message{
|
msg := &model.Message{
|
||||||
Title: title,
|
Title: title,
|
||||||
Content: content,
|
Content: content,
|
||||||
Type: model.MessageTypeStore,
|
Type: int8(messageType),
|
||||||
|
ActInfo: actInfo,
|
||||||
}
|
}
|
||||||
dao.WrapAddIDCULDEntity(msg, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(msg, ctx.GetUserName())
|
||||||
if err = dao.CreateEntity(db, msg); err != nil {
|
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) {
|
rootTask := tasksch.NewParallelTask("SendStoreMessage", nil, ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
msgStatus := batchItemList[0].(*model.MessageStatus)
|
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
|
msgStatus.Status = model.MessageStatusSendAllSuccess
|
||||||
} else {
|
} else {
|
||||||
msgStatus.Status = model.MessageStatusSendAllFailed
|
msgStatus.Status = model.MessageStatusSendAllFailed
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ type MessageStatus struct {
|
|||||||
Status int8 `json:"status"`
|
Status int8 `json:"status"`
|
||||||
ReadCount int `json:"readCount"`
|
ReadCount int `json:"readCount"`
|
||||||
UserID string `orm:"column(user_id)" json:"userID"`
|
UserID string `orm:"column(user_id)" json:"userID"`
|
||||||
|
ConfirmStatus int `json:"confirmStatus"` //商家确认活动,默认0不确认,1确认
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*MessageStatus) TableIndex() [][]string {
|
func (*MessageStatus) TableIndex() [][]string {
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ type MsgController struct {
|
|||||||
// @Param storeIDs formData string true "门店 ID列表"
|
// @Param storeIDs formData string true "门店 ID列表"
|
||||||
// @Param title formData string true "消息标题"
|
// @Param title formData string true "消息标题"
|
||||||
// @Param content 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 isAsync formData bool false "是否异步操作,缺省否"
|
||||||
// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省false"
|
// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省false"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
@@ -32,7 +34,7 @@ func (c *MsgController) SendStoreMessage() {
|
|||||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err != nil {
|
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err != nil {
|
||||||
return retVal, "", err
|
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
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1038,3 +1038,17 @@ func (c *StoreController) GetBrandStore() {
|
|||||||
return retVal, "", err
|
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,
|
Filters: nil,
|
||||||
Params: 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.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "SyncJdStore",
|
Method: "SyncJdStore",
|
||||||
|
|||||||
Reference in New Issue
Block a user