activity_special.go 22 KB

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