calendar.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. package roadshow
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_mobile_admin/models/tables/admin"
  6. "time"
  7. )
  8. type AddActivityReq struct {
  9. ActivityType string `description:"活动类型"`
  10. RoadshowType string `description:"路演形式"`
  11. RoadshowPlatform string `description:"路演平台"`
  12. CompanyId int `description:"客户id"`
  13. CompanyName string `description:"客户名称"`
  14. Province string `description:"省"`
  15. ProvinceCode string `description:"省编码"`
  16. City string `description:"市"`
  17. CityCode string `description:"市编码"`
  18. Theme string `description:"会议主题"`
  19. CooperationName string `description:"合作方名称"`
  20. ActivityCategory string `description:"活动类别"`
  21. ResearcherList []*CalendarResearcher
  22. EnglishCompany int `description:"是否为英文客户"`
  23. }
  24. type CalendarResearcher struct {
  25. ResearcherId int `description:"研究员id"`
  26. ResearcherName string `description:"研究员名称"`
  27. StartDate string `description:"开始日期"`
  28. EndDate string `description:"结束日期"`
  29. StartTime string `description:"开始时间"`
  30. EndTime string `description:"结束时间"`
  31. StartWeek string `description:"开始日期对应周"`
  32. EndWeek string `description:"结束日期对应周"`
  33. }
  34. type RsCalendar struct {
  35. RsCalendarId int `orm:"column(rs_calendar_id);pk"`
  36. SysUserId int `description:"创建人id"`
  37. SysUserRealName string `description:"创建人名称"`
  38. ActivityType string `description:"活动类型"`
  39. RoadshowType string `description:"路演形式"`
  40. RoadshowPlatform string `description:"路演平台"`
  41. CompanyId int `description:"客户id"`
  42. CompanyName string `description:"客户名称"`
  43. Province string `description:"省"`
  44. ProvinceCode string `description:"省编码"`
  45. City string `description:"市"`
  46. CityCode string `description:"市编码"`
  47. Theme string `description:"会议主题"`
  48. CooperationName string `description:"合作方名称"`
  49. Title string `description:"展示在日历的标题"`
  50. Source int8 `description:"来源,0:自系统,1:上海方的"`
  51. CreateTime time.Time
  52. ModifyTime time.Time
  53. ActivityCategory string `description:"活动类别"`
  54. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  55. UnionCode string `description:"公开会议联合编码"`
  56. EnglishCompany int `description:"是否为英文客户: 0-否; 1-是"`
  57. }
  58. type RsCalendarResearcher struct {
  59. RsCalendarResearcherId int `orm:"column(rs_calendar_researcher_id);pk"`
  60. RsCalendarId 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. CreateTime time.Time
  70. ModifyTime time.Time
  71. Status int `description:"状态:1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束"`
  72. RefuseReason string `description:"拒绝理由"`
  73. RefuseTime time.Time `description:"拒绝时间"`
  74. DeleteReason string `description:"删除理由"`
  75. DeleteTime time.Time `description:"删除时间"`
  76. ApproveTime time.Time `description:"接受时间"`
  77. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  78. ResearcherSort int `description:"研究员新增排序"`
  79. }
  80. func GetRsCalendarById(rsCalendarId int) (item *RsCalendar, err error) {
  81. o := orm.NewOrm()
  82. sql := `SELECT * FROM rs_calendar WHERE rs_calendar_id=? `
  83. err = o.Raw(sql, rsCalendarId).QueryRow(&item)
  84. return
  85. }
  86. func GetRsCalendarResearcherById(rsCalendarResearcherId int) (item *RsCalendarResearcher, err error) {
  87. o := orm.NewOrm()
  88. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_researcher_id=? `
  89. err = o.Raw(sql, rsCalendarResearcherId).QueryRow(&item)
  90. return
  91. }
  92. func GetRsCalendarResearcherListById(rsCalendarId int) (item []*RsCalendarResearcher, err error) {
  93. o := orm.NewOrm()
  94. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  95. _, err = o.Raw(sql, rsCalendarId).QueryRows(&item)
  96. return
  97. }
  98. func GetRsCalendarResearcherListByCalendarResearcherId(rsCalendarResearcherId int) (item []*RsCalendarResearcher, err error) {
  99. o := orm.NewOrm()
  100. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_researcher_id=? `
  101. _, err = o.Raw(sql, rsCalendarResearcherId).QueryRows(&item)
  102. return
  103. }
  104. type Researcher struct {
  105. AdminId int `description:"研究员id"`
  106. RealName string `description:"研究员名称"`
  107. GroupId int `description:"分组id"`
  108. GroupName string `description:"分组名称"`
  109. RoleTypeCode string `description:"角色编码"`
  110. }
  111. type ResearcherGroup struct {
  112. GroupId int `description:"分组id"`
  113. GroupName string `description:"分组名称"`
  114. ResearcherList []*Researcher
  115. }
  116. type CalendarListView struct {
  117. RsCalendarId int `orm:"column(rs_calendar_id);pk"`
  118. SysUserId int `description:"创建人id"`
  119. SysUserRealName string `description:"创建人名称"`
  120. ActivityType string `description:"活动类型"`
  121. RoadshowType string `description:"路演形式"`
  122. RoadshowPlatform string `description:"路演平台"`
  123. CompanyId int `description:"客户id"`
  124. CompanyName string `description:"客户名称"`
  125. CompanyStatus string `description:"客户状态"`
  126. RsCalendarResearcherId int `description:"活动研究员id"`
  127. ResearcherId string `description:"研究员id"`
  128. ResearcherName string `description:"研究员名称"`
  129. StartDate string `description:"开始日期"`
  130. EndDate string `description:"结束日期"`
  131. StartTime string `description:"开始时间"`
  132. EndTime string `description:"结束时间"`
  133. StartWeek string `description:"开始日期对应周"`
  134. EndWeek string `description:"结束日期对应周"`
  135. CreateTime time.Time
  136. ModifyTime time.Time
  137. Status int `description:"状态:1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回"`
  138. RefuseReason string `description:"拒绝理由"`
  139. RefuseTime time.Time `description:"拒绝时间"`
  140. DeleteReason string `description:"删除原因"`
  141. Province string `description:"省"`
  142. ProvinceCode string `description:"省编码"`
  143. City string `description:"市"`
  144. CityCode string `description:"市编码"`
  145. Theme string `description:"会议主题"`
  146. CooperationName string `description:"合作方名称"`
  147. ActivityCategory string `description:"活动类别"`
  148. Source int `description:"来源,0:自系统,1:上海方的"`
  149. Title string `description:"活动标题"`
  150. EnglishCompany int `description:"是否为英文客户: 0-否; 1-是"`
  151. EnglishCountry string `description:"英文客户-国家"`
  152. EnglishViewTotal int `description:"英文客户-累计点击量"`
  153. }
  154. type CalendarListResp struct {
  155. Paging *paging.PagingItem
  156. List []*CalendarListView
  157. }
  158. func GetCalendarListCount(condition string, pars []interface{}) (count int, err error) {
  159. o := orm.NewOrm()
  160. sql := `SELECT COUNT(1) AS count FROM rs_calendar AS a
  161. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  162. WHERE 1=1 `
  163. if condition != "" {
  164. sql += condition
  165. }
  166. err = o.Raw(sql, pars).QueryRow(&count)
  167. return
  168. }
  169. func GetCalendarList(condition string, pars []interface{}, status int, pageLimit ...int) (list []*CalendarListView, err error) {
  170. o := orm.NewOrm()
  171. sql := `SELECT * FROM rs_calendar AS a
  172. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  173. `
  174. if condition != "" {
  175. sql += condition
  176. }
  177. if status == 1 {
  178. sql += ` ORDER BY b.create_time ASC LIMIT ?,? `
  179. } else {
  180. sql += ` ORDER BY b.create_time DESC LIMIT ?,? `
  181. }
  182. _, err = o.Raw(sql, pars, pageLimit).QueryRows(&list)
  183. return
  184. }
  185. type AcceptReq struct {
  186. RsCalendarId int `description:"日历活动id"`
  187. RsCalendarResearcherId int `description:"活动研究员id"`
  188. }
  189. type DeleteReq struct {
  190. RsCalendarId int `description:"日历活动id"`
  191. RsCalendarResearcherId int `description:"活动研究员id"`
  192. DeleteReason string `description:"删除原因"`
  193. }
  194. type RefuseReq struct {
  195. RsCalendarId int `description:"日历活动id"`
  196. RsCalendarResearcherId int `description:"活动研究员id"`
  197. RefuseReason string `description:"拒绝原因"`
  198. }
  199. // 更新
  200. func UpdateCalendarResearcher(where, updateParams map[string]interface{}) error {
  201. o := orm.NewOrm()
  202. ptrStructOrTableName := "rs_calendar_researcher"
  203. qs := o.QueryTable(ptrStructOrTableName)
  204. for expr, exprV := range where {
  205. qs = qs.Filter(expr, exprV)
  206. }
  207. _, err := qs.Update(updateParams)
  208. return err
  209. }
  210. // 更新
  211. func UpdateCalendarResearcherFromSH(item *RsCalendarResearcher) error {
  212. o := orm.NewOrm()
  213. _, err := o.Update(item, "")
  214. return err
  215. }
  216. type AddMattersReq struct {
  217. StartDate string `description:"开始日期"`
  218. EndDate string `description:"结束日期"`
  219. StartTime string `description:"开始时间"`
  220. EndTime string `description:"结束时间"`
  221. StartWeek string `description:"开始日期周"`
  222. EndWeek string `description:"结束日期周"`
  223. MatterContent string `description:"事项内容"`
  224. }
  225. type RsMatters struct {
  226. RsMattersId int `orm:"column(rs_matters_id);pk"`
  227. SysUserId int `description:"添加事项人id"`
  228. SysUserRealName string `description:"创建人姓名"`
  229. StartDate string `description:"开始日期"`
  230. EndDate string `description:"结束日期"`
  231. StartTime string `description:"开始时间"`
  232. EndTime string `description:"结束时间"`
  233. StartWeek string `description:"开始日期周"`
  234. EndWeek string `description:"结束日期周"`
  235. MatterContent string `description:"事项内容"`
  236. Status int8 `description:"状态:1:进行中,6:已结束"`
  237. CreateTime time.Time `description:"创建时间"`
  238. ModifyTime time.Time `description:"修改时间"`
  239. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  240. }
  241. type UpdateMattersReq struct {
  242. RsMattersId int `orm:"column(rs_matters_id);pk"`
  243. StartDate string `description:"开始日期"`
  244. EndDate string `description:"结束日期"`
  245. StartTime string `description:"开始时间"`
  246. EndTime string `description:"结束时间"`
  247. StartWeek string `description:"开始日期周"`
  248. EndWeek string `description:"结束日期周"`
  249. MatterContent string `description:"事项内容"`
  250. }
  251. type CalendarDetailResp struct {
  252. RsCalendarItem *RsCalendar
  253. RsCalendarResearcherItem *RsCalendarResearcher
  254. CompanyDetail *CompanyDetailView
  255. }
  256. type MattersListResp struct {
  257. Paging *paging.PagingItem
  258. List []*RsMattersView
  259. }
  260. type RsMattersView struct {
  261. RsMattersId int `orm:"column(rs_matters_id);pk"`
  262. SysUserId int `description:"添加事项人id"`
  263. SysUserRealName string `description:"创建人姓名"`
  264. StartDate string `description:"开始日期"`
  265. EndDate string `description:"结束日期"`
  266. StartTime string `description:"开始时间"`
  267. EndTime string `description:"结束时间"`
  268. StartWeek string `description:"开始日期周"`
  269. EndWeek string `description:"结束日期周"`
  270. MatterContent string `description:"事项内容"`
  271. Status int8 `description:"状态:1:进行中,6:已结束"`
  272. CreateTime string `description:"创建时间"`
  273. ModifyTime string `description:"修改时间"`
  274. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  275. }
  276. func GetMattersListCount(condition string, pars []interface{}) (count int, err error) {
  277. o := orm.NewOrm()
  278. sql := `SELECT COUNT(1) AS count FROM rs_matters AS a
  279. WHERE 1=1 `
  280. if condition != "" {
  281. sql += condition
  282. }
  283. err = o.Raw(sql, pars).QueryRow(&count)
  284. return
  285. }
  286. func GetMattersList(condition string, pars []interface{}, pageLimit ...int) (list []*RsMattersView, err error) {
  287. o := orm.NewOrm()
  288. sql := `SELECT * FROM rs_matters AS a
  289. WHERE 1=1 `
  290. if condition != "" {
  291. sql += condition
  292. }
  293. sql += ` ORDER BY a.create_time DESC LIMIT ?,? `
  294. _, err = o.Raw(sql, pars, pageLimit).QueryRows(&list)
  295. return
  296. }
  297. type DeleteMattersReq struct {
  298. RsMattersId int `description:"事项id"`
  299. }
  300. // 删除事项
  301. func DeleteRsMatters(rsMattersId int) (err error) {
  302. o := orm.NewOrm()
  303. sql := ` DELETE FROM rs_matters WHERE rs_matters_id=? `
  304. _, err = o.Raw(sql, rsMattersId).Exec()
  305. return err
  306. }
  307. func CheckMattersCount(condition string, pars []interface{}) (count int, err error) {
  308. o := orm.NewOrm()
  309. sql := `SELECT COUNT(1) AS count FROM rs_matters AS a
  310. WHERE 1=1 `
  311. if condition != "" {
  312. sql += condition
  313. }
  314. err = o.Raw(sql, pars).QueryRow(&count)
  315. return
  316. }
  317. func GetResearcherFromAdmin(condition string, pars []interface{}) (lists []*admin.Admin, err error) {
  318. o := orm.NewOrm()
  319. sql := `SELECT * FROM admin WHERE 1=1 `
  320. if condition != "" {
  321. sql += condition
  322. }
  323. _, err = o.Raw(sql, pars).QueryRows(&lists)
  324. return
  325. }
  326. // 更新活动信息
  327. func UpdateRsCalendar(where, updateParams map[string]interface{}) error {
  328. o := orm.NewOrm()
  329. ptrStructOrTableName := "rs_calendar"
  330. qs := o.QueryTable(ptrStructOrTableName)
  331. for expr, exprV := range where {
  332. qs = qs.Filter(expr, exprV)
  333. }
  334. _, err := qs.Update(updateParams)
  335. return err
  336. }
  337. // 更新
  338. func UpdateRsMatters(where, updateParams map[string]interface{}) error {
  339. o := orm.NewOrm()
  340. ptrStructOrTableName := "rs_matters"
  341. qs := o.QueryTable(ptrStructOrTableName)
  342. for expr, exprV := range where {
  343. qs = qs.Filter(expr, exprV)
  344. }
  345. _, err := qs.Update(updateParams)
  346. return err
  347. }
  348. type EditActivityReq struct {
  349. EditType int `description:"修改方式: 1:修改,2:修改重提"`
  350. RsCalendarId int `description:"路演活动id"`
  351. RsCalendarResearcherId int `description:"活动研究员id"`
  352. ActivityType string `description:"活动类型"`
  353. RoadshowType string `description:"路演形式"`
  354. RoadshowPlatform string `description:"路演平台"`
  355. CompanyId int `description:"客户id"`
  356. CompanyName string `description:"客户名称"`
  357. Province string `description:"省"`
  358. ProvinceCode string `description:"省编码"`
  359. City string `description:"市"`
  360. CityCode string `description:"市编码"`
  361. Theme string `description:"会议主题"`
  362. CooperationName string `description:"合作方名称"`
  363. ActivityCategory string `description:"活动类别"`
  364. ResearcherList []*CalendarResearcher
  365. EnglishCompany int `description:"是否为英文客户"`
  366. }
  367. // GetRsCalendarResearcherListByRsCalendarId 根据路演id获取路演研究员列表
  368. func GetRsCalendarResearcherListByRsCalendarId(rsCalendarId int) (items []*RsCalendarResearcher, err error) {
  369. o := orm.NewOrm()
  370. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  371. _, err = o.Raw(sql, rsCalendarId).QueryRows(&items)
  372. return
  373. }
  374. func CheckCalendarResearcherCount(condition string, pars []interface{}) (count int, err error) {
  375. o := orm.NewOrm()
  376. sql := `SELECT COUNT(1) AS count FROM rs_calendar_researcher AS a
  377. WHERE 1=1 `
  378. if condition != "" {
  379. sql += condition
  380. }
  381. err = o.Raw(sql, pars).QueryRow(&count)
  382. return
  383. }
  384. func GetMattersById(rsMatters int) (item *RsMatters, err error) {
  385. o := orm.NewOrm()
  386. sql := `SELECT * FROM rs_matters
  387. WHERE rs_matters_id=? `
  388. err = o.Raw(sql, rsMatters).QueryRow(&item)
  389. return
  390. }
  391. // 添加RsCalendarResearcher
  392. func AddRsMatters(item *RsMatters) (id int64, err error) {
  393. o := orm.NewOrm()
  394. id, err = o.Insert(item)
  395. return
  396. }
  397. // 添加RsCalendar
  398. func AddRsCalendar(item *RsCalendar) (lastId int64, err error) {
  399. o := orm.NewOrm()
  400. lastId, err = o.Insert(item)
  401. return
  402. }
  403. // 添加RsCalendarResearcher
  404. func AddRsCalendarResearcher(item *RsCalendarResearcher) (lastId int64, err error) {
  405. o := orm.NewOrm()
  406. lastId, err = o.Insert(item)
  407. return
  408. }
  409. func GetRsCalendarResearcherByRsCalendarIdAndResearcherId(rsCalendarId, researcherId int) (item *RsCalendarResearcher, err error) {
  410. o := orm.NewOrm()
  411. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? AND researcher_id=? `
  412. err = o.Raw(sql, rsCalendarId, researcherId).QueryRow(&item)
  413. return
  414. }
  415. func GetRsCalendarResearcherByCalendarId(rsCalendarId int) (item []*RsCalendarResearcher, err error) {
  416. o := orm.NewOrm()
  417. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  418. _, err = o.Raw(sql, rsCalendarId).QueryRows(&item)
  419. return
  420. }
  421. // 删除
  422. func DeleteRsCalendarResearcher(rsCalendarId int) (err error) {
  423. o := orm.NewOrm()
  424. sql := ` DELETE FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  425. _, err = o.Raw(sql, rsCalendarId).Exec()
  426. return err
  427. }
  428. func GetResearcherGroup() (list []*ResearcherGroup, err error) {
  429. o := orm.NewOrm()
  430. sql := ` SELECT group_id,group_name FROM admin AS a
  431. WHERE a.role_type_code IN('researcher','ficc_researcher','ficc_admin')
  432. AND a.enabled=1
  433. AND a.group_id>0
  434. AND a.group_name<>'无'
  435. GROUP BY a.group_id
  436. ORDER BY a.group_id ASC `
  437. _, err = o.Raw(sql).QueryRows(&list)
  438. return
  439. }
  440. func GetResearcher() (list []*Researcher, err error) {
  441. o := orm.NewOrm()
  442. sql := ` SELECT * FROM admin AS a
  443. WHERE a.role_type_code IN('researcher','rai_researcher','ficc_researcher','ficc_admin')
  444. AND a.enabled=1 AND a.real_name<>'于菲' `
  445. _, err = o.Raw(sql).QueryRows(&list)
  446. return
  447. }
  448. // 删除
  449. func DeleteCalendar(rsCalendarId, rsCalendarResearcherId int) (err error) {
  450. o := orm.NewOrm()
  451. sql := ` DELETE FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  452. _, err = o.Raw(sql, rsCalendarId).Exec()
  453. if err != nil {
  454. return err
  455. }
  456. //var count int
  457. //sql = ` SELECT COUNT(1) AS count FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  458. //err = o.Raw(sql, rsCalendarId).QueryRow(&count)
  459. //if err != nil && err.Error() != utils.ErrNoRow() {
  460. // return err
  461. //}
  462. //if count <= 0 {
  463. // sql := ` DELETE FROM rs_calendar WHERE rs_calendar_id=? `
  464. // _, err = o.Raw(sql, rsCalendarId).Exec()
  465. // if err != nil {
  466. // return err
  467. // }
  468. //}
  469. sql = ` DELETE FROM rs_calendar WHERE rs_calendar_id=? `
  470. _, err = o.Raw(sql, rsCalendarId).Exec()
  471. if err != nil {
  472. return err
  473. }
  474. return err
  475. }
  476. type ActivityTypeList struct {
  477. ActivityTypeId int `description:"活动类型ID"`
  478. ActivityTypeName string `description:"活动类型名称"`
  479. Pid int `description:"父级id,默认是:0"`
  480. Sort int `description:"排序字段"`
  481. FrontIsShow int8 `description:"是否在前台展示,0:不展示,1:展示"`
  482. CreateTime time.Time `description:"创建时间"`
  483. ChildList []*ActivityTypeList `description:"下级活动类型列表"`
  484. }
  485. // GetActivityTypeListByActivityTypePId 根据上级id获取活动分类列表
  486. func GetActivityTypeListByActivityTypePId(pid int) (list []*ActivityTypeList, err error) {
  487. o := orm.NewOrm()
  488. sql := `select * from yb_activity_type where pid=? order by sort asc ,activity_type_id asc`
  489. _, err = o.Raw(sql, pid).QueryRows(&list)
  490. return
  491. }
  492. type CalendarPanelDetailResp struct {
  493. CalendarList []*CalendarListView
  494. RsMattersList []*RsMatters
  495. }
  496. func GetCalendarDetailList(condition string, pars []interface{}) (list []*CalendarListView, err error) {
  497. o := orm.NewOrm()
  498. sql := `SELECT a.*,b.*,c.status AS company_status FROM rs_calendar AS a
  499. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  500. LEFT JOIN company_product AS c ON a.company_id=c.company_id AND c.product_id=1
  501. WHERE 1=1 `
  502. if condition != "" {
  503. sql += condition
  504. }
  505. sql += ` ORDER BY a.create_time DESC `
  506. _, err = o.Raw(sql, pars).QueryRows(&list)
  507. return
  508. }
  509. func GetRsMattersList(startDate, endDate string, researcherId int) (list []*RsMatters, err error) {
  510. o := orm.NewOrm()
  511. //sql := `SELECT * FROM rs_matters AS a WHERE a.start_date>=? AND a.end_date<=? AND sys_user_id=? `
  512. //sql := `SELECT * FROM rs_matters AS a WHERE a.end_date>=? AND sys_user_id=? `
  513. sql := `SELECT * FROM rs_matters AS a WHERE sys_user_id=? `
  514. sql += ` ORDER BY a.create_time DESC `
  515. _, err = o.Raw(sql, researcherId).QueryRows(&list)
  516. return
  517. }
  518. func GetCalendarTypeList(condition string, pars []interface{}, startSize, pageSize int) (list []*CalendarListView, err error) {
  519. o := orm.NewOrm()
  520. sql := ` SELECT a.rs_calendar_id,a.activity_type,a.roadshow_type,a.activity_category,a.roadshow_platform,b.create_time,
  521. b.modify_time,GROUP_CONCAT(b.researcher_id ORDER BY researcher_sort ASC) AS researcher_id,GROUP_CONCAT(b.researcher_name ORDER BY researcher_sort ASC) AS researcher_name,
  522. b.rs_calendar_researcher_id,b.start_date,
  523. b.end_date,b.start_time,b.end_time,b.start_week,b.end_week,b.status,b.refuse_reason,b.refuse_time,
  524. b.delete_reason,a.sys_user_real_name,a.city,a.province,a.company_name,a.company_id,
  525. a.cooperation_name,a.theme,a.activity_category
  526. FROM rs_calendar AS a
  527. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  528. WHERE 1=1
  529. `
  530. if condition != "" {
  531. sql += condition
  532. }
  533. sql += ` GROUP BY a.rs_calendar_id
  534. ORDER BY b.create_time DESC LIMIT ?,? `
  535. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  536. return
  537. }
  538. func GetCalendarTypeListCount(condition string, pars []interface{}) (count int, err error) {
  539. o := orm.NewOrm()
  540. sql := `SELECT COUNT(1) AS count FROM(SELECT COUNT(1) AS count
  541. FROM rs_calendar AS a
  542. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  543. WHERE 1=1 `
  544. if condition != "" {
  545. sql += condition
  546. }
  547. sql += ` GROUP BY a.rs_calendar_id ) AS t `
  548. err = o.Raw(sql, pars).QueryRow(&count)
  549. return
  550. }