activity_special.go 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/utils"
  7. "strconv"
  8. "strings"
  9. "time"
  10. )
  11. //func init() {
  12. // UpdateCygxActivitySpecialSignupNum()
  13. //}
  14. func ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState string) (condition string) {
  15. //行业名称
  16. if len(chartPermissionIds) > 0 {
  17. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  18. }
  19. if whichDay != "" {
  20. var startDate string
  21. var endDate string
  22. if whichDay == "1" {
  23. startDate = time.Now().Format(utils.FormatDate)
  24. endDate = startDate
  25. } else if whichDay == "2" {
  26. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  27. endDate = startDate
  28. } else if whichDay == "1,2" || whichDay == "2,1" {
  29. startDate = time.Now().Format(utils.FormatDate)
  30. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  31. } else if whichDay == "3" {
  32. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  33. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  34. } else if whichDay == "4" {
  35. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  36. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  37. } else if whichDay == "5" {
  38. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  39. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  40. } else if whichDay == "6" {
  41. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  42. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  43. } else if whichDay == "3,4" || whichDay == "4,3" {
  44. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  45. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  46. } else if whichDay == "5,6" || whichDay == "6,5" {
  47. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  48. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  49. } else {
  50. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  51. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  52. }
  53. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  54. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  55. }
  56. if activeState == "2" {
  57. condition += ` AND art.days > 0 AND art.activity_time <= ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
  58. condition += ` AND art.activity_time_end >= ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
  59. }
  60. if activeState == "3" {
  61. condition += ` AND art.days > 0 AND art.activity_time_end <= ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
  62. }
  63. //if activeState != "3" {
  64. // condition += ` AND art.activity_time_end > ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
  65. //}
  66. //if activeState == "" && whichDay == "" {
  67. // condition += ` AND art.activity_time_end > ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
  68. //}
  69. if whichDay != "" {
  70. condition += ` AND art.days > 0 `
  71. }
  72. condition += ` AND art.label != '' AND art.is_offline = 0 `
  73. if activeState == "1" {
  74. condition = condition + ` AND art.days > 0 AND art.activity_time_end > ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
  75. }
  76. return
  77. }
  78. // ActivityLabelSpecialUserSql 专项产业调研用户权限查询数据预处理
  79. func ActivityLabelSpecialUserSql(user *models.WxUserItem) (conditionShengji, conditionZhengshi, conditionHangYe string, err error) {
  80. _, userType, e := HandleActivityLabelSpecialTripPermission(user)
  81. if e != nil {
  82. err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
  83. return
  84. }
  85. // 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
  86. permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
  87. if errs != nil {
  88. err = errs
  89. return
  90. }
  91. if permissionShengji != "" {
  92. slicePerShengji := strings.Split(permissionShengji, ",")
  93. permissionShengji = ""
  94. for _, v := range slicePerShengji {
  95. permissionShengji += "'" + v + "',"
  96. }
  97. permissionShengji = strings.TrimRight(permissionShengji, ",")
  98. conditionShengji = ` art.customer_type_ids LIKE '%8%' AND art.chart_permission_name IN (` + permissionShengji + `)`
  99. }
  100. //9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
  101. permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
  102. if errs != nil {
  103. err = errs
  104. return
  105. }
  106. if permissionZhengShiStr != "" {
  107. slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
  108. permissionZhengShiStr = ""
  109. for _, v := range slicePerZhengshi {
  110. if userType == 1 {
  111. //研选权限处理(永续客户无法查看研选)
  112. if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
  113. permissionZhengShiStr += "'" + v + "',"
  114. }
  115. } else {
  116. permissionZhengShiStr += "'" + v + "',"
  117. }
  118. }
  119. permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
  120. permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
  121. permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
  122. permissionZhengShiStr += `, '宏观'`
  123. if userType != 1 && userType != 2 && userType != 10 {
  124. conditionHangYe = ` art.customer_type_ids LIKE '%3%' AND art.chart_permission_name IN (` + permissionZhengShiStr + `)`
  125. }
  126. if userType == 3 {
  127. conditionZhengshi = ` art.customer_type_ids LIKE '%9%' AND art.chart_permission_name NOT IN (` + permissionZhengShiStr + `)`
  128. }
  129. }
  130. return
  131. }
  132. // 处理专项调研的展示
  133. func GetActivityLabelSpecialList(user *models.WxUserItem, conditionActivitySpecial, activeState string) (item *models.ActivityTypeHome, err error) {
  134. itemList := new(models.ActivityTypeHome)
  135. if user.CompanyId <= 1 {
  136. itemList.List = make([]*models.CygxActivityLabelList, 0)
  137. item = itemList
  138. return
  139. }
  140. companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
  141. if e != nil && e.Error() != utils.ErrNoRow() {
  142. err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
  143. return
  144. }
  145. if companyDetail == nil {
  146. return
  147. }
  148. //如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
  149. var condition string
  150. var conditionUser string
  151. //var userType int
  152. if companyDetail.Status == "永续" {
  153. conditionUser, e = HandleActivityLabelSpecialPermission(user)
  154. if e != nil {
  155. err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
  156. return
  157. }
  158. } else {
  159. conditionUser, _, e = HandleActivityLabelSpecialTripPermission(user)
  160. if e != nil {
  161. err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
  162. return
  163. }
  164. }
  165. var pars []interface{}
  166. condition += ` AND art.publish_status = 1 AND art.label != '' AND art.is_offline = 0 ` + conditionActivitySpecial
  167. conditionTrip := condition
  168. conditionTripSql := condition
  169. conditionNoTrip := condition
  170. conditionNoTripSql := condition
  171. //condition += conditionUser
  172. conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
  173. if e != nil {
  174. err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
  175. return
  176. }
  177. conditionTrip += ` AND art.days > 0 AND art.activity_time_end > '` + time.Now().Format(utils.FormatDateTime) + ` '`
  178. var conditionZhengshiTrip string
  179. var conditionShengjiTrip string
  180. var conditionHangYeTrip string
  181. //处理专项调研确认行程的其它正式客户权限查询
  182. if conditionZhengshi != "" {
  183. conditionZhengshiTrip = ` OR ( ` + conditionZhengshi + conditionTrip + ` )`
  184. }
  185. //处理升级权限查询
  186. if conditionShengji != "" {
  187. conditionShengjiTrip = ` OR ( ` + conditionShengji + conditionTrip + ` )`
  188. }
  189. //处理行业套餐客户权限查询
  190. if conditionHangYe != "" {
  191. conditionHangYeTrip = ` OR ( ` + conditionHangYe + conditionTrip + ` )`
  192. }
  193. if conditionZhengshi != "" {
  194. conditionTrip += conditionZhengshiTrip
  195. }
  196. if conditionShengjiTrip != "" {
  197. conditionTrip += conditionShengjiTrip
  198. }
  199. if conditionHangYeTrip != "" {
  200. conditionTrip += conditionHangYeTrip
  201. }
  202. conditionTripSql += conditionUser + conditionTrip + ` ORDER BY art.activity_time ASC `
  203. specialList, err := models.GetActivityLabelSpecialListAll(conditionTripSql, pars, 0, 80)
  204. if err != nil {
  205. return
  206. }
  207. //if len(specialList) < 80 {
  208. if activeState == "" {
  209. conditionNoTrip += ` AND art.days = 0 `
  210. }
  211. var conditionShengjiNoTrip string
  212. var conditionZhengshiNoTrip string
  213. var conditionHangYeNoTrip string
  214. if conditionShengji != "" {
  215. conditionShengjiNoTrip = ` OR ( ` + conditionShengji + conditionNoTrip + ` )`
  216. }
  217. if conditionZhengshi != "" {
  218. conditionZhengshiNoTrip = ` OR ( ` + conditionZhengshi + conditionNoTrip + ` )`
  219. }
  220. if conditionHangYe != "" {
  221. conditionHangYeNoTrip = ` OR ( ` + conditionHangYe + conditionNoTrip + ` )`
  222. }
  223. if conditionShengji != "" {
  224. conditionNoTrip += conditionShengjiNoTrip
  225. }
  226. if conditionZhengshi != "" {
  227. conditionNoTrip += conditionZhengshiNoTrip
  228. }
  229. if conditionHangYe != "" {
  230. conditionNoTrip += conditionHangYeNoTrip
  231. }
  232. conditionNoTripSql += conditionUser + conditionNoTrip + ` ORDER BY art.last_updated_time DESC`
  233. specialListNotrip, e := models.GetActivityLabelSpecialListAll(conditionNoTripSql, pars, 0, 200)
  234. if e != nil {
  235. err = e
  236. return
  237. }
  238. for _, v := range specialListNotrip {
  239. specialList = append(specialList, v)
  240. }
  241. //}
  242. for k2, v2 := range specialList {
  243. v2.Resource = 2
  244. if v2.Days == 0 {
  245. specialList[k2].TripStatus = 1
  246. } else {
  247. specialList[k2].TripStatus = 2
  248. }
  249. specialList[k2].KeyWord = LabelStr(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
  250. specialList[k2].ImgUrlBg = "https://hzstatic.hzinsights.com/static/temp/20220426202204/20220426/XDLLsjC9XAAy8LIzQr7GsjrBbtX6.png"
  251. specialList[k2].ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl3
  252. }
  253. itemList.ActivityTypeName = "专项产业调研"
  254. itemList.Resource = 2
  255. itemList.List = specialList
  256. itemList.ActivityTypeId = 7
  257. itemList.OnlineIco = utils.ACTIVITY_ZXDY_ImgUrl1
  258. itemList.ImgUrlBgPc = utils.ACTIVITY_ZXDY_ImgUrl2
  259. item = itemList
  260. return
  261. }
  262. // HandleActivityLabelSpecialPermission 处理专项产业调研的查询权限sql 永续
  263. func HandleActivityLabelSpecialPermission(user *models.WxUserItem) (condition string, err error) {
  264. permissionStr, e := GetCompanyPermission(user.CompanyId)
  265. if e != nil {
  266. err = errors.New("GetCompanyPermission, Err: " + e.Error())
  267. return
  268. }
  269. userType, e := GetSpecialUserType(user)
  270. if e != nil {
  271. err = errors.New("GetSpecialUserType, Err: " + e.Error())
  272. return
  273. }
  274. slicePer := strings.Split(permissionStr, ",")
  275. var permissionSqlStr string
  276. for _, v := range slicePer {
  277. if userType == 1 {
  278. if !strings.Contains(v, "研选") {
  279. permissionSqlStr += "'" + v + "',"
  280. }
  281. } else {
  282. permissionSqlStr += "'" + v + "',"
  283. }
  284. }
  285. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  286. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.is_offline = 0 `
  287. //if permissionSqlStr != "" {
  288. // condition += ` AND art.chart_permission_name IN (` + permissionSqlStr + `) `
  289. //}
  290. condition += ` AND art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  291. return
  292. }
  293. // HandleActivityLabelSpecialPermisseion 处理专项产业调研的查询权限sql
  294. // HandleActivityLabelSpecialPermisseion 处理专项产业调研的查询权限sql
  295. func HandleActivityLabelSpecialTripPermission(user *models.WxUserItem) (condition string, userType int, err error) {
  296. permissionStr, e := GetCompanyPermission(user.CompanyId)
  297. if e != nil {
  298. err = errors.New("GetCompanyPermission, Err: " + e.Error())
  299. return
  300. }
  301. userType, _, e = GetUserType(user.CompanyId)
  302. //userType, e := GetSpecialUserType(user)
  303. if e != nil {
  304. err = errors.New("GetSpecialUserType, Err: " + e.Error())
  305. return
  306. }
  307. mapUserType, e := GetActivityCcustomerTypeList()
  308. if e != nil {
  309. err = e
  310. return
  311. }
  312. var userTypeStr string
  313. userTypeStr = mapUserType[userType]
  314. //fmt.Println(userType)
  315. slicePer := strings.Split(permissionStr, ",")
  316. var permissionSqlStr string
  317. for _, v := range slicePer {
  318. if userType == 1 {
  319. if !strings.Contains(v, "研选") {
  320. permissionSqlStr += "'" + v + "',"
  321. }
  322. } else {
  323. permissionSqlStr += "'" + v + "',"
  324. }
  325. }
  326. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  327. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.is_offline = 0 `
  328. if permissionSqlStr != "" && userType == 3 {
  329. condition += ` AND art.chart_permission_name IN (` + permissionSqlStr + `) `
  330. }
  331. condition += ` AND art.customer_type_ids LIKE '%` + userTypeStr + `%' `
  332. //if userType != 2 {
  333. return
  334. }
  335. // 获取预报名列表
  336. func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize int, keywords, conditionActivity string) (list []*models.CygxActivitySpecialDetail, totalPrepare int, err error) {
  337. companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
  338. if e != nil && e.Error() != utils.ErrNoRow() {
  339. err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
  340. return
  341. }
  342. if companyDetail == nil {
  343. return
  344. }
  345. //如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
  346. var condition string
  347. var conditionUser string
  348. if companyDetail.Status == "永续" {
  349. conditionUser, e = HandleActivityLabelSpecialPermission(user)
  350. if e != nil {
  351. err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
  352. return
  353. }
  354. } else {
  355. conditionUser, _, e = HandleActivityLabelSpecialTripPermission(user)
  356. if e != nil {
  357. err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
  358. return
  359. }
  360. }
  361. var pars []interface{}
  362. condition += ` AND art.days = 0 AND art.publish_status = 1 AND art.is_offline = 0 ` + conditionActivity
  363. if keywords != "" {
  364. keywords = "%" + keywords + "%"
  365. condition += ` AND art.research_theme LIKE ` + keywords
  366. }
  367. conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
  368. if e != nil {
  369. err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
  370. return
  371. }
  372. conditionNoTrip := condition
  373. var conditionShengjiNoTrip string
  374. var conditionZhengshiNoTrip string
  375. var conditionHangYeNoTrip string
  376. if conditionShengji != "" {
  377. conditionShengjiNoTrip = ` OR ( ` + conditionShengji + conditionNoTrip + ` )`
  378. }
  379. if conditionZhengshi != "" {
  380. conditionZhengshiNoTrip = ` OR ( ` + conditionZhengshi + conditionNoTrip + ` )`
  381. }
  382. //处理行业套餐权限查询
  383. if conditionHangYe != "" {
  384. conditionHangYeNoTrip = ` OR ( ` + conditionHangYe + conditionNoTrip + ` )`
  385. }
  386. if conditionShengji != "" {
  387. conditionNoTrip += conditionShengjiNoTrip
  388. }
  389. if conditionZhengshi != "" {
  390. conditionNoTrip += conditionZhengshiNoTrip
  391. }
  392. if conditionHangYe != "" {
  393. conditionNoTrip += conditionHangYeNoTrip
  394. }
  395. conditionNoTripSql := conditionUser + conditionNoTrip
  396. totalPrepare, e = models.GetActivitySpecialCount(conditionNoTripSql, pars)
  397. if e != nil {
  398. err = errors.New("GetActivitySpecialCount, Err: " + e.Error())
  399. return
  400. }
  401. conditionNoTripSql += ` ORDER BY art.last_updated_time DESC `
  402. list, e = models.GetCygxActivitySpecialDetailList(conditionNoTripSql, pars, user.UserId, startSize, pageSize)
  403. if e != nil {
  404. err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
  405. return
  406. }
  407. return
  408. }
  409. /*
  410. 确定行程的查询 GetActivityLabelSpecialConfirmList
  411. state 进行状态 1:未开始,2:进行中,3:已结束,4:未开始、进行中 不传默认查询全部items []*CygxActivitySpecialDetail
  412. */
  413. func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, pageSize, state int, keywords, conditionActivity string) (list []*models.CygxActivitySpecialDetail, totalConfirm int, err error) {
  414. //var condition string
  415. companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
  416. if e != nil && e.Error() != utils.ErrNoRow() {
  417. err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
  418. return
  419. }
  420. if companyDetail == nil {
  421. return
  422. }
  423. //如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
  424. var condition string
  425. var conditionUser string
  426. //var userType int
  427. if companyDetail.Status == "永续" {
  428. conditionUser, e = HandleActivityLabelSpecialPermission(user)
  429. if e != nil {
  430. err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
  431. return
  432. }
  433. } else {
  434. conditionUser, _, e = HandleActivityLabelSpecialTripPermission(user)
  435. if e != nil {
  436. err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
  437. return
  438. }
  439. }
  440. var pars []interface{}
  441. condition += ` AND art.days >0 AND art.publish_status =1 AND art.is_offline = 0 ` + conditionActivity
  442. if state == 1 {
  443. condition += ` AND art.activity_time > '` + time.Now().Format(utils.FormatDateTime) + `'`
  444. }
  445. if state == 2 {
  446. condition += ` AND art.activity_time < '` + time.Now().Format(utils.FormatDateTime) + `'`
  447. condition += ` AND art.activity_time_end > '` + time.Now().Format(utils.FormatDateTime) + `'`
  448. }
  449. if state == 3 {
  450. condition += ` AND art.activity_time_end < '` + time.Now().Format(utils.FormatDateTime) + `'`
  451. }
  452. if state == 4 {
  453. condition += ` AND art.activity_time_end > '` + time.Now().Format(utils.FormatDateTime) + `'`
  454. }
  455. if keywords != "" {
  456. keywords = "%" + keywords + "%"
  457. condition += ` AND art.research_theme LIKE ` + keywords
  458. }
  459. //condition += ` AND art.publish_status = 1 AND art.label != '' AND art.is_offline = 0 ` + conditionActivitySpecial
  460. conditionTrip := condition
  461. conditionTripSql := condition
  462. //condition += conditionUser
  463. conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
  464. if e != nil {
  465. err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
  466. return
  467. }
  468. conditionTrip += ` AND art.days > 0 AND art.activity_time_end > '` + time.Now().Format(utils.FormatDateTime) + ` '`
  469. var conditionZhengshiTrip string
  470. var conditionShengjiTrip string
  471. var conditionHangYeTrip string
  472. //处理专项调研确认行程的其它正式客户权限查询
  473. if conditionZhengshi != "" {
  474. conditionZhengshiTrip = ` OR ( ` + conditionZhengshi + conditionTrip + ` )`
  475. }
  476. //处理专项调研确认行程的升级权限查询
  477. if conditionShengji != "" {
  478. conditionShengjiTrip = ` OR ( ` + conditionShengji + conditionTrip + ` )`
  479. }
  480. //处理行业套餐客户权限查询
  481. if conditionHangYe != "" {
  482. conditionHangYeTrip = ` OR ( ` + conditionHangYe + conditionTrip + ` )`
  483. }
  484. if conditionZhengshi != "" {
  485. conditionTrip += conditionZhengshiTrip
  486. }
  487. if conditionShengjiTrip != "" {
  488. conditionTrip += conditionShengjiTrip
  489. }
  490. if conditionHangYeTrip != "" {
  491. conditionTrip += conditionHangYeTrip
  492. }
  493. conditionTripSql += conditionUser + conditionTrip + ` ORDER BY art.activity_time ASC `
  494. //condition += conditionUser + conditionOr
  495. totalConfirm, e = models.GetActivitySpecialCount(conditionTripSql, pars)
  496. if e != nil {
  497. err = errors.New("GetActivitySpecialCount, Err: " + e.Error())
  498. return
  499. }
  500. condition += ` ORDER BY art.activity_time ASC `
  501. list, e = models.GetCygxActivitySpecialDetailList(conditionTripSql, pars, user.UserId, startSize, pageSize)
  502. if e != nil {
  503. err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
  504. return
  505. }
  506. var activityIds []int
  507. for k, v := range list {
  508. resultTimeStart := utils.StrTimeToTime(v.ActivityTime) //时间字符串格式转时间格式
  509. resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
  510. if resultTimeStart.After(time.Now()) {
  511. list[k].ActiveState = strconv.Itoa(1)
  512. } else if time.Now().After(resultTimeEnd) {
  513. list[k].ActiveState = strconv.Itoa(3)
  514. } else {
  515. list[k].ActiveState = strconv.Itoa(2)
  516. }
  517. if list[k].Days == 0 {
  518. list[k].TripStatus = 1
  519. } else {
  520. list[k].TripStatus = 2
  521. }
  522. activityIds = append(activityIds, v.ActivityId)
  523. }
  524. //处理用户已经报名了的行程
  525. UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
  526. if e != nil {
  527. err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
  528. return
  529. }
  530. for k, v := range list {
  531. if _, ok := UserMap[v.ActivityId]; ok {
  532. list[k].IsTrip = 1
  533. }
  534. }
  535. return
  536. }
  537. // 获取用户已经报名的活动
  538. func GetSpecialTripUserMap(activityIds []int, userId int) (mapUserId map[int]int, err error) {
  539. var condition string
  540. var pars []interface{}
  541. activityIdsLen := len(activityIds)
  542. if activityIdsLen > 0 {
  543. condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
  544. pars = append(pars, activityIds)
  545. }
  546. condition += ` AND user_id = ? AND is_cancel = 0 `
  547. pars = append(pars, userId)
  548. list, e := models.GetCygxActivitySpecialTripList(condition, pars)
  549. if e != nil {
  550. err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
  551. return
  552. }
  553. mapUid := make(map[int]int)
  554. for _, v := range list {
  555. mapUid[v.ActivityId] = v.UserId
  556. }
  557. mapUserId = mapUid
  558. return
  559. }
  560. // 获取用户已经报名的活动数量
  561. func GetSpecialTripUserSchedule(userId int) (total int, err error) {
  562. var condition string
  563. var pars []interface{}
  564. condition += ` AND t.user_id = ? AND t.is_cancel = 0 `
  565. pars = append(pars, userId)
  566. condition += ` AND a.activity_time_end >= ? `
  567. pars = append(pars, time.Now())
  568. condition += ` AND is_valid = 1 `
  569. total, err = models.GetActivitySpecialTripCountByActivitySpecial(condition, pars)
  570. return
  571. }
  572. // GetActivitySpecialList 获取专项调研列表
  573. func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int, keywords, conditionActivity, activeState string) (list []*models.CygxActivitySpecialDetail, total int, err error) {
  574. if user.CompanyId <= 1 {
  575. return
  576. }
  577. state := 4
  578. if activeState == "3" {
  579. state = 3
  580. }
  581. listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, state, keywords, conditionActivity)
  582. if e != nil {
  583. err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
  584. return
  585. }
  586. if currentIndex == 1 && len(listConfirm) > 0 {
  587. listConfirm[0].Explain = utils.ACtIVITY_SPECIAL_TRIP_EXPLAIN
  588. }
  589. list = listConfirm
  590. total = totalConfirm
  591. var startSizePrepare, pageSizePrepare int
  592. //全是确定行程的查询数据
  593. if totalConfirm >= currentIndex*pageSize {
  594. startSizePrepare = 0
  595. pageSizePrepare = 0
  596. } else if totalConfirm > (currentIndex-1)*pageSize && totalConfirm < currentIndex*pageSize {
  597. //一半确认行程一半预报名
  598. startSizePrepare = 0
  599. pageSizePrepare = pageSize - len(listConfirm)
  600. } else {
  601. //全是预报名
  602. startSizePrepare = (currentIndex-1)*pageSize - totalConfirm
  603. pageSizePrepare = pageSize - len(listConfirm)
  604. }
  605. listPrepare, totalPrepare, e := GetActivitySpecialPrepareList(user, startSizePrepare, pageSizePrepare, keywords, conditionActivity)
  606. if e != nil {
  607. err = errors.New("GetActivitySpecialPrepareList, Err: " + e.Error())
  608. return
  609. }
  610. if len(listPrepare) > 0 {
  611. for _, v := range listPrepare {
  612. list = append(list, v)
  613. }
  614. if startSizePrepare == 0 {
  615. listPrepare[0].Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
  616. }
  617. }
  618. total = totalConfirm + totalPrepare
  619. //处理封面图片
  620. detail, e := models.GetConfigByCode("city_img_url")
  621. if e != nil {
  622. err = errors.New("GetConfigByCode, Err: " + e.Error())
  623. return
  624. }
  625. detailChart, e := models.GetConfigByCode("chart_img_url")
  626. if e != nil {
  627. err = errors.New("GetConfigByCode, Err: " + e.Error())
  628. return
  629. }
  630. addressList := strings.Split(detail.ConfigValue, "{|}")
  631. mapAddress := make(map[string]string)
  632. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  633. mapChart := make(map[string]string)
  634. var cityName string
  635. var chartName string
  636. var imgUrl string
  637. var imgUrlChart string
  638. for _, v := range addressList {
  639. vslice := strings.Split(v, "_")
  640. cityName = vslice[0]
  641. imgUrl = vslice[len(vslice)-1]
  642. mapAddress[cityName] = imgUrl
  643. }
  644. for _, v := range chartList {
  645. vslice := strings.Split(v, "_")
  646. chartName = vslice[0]
  647. imgUrlChart = vslice[len(vslice)-1]
  648. mapChart[chartName] = imgUrlChart
  649. }
  650. for k, v := range list {
  651. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  652. if mapChart[v.ChartPermissionName] != "" {
  653. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  654. }
  655. list[k].ActivityTypeName = "专项调研"
  656. if list[k].Days == 0 {
  657. list[k].TripStatus = 1
  658. } else {
  659. list[k].TripStatus = 2
  660. list[k].TripImgLink = list[k].TripImgLinkFix
  661. }
  662. }
  663. return
  664. }
  665. // HandleActivitySpecialShow 处理活动的状态
  666. func HandleActivitySpecialShow(activityDetail *models.CygxActivitySpecialDetail, user *models.WxUserItem) (item *models.CygxActivitySpecialDetail, err error) {
  667. var activityIds []int
  668. resultTimeStart := utils.StrTimeToTime(activityDetail.ActivityTime) //时间字符串格式转时间格式
  669. resultTimeEnd := utils.StrTimeToTime(activityDetail.ActivityTimeEnd) //时间字符串格式转时间格式
  670. if resultTimeStart.After(time.Now()) {
  671. activityDetail.ActiveState = strconv.Itoa(1)
  672. } else if time.Now().After(resultTimeEnd) {
  673. activityDetail.ActiveState = strconv.Itoa(3)
  674. } else {
  675. activityDetail.ActiveState = strconv.Itoa(2)
  676. }
  677. activityIds = append(activityIds, activityDetail.ActivityId)
  678. //处理用户已经报名了的行程
  679. UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
  680. if e != nil {
  681. err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
  682. return
  683. }
  684. if activityDetail.Days == 0 {
  685. activityDetail.TripStatus = 1
  686. activityDetail.Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
  687. } else {
  688. activityDetail.TripStatus = 2
  689. activityDetail.TripImgLink = activityDetail.TripImgLinkFix
  690. activityDetail.Explain = utils.ACtIVITY_SPECIAL_TRIP_EXPLAIN
  691. }
  692. if _, ok := UserMap[activityDetail.ActivityId]; ok {
  693. activityDetail.IsTrip = 1
  694. }
  695. if activityDetail.Days == 0 {
  696. activityDetail.ActiveState = ""
  697. }
  698. item = activityDetail
  699. return
  700. }
  701. // 活动与专项调研搜索 GetActivitySpecialSearcheList
  702. // 活动与专项调研搜索 GetActivitySpecialSearcheList
  703. func GetActivitySpecialSearcheList(user *models.WxUserItem, condition string, startSize, pageSize, playBack int, keywords string) (items []*models.ActivityDetail, total int, err error) {
  704. var conditionSpecil string
  705. var pars, parsSpecil []interface{}
  706. keyword := keywords
  707. if keywords != "" {
  708. keywords = "%" + keywords + "%"
  709. conditionSpecil += ` AND art.days > 0 AND (art.research_theme LIKE ? OR art.label LIKE ? OR art.industrial_name LIKE ? OR art.industrial_subject_name LIKE ? ) `
  710. parsSpecil = append(parsSpecil, keywords, keywords, keywords, keywords)
  711. }
  712. if playBack == 1 {
  713. conditionSpecil += ` AND art.activity_id = 0 `
  714. }
  715. conditionSpecil += ` AND art.publish_status = 1 `
  716. list, totalSearche, e := models.GetActivitySpecialSearcheList(condition, pars, conditionSpecil, parsSpecil, startSize, pageSize)
  717. if e != nil {
  718. err = errors.New("GetActivitySpecialSearcheList, Err: " + e.Error())
  719. return
  720. }
  721. keyWordArr, e := GetIndustryMapNameSliceV3(keywords)
  722. if e != nil {
  723. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  724. return
  725. }
  726. var totalIk int
  727. if len(keyWordArr) > 1 {
  728. // 查询IK分词后那一部分的数据
  729. conditionActivityIk, e := GetActivityonditionList(user, "", "", "", "", "", 0, 1, keyword, playBack, 2)
  730. if e != nil && e.Error() != utils.ErrNoRow() {
  731. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  732. return
  733. }
  734. conditionActivityIk += " AND art.is_limit_people = 1 AND art.publish_status = 1 "
  735. totalIk, e = models.GetActivityCount(conditionActivityIk, 0, pars, 0)
  736. if e != nil {
  737. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  738. return
  739. }
  740. keyWordArr, e := GetIndustryMapNameSliceV3(keywords)
  741. if e != nil {
  742. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  743. return
  744. }
  745. keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
  746. startSizeIk := startSize - totalSearche
  747. if startSizeIk < 0 {
  748. startSizeIk = 0
  749. }
  750. var pageSizeIk int
  751. pageSizeIk = pageSize - len(list)
  752. if pageSizeIk > 0 {
  753. //搜索关键词联想
  754. conditionActivityIk += ` ORDER BY art.activity_time DESC , art.active_state ASC `
  755. listIk, e := models.GetActivityListNew(conditionActivityIk, pars, user.UserId, startSizeIk, pageSizeIk, 0, 0, "")
  756. if e != nil {
  757. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  758. return
  759. }
  760. for _, item := range listIk {
  761. list = append(list, item)
  762. }
  763. }
  764. }
  765. total = totalSearche + totalIk
  766. items, e = HandleActivityListButton(list, user)
  767. if e != nil {
  768. err = errors.New("HandleActivityListButton, Err: " + e.Error())
  769. return
  770. }
  771. return
  772. }
  773. // 获取 专项调研客户类型 //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //8、行业升级套餐客户 //9、其余正式客户;5、试用客户
  774. func GetActivitySpecialUserType(companyId int) (userType int, permissionStrnew string, err error) {
  775. var permissionStr string
  776. if companyId <= 1 {
  777. userType = 0
  778. } else {
  779. total, e := models.GetCountCompanyDetailByIdGroupTrip(companyId)
  780. if e != nil {
  781. err = errors.New("GetCountCompanyDetailByIdGroupTrip, Err: " + e.Error())
  782. return
  783. }
  784. if total == 0 {
  785. userType = 0
  786. } else {
  787. companyDetail, e := models.GetCompanyDetailByIdGroupTrip(companyId)
  788. if e != nil {
  789. err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
  790. return
  791. }
  792. permissionStr, e = models.GetCompanyPermissionByUserTrip(companyId)
  793. if e != nil {
  794. err = errors.New("GetCompanyPermissionByUserTrip, Err: " + e.Error())
  795. return
  796. }
  797. //permissionZhengShiStr, e = models.GetCompanyPermissionByUserZhengShiTrip(companyId)
  798. //if e != nil {
  799. // err = errors.New("GetCompanyPermissionByUserZhengShiTrip, Err: " + e.Error())
  800. // return
  801. //}
  802. //大套餐客户定义:医药、消费、科技、智造。4个行业中为升级,策略是正式,属于大套餐客户
  803. if companyDetail.Status == "永续" {
  804. userType = 1
  805. } else if companyDetail.Status == "试用" {
  806. userType = 5
  807. } else if companyDetail.Status == "正式" {
  808. if permissionStr == "专家" {
  809. userType = 4
  810. } else if strings.Count(permissionStr, "医药") == 2 && strings.Count(permissionStr, "消费") == 2 && strings.Count(permissionStr, "科技") == 2 && strings.Count(permissionStr, "智造") == 2 && strings.Count(permissionStr, "策略") == 1 {
  811. userType = 2
  812. } else {
  813. userType = 3
  814. }
  815. if userType == 3 {
  816. if !strings.Contains(permissionStr, "医药") && !strings.Contains(permissionStr, "消费") && !strings.Contains(permissionStr, "科技") && !strings.Contains(permissionStr, "智造") {
  817. userType = 4
  818. }
  819. }
  820. } else if companyDetail.Status == "冻结" {
  821. userType = 6
  822. } else if companyDetail.Status == "流失" {
  823. userType = 7
  824. }
  825. }
  826. }
  827. permissionStrnew = permissionStr
  828. return
  829. }
  830. // GetSpecialUserType 获取专项产业调研的用户身份类型
  831. // 获取 专项调研客户类型 //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //8、行业升级套餐客户 //9、其余正式客户;5、试用客户
  832. func GetSpecialUserType(user *models.WxUserItem) (userType int, err error) {
  833. companyId := user.CompanyId
  834. companyDetail, e := models.GetCompanyDetailByIdGroupTrip(companyId)
  835. if e != nil && e.Error() != utils.ErrNoRow() {
  836. err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
  837. return
  838. }
  839. if companyDetail == nil {
  840. return
  841. }
  842. if companyId <= 1 {
  843. userType = 0
  844. } else {
  845. if companyDetail.Status == "永续" {
  846. userType = 1
  847. } else {
  848. if companyDetail.Status == "正式" {
  849. list, e := models.GetCompanyReportPermissionUpgrade(companyId, 2)
  850. if e != nil && e.Error() != utils.ErrNoRow() {
  851. err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
  852. }
  853. if len(list) == 0 {
  854. userType = 9
  855. }
  856. if len(list) == 4 {
  857. totalName, e := models.GetCompanyPermissionNameCheck(companyId, 2, "策略")
  858. if e != nil {
  859. err = errors.New("获取品种信息失败, Err:" + e.Error())
  860. return
  861. }
  862. if totalName > 0 {
  863. userType = 2
  864. } else {
  865. userType = 8
  866. }
  867. } else {
  868. userType = 8
  869. }
  870. } else if companyDetail.Status == "试用" {
  871. userType = 5
  872. }
  873. }
  874. }
  875. return
  876. }
  877. // GetSpecialDetailUserPower 处理用户查看专项调研详情的权限
  878. func GetSpecialDetailUserPower(user *models.WxUserItem, activityInfo *models.CygxActivitySpecialDetail) (havePower bool, err error) {
  879. if user.CompanyId == utils.HZ_COMPANY_ID {
  880. havePower = true
  881. return
  882. }
  883. userType, _, e := GetUserType(user.CompanyId)
  884. if e != nil {
  885. err = errors.New("GetSpecialUserType, Err: " + e.Error())
  886. return
  887. }
  888. if userType == 0 {
  889. return
  890. }
  891. mapUserType, e := GetActivityCcustomerTypeList()
  892. if e != nil {
  893. err = e
  894. return
  895. }
  896. var userTypeStr string
  897. userTypeStr = mapUserType[userType]
  898. // 永续客户、大套餐客户可以查看行业升级套餐客户 权限
  899. if userTypeStr == "1" || userTypeStr == "2" {
  900. if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) || strings.Contains(activityInfo.CustomerTypeIds, "8") {
  901. havePower = true
  902. return
  903. }
  904. }
  905. permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
  906. if e != nil {
  907. err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
  908. return
  909. }
  910. //如果有升级权限的自动添加策略、固收的升级权限
  911. if permissionStr != "" {
  912. if activityInfo.ChartPermissionName == utils.CE_LUE_NAME {
  913. permissionStr += "," + utils.CE_LUE_NAME
  914. }
  915. if activityInfo.ChartPermissionName == utils.GU_SHOU_NAME {
  916. permissionStr += "," + utils.GU_SHOU_NAME
  917. }
  918. }
  919. //如果没有对应的升级权限,则返回
  920. if !strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
  921. return
  922. }
  923. //userType, e := GetSpecialUserType(user)
  924. var pars []interface{}
  925. var condition string
  926. var userTypes string
  927. condition += ` AND art.publish_status = 1 AND art.is_offline = 0 `
  928. userTypes = "%" + userTypeStr + "%"
  929. condition += ` AND art.customer_type_ids LIKE ? `
  930. pars = append(pars, userTypes)
  931. condition += ` AND art.activity_id = ? `
  932. pars = append(pars, activityInfo.ActivityId)
  933. total, e := models.GetActivitySpecialCount(condition, pars)
  934. if e != nil {
  935. err = errors.New("GetSpecialUserType, Err: " + e.Error())
  936. return
  937. }
  938. if total == 1 {
  939. havePower = true
  940. return
  941. }
  942. fmt.Println(userType)
  943. fmt.Println(permissionStr)
  944. fmt.Println(activityInfo.ChartPermissionName)
  945. fmt.Println(activityInfo.CustomerTypeIds)
  946. if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
  947. havePower = true
  948. return
  949. }
  950. return
  951. }
  952. // 预报名活动,感兴趣人数满10人时,推送给活动负责人和王芳
  953. func SendWxMsgActivitySpecial10(activityInfo *models.CygxActivitySpecialDetail) (err error) {
  954. activityId := activityInfo.ActivityId
  955. var msg string
  956. defer func() {
  957. if err != nil {
  958. go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
  959. go utils.SendAlarmMsg(fmt.Sprint("预报名活动,感兴趣人数满10人时,推送给活动负责人和王芳消息发送失败", activityInfo.ResearchTheme, ", activityId"), 2)
  960. utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
  961. }
  962. }()
  963. var first string
  964. var keyword1 string
  965. var keyword2 string
  966. var keyword3 string
  967. var keyword4 string
  968. var remark string
  969. adminUser, e := models.GetSellerByAdminId(activityInfo.AdminId)
  970. if e != nil {
  971. err = errors.New("GetSellerByAdminId, Err: " + e.Error())
  972. return
  973. }
  974. cnf, _ := models.GetConfigByCode("tpl_msg")
  975. mobile := adminUser.Mobile + "," + cnf.ConfigValue
  976. specialSignupList, e := models.GetActivityListSpecialByActivityId(activityId)
  977. if e != nil {
  978. err = errors.New("GetActivityListSpecialAll, Err: " + e.Error())
  979. return
  980. }
  981. for _, v := range specialSignupList {
  982. keyword1 += "【" + v.RealName + "--" + v.CompanyName + "】"
  983. }
  984. openIdList, e := models.GetWxOpenIdByMobileList(mobile)
  985. if e != nil {
  986. err = errors.New("GetSellerByAdminId, Err: " + e.Error())
  987. return
  988. }
  989. first = "【" + activityInfo.ResearchTheme + "】已有10人预报名"
  990. keyword3 = "-"
  991. keyword2 = "-"
  992. keyword4 = activityInfo.ResearchTheme
  993. openIdArr := make([]string, 0)
  994. for _, v := range openIdList {
  995. openIdArr = append(openIdArr, v.OpenId)
  996. }
  997. redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(activityId)
  998. sendInfo := new(SendWxTemplate)
  999. sendInfo.First = first
  1000. sendInfo.Keyword1 = keyword1
  1001. sendInfo.Keyword2 = keyword2
  1002. sendInfo.Keyword3 = keyword3
  1003. sendInfo.Keyword4 = keyword4
  1004. sendInfo.Remark = remark
  1005. sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
  1006. sendInfo.RedirectUrl = redirectUrl
  1007. sendInfo.RedirectTarget = 3
  1008. sendInfo.Resource = strconv.Itoa(activityId)
  1009. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
  1010. sendInfo.OpenIdArr = openIdArr
  1011. err = PublicSendTemplateMsg(sendInfo)
  1012. if err != nil {
  1013. return
  1014. }
  1015. return
  1016. }
  1017. // 获取专项调研活动分享封面图片
  1018. func GetActivitySpecialShareImg(activityDetail *models.CygxActivitySpecialDetail) (shareImg string) {
  1019. var err error
  1020. defer func() {
  1021. if err != nil {
  1022. go utils.SendAlarmMsg(fmt.Sprint("获取专项调研活动分享封面图片失败Err:", err.Error(), "活动ID:", activityDetail.ActivityId), 2)
  1023. }
  1024. }()
  1025. activityTypeId := 0
  1026. chartPermissionId := activityDetail.ChartPermissionId
  1027. city := ""
  1028. imgDetail, e := models.CygxActivityShareImgDetail(activityTypeId, chartPermissionId, city)
  1029. if e != nil {
  1030. err = errors.New("CygxActivityShareImgDetail, Err: " + e.Error())
  1031. return
  1032. }
  1033. shareImg = imgDetail.Img
  1034. return
  1035. }