gushou.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/models/time_line"
  7. "hongze/hongze_clpt/services"
  8. "hongze/hongze_clpt/utils"
  9. "time"
  10. )
  11. // 固收
  12. type MobileGushouController struct {
  13. BaseAuthMobileController
  14. }
  15. // @Title 固收时间线列表
  16. // @Description 固收时间线列表接口
  17. // @Param PageSize query int true "每页数据条数"
  18. // @Param CurrentIndex query int true "当前页页码,从1开始"
  19. // @Success 200 {object} models.GetCygxGushouTimeLineResp
  20. // @router /gushouTimeLine/list [get]
  21. func (this *MobileGushouController) GushouTimeLineList() {
  22. br := new(models.BaseResponse).Init()
  23. defer func() {
  24. this.Data["json"] = br
  25. this.ServeJSON()
  26. }()
  27. user := this.User
  28. if user == nil {
  29. br.Msg = "请登录"
  30. br.ErrMsg = "请登录,用户信息为空"
  31. br.Ret = 408
  32. return
  33. }
  34. resp := new(time_line.GetCygxGushouTimeLineResp)
  35. pageSize, _ := this.GetInt("PageSize")
  36. currentIndex, _ := this.GetInt("CurrentIndex")
  37. var startSize int
  38. if pageSize <= 0 {
  39. pageSize = utils.PageSize20
  40. }
  41. if currentIndex <= 0 {
  42. currentIndex = 1
  43. }
  44. startSize = utils.StartIndex(currentIndex, pageSize)
  45. var condition string
  46. var pars []interface{}
  47. condition += ` AND art.status = 1 `
  48. total, err := time_line.GetCygxGushouTimeLineCount(condition, pars)
  49. if err != nil {
  50. br.Msg = "获取失败"
  51. br.ErrMsg = "获取失败,Err:" + err.Error()
  52. return
  53. }
  54. condition += " ORDER BY art.publish_time DESC , art.time_line_id DESC "
  55. list, err := time_line.GetCygxGushouTimeLineList(condition, pars, startSize, pageSize)
  56. if err != nil {
  57. br.Msg = "获取失败"
  58. br.ErrMsg = "获取失败,Err:" + err.Error()
  59. return
  60. }
  61. for _, v := range list {
  62. v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
  63. v.Resource = 1
  64. v.Content = services.AnnotationHtml(v.Content)
  65. }
  66. if len(list) == 0 {
  67. list = make([]*time_line.CygxGushouTimeLineResp, 0)
  68. }
  69. cf, err := models.GetConfigByCode(utils.CYGX_GUSHOU_TIME_LINE_STATUS)
  70. if err != nil {
  71. br.Msg = "获取失败"
  72. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  73. return
  74. }
  75. //如果不是弘则用户,并且设置了内部可见,那么数据就隐藏
  76. if user.CompanyId != utils.HZ_COMPANY_ID && cf.ConfigValue != "1" {
  77. list = make([]*time_line.CygxGushouTimeLineResp, 0)
  78. }
  79. page := paging.GetPaging(currentIndex, pageSize, total)
  80. resp.List = list
  81. resp.Paging = page
  82. br.Ret = 200
  83. br.Success = true
  84. br.Msg = "获取成功"
  85. br.Data = resp
  86. }
  87. // @Title 固收时间线点击记录
  88. // @Description 固收时间线点击记录接口
  89. // @Param request body models.GushouTimeLineTimeLineIdReq true "type json string"
  90. // @Success Ret=200 新增成功
  91. // @router /gushouTimeLine/history [post]
  92. func (this *MobileGushouController) History() {
  93. br := new(models.BaseResponse).Init()
  94. defer func() {
  95. this.Data["json"] = br
  96. this.ServeJSON()
  97. }()
  98. user := this.User
  99. if user == nil {
  100. br.Msg = "请登录"
  101. br.ErrMsg = "请登录,用户信息为空"
  102. br.Ret = 408
  103. return
  104. }
  105. var req models.TacticsTimeLineTimeLineIdReq
  106. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  107. if err != nil {
  108. br.Msg = "参数解析异常!"
  109. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  110. return
  111. }
  112. timeLineId := req.TimeLineId
  113. if timeLineId == 0 {
  114. br.Msg = "时间线ID错误"
  115. return
  116. }
  117. var sellerName string
  118. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  119. if err != nil {
  120. br.Msg = "记录失败!"
  121. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  122. return
  123. }
  124. item := time_line.CygxGushouTimeLineHistory{
  125. TimeLineId: timeLineId,
  126. UserId: user.UserId,
  127. Mobile: user.Mobile,
  128. Email: user.Email,
  129. CompanyId: user.CompanyId,
  130. CompanyName: user.CompanyName,
  131. RealName: user.RealName,
  132. SellerName: sellerName,
  133. CreateTime: time.Now(),
  134. ModifyTime: time.Now(),
  135. }
  136. err = time_line.AddCygxGushouTimeLineHistory(&item)
  137. br.Ret = 200
  138. br.Success = true
  139. br.Msg = "获取成功"
  140. }