1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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 销售列表
- // @Param SellerType query int false "销售类型: 0-所有; 1-FICC; 2-权益"
- // @Success 200 {object} crm.CompanySellerList
- // @router /crm/company_seller/list [get]
- func (rg *CompanySellerController) List(c *gin.Context) {
- var req crm.CompanySellerListReq
- 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
- }
- //roleCodeArr := make([]string, 0)
- //if req.SellerType == crm.CompanyProductRai {
- // roleCodeArr = []string{
- // crm.ROLE_TYPE_CODE_RAI_ADMIN,
- // crm.ROLE_TYPE_CODE_RAI_DEPARTMENT,
- // crm.ROLE_TYPE_CODE_RAI_GROUP,
- // crm.ROLE_TYPE_CODE_RAI_SELLER,
- // }
- //} else {
- // roleCodeArr = []string{
- // crm.ROLE_TYPE_CODE_FICC_ADMIN,
- // crm.ROLE_TYPE_CODE_FICC_DEPARTMENT,
- // crm.ROLE_TYPE_CODE_FICC_GROUP,
- // crm.ROLE_TYPE_CODE_FICC_TEAM,
- // crm.ROLE_TYPE_CODE_FICC_SELLER,
- // }
- //}
- //cond := `b.role_type_code IN ?`
- //pars := make([]interface{}, 0)
- //pars = append(pars, roleCodeArr)
- //list, e := crm.GetCompanySellerByRoleCodes(cond, pars)
- //if e != nil {
- // resp.FailData("获取失败", "获取销售列表失败, Err:"+e.Error(), c)
- // return
- //}
- // 此处调整为只取销售部门的人员, 而不是原先的根据角色取
- sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
- if e != nil {
- resp.FailData("获取失败", "获取销售列表失败, Err:"+e.Error(), c)
- return
- }
- list := make([]*crm.CompanySellerList, 0)
- for i := range sellerList {
- list = append(list, &crm.CompanySellerList{
- AdminId: sellerList[i].SellerId,
- AdminName: sellerList[i].SellerName,
- RealName: sellerList[i].SellerName,
- })
- }
- 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) {
- groupOB := new(crm.SysGroup)
- cond := `department_id = ? AND parent_id = 0`
- pars := make([]interface{}, 0)
- pars = append(pars, crm.SellerDepartmentId)
- list, e := groupOB.List(cond, pars)
- if e != nil {
- resp.FailData("获取失败", "获取销售组别列表失败, Err:"+e.Error(), c)
- return
- }
- resp.OkData("获取成功", list, c)
- }
|