company_seller.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package crm
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/go-playground/validator/v10"
  5. "hongze/fms_api/controller/resp"
  6. "hongze/fms_api/global"
  7. "hongze/fms_api/models/crm"
  8. crmService "hongze/fms_api/services/crm"
  9. )
  10. // CompanySellerController CRM销售
  11. type CompanySellerController struct{}
  12. // List
  13. // @Title 销售列表
  14. // @Description 销售列表
  15. // @Param SellerType query int false "销售类型: 0-所有; 1-FICC; 2-权益"
  16. // @Success 200 {object} crm.CompanySellerList
  17. // @router /crm/company_seller/list [get]
  18. func (rg *CompanySellerController) List(c *gin.Context) {
  19. var req crm.CompanySellerListReq
  20. if e := c.BindQuery(&req); e != nil {
  21. err, ok := e.(validator.ValidationErrors)
  22. if !ok {
  23. resp.FailData("参数解析失败", "Err:"+e.Error(), c)
  24. return
  25. }
  26. resp.FailData("参数解析失败", err.Translate(global.Trans), c)
  27. return
  28. }
  29. //roleCodeArr := make([]string, 0)
  30. //if req.SellerType == crm.CompanyProductRai {
  31. // roleCodeArr = []string{
  32. // crm.ROLE_TYPE_CODE_RAI_ADMIN,
  33. // crm.ROLE_TYPE_CODE_RAI_DEPARTMENT,
  34. // crm.ROLE_TYPE_CODE_RAI_GROUP,
  35. // crm.ROLE_TYPE_CODE_RAI_SELLER,
  36. // }
  37. //} else {
  38. // roleCodeArr = []string{
  39. // crm.ROLE_TYPE_CODE_FICC_ADMIN,
  40. // crm.ROLE_TYPE_CODE_FICC_DEPARTMENT,
  41. // crm.ROLE_TYPE_CODE_FICC_GROUP,
  42. // crm.ROLE_TYPE_CODE_FICC_TEAM,
  43. // crm.ROLE_TYPE_CODE_FICC_SELLER,
  44. // }
  45. //}
  46. //cond := `b.role_type_code IN ?`
  47. //pars := make([]interface{}, 0)
  48. //pars = append(pars, roleCodeArr)
  49. //list, e := crm.GetCompanySellerByRoleCodes(cond, pars)
  50. //if e != nil {
  51. // resp.FailData("获取失败", "获取销售列表失败, Err:"+e.Error(), c)
  52. // return
  53. //}
  54. // 此处调整为只取销售部门的人员, 而不是原先的根据角色取
  55. sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
  56. if e != nil {
  57. resp.FailData("获取失败", "获取销售列表失败, Err:"+e.Error(), c)
  58. return
  59. }
  60. list := make([]*crm.CompanySellerList, 0)
  61. for i := range sellerList {
  62. list = append(list, &crm.CompanySellerList{
  63. AdminId: sellerList[i].SellerId,
  64. AdminName: sellerList[i].SellerName,
  65. RealName: sellerList[i].SellerName,
  66. })
  67. }
  68. resp.OkData("获取成功", list, c)
  69. }
  70. // GroupList
  71. // @Title 销售组别列表
  72. // @Description 销售组别列表
  73. // @Success 200 {object} crm.SysGroup
  74. // @router /crm/company_seller/group_list [get]
  75. func (rg *CompanySellerController) GroupList(c *gin.Context) {
  76. groupOB := new(crm.SysGroup)
  77. cond := `department_id = ? AND parent_id = 0`
  78. pars := make([]interface{}, 0)
  79. pars = append(pars, crm.SellerDepartmentId)
  80. list, e := groupOB.List(cond, pars)
  81. if e != nil {
  82. resp.FailData("获取失败", "获取销售组别列表失败, Err:"+e.Error(), c)
  83. return
  84. }
  85. resp.OkData("获取成功", list, c)
  86. }