calendar.go 38 KB

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