diff --git a/business/partner/im/im.go b/business/partner/im/im.go index 068a0eee3..f02a4ceee 100644 --- a/business/partner/im/im.go +++ b/business/partner/im/im.go @@ -547,6 +547,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) { } else { temp.MsgContent = AutoReplyByAppID[mt.AppID] } + temp.MsgSource = mtwmapi.MsgSourceStore temp.Cts = int(time.Now().Unix()) temp.MsgID = RandTimeNumber() @@ -611,28 +612,18 @@ func GetCustomTemplate(appID, vendorStoreID string) (storeTemplate string) { return storeTemplate } -// AddOrGetCustomReply 增加以及获取门店自定义回复模板 -func AddOrGetCustomReply(appID, vendorStoreID, replyTemplate string, opType int) (storeTemplate string, err error) { - if len(appID) == 0 || len(vendorStoreID) == 0 { +// AddCustomReply 增加门店自定义回复模板 +func AddCustomReply(appID, vendorStoreID, replyTemplate string) (storeTemplate string, err error) { + if len(appID) == 0 || len(vendorStoreID) == 0 || len(replyTemplate) == 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 + err = rdb.Del(key) + if err == nil { + err = rdb.Set(key, replyTemplate, 0) } - return "", nil + return "", err + } diff --git a/controllers/im.go b/controllers/im.go index 4a18eee31..0e9d69c18 100644 --- a/controllers/im.go +++ b/controllers/im.go @@ -145,19 +145,33 @@ func (c *IMController) GetElmMedia() { }) } -// @Title 增加以及获取门店自定义回复模板 -// @Description 增加以及获取门店自定义回复模板 +// @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-获取" +// @Param appID formData string true "应用id" +// @Param vendorStoreID formData string true "美团门店id" +// @Param replyTemplate formData string true "新增或修改自定义模板" // @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.AppID, params.VendorStoreID, params.ReplyTemplate, params.OpType) +// @router /AddCustomReply [post] +func (c *IMController) AddCustomReply() { + c.callAddCustomReply(func(params *tImAddCustomReplyParams) (interface{}, string, error) { + retVal, err := im.AddCustomReply(params.AppID, params.VendorStoreID, params.ReplyTemplate) 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 + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index d688f8cfc..3a41b35c9 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -4544,13 +4544,20 @@ func init() { 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`, + Method: "AddCustomReply", + 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"}, 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",