user.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. package models
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "hongze/hongze_web_mfyx/utils"
  6. "time"
  7. )
  8. type UserDetail struct {
  9. Headimgurl string `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
  10. Mobile string `description:"手机号码"`
  11. Email string `description:"邮箱"`
  12. NickName string `description:"用户昵称"`
  13. RealName string `description:"用户实际名称"`
  14. CompanyName string `description:"公司名称"`
  15. PermissionName string `description:"拥有权限分类,多个用英文逗号分隔"`
  16. HasPermission int `description:"1:无该行业权限,不存在权益客户下,2:潜在客户,未提交过申请,3:潜在客户,已提交过申请"`
  17. SellerMobile string `description:"销售手机号"`
  18. SellerName string `description:"销售名称"`
  19. Note string `json:"-" description:"申请提交时,公司名称"`
  20. CountryCode string `description:"区号"`
  21. OutboundMobile string `description:"外呼手机号"`
  22. OutboundCountryCode string `description:"外呼手机号区号"`
  23. }
  24. func GetUserDetailByUserId(userId int) (item *UserDetail, err error) {
  25. o := orm.NewOrmUsingDB("weekly_report")
  26. sql := `SELECT * FROM wx_user WHERE user_id = ? `
  27. err = o.Raw(sql, userId).QueryRow(&item)
  28. return
  29. }
  30. func GetUserDetailByMobile(mobile string) (item *UserDetail, err error) {
  31. o := orm.NewOrmUsingDB("weekly_report")
  32. sql := `SELECT * FROM wx_user WHERE mobile = ? `
  33. err = o.Raw(sql, mobile).QueryRow(&item)
  34. return
  35. }
  36. type UserPermission struct {
  37. CompanyName string `description:"公司名称"`
  38. ChartPermissionName string `description:"权限"`
  39. }
  40. type LoginReq struct {
  41. Mobile string `description:"手机号"`
  42. VCode string `description:"验证码"`
  43. Token string `description:"微信扫码登录之后返回的Token"`
  44. }
  45. type WxBindMobileReq struct {
  46. Mobile string `description:"手机号"`
  47. VCode string `description:"验证码"`
  48. //Token string `description:"Token"`
  49. }
  50. func PcBindMobile(unionId, mobile string, userId, loginType int) (wxUserId int, err error) {
  51. //loginType 登录方式:1:手机,2:邮箱
  52. sql := ``
  53. if loginType == 1 {
  54. sql = `SELECT * FROM wx_user WHERE mobile = ? `
  55. } else {
  56. sql = "SELECT * FROM wx_user WHERE email = ? "
  57. }
  58. user := new(WxUser)
  59. o := orm.NewOrmUsingDB("weekly_report")
  60. err = o.Raw(sql, mobile).QueryRow(&user)
  61. if err != nil && err.Error() != utils.ErrNoRow() {
  62. return
  63. }
  64. if user == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  65. msql := ``
  66. if loginType == 1 {
  67. msql = "UPDATE wx_user SET mobile = ?,bind_account = ? WHERE union_id = ? "
  68. } else {
  69. msql = "UPDATE wx_user SET email = ?,bind_account = ? WHERE union_id = ? "
  70. }
  71. _, err = o.Raw(msql, mobile, mobile, unionId).Exec()
  72. wxUserId = userId
  73. } else {
  74. if user.UnionId == "" {
  75. sql = `SELECT * FROM wx_user WHERE union_id = ? `
  76. userInfo := new(WxUser)
  77. o := orm.NewOrm()
  78. err = o.Raw(sql, unionId).QueryRow(&userInfo)
  79. if err != nil {
  80. return
  81. }
  82. var maxRegisterTime time.Time
  83. if user.RegisterTime.Before(userInfo.RegisterTime) {
  84. maxRegisterTime = user.RegisterTime
  85. } else {
  86. maxRegisterTime = userInfo.RegisterTime
  87. }
  88. wxUserId = user.UserId
  89. dsql := ` DELETE FROM wx_user WHERE union_id = ? `
  90. _, err = o.Raw(dsql, unionId).Exec()
  91. if err != nil {
  92. return wxUserId, err
  93. }
  94. msql := ` UPDATE wx_user SET union_id=?,register_time=?,province=?,city=?,country=?,headimgurl=?,unionid=?,sex=? WHERE user_id = ? `
  95. _, err = o.Raw(msql, unionId, maxRegisterTime, userInfo.Province, userInfo.City, userInfo.Country, userInfo.Headimgurl, unionId, userInfo.Sex, user.UserId).Exec()
  96. wxUserId = user.UserId
  97. } else {
  98. sql = `SELECT * FROM wx_user WHERE user_id = ? `
  99. userInfo := new(WxUser)
  100. o := orm.NewOrm()
  101. err = o.Raw(sql, userId).QueryRow(&userInfo)
  102. if err != nil && err.Error() != utils.ErrNoRow() {
  103. return
  104. }
  105. if user.UserId != userId {
  106. dsql := ` DELETE FROM wx_user WHERE user_id = ? `
  107. _, err = o.Raw(dsql, userId).Exec()
  108. if err != nil {
  109. return user.UserId, err
  110. }
  111. }
  112. msql := ` UPDATE wx_user SET union_id=?,province=?,city=?,country=?,headimgurl=?,unionid=?,sex=? WHERE user_id = ? `
  113. _, err = o.Raw(msql, unionId, userInfo.Province, userInfo.City, userInfo.Country, userInfo.Headimgurl, unionId, userInfo.Sex, user.UserId).Exec()
  114. wxUserId = userId
  115. }
  116. }
  117. return
  118. }
  119. type LoginResp struct {
  120. UserId int `description:"用户id"`
  121. Authorization string `description:"Token"`
  122. Headimgurl string `description:"用户头像"`
  123. Mobile string `description:"手机号"`
  124. Email string `description:"邮箱"`
  125. CompanyName string `description:"客户名称"`
  126. }
  127. type UserDetailResp struct {
  128. UserId int `description:"用户id"`
  129. UserName string `description:"用户名称"`
  130. Headimgurl string `description:"用户头像"`
  131. Mobile string `description:"手机号"`
  132. Email string `description:"邮箱"`
  133. CompanyName string `description:"客户名称"`
  134. OutboundMobile string `description:"外呼手机号"`
  135. OutboundCountryCode string `description:"外呼手机号区号"`
  136. PermissionName []string `description:"拥有权限分类"`
  137. PermissionStatus string `description:"状态"`
  138. StartDate string `description:"开始日期"`
  139. EndDate string `description:"结束日期"`
  140. CompanyPointsNum float64 `description:"公司剩余点数"`
  141. HasPermission int `description:"1:有该行业权限,正常展示"`
  142. IsAuthor bool `description:"是否开通了研选专栏"`
  143. SpecialColumnId int // 专栏栏目ID
  144. IsImproveInformation bool `description:"作者信息是否完善"`
  145. InviteShareCode string `description:"销售账号邀请码"`
  146. }
  147. type CheckStatusResp struct {
  148. IsBind bool `description:"true:需要绑定手机号或邮箱,false:不需要绑定手机号或邮箱"`
  149. IsAuth bool `description:"true:需要授权,false:不需要授权"`
  150. PermissionName string `description:"拥有权限分类,多个用英文逗号分隔"`
  151. }
  152. type ApplyTryReq struct {
  153. BusinessCardUrl string `description:"名片地址"`
  154. RealName string `description:"姓名"`
  155. CompanyName string `description:"公司名称"`
  156. ApplyMethod int `description:"1:已付费客户申请试用,2:非客户申请试用,3:非客户申请试用(ficc下,不需要进行数据校验)"`
  157. TryType string `description:"提交类型,Article:文章、Activity:活动、MicroAudio:微路演音频、MicroVideo:微路演视频、Researchsummary:本周研究汇总、Minutessummary:上周纪要汇总、ReportSelection:报告精选、ProductInterior:产品内测"`
  158. DetailId int `description:"详情ID"`
  159. }
  160. type CountryCode struct {
  161. IsNeedAddCountryCode bool `description:"是否需要填写区号:需要填写,false:不需要填写"`
  162. }
  163. type OutboundMobile struct {
  164. IsNeedAddOutboundMobile bool `description:"是否需要填写外呼手机号:需要填写,false:不需要填写"`
  165. }
  166. type CountryCodeItem struct {
  167. CountryCode string `description:"区号"`
  168. }
  169. // 修改外呼手机号
  170. type OutboundMobileItem struct {
  171. OutboundMobile string `description:"外呼手机号"`
  172. OutboundCountryCode string `description:"外呼手机号区号"`
  173. }
  174. type UserWhiteList struct {
  175. Mobile string `description:"手机号码"`
  176. RealName string `description:"用户实际名称"`
  177. CompanyName string `description:"公司名称"`
  178. Permission string `description:"拥有权限分类,多个用英文逗号分隔"`
  179. CountryCode string `description:"区号"`
  180. SellerName string `description:"销售姓名"`
  181. CreatedTime time.Time
  182. Status string `description:"客户状态'试用','永续','冻结','流失','正式','潜在'"`
  183. }
  184. type UserWhiteListRep struct {
  185. List []*UserWhiteList
  186. }
  187. type UserDetailByUserLogin struct {
  188. Headimgurl string `description:"头像"`
  189. Mobile string `description:"手机号码"`
  190. RealName string `description:"用户实际名称"`
  191. CompanyName string `description:"公司名称"`
  192. Permission string `description:"拥有权限分类,多个用英文逗号分隔"`
  193. HasPermission int `description:"1:有该行业权限,正常展示,2:无权限,非潜在客户,3:潜在客户"`
  194. Token string `description:"Token"`
  195. }
  196. func GetCompanyPermission(companyId int) (permission string, err error) {
  197. sql := ` SELECT GROUP_CONCAT(DISTINCT b.remark ORDER BY b.sort ASC SEPARATOR ',') AS permission
  198. FROM company_report_permission AS a
  199. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  200. INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
  201. WHERE a.company_id=?
  202. AND c.is_suspend=0
  203. AND b.cygx_auth=1
  204. AND c.status IN('正式','试用','永续')
  205. AND a.status IN('正式','试用','永续') `
  206. o := orm.NewOrmUsingDB("weekly_report")
  207. err = o.Raw(sql, companyId).QueryRow(&permission)
  208. return
  209. }
  210. func GetCompanyPermissionName(companyId int) (permission string, err error) {
  211. sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_name ORDER BY b.sort ASC SEPARATOR ',') AS permission
  212. FROM company_report_permission AS a
  213. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  214. INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
  215. WHERE a.company_id=?
  216. AND c.is_suspend=0
  217. AND b.cygx_auth=1
  218. AND c.status IN('正式','试用','永续')
  219. AND a.status IN('正式','试用','永续') `
  220. o := orm.NewOrmUsingDB("weekly_report")
  221. err = o.Raw(sql, companyId).QueryRow(&permission)
  222. return
  223. }
  224. func GetCompanyPermissionId(companyId int) (permissionId string, err error) {
  225. sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_id ORDER BY b.sort ASC SEPARATOR ',') AS permissionId
  226. FROM company_report_permission AS a
  227. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  228. INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
  229. WHERE a.company_id=?
  230. AND c.is_suspend=0
  231. AND b.cygx_auth=1
  232. AND c.status IN('正式','试用','永续')
  233. AND a.status IN('正式','试用','永续') `
  234. o := orm.NewOrmUsingDB("weekly_report")
  235. err = o.Raw(sql, companyId).QueryRow(&permissionId)
  236. return
  237. }
  238. // 用户绑定手机号时同时绑定外呼手机号
  239. func BindUserOutboundMobile(mobile, countryCode string, userId int) (err error) {
  240. o := orm.NewOrmUsingDB("weekly_report")
  241. sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ?, country_code= ? WHERE user_id=? `
  242. _, err = o.Raw(sql, mobile, countryCode, countryCode, userId).Exec()
  243. return
  244. }
  245. type UserPermissionAuthInfo struct {
  246. HasPermission int `description:"是否有权限:1-有权限; 2-无权限; 3-潜在客户未提交申请; 4-潜在客户已提交申请 5-仅有FICC权限"`
  247. SellerMobile string `description:"销售手机号"`
  248. SellerName string `description:"销售名称"`
  249. OperationMode string `description:"操作方式:Apply-立即申请; Call-拨号"`
  250. PopupMsg string `description:"权限弹窗信息"`
  251. }
  252. // 修改用户是否绑定外呼手机号弹窗
  253. func ModifyWxUserIsMsgOutboundMobile(userId int) (err error) {
  254. o := orm.NewOrmUsingDB("weekly_report")
  255. sql := `UPDATE wx_user SET is_msg_outbound_mobile=1 WHERE user_id=? `
  256. _, err = o.Raw(sql, userId).Exec()
  257. return
  258. }
  259. // 已经绑定手机号,没有绑定外呼手机号的的用户,预约外呼的时候,将外呼手机号同步成手机号
  260. func BindUserOutboundMobileByMobile(mobile, countryCode string, userId int) (err error) {
  261. o := orm.NewOrmUsingDB("weekly_report")
  262. sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ? WHERE user_id=? `
  263. _, err = o.Raw(sql, mobile, countryCode, userId).Exec()
  264. return
  265. }
  266. // GetWxUserByMobiles 根据用户手机号获取用户详情
  267. func GetWxUserByMobiles(mobiles []string) (items []*WxUser, err error) {
  268. lenmobiles := len(mobiles)
  269. if lenmobiles == 0 {
  270. return
  271. }
  272. sql := `SELECT* FROM wx_user WHERE mobile in (` + utils.GetOrmInReplace(lenmobiles) + `) `
  273. o := orm.NewOrmUsingDB("weekly_report")
  274. _, err = o.Raw(sql, mobiles).QueryRows(&items)
  275. return
  276. }
  277. func GetUserCompanyPermissionSand(companyId int) (items []*ChartPermissionResp, err error) {
  278. sql := ` SELECT b.*
  279. FROM company_report_permission AS a
  280. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  281. INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
  282. WHERE a.company_id=?
  283. AND a.product_id=2
  284. AND c.is_suspend=0
  285. AND b.cygx_auth=1
  286. AND b.is_other=0
  287. AND c.status IN('正式','试用','永续')
  288. AND a.status IN('正式','试用','永续')
  289. AND b.chart_permission_name != '专家'
  290. GROUP BY b.chart_permission_name
  291. ORDER BY b.sort ASC `
  292. o := orm.NewOrmUsingDB("weekly_report")
  293. _, err = o.Raw(sql, companyId).QueryRows(&items)
  294. return
  295. }
  296. func AddOutboundMobile(item *OutboundMobileItem, userId int) (err error) {
  297. o, err := orm.NewOrmUsingDB("weekly_report").Begin()
  298. if err != nil {
  299. return
  300. }
  301. defer func() {
  302. fmt.Println(err)
  303. if err == nil {
  304. o.Commit()
  305. } else {
  306. o.Rollback()
  307. }
  308. }()
  309. sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ?, is_msg_outbound_mobile= 1 WHERE user_id=? `
  310. _, err = o.Raw(sql, item.OutboundMobile, item.OutboundCountryCode, userId).Exec()
  311. if err != nil {
  312. return
  313. }
  314. //if item.ActivityId > 0 {
  315. // sql = `UPDATE cygx_activity_signup SET outbound_mobile=? ,country_code = ? WHERE user_id=? AND activity_id = ?`
  316. // _, err = o.Raw(sql, item.OutboundMobile, item.OutboundCountryCode, userId, item.ActivityId).Exec()
  317. //}
  318. return
  319. }
  320. type Headimgurl struct {
  321. Headimgurl string `description:"用户头像"`
  322. }
  323. // 更改用户头像
  324. func UpdateUserHeadimgurl(headimgurl string, userId int) (err error) {
  325. o := orm.NewOrmUsingDB("weekly_report")
  326. sql := `UPDATE wx_user SET headimgurl = ? WHERE user_id=? `
  327. _, err = o.Raw(sql, headimgurl, userId).Exec()
  328. return
  329. }
  330. // 更改用户邮箱号
  331. func UpdateUserEmail(email string, userId int) (err error) {
  332. o := orm.NewOrmUsingDB("weekly_report")
  333. sql := `UPDATE wx_user SET email = ? WHERE user_id=? `
  334. _, err = o.Raw(sql, email, userId).Exec()
  335. return
  336. }
  337. func GetArticleUserCollectCount(userId int) (count int, err error) {
  338. sql := `SELECT SUM(count) AS count FROM (
  339. SELECT COUNT(1) AS count FROM cygx_article_collect AS a
  340. INNER JOIN cygx_article as art ON art.article_id = a.article_id
  341. WHERE a.user_id=? AND art.publish_status = 1 AND art.article_type_id > 0
  342. UNION ALL
  343. SELECT COUNT(1) AS count FROM cygx_yanxuan_special_collect AS a
  344. INNER JOIN cygx_yanxuan_special as b ON b.id = a.yanxuan_special_id
  345. WHERE a.user_id=? AND b.status = 3) AS c
  346. `
  347. err = orm.NewOrm().Raw(sql, userId, userId).QueryRow(&count)
  348. return
  349. }
  350. //art.article_id,
  351. //art.article_type_id,
  352. //art.title,
  353. //art.publish_date,
  354. //'' AS company_tags,
  355. //'' AS industry_tags,
  356. //art.department_id,
  357. //d.nick_name,
  358. //0 AS is_special,
  359. //0 as pv,
  360. //0 as collect_num,
  361. //a.create_time
  362. //FROM
  363. //cygx_article AS art
  364. //INNER JOIN cygx_article_history_record_newpv AS a ON art.article_id = a.article_id
  365. //INNER JOIN cygx_article_department AS d ON d.department_id = art.department_id
  366. //WHERE
  367. //a.user_id = ?
  368. //AND a.create_time >= ?
  369. //AND art.article_type_id > 0
  370. //GROUP BY
  371. //art.article_id UNION ALL
  372. //SELECT
  373. //art.id AS article_id,
  374. //- 1 AS article_type_id,
  375. //art.title,
  376. //art.publish_time AS publish_date,
  377. //art.company_tags AS company_tags,
  378. //art.industry_tags AS industry_tags,
  379. //d.id AS department_id,
  380. //d.nick_name,
  381. //1 AS is_special,
  382. //art.pv,
  383. //art.article_collect_num as collect_num,
  384. //a.create_time
  385. func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*ArticleListResp, err error) {
  386. sql := `SELECT
  387. art.article_id,
  388. art.article_type_id,
  389. art.title,
  390. art.publish_date,
  391. '' AS company_tags,
  392. '' AS industry_tags,
  393. art.department_id,
  394. d.nick_name,
  395. 0 AS is_special,
  396. 0 as pv,
  397. 0 as collect_num,
  398. a.create_time
  399. FROM
  400. cygx_article AS art
  401. INNER JOIN cygx_article_collect as a ON art.article_id = a.article_id
  402. INNER JOIN cygx_article_department AS d ON d.department_id = art.department_id
  403. WHERE a.user_id=?
  404. AND art.article_type_id > 0
  405. UNION ALL
  406. SELECT
  407. art.id AS article_id,
  408. - 1 AS article_type_id,
  409. art.title,
  410. art.publish_time AS publish_date,
  411. art.company_tags AS company_tags,
  412. art.industry_tags AS industry_tags,
  413. b.id AS department_id,
  414. b.nick_name,
  415. 1 AS is_special,
  416. art.pv,
  417. art.article_collect_num as collect_num,
  418. c.create_time
  419. FROM
  420. cygx_yanxuan_special AS art
  421. JOIN cygx_yanxuan_special_author AS b ON art.user_id = b.user_id
  422. JOIN cygx_yanxuan_special_collect AS c ON art.id = c.yanxuan_special_id
  423. WHERE
  424. 1 = 1 AND art.status = 3 AND c.user_id=?
  425. ORDER BY create_time DESC
  426. LIMIT ?,? `
  427. _, err = orm.NewOrm().Raw(sql, userId, userId, startSize, pageSize).QueryRows(&items)
  428. return
  429. }
  430. func GetArticleUserBrowseHistoryCount(userId int, endDate string) (count int, err error) {
  431. sql := `SELECT COUNT( 1 ) as count
  432. FROM
  433. ( SELECT count(*) FROM cygx_article as art INNER JOIN cygx_article_history_record_newpv AS a ON art.article_id = a.article_id AND article_type_id > 0 WHERE a.user_id = ? AND a.create_time >= ? GROUP BY a.article_id ) b `
  434. err = orm.NewOrm().Raw(sql, userId, endDate).QueryRow(&count)
  435. return
  436. }
  437. //func GetArticleUserBrowseHistoryList(startSize, pageSize, userId int, endDate string) (items []*ArticleReportBillboardResp, err error) {
  438. // sql := `SELECT a.* , MAX( a.id ) AS mid FROM cygx_article as art INNER JOIN cygx_article_history_record_newpv AS a ON art.article_id = a.article_id AND article_type_id > 0
  439. // WHERE a.user_id=? AND a.create_time>=? GROUP BY a.article_id
  440. // ORDER BY mid DESC LIMIT ?,? `
  441. // _, err = orm.NewOrm().Raw(sql, userId, endDate, startSize, pageSize).QueryRows(&items)
  442. // return
  443. //}
  444. func GetArticleUserBrowseHistoryList(startSize, pageSize, userId int, endDate string) (items []*ArticleListResp, err error) {
  445. sql := `SELECT
  446. art.article_id,
  447. art.article_type_id,
  448. art.title,
  449. art.publish_date,
  450. '' AS company_tags,
  451. '' AS industry_tags,
  452. art.department_id,
  453. d.nick_name,
  454. 0 AS is_special,
  455. 0 as pv,
  456. 0 as collect_num,
  457. a.create_time
  458. FROM
  459. cygx_article AS art
  460. INNER JOIN cygx_article_history_record_newpv AS a ON art.article_id = a.article_id
  461. INNER JOIN cygx_article_department AS d ON d.department_id = art.department_id
  462. WHERE
  463. a.user_id = ?
  464. AND a.create_time >= ?
  465. AND art.article_type_id > 0
  466. GROUP BY
  467. art.article_id UNION ALL
  468. SELECT
  469. art.id AS article_id,
  470. - 1 AS article_type_id,
  471. art.title,
  472. art.publish_time AS publish_date,
  473. art.company_tags AS company_tags,
  474. art.industry_tags AS industry_tags,
  475. d.id AS department_id,
  476. d.nick_name,
  477. 1 AS is_special,
  478. art.pv,
  479. art.article_collect_num as collect_num,
  480. a.create_time
  481. FROM
  482. cygx_yanxuan_special AS art
  483. INNER JOIN cygx_yanxuan_special_record AS a ON art.id = a.yanxuan_special_id
  484. INNER JOIN cygx_yanxuan_special_author AS d ON d.user_id = art.user_id
  485. WHERE
  486. a.user_id = ?
  487. AND a.create_time >= ?
  488. GROUP BY
  489. art.id
  490. ORDER BY
  491. create_time DESC
  492. LIMIT ?,? `
  493. _, err = orm.NewOrm().Raw(sql, userId, endDate, userId, endDate, startSize, pageSize).QueryRows(&items)
  494. return
  495. }
  496. func GetUserMicroRoadshowCollectList(userId int) (items []*CygxArticleCollect, err error) {
  497. sql := `SELECT a.* FROM cygx_article_collect AS a
  498. WHERE a.user_id=?
  499. AND a.article_id =0
  500. ORDER BY a.create_time DESC `
  501. _, err = orm.NewOrm().Raw(sql, userId).QueryRows(&items)
  502. return
  503. }