feedback.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package roadshow
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. )
  6. type FeedbackView struct {
  7. RsCalendarResearcherId int `orm:"column(rs_calendar_researcher_id);pk"`
  8. RsCalendarId int `description:"日历活动id"`
  9. SysUserId int `description:"创建人id"`
  10. SysUserRealName string `description:"创建人名称"`
  11. ActivityType string `description:"活动类型"`
  12. RoadshowType string `description:"路演形式"`
  13. RoadshowPlatform string `description:"路演平台"`
  14. ResearcherId int `description:"研究员id"`
  15. ResearcherName string `description:"研究员名称"`
  16. StartDate string `description:"开始日期"`
  17. EndDate string `description:"结束日期"`
  18. StartTime string `description:"开始时间"`
  19. EndTime string `description:"结束时间"`
  20. StartWeek string `description:"开始日期对应周"`
  21. EndWeek string `description:"结束日期对应周"`
  22. Status int `description:"状态:1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束"`
  23. ApproveTime string `description:"接受时间"`
  24. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  25. ResearcherSort int `description:"研究员新增排序"`
  26. CompanyId int `description:"客户id"`
  27. CompanyName string `description:"客户名称"`
  28. CompanyStatus string `description:"客户状态"`
  29. FeedbackStatus int `description:"1:未请求,2:待反馈,3:已反馈"`
  30. FeedbackTime string `description:"反馈时间"`
  31. FeedbackContent string `description:"反馈内容"`
  32. FeedbackRequestTime string `description:"反馈请求时间"`
  33. Province string `description:"省"`
  34. ProvinceCode string `description:"省编码"`
  35. City string `description:"市"`
  36. CityCode string `description:"市编码"`
  37. }
  38. func GetFeedbackListCount(condition string, pars []interface{}) (count int, err error) {
  39. o := orm.NewOrm()
  40. sql := `SELECT COUNT(1) AS count FROM rs_calendar AS a
  41. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  42. INNER JOIN admin AS c ON b.researcher_id=c.admin_id
  43. WHERE 1=1 AND c.enabled=1 `
  44. if condition != "" {
  45. sql += condition
  46. }
  47. err = o.Raw(sql, pars).QueryRow(&count)
  48. return
  49. }
  50. func GetFeedbackList(condition string, pars []interface{}, startSize, pageSize, feedbackType int) (list []*FeedbackView, err error) {
  51. o := orm.NewOrm()
  52. sql := ` SELECT * FROM rs_calendar AS a
  53. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  54. INNER JOIN admin AS c ON b.researcher_id=c.admin_id
  55. WHERE 1=1 AND c.enabled=1 `
  56. if condition != "" {
  57. sql += condition
  58. }
  59. //显示已发送反馈请求的路演
  60. if feedbackType == 1 {
  61. sql += ` ORDER BY FIELD(feedback_status,3) DESC,b.feedback_time DESC,FIELD(B.feedback_status,2) DESC,b.feedback_request_time DESC `
  62. } else {
  63. sql += ` ORDER BY DATE_FORMAT(CONCAT(b.end_date," ",b.end_time),'%Y-%m-%d %H:%i:%S') DESC `
  64. }
  65. sql += ` LIMIT ?,? `
  66. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  67. return
  68. }
  69. type FeedbackListResp struct {
  70. Paging *paging.PagingItem
  71. List []*FeedbackView
  72. }
  73. func GetSubmitFeedbackList(condition string, pars []interface{}) (list []*FeedbackView, err error) {
  74. o := orm.NewOrm()
  75. sql := ` SELECT * FROM rs_calendar AS a
  76. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  77. WHERE 1=1 `
  78. if condition != "" {
  79. sql += condition
  80. }
  81. //显示已发送反馈请求的路演
  82. sql += ` ORDER BY b.feedback_request_time DESC `
  83. _, err = o.Raw(sql, pars).QueryRows(&list)
  84. return
  85. }
  86. type WriteFeedbackReq struct {
  87. RsCalendarResearcherId int `description:"路演研究员id"`
  88. FeedbackContent string `description:"反馈内容"`
  89. }
  90. func WriteFeedback(item *WriteFeedbackReq) (err error) {
  91. o := orm.NewOrm()
  92. sql := ` UPDATE rs_calendar_researcher SET feedback_content = ? WHERE rs_calendar_researcher_id=? `
  93. _, err = o.Raw(sql, item.FeedbackContent, item.RsCalendarResearcherId).Exec()
  94. return
  95. }
  96. type SubmitFeedbackReq struct {
  97. List []SubmitFeedback
  98. }
  99. type SubmitFeedback struct {
  100. RsCalendarResearcherId int `description:"路演研究员id"`
  101. }
  102. func SubmitFeedbackInfo(rsCalendarResearcherId int) (err error) {
  103. o := orm.NewOrm()
  104. sql := ` UPDATE rs_calendar_researcher SET feedback_time = NOW(),feedback_status=3 WHERE rs_calendar_researcher_id=? `
  105. _, err = o.Raw(sql, rsCalendarResearcherId).Exec()
  106. return
  107. }
  108. func SendFeedbackInfo(rsCalendarResearcherId int) (err error) {
  109. o := orm.NewOrm()
  110. sql := ` UPDATE rs_calendar_researcher SET feedback_request_time = NOW(),feedback_status=2 WHERE rs_calendar_researcher_id=? `
  111. _, err = o.Raw(sql, rsCalendarResearcherId).Exec()
  112. return
  113. }