calendar.go 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. package roadshow
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hz_crm_api/models/company"
  7. "hongze/hz_crm_api/models/system"
  8. "hongze/hz_crm_api/utils"
  9. "strings"
  10. "time"
  11. )
  12. type AddActivityReq struct {
  13. ActivityType string `description:"活动类型"`
  14. RoadshowType string `description:"路演形式"`
  15. RoadshowPlatform string `description:"路演平台"`
  16. CompanyId int `description:"客户id"`
  17. CompanyName string `description:"客户名称"`
  18. Province string `description:"省"`
  19. ProvinceCode string `description:"省编码"`
  20. City string `description:"市"`
  21. CityCode string `description:"市编码"`
  22. District string `description:"区"`
  23. Theme string `description:"会议主题"`
  24. CooperationName string `description:"合作方名称"`
  25. ActivityCategory string `description:"活动类别"`
  26. ResearcherList []*CalendarResearcher
  27. EnglishCompany int `description:"是否为英文客户"`
  28. }
  29. type CalendarResearcher struct {
  30. ResearcherId int `description:"研究员id"`
  31. ResearcherName string `description:"研究员名称"`
  32. StartDate string `description:"开始日期"`
  33. EndDate string `description:"结束日期"`
  34. StartTime string `description:"开始时间"`
  35. EndTime string `description:"结束时间"`
  36. StartWeek string `description:"开始日期对应周"`
  37. EndWeek string `description:"结束日期对应周"`
  38. }
  39. type RsCalendar struct {
  40. RsCalendarId int `orm:"column(rs_calendar_id);pk"`
  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. District 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. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  61. UnionCode string `description:"公开会议联合编码"`
  62. EnglishCompany int `description:"是否为英文客户: 0-否; 1-是"`
  63. }
  64. type RsCalendarResearcher struct {
  65. RsCalendarResearcherId int `orm:"column(rs_calendar_researcher_id);pk"`
  66. RsCalendarId int `description:"日历活动id"`
  67. ResearcherId int `description:"研究员id"`
  68. ResearcherName string `description:"研究员名称"`
  69. StartDate string `description:"开始日期"`
  70. EndDate string `description:"结束日期"`
  71. StartTime string `description:"开始时间"`
  72. EndTime string `description:"结束时间"`
  73. StartWeek string `description:"开始日期对应周"`
  74. EndWeek string `description:"结束日期对应周"`
  75. CreateTime time.Time
  76. ModifyTime time.Time
  77. Status int `description:"状态:1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束"`
  78. RefuseReason string `description:"拒绝理由"`
  79. RefuseTime time.Time `description:"拒绝时间"`
  80. DeleteReason string `description:"删除理由"`
  81. DeleteTime time.Time `description:"删除时间"`
  82. ApproveTime time.Time `description:"接受时间"`
  83. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  84. ResearcherSort int `description:"研究员新增排序"`
  85. UnionCode string `description:"公开会议联合编码"`
  86. }
  87. func GetRsCalendarById(rsCalendarId int) (item *RsCalendar, err error) {
  88. o := orm.NewOrm()
  89. sql := `SELECT * FROM rs_calendar WHERE rs_calendar_id=? `
  90. err = o.Raw(sql, rsCalendarId).QueryRow(&item)
  91. return
  92. }
  93. func GetRsCalendarResearcherById(rsCalendarResearcherId int) (item *RsCalendarResearcher, err error) {
  94. o := orm.NewOrm()
  95. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_researcher_id=? `
  96. err = o.Raw(sql, rsCalendarResearcherId).QueryRow(&item)
  97. return
  98. }
  99. // Update 更新路演用户信息
  100. func (item *RsCalendarResearcher) Update(cols []string) (err error) {
  101. o := orm.NewOrm()
  102. _, err = o.Update(item, cols...)
  103. return
  104. }
  105. func GetRsCalendarResearcherListById(rsCalendarId int) (item []*RsCalendarResearcher, err error) {
  106. o := orm.NewOrm()
  107. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  108. _, err = o.Raw(sql, rsCalendarId).QueryRows(&item)
  109. return
  110. }
  111. // 根据多个路演ID获取研究员信息
  112. func GetRsCalendarResearcherListByIds(rsCalendarIds []int) (item []*RsCalendarResearcher, err error) {
  113. if len(rsCalendarIds) == 0 {
  114. return
  115. }
  116. o := orm.NewOrm()
  117. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id IN (` + utils.GetOrmInReplace(len(rsCalendarIds)) + `) `
  118. _, err = o.Raw(sql, rsCalendarIds).QueryRows(&item)
  119. return
  120. }
  121. func GetRsCalendarResearcherListByCalendarResearcherId(rsCalendarResearcherId int) (item []*RsCalendarResearcher, err error) {
  122. o := orm.NewOrm()
  123. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_researcher_id=? `
  124. _, err = o.Raw(sql, rsCalendarResearcherId).QueryRows(&item)
  125. return
  126. }
  127. // 添加RsCalendar
  128. func AddRsCalendar(item *RsCalendar) (lastId int64, err error) {
  129. o := orm.NewOrm()
  130. lastId, err = o.Insert(item)
  131. return
  132. }
  133. // 添加RsCalendarResearcher
  134. func AddRsCalendarResearcher(item *RsCalendarResearcher) (lastId int64, err error) {
  135. o := orm.NewOrm()
  136. lastId, err = o.Insert(item)
  137. return
  138. }
  139. // 添加RsCalendarResearcher
  140. func AddRsCalendarResearcherFromSH(item *RsCalendarResearcher) (bool bool, id int64, err error) {
  141. o := orm.NewOrm()
  142. bool, id, err = o.ReadOrCreate(item, "rs_calendar_id")
  143. return
  144. }
  145. type Researcher struct {
  146. AdminId int `description:"研究员id"`
  147. RealName string `description:"研究员名称"`
  148. GroupId int `description:"分组id"`
  149. GroupName string `description:"分组名称"`
  150. RoleTypeCode string `description:"角色编码"`
  151. }
  152. type ResearcherIds struct {
  153. AdminIds string `description:"研究员id"`
  154. }
  155. type ResearcherGroup struct {
  156. GroupId int `description:"分组id"`
  157. GroupName string `description:"分组名称"`
  158. AdminId int `description:"研究员id"`
  159. RealName string `description:"研究员名称"`
  160. RoleTypeCode string `description:"角色编码"`
  161. ResearcherList []*ResearcherGroup
  162. }
  163. func GetResearcherGroup() (list []*ResearcherGroup, err error) {
  164. o := orm.NewOrm()
  165. sql := ` SELECT group_id,group_name FROM admin AS a
  166. WHERE a.role_type_code IN('researcher','ficc_researcher','ficc_admin')
  167. AND a.enabled=1
  168. AND a.group_id>0
  169. AND a.group_name<>'无'
  170. GROUP BY a.group_id
  171. ORDER BY a.group_id ASC `
  172. _, err = o.Raw(sql).QueryRows(&list)
  173. return
  174. }
  175. func GetResearcher() (list []*ResearcherGroup, err error) {
  176. o := orm.NewOrm()
  177. sql := ` SELECT * FROM admin AS a
  178. WHERE a.role_type_code IN('researcher','rai_researcher','ficc_researcher','ficc_admin')
  179. AND a.enabled=1 AND a.real_name<>'于菲' `
  180. _, err = o.Raw(sql).QueryRows(&list)
  181. return
  182. }
  183. func GetChoiceResearcher(adminIds string) (list []*Researcher, err error) {
  184. o := orm.NewOrm()
  185. sql := ` SELECT * FROM admin WHERE admin_id IN ( ` + adminIds + ` ); `
  186. _, err = o.Raw(sql).QueryRows(&list)
  187. return
  188. }
  189. // GetResearcherV2 获取研究员列表(冻结的也要)
  190. func GetResearcherV2() (list []*ResearcherGroup, err error) {
  191. o := orm.NewOrm()
  192. sql := ` SELECT * FROM admin AS a
  193. WHERE a.role_type_code IN('researcher','rai_researcher','ficc_researcher','ficc_admin')
  194. AND a.enabled=1 and admin_id !=92 `
  195. _, err = o.Raw(sql).QueryRows(&list)
  196. return
  197. }
  198. // GetSellerGroup 获取销售分组
  199. func GetSellerGroup() (list []*ResearcherGroup, err error) {
  200. o := orm.NewOrm()
  201. sql := ` SELECT group_id,group_name FROM admin AS a
  202. WHERE a.role_type_code IN('ficc_seller','ficc_group')
  203. AND a.enabled=1
  204. AND a.group_id>0
  205. AND a.group_name<>'无'
  206. GROUP BY a.group_id
  207. ORDER BY a.group_id ASC `
  208. _, err = o.Raw(sql).QueryRows(&list)
  209. return
  210. }
  211. // GetSellerList 获取销售列表(冻结的也要)
  212. func GetSellerList(roleTypeCode string, groupIds string) (list []*Researcher, err error) {
  213. o := orm.NewOrm()
  214. sql := ` SELECT * FROM admin AS a
  215. WHERE a.role_type_code IN ` + roleTypeCode + `
  216. AND a.enabled=1 `
  217. if groupIds != "" {
  218. sql += "and group_id in " + groupIds
  219. }
  220. _, err = o.Raw(sql).QueryRows(&list)
  221. return
  222. }
  223. // GetRaiSellerList 获取权益销售列表(冻结的也要)
  224. func GetRaiSellerList(roleTypeCode string, groupIds string) (list []*Researcher, err error) {
  225. o := orm.NewOrm()
  226. sql := ` SELECT * FROM admin AS a
  227. WHERE a.role_type_code IN ` + roleTypeCode + `
  228. AND a.enabled=1 `
  229. if groupIds != "" {
  230. sql += "and group_id in " + groupIds
  231. }
  232. _, err = o.Raw(sql).QueryRows(&list)
  233. return
  234. }
  235. type CalendarListView struct {
  236. RsCalendarId int `orm:"column(rs_calendar_id);pk"`
  237. SysUserId int `description:"创建人id"`
  238. SysUserRealName string `description:"创建人名称"`
  239. ActivityType string `description:"活动类型"`
  240. RoadshowType string `description:"路演形式"`
  241. RoadshowPlatform string `description:"路演平台"`
  242. CompanyId int `description:"客户id"`
  243. CompanyName string `description:"客户名称"`
  244. RsCalendarResearcherId int `description:"活动研究员id"`
  245. ResearcherId string `description:"研究员id"`
  246. ResearcherName string `description:"研究员名称"`
  247. StartDate string `description:"开始日期"`
  248. EndDate string `description:"结束日期"`
  249. StartTime string `description:"开始时间"`
  250. EndTime string `description:"结束时间"`
  251. StartWeek string `description:"开始日期对应周"`
  252. EndWeek string `description:"结束日期对应周"`
  253. CreateTime string
  254. ModifyTime string
  255. Status int `description:"状态:1:待接受,2:已接受,3:已拒绝,4:已删除,5:已撤回,6:已结束"`
  256. RefuseReason string `description:"拒绝理由"`
  257. RefuseTime string `description:"拒绝时间"`
  258. DeleteReason string `description:"删除原因"`
  259. Province string `description:"省"`
  260. ProvinceCode string `description:"省编码"`
  261. City string `description:"市"`
  262. CityCode string `description:"市编码"`
  263. District string `description:"区"`
  264. Theme string `description:"会议主题"`
  265. CooperationName string `description:"合作方名称"`
  266. ActivityCategory string `description:"活动类别"`
  267. Source int `description:"来源,0:自系统,1:上海方的"`
  268. Title string `description:"日历展示标题"`
  269. CompanyStatus string `description:"新增客户状态"`
  270. UnionCode string `description:"公开会议联合编码"`
  271. EnglishCompany int `description:"是否为英文客户: 0-否; 1-是"`
  272. EnglishCountry string `description:"英文客户-国家"`
  273. EnglishViewTotal int `description:"英文客户-累计点击量"`
  274. SubmitButton bool `description:"提交按钮是否展示"`
  275. ViewButton bool `description:"查看按钮是否展示"`
  276. }
  277. type CalendarListResp struct {
  278. Paging *paging.PagingItem
  279. List []*CalendarListView
  280. }
  281. func GetCalendarListCount(condition string, pars []interface{}, calendarType int) (count int, err error) {
  282. o := orm.NewOrm()
  283. if calendarType == 3 || calendarType == 4 {
  284. sql := `SELECT COUNT(1) AS count FROM(SELECT COUNT(1) AS count
  285. FROM rs_calendar AS a
  286. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  287. WHERE 1=1 `
  288. if condition != "" {
  289. sql += condition
  290. }
  291. sql += ` GROUP BY a.rs_calendar_id ) AS t `
  292. err = o.Raw(sql, pars).QueryRow(&count)
  293. } else {
  294. sql := `SELECT COUNT(1) AS count FROM rs_calendar AS a
  295. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  296. WHERE 1=1 `
  297. if condition != "" {
  298. sql += condition
  299. }
  300. err = o.Raw(sql, pars).QueryRow(&count)
  301. }
  302. return
  303. }
  304. func GetCalendarList(condition string, pars []interface{}, startSize, pageSize, calendarType int) (list []*CalendarListView, err error) {
  305. o := orm.NewOrm()
  306. if calendarType == 3 || calendarType == 4 {
  307. sql := ` SELECT a.rs_calendar_id,a.activity_type,a.roadshow_type,a.activity_category,a.roadshow_platform,b.create_time,a.district,
  308. 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,
  309. b.rs_calendar_researcher_id,b.start_date,
  310. b.end_date,b.start_time,b.end_time,b.start_week,b.end_week,b.status,b.refuse_reason,b.refuse_time,
  311. b.delete_reason,a.sys_user_real_name,a.city,a.province,a.company_name,a.company_id,
  312. a.cooperation_name,a.theme,a.activity_category,a.english_company
  313. FROM rs_calendar AS a
  314. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  315. WHERE 1=1
  316. `
  317. if condition != "" {
  318. sql += condition
  319. }
  320. if calendarType == 1 {
  321. sql += ` GROUP BY a.rs_calendar_id
  322. ORDER BY b.create_time ASC LIMIT ?,? `
  323. } else {
  324. sql += ` GROUP BY a.rs_calendar_id
  325. ORDER BY b.create_time DESC LIMIT ?,? `
  326. }
  327. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  328. } else {
  329. sql := `SELECT a.rs_calendar_id,a.activity_type,a.roadshow_type,a.activity_category,a.roadshow_platform,b.create_time,a.district,a.sys_user_id,
  330. b.modify_time,b.researcher_id,b.researcher_name,
  331. b.rs_calendar_researcher_id,b.start_date,
  332. b.end_date,b.start_time,b.end_time,b.start_week,b.end_week,b.status,b.refuse_reason,b.refuse_time,
  333. b.delete_reason,a.sys_user_real_name,a.city,a.province,a.company_name,a.company_id,a.cooperation_name,a.theme,a.activity_category,a.english_company
  334. FROM rs_calendar AS a
  335. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  336. WHERE 1=1 `
  337. if condition != "" {
  338. sql += condition
  339. }
  340. if calendarType == 1 {
  341. sql += ` ORDER BY b.create_time ASC LIMIT ?,? `
  342. } else {
  343. sql += ` ORDER BY b.create_time DESC LIMIT ?,? `
  344. }
  345. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  346. }
  347. return
  348. }
  349. type AcceptReq struct {
  350. RsCalendarId int `description:"日历活动id"`
  351. RsCalendarResearcherId int `description:"活动研究员id"`
  352. }
  353. type DeleteReq struct {
  354. RsCalendarId int `description:"日历活动id"`
  355. RsCalendarResearcherId int `description:"活动研究员id"`
  356. DeleteReason string `description:"删除原因"`
  357. }
  358. type RefuseReq struct {
  359. RsCalendarId int `description:"日历活动id"`
  360. RsCalendarResearcherId int `description:"活动研究员id"`
  361. RefuseReason string `description:"拒绝原因"`
  362. }
  363. // 更新
  364. func UpdateCalendarResearcher(where, updateParams map[string]interface{}) error {
  365. o := orm.NewOrm()
  366. ptrStructOrTableName := "rs_calendar_researcher"
  367. qs := o.QueryTable(ptrStructOrTableName)
  368. for expr, exprV := range where {
  369. qs = qs.Filter(expr, exprV)
  370. }
  371. _, err := qs.Update(updateParams)
  372. return err
  373. }
  374. // 更新
  375. func UpdateCalendarResearcherFromSH(item *RsCalendarResearcher) error {
  376. o := orm.NewOrm()
  377. _, err := o.Update(item, "")
  378. return err
  379. }
  380. type AddMattersReq struct {
  381. StartDate string `description:"开始日期"`
  382. EndDate string `description:"结束日期"`
  383. StartTime string `description:"开始时间"`
  384. EndTime string `description:"结束时间"`
  385. StartWeek string `description:"开始日期周"`
  386. EndWeek string `description:"结束日期周"`
  387. MatterContent string `description:"事项内容"`
  388. }
  389. type RsMatters struct {
  390. RsMattersId int `orm:"column(rs_matters_id);pk"`
  391. SysUserId int `description:"添加事项人id"`
  392. SysUserRealName string `description:"创建人姓名"`
  393. StartDate string `description:"开始日期"`
  394. EndDate string `description:"结束日期"`
  395. StartTime string `description:"开始时间"`
  396. EndTime string `description:"结束时间"`
  397. StartWeek string `description:"开始日期周"`
  398. EndWeek string `description:"结束日期周"`
  399. MatterContent string `description:"事项内容"`
  400. Status int8 `description:"状态:1:进行中,6:已结束"`
  401. CreateTime time.Time `description:"创建时间"`
  402. ModifyTime time.Time `description:"修改时间"`
  403. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  404. EditReason string `description:"修改原因"`
  405. IsSeller int `description:"是否为销售事项: 0-否; 1-是"`
  406. }
  407. // 添加RsCalendarResearcher
  408. func AddRsMatters(item *RsMatters) (id int64, err error) {
  409. o := orm.NewOrm()
  410. id, err = o.Insert(item)
  411. return
  412. }
  413. type UpdateMattersReq struct {
  414. RsMattersId int `orm:"column(rs_matters_id);pk"`
  415. StartDate string `description:"开始日期"`
  416. EndDate string `description:"结束日期"`
  417. StartTime string `description:"开始时间"`
  418. EndTime string `description:"结束时间"`
  419. StartWeek string `description:"开始日期周"`
  420. EndWeek string `description:"结束日期周"`
  421. MatterContent string `description:"事项内容"`
  422. EditReason string `description:"修改原因"`
  423. }
  424. // 更新
  425. func UpdateRsMatters(where, updateParams map[string]interface{}) error {
  426. o := orm.NewOrm()
  427. ptrStructOrTableName := "rs_matters"
  428. qs := o.QueryTable(ptrStructOrTableName)
  429. for expr, exprV := range where {
  430. qs = qs.Filter(expr, exprV)
  431. }
  432. _, err := qs.Update(updateParams)
  433. return err
  434. }
  435. type DeleteMattersReq struct {
  436. RsMattersId int `description:"事项id"`
  437. }
  438. // 删除事项
  439. func DeleteRsMatters(rsMattersId int) (err error) {
  440. o := orm.NewOrm()
  441. sql := ` DELETE FROM rs_matters WHERE rs_matters_id=? `
  442. _, err = o.Raw(sql, rsMattersId).Exec()
  443. return err
  444. }
  445. type RsMattersView struct {
  446. RsMattersId int `orm:"column(rs_matters_id);pk"`
  447. SysUserId int `description:"添加事项人id"`
  448. SysUserRealName string `description:"创建人姓名"`
  449. StartDate string `description:"开始日期"`
  450. EndDate string `description:"结束日期"`
  451. StartTime string `description:"开始时间"`
  452. EndTime string `description:"结束时间"`
  453. StartWeek string `description:"开始日期周"`
  454. EndWeek string `description:"结束日期周"`
  455. MatterContent string `description:"事项内容"`
  456. Status int8 `description:"状态:1:进行中,6:已结束"`
  457. CreateTime string `description:"创建时间"`
  458. ModifyTime string `description:"修改时间"`
  459. IsSynced int `description:"是否与上海同步 0:未同步 1:已同步"`
  460. EditReason string `description:"修改原因"`
  461. ButtonAuth RsMatterButton `description:"按钮权限"`
  462. }
  463. // RsMatterButton
  464. type RsMatterButton struct {
  465. EditDisabled bool `description:"禁用编辑"`
  466. RemoveDisabled bool `description:"禁用删除"`
  467. }
  468. func GetCalendarDetailList(condition string, pars []interface{}) (list []*CalendarListView, err error) {
  469. o := orm.NewOrm()
  470. sql := `SELECT a.*,b.*,c.status AS company_status FROM rs_calendar AS a
  471. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  472. LEFT JOIN company_product AS c ON a.company_id=c.company_id AND c.product_id=1
  473. WHERE 1=1 `
  474. if condition != "" {
  475. sql += condition
  476. }
  477. sql += ` ORDER BY a.create_time DESC `
  478. _, err = o.Raw(sql, pars).QueryRows(&list)
  479. return
  480. }
  481. func GetCalendarDetailListinit() (list []*CalendarListView, err error) {
  482. o := orm.NewOrm()
  483. sql := `SELECT
  484. a.rs_calendar_id,
  485. b.researcher_name , b.start_date , b.start_time,a.company_name ,sys_user_real_name
  486. FROM
  487. rs_calendar AS a
  488. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id = b.rs_calendar_id
  489. WHERE
  490. 1 = 1
  491. AND a.sys_user_id IN (SELECT admin_id FROM admin WHERE role_type_code IN ('rai_group','rai_seller') and role_id NOT IN (28,69,70) AND enabled = 1 )
  492. AND a.rs_calendar_id NOT IN (SELECT rs_calendar_id FROM rs_calendar_meeting_user GROUP BY rs_calendar_id )
  493. AND a.activity_type = '路演'
  494. AND b.start_date >= '2024-01-01'
  495. AND b.end_date <='2024-10-07'
  496. AND a.company_name !=''
  497. AND b.status IN (2,6)
  498. ORDER BY start_date ASC ,start_time ASC `
  499. _, err = o.Raw(sql).QueryRows(&list)
  500. return
  501. }
  502. func GetRsMattersList(startDate, endDate string, researcherId int) (list []*RsMatters, err error) {
  503. o := orm.NewOrm()
  504. //sql := `SELECT * FROM rs_matters AS a WHERE a.start_date>=? AND a.end_date<=? AND sys_user_id=? `
  505. sql := `SELECT * FROM rs_matters AS a WHERE sys_user_id=? `
  506. sql += ` ORDER BY a.create_time DESC `
  507. //_, err = o.Raw(sql, startDate, endDate, researcherId).QueryRows(&list)
  508. _, err = o.Raw(sql, researcherId).QueryRows(&list)
  509. return
  510. }
  511. type CalendarDetailResp struct {
  512. CalendarList []*CalendarListView
  513. RsMattersList []*RsMatters
  514. }
  515. type EditActivityReq struct {
  516. EditType int `description:"修改方式: 1:修改,2:修改重提"`
  517. RsCalendarId int `description:"路演活动id"`
  518. RsCalendarResearcherId int `description:"活动研究员id"`
  519. ActivityType string `description:"活动类型"`
  520. RoadshowType string `description:"路演形式"`
  521. RoadshowPlatform string `description:"路演平台"`
  522. CompanyId int `description:"客户id"`
  523. CompanyName string `description:"客户名称"`
  524. Province string `description:"省"`
  525. ProvinceCode string `description:"省编码"`
  526. City string `description:"市"`
  527. CityCode string `description:"市编码"`
  528. District string `description:"区"`
  529. Theme string `description:"会议主题"`
  530. CooperationName string `description:"合作方名称"`
  531. ActivityCategory string `description:"活动类别"`
  532. ResearcherList []*CalendarResearcher
  533. EnglishCompany int `description:"是否为英文客户"`
  534. }
  535. // 更新活动信息
  536. func UpdateRsCalendar(where, updateParams map[string]interface{}) error {
  537. o := orm.NewOrm()
  538. ptrStructOrTableName := "rs_calendar"
  539. qs := o.QueryTable(ptrStructOrTableName)
  540. for expr, exprV := range where {
  541. qs = qs.Filter(expr, exprV)
  542. }
  543. _, err := qs.Update(updateParams)
  544. return err
  545. }
  546. func GetMattersListCount(condition string, pars []interface{}) (count int, err error) {
  547. o := orm.NewOrm()
  548. sql := `SELECT COUNT(1) AS count FROM rs_matters AS a
  549. WHERE 1=1 `
  550. if condition != "" {
  551. sql += condition
  552. }
  553. err = o.Raw(sql, pars).QueryRow(&count)
  554. return
  555. }
  556. func GetMattersList(condition string, pars []interface{}, pageLimit ...int) (list []*RsMattersView, err error) {
  557. o := orm.NewOrm()
  558. sql := `SELECT * FROM rs_matters AS a
  559. WHERE 1=1 `
  560. if condition != "" {
  561. sql += condition
  562. }
  563. sql += ` ORDER BY a.create_time DESC LIMIT ?,? `
  564. _, err = o.Raw(sql, pars, pageLimit).QueryRows(&list)
  565. return
  566. }
  567. type MattersListResp struct {
  568. Paging *paging.PagingItem
  569. List []*RsMattersView
  570. }
  571. // 删除
  572. func DeleteCalendar(rsCalendarId, rsCalendarResearcherId int) (err error) {
  573. o := orm.NewOrm()
  574. sql := ` DELETE FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  575. _, err = o.Raw(sql, rsCalendarId).Exec()
  576. if err != nil {
  577. return err
  578. }
  579. //var count int
  580. //sql = ` SELECT COUNT(1) AS count FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  581. //err = o.Raw(sql, rsCalendarId).QueryRow(&count)
  582. //if err != nil && err.Error() != utils.ErrNoRow() {
  583. // return err
  584. //}
  585. //if count <= 0 {
  586. // sql := ` DELETE FROM rs_calendar WHERE rs_calendar_id=? `
  587. // _, err = o.Raw(sql, rsCalendarId).Exec()
  588. // if err != nil {
  589. // return err
  590. // }
  591. //}
  592. sql = ` DELETE FROM rs_calendar WHERE rs_calendar_id=? `
  593. _, err = o.Raw(sql, rsCalendarId).Exec()
  594. return err
  595. }
  596. // 删除
  597. func DeleteRsCalendarResearcher(rsCalendarId int) (err error) {
  598. o := orm.NewOrm()
  599. sql := ` DELETE FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  600. _, err = o.Raw(sql, rsCalendarId).Exec()
  601. return err
  602. }
  603. func CheckMattersCount(condition string, pars []interface{}) (count int, err error) {
  604. o := orm.NewOrm()
  605. sql := `SELECT COUNT(1) AS count FROM rs_matters AS a
  606. WHERE 1=1 `
  607. if condition != "" {
  608. sql += condition
  609. }
  610. err = o.Raw(sql, pars).QueryRow(&count)
  611. return
  612. }
  613. func CheckCalendarResearcherCount(condition string, pars []interface{}) (count int, err error) {
  614. o := orm.NewOrm()
  615. sql := `SELECT COUNT(1) AS count FROM rs_calendar_researcher AS a
  616. WHERE 1=1 `
  617. if condition != "" {
  618. sql += condition
  619. }
  620. err = o.Raw(sql, pars).QueryRow(&count)
  621. return
  622. }
  623. func GetResearcherFromAdmin(condition string, pars []interface{}) (lists []*system.Admin, err error) {
  624. o := orm.NewOrm()
  625. sql := `SELECT * FROM admin WHERE 1=1 `
  626. if condition != "" {
  627. sql += condition
  628. }
  629. _, err = o.Raw(sql, pars).QueryRows(&lists)
  630. return
  631. }
  632. func GetCreditCodeFromCompany(companyId int) (creditCode string, err error) {
  633. o := orm.NewOrm()
  634. companyItem := company.Company{CompanyId: companyId}
  635. err = o.Read(&companyItem)
  636. if err != nil {
  637. return "", err
  638. }
  639. creditCode = companyItem.CreditCode
  640. return
  641. }
  642. type SHCalendar struct {
  643. CalendarId int `description:"日历id"`
  644. UserPhone string `description:"创建人手机号"`
  645. ResearcherPhone string `description:"研究员手机号"`
  646. IndustryName string `description:"行业名称"`
  647. CreditCode string `description:"社会信用码"`
  648. content string `description:"日历内容"`
  649. StartTime string `description:"开始时间"`
  650. EndTime string `description:"结束时间"`
  651. }
  652. func GetRsCalendarResearcherByRsCalendarIdAndResearcherId(rsCalendarId, researcherId int) (item *RsCalendarResearcher, err error) {
  653. o := orm.NewOrm()
  654. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? AND researcher_id=? `
  655. err = o.Raw(sql, rsCalendarId, researcherId).QueryRow(&item)
  656. return
  657. }
  658. // GetRsCalendarResearcherListByRsCalendarId 根据路演id获取路演研究员列表
  659. func GetRsCalendarResearcherListByRsCalendarId(rsCalendarId int) (items []*RsCalendarResearcher, err error) {
  660. o := orm.NewOrm()
  661. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  662. _, err = o.Raw(sql, rsCalendarId).QueryRows(&items)
  663. return
  664. }
  665. func GetMattersById(rsMatters int) (item *RsMatters, err error) {
  666. o := orm.NewOrm()
  667. sql := `SELECT * FROM rs_matters
  668. WHERE rs_matters_id=? `
  669. err = o.Raw(sql, rsMatters).QueryRow(&item)
  670. return
  671. }
  672. func GetRsCalendarResearcherExist(rsCalendarResearcherId, rsCalendarId, researcherId int) (count int, err error) {
  673. o := orm.NewOrm()
  674. sql := `SELECT COUNT(1) AS count FROM rs_calendar_researcher WHERE rs_calendar_researcher_id=? AND rs_calendar_id=? AND researcher_id=? `
  675. err = o.Raw(sql, rsCalendarResearcherId, rsCalendarId, researcherId).QueryRow(&count)
  676. return
  677. }
  678. func GetRsCalendarResearcherByCalendarId(rsCalendarId int) (item []*RsCalendarResearcher, err error) {
  679. o := orm.NewOrm()
  680. sql := `SELECT * FROM rs_calendar_researcher WHERE rs_calendar_id=? `
  681. _, err = o.Raw(sql, rsCalendarId).QueryRows(&item)
  682. return
  683. }
  684. type PublicMeetingDetailResp struct {
  685. Group []*PublicMeetingGroup
  686. }
  687. type PublicMeetingGroup struct {
  688. UnionCode string
  689. MinTime string
  690. MaxTime string
  691. CalendarList []*CalendarListView
  692. }
  693. func GetPublicCalendarDetailList(condition string, pars []interface{}) (list []*CalendarListView, err error) {
  694. o := orm.NewOrm()
  695. sql := `SELECT a.*,b.*,c.status AS company_status FROM rs_calendar AS a
  696. INNER JOIN rs_calendar_researcher AS b ON a.rs_calendar_id=b.rs_calendar_id
  697. LEFT JOIN company_product AS c ON a.company_id=c.company_id AND c.product_id=1
  698. INNER JOIN admin AS d ON b.researcher_id=d.admin_id
  699. WHERE 1=1 AND d.enabled=1 `
  700. if condition != "" {
  701. sql += condition
  702. }
  703. sql += ` ORDER BY a.create_time DESC `
  704. _, err = o.Raw(sql, pars).QueryRows(&list)
  705. return
  706. }
  707. type AdminInfo struct {
  708. AdminId int
  709. RealName string
  710. }
  711. func GetOverseaCustomCalendarSellerList() (list []*AdminInfo, err error) {
  712. o := orm.NewOrm()
  713. sql1 := `SELECT a.sys_user_id FROM rs_calendar AS a
  714. INNER JOIN rs_report_record AS b ON a.rs_calendar_id=b.rs_calendar_id
  715. JOIN company_product AS c ON a.company_id=c.company_id AND c.product_id=1
  716. JOIN company AS d ON c.company_id=d.company_id
  717. INNER JOIN overseas_custom_seller AS f ON c.seller_id=f.seller_id
  718. where c.is_overseas = 0 and a.english_company= 0 AND a.source = 0 AND b.rs_calendar_researcher_status=2 AND a.sys_user_id != 0 `
  719. sql2 := `SELECT aa.sys_user_id FROM rs_calendar AS aa
  720. INNER JOIN rs_report_record AS bb ON aa.rs_calendar_id=bb.rs_calendar_id
  721. where aa.english_company= 1 AND aa.source = 0 AND bb.rs_calendar_researcher_status=2 AND aa.sys_user_id != 0`
  722. sql := `SELECT n.admin_id,n.real_name FROM (` + sql1 + ` UNION ALL ` + sql2
  723. sql += ` ) AS m
  724. JOIN admin n on m.sys_user_id=n.admin_id
  725. WHERE 1=1 Group by sys_user_id order by sys_user_id asc`
  726. _, err = o.Raw(sql).QueryRows(&list)
  727. return
  728. }
  729. func GetOverseaCustomCalendarResearcherList() (list []*AdminInfo, err error) {
  730. o := orm.NewOrm()
  731. sql1 := `SELECT b.researcher_id FROM rs_calendar AS a
  732. INNER JOIN rs_report_record AS b ON a.rs_calendar_id=b.rs_calendar_id
  733. JOIN company_product AS c ON a.company_id=c.company_id AND c.product_id=1
  734. JOIN company AS d ON c.company_id=d.company_id
  735. INNER JOIN overseas_custom_seller AS f ON c.seller_id=f.seller_id
  736. where c.is_overseas = 0 and a.english_company= 0 AND a.source = 0 AND b.rs_calendar_researcher_status=2 AND b.researcher_id != 0`
  737. sql2 := `SELECT bb.researcher_id FROM rs_calendar AS aa
  738. INNER JOIN rs_report_record AS bb ON aa.rs_calendar_id=bb.rs_calendar_id
  739. where aa.english_company= 1 AND aa.source = 0 AND bb.rs_calendar_researcher_status=2 AND bb.researcher_id != 0 `
  740. sql := `SELECT n.admin_id,n.real_name FROM (` + sql1 + ` UNION ALL ` + sql2
  741. sql += ` ) AS m
  742. JOIN admin n on m.researcher_id=n.admin_id
  743. WHERE 1=1 Group by researcher_id order by researcher_id asc`
  744. _, err = o.Raw(sql).QueryRows(&list)
  745. return
  746. }
  747. type OverseaCustomRecordInfoResp struct {
  748. Paging *paging.PagingItem
  749. List []*OverseaCustomRecordInfo
  750. }
  751. type OverseaCustomRecordInfo struct {
  752. RsCalendarId int
  753. CompanyId int
  754. Source int
  755. RoadshowType string
  756. RoadshowPlatform string
  757. SellerName string
  758. ResearcherName string
  759. CompanyName string
  760. CompanyStatus string
  761. StartDate string
  762. }
  763. func GetOverseaCustomCalendarList(keyword, sellerId, researcherId, startDate, endDate, companyStatus, sortField, sortDesc string, startSize, pageSize int) (total int, list []*OverseaCustomRecordInfo, err error) {
  764. var databaseName string
  765. if utils.RunMode == "debug" {
  766. databaseName = "test_v2_hongze_rddp"
  767. } else {
  768. databaseName = "hongze_rddp"
  769. }
  770. companyStatusList := make([]string, 0)
  771. if companyStatus != "" {
  772. companyStatusList = strings.Split(companyStatus, ",")
  773. }
  774. lenCompanyStatusList := len(companyStatusList)
  775. o := orm.NewOrm()
  776. pars := make([]interface{}, 0)
  777. sql1 := `SELECT d.company_name,d.overseas_status company_status,b.start_date,a.rs_calendar_id,a.roadshow_type,a.roadshow_platform,a.sys_user_real_name seller_name,b.researcher_name as base_researcher_name,2 AS source,d.company_id FROM rs_calendar AS a
  778. INNER JOIN rs_report_record AS b ON a.rs_calendar_id=b.rs_calendar_id
  779. JOIN company_product AS c ON a.company_id=c.company_id AND c.product_id=1
  780. JOIN company AS d ON c.company_id=d.company_id
  781. INNER JOIN overseas_custom_seller AS f ON c.seller_id=f.seller_id
  782. where c.is_overseas = 0 and a.english_company= 0 AND a.source = 0 AND b.rs_calendar_researcher_status=2 AND b.researcher_id != 0`
  783. if keyword != "" {
  784. sql1 += ` AND d.company_name like ? `
  785. pars = utils.GetLikeKeywordPars(pars, keyword, 1)
  786. }
  787. if sellerId != "" {
  788. sql1 += fmt.Sprintf(` AND a.sys_user_id in (%s) `, sellerId)
  789. }
  790. if startDate != "" {
  791. sql1 += ` AND b.start_date >= ? `
  792. pars = append(pars, startDate)
  793. }
  794. if endDate != "" {
  795. sql1 += ` AND b.start_date <= ? `
  796. pars = append(pars, endDate)
  797. }
  798. if lenCompanyStatusList > 0 {
  799. sql1 += ` AND d.overseas_status in (` + utils.GetOrmInReplace(lenCompanyStatusList) + ") "
  800. pars = append(pars, companyStatusList)
  801. }
  802. sql2 := fmt.Sprintf(`SELECT cc.company_name,cc.overseas_status company_status,bb.start_date,aa.rs_calendar_id,aa.roadshow_type,aa.roadshow_platform,aa.sys_user_real_name seller_name,bb.researcher_name as base_researcher_name,1 AS source,cc.company_id+10000000 FROM rs_calendar AS aa
  803. INNER JOIN rs_report_record AS bb ON aa.rs_calendar_id=bb.rs_calendar_id
  804. INNER JOIN %s.english_company AS cc ON aa.company_id=cc.company_id
  805. where aa.english_company= 1 AND aa.source = 0 AND cc.is_deleted=0 AND bb.rs_calendar_researcher_status=2 AND bb.researcher_id != 0 `, databaseName)
  806. if keyword != "" {
  807. sql2 += ` AND cc.company_name like ? `
  808. pars = utils.GetLikeKeywordPars(pars, keyword, 1)
  809. }
  810. if sellerId != "" {
  811. sql2 += fmt.Sprintf(` AND aa.sys_user_id in (%s) `, sellerId)
  812. }
  813. if startDate != "" {
  814. sql2 += ` AND bb.start_date >= ? `
  815. pars = append(pars, startDate)
  816. }
  817. if endDate != "" {
  818. sql2 += ` AND bb.start_date <= ? `
  819. pars = append(pars, endDate)
  820. }
  821. if lenCompanyStatusList > 0 {
  822. sql2 += ` AND cc.overseas_status in (` + utils.GetOrmInReplace(lenCompanyStatusList) + ") "
  823. pars = append(pars, companyStatusList)
  824. }
  825. rsCalendarIdList := make([]int, 0)
  826. if researcherId != `` {
  827. rsCalendarIdSql := fmt.Sprintf("select rs_calendar_id from rs_calendar_researcher where researcher_id in (%s) group by rs_calendar_id", researcherId)
  828. _, err = o.Raw(rsCalendarIdSql).QueryRows(&rsCalendarIdList)
  829. if err != nil {
  830. return
  831. }
  832. }
  833. rsCalendarIdNum := len(rsCalendarIdList)
  834. // 汇总数据
  835. totalSql := `SELECT COUNT(1) FROM (SELECT rs_calendar_id FROM (` + sql1 + ` UNION ALL ` + sql2
  836. totalSql += ` ) AS m WHERE 1=1 `
  837. if rsCalendarIdNum > 0 {
  838. totalSql += fmt.Sprintf(` AND rs_calendar_id IN (` + utils.GetOrmInReplace(rsCalendarIdNum) + `)`)
  839. pars = append(pars, rsCalendarIdList)
  840. }
  841. totalSql += ` Group by rs_calendar_id) fff`
  842. err = o.Raw(totalSql, pars).QueryRow(&total)
  843. if err != nil {
  844. return
  845. }
  846. // 列表数据
  847. sql := `SELECT m.*,GROUP_CONCAT(DISTINCT base_researcher_name ORDER BY rs_calendar_id ASC SEPARATOR ',') AS researcher_name FROM (` + sql1 + ` UNION ALL ` + sql2
  848. sql += ` ) AS m WHERE 1=1 `
  849. if rsCalendarIdNum > 0 {
  850. sql += fmt.Sprintf(` AND rs_calendar_id IN (` + utils.GetOrmInReplace(rsCalendarIdNum) + `)`)
  851. }
  852. sql += fmt.Sprintf(` Group by rs_calendar_id order by %s %s `, sortField, sortDesc)
  853. sql += ` LIMIT ?,? `
  854. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  855. return
  856. }
  857. func GetOverseaCustomCalendarList2(sellerId, researcherId, startDate, endDate, companyStatus string) (list []*RsReportRecordList, err error) {
  858. var databaseName string
  859. if utils.RunMode == "debug" {
  860. databaseName = "test_v2_hongze_rddp"
  861. } else {
  862. databaseName = "hongze_rddp"
  863. }
  864. companyStatusList := make([]string, 0)
  865. if companyStatus != "" {
  866. companyStatusList = strings.Split(companyStatus, ",")
  867. }
  868. lenCompanyStatusList := len(companyStatusList)
  869. o := orm.NewOrm()
  870. pars := make([]interface{}, 0)
  871. sql1 := `SELECT b.start_date,b.end_date,b.start_time,b.end_time,a.rs_calendar_id,b.seller_id,b.seller_name,b.researcher_name,b.company_name,b.company_id,d.overseas_status as company_status,b.roadshow_type,a.theme,a.roadshow_platform,a.province as province,a.city as city FROM rs_calendar AS a
  872. INNER JOIN rs_report_record AS b ON a.rs_calendar_id=b.rs_calendar_id
  873. JOIN company_product AS c ON a.company_id=c.company_id AND c.product_id=1
  874. JOIN company AS d ON c.company_id=d.company_id
  875. INNER JOIN overseas_custom_seller AS f ON c.seller_id=f.seller_id
  876. where c.is_overseas = 0 and a.english_company= 0 AND a.source = 0 AND b.rs_calendar_researcher_status=2 AND b.researcher_id != 0`
  877. if startDate != "" {
  878. sql1 += ` AND b.start_date >= ? `
  879. pars = append(pars, startDate)
  880. }
  881. if endDate != "" {
  882. sql1 += ` AND b.start_date <= ? `
  883. pars = append(pars, endDate)
  884. }
  885. if lenCompanyStatusList > 0 {
  886. sql1 += ` AND d.overseas_status in (` + utils.GetOrmInReplace(lenCompanyStatusList) + ") "
  887. pars = append(pars, companyStatusList)
  888. }
  889. if sellerId != "" {
  890. sql1 += fmt.Sprintf(` AND b.seller_id in (%s) `, sellerId)
  891. }
  892. if researcherId != "" {
  893. sql1 += fmt.Sprintf(` AND b.researcher_id in (%s) `, researcherId)
  894. }
  895. sql2 := fmt.Sprintf(`SELECT bb.start_date,bb.end_date,bb.start_time,bb.end_time,aa.rs_calendar_id,bb.seller_id,bb.seller_name,bb.researcher_name,aa.company_name,aa.company_id,cc.overseas_status as company_status,bb.roadshow_type,aa.theme,aa.roadshow_platform,aa.province as province,aa.city as city FROM rs_calendar AS aa
  896. INNER JOIN rs_report_record AS bb ON aa.rs_calendar_id=bb.rs_calendar_id
  897. INNER JOIN %s.english_company AS cc ON aa.company_id=cc.company_id
  898. where aa.english_company= 1 AND aa.source = 0 AND cc.is_deleted=0 AND bb.rs_calendar_researcher_status=2 AND bb.researcher_id != 0 `, databaseName)
  899. if startDate != "" {
  900. sql2 += ` AND bb.start_date >= ? `
  901. pars = append(pars, startDate)
  902. }
  903. if endDate != "" {
  904. sql2 += ` AND bb.start_date <= ? `
  905. pars = append(pars, endDate)
  906. }
  907. if lenCompanyStatusList > 0 {
  908. sql2 += ` AND cc.overseas_status in (` + utils.GetOrmInReplace(lenCompanyStatusList) + ") "
  909. pars = append(pars, companyStatusList)
  910. }
  911. if sellerId != "" {
  912. sql2 += fmt.Sprintf(` AND bb.seller_id in (%s) `, sellerId)
  913. }
  914. if researcherId != "" {
  915. sql2 += fmt.Sprintf(` AND bb.researcher_id in (%s) `, researcherId)
  916. }
  917. // 列表数据
  918. sql := `SELECT m.* FROM (` + sql1 + ` UNION ALL ` + sql2
  919. sql += ` ) AS m WHERE 1=1 `
  920. sql += ` Group by rs_calendar_id `
  921. _, err = o.Raw(sql, pars).QueryRows(&list)
  922. return
  923. }