1
This commit is contained in:
@@ -798,7 +798,7 @@ func CreateActForMtByOrder(ctx *jxcontext.Context, act *model.Act, vendorIDs []i
|
||||
var (
|
||||
actStoreSkuMapUpdate *model.ActStoreSkuMap
|
||||
)
|
||||
sql := `
|
||||
sql := `weix
|
||||
SELECT * FROM act_store_sku_map WHERE act_id = ? AND store_id = ? AND sku_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{act.ID, storeID, utils.Str2Int(v.AppFoodCode)}
|
||||
|
||||
@@ -363,19 +363,6 @@ func GenMsgListID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string) {
|
||||
return msgID
|
||||
}
|
||||
|
||||
// GenIsAutoApplyID 生成获取消息自动回复状态
|
||||
func GenIsAutoApplyID(jxMsg *JXMsg, vendorID int) (msgID string) {
|
||||
if vendorID == VendorIDMT {
|
||||
var d1 = jxMsg.MsgContent.(mtwmapi.PushContentReq)
|
||||
msgID = utils.Int2Str(d1.AppID) + ":" + utils.Int2Str(d1.OpenUserID) + ":" + utils.Int2Str(d1.MsgID)
|
||||
}
|
||||
if vendorID == VendorIDELM {
|
||||
var d2 = jxMsg.MsgContent.(ebaiapi.ImMessageSend)
|
||||
msgID = d2.PayLoad.MsgID + ":" + d2.PayLoad.SenderID
|
||||
}
|
||||
return msgID
|
||||
}
|
||||
|
||||
// GetImUserList 获取门店用户聊天列表
|
||||
func GetImUserList(req []RelInfo) (map[string][]interface{}, error) {
|
||||
retVal := make(map[string][]interface{}, 0)
|
||||
@@ -528,7 +515,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
|
||||
if req.SendType == SendTypeMt {
|
||||
mt := req.MsgContent.(mtwmapi.PushContentReq)
|
||||
key := utils.Int2Str(mt.AppID) + ":" + utils.Int2Str(mt.OpenUserID) + ":autoReply"
|
||||
//1 检测是否已有回复消息
|
||||
//1 检测是否已自动回复
|
||||
if n, err := rdb.Exists(key); n > 0 && err == nil {
|
||||
str := rdb.LRange(key)
|
||||
for i := 0; i < len(str); i++ {
|
||||
@@ -549,7 +536,12 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
|
||||
}
|
||||
|
||||
temp := mt
|
||||
temp.MsgContent = AutoReplyByAppID[mt.AppID]
|
||||
//获取自定义回复模板
|
||||
if template := GetCustomTemplate(utils.Int2Str(mt.AppID), mt.AppPoiCode); len(template) != 0 {
|
||||
temp.MsgContent = template
|
||||
} else {
|
||||
temp.MsgContent = AutoReplyByAppID[mt.AppID]
|
||||
}
|
||||
temp.Cts = int(time.Now().Unix())
|
||||
temp.MsgID = RandTimeNumber()
|
||||
|
||||
@@ -575,3 +567,44 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
|
||||
//}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GenCustomReplyID 生成门店自动回复模板ID
|
||||
func GenCustomReplyID(appID, vendorStoreID string) string {
|
||||
return BaseCusKey + ":" + appID + ":" + vendorStoreID
|
||||
}
|
||||
|
||||
// GetCustomTemplate 获取自动回复模板
|
||||
func GetCustomTemplate(appID, vendorStoreID string) (storeTemplate string) {
|
||||
key := GenCustomReplyID(appID, vendorStoreID)
|
||||
temp := rdb.Get(key)
|
||||
if temp != nil {
|
||||
storeTemplate = temp.(string)
|
||||
}
|
||||
return storeTemplate
|
||||
}
|
||||
|
||||
// AddOrGetCustomReply 增加以及获取门店自定义回复模板
|
||||
func AddOrGetCustomReply(appID, vendorStoreID, replyTemplate string, opType int) (storeTemplate string, err error) {
|
||||
if len(appID) == 0 || len(vendorStoreID) == 0 {
|
||||
return "", errors.New("参数错误请检查!")
|
||||
}
|
||||
|
||||
key := GenCustomReplyID(appID, vendorStoreID)
|
||||
|
||||
switch opType {
|
||||
case OpTypeAdd: //新增或修改
|
||||
if len(replyTemplate) == 0 {
|
||||
return "", errors.New("新增或修改门店自定义回复模板,不允许为空")
|
||||
}
|
||||
err = rdb.Del(key)
|
||||
if err == nil {
|
||||
err = rdb.Set(key, replyTemplate, 0)
|
||||
}
|
||||
return "", err
|
||||
|
||||
case OpTypeGet:
|
||||
storeTemplate = GetCustomTemplate(appID, vendorStoreID)
|
||||
return storeTemplate, nil
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
@@ -54,7 +54,9 @@ var (
|
||||
SendTypeJx = "jx" //京西客户端发送方标识
|
||||
SendTypeMt = "mt" //美团用户发送方标识符
|
||||
SendTypeElm = "elm" //饿了么用户发送方标识符
|
||||
|
||||
OpTypeAdd = 1 //门店新增或修改自定义回复模板
|
||||
OpTypeGet = 2 //门店获取
|
||||
BaseCusKey = "customReply"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -144,3 +144,20 @@ func (c *IMController) GetElmMedia() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 增加以及获取门店自定义回复模板
|
||||
// @Description 增加以及获取门店自定义回复模板
|
||||
// @Param token header string true "认证token"
|
||||
// @Param appID query string true "京西门店id"
|
||||
// @Param vendorStoreID query string true "美团门店id"
|
||||
// @Param replyTemplate query string true "新增或修改自定义模板"
|
||||
// @Param opType query int true "操作 1-新增 2-获取"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /AddOrGetCustomReply [get]
|
||||
func (c *IMController) AddOrGetCustomReply() {
|
||||
c.callAddOrGetCustomReply(func(params *tImAddOrGetCustomReplyParams) (interface{}, string, error) {
|
||||
retVal, err := im.AddOrGetCustomReply(params.StoreID, params.VendorStoreID, params.ReplyTemplate, params.OpType)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4542,6 +4542,15 @@ func init() {
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"],
|
||||
web.ControllerComments{
|
||||
Method: "AddOrGetCustomReply",
|
||||
Router: `/AddOrGetCustomReply`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
//web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FnController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FnController"],
|
||||
// web.ControllerComments{
|
||||
// Method: "FnStore",
|
||||
|
||||
Reference in New Issue
Block a user