activity_special.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. package cygx
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "time"
  7. )
  8. // 活动添加、修改入参
  9. type ActivitySpecialRep struct {
  10. ActivityId int `description:"活动ID 等于0新增活动,大于0修改活动"`
  11. DoType int `description:"操作类型 0,保存 、1,发布"`
  12. PermissionName string `description:"行业名称"`
  13. ResearchTheme string `description:"调研主题"`
  14. ActivityTimeText string `description:"活动预期时间带文字"`
  15. IndustrialManagementIdS string `description:"产业ID,多个ID用 , 隔开"`
  16. IndustrialSubjectIdS string `description:"标的ID,多个ID用 , 隔开"`
  17. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  18. TemporaryLabel string `description:"临时标签"`
  19. TemporarySubject string `description:"临时标的"`
  20. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  21. TripImgLink string `description:"行程图片链接"`
  22. SpecialType int `description:"调研形式、 1 线上 , 2 线下"`
  23. City string `description:"调研城市"`
  24. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
  25. }
  26. // 活动添加、修改入参
  27. type ActivitySpecialDateRep struct {
  28. ActivityId int `description:"活动ID"`
  29. PermissionName string `description:"行业名称"`
  30. ResearchTheme string `description:"调研主题"`
  31. ActivityTimeText string `description:"活动预期时间带文字"`
  32. IndustrialManagementIdS string `description:"产业ID,多个ID用 , 隔开"`
  33. IndustrialSubjectIdS string `description:"标的ID,多个ID用 , 隔开"`
  34. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  35. TemporaryLabel string `description:"临时标签"`
  36. TemporarySubject string `description:"临时标的"`
  37. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  38. TripImgLink string `description:"行程图片链接"`
  39. SpecialType int `description:"调研形式、 1 线上 , 2 线下"`
  40. City string `description:"调研城市"`
  41. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
  42. DateYmdList []*DateYmdList `description:"时间年月日"`
  43. Days int `description:"调研天数"`
  44. Host string `description:"主持人"`
  45. PersonInCharge string `description:"纪要负责人"`
  46. LimitPeopleNum int `description:"限制人数数量"`
  47. TripImgLinkFix string `description:"确定行程之后的图片链接"`
  48. ActivityTimeTextByDay string `description:"活动预期时间带文字"`
  49. }
  50. type DateYmdList struct {
  51. DateYmd string `description:"时间年月日"`
  52. DateHmsList []*DateHmsList `description:"时间时分秒"`
  53. }
  54. type DateHmsList struct {
  55. DateHms []string `description:"时间时分秒"`
  56. }
  57. // 活动详情
  58. type ActivitySpecialDetail struct {
  59. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  60. ChartPermissionId int `description:"行业id"`
  61. ChartPermissionName string `description:"行业名称"`
  62. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  63. PublishStatus int `description:"发布状态 1已发布,0未发布"`
  64. ResearchTheme string `description:"调研主题"`
  65. ActivityTimeText string `description:"活动预期时间带文字"`
  66. TemporaryLabel string `description:"临时标签"`
  67. TemporarySubject string `description:"临时标的"`
  68. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  69. TripImgLink string `description:"行程图片链接"`
  70. IndustrialName string `description:"产业名称"`
  71. IndustrialSubjectName string `description:"标的名称(相关公司)"`
  72. Label string `description:"标签"`
  73. CustomerName string `description:"活动可见—套餐类型"`
  74. SpecialType int `description:"调研形式、 1 线上 , 2 线下"`
  75. City string `description:"调研城市"`
  76. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
  77. AdminId int `description:"销售/管理员ID"`
  78. AdminName string `description:"销售/管理员姓名"`
  79. ListIndustrial []*IndustrialActivityGroupManagementRep
  80. ListSubject []*SubjectActivityGroupManagementRep
  81. Days int `description:"调研天数"`
  82. Host string `description:"主持人"`
  83. PersonInCharge string `description:"纪要负责人"`
  84. LimitPeopleNum int `description:"限制人数数量"`
  85. TripImgLinkFix string `description:"确定行程之后的图片链接"`
  86. ActivityTimeTextByDay string `description:"活动预期时间带周日"`
  87. ActivityTime string `description:"活动预期时间"`
  88. IsOffline int `description:"是否下线,1已下线,0未下线"`
  89. DateYmdList []*DateYmdList `description:"时间年月日"`
  90. IsSubmitMeeting int `description:"是否提交过到会信息 ,1是,0否"`
  91. LastUpdatedTime time.Time `description:"更新时间"`
  92. }
  93. type ActivityDetailSpecialRep struct {
  94. Detail *ActivityDetail
  95. ListIndustrial []*IndustrialActivityGroupManagementRep
  96. ListSubject []*SubjectActivityGroupManagementRep
  97. }
  98. // 活动详情
  99. type CygxActivitySpecial struct {
  100. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  101. ChartPermissionId int `description:"行业id"`
  102. ChartPermissionName string `description:"行业名称"`
  103. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  104. PublishStatus int `description:"发布状态 1已发布,0未发布"`
  105. ResearchTheme string `description:"调研主题"`
  106. ActivityTimeText string `description:"活动预期时间带文字"`
  107. Label string `description:"标签"`
  108. TemporaryLabel string `description:"临时标签"`
  109. TemporarySubject string `description:"临时标的"`
  110. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  111. TripImgLink string `description:"行程图片链接"`
  112. IndustrialName string `description:"产业名称"`
  113. IndustrialSubjectName string `description:"标的名称"`
  114. LastUpdatedTime time.Time `description:"更新时间"`
  115. CreateTime time.Time `description:"创建时间"`
  116. SpecialType int `description:"调研形式、 1 线上 , 2 线下"`
  117. City string `description:"调研城市"`
  118. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0否 默认0 "`
  119. AdminId int `description:"销售/管理员ID"`
  120. AdminName string `description:"销售/管理员姓名"`
  121. Days int `description:"调研天数"`
  122. Host string `description:"主持人"`
  123. PersonInCharge string `description:"纪要负责人"`
  124. LimitPeopleNum int `description:"限制人数数量"`
  125. TripImgLinkFix string `description:"确定行程之后的图片链接"`
  126. ActivityTimeTextByDay string `description:"活动预期时间带周日"`
  127. ActivityTime string `description:"活动预期时间"`
  128. PublishDate string `description:"活动发布时间"`
  129. ActivityTimeEnd string `description:"活动预期结束时间"`
  130. IsOffline int `description:"是否下线,1已下线,0未下线"`
  131. }
  132. // 添加活动
  133. func AddActivitySpecial(item *CygxActivitySpecial, industrialActivityItems []*CygxIndustrialActivityGroupManagement, subjectActivityItems []*CygxIndustrialActivityGroupSubject) (newId int64, err error) {
  134. o := orm.NewOrm()
  135. to, err := o.Begin()
  136. if err != nil {
  137. return
  138. }
  139. defer func() {
  140. if err != nil {
  141. fmt.Println(err)
  142. _ = to.Rollback()
  143. } else {
  144. _ = to.Commit()
  145. }
  146. }()
  147. newId, err = to.Insert(item)
  148. if err != nil {
  149. return
  150. }
  151. //添加关联的产业
  152. if len(industrialActivityItems) > 0 {
  153. for _, v := range industrialActivityItems {
  154. v.ActivityId = int(newId)
  155. _, err = to.Insert(v)
  156. if err != nil {
  157. return
  158. }
  159. }
  160. }
  161. //添加关联的标的
  162. if len(subjectActivityItems) > 0 {
  163. for _, v := range subjectActivityItems {
  164. v.ActivityId = int(newId)
  165. _, err = to.Insert(v)
  166. if err != nil {
  167. return
  168. }
  169. }
  170. }
  171. return
  172. }
  173. // 通过纪要ID获取活动详情
  174. func GetAddActivityInfoSpecialById(ActivityId int) (item *ActivitySpecialDetail, err error) {
  175. o := orm.NewOrm()
  176. sql := `SELECT * FROM cygx_activity_special WHERE activity_id=?`
  177. err = o.Raw(sql, ActivityId).QueryRow(&item)
  178. return
  179. }
  180. // 通过纪要ID获取活动详情
  181. func GetCustomerName(ids string) (name string, err error) {
  182. o := orm.NewOrm()
  183. sql := `SELECT GROUP_CONCAT( DISTINCT c.customer_name SEPARATOR '、' ) AS name
  184. FROM cygx_customer_type AS c WHERE c.customer_type_id IN (` + ids + `)`
  185. err = o.Raw(sql).QueryRow(&name)
  186. return
  187. }
  188. // 修改
  189. func EditActivitySpecial(updateParams map[string]interface{}, item *CygxActivitySpecial, industrialActivityItems []*CygxIndustrialActivityGroupManagement, subjectActivityItems []*CygxIndustrialActivityGroupSubject) (err error) {
  190. o := orm.NewOrm()
  191. to, err := o.Begin()
  192. if err != nil {
  193. return
  194. }
  195. defer func() {
  196. if err != nil {
  197. fmt.Println(err)
  198. _ = to.Rollback()
  199. } else {
  200. _ = to.Commit()
  201. }
  202. }()
  203. activityId := item.ActivityId
  204. //修改活动信息
  205. ptrStructOrTableName := "cygx_activity_special"
  206. whereParam := map[string]interface{}{"activity_id": item.ActivityId}
  207. qs := to.QueryTable(ptrStructOrTableName)
  208. for expr, exprV := range whereParam {
  209. qs = qs.Filter(expr, exprV)
  210. }
  211. _, err = qs.Update(updateParams)
  212. //删除活动关联的产业
  213. sql := ` DELETE FROM cygx_industrial_activity_group_management WHERE activity_id = ? AND source =2`
  214. _, err = to.Raw(sql, activityId).Exec()
  215. if err != nil {
  216. return
  217. }
  218. //删除活动关联的标的
  219. sql = ` DELETE FROM cygx_industrial_activity_group_subject WHERE activity_id = ? AND source =2`
  220. _, err = to.Raw(sql, activityId).Exec()
  221. if err != nil {
  222. return
  223. }
  224. //添加关联的产业
  225. if len(industrialActivityItems) > 0 {
  226. for _, v := range industrialActivityItems {
  227. _, err = to.Insert(v)
  228. if err != nil {
  229. return
  230. }
  231. }
  232. }
  233. //添加关联的标的
  234. if len(subjectActivityItems) > 0 {
  235. for _, v := range subjectActivityItems {
  236. _, err = to.Insert(v)
  237. if err != nil {
  238. return
  239. }
  240. }
  241. }
  242. return
  243. }
  244. // 修改
  245. func EditActivitySpecialStatus(item *CygxActivitySpecial) (err error) {
  246. o := orm.NewOrm()
  247. sql := `UPDATE cygx_activity_special SET publish_status=?, last_updated_time=NOW() WHERE activity_id=?`
  248. _, err = o.Raw(sql, item.PublishStatus, item.ActivityId).Exec()
  249. return
  250. }
  251. // 修改
  252. func UpdateActivitySpecial(updateParams map[string]interface{}, item *CygxActivitySpecial) (err error) {
  253. to := orm.NewOrm()
  254. //修改活动信息
  255. ptrStructOrTableName := "cygx_activity_special"
  256. whereParam := map[string]interface{}{"activity_id": item.ActivityId}
  257. qs := to.QueryTable(ptrStructOrTableName)
  258. for expr, exprV := range whereParam {
  259. qs = qs.Filter(expr, exprV)
  260. }
  261. _, err = qs.Update(updateParams)
  262. return
  263. }
  264. // 修改是否下线
  265. func EditActivitySpecialIsOffline(item *CygxActivitySpecial) (err error) {
  266. o := orm.NewOrm()
  267. sql := `UPDATE cygx_activity_special SET is_offline=?,publish_status=?, last_updated_time=NOW() WHERE activity_id=?`
  268. _, err = o.Raw(sql, item.IsOffline, item.PublishStatus, item.ActivityId).Exec()
  269. return
  270. }
  271. // 活动详情
  272. type CygxActivitySpecialList struct {
  273. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  274. ResearchTheme string `description:"调研主题"`
  275. ChartPermissionName string `description:"行业名称"`
  276. ActivityTimeText string `description:"活动预期时间带文字"`
  277. ActivityTime string `description:"活动预期时间"`
  278. ActivityTimeTextByDay string `description:"活动预期时间带周几"`
  279. LastUpdatedTime string `description:"更新时间"`
  280. InterestedNum int `description:"感兴趣人数"`
  281. SignupPeopleNum int `description:"报名人数"`
  282. PublishStatus int `description:"发布状态 1已发布,0未发布"`
  283. SpecialType int `description:"调研形式、 1 线上 , 2 线下"`
  284. City string `description:"调研城市"`
  285. AdminId int `description:"销售/管理员ID"`
  286. AdminName string `description:"销售/管理员姓名"`
  287. IsOffline int `description:"是否下线,1已下线,0未下线"`
  288. Days int `description:"调研天数"`
  289. IsDetermineTravel int `orm:"column(days)";description:"是否确定行程,1是,0否"`
  290. IsShowAttendanceDetails bool `description:"是否展示到会详情"`
  291. IsShowUpdateMeeting bool `description:"是否展示修改到会情况"`
  292. IsShowSubmitMeeting bool `description:"是否展示提交到会情况"`
  293. IsSubmitMeeting int `description:"是否提交过到会信息 ,1是,0否"`
  294. }
  295. type GetCygxActivityListSpecialRep struct {
  296. Paging *paging.PagingItem `description:"分页数据"`
  297. List []*CygxActivitySpecialList
  298. }
  299. // 列表
  300. func GetActivityListSpecialAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivitySpecialList, err error) {
  301. o := orm.NewOrm()
  302. sql := `SELECT (SELECT COUNT(1) FROM cygx_activity_special_signup AS h INNER JOIN wx_user AS u ON u.user_id = h.user_id WHERE h.activity_id=art.activity_id) AS interested_num ,
  303. (SELECT COUNT(1) FROM cygx_activity_special_trip AS h INNER JOIN wx_user AS u ON u.user_id = h.user_id WHERE h.activity_id=art.activity_id AND h.is_cancel =0 ) AS signup_people_num ,
  304. art.* FROM cygx_activity_special as art WHERE 1= 1 `
  305. if condition != "" {
  306. sql += condition
  307. }
  308. sql += ` LIMIT ?,?`
  309. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  310. return
  311. }
  312. // 获取数量
  313. func GetActivitySpecialCount(condition string, pars []interface{}) (count int, err error) {
  314. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_special as art WHERE 1= 1 `
  315. if condition != "" {
  316. sqlCount += condition
  317. }
  318. o := orm.NewOrm()
  319. err = o.Raw(sqlCount, pars).QueryRow(&count)
  320. return
  321. }
  322. // 删除数据
  323. func DeleteActivitySpecial(activityId int) (err error) {
  324. o := orm.NewOrm()
  325. sql := ` DELETE FROM cygx_activity_special WHERE activity_id = ?`
  326. _, err = o.Raw(sql, activityId).Exec()
  327. return
  328. }
  329. type CygxActivitySpecialSignup struct {
  330. Id int `orm:"column(id);pk"`
  331. ActivityId int `description:"活动ID"`
  332. UserId int `description:"用户ID"`
  333. CreateTime string `description:"创建时间"`
  334. Mobile string `description:"手机号"`
  335. CompanyName string `description:"公司名称"`
  336. CompanyId int `description:"公司ID"`
  337. RealName string `description:"姓名"`
  338. SellerName string `description:"销售姓名"`
  339. }
  340. type CygxActivitySpecialSignupListResp struct {
  341. List []*CygxActivitySpecialSignup
  342. }
  343. // 感兴趣列表
  344. func GetCygxActivitySpecialSignupList(activityId int) (items []*CygxActivitySpecialSignup, err error) {
  345. o := orm.NewOrm()
  346. sql := `SELECT
  347. s.id,
  348. s.activity_id,
  349. s.user_id,
  350. s.mobile,
  351. s.create_time,
  352. u.real_name,
  353. c.company_name,
  354. ( SELECT p.seller_name FROM company_product AS p WHERE p.company_id = u.company_id AND p.product_id = 2 ) AS seller_name,
  355. GROUP_CONCAT( DISTINCT p.seller_name SEPARATOR '/' ) AS pseller_name
  356. FROM
  357. cygx_activity_special_signup AS s
  358. INNER JOIN wx_user AS u ON u.user_id = s.user_id
  359. LEFT JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
  360. LEFT JOIN company_product AS p ON p.company_id = u.company_id
  361. LEFT JOIN company AS c ON c.company_id = u.company_id
  362. WHERE
  363. a.activity_id = ?
  364. GROUP BY
  365. s.user_id
  366. ORDER BY
  367. s.id DESC`
  368. _, err = o.Raw(sql, activityId).QueryRows(&items)
  369. return
  370. }
  371. // 获取数量
  372. func GetCygxActivitySpecialSignupCount(condition string, pars []interface{}) (count int, err error) {
  373. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_special_signup as s INNER JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
  374. INNER JOIN wx_user AS u ON u.user_id = s.user_id WHERE 1= 1 `
  375. if condition != "" {
  376. sqlCount += condition
  377. }
  378. o := orm.NewOrm()
  379. err = o.Raw(sqlCount, pars).QueryRow(&count)
  380. return
  381. }
  382. type CygxActivitySpecialSignupResp struct {
  383. Id int `orm:"column(id);pk"`
  384. ActivityId int `description:"活动ID"`
  385. UserId int `description:"用户ID"`
  386. CreateTime string `description:"创建时间"`
  387. Mobile string `description:"手机号"`
  388. CompanyName string `description:"公司名称"`
  389. CompanyId int `description:"公司ID"`
  390. RealName string `description:"姓名"`
  391. SellerName string `description:"销售姓名"`
  392. ResearchTheme string `description:"调研主题"`
  393. Label string `description:"标签"`
  394. ChartPermissionName string `description:"行业"`
  395. PublishDate string `description:"发布时间"`
  396. }
  397. type CygxActivitySpecialSignupRespList struct {
  398. List []*CygxActivitySpecialSignupResp
  399. Paging *paging.PagingItem `description:"分页数据"`
  400. }
  401. // 列表
  402. func GetCygxActivitySpecialSignupListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivitySpecialSignupResp, err error) {
  403. o := orm.NewOrm()
  404. sql := `SELECT
  405. s.id,
  406. s.activity_id,
  407. s.user_id,
  408. s.create_time,
  409. s.user_num,
  410. u.real_name,
  411. c.company_name,
  412. c.company_id,
  413. a.research_theme,
  414. a.label,
  415. a.chart_permission_name,
  416. a.create_time AS publish_date,
  417. ( SELECT p.seller_name FROM company_product AS p WHERE p.company_id = u.company_id AND p.product_id = 2 ) AS seller_name,
  418. GROUP_CONCAT( DISTINCT p.seller_name SEPARATOR '/' ) AS pseller_name
  419. FROM
  420. cygx_activity_special_signup AS s
  421. INNER JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
  422. INNER JOIN wx_user AS u ON u.user_id = s.user_id
  423. LEFT JOIN company_product AS p ON p.company_id = u.company_id
  424. LEFT JOIN company AS c ON c.company_id = u.company_id
  425. WHERE
  426. 1 = 1 `
  427. if condition != "" {
  428. sql += condition
  429. }
  430. sql += ` LIMIT ?,?`
  431. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  432. return
  433. }
  434. type AdminOpenIdList struct {
  435. OpenId string `description:"OpenId"`
  436. UserId int `description:"UserId"`
  437. Mobile string `description:"手机号"`
  438. CompanyId int `description:"手机号"`
  439. }
  440. // GetAdminOpendidByCompany 通过用户公司ID获取对应销售的openid
  441. func GetAdminOpendidByCompany(condition string, pars []interface{}) (list []*AdminOpenIdList, err error) {
  442. sql := `SELECT
  443. cr.open_id,a.mobile,p.company_id,cr.union_id
  444. FROM
  445. company_product AS p
  446. INNER JOIN admin AS a ON a.admin_id = p.seller_id
  447. INNER JOIN user_record as c ON c.bind_account = a.mobile
  448. INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
  449. WHERE
  450. 1 = 1
  451. AND p.product_id = 2
  452. AND create_platform = 4 ` + condition
  453. _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
  454. return
  455. }
  456. // 获取预约活动的用户的openID
  457. func GetActivitySpecialOpenIdList() (items []*AdminOpenIdList, err error) {
  458. sql := `SELECT DISTINCT cr.open_id,u.user_id,m.company_id
  459. FROM
  460. cygx_user_follow_special AS m
  461. INNER JOIN user_record AS u ON u.bind_account = m.mobile
  462. INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
  463. WHERE u.create_platform = 4 `
  464. _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
  465. return
  466. }
  467. func GetActivitySpecialByIndustryIds(condition string, pars []interface{}) (list []*CygxActivitySpecialSignup, err error) {
  468. sql := `SELECT
  469. m.activity_id
  470. FROM
  471. cygx_industrial_activity_group_management AS m
  472. INNER JOIN cygx_activity_special AS a ON a.activity_id = m.activity_id
  473. WHERE
  474. 1= 1
  475. AND m.source = 2
  476. AND a.publish_status = 1 AND a.is_offline = 0 AND a.days >0 ` + condition
  477. _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
  478. return
  479. }
  480. func GetWxOpenIdByMobileList(condition string, pars []interface{}) (items []*OpenIdList, err error) {
  481. sql := `SELECT cr.*,user_id FROM user_record as c
  482. INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
  483. WHERE 1= 1 AND create_platform = 4 ` + condition
  484. _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items)
  485. return
  486. }
  487. func GetWxOpenIdBList(condition string, pars []interface{}) (items []*OpenIdList, err error) {
  488. sql := `SELECT
  489. cr.*,
  490. u.user_id
  491. FROM
  492. cygx_user_record AS cr
  493. INNER JOIN user_record AS c ON c.union_id = cr.union_id
  494. INNER JOIN wx_user AS u ON u.user_id = c.user_id
  495. WHERE
  496. 1 = 1
  497. AND c.create_platform = 4 ` + condition + ` GROUP BY cr.open_id `
  498. _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items)
  499. return
  500. }
  501. // 通过产业名称获取关联的ID
  502. func GetactivitySpecilIdsByLabel(name string) (activityIds string, err error) {
  503. sql := ` SELECT
  504. GROUP_CONCAT( DISTINCT s.activity_id SEPARATOR ',' ) AS activityIds
  505. FROM
  506. cygx_activity_special AS s
  507. WHERE
  508. label LIKE '%` + name + `%' `
  509. o := orm.NewOrm()
  510. err = o.Raw(sql).QueryRow(&activityIds)
  511. return
  512. }