变更运营时,发送钉钉消息

This commit is contained in:
gazebo
2019-11-05 18:50:48 +08:00
parent 5512efaaf5
commit c2393c17be

View File

@@ -30,6 +30,7 @@ import (
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
)
const (
@@ -758,6 +759,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
}
} else {
dao.Commit(db)
notifyStoreOperatorChanged(store, valid["operatorPhone"])
}
}
} else {
@@ -766,6 +768,21 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
return num, err
}
func notifyStoreOperatorChanged(store *model.Store, newOperator2 interface{}) {
if store.OperatorPhone != "" && newOperator2 != nil {
db := dao.GetDB()
if user, err := dao.GetUserByID(db, "mobile", store.OperatorPhone); err == nil {
curUserName := ""
if newOperator := utils.Interface2String(newOperator2); newOperator != "" {
if curUser, err := dao.GetUserByID(db, "mobile", store.OperatorPhone); err == nil {
curUserName = curUser.GetName()
}
}
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.GetID(), "门店运营变更", fmt.Sprintf("门店:%d-%s,原运营:%s,变更为:%s", store.ID, store.Name, user.GetName(), curUserName))
}
}
}
func SetStoreStatus(ctx *jxcontext.Context, storeID, status int) (err error) {
payload := map[string]interface{}{
"status": status,