Browse Source

Merge branch 'cygx_10.12.1' of http://8.136.199.33:3000/hongze/hz_crm_api

xingzai 1 year ago
parent
commit
65a4455535

+ 4 - 0
controllers/company.go

@@ -359,6 +359,10 @@ func (this *CompanyController) SearchList() {
 			//根据销售"领取客户"的权限对部分按钮做限制
 			btnItem = services.GetCompanyPermissionButtonByReceiveEnabled(btnItem, receiveEnabled)
 		}
+		//如果是权益客户,操作者又是权益管理员,那么就对他进行展示研选详情按钮
+		if strings.Contains(item.CompanyType, utils.COMPANY_CLASSIFY_RAI) && sysUser.RoleName == utils.ROLE_TYPE_RAI_PRODUCT {
+			btnItem.IsResearchShow = true
+		}
 		list[i].BtnItem = btnItem
 	}
 	if list == nil {

+ 74 - 14
controllers/cygx/user.go

@@ -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
 }
+

+ 1 - 0
models/company/company.go

@@ -1202,6 +1202,7 @@ type ButtonPermission struct {
 	BtnServiceRecord bool `description:"查看服务记录按钮:true显示,false不显示"`
 	BtnClose         bool `description:"关闭客户按钮:true显示,false不显示"`
 	BtnLoss          bool `description:"转流失按钮:true显示,false不显示"`
+	IsResearchShow   bool `description:"研选详情展示控制:true显示,false不显示"`
 }
 
 type ButtonSearchPermission struct {

+ 4 - 2
models/cygx/cygx_user.go

@@ -197,8 +197,10 @@ type UserRemarksResp struct {
 }
 
 type UserRemarAddReq struct {
-	UserId  int    `description:"用户ID"`
-	Content string `description:"备注信息"`
+	UserId     int    `description:"用户ID"`
+	Content    string `description:"备注信息"`
+	SourceType int    `description:"操作类型,1:对联系人单独设置,2:对机构批量设置"`
+	DoType     int    `description:"操作方式,1:添加,2:取消"`
 }
 
 // 添加UserRemarks

+ 52 - 1
models/cygx/user_remind.go

@@ -19,13 +19,33 @@ type CygxUserRemind struct {
 	AdminName   string `description:"管理员销售姓名"`
 }
 
-//添加
+// 添加
 func AddCygxUserRemind(item *CygxUserRemind) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
+// AddCygxUserRemindMulti 批量添加
+func AddCygxUserRemindMulti(items []*CygxUserRemind) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	if len(items) > 0 {
+		//批量添加流水信息
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
 type CygxUserRemindResp struct {
 	Status int `description:"1:添加,2:取消"`
 }
@@ -37,8 +57,39 @@ func RemoveCygxUserRemind(userId int) (err error) {
 	return
 }
 
+func RemoveCygxUserRemindByCompanyId(companyId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_user_remind WHERE company_id = ? `
+	_, err = o.Raw(sql, companyId).Exec()
+	return
+}
+
 func GetCygxUserRemindCount(userId int) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM cygx_user_remind WHERE user_id=? `
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
 	return
 }
+
+// 列表
+func GetCygxUserRemindList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxUserRemind, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_remind as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	if startSize+startSize > 0 {
+		sql += ` LIMIT ?,?  `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		_, err = o.Raw(sql, pars).QueryRows(&items)
+	}
+	return
+}
+
+// 根据公司ID获取列表
+func GetCygxUserRemindListByCompanyId(companyId int) (items []*CygxUserRemind, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_remind  WHERE 1= 1  AND company_id = ? `
+	_, err = o.Raw(sql, companyId).QueryRows(&items)
+	return
+}

+ 8 - 0
models/wx_user.go

@@ -514,3 +514,11 @@ func GetWxUserListByUserMobileHaveCompany(mobiles []string) (list []*WxUserItem,
 	_, err = o.Raw(sql, mobiles).QueryRows(&list)
 	return
 }
+
+// GetWxUserListCompanyId 根据公司ID获取所有用户信息
+func GetWxUserListCompanyId(companyId int) (list []*WxUserItem, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT* FROM wx_user  WHERE company_id = ?   `
+	_, err = o.Raw(sql, companyId).QueryRows(&list)
+	return
+}

+ 1 - 0
utils/constants.go

@@ -113,6 +113,7 @@ const (
 	ROLE_TYPE_FICC_SELLER = "ficc销售"
 	ROLE_TYPE_RAI_ADMIN   = "权益管理员"
 	ROLE_TYPE_RAI_SELLER  = "权益销售"
+	ROLE_TYPE_RAI_PRODUCT = "权益产品"
 
 	ROLE_TYPE_FICC_GROUP      = "ficc销售组长"
 	ROLE_TYPE_FICC_MANAGER    = "ficc销售主管"