1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package crm
- import (
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- "hongze/fms_api/controller/resp"
- "hongze/fms_api/global"
- "hongze/fms_api/models/crm"
- crmService "hongze/fms_api/services/crm"
- )
- // CompanySellerController CRM销售
- type CompanySellerController struct{}
- // List
- // @Title 销售列表
- // @Description 销售列表
- // @Success 200 {object} crm.SellerAdminWithGroupList
- // @router /crm/company_seller/list [get]
- func (rg *CompanySellerController) List(c *gin.Context) {
- // 此处调整为只取销售部门的人员, 而不是原先的根据角色取
- list, e := crmService.GetSellerDepartmentList()
- if e != nil {
- resp.FailData("获取失败", "获取销售列表失败, Err:"+e.Error(), c)
- return
- }
- resp.OkData("获取成功", list, c)
- }
- // GroupList
- // @Title 销售组别列表
- // @Description 销售组别列表
- // @Success 200 {object} crm.SysGroup
- // @router /crm/company_seller/group_list [get]
- func (rg *CompanySellerController) GroupList(c *gin.Context) {
- var req crm.SysGroupListReq
- if e := c.BindQuery(&req); e != nil {
- err, ok := e.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+e.Error(), c)
- return
- }
- resp.FailData("参数解析失败", err.Translate(global.Trans), c)
- return
- }
- var departmentId int
- if req.SellerType == 1 {
- departmentId = crm.SellerDepartmentId
- }else if req.SellerType == 2 {
- departmentId = crm.RaiSellerDepartmentId
- }else if req.SellerType == 0 {
- resp.Fail("请选择销售类型", c)
- return
- }else {
- resp.Fail("请选择正确的销售类型", c)
- return
- }
- groupOB := new(crm.SysGroup)
- cond := `department_id = ? AND parent_id = 0`
- pars := make([]interface{}, 0)
- pars = append(pars, departmentId)
- list, e := groupOB.List(cond, pars)
- if e != nil {
- resp.FailData("获取失败", "获取销售组别列表失败, Err:"+e.Error(), c)
- return
- }
- resp.OkData("获取成功", list, c)
- }
|