소스 검색

用户管理,用户批量导入

xyxie 4 달 전
부모
커밋
78e4264d56
9개의 변경된 파일1337개의 추가작업 그리고 0개의 파일을 삭제
  1. 1067 0
      controllers/eta_business/user.go
  2. 1 0
      go.mod
  3. 2 0
      go.sum
  4. 1 0
      models/db.go
  5. 21 0
      models/eta_business/eta_business.go
  6. 174 0
      models/user.go
  7. 54 0
      routers/commentsRouter.go
  8. 1 0
      routers/router.go
  9. 16 0
      services/eta_business/user.go

+ 1067 - 0
controllers/eta_business/user.go

@@ -0,0 +1,1067 @@
+package eta_business
+
+import (
+	"encoding/json"
+	"eta/eta_forum_admin/controllers"
+	"eta/eta_forum_admin/models"
+	"eta/eta_forum_admin/models/eta_business"
+	eta_business2 "eta/eta_forum_admin/services/eta_business"
+	"eta/eta_forum_admin/utils"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"github.com/tealeg/xlsx"
+	"os"
+	"strings"
+	"time"
+)
+
+// 客户联系人管理
+type EtaBusinessUserController struct {
+	controllers.BaseAuthController
+}
+
+// List
+// @Title 联系人列表
+// @Description 联系人列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   CompanyId   query   int  true       "公司id,必填"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   ProductType   query   int  true       "产品类型"
+// @Param   ProductId   query   int  true       "产品id"
+// @Param   IsSubscribe   query   int  true       "是否关注了公众号: -1-默认全部; 0-未关注; 1-已关注"
+// @Param   IsSubscribeHzyj   query   int  true       "是否关注了弘则研究公众号: -1-默认全部; 0-未关注; 1-已关注"
+// @Param   IsSubscribeCygx   query   int  true       "是否关注了查研观向小助手公众号: -1-默认全部; 0-未关注; 1-已关注"
+// @Success 200 {object} company.CompanyUserListResp
+// @router /user/list [get]
+func (this *EtaBusinessUserController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	positionStatus, _ := this.GetInt("PositionStatus", -1)
+	enabled, _ := this.GetInt("Enabled", -1)
+	businessCode := this.GetString("BusinessCode")
+	keyword := utils.TrimStr(this.GetString("Keyword"))
+
+	/*if businessCode <= 0 {
+		br.Msg = "请选择客户"
+		br.ErrMsg = "客户参数错误"
+		return
+	}*/
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if keyword != "" {
+		condition += ` AND (real_name LIKE '%` + keyword + `%' OR mobile LIKE '%` + keyword + `%' OR email LIKE '%` + keyword + `%') `
+	}
+
+	if businessCode != "" {
+		condition += ` AND business_code = ? `
+		pars = append(pars, businessCode)
+	}
+
+	if positionStatus > 0 {
+		condition += ` AND position_status = ? `
+		pars = append(pars, positionStatus)
+	}
+
+	if enabled > 0 { // 0-禁用 1-启用
+		condition += ` AND enabled = ? `
+		pars = append(pars, enabled)
+	}
+
+	total, err := models.GetUserCountByCondition(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
+		return
+	}
+
+	list, err := models.GetUserPageListByCondition(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.UserListResp)
+	userList := make([]*models.BusinessUser, 0)
+	if len(list) == 0 {
+		resp.List = userList
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	// 查找商户信息
+	businessCodeStr := make([]string, 0)
+	businessCodeMap := make(map[string]string)
+	for _, v := range list {
+		if _, ok := businessCodeMap[v.BusinessCode]; ok {
+			continue
+		}
+		businessCodeStr = append(businessCodeStr, v.BusinessCode)
+	}
+	obj := new(eta_business.EtaBusiness)
+	condition1 := " AND business_code IN (" + utils.GetOrmInReplace(len(businessCodeStr)) + ") "
+	var pars1 []interface{}
+	pars1 = append(pars1, businessCodeStr)
+	businessList, err := obj.GetItemsByCondition(condition1, pars1, []string{"business_code", "business_name"}, "")
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取商户信息失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range businessList {
+		businessCodeMap[v.BusinessCode] = v.BusinessName
+	}
+
+	for _, v := range list {
+		tmp := new(models.BusinessUser)
+		if businessName, ok := businessCodeMap[v.BusinessCode]; ok {
+			tmp.BusinessName = businessName
+		}
+		tmp.BusinessCode = v.BusinessCode
+		tmp.UserId = v.UserId
+		tmp.RealName = v.RealName
+		tmp.Mobile = v.Mobile
+		tmp.Email = v.Email
+		tmp.Enabled = v.Enabled
+		tmp.PositionStatus = v.PositionStatus
+		tmp.Position = v.Position
+		tmp.DepartmentName = v.DepartmentName
+		tmp.LastLoginTime = v.LastLoginTime
+		tmp.CreatedTime = v.CreatedTime.Format(utils.FormatDateTime)
+		tmp.LastUpdatedTime = v.LastUpdatedTime.Format(utils.FormatDateTime)
+		userList = append(userList, tmp)
+	}
+	resp.List = userList
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 新增客户联系人
+// @Description 新增客户联系人接口
+// @Param	request	body company.AddUserReq true "type json string"
+// @router /user/add [post]
+func (this *EtaBusinessUserController) AddUser() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.AddUserReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.RealName == "" {
+		br.Msg = "请填写姓名"
+		br.IsSendEmail = false
+		return
+	}
+
+	if req.Mobile == "" {
+		br.Msg = "请输入手机号"
+		br.IsSendEmail = false
+		return
+	}
+
+	if req.BusinessCode == "" {
+		br.Msg = "请选择客户"
+		br.IsSendEmail = false
+		return
+	}
+
+	if req.CountryCode == "" {
+		req.CountryCode = "86"
+	}
+
+	//空格移除
+	req.Mobile = utils.TrimStr(req.Mobile)
+	req.RealName = utils.TrimStr(req.RealName)
+	//判断该手机号、邮箱是否已经添加,如果已经添加,那么就不再添加
+	var key string
+	if req.Mobile != "" {
+		key = fmt.Sprintf("user:mobile:%s_%s", req.CountryCode, req.Mobile)
+	}
+	isHas := utils.Rc.IsExist(key)
+	if isHas == true {
+		br.Msg = "重复添加"
+		return
+	} else {
+		//设置3分钟缓存,不允许重复添加
+		utils.Rc.SetNX(key, 1, time.Second*300)
+
+		//添加完成删除对应的缓存
+		defer utils.Rc.Delete(key)
+	}
+
+	businessObj := new(eta_business.EtaBusiness)
+
+	businessInfo, err := businessObj.GetItemByBusinessCode(req.BusinessCode)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "商户不存在"
+			return
+		}
+		br.Msg = "客户信息有误"
+		br.ErrMsg = "获取客户信息失败, Err: " + err.Error()
+		return
+	}
+	//操作权限校验
+	ok := eta_business2.CheckBusinessUserButton(sysUser.RoleTypeCode, businessInfo.SellerId, sysUser.AdminId)
+	if !ok {
+		br.Msg = "没有操作权限"
+		br.ErrMsg = "没有操作权限"
+		return
+	}
+	//systemUser models.Company.CompanyUser
+	//var sysemUser company.CompanyUser
+	//校验主手机号
+	mobileItem, err := models.GetUserByMobileCountryCode(req.Mobile, req.CountryCode)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "校验手机号有误"
+		br.ErrMsg = "校验手机号有误, Err: " + err.Error()
+		return
+	}
+	if err == nil && mobileItem.UserId > 0 {
+		br.Msg = "手机号已存在"
+		br.Success = true
+		br.Data = mobileItem
+		br.IsSendEmail = false
+		br.Ret = 600
+		return
+	}
+	err = nil
+
+	user := new(models.User)
+	user.RealName = utils.TrimStr(req.RealName)
+	user.CountryCode = utils.TrimStr(req.CountryCode)
+	user.Mobile = utils.TrimStr(req.Mobile)
+	user.Position = req.Position
+	user.PositionStatus = req.PositionStatus
+	user.Enabled = 1
+	user.BusinessCode = req.BusinessCode
+	user.DepartmentName = req.DepartmentName
+	user.CreatedTime = time.Now()
+	user.RegisterTime = time.Now()
+
+	newId, err := models.AddUser(user)
+	user.UserId = int(newId)
+	if err != nil {
+		br.Msg = "新增失败"
+		br.ErrMsg = "新增失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "新增成功"
+	br.Data = newId
+	br.IsAddLog = true
+}
+
+// @Title 删除客户联系人
+// @Description 删除客户联系人接口
+// @Param	request	body company.DeleteUserReq true "type json string"
+// @router /user/delete [post]
+func (this *EtaBusinessUserController) DeleteUser() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.DeleteUserReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.UserId <= 0 {
+		br.Msg = "参数错误!"
+		return
+	}
+
+	//获取联系人详情
+	userInfo, err := models.GetUserByUserId(req.UserId)
+	if err != nil {
+		br.Msg = "获取联系人异常!"
+		br.ErrMsg = "获取联系人异常,Err:" + err.Error()
+		return
+	}
+	// 查询商户关联的销售信息
+	businessObj := new(eta_business.EtaBusiness)
+
+	businessInfo, err := businessObj.GetItemByBusinessCode(userInfo.BusinessCode)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "商户不存在"
+			return
+		}
+		br.Msg = "客户信息有误"
+		br.ErrMsg = "获取客户信息失败, Err: " + err.Error()
+		return
+	}
+	//操作权限校验
+	ok := eta_business2.CheckBusinessUserButton(sysUser.RoleTypeCode, businessInfo.SellerId, sysUser.AdminId)
+	if !ok {
+		br.Msg = "删除失败,没有权限"
+		br.ErrMsg = "删除失败,没有权限"
+		return
+	}
+
+	err = models.DeleteUser(req.UserId)
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "删除成功"
+	br.IsAddLog = true
+}
+
+// @Title 编辑客户联系人
+// @Description 编辑客户联系人接口
+// @Param	request	body company.EditUserReq true "type json string"
+// @router /user/edit [post]
+func (this *EtaBusinessUserController) EditUser() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.EditUserReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.UserId <= 0 {
+		br.Msg = "参数错误!"
+		return
+	}
+
+	//移除空格
+	req.Mobile = utils.TrimStr(req.Mobile)
+	req.RealName = utils.TrimStr(req.RealName)
+
+	if req.RealName == "" {
+		br.Msg = "请填写姓名"
+		br.IsSendEmail = false
+		return
+	}
+
+	if req.Mobile == "" {
+		br.Msg = "请输入手机号"
+		br.IsSendEmail = false
+		return
+	}
+
+	if req.BusinessCode == "" {
+		br.Msg = "请选择客户"
+		br.IsSendEmail = false
+		return
+	}
+
+	if req.CountryCode == "" {
+		req.CountryCode = "86"
+	}
+
+	//操作权限校验
+	userInfo, err := models.GetUserByUserId(req.UserId)
+	if err != nil {
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		br.Msg = "获取信息失败"
+		return
+	}
+
+	businessObj := new(eta_business.EtaBusiness)
+
+	businessInfo, err := businessObj.GetItemByBusinessCode(req.BusinessCode)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "商户不存在"
+			return
+		}
+		br.Msg = "客户信息有误"
+		br.ErrMsg = "获取客户信息失败, Err: " + err.Error()
+		return
+	}
+	//操作权限校验
+	ok := eta_business2.CheckBusinessUserButton(sysUser.RoleTypeCode, businessInfo.SellerId, sysUser.AdminId)
+	if !ok {
+		br.Msg = "没有操作权限"
+		br.ErrMsg = "没有操作权限"
+		return
+	}
+
+	if req.Mobile != "" && req.Mobile != userInfo.Mobile && req.CountryCode != userInfo.CountryCode {
+		mobileItem, e := models.GetUserByMobileCountryCode(req.Mobile, req.CountryCode)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			br.Msg = "校验手机号有误"
+			br.ErrMsg = "校验手机号有误, Err: " + err.Error()
+			return
+		}
+		if e == nil && mobileItem.UserId > 0 && mobileItem.UserId != req.UserId {
+			{
+				br.Msg = "手机号已存在"
+				br.Success = true
+				br.Data = mobileItem
+				br.IsSendEmail = false
+				br.Ret = 600
+				return
+			}
+		}
+	}
+
+	//待更新字段
+	updateCol := []string{"RealName", "Mobile", "LastUpdatedTime", "Position", "PositionStatus", "DepartmentName", "BusinessCode", "CountryCode"}
+
+	userInfo.RealName = req.RealName
+	userInfo.Mobile = req.Mobile
+	userInfo.LastUpdatedTime = time.Now()
+	userInfo.Position = req.Position
+	userInfo.DepartmentName = req.DepartmentName
+	userInfo.BusinessCode = req.BusinessCode
+	userInfo.CountryCode = req.CountryCode
+	userInfo.PositionStatus = req.PositionStatus
+	err = userInfo.Update(updateCol)
+	if err != nil {
+		br.Msg = "编辑失败!"
+		br.ErrMsg = "编辑失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "编辑成功"
+	br.IsAddLog = true
+}
+
+// @Title 获取批量导入联系人数据
+// @Description 获取批量导入联系人数据
+// @Param   File   query   file  true       "文件"
+// @Param   CompanyId   query   file  true       "客户id"
+// @Success 200 {object} models.ImportListResp
+// @router /import/list [post]
+func (this *EtaBusinessUserController) ImportList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请重新登录"
+		return
+	}
+	file, h, err := this.GetFile("File")
+	if err != nil {
+		br.Msg = "获取文件失败"
+		br.ErrMsg = "获取文件失败,Err:" + err.Error()
+		return
+	}
+
+	//todo 没有选择对应的商户所以无操作权限校验
+
+	uploadDir := "static/xls"
+	err = os.MkdirAll(uploadDir, 766)
+	if err != nil {
+		br.Msg = "存储目录创建失败"
+		br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
+		return
+	}
+	path := uploadDir + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + h.Filename
+	defer file.Close()
+	err = this.SaveToFile("File", path)
+	if err != nil {
+		br.Msg = "文件保存失败"
+		br.ErrMsg = "文件保存失败,Err:" + err.Error()
+		return
+	}
+	xlFile, err := xlsx.OpenFile(path)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "打开文件失败,Err:" + err.Error() + ";path:" + path
+		return
+	}
+	existUser := make([]*models.User, 0)
+	addUser := make([]*models.User, 0)
+	//excel中已经存在的数据,用来判断excel中是否存在相同手机号/邮箱,避免重复提交
+	excelData := make(map[string]string)
+	//重复数据
+	repeatUser := make([]*models.User, 0)
+
+	// 遍历sheet页读取
+	for _, sheet := range xlFile.Sheets {
+		//遍历行读取
+		maxRow := sheet.MaxRow
+		fmt.Println("maxRow:", maxRow)
+		fmt.Println("maxRow")
+		for i := 0; i < maxRow; i++ {
+			if i == 1 {
+				row := sheet.Row(i)
+				cells := row.Cells
+				for k, cell := range cells {
+					text := cell.String()
+					if k == 0 {
+						if text != "姓名" {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 1 {
+						if !strings.Contains(text, "区号") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 2 {
+						if !strings.Contains(text, "手机号") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 3 {
+						if !strings.Contains(text, "岗位") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 4 {
+						if !strings.Contains(text, "部门") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 5 {
+						if !strings.Contains(text, "客户名称") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 6 {
+						if !strings.Contains(text, "社会信用码") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 7 {
+						if !strings.Contains(text, "在职状态") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+				}
+			}
+			if i >= 2 {
+				row := sheet.Row(i)
+				cells := row.Cells
+				var userName, countryCode, mobileOne, position, departmentName, businessName, creditCode, positionStatus string
+				for k, cell := range cells {
+					if k == 0 {
+						userName = cell.String()
+					}
+					if k == 1 {
+						countryCode = cell.String()
+					}
+					if k == 2 {
+						mobileOne = cell.String()
+					}
+					if k == 3 {
+						position = cell.String()
+					}
+					if k == 4 {
+						departmentName = cell.String()
+					}
+					if k == 5 {
+						businessName = cell.String()
+					}
+					if k == 6 {
+						creditCode = cell.String()
+					}
+					if k == 7 {
+						positionStatus = cell.String()
+					}
+				}
+
+				//移除空格
+				mobileOne = utils.TrimStr(mobileOne)
+				//这些字段都没有的话,系统认为excel到底了
+				if userName == "" {
+					utils.FileLog.Info("姓名必填")
+					continue
+				}
+
+				//如果手机号或者邮箱都没有填写的情况下
+				if mobileOne == "" {
+					utils.FileLog.Info("手机号必填")
+					continue
+				}
+				if countryCode == "" {
+					utils.FileLog.Info("导入数据中存在【国际区号】为空的用户,请检查")
+					continue
+				}
+
+				if businessName == "" && creditCode == "" {
+					utils.FileLog.Info("导入数据中存在【姓名】和【社会信用码】都为空的用户,请检查")
+					continue
+				}
+
+				item := new(models.User)
+				item.CountryCode = countryCode
+				item.RealName = userName
+				if positionStatus == "在职" {
+					item.PositionStatus = 1
+				} else if positionStatus == "离职" {
+					item.PositionStatus = 0
+				}
+				item.Mobile = mobileOne
+				item.Position = position
+				item.DepartmentName = departmentName
+				// 查询商户信息
+				if creditCode != "" {
+					businessObj := new(eta_business.EtaBusiness)
+					businessInfo := new(eta_business.EtaBusiness)
+					businessInfo, err = businessObj.GetItemByCreditCode(creditCode)
+					if err != nil {
+						if err.Error() == utils.ErrNoRow() {
+							utils.FileLog.Info("商户不存在")
+							continue
+						}
+						utils.FileLog.Info("获取商户信息失败, Err: " + err.Error())
+						continue
+					}
+					item.BusinessCode = businessInfo.BusinessCode
+				}
+				if item.BusinessCode == "" && businessName != "" {
+					businessObj := new(eta_business.EtaBusiness)
+					businessInfo := new(eta_business.EtaBusiness)
+					businessInfo, err = businessObj.GetItemByBusinessName(businessName)
+					if err != nil {
+						if err.Error() == utils.ErrNoRow() {
+							utils.FileLog.Info("商户不存在")
+							continue
+						}
+						utils.FileLog.Info("获取商户信息失败, Err: " + err.Error())
+						continue
+					}
+					item.BusinessCode = businessInfo.BusinessCode
+				}
+				if _, ok := excelData[item.CountryCode+"_"+item.Mobile]; ok {
+					//将用户插入其中,然后退出当前循环,进入下一循环
+					//repeatUser = append(repeatUser, item)
+					continue
+				}
+				excelData[item.CountryCode+"_"+item.Mobile] = item.CountryCode
+
+				//没问题数据
+				existUser = append(existUser, item)
+			}
+		}
+	}
+
+	// 判断系统里该手机号是否已存在
+	mobiles := make([]string, 0)
+	for k, _ := range excelData {
+		mobile := strings.Split(k, "_")[1]
+		mobiles = append(mobiles, mobile)
+	}
+
+	// 查询系统里是否存在
+	existUserMap := make(map[string]struct{})
+	if len(mobiles) > 0 {
+		existUsers, e := models.GetUserByMobiles(mobiles)
+		if e != nil {
+			br.Msg = "查询用户失败"
+			br.ErrMsg = "查询用户失败,Err:" + e.Error()
+			return
+		}
+		for _, user := range existUsers {
+			existUserMap[user.CountryCode+"_"+user.Mobile] = struct{}{}
+		}
+	}
+	for _, v := range existUser {
+		if _, ok := existUserMap[v.CountryCode+"_"+v.Mobile]; ok {
+			repeatUser = append(repeatUser, v)
+		} else {
+			addUser = append(addUser, v)
+		}
+	}
+	//defer func() {
+	//	os.Remove(path)
+	//}()
+	br.Msg = "获取成功"
+	br.Ret = 200
+	br.Success = true
+	br.Data = models.ImportListResp{
+		ValidUser:  addUser,
+		RepeatUser: repeatUser,
+	}
+}
+
+// 需要更新的联系人数据实体
+type UpdateWxUser struct {
+	OldWxUser models.User  `description:"旧的联系人数据orm实体(未变更前的)"`
+	WxUser    *models.User `description:"联系人数据orm实体"`
+	Cols      []string     `description:"需要修改的字段名切片"`
+}
+
+// @Title 批量导入联系人数据
+// @Description 批量导入联系人数据
+// @Param   File   query   file  true       "文件"
+// @Param   CompanyId   query   file  true       "客户id"
+// @Success 600 {object} []*company.CompanyUser
+// @Success 200 Ret=200 导入成功
+// @router /import [post]
+func (this *EtaBusinessUserController) Import() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请重新登录"
+		return
+	}
+	file, h, err := this.GetFile("File")
+	if err != nil {
+		br.Msg = "获取文件失败"
+		br.ErrMsg = "获取文件失败,Err:" + err.Error()
+		return
+	}
+
+	//todo 没有选择对应的商户所以无操作权限校验
+
+	uploadDir := "static/xls"
+	err = os.MkdirAll(uploadDir, 766)
+	if err != nil {
+		br.Msg = "存储目录创建失败"
+		br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
+		return
+	}
+	path := uploadDir + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + h.Filename
+	defer file.Close()
+	err = this.SaveToFile("File", path)
+	if err != nil {
+		br.Msg = "文件保存失败"
+		br.ErrMsg = "文件保存失败,Err:" + err.Error()
+		return
+	}
+	xlFile, err := xlsx.OpenFile(path)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "打开文件失败,Err:" + err.Error() + ";path:" + path
+		return
+	}
+	existUser := make([]*models.User, 0)
+	addUser := make([]*models.User, 0)
+	//excel中已经存在的数据,用来判断excel中是否存在相同手机号/邮箱,避免重复提交
+	excelData := make(map[string]string)
+
+	// 遍历sheet页读取
+	for _, sheet := range xlFile.Sheets {
+		//遍历行读取
+		maxRow := sheet.MaxRow
+		fmt.Println("maxRow:", maxRow)
+		fmt.Println("maxRow")
+		for i := 0; i < maxRow; i++ {
+			if i == 1 {
+				row := sheet.Row(i)
+				cells := row.Cells
+				for k, cell := range cells {
+					text := cell.String()
+					if k == 0 {
+						if text != "姓名" {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 1 {
+						if !strings.Contains(text, "区号") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 2 {
+						if !strings.Contains(text, "手机号") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 3 {
+						if !strings.Contains(text, "岗位") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 4 {
+						if !strings.Contains(text, "部门") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 5 {
+						if !strings.Contains(text, "客户名称") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 6 {
+						if !strings.Contains(text, "社会信用码") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+					if k == 7 {
+						if !strings.Contains(text, "在职状态") {
+							br.Msg = "模板格式错误"
+							br.ErrMsg = "模板格式错误,title:" + text
+							return
+						}
+					}
+				}
+			}
+			if i >= 2 {
+				row := sheet.Row(i)
+				cells := row.Cells
+				var userName, countryCode, mobileOne, position, departmentName, businessName, creditCode, positionStatus string
+				for k, cell := range cells {
+					if k == 0 {
+						userName = cell.String()
+					}
+					if k == 1 {
+						countryCode = cell.String()
+					}
+					if k == 2 {
+						mobileOne = cell.String()
+					}
+					if k == 3 {
+						position = cell.String()
+					}
+					if k == 4 {
+						departmentName = cell.String()
+					}
+					if k == 5 {
+						businessName = cell.String()
+					}
+					if k == 6 {
+						creditCode = cell.String()
+					}
+					if k == 7 {
+						positionStatus = cell.String()
+					}
+				}
+
+				//移除空格
+				mobileOne = utils.TrimStr(mobileOne)
+				//这些字段都没有的话,系统认为excel到底了
+				if userName == "" {
+					utils.FileLog.Info("姓名必填")
+					continue
+				}
+
+				//如果手机号或者邮箱都没有填写的情况下
+				if mobileOne == "" {
+					utils.FileLog.Info("手机号必填")
+					continue
+				}
+				if countryCode == "" {
+					utils.FileLog.Info("导入数据中存在【国际区号】为空的用户,请检查")
+					continue
+				}
+
+				if businessName == "" && creditCode == "" {
+					utils.FileLog.Info("导入数据中存在【姓名】和【社会信用码】都为空的用户,请检查")
+					continue
+				}
+
+				item := new(models.User)
+				item.CountryCode = countryCode
+				item.RealName = userName
+				if positionStatus == "在职" {
+					item.PositionStatus = 1
+				} else if positionStatus == "离职" {
+					item.PositionStatus = 0
+				}
+				item.Mobile = mobileOne
+				item.Position = position
+				item.DepartmentName = departmentName
+				// 查询商户信息
+				if creditCode != "" {
+					businessObj := new(eta_business.EtaBusiness)
+					businessInfo := new(eta_business.EtaBusiness)
+					businessInfo, err = businessObj.GetItemByCreditCode(creditCode)
+					if err != nil {
+						if err.Error() == utils.ErrNoRow() {
+							utils.FileLog.Info("商户不存在")
+							continue
+						}
+						utils.FileLog.Info("获取商户信息失败, Err: " + err.Error())
+						continue
+					}
+					item.BusinessCode = businessInfo.BusinessCode
+				}
+				if item.BusinessCode == "" && businessName != "" {
+					businessObj := new(eta_business.EtaBusiness)
+					businessInfo := new(eta_business.EtaBusiness)
+					businessInfo, err = businessObj.GetItemByBusinessName(businessName)
+					if err != nil {
+						if err.Error() == utils.ErrNoRow() {
+							utils.FileLog.Info("商户不存在")
+							continue
+						}
+						utils.FileLog.Info("获取商户信息失败, Err: " + err.Error())
+						continue
+					}
+					item.BusinessCode = businessInfo.BusinessCode
+				}
+				if _, ok := excelData[item.CountryCode+"_"+item.Mobile]; ok {
+					//将用户插入其中,然后退出当前循环,进入下一循环
+					//repeatUser = append(repeatUser, item)
+					continue
+				}
+				excelData[item.CountryCode+"_"+item.Mobile] = item.CountryCode
+
+				//没问题数据
+				existUser = append(existUser, item)
+			}
+		}
+	}
+
+	// 判断系统里该手机号是否已存在
+	mobiles := make([]string, 0)
+	for k, _ := range excelData {
+		mobile := strings.Split(k, "_")[1]
+		mobiles = append(mobiles, mobile)
+	}
+
+	// 查询系统里是否存在
+	existUserMap := make(map[string]struct{})
+	if len(mobiles) > 0 {
+		existUsers, e := models.GetUserByMobiles(mobiles)
+		if e != nil {
+			br.Msg = "查询用户失败"
+			br.ErrMsg = "查询用户失败,Err:" + e.Error()
+			return
+		}
+		for _, user := range existUsers {
+			existUserMap[user.CountryCode+"_"+user.Mobile] = struct{}{}
+		}
+	}
+	for _, v := range existUser {
+		if _, ok := existUserMap[v.CountryCode+"_"+v.Mobile]; !ok {
+			addUser = append(addUser, v)
+		}
+	}
+	fmt.Println("表格中用户与系统中存在用户没有冲突")
+	//如果表格中用户与系统中存在用户 没有冲突,那么继续执行
+	for _, user := range addUser {
+		if user.RealName != "" && user.Mobile != "" {
+			userData := new(models.User)
+			userData.RealName = user.RealName
+			userData.Mobile = user.Mobile
+			userData.CountryCode = user.CountryCode
+			userData.Email = user.Email
+			userData.Position = user.Position
+			userData.PositionStatus = user.PositionStatus
+			userData.BusinessCode = user.BusinessCode
+			userData.DepartmentName = user.DepartmentName
+			userData.CountryCode = user.CountryCode
+
+			//判断该手机号、邮箱是否已经添加,如果已经添加,那么就不再添加
+			var key string
+			key = "user:mobile:" + userData.Mobile
+
+			isHas := utils.Rc.IsExist(key)
+			if isHas == false {
+				newId, err := models.AddUser(userData)
+				userData.UserId = int(newId)
+				if err != nil {
+					br.Msg = "导入失败"
+					br.ErrMsg = "导入失败,Err:" + err.Error()
+					return
+				}
+			}
+		}
+	}
+	defer func() {
+		os.Remove(path)
+	}()
+
+	br.Msg = "导入成功"
+	br.Ret = 200
+	br.Success = true
+}

+ 1 - 0
go.mod

@@ -14,6 +14,7 @@ require (
 	github.com/olivere/elastic/v7 v7.0.32
 	github.com/rdlucklib/rdluck_tools v1.0.3
 	github.com/shopspring/decimal v1.3.1
+	github.com/tealeg/xlsx v1.0.5
 	go.mongodb.org/mongo-driver v1.15.0
 	gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
 )

+ 2 - 0
go.sum

@@ -207,6 +207,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
 github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
+github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
+github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
 github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
 github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
 github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=

+ 1 - 0
models/db.go

@@ -85,6 +85,7 @@ func initEtaBusiness() {
 		new(eta_business.EtaBusinessMenuRelate),      // ETA商家菜单关联表
 		new(eta_business.EtaBusinessConfigRelate),    // ETA商家配置关联表
 		new(eta_business.EtaBusinessMenuIcon),        // ETA商家菜单icon表
+		new(User),                                    // 商家用户表
 	)
 }
 

+ 21 - 0
models/eta_business/eta_business.go

@@ -141,6 +141,27 @@ func (m *EtaBusiness) GetItemById(id int) (item *EtaBusiness, err error) {
 	return
 }
 
+func (m *EtaBusiness) GetItemByBusinessCode(code string) (item *EtaBusiness, err error) {
+	o := orm.NewOrm()
+	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), EtaBusinessColumns.BusinessCode)
+	err = o.Raw(sql, code).QueryRow(&item)
+	return
+}
+
+func (m *EtaBusiness) GetItemByCreditCode(code string) (item *EtaBusiness, err error) {
+	o := orm.NewOrm()
+	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), EtaBusinessColumns.CreditCode)
+	err = o.Raw(sql, code).QueryRow(&item)
+	return
+}
+
+func (m *EtaBusiness) GetItemByBusinessName(name string) (item *EtaBusiness, err error) {
+	o := orm.NewOrm()
+	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), EtaBusinessColumns.BusinessName)
+	err = o.Raw(sql, name).QueryRow(&item)
+	return
+}
+
 func (m *EtaBusiness) GetItemByCondition(condition string, pars []interface{}) (item *EtaBusiness, err error) {
 	o := orm.NewOrm()
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s LIMIT 1`, m.TableName(), condition)

+ 174 - 0
models/user.go

@@ -0,0 +1,174 @@
+package models
+
+import (
+	"eta/eta_forum_admin/utils"
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type User struct {
+	UserId               int `orm:"column(user_id);pk"`
+	BusinessCode         string
+	RealName             string `description:"姓名"`
+	Mobile               string
+	Email                string
+	NickName             string `description:"昵称"`
+	CountryCode          string `description:"区号,86、852、886等"`
+	LastLoginTime        string
+	IsFreeLogin          int `description:"是否30天免登录,0否,1是"`
+	RegisterTime         time.Time
+	LastCollectChartTime string `description:"最近收藏图表时间"`
+	Enabled              int
+	DepartmentName       string `description:"部门名称"`
+	Position             string `description:"岗位"`
+	PositionStatus       int    `description:"在职状态:1:在职,0:离职"`
+	CreatedTime          time.Time
+	LastUpdatedTime      time.Time `description:"最近一次更新时间"`
+}
+
+// 用户详情出参
+type UserResp struct {
+	Detail *User
+}
+
+func AddUser(item *User) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+func GetUserByMobile(mobile string) (item *User, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM user WHERE mobile = ? LIMIT 1`
+	err = o.Raw(sql, mobile).QueryRow(&item)
+	return
+}
+
+func GetUserByMobiles(mobiles []string) (items []*User, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM user WHERE mobile in (` + utils.GetOrmInReplace(len(mobiles)) + `)`
+	_, err = o.Raw(sql, mobiles).QueryRows(&items)
+	return
+}
+
+// GetUserByMobileCountryCode 根据手机号和区号获取用户信息
+func GetUserByMobileCountryCode(mobile, countryCode string) (item *User, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM user WHERE mobile = ? `
+	sql += ` and country_code =? `
+	sql += ` LIMIT 1 `
+	err = o.Raw(sql, mobile, countryCode).QueryRow(&item)
+	return
+}
+
+func GetUserByUserId(userId int) (item *User, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM user WHERE user_id=? `
+	err = o.Raw(sql, userId).QueryRow(&item)
+	return
+}
+
+// 更新User信息
+func (User *User) Update(cols []string) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Update(User, cols...)
+	return
+}
+
+// 获取该用户数量
+func GetUserCountByCondition(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	tmpSql := `SELECT *
+			FROM
+				user
+			WHERE
+				1=1 `
+	if condition != "" {
+		tmpSql += condition
+	}
+	sql := `SELECT COUNT(1) AS count FROM (` + tmpSql + `) AS c `
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+// 获取该用户列表
+func GetUserPageListByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*User, err error) {
+	o := orm.NewOrm()
+	tmpSql := `SELECT *
+			FROM
+				user
+			WHERE
+				1=1 `
+	if condition != "" {
+		tmpSql += condition
+	}
+	tmpSql += ` ORDER BY user_id DESC Limit ?,?`
+	_, err = o.Raw(tmpSql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type BusinessUser struct {
+	UserId          int
+	BusinessCode    string
+	BusinessName    string
+	RealName        string `description:"姓名"`
+	Mobile          string
+	Email           string
+	CountryCode     string `description:"区号,86、852、886等"`
+	LastLoginTime   string
+	Enabled         int
+	DepartmentName  string `description:"部门名称"`
+	Position        string `description:"岗位"`
+	PositionStatus  int    `description:"在职状态:1:在职,0:离职"`
+	CreatedTime     string
+	LastUpdatedTime string `description:"最近一次更新时间"`
+}
+
+type UserListResp struct {
+	Paging *paging.PagingItem
+	List   []*BusinessUser
+}
+
+// 新增用户请求参数
+type AddUserReq struct {
+	RealName    string `description:"姓名"`
+	CountryCode string `description:"区号,86、852、886等"`
+	Mobile      string `description:"手机号"`
+	//Email          string `description:"邮箱"`
+	Position       string `description:"职位"`
+	PositionStatus int    `description:"在职状态:1:在职,0:离职"`
+	BusinessCode   string `description:"商家编码"`
+	DepartmentName string `description:"联系人部门"`
+}
+
+// 删除客户请求参数
+type DeleteUserReq struct {
+	UserId int
+}
+
+// 新增客户请求参数
+type EditUserReq struct {
+	UserId      int
+	RealName    string `description:"姓名"`
+	CountryCode string `description:"区号,86、852、886等"`
+	Mobile      string `description:"手机号"`
+	//Email          string `description:"邮箱"`
+	Position       string `description:"职位"`
+	PositionStatus int    `description:"在职状态:1:在职,0:离职"`
+	BusinessCode   string `description:"商家编码"`
+	DepartmentName string `description:"联系人部门"`
+}
+
+func DeleteUser(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM user WHERE user_id=? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 联系人导入预览数据返回
+type ImportListResp struct {
+	ValidUser  []*User `description:"有效客户数据"`
+	RepeatUser []*User `description:"重复客户数据"`
+}

+ 54 - 0
routers/commentsRouter.go

@@ -187,6 +187,60 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"] = append(beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"],
+        beego.ControllerComments{
+            Method: "Import",
+            Router: `/import`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"] = append(beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"],
+        beego.ControllerComments{
+            Method: "ImportList",
+            Router: `/import/list`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"] = append(beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"],
+        beego.ControllerComments{
+            Method: "AddUser",
+            Router: `/user/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"] = append(beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"],
+        beego.ControllerComments{
+            Method: "DeleteUser",
+            Router: `/user/delete`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"] = append(beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"],
+        beego.ControllerComments{
+            Method: "EditUser",
+            Router: `/user/edit`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"] = append(beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/eta_business:EtaBusinessUserController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/user/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/help_doc:HelpDocClassifyController"] = append(beego.GlobalControllerRouter["eta/eta_forum_admin/controllers/help_doc:HelpDocClassifyController"],
         beego.ControllerComments{
             Method: "AddClassify",

+ 1 - 0
routers/router.go

@@ -47,6 +47,7 @@ func init() {
 			web.NSInclude(
 				&eta_business.EtaBusinessController{},
 				&eta_business.EtaBusinessMenuController{},
+				&eta_business.EtaBusinessUserController{},
 			),
 		),
 		web.NSNamespace("/eta_trial",

+ 16 - 0
services/eta_business/user.go

@@ -0,0 +1,16 @@
+package eta_business
+
+import "eta/eta_forum_admin/utils"
+
+// 校验当前操作员是否具有联系人权限是否有操作权限
+func CheckBusinessUserButton(roleTypeCode string, itemSellerId, sysUserId int) (ok bool) {
+	if roleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
+		ok = true
+		return
+	}
+	if sysUserId == itemSellerId {
+		ok = true
+		return
+	}
+	return
+}