|
@@ -4139,10 +4139,22 @@ func (this *UserController) UserRemind() {
|
|
|
return
|
|
|
}
|
|
|
userId := req.UserId
|
|
|
+ sourceType := req.SourceType
|
|
|
+ doType := req.DoType
|
|
|
wxUser, err := cygx.GetUserAndCompanyNameList(userId)
|
|
|
if err != nil {
|
|
|
+ br.Msg = "设置互动提醒失败"
|
|
|
br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
- br.Msg = "获取信息失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if sourceType != 1 && sourceType != 2 {
|
|
|
+ br.Msg = "设置互动提醒失败"
|
|
|
+ br.ErrMsg = "设置互动提醒失败,sourceType:" + strconv.Itoa(sourceType)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if doType != 1 && doType != 2 {
|
|
|
+ br.Msg = "设置互动提醒失败"
|
|
|
+ br.ErrMsg = "设置互动提醒失败,doType:" + strconv.Itoa(doType)
|
|
|
return
|
|
|
}
|
|
|
count, err := cygx.GetCygxUserRemindCount(userId)
|
|
@@ -4153,18 +4165,60 @@ func (this *UserController) UserRemind() {
|
|
|
}
|
|
|
resp := new(cygx.CygxUserRemindResp)
|
|
|
if count <= 0 {
|
|
|
- item := new(cygx.CygxUserRemind)
|
|
|
- item.AdminId = sysUser.AdminId
|
|
|
- item.AdminName = sysUser.RealName
|
|
|
- item.UserId = userId
|
|
|
- item.Mobile = wxUser.Mobile
|
|
|
- item.Email = wxUser.Email
|
|
|
- item.CompanyId = wxUser.CompanyId
|
|
|
- item.CompanyName = wxUser.CompanyName
|
|
|
- item.RealName = wxUser.RealName
|
|
|
- item.CreateTime = time.Now()
|
|
|
- item.ModifyTime = time.Now()
|
|
|
- _, err = cygx.AddCygxUserRemind(item)
|
|
|
+ var items []*cygx.CygxUserRemind
|
|
|
+ if sourceType == 1 {
|
|
|
+ item := new(cygx.CygxUserRemind)
|
|
|
+ item.AdminId = sysUser.AdminId
|
|
|
+ item.AdminName = sysUser.RealName
|
|
|
+ item.UserId = userId
|
|
|
+ item.Mobile = wxUser.Mobile
|
|
|
+ item.Email = wxUser.Email
|
|
|
+ item.CompanyId = wxUser.CompanyId
|
|
|
+ item.CompanyName = wxUser.CompanyName
|
|
|
+ item.RealName = wxUser.RealName
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ items = append(items, item)
|
|
|
+ } else {
|
|
|
+ //获取机构下所有的用户
|
|
|
+ listUser, err := models.GetWxUserListCompanyId(wxUser.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "获取数据失败,GetWxUserListCompanyId Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //获取已经添加消息提醒的
|
|
|
+ listUserRemind, err := cygx.GetCygxUserRemindListByCompanyId(wxUser.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "获取数据失败,GetCygxUserRemindListByCompanyId Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapUserRemind := make(map[int]bool)
|
|
|
+ for _, v := range listUserRemind {
|
|
|
+ mapUserRemind[v.UserId] = true
|
|
|
+ }
|
|
|
+ for _, v := range listUser {
|
|
|
+ //如果已经添加了提醒的用户就不做添加处理
|
|
|
+ if mapUserRemind[v.UserId] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ item := new(cygx.CygxUserRemind)
|
|
|
+ item.AdminId = sysUser.AdminId
|
|
|
+ item.AdminName = sysUser.RealName
|
|
|
+ item.UserId = v.UserId
|
|
|
+ item.Mobile = v.Mobile
|
|
|
+ item.Email = v.Email
|
|
|
+ item.CompanyId = v.CompanyId
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.RealName = v.RealName
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ items = append(items, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //批量加入
|
|
|
+ err = cygx.AddCygxUserRemindMulti(items)
|
|
|
if err != nil {
|
|
|
br.Msg = "添加失败"
|
|
|
br.ErrMsg = "添加失败,Err:" + err.Error()
|
|
@@ -4173,7 +4227,12 @@ func (this *UserController) UserRemind() {
|
|
|
br.Msg = "收藏成功"
|
|
|
resp.Status = 1
|
|
|
} else {
|
|
|
- err = cygx.RemoveCygxUserRemind(userId)
|
|
|
+ if sourceType == 1 {
|
|
|
+ err = cygx.RemoveCygxUserRemind(userId) //取消个人提醒
|
|
|
+ } else {
|
|
|
+ err = cygx.RemoveCygxUserRemindByCompanyId(wxUser.CompanyId) //取消整个机构提醒
|
|
|
+ }
|
|
|
+
|
|
|
if err != nil {
|
|
|
br.Msg = "取消失败"
|
|
|
br.ErrMsg = "取消失败,Err:" + err.Error()
|
|
@@ -4186,3 +4245,4 @@ func (this *UserController) UserRemind() {
|
|
|
br.Success = true
|
|
|
br.Data = resp
|
|
|
}
|
|
|
+
|