report.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package roadshow
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type RsReportRecord struct {
  7. RsReportRecordId int `orm:"column(rs_report_record_id);pk"`
  8. CompanyId int `description:"客户id"`
  9. CompanyName string `description:"客户名称"`
  10. CreditCode string `description:"社会统一信用码"`
  11. CompanyStatus string `description:"客户状态:'试用','永续','冻结','流失','正式','潜在'"`
  12. PermissionName string `description:"开通品种"`
  13. ResearcherId int `description:"研究员id"`
  14. ResearcherName string `description:"研究员名称"`
  15. ResearcherGroupId int `description:"研究员分组id"`
  16. ResearcherGroupName string `description:"研究员分组名称"`
  17. SellerId int `description:"所属销售id"`
  18. SellerName string `description:"所属销售名称"`
  19. SellerGroupId int `description:"销售分组id"`
  20. SellerGroupName string `description:"销售分组名称"`
  21. RsCalendarId int `description:"路演活动id"`
  22. RsCalendarResearcherId int `description:"路演研究员id"`
  23. StartDate string `description:"开始日期"`
  24. EndDate string `description:"结束日期"`
  25. StartTime string `description:"开始时间"`
  26. EndTime string `description:"结束时间"`
  27. StartWeek string `description:"开始日期对应周"`
  28. EndWeek string `description:"结束日期对应周"`
  29. CreateTime time.Time `description:"记录创建时间"`
  30. RsCalendarResearcherStatus int `description:"路演活动状态"`
  31. ModifyTime time.Time `description:"记录修改时间"`
  32. ActivityType string `description:"活动类型"`
  33. RoadshowType string `description:"路演形式"`
  34. }
  35. func AddRsReportRecord(item *RsReportRecord) (lastId int64, err error) {
  36. o := orm.NewOrm()
  37. lastId, err = o.Insert(item)
  38. return
  39. }
  40. type RsCalendarResearcherView struct {
  41. RsCalendarId int `description:"活动"`
  42. SysUserId int `description:"创建人id"`
  43. SysUserRealName string `description:"创建人名称"`
  44. ActivityType string `description:"活动类型"`
  45. RoadshowType string `description:"路演形式"`
  46. RoadshowPlatform string `description:"路演平台"`
  47. CompanyId int `description:"客户id"`
  48. CompanyName string `description:"客户名称"`
  49. Province string `description:"省"`
  50. ProvinceCode string `description:"省编码"`
  51. City string `description:"市"`
  52. CityCode string `description:"市编码"`
  53. Theme string `description:"会议主题"`
  54. CooperationName string `description:"合作方名称"`
  55. Title string `description:"展示在日历的标题"`
  56. Source int8 `description:"来源,0:自系统,1:上海方的"`
  57. CreateTime time.Time
  58. ModifyTime time.Time
  59. ActivityCategory string `description:"活动类别"`
  60. RsCalendarResearcherId int `description:"活动研究员id"`
  61. ResearcherId int `description:"研究员id"`
  62. ResearcherName string `description:"研究员名称"`
  63. StartDate string `description:"开始日期"`
  64. EndDate string `description:"结束日期"`
  65. StartTime string `description:"开始时间"`
  66. EndTime string `description:"结束时间"`
  67. StartWeek string `description:"开始日期对应周"`
  68. EndWeek string `description:"结束日期对应周"`
  69. Status int `description:"状态:1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束"`
  70. RefuseReason string `description:"拒绝理由"`
  71. RefuseTime time.Time `description:"拒绝时间"`
  72. DeleteReason string `description:"删除理由"`
  73. DeleteTime time.Time `description:"删除时间"`
  74. ApproveTime time.Time `description:"接受时间"`
  75. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  76. ResearcherSort int `description:"研究员新增排序"`
  77. }
  78. func GetRsCalendarDetail(endDate string) (list []*RsCalendarResearcherView, err error) {
  79. sql := ` SELECT * FROM rs_calendar AS a
  80. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  81. WHERE a.source=0 AND b.end_date>=? `
  82. o := orm.NewOrm()
  83. _, err = o.Raw(sql, endDate).QueryRows(&list)
  84. return
  85. }
  86. type CompanySearchView struct {
  87. CompanyId int `orm:"column(company_id);pk"`
  88. CompanyName string `description:"客户名称"`
  89. CreditCode string `description:"社会统一信用码"`
  90. CompanyCode string `description:"客户编码"`
  91. Status string `description:"客户状态"`
  92. PermissionName string `description:"开通品种"`
  93. }
  94. func RsCompanyList() (list []*CompanySearchView, err error) {
  95. o := orm.NewOrm()
  96. sql := ` SELECT b.company_id,b.company_name,a.credit_code,b.status FROM company AS a
  97. INNER JOIN company_product AS b ON a.company_id=b.company_id
  98. WHERE b.status IN('正式','试用') AND b.product_id=1 `
  99. sql += ` GROUP BY b.company_id `
  100. _, err = o.Raw(sql).QueryRows(&list)
  101. return
  102. }
  103. // 权益客户
  104. func RsCompanyListRai() (list []*CompanySearchView, err error) {
  105. o := orm.NewOrm()
  106. sql := ` SELECT b.company_id,b.company_name,a.credit_code,b.status FROM company AS a
  107. INNER JOIN company_product AS b ON a.company_id=b.company_id
  108. WHERE b.product_id=2 `
  109. sql += ` GROUP BY b.company_id `
  110. _, err = o.Raw(sql).QueryRows(&list)
  111. return
  112. }
  113. func GetExistRsReportRecord(endDate string) (list []*RsReportRecord, err error) {
  114. sql := ` SELECT * FROM rs_report_record
  115. WHERE end_date>=? `
  116. o := orm.NewOrm()
  117. _, err = o.Raw(sql, endDate).QueryRows(&list)
  118. return
  119. }
  120. // 更新活动信息
  121. func UpdateRsReportRecord(where, updateParams map[string]interface{}) error {
  122. o := orm.NewOrm()
  123. ptrStructOrTableName := "rs_report_record"
  124. qs := o.QueryTable(ptrStructOrTableName)
  125. for expr, exprV := range where {
  126. qs = qs.Filter(expr, exprV)
  127. }
  128. _, err := qs.Update(updateParams)
  129. return err
  130. }