activity_special.go 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_web_mfyx/models"
  6. "hongze/hongze_web_mfyx/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. state := 4
  575. if activeState == "3" {
  576. state = 3
  577. }
  578. listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, state, keywords, conditionActivity)
  579. if e != nil {
  580. err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
  581. return
  582. }
  583. if currentIndex == 1 && len(listConfirm) > 0 {
  584. listConfirm[0].Explain = utils.ACtIVITY_SPECIAL_TRIP_EXPLAIN
  585. }
  586. list = listConfirm
  587. total = totalConfirm
  588. var startSizePrepare, pageSizePrepare int
  589. //全是确定行程的查询数据
  590. if totalConfirm >= currentIndex*pageSize {
  591. startSizePrepare = 0
  592. pageSizePrepare = 0
  593. } else if totalConfirm > (currentIndex-1)*pageSize && totalConfirm < currentIndex*pageSize {
  594. //一半确认行程一半预报名
  595. startSizePrepare = 0
  596. pageSizePrepare = pageSize - len(listConfirm)
  597. } else {
  598. //全是预报名
  599. startSizePrepare = (currentIndex-1)*pageSize - totalConfirm
  600. pageSizePrepare = pageSize - len(listConfirm)
  601. }
  602. listPrepare, totalPrepare, e := GetActivitySpecialPrepareList(user, startSizePrepare, pageSizePrepare, keywords, conditionActivity)
  603. if e != nil {
  604. err = errors.New("GetActivitySpecialPrepareList, Err: " + e.Error())
  605. return
  606. }
  607. if len(listPrepare) > 0 {
  608. for _, v := range listPrepare {
  609. list = append(list, v)
  610. }
  611. if startSizePrepare == 0 {
  612. listPrepare[0].Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
  613. }
  614. }
  615. total = totalConfirm + totalPrepare
  616. //处理封面图片
  617. detail, e := models.GetConfigByCode("city_img_url")
  618. if e != nil {
  619. err = errors.New("GetConfigByCode, Err: " + e.Error())
  620. return
  621. }
  622. detailChart, e := models.GetConfigByCode("chart_img_url")
  623. if e != nil {
  624. err = errors.New("GetConfigByCode, Err: " + e.Error())
  625. return
  626. }
  627. addressList := strings.Split(detail.ConfigValue, "{|}")
  628. mapAddress := make(map[string]string)
  629. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  630. mapChart := make(map[string]string)
  631. var cityName string
  632. var chartName string
  633. var imgUrl string
  634. var imgUrlChart string
  635. for _, v := range addressList {
  636. vslice := strings.Split(v, "_")
  637. cityName = vslice[0]
  638. imgUrl = vslice[len(vslice)-1]
  639. mapAddress[cityName] = imgUrl
  640. }
  641. for _, v := range chartList {
  642. vslice := strings.Split(v, "_")
  643. chartName = vslice[0]
  644. imgUrlChart = vslice[len(vslice)-1]
  645. mapChart[chartName] = imgUrlChart
  646. }
  647. for k, v := range list {
  648. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  649. if mapChart[v.ChartPermissionName] != "" {
  650. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  651. }
  652. list[k].ActivityTypeName = "专项调研"
  653. if list[k].Days == 0 {
  654. list[k].TripStatus = 1
  655. } else {
  656. list[k].TripStatus = 2
  657. list[k].TripImgLink = list[k].TripImgLinkFix
  658. }
  659. }
  660. return
  661. }
  662. // HandleActivitySpecialShow 处理活动的状态
  663. func HandleActivitySpecialShow(activityDetail *models.CygxActivitySpecialDetail, user *models.WxUserItem) (item *models.CygxActivitySpecialDetail, err error) {
  664. var activityIds []int
  665. resultTimeStart := utils.StrTimeToTime(activityDetail.ActivityTime) //时间字符串格式转时间格式
  666. resultTimeEnd := utils.StrTimeToTime(activityDetail.ActivityTimeEnd) //时间字符串格式转时间格式
  667. if resultTimeStart.After(time.Now()) {
  668. activityDetail.ActiveState = strconv.Itoa(1)
  669. } else if time.Now().After(resultTimeEnd) {
  670. activityDetail.ActiveState = strconv.Itoa(3)
  671. } else {
  672. activityDetail.ActiveState = strconv.Itoa(2)
  673. }
  674. activityIds = append(activityIds, activityDetail.ActivityId)
  675. //处理用户已经报名了的行程
  676. UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
  677. if e != nil {
  678. err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
  679. return
  680. }
  681. if activityDetail.Days == 0 {
  682. activityDetail.TripStatus = 1
  683. activityDetail.Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
  684. } else {
  685. activityDetail.TripStatus = 2
  686. activityDetail.TripImgLink = activityDetail.TripImgLinkFix
  687. activityDetail.Explain = utils.ACtIVITY_SPECIAL_TRIP_EXPLAIN
  688. }
  689. if _, ok := UserMap[activityDetail.ActivityId]; ok {
  690. activityDetail.IsTrip = 1
  691. }
  692. if activityDetail.Days == 0 {
  693. activityDetail.ActiveState = ""
  694. }
  695. item = activityDetail
  696. return
  697. }
  698. // 活动与专项调研搜索 GetActivitySpecialSearcheList
  699. // 活动与专项调研搜索 GetActivitySpecialSearcheList
  700. func GetActivitySpecialSearcheList(user *models.WxUserItem, condition string, startSize, pageSize, playBack int, keywords string) (items []*models.ActivityDetail, total int, err error) {
  701. var conditionSpecil string
  702. var pars, parsSpecil []interface{}
  703. keyword := keywords
  704. if keywords != "" {
  705. keywords = "%" + keywords + "%"
  706. 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 ? ) `
  707. parsSpecil = append(parsSpecil, keywords, keywords, keywords, keywords)
  708. }
  709. if playBack == 1 {
  710. conditionSpecil += ` AND art.activity_id = 0 `
  711. }
  712. conditionSpecil += ` AND art.publish_status = 1 `
  713. list, totalSearche, e := models.GetActivitySpecialSearcheList(condition, pars, conditionSpecil, parsSpecil, startSize, pageSize)
  714. if e != nil {
  715. err = errors.New("GetActivitySpecialSearcheList, Err: " + e.Error())
  716. return
  717. }
  718. keyWordArr, e := GetIndustryMapNameSliceV3(keywords)
  719. if e != nil {
  720. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  721. return
  722. }
  723. var totalIk int
  724. if len(keyWordArr) > 1 {
  725. // 查询IK分词后那一部分的数据
  726. conditionActivityIk, e := GetActivityonditionList(user, "", "", "", "", "", 0, 1, keyword, playBack, 2)
  727. if e != nil && e.Error() != utils.ErrNoRow() {
  728. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  729. return
  730. }
  731. conditionActivityIk += " AND art.is_limit_people = 1 AND art.publish_status = 1 "
  732. totalIk, e = models.GetActivityCount(conditionActivityIk, 0, pars, 0)
  733. if e != nil {
  734. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  735. return
  736. }
  737. keyWordArr, e := GetIndustryMapNameSliceV3(keywords)
  738. if e != nil {
  739. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  740. return
  741. }
  742. keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
  743. startSizeIk := startSize - totalSearche
  744. if startSizeIk < 0 {
  745. startSizeIk = 0
  746. }
  747. var pageSizeIk int
  748. pageSizeIk = pageSize - len(list)
  749. if pageSizeIk > 0 {
  750. //搜索关键词联想
  751. conditionActivityIk += ` ORDER BY art.activity_time DESC , art.active_state ASC `
  752. listIk, e := models.GetActivityListNew(conditionActivityIk, pars, user.UserId, startSizeIk, pageSizeIk, 0, 0, "")
  753. if e != nil {
  754. err = errors.New("GetActivityonditionList, Err: " + e.Error())
  755. return
  756. }
  757. for _, item := range listIk {
  758. list = append(list, item)
  759. }
  760. }
  761. }
  762. total = totalSearche + totalIk
  763. items, e = HandleActivityListButton(list, user)
  764. if e != nil {
  765. err = errors.New("HandleActivityListButton, Err: " + e.Error())
  766. return
  767. }
  768. return
  769. }
  770. // 获取 专项调研客户类型 //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //8、行业升级套餐客户 //9、其余正式客户;5、试用客户
  771. func GetActivitySpecialUserType(companyId int) (userType int, permissionStrnew string, err error) {
  772. var permissionStr string
  773. if companyId <= 1 {
  774. userType = 0
  775. } else {
  776. total, e := models.GetCountCompanyDetailByIdGroupTrip(companyId)
  777. if e != nil {
  778. err = errors.New("GetCountCompanyDetailByIdGroupTrip, Err: " + e.Error())
  779. return
  780. }
  781. if total == 0 {
  782. userType = 0
  783. } else {
  784. companyDetail, e := models.GetCompanyDetailByIdGroupTrip(companyId)
  785. if e != nil {
  786. err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
  787. return
  788. }
  789. permissionStr, e = models.GetCompanyPermissionByUserTrip(companyId)
  790. if e != nil {
  791. err = errors.New("GetCompanyPermissionByUserTrip, Err: " + e.Error())
  792. return
  793. }
  794. //permissionZhengShiStr, e = models.GetCompanyPermissionByUserZhengShiTrip(companyId)
  795. //if e != nil {
  796. // err = errors.New("GetCompanyPermissionByUserZhengShiTrip, Err: " + e.Error())
  797. // return
  798. //}
  799. //大套餐客户定义:医药、消费、科技、智造。4个行业中为升级,策略是正式,属于大套餐客户
  800. if companyDetail.Status == "永续" {
  801. userType = 1
  802. } else if companyDetail.Status == "试用" {
  803. userType = 5
  804. } else if companyDetail.Status == "正式" {
  805. if permissionStr == "专家" {
  806. userType = 4
  807. } else if strings.Count(permissionStr, "医药") == 2 && strings.Count(permissionStr, "消费") == 2 && strings.Count(permissionStr, "科技") == 2 && strings.Count(permissionStr, "智造") == 2 && strings.Count(permissionStr, "策略") == 1 {
  808. userType = 2
  809. } else {
  810. userType = 3
  811. }
  812. if userType == 3 {
  813. if !strings.Contains(permissionStr, "医药") && !strings.Contains(permissionStr, "消费") && !strings.Contains(permissionStr, "科技") && !strings.Contains(permissionStr, "智造") {
  814. userType = 4
  815. }
  816. }
  817. } else if companyDetail.Status == "冻结" {
  818. userType = 6
  819. } else if companyDetail.Status == "流失" {
  820. userType = 7
  821. }
  822. }
  823. }
  824. permissionStrnew = permissionStr
  825. return
  826. }
  827. // GetSpecialUserType 获取专项产业调研的用户身份类型
  828. // 获取 专项调研客户类型 //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //8、行业升级套餐客户 //9、其余正式客户;5、试用客户
  829. func GetSpecialUserType(user *models.WxUserItem) (userType int, err error) {
  830. companyId := user.CompanyId
  831. companyDetail, e := models.GetCompanyDetailByIdGroupTrip(companyId)
  832. if e != nil && e.Error() != utils.ErrNoRow() {
  833. err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
  834. return
  835. }
  836. if companyDetail == nil {
  837. return
  838. }
  839. if companyId <= 1 {
  840. userType = 0
  841. } else {
  842. if companyDetail.Status == "永续" {
  843. userType = 1
  844. } else {
  845. if companyDetail.Status == "正式" {
  846. list, e := models.GetCompanyReportPermissionUpgrade(companyId, 2)
  847. if e != nil && e.Error() != utils.ErrNoRow() {
  848. err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
  849. }
  850. if len(list) == 0 {
  851. userType = 9
  852. }
  853. if len(list) == 4 {
  854. totalName, e := models.GetCompanyPermissionNameCheck(companyId, 2, "策略")
  855. if e != nil {
  856. err = errors.New("获取品种信息失败, Err:" + e.Error())
  857. return
  858. }
  859. if totalName > 0 {
  860. userType = 2
  861. } else {
  862. userType = 8
  863. }
  864. } else {
  865. userType = 8
  866. }
  867. } else if companyDetail.Status == "试用" {
  868. userType = 5
  869. }
  870. }
  871. }
  872. return
  873. }
  874. // GetSpecialDetailUserPower 处理用户查看专项调研详情的权限
  875. func GetSpecialDetailUserPower(user *models.WxUserItem, activityInfo *models.CygxActivitySpecialDetail) (havePower bool, err error) {
  876. if user.CompanyId == utils.HZ_COMPANY_ID {
  877. havePower = true
  878. return
  879. }
  880. userType, _, e := GetUserType(user.CompanyId)
  881. if e != nil {
  882. err = errors.New("GetSpecialUserType, Err: " + e.Error())
  883. return
  884. }
  885. if userType == 0 {
  886. return
  887. }
  888. mapUserType, e := GetActivityCcustomerTypeList()
  889. if e != nil {
  890. err = e
  891. return
  892. }
  893. var userTypeStr string
  894. userTypeStr = mapUserType[userType]
  895. // 永续客户、大套餐客户可以查看行业升级套餐客户 权限
  896. if userTypeStr == "1" || userTypeStr == "2" {
  897. if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) || strings.Contains(activityInfo.CustomerTypeIds, "8") {
  898. havePower = true
  899. return
  900. }
  901. }
  902. permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
  903. if e != nil {
  904. err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
  905. return
  906. }
  907. //如果有升级权限的自动添加策略的升级权限
  908. if permissionStr != "" {
  909. if activityInfo.ChartPermissionName == utils.CE_LUE_NAME {
  910. permissionStr += "," + utils.CE_LUE_NAME
  911. }
  912. }
  913. //如果没有对应的升级权限,则返回
  914. if !strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
  915. return
  916. }
  917. //userType, e := GetSpecialUserType(user)
  918. var pars []interface{}
  919. var condition string
  920. var userTypes string
  921. condition += ` AND art.publish_status = 1 AND art.is_offline = 0 `
  922. userTypes = "%" + userTypeStr + "%"
  923. condition += ` AND art.customer_type_ids LIKE ? `
  924. pars = append(pars, userTypes)
  925. condition += ` AND art.activity_id = ? `
  926. pars = append(pars, activityInfo.ActivityId)
  927. total, e := models.GetActivitySpecialCount(condition, pars)
  928. if e != nil {
  929. err = errors.New("GetSpecialUserType, Err: " + e.Error())
  930. return
  931. }
  932. if total == 1 {
  933. havePower = true
  934. return
  935. }
  936. fmt.Println(userType)
  937. fmt.Println(permissionStr)
  938. fmt.Println(activityInfo.ChartPermissionName)
  939. fmt.Println(activityInfo.CustomerTypeIds)
  940. if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
  941. havePower = true
  942. return
  943. }
  944. return
  945. }
  946. // 预报名活动,感兴趣人数满10人时,推送给活动负责人和王芳
  947. func SendWxMsgActivitySpecial10(activityInfo *models.CygxActivitySpecialDetail) (err error) {
  948. activityId := activityInfo.ActivityId
  949. var msg string
  950. defer func() {
  951. if err != nil {
  952. go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
  953. go utils.SendAlarmMsg(fmt.Sprint("预报名活动,感兴趣人数满10人时,推送给活动负责人和王芳消息发送失败", activityInfo.ResearchTheme, ", activityId"), 2)
  954. utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
  955. }
  956. }()
  957. var first string
  958. var keyword1 string
  959. var keyword2 string
  960. var keyword3 string
  961. var keyword4 string
  962. var remark string
  963. adminUser, e := models.GetSellerByAdminId(activityInfo.AdminId)
  964. if e != nil {
  965. err = errors.New("GetSellerByAdminId, Err: " + e.Error())
  966. return
  967. }
  968. cnf, _ := models.GetConfigByCode("tpl_msg")
  969. mobile := adminUser.Mobile + "," + cnf.ConfigValue
  970. specialSignupList, e := models.GetActivityListSpecialByActivityId(activityId)
  971. if e != nil {
  972. err = errors.New("GetActivityListSpecialAll, Err: " + e.Error())
  973. return
  974. }
  975. for _, v := range specialSignupList {
  976. keyword1 += "【" + v.RealName + "--" + v.CompanyName + "】"
  977. }
  978. openIdList, e := models.GetWxOpenIdByMobileList(mobile)
  979. if e != nil {
  980. err = errors.New("GetSellerByAdminId, Err: " + e.Error())
  981. return
  982. }
  983. first = "【" + activityInfo.ResearchTheme + "】已有10人预报名"
  984. keyword3 = "-"
  985. keyword2 = "-"
  986. keyword4 = activityInfo.ResearchTheme
  987. openIdArr := make([]string, 0)
  988. for _, v := range openIdList {
  989. openIdArr = append(openIdArr, v.OpenId)
  990. }
  991. redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(activityId)
  992. sendInfo := new(SendWxTemplate)
  993. sendInfo.First = first
  994. sendInfo.Keyword1 = keyword1
  995. sendInfo.Keyword2 = keyword2
  996. sendInfo.Keyword3 = keyword3
  997. sendInfo.Keyword4 = keyword4
  998. sendInfo.Remark = remark
  999. sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
  1000. sendInfo.RedirectUrl = redirectUrl
  1001. sendInfo.RedirectTarget = 3
  1002. sendInfo.Resource = strconv.Itoa(activityId)
  1003. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
  1004. sendInfo.OpenIdArr = openIdArr
  1005. err = PublicSendTemplateMsg(sendInfo)
  1006. if err != nil {
  1007. return
  1008. }
  1009. return
  1010. }