report.go 5.9 KB

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