wx_user.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hz_crm_api/utils"
  6. "time"
  7. )
  8. type WxUser struct {
  9. UserId int64 `orm:"column(user_id);pk"`
  10. Mobile string
  11. Email string
  12. CompanyId int
  13. RealName string `description:"姓名"`
  14. NickName string `description:"昵称"`
  15. CreatedTime time.Time
  16. MobileTwo string `description:"备用手机号"`
  17. BusinessCardUrl string `description:"名片"`
  18. IsMaker int `description:"是否决策人,1:是,0:否"`
  19. Position string `description:"职位"`
  20. Sex int `description:"普通用户性别,1为男性,2为女性"`
  21. DepartmentName string `description:"联系人部门"`
  22. RegisterTime time.Time
  23. RegisterPlatform int
  24. Remark string `description:"备注"`
  25. CountryCode string `description:"区号,86、852、886等"`
  26. OutboundMobile string `description:"外呼手机号"`
  27. OutboundCountryCode string `description:"外呼手机号区号,86、852、886等"`
  28. LastUpdatedTime time.Time `description:"最近一次更新时间"`
  29. IsDeal int `description:"是否标记处理 0-未处理 1-已处理"`
  30. OpenId string `orm:"column(open_id)" description:"微信openid"`
  31. Headimgurl string `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
  32. UserLabel string `description:"查研观向用户标签"`
  33. }
  34. func AddWxUser(item *WxUser) (lastId int64, err error) {
  35. o := orm.NewOrm()
  36. lastId, err = o.Insert(item)
  37. return
  38. }
  39. func GetWxUserByMobile(mobile string) (item *WxUser, err error) {
  40. o := orm.NewOrm()
  41. sql := `SELECT * FROM wx_user WHERE mobile = ? LIMIT 1`
  42. err = o.Raw(sql, mobile).QueryRow(&item)
  43. return
  44. }
  45. // GetWxUserByMobileCountryCode 根据手机号和区号获取用户信息
  46. func GetWxUserByMobileCountryCode(mobile, countryCode string) (item *WxUser, err error) {
  47. o := orm.NewOrm()
  48. sql := `SELECT * FROM wx_user WHERE mobile = ? `
  49. sql += ` and country_code in ("","` + countryCode + `") `
  50. sql += ` LIMIT 1 `
  51. err = o.Raw(sql, mobile).QueryRow(&item)
  52. return
  53. }
  54. func GetWxUserByUserId(userId int) (item *WxUser, err error) {
  55. o := orm.NewOrm()
  56. sql := `SELECT * FROM wx_user WHERE user_id=? `
  57. err = o.Raw(sql, userId).QueryRow(&item)
  58. return
  59. }
  60. // 更新wxUser信息
  61. func (wxUser *WxUser) Update(cols []string) (err error) {
  62. o := orm.NewOrm()
  63. _, err = o.Update(wxUser, cols...)
  64. return
  65. }
  66. type PotentialUserItem struct {
  67. UserId int `description:"用户id"`
  68. RealName string `description:"姓名"`
  69. CountryCode string `description:"区号,86、852、886等"`
  70. Mobile string `description:"手机号"`
  71. Email string `description:"邮箱"`
  72. CreatedTime string `description:"注册时间"`
  73. ApplyMethod int `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
  74. CompanyName string `description:"客户名称"`
  75. ViewTotal int `description:"累计阅读次数"`
  76. LastViewTime time.Time `json:"-" description:"最后一次阅读时间"`
  77. LastViewTimeStr string `description:"最后一次阅读时间"`
  78. FromType string `description:"report:研报,teleconference:电话会"`
  79. BusinessCardUrl string `description:"名片"`
  80. Source int `description:"来源,1:微信端,2:pc网页端,3:查研观向小程序,4:每日咨询,5:电话会"`
  81. IsDeal int `description:"是否标记处理,0是未处理,1是已处理"`
  82. }
  83. type PotentialUserListResp struct {
  84. List []*PotentialUserItem
  85. Paging *paging.PagingItem `description:"分页数据"`
  86. }
  87. // 联系人导入预览数据返回
  88. type ImportListResp struct {
  89. ValidUser []*WxUser `description:"有效客户数据"`
  90. RepeatUser []*WxUser `description:"重复客户数据"`
  91. }
  92. func GetPotentialUserListCount(condition string, pars []interface{}) (count int, err error) {
  93. o := orm.NewOrm()
  94. sql := `SELECT COUNT(1) AS count
  95. FROM wx_user AS a
  96. LEFT JOIN company AS b ON a.company_id = b.company_id
  97. LEFT JOIN user_record AS c ON a.user_id=c.user_id
  98. WHERE b.enabled = 1 AND b.company_id = 1
  99. AND (a.mobile IS NOT NULL || a.email IS NOT NULL)
  100. AND (a.mobile<>'' OR a.email<>'')
  101. AND (c.create_platform<>4 or c.create_platform is null)`
  102. if condition != "" {
  103. sql += condition
  104. }
  105. err = o.Raw(sql, pars).QueryRow(&count)
  106. return
  107. }
  108. func GetPotentialUserList(condition string, pars []interface{}, startSize, pageSize int) (items []*PotentialUserItem, err error) {
  109. o := orm.NewOrm()
  110. sql := `SELECT a.*,a.note AS company_name,
  111. IF(b.type IN (1,2),1,0) AS is_fee_customer,
  112. (SELECT count(1) FROM user_view_history AS uvh WHERE uvh.user_id=a.user_id GROUP BY a.user_id) AS view_total,
  113. a.report_last_view_time AS last_view_time_str,
  114. c.create_platform
  115. FROM wx_user AS a
  116. LEFT JOIN company AS b ON a.company_id = b.company_id
  117. LEFT JOIN user_record AS c ON a.user_id=c.user_id
  118. WHERE b.enabled = 1 AND b.company_id = 1
  119. AND (a.mobile IS NOT NULL || a.email IS NOT NULL)
  120. AND (a.mobile<>'' OR a.email<>'')
  121. AND (c.create_platform<>4 or c.create_platform is null) `
  122. if condition != "" {
  123. sql += condition
  124. }
  125. sql += ` GROUP BY a.user_id `
  126. sql += `ORDER BY a.created_time DESC LIMIT ?,? `
  127. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  128. return
  129. }
  130. type PotentialUserDeleteReq struct {
  131. UserId int `description:"用户id"`
  132. }
  133. // 标记潜在用户请求
  134. type PotentialUserDealReq struct {
  135. UserId int `description:"用户id"`
  136. }
  137. func DeletePotentialUser(userId int) (err error) {
  138. sql := ` DELETE FROM wx_user WHERE user_id=? `
  139. _, err = orm.NewOrm().Raw(sql, userId).Exec()
  140. return
  141. }
  142. // DeleteWxUserByUserIds 根据用户id字符串批量删除用户信息
  143. func DeleteWxUserByUserIds(userIds string) (err error) {
  144. sql := ` DELETE FROM wx_user WHERE user_id in (` + userIds + `) `
  145. _, err = orm.NewOrm().Raw(sql).Exec()
  146. return
  147. }
  148. // 移动潜在客户名下的联系人 请求数据
  149. type PotentialUserMoveReq struct {
  150. UserId int `description:"用户id"`
  151. CompanyId int `description:"移动到的客户id"`
  152. SellerId int `description:"需要移动到的销售id"`
  153. RealName string `description:"姓名"`
  154. Mobile string `description:"手机号"`
  155. Email string `description:"邮箱"`
  156. Remark string `description:"备注信息"`
  157. //crm4.0新增校验字段
  158. Sex int `description:"用户性别,1为男性,2为女性"`
  159. RegionType string `description:"区域,枚举值:国内、海外"`
  160. Position string `description:"职位"`
  161. IsMaker int `description:"是否决策人,1:是,0:否"`
  162. BusinessCardUrl string `description:"名片地址"`
  163. DepartmentName string `description:"联系人部门"`
  164. CountryCode string `description:"区号,86、852、886等"`
  165. }
  166. // 移动联系人请求数据
  167. type UserMoveReq struct {
  168. UserId int `description:"用户id"`
  169. CompanyId int `description:"移动到的客户id"`
  170. SellerId int `description:"需要移动到的销售id"`
  171. }
  172. // FICC申请单-移动潜在客户名下的联系人 请求数据
  173. type ApplyRecordPotentialUserMoveReq struct {
  174. UserId int `description:"用户id"`
  175. CompanyId int `description:"移动到的客户id"`
  176. SellerId int `description:"需要移动到的销售id"`
  177. RealName string `description:"姓名"`
  178. Mobile string `description:"手机号"`
  179. Email string `description:"邮箱"`
  180. Remark string `description:"备注信息"`
  181. ApplyRecordId int `description:"申请单ID"`
  182. Sex int `description:"用户性别,1为男性,2为女性"`
  183. RegionType string `description:"区域,枚举值:国内、海外"`
  184. Position string `description:"职位"`
  185. IsMaker int `description:"是否决策人,1:是,0:否"`
  186. BusinessCardUrl string `description:"名片地址"`
  187. DepartmentName string `description:"联系人部门"`
  188. CountryCode string `description:"区号,86、852、886等"`
  189. }
  190. func CheckUserMobileIsRegister(userId int, mobile string) (count int, err error) {
  191. sql := `SELECT COUNT(1) AS count FROM wx_user AS a
  192. INNER JOIN company AS b ON a.company_id = b.company_id
  193. WHERE a.mobile = ? AND a.user_id<> ? `
  194. o := orm.NewOrm()
  195. err = o.Raw(sql, mobile, userId).QueryRow(&count)
  196. return
  197. }
  198. func CheckUserEmailIsRegister(userId int, email string) (count int, err error) {
  199. sql := `SELECT COUNT(1) AS count FROM wx_user AS a
  200. INNER JOIN company AS b ON a.company_id = b.company_id
  201. WHERE a.email = ? AND a.user_id<> ? `
  202. o := orm.NewOrm()
  203. err = o.Raw(sql, email, userId).QueryRow(&count)
  204. return
  205. }
  206. // 移动潜在客户名下的联系人
  207. func MovePotentialUser(userId, companyId int, realName, mobile, email, remark string) (err error) {
  208. if realName != "" {
  209. sql := ` UPDATE wx_user
  210. SET
  211. company_id = ?,
  212. real_name = ?,
  213. mobile = ?,
  214. email = ?,
  215. remark = ?,
  216. last_updated_time = NOW(),
  217. is_note = 1
  218. WHERE user_id = ? `
  219. _, err = orm.NewOrm().Raw(sql, companyId, realName, mobile, email, remark, userId).Exec()
  220. } else {
  221. sql := ` UPDATE wx_user
  222. SET
  223. company_id = ?,
  224. mobile = ?,
  225. email = ?,
  226. remark = ?,
  227. last_updated_time = NOW(),
  228. is_note = 1
  229. WHERE user_id = ? `
  230. _, err = orm.NewOrm().Raw(sql, companyId, mobile, email, remark, userId).Exec()
  231. }
  232. return
  233. }
  234. // 移动联系人
  235. func MoveUser(userId, companyId int) (err error) {
  236. sql := ` UPDATE wx_user
  237. SET
  238. company_id = ?,
  239. last_updated_time = NOW(),
  240. is_note = 1
  241. WHERE user_id = ? `
  242. _, err = orm.NewOrm().Raw(sql, companyId, userId).Exec()
  243. return
  244. }
  245. type ReportViewRecordTotal struct {
  246. ViewTotal int
  247. LastViewTime time.Time
  248. }
  249. func GetReportViewMaxTime(uid int) (item *ReportViewRecordTotal, err error) {
  250. o := orm.NewOrmUsingDB("rddp")
  251. rddpSql := "SELECT MAX(create_time) AS last_view_time,COUNT(1) AS view_total FROM report_view_record WHERE user_id=? "
  252. err = o.Raw(rddpSql, uid).QueryRow(&item)
  253. return
  254. }
  255. // 根据用户id字符串获取用户的浏览数
  256. func GetReportViewMaxTimeByUserIds(userIds string) (items []*ReportViewRecord, err error) {
  257. o := orm.NewOrmUsingDB("rddp")
  258. rddpSql := `SELECT user_id,MAX(create_time) AS last_view_time,COUNT(1) AS view_total FROM report_view_record WHERE user_id in (` + userIds + `) group by user_id`
  259. _, err = o.Raw(rddpSql).QueryRows(&items)
  260. return
  261. }
  262. // 根据用户手机号字符串获取用户的浏览数
  263. type ReportViewMobileRecord struct {
  264. Mobile string
  265. ViewTotal int
  266. LastViewTime time.Time
  267. }
  268. func GetReportViewMaxTimeByMobiles(mobiles string) (items []*ReportViewMobileRecord, err error) {
  269. o := orm.NewOrmUsingDB("rddp")
  270. rddpSql := `SELECT mobile,MAX(create_time) AS last_view_time,COUNT(1) AS view_total FROM report_view_record WHERE mobile in (` + mobiles + `) group by mobile`
  271. _, err = o.Raw(rddpSql).QueryRows(&items)
  272. return
  273. }
  274. // 根据用户邮箱字符串获取用户的浏览数
  275. type ReportViewEmailRecord struct {
  276. Email string
  277. ViewTotal int
  278. LastViewTime time.Time
  279. }
  280. func GetReportViewMaxTimeByEmails(emails string) (items []*ReportViewEmailRecord, err error) {
  281. o := orm.NewOrmUsingDB("rddp")
  282. rddpSql := `SELECT email,MAX(create_time) AS last_view_time,COUNT(1) AS view_total FROM report_view_record WHERE email in (` + emails + `) group by email`
  283. _, err = o.Raw(rddpSql).QueryRows(&items)
  284. return
  285. }
  286. func GetPotentialUserListExport(condition string, pars []interface{}) (items []*PotentialUserItem, err error) {
  287. o := orm.NewOrm()
  288. sql := `SELECT DISTINCT a.*,b.company_name,
  289. IF(b.type IN (1,2),1,0) AS is_fee_customer,
  290. (SELECT count(1) FROM user_view_history AS uvh WHERE uvh.user_id=a.user_id GROUP BY a.user_id) AS view_total,
  291. (SELECT max(uvh.created_time) FROM user_view_history AS uvh WHERE uvh.user_id=a.user_id GROUP BY a.user_id) AS last_view_time
  292. FROM wx_user AS a
  293. LEFT JOIN company AS b ON a.company_id = b.company_id
  294. INNER JOIN user_record AS c ON a.user_id=c.user_id
  295. WHERE b.enabled = 1 AND b.company_id = 1
  296. AND (a.mobile IS NOT NULL || a.email IS NOT NULL)
  297. AND (a.mobile<>'' OR a.email<>'')
  298. AND c.create_platform<>4 `
  299. if condition != "" {
  300. sql += condition
  301. }
  302. sql += `ORDER BY a.last_updated_time DESC `
  303. _, err = o.Raw(sql, pars).QueryRows(&items)
  304. return
  305. }
  306. type WxUserDetail struct {
  307. UserId int64 `orm:"column(user_id);pk"`
  308. CountryCode string `description:"区号,86、852、886等"`
  309. Mobile string
  310. Email string
  311. CompanyId int
  312. RealName string `description:"姓名"`
  313. CreatedTime time.Time
  314. MobileTwo string `description:"备用手机号"`
  315. BusinessCardUrl string `description:"名片"`
  316. IsMaker int `description:"是否决策人,1:是,0:否"`
  317. Position string `description:"职位"`
  318. Sex int `description:"普通用户性别,1为男性,2为女性"`
  319. CompanyName string `description:"公司名称"`
  320. DepartmentName string `description:"联系人部门"`
  321. SellerRealName string `description:"销售"`
  322. }
  323. // GetWxUserListByUserIds 根据用户ID集合获取用户
  324. func GetWxUserListByUserIds(userIds string) (list []*WxUser, err error) {
  325. o := orm.NewOrm()
  326. sql := ` SELECT * FROM wx_user WHERE user_id IN (` + userIds + `) `
  327. _, err = o.Raw(sql).QueryRows(&list)
  328. return
  329. }
  330. // GetWxUserByCompanyIdAndMobile 根据客户ID及手机号获取用户
  331. func GetWxUserByCompanyIdAndMobile(companyId int, mobile string) (item *WxUser, err error) {
  332. o := orm.NewOrm()
  333. sql := ` SELECT * FROM wx_user WHERE company_id = ? AND mobile = ? LIMIT 1 `
  334. err = o.Raw(sql, companyId, mobile).QueryRow(&item)
  335. return
  336. }
  337. // DeleteWxUserAndRecordByUserId 删除用户及第三方信息
  338. func DeleteWxUserAndRecordByUserId(userId int) (err error) {
  339. o := orm.NewOrm()
  340. to, err := o.Begin()
  341. if err != nil {
  342. return
  343. }
  344. defer func() {
  345. if err != nil {
  346. _ = to.Rollback()
  347. } else {
  348. _ = to.Commit()
  349. }
  350. }()
  351. // 删除wx_user
  352. userSql := ` DELETE FROM wx_user WHERE user_id = ? LIMIT 1 `
  353. _, err = to.Raw(userSql, userId).Exec()
  354. // 删除user_record
  355. if err == nil {
  356. recordSql := ` DELETE FROM user_record WHERE user_id = ? `
  357. _, err = to.Raw(recordSql, userId).Exec()
  358. }
  359. return
  360. }
  361. // 获取这个公司下面所有用户的手机号
  362. func GetCompanyUserMobilesByCompanyId(companyId int) (mobiles string, err error) {
  363. o := orm.NewOrm()
  364. sql := ` SELECT GROUP_CONCAT( DISTINCT a.mobile SEPARATOR ',' ) AS mobiles FROM
  365. wx_user AS a WHERE company_id = ? AND mobile != '' `
  366. err = o.Raw(sql, companyId).QueryRow(&mobiles)
  367. return
  368. }
  369. // 获取这个公司下面所有用户的邮箱号
  370. func GetCompanyUserEmailsByCompanyId(companyId int) (emails string, err error) {
  371. o := orm.NewOrm()
  372. sql := ` SELECT GROUP_CONCAT( DISTINCT a.email SEPARATOR ',' ) AS emails FROM
  373. wx_user AS a WHERE company_id = ? AND email != '' `
  374. err = o.Raw(sql, companyId).QueryRow(&emails)
  375. return
  376. }
  377. // 获取这个公司下面所有用户的手机号
  378. func SetUserSubscribe(openId string) (err error) {
  379. o := orm.NewOrm()
  380. sql := ` UPDATE user_record SET subscribe=1,subscribe_time=NOW() WHERE open_id=? `
  381. _, err = o.Raw(sql, openId).Exec()
  382. return
  383. }
  384. type WxUserItem struct {
  385. UserId int `description:"用户id"`
  386. OpenId string `description:"open_id"`
  387. UnionId string `description:"union_id"`
  388. CompanyId int `description:"客户id"`
  389. NickName string `description:"用户昵称"`
  390. RealName string `description:"用户实际名称"`
  391. Mobile string `description:"手机号码"`
  392. BindAccount string `description:"绑定时的账号"`
  393. Email string `description:"邮箱"`
  394. Headimgurl string `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
  395. ApplyMethod int `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
  396. FirstLogin int `description:"是否第一次登陆"`
  397. IsFreeLogin int `description:"是否免登陆,true:免登陆,false:非免登陆"`
  398. LoginTime time.Time `description:"登录时间"`
  399. CreatedTime time.Time `description:"创建时间"`
  400. LastUpdatedTime time.Time `description:"最近一次修改时间"`
  401. SessionKey string `description:"微信小程序会话密钥"`
  402. CompanyName string `description:"公司名称"`
  403. IsRegister int `description:"是否注册:1:已注册,0:未注册"`
  404. CountryCode string `description:"手机国家区号"`
  405. OutboundMobile string `description:"外呼手机号"`
  406. OutboundCountryCode string `description:"外呼手机号区号"`
  407. IsMsgOutboundMobile int `description:"是否弹窗过绑定外呼手机号区号"`
  408. IsMaker int `description:"是否是决策人"`
  409. Source int
  410. }
  411. // GetWxUserListByUserIds 根据用户ID集合获取用户有公司名称
  412. func GetWxUserListByUserIdsHaveCompany(userIds string) (list []*WxUserItem, err error) {
  413. o := orm.NewOrm()
  414. sql := ` SELECT u.*, c.company_name FROM wx_user AS u
  415. INNER JOIN company AS c ON c.company_id = u.company_id
  416. WHERE user_id IN (` + userIds + `) `
  417. _, err = o.Raw(sql).QueryRows(&list)
  418. return
  419. }
  420. // GetWxUserByAdminId 通过后台用户ID及微信平台获取对应的微信用户
  421. func GetWxUserByAdminId(platform, adminId int) (item *WxUser, err error) {
  422. o := orm.NewOrm()
  423. sql := `SELECT
  424. wu.user_id
  425. FROM
  426. wx_user AS wu
  427. JOIN user_record AS ur ON wu.user_id = ur.user_id AND ur.create_platform = ?
  428. JOIN admin AS ad ON wu.mobile = ad.mobile
  429. WHERE
  430. ad.admin_id = ?`
  431. err = o.Raw(sql, platform, adminId).QueryRow(&item)
  432. return
  433. }
  434. // GetWxUserByOutboundMobiles 根据用户手机号获取用户详情
  435. func GetWxUserByOutboundMobiles(mobiles []string) (items []*WxUser, err error) {
  436. lenmobiles := len(mobiles)
  437. if lenmobiles == 0 {
  438. return
  439. }
  440. sql := `SELECT* FROM wx_user WHERE outbound_mobile in (` + utils.GetOrmInReplace(lenmobiles) + `) `
  441. o := orm.NewOrm()
  442. _, err = o.Raw(sql, mobiles).QueryRows(&items)
  443. return
  444. }
  445. // GetWxUserByUserIds 根据用户ID获取用户详情
  446. func GetWxUserByUserIds(userIds []int) (items []*WxUser, err error) {
  447. lenuserIds := len(userIds)
  448. if lenuserIds == 0 {
  449. return
  450. }
  451. sql := `SELECT* FROM wx_user WHERE user_id in (` + utils.GetOrmInReplace(lenuserIds) + `) `
  452. o := orm.NewOrm()
  453. _, err = o.Raw(sql, userIds).QueryRows(&items)
  454. return
  455. }
  456. // GetWxUserListByUserMobileHaveCompany 根据用户手机号集合获取用户有公司名称
  457. func GetWxUserListByUserMobileHaveCompany(mobiles []string) (list []*WxUserItem, err error) {
  458. lenmobiles := len(mobiles)
  459. if lenmobiles == 0 {
  460. return
  461. }
  462. o := orm.NewOrm()
  463. sql := ` SELECT u.*, c.company_name FROM wx_user AS u
  464. INNER JOIN company AS c ON c.company_id = u.company_id
  465. WHERE mobile in (` + utils.GetOrmInReplace(lenmobiles) + `) `
  466. _, err = o.Raw(sql, mobiles).QueryRows(&list)
  467. return
  468. }
  469. // GetWxUserListCompanyId 根据公司ID获取所有用户信息
  470. func GetWxUserListCompanyId(companyId int) (list []*WxUserItem, err error) {
  471. o := orm.NewOrm()
  472. sql := ` SELECT* FROM wx_user WHERE company_id = ? `
  473. _, err = o.Raw(sql, companyId).QueryRows(&list)
  474. return
  475. }