calendar.go 23 KB

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