activity_signup.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. package models
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type CygxActivitySignup struct {
  8. Id int `orm:"column(id);pk"`
  9. ActivityId int `description:"活动ID"`
  10. UserId int `description:"用户ID"`
  11. CreateTime time.Time `description:"创建时间"`
  12. Mobile string `description:"手机号"`
  13. Email string `description:"邮箱"`
  14. CompanyId int `description:"公司id"`
  15. CompanyName string `description:"公司名称"`
  16. FailType int `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
  17. SignupType int `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
  18. DoFailType int `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
  19. OutboundMobile string `description:"外呼手机号"`
  20. CountryCode string `description:"手机国家区号"`
  21. RealName string `description:"用户实际名称"`
  22. SellerName string `description:"所属销售"`
  23. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  24. }
  25. type SignupStatus struct {
  26. SignupStatus string `description:"返回状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  27. GoFollow bool `description:"是否去关注"`
  28. SignupType int `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
  29. ActivityId int `description:"活动ID"`
  30. HaqveJurisdiction bool `description:"是否有权限"`
  31. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  32. PopupMsg string `description:"权限弹窗信息"`
  33. SellerMobile string `description:"销售电话"`
  34. SellerName string `description:"销售姓名"`
  35. Mobile string `description:"外呼手机号"`
  36. CountryCode string `description:"外呼手机号区号"`
  37. GoOutboundMobile bool `description:"是否去绑定手机号"`
  38. GoBindEmail bool `description:"是否去绑定邮箱"`
  39. IsResearch bool `description:"是否属于研选"`
  40. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  41. }
  42. type ActivitySingnupRep struct {
  43. ActivityId int `description:"活动id"`
  44. SignupType int `description:"报名方式,,1预约外呼,2自主拨入,3我要报名"`
  45. Email string `description:"邮箱号"`
  46. }
  47. // 我的日程
  48. type CygxMySchedule struct {
  49. Id int `orm:"column(id);pk"`
  50. ActivityId int `description:"活动ID"`
  51. UserId int `description:"用户ID"`
  52. CreateTime time.Time `description:"创建时间"`
  53. Mobile string `description:"手机号"`
  54. Email string `description:"邮箱"`
  55. CompanyId int `description:"公司id"`
  56. CompanyName string `description:"公司名称"`
  57. }
  58. // 报名记录日志
  59. type CygxActivitySignupLog struct {
  60. Id int `orm:"column(id);pk"`
  61. ActivityId int `description:"活动ID"`
  62. UserId int `description:"用户ID"`
  63. CreateTime time.Time `description:"创建时间"`
  64. Mobile string `description:"手机号"`
  65. Email string `description:"邮箱"`
  66. CompanyId int `description:"公司id"`
  67. CompanyName string `description:"公司名称"`
  68. Type int `description:"操作方式,1报名,2取消报名"`
  69. }
  70. // 添加报名信息
  71. func AddActivitySignup(item *CygxActivitySignup) (lastId int64, err error) {
  72. o, err := orm.NewOrm().Begin()
  73. if err != nil {
  74. return
  75. }
  76. defer func() {
  77. fmt.Println(err)
  78. if err == nil {
  79. o.Commit()
  80. } else {
  81. o.Rollback()
  82. }
  83. }()
  84. var count int
  85. var countMySchedule int
  86. sql := `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
  87. err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countMySchedule)
  88. if err != nil {
  89. return
  90. }
  91. if countMySchedule == 0 {
  92. itemMy := new(CygxMySchedule)
  93. itemMy.UserId = item.UserId
  94. itemMy.ActivityId = item.ActivityId
  95. itemMy.CreateTime = time.Now()
  96. itemMy.Mobile = item.Mobile
  97. itemMy.Email = item.Email
  98. itemMy.CompanyId = item.CompanyId
  99. itemMy.CompanyName = item.CompanyName
  100. lastId, err = o.Insert(itemMy)
  101. if err != nil {
  102. return
  103. }
  104. }
  105. sql = `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE user_id=? AND activity_id=? `
  106. err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&count)
  107. if err != nil {
  108. return
  109. }
  110. if count > 0 {
  111. sql := `UPDATE cygx_activity_signup SET is_cancel = 0 ,do_fail_type = 0, signup_type=? WHERE user_id=? AND activity_id=? `
  112. _, err = o.Raw(sql, item.SignupType, item.UserId, item.ActivityId).Exec()
  113. } else {
  114. lastId, err = o.Insert(item)
  115. }
  116. if err != nil {
  117. return
  118. }
  119. itemLog := new(CygxActivitySignupLog)
  120. itemLog.UserId = item.UserId
  121. itemLog.ActivityId = item.ActivityId
  122. itemLog.CreateTime = time.Now()
  123. itemLog.Mobile = item.Mobile
  124. itemLog.Email = item.Email
  125. itemLog.CompanyId = item.CompanyId
  126. itemLog.CompanyName = item.CompanyName
  127. itemLog.Type = 1
  128. lastId, err = o.Insert(itemLog)
  129. return
  130. }
  131. // 仅绑定邮箱的用户修改报名后,添加报名信息
  132. func AddActivitySignupFromEmail(item *CygxActivitySignup) (lastId int64, err error) {
  133. o, err := orm.NewOrm().Begin()
  134. if err != nil {
  135. return
  136. }
  137. defer func() {
  138. fmt.Println(err)
  139. if err == nil {
  140. o.Commit()
  141. } else {
  142. o.Rollback()
  143. }
  144. }()
  145. var count int
  146. var countMySchedule int
  147. sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ? ,is_msg_outbound_mobile = 1 WHERE user_id=? `
  148. _, err = o.Raw(sql, item.OutboundMobile, item.CountryCode, item.UserId).Exec()
  149. if err != nil {
  150. return
  151. }
  152. sql = `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
  153. err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countMySchedule)
  154. if err != nil {
  155. return
  156. }
  157. if countMySchedule == 0 {
  158. itemMy := new(CygxMySchedule)
  159. itemMy.UserId = item.UserId
  160. itemMy.ActivityId = item.ActivityId
  161. itemMy.CreateTime = time.Now()
  162. itemMy.Mobile = item.Mobile
  163. itemMy.Email = item.Email
  164. itemMy.CompanyId = item.CompanyId
  165. itemMy.CompanyName = item.CompanyName
  166. lastId, err = o.Insert(itemMy)
  167. if err != nil {
  168. return
  169. }
  170. }
  171. sql = `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE user_id=? AND activity_id=? `
  172. err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&count)
  173. if err != nil {
  174. return
  175. }
  176. if count > 0 {
  177. sql := `UPDATE cygx_activity_signup SET is_cancel = 0 ,do_fail_type = 0, signup_type=? WHERE user_id=? AND activity_id=? `
  178. _, err = o.Raw(sql, item.SignupType, item.UserId, item.ActivityId).Exec()
  179. } else {
  180. lastId, err = o.Insert(item)
  181. }
  182. if err != nil {
  183. return
  184. }
  185. itemLog := new(CygxActivitySignupLog)
  186. itemLog.UserId = item.UserId
  187. itemLog.ActivityId = item.ActivityId
  188. itemLog.CreateTime = time.Now()
  189. itemLog.Mobile = item.Mobile
  190. itemLog.Email = item.Email
  191. itemLog.CompanyId = item.CompanyId
  192. itemLog.CompanyName = item.CompanyName
  193. itemLog.Type = 1
  194. lastId, err = o.Insert(itemLog)
  195. return
  196. }
  197. // 添加报名信息
  198. func AddActivitySignupNoSchedule(item *CygxActivitySignup) (lastId int64, err error) {
  199. o, err := orm.NewOrm().Begin()
  200. if err != nil {
  201. return
  202. }
  203. defer func() {
  204. fmt.Println(err)
  205. if err == nil {
  206. o.Commit()
  207. } else {
  208. o.Rollback()
  209. }
  210. }()
  211. lastId, err = o.Insert(item)
  212. if err != nil {
  213. return
  214. }
  215. itemLog := new(CygxActivitySignupLog)
  216. itemLog.UserId = item.UserId
  217. itemLog.ActivityId = item.ActivityId
  218. itemLog.CreateTime = time.Now()
  219. itemLog.Mobile = item.Mobile
  220. itemLog.Email = item.Email
  221. itemLog.CompanyId = item.CompanyId
  222. itemLog.CompanyName = item.CompanyName
  223. itemLog.Type = 1
  224. lastId, err = o.Insert(itemLog)
  225. return
  226. }
  227. // 获取用户报名成功数量
  228. func GetActivitySignupCount(uid, activityId int) (count int, err error) {
  229. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0 AND do_fail_type = 0 AND user_id=? AND activity_id=? `
  230. o := orm.NewOrm()
  231. err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
  232. return
  233. }
  234. // 获取用户报名数量
  235. func GetActivitySignupByUserCount(uid, activityId int) (count int, err error) {
  236. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0 AND user_id=? AND activity_id=? `
  237. o := orm.NewOrm()
  238. err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
  239. return
  240. }
  241. // 获取除弘则以外所有成功报名的用户数量
  242. func GetActivitySignupSuccessByUserCountNoHz(activityId int) (count int, err error) {
  243. sqlCount := `SELECT
  244. COUNT( 1 ) AS count
  245. FROM
  246. cygx_activity_signup
  247. WHERE
  248. is_cancel = 0
  249. AND company_id != 16
  250. AND do_fail_type = 0
  251. AND activity_id = ? `
  252. o := orm.NewOrm()
  253. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  254. return
  255. }
  256. // 获取用户报名禁止数量
  257. func GetActivitySignupByUserRestrictCount(uid, activityId int) (count int, err error) {
  258. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE do_fail_type=3 AND user_id=? AND activity_id=? `
  259. o := orm.NewOrm()
  260. err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
  261. return
  262. }
  263. // 获取某一活动已经报名的数量
  264. func GetActivitySignupSuccessCount(activityId int) (count int, err error) {
  265. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0 AND do_fail_type = 0 AND activity_id=? `
  266. o := orm.NewOrm()
  267. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  268. return
  269. }
  270. // 获取某一活动某个机构已经报名的数量
  271. func GetActivitySignupCompanyCount(activityId, companyId int) (count int, err error) {
  272. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0 AND fail_type = 0 AND activity_id=? AND company_id=? `
  273. o := orm.NewOrm()
  274. err = o.Raw(sqlCount, activityId, companyId).QueryRow(&count)
  275. return
  276. }
  277. // 获取某一用户是否被限制报名
  278. func GetUserRestrictCount(mobile string) (count int, err error) {
  279. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_restrict_signup WHERE is_restrict=1 AND mobile=? `
  280. o := orm.NewOrm()
  281. err = o.Raw(sqlCount, mobile).QueryRow(&count)
  282. return
  283. }
  284. // 获取某一用户的日程数量
  285. func GetUserMeetingReminderCount(uid int) (count int, err error) {
  286. sqlCount := `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? `
  287. o := orm.NewOrm()
  288. err = o.Raw(sqlCount, uid).QueryRow(&count)
  289. return
  290. }
  291. // 获取某一用户的报名的数量
  292. func GetUserSignupCount(uid int) (count int, err error) {
  293. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup_log WHERE user_id=? `
  294. o := orm.NewOrm()
  295. err = o.Raw(sqlCount, uid).QueryRow(&count)
  296. return
  297. }
  298. // 取消报名
  299. func CancelActivitySignup(item *CygxActivitySignup) (lastId int64, err error) {
  300. o, err := orm.NewOrm().Begin()
  301. if err != nil {
  302. return
  303. }
  304. defer func() {
  305. fmt.Println(err)
  306. if err == nil {
  307. o.Commit()
  308. } else {
  309. o.Rollback()
  310. }
  311. }()
  312. //判断是否删除我的日程
  313. var countReminder int
  314. var countAppointment int
  315. sql := `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder WHERE is_cancel = 0 AND user_id=? AND activity_id=? `
  316. err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countReminder)
  317. sql = `SELECT COUNT(1) AS count FROM cygx_activity_appointment WHERE user_id=? AND activity_id=? `
  318. err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countAppointment)
  319. if err != nil {
  320. return
  321. }
  322. if countReminder == 0 && countAppointment == 0 {
  323. sql = `DELETE FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
  324. _, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
  325. if err != nil {
  326. return
  327. }
  328. }
  329. sql = `DELETE FROM cygx_activity_signup WHERE user_id=? AND activity_id=? `
  330. _, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
  331. if err != nil {
  332. return
  333. }
  334. itemLog := new(CygxActivitySignupLog)
  335. itemLog.UserId = item.UserId
  336. itemLog.ActivityId = item.ActivityId
  337. itemLog.CreateTime = time.Now()
  338. itemLog.Mobile = item.Mobile
  339. itemLog.Email = item.Email
  340. itemLog.CompanyId = item.CompanyId
  341. itemLog.CompanyName = item.CompanyName
  342. itemLog.Type = 2
  343. lastId, err = o.Insert(itemLog)
  344. return
  345. }
  346. // 详情
  347. func GetActivitySignupDetail(activityId, uid int) (item *CygxActivitySignup, err error) {
  348. o := orm.NewOrm()
  349. sql := `SELECT * FROM cygx_activity_signup WHERE activity_id = ? AND user_id =? `
  350. err = o.Raw(sql, activityId, uid).QueryRow(&item)
  351. return
  352. }
  353. func GetActivitySignuListByUser(condition string, pars []interface{}) (item []*CygxActivitySignup, err error) {
  354. o := orm.NewOrm()
  355. sql := `SELECT *
  356. FROM
  357. cygx_activity_signup
  358. WHERE 1 = 1 ` + condition
  359. _, err = o.Raw(sql, pars).QueryRows(&item)
  360. return
  361. }
  362. // 解除报名限制之后二次报名
  363. func AddActivitySignupByRestrict(item *CygxActivitySignup) (lastId int64, err error) {
  364. o, err := orm.NewOrm().Begin()
  365. if err != nil {
  366. return
  367. }
  368. defer func() {
  369. fmt.Println(err)
  370. if err == nil {
  371. o.Commit()
  372. } else {
  373. o.Rollback()
  374. }
  375. }()
  376. itemMy := new(CygxMySchedule)
  377. itemMy.UserId = item.UserId
  378. itemMy.ActivityId = item.ActivityId
  379. itemMy.CreateTime = time.Now()
  380. itemMy.Mobile = item.Mobile
  381. itemMy.Email = item.Email
  382. itemMy.CompanyId = item.CompanyId
  383. itemMy.CompanyName = item.CompanyName
  384. lastId, err = o.Insert(itemMy)
  385. if err != nil {
  386. return
  387. }
  388. sql := `UPDATE cygx_activity_signup SET do_fail_type = 0 , fail_type=0 WHERE user_id=? AND activity_id=? `
  389. _, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
  390. itemLog := new(CygxActivitySignupLog)
  391. itemLog.UserId = item.UserId
  392. itemLog.ActivityId = item.ActivityId
  393. itemLog.CreateTime = time.Now()
  394. itemLog.Mobile = item.Mobile
  395. itemLog.Email = item.Email
  396. itemLog.CompanyId = item.CompanyId
  397. itemLog.CompanyName = item.CompanyName
  398. itemLog.Type = 1
  399. lastId, err = o.Insert(itemLog)
  400. return
  401. }
  402. // 列表
  403. func GetActivitySignupListAll() (items []*CygxActivitySignup, err error) {
  404. o := orm.NewOrm()
  405. sql := `SELECT * FROM cygx_activity_signup `
  406. _, err = o.Raw(sql).QueryRows(&items)
  407. return
  408. }
  409. // 修改是否推送消息状态
  410. func UPdateSignup(item *CygxActivitySignup) (err error) {
  411. sql := ` UPDATE cygx_activity_signup SET outbound_mobile= ? , country_code=86 WHERE id = ?`
  412. o := orm.NewOrm()
  413. _, err = o.Raw(sql, item.Mobile, item.Id).Exec()
  414. return
  415. }
  416. // 获取数量
  417. func GetActivityCountByIdWithUid(activityId, Uid int) (count int, err error) {
  418. o := orm.NewOrm()
  419. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE activity_id = ? AND user_id = ?`
  420. err = o.Raw(sqlCount, activityId, Uid).QueryRow(&count)
  421. return
  422. }
  423. // 获取用户报名数量
  424. func GetActivitySignupNomeetingCount(activityId int) (count int, err error) {
  425. sqlCount := `SELECT
  426. COUNT( 1 ) count
  427. FROM
  428. cygx_activity_signup AS s
  429. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  430. WHERE
  431. 1 = 1
  432. AND a.is_limit_people > 0
  433. AND s.is_meeting = 0
  434. AND a.is_submit_meeting = 1
  435. AND a.activity_id = ?`
  436. o := orm.NewOrm()
  437. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  438. return
  439. }
  440. func GetUserMeetingMobile(activityId int) (items []*CygxActivitySignup, err error) {
  441. o := orm.NewOrm()
  442. sql := `SELECT *
  443. FROM
  444. cygx_activity_signup AS s
  445. WHERE
  446. s.is_meeting = 1
  447. AND s.activity_id = ?`
  448. _, err = o.Raw(sql, activityId).QueryRows(&items)
  449. return
  450. }
  451. // 获取用户是否被限制报名
  452. func GetRestrictSignupCountByUid(uid int) (count int, err error) {
  453. sqlCount := `SELECT COUNT( 1 ) count FROM cygx_activity_restrict_signup WHERE user_id = ?`
  454. o := orm.NewOrm()
  455. err = o.Raw(sqlCount, uid).QueryRow(&count)
  456. return
  457. }
  458. // 获取用户爽约次数
  459. func GetActivitySignupNomeetingCountByUid(uid int) (count int, err error) {
  460. sqlCount := `SELECT
  461. COUNT( 1 ) count
  462. FROM
  463. cygx_activity_signup AS s
  464. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  465. WHERE
  466. 1 = 1
  467. AND a.is_limit_people > 0
  468. AND s.is_meeting = 0
  469. AND a.is_submit_meeting = 1
  470. AND s.do_fail_type = 0
  471. AND s.user_id = ?`
  472. o := orm.NewOrm()
  473. err = o.Raw(sqlCount, uid).QueryRow(&count)
  474. return
  475. }
  476. // 删除
  477. func DeleteCygxActivityRestrictSignup(uid int) (err error) {
  478. o := orm.NewOrm()
  479. sql := ` DELETE FROM cygx_activity_restrict_signup WHERE user_id=?`
  480. _, err = o.Raw(sql, uid).Exec()
  481. return
  482. }
  483. type CygxActivitySignupList struct {
  484. Id int `orm:"column(id);pk"`
  485. UserId int `description:"用户id"`
  486. ActivityId int `description:"活动ID"`
  487. CompanyName string `description:"公司名称"`
  488. RealName string `description:"姓名"`
  489. CreateTime string `description:"创建时间"`
  490. IsMeeting int `description:"是否到会 ,1是, 0否"`
  491. Operation bool `description:"操作按钮,true,到会,false 未到会"`
  492. Channel int `description:"报名渠道,0 空降、 1小程序报名"`
  493. }
  494. // 获取用户报名列表
  495. func GetActivitySignupNomeetingCountList(activityId int) (items []*CygxActivitySignupList, err error) {
  496. o := orm.NewOrm()
  497. sql := `SELECT
  498. s.user_id
  499. FROM
  500. cygx_activity_signup AS s
  501. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  502. WHERE
  503. 1 = 1
  504. AND a.is_limit_people > 0
  505. AND s.is_meeting = 0
  506. AND a.is_submit_meeting = 1
  507. AND a.activity_id = ?`
  508. _, err = o.Raw(sql, activityId).QueryRows(&items)
  509. return
  510. }
  511. type UserAndCompanyName struct {
  512. UserId int `orm:"column(user_id);pk"`
  513. Mobile string
  514. Email string
  515. CompanyId int
  516. CompanyName string `description:"公司名称"`
  517. CountryCode string `description:"手机国家区号"`
  518. OutboundMobile string `description:"外呼手机号"`
  519. OutboundCountryCode string `description:"外呼手机号区号"`
  520. }
  521. func GetUserAndCompanyNameList(uid int) (item *UserAndCompanyName, err error) {
  522. o := orm.NewOrm()
  523. sql := ` SELECT u.*,c.company_name
  524. FROM wx_user AS u
  525. INNER JOIN company AS c ON c.company_id = u.company_id
  526. WHERE user_id =?`
  527. err = o.Raw(sql, uid).QueryRow(&item)
  528. return
  529. }
  530. type CygxActivityRestrictSignup struct {
  531. Id int `orm:"column(id);pk"`
  532. UserId int `description:"用户id,多个用,隔开"`
  533. CreateTime time.Time `description:"创建时间"`
  534. Mobile string `description:"手机号"`
  535. Email string `description:"邮箱号"`
  536. CompanyId int `description:"公司ID"`
  537. CompanyName string `description:"公司名称"`
  538. IsRestrict int `description:"是否限制报名,1是,0否"`
  539. }
  540. // 添加
  541. func AddCygxActivityRestrictSignup(item *CygxActivityRestrictSignup) (err error) {
  542. o := orm.NewOrm()
  543. _, err = o.Insert(item)
  544. return
  545. }
  546. // 获取列表信息根据手机号分组
  547. func GetCygxActivitySignupByMobileList(condition string) (items []*CygxActivitySignup, err error) {
  548. o := orm.NewOrm()
  549. sql := `SELECT * FROM cygx_activity_signup WHERE 1= 1 ` + condition + ` GROUP BY mobile `
  550. _, err = o.Raw(sql).QueryRows(&items)
  551. return
  552. }
  553. // 修改用户报名的相关信息
  554. func UpdateCygxActivitySignup(wxUser *WxUserItem) (err error) {
  555. o := orm.NewOrm()
  556. sql := `UPDATE cygx_activity_signup SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
  557. _, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
  558. return
  559. }
  560. // UpdateCygxActivitySignupisMeet 修改易董的活动,用户已到会
  561. func UpdateCygxActivitySignupisMeet(activityId int, mobile string) (err error) {
  562. o := orm.NewOrm()
  563. sql := `UPDATE cygx_activity_signup SET is_meeting=1 WHERE activity_id=? AND mobile = ? `
  564. _, err = o.Raw(sql, activityId, mobile).Exec()
  565. return
  566. }
  567. // GetCygxCygxActivitySignupList 获取报名列表信息
  568. func GetActivitySignupList(condition string, pars []interface{}) (items []*CygxActivitySignup, err error) {
  569. sql := `SELECT
  570. signup_type,activity_id
  571. FROM
  572. cygx_activity_signup AS v
  573. WHERE
  574. 1 = 1 ` + condition
  575. o := orm.NewOrm()
  576. _, err = o.Raw(sql, pars).QueryRows(&items)
  577. return
  578. }