1
This commit is contained in:
@@ -547,6 +547,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
|
|||||||
} else {
|
} else {
|
||||||
temp.MsgContent = AutoReplyByAppID[mt.AppID]
|
temp.MsgContent = AutoReplyByAppID[mt.AppID]
|
||||||
}
|
}
|
||||||
|
temp.MsgSource = mtwmapi.MsgSourceStore
|
||||||
temp.Cts = int(time.Now().Unix())
|
temp.Cts = int(time.Now().Unix())
|
||||||
temp.MsgID = RandTimeNumber()
|
temp.MsgID = RandTimeNumber()
|
||||||
|
|
||||||
@@ -611,28 +612,18 @@ func GetCustomTemplate(appID, vendorStoreID string) (storeTemplate string) {
|
|||||||
return storeTemplate
|
return storeTemplate
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddOrGetCustomReply 增加以及获取门店自定义回复模板
|
// AddCustomReply 增加门店自定义回复模板
|
||||||
func AddOrGetCustomReply(appID, vendorStoreID, replyTemplate string, opType int) (storeTemplate string, err error) {
|
func AddCustomReply(appID, vendorStoreID, replyTemplate string) (storeTemplate string, err error) {
|
||||||
if len(appID) == 0 || len(vendorStoreID) == 0 {
|
if len(appID) == 0 || len(vendorStoreID) == 0 || len(replyTemplate) == 0 {
|
||||||
return "", errors.New("参数错误请检查!")
|
return "", errors.New("参数错误请检查!")
|
||||||
}
|
}
|
||||||
|
|
||||||
key := GenCustomReplyID(appID, vendorStoreID)
|
key := GenCustomReplyID(appID, vendorStoreID)
|
||||||
|
|
||||||
switch opType {
|
err = rdb.Del(key)
|
||||||
case OpTypeAdd: //新增或修改
|
if err == nil {
|
||||||
if len(replyTemplate) == 0 {
|
err = rdb.Set(key, 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
|
return "", err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,19 +145,33 @@ func (c *IMController) GetElmMedia() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title 增加以及获取门店自定义回复模板
|
// @Title 增加门店自定义回复模板
|
||||||
// @Description 增加以及获取门店自定义回复模板
|
// @Description 增加门店自定义回复模板
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param appID query string true "京西门店id"
|
// @Param appID formData string true "应用id"
|
||||||
// @Param vendorStoreID query string true "美团门店id"
|
// @Param vendorStoreID formData string true "美团门店id"
|
||||||
// @Param replyTemplate query string true "新增或修改自定义模板"
|
// @Param replyTemplate formData string true "新增或修改自定义模板"
|
||||||
// @Param opType query int true "操作 1-新增 2-获取"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /AddOrGetCustomReply [get]
|
// @router /AddCustomReply [post]
|
||||||
func (c *IMController) AddOrGetCustomReply() {
|
func (c *IMController) AddCustomReply() {
|
||||||
c.callAddOrGetCustomReply(func(params *tImAddOrGetCustomReplyParams) (interface{}, string, error) {
|
c.callAddCustomReply(func(params *tImAddCustomReplyParams) (interface{}, string, error) {
|
||||||
retVal, err := im.AddOrGetCustomReply(params.AppID, params.VendorStoreID, params.ReplyTemplate, params.OpType)
|
retVal, err := im.AddCustomReply(params.AppID, params.VendorStoreID, params.ReplyTemplate)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 获取门店自定义回复模板
|
||||||
|
// @Description 获取门店自定义回复模板
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param appID query string true "应用id"
|
||||||
|
// @Param vendorStoreID query string true "美团门店id"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetCustomReply [get]
|
||||||
|
func (c *IMController) GetCustomReply() {
|
||||||
|
c.callGetCustomReply(func(params *tImGetCustomReplyParams) (interface{}, string, error) {
|
||||||
|
retVal := im.GetCustomTemplate(params.AppID, params.VendorStoreID)
|
||||||
|
return retVal, "", nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -4544,13 +4544,20 @@ func init() {
|
|||||||
Params: 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.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"],
|
||||||
web.ControllerComments{
|
web.ControllerComments{
|
||||||
Method: "AddOrGetCustomReply",
|
Method: "AddCustomReply",
|
||||||
Router: `/AddOrGetCustomReply`,
|
Router: `/AddCustomReply`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
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: "GetCustomReply",
|
||||||
|
Router: `/GetCustomReply`,
|
||||||
AllowHTTPMethods: []string{"get"},
|
AllowHTTPMethods: []string{"get"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: 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.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FnController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FnController"],
|
||||||
// web.ControllerComments{
|
// web.ControllerComments{
|
||||||
// Method: "FnStore",
|
// Method: "FnStore",
|
||||||
|
|||||||
Reference in New Issue
Block a user