user.go 20 KB

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