activity.go 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_web_mfyx/models"
  6. "hongze/hongze_web_mfyx/models/order"
  7. "hongze/hongze_web_mfyx/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. "unicode/utf8"
  12. )
  13. // 获取活动列表查询权限的SQL
  14. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  15. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  16. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  17. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  18. // @Param WhichTime query string false "已结束的时间筛选项 本周:1、上周:2 、本月:3、上月:4"
  19. // @Param Label query string false "搜索主题 多个用 , 隔开"
  20. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  21. // @Param KeyWord query string false "搜索关键词"
  22. // @Param ikType query int false "联想词类型 , 1不做联想,2,做除初始词的联想,3所有联想"
  23. func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermissionIds, whichDay, activeState, label string, isPower, source int, keyWord string, playBack, ikType int) (conditionActivity string, err error) {
  24. keyWordNoIk := keyWord
  25. adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
  26. if err != nil {
  27. return
  28. }
  29. userType, permissionStr, permissionStrZhengShi, err := GetUserTypeZhengShi(user.CompanyId)
  30. if err != nil {
  31. return
  32. }
  33. //判断客户规模是否属于可见范围的活动
  34. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  35. if err != nil && err.Error() != utils.ErrNoRow() {
  36. return
  37. }
  38. isMaker := user.IsMaker
  39. slicePer := strings.Split(permissionStr, ",")
  40. var permissionSqlStr string
  41. var permissionNameStr string
  42. for _, v := range slicePer {
  43. if userType == 1 {
  44. //研选权限处理
  45. if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
  46. permissionNameStr += "'" + v + "',"
  47. }
  48. } else {
  49. permissionNameStr += "'" + v + "',"
  50. }
  51. }
  52. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  53. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  54. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  55. slicePerZhengShi := strings.Split(permissionStrZhengShi, ",")
  56. var permissionNameStrZhengShi string
  57. for _, v := range slicePerZhengShi {
  58. if userType == 1 {
  59. //研选权限处理
  60. if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
  61. permissionNameStrZhengShi += "'" + v + "',"
  62. }
  63. } else {
  64. permissionNameStrZhengShi += "'" + v + "',"
  65. }
  66. }
  67. permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(主观)", "", -1)
  68. permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(客观)", "", -1)
  69. permissionNameStrZhengShi = strings.TrimRight(permissionNameStrZhengShi, ",")
  70. mapUserType, e := GetActivityCcustomerTypeList()
  71. if e != nil {
  72. err = e
  73. return
  74. }
  75. var userTypeStr string
  76. userTypeStr = mapUserType[userType]
  77. // 查研观向7.4-始终查询宏观的权限(无论是否有权限)
  78. if permissionNameStr == `` {
  79. permissionNameStr = `'宏观'`
  80. } else {
  81. permissionNameStr += `, '宏观'`
  82. }
  83. var condition string
  84. var conditionAdmin string
  85. var conditionHz string // 弘则权限处理
  86. var sqlExport string // 专家权限处理
  87. //permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionNameStr + `)`
  88. sqlExport = ` AND (art.customer_type_ids LIKE '%` + userTypeStr + `%' `
  89. //if userType == 2 {
  90. // sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  91. //}
  92. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  93. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  94. }
  95. sqlExport += `) `
  96. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  97. if activityTypeId != "" {
  98. if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
  99. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
  100. } else {
  101. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.activity_type_id IN (` + activityTypeId + `)`
  102. }
  103. }
  104. //主题
  105. if label != "" {
  106. condition = ` AND art.label LIKE "%` + label + `%" `
  107. }
  108. if isPower == 1 {
  109. condition += permissionSqlStr
  110. }
  111. //行业名称
  112. if len(chartPermissionIds) > 0 {
  113. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  114. }
  115. //如果是PC的,则不看易董的
  116. if source == 1 {
  117. condition += ` AND art.yidong_activity_id = '' `
  118. }
  119. var conditionOr string
  120. if whichDay != "" {
  121. var startDate string
  122. var endDate string
  123. if whichDay == "1" {
  124. startDate = time.Now().Format(utils.FormatDate)
  125. endDate = startDate
  126. } else if whichDay == "2" {
  127. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  128. endDate = startDate
  129. } else if whichDay == "3" {
  130. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  131. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  132. } else if whichDay == "4" {
  133. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  134. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  135. } else if whichDay == "5" {
  136. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  137. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  138. } else if whichDay == "6" {
  139. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  140. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  141. } else if whichDay == "1,2" {
  142. startDate = time.Now().Format(utils.FormatDate)
  143. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  144. } else if whichDay == "3,4" {
  145. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  146. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  147. } else if whichDay == "5,6" {
  148. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  149. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  150. } else {
  151. startDate = time.Now().Format(utils.FormatDate)
  152. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  153. }
  154. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  155. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  156. }
  157. //有搜索条件传过来时,不判进行状态条件
  158. if keyWord != "" {
  159. if ikType == 2 || ikType == 3 {
  160. keyWordArr, e := GetIndustryMapNameSliceV3(keyWord)
  161. if e != nil {
  162. err = errors.New("获取分词失败,GetIndustryMapNameSliceV3, Err: " + keyWord + e.Error())
  163. return
  164. }
  165. keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
  166. //var keywords string
  167. if len(keyWordArr) > 1 {
  168. if ikType == 2 {
  169. keyWord = KeyWordArrSqlRegexp(keyWordArr)
  170. condition += ` AND (art.label NOT LIKE '%` + keyWordNoIk + `%' AND art.activity_name NOT LIKE '%` + keyWordNoIk + `%' ) `
  171. } else if ikType == 3 {
  172. keyWord = KeyWordArrSqlRegexpAll(keyWordArr)
  173. }
  174. }
  175. }
  176. condition += ` AND (art.label REGEXP '` + keyWord + `' OR art.activity_name REGEXP '` + keyWord + `' ) `
  177. } else {
  178. if activeState != "" {
  179. // 默认查看未开始跟进行中
  180. if activeState == "1" {
  181. condition += ` AND art.active_state IN (1,2)`
  182. } else {
  183. condition += ` AND art.active_state IN (` + activeState + `)`
  184. }
  185. } else {
  186. condition += ` AND art.active_state IN (1,2)`
  187. }
  188. }
  189. if playBack == 1 {
  190. var pars []interface{}
  191. ativityVIdArry := make([]string, 0)
  192. voiceList, e := models.GetActivityVoiceListAll("", pars, 0, 1000)
  193. if e != nil && e.Error() != utils.ErrNoRow() {
  194. err = e
  195. return
  196. }
  197. for _, v := range voiceList {
  198. ativityVIdArry = append(ativityVIdArry, strconv.Itoa(v.ActivityId))
  199. }
  200. videoList, e := models.GetActivityVideoListAll("", pars, 0, 1000)
  201. if e != nil && e.Error() != utils.ErrNoRow() {
  202. err = e
  203. return
  204. }
  205. for _, v := range videoList {
  206. ativityVIdArry = append(ativityVIdArry, strconv.Itoa(v.ActivityId))
  207. }
  208. //活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间
  209. //endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
  210. //condition += ` AND art.activity_time > '` + endTime + `' `
  211. if len(ativityVIdArry) > 0 {
  212. ativityVIdstr := strings.Join(ativityVIdArry, ",")
  213. condition += ` AND art.activity_id IN (` + ativityVIdstr + `) `
  214. } else {
  215. condition += ` AND art.activity_id = 0 `
  216. }
  217. }
  218. //查询全部可见的数据(是否全部客户可见)
  219. //condition += ` AND art.visible_range != 1 AND art.publish_status = 1 `
  220. condition += ` AND art.publish_status = 1 `
  221. //if adminIds == "" {
  222. // //condition += ` AND art.visible_range != 1 `
  223. //} else {
  224. // condition += ` AND ( art.visible_range != 1 OR ( art.admin_id IN ( ` + adminIds + ` ) AND art.visible_range = 1 )) `
  225. //}
  226. if adminIds != "" {
  227. condition += ` AND ( art.visible_range != 1 OR ( art.admin_id IN ( ` + adminIds + ` ) AND art.visible_range = 1 )) `
  228. }
  229. conditionHz = condition
  230. //活动仅决策人可见
  231. if isMaker == 0 {
  232. condition += ` AND art.is_maker_show = 0 `
  233. }
  234. conditionAdmin = condition + ` AND art.visible_range = 1 `
  235. //condition += ` AND art.visible_range != 1 `
  236. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  237. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  238. }
  239. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  240. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  241. }
  242. if userType == 1 {
  243. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  244. } else {
  245. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  246. }
  247. if userType == 6 || userType == 7 {
  248. conditionOr += ` OR ( art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' ` + condition + `) `
  249. }
  250. if companyProduct != nil {
  251. if companyProduct.Scale != "" {
  252. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  253. }
  254. }
  255. if adminIds != "" {
  256. if userType == 3 {
  257. conditionAdmin += ` AND art.chart_permission_name IN (` + permissionNameStrZhengShi + `) `
  258. }
  259. conditionOr += ` OR ( art.customer_type_ids LIKE '%` + userTypeStr + `%' ` + ` AND art.admin_id IN (` + adminIds + `) ` + conditionAdmin + `) `
  260. if companyProduct != nil {
  261. if companyProduct.Scale != "" {
  262. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%'` + ` AND art.admin_id IN (` + adminIds + `) ` + conditionAdmin + `) `
  263. }
  264. }
  265. }
  266. conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
  267. if e != nil {
  268. err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
  269. return
  270. }
  271. if conditionShengji != "" {
  272. conditionOr += ` OR ( art.is_limit_people = 1 AND ` + conditionShengji + condition + ` ) `
  273. }
  274. if conditionZhengshi != "" {
  275. conditionOr += ` OR ( art.is_limit_people = 1 AND ` + conditionZhengshi + condition + ` ) `
  276. }
  277. if conditionHangYe != "" {
  278. conditionOr += ` OR ( art.is_limit_people = 1 AND ` + conditionHangYe + condition + ` ) `
  279. }
  280. //弘则研究下的客户不做权限,限制,C类电话会,仅本组销售、部门管理员、admin、权益研究员账号能看到
  281. if user.CompanyId == utils.HZ_COMPANY_ID {
  282. mapMobile, e := GetAdminMobileMap()
  283. if e != nil {
  284. err = e
  285. return
  286. }
  287. if _, ok := mapMobile[user.Mobile]; ok {
  288. conditionOr += ` OR ( art.publish_status = 1 ` + conditionHz + `) `
  289. }
  290. }
  291. if userType == 3 {
  292. condition += ` AND art.chart_permission_name IN (` + permissionNameStrZhengShi + `) `
  293. }
  294. conditionActivity = condition + permissionSqlStr + sqlExport + conditionOr
  295. return
  296. }
  297. // 根据用户身份处理活动可见
  298. func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower int) (conditionActivity string, err error) {
  299. condition += " AND IF ( art.is_limit_people = 1 , art.customer_type_ids != '' ,1=1 ) "
  300. //未登录的用户也可以查看所有活动v12.2.1
  301. if user.UserId == 0 {
  302. conditionActivity = ` AND art.publish_status = 1 AND art.yidong_activity_id = '' ` + condition
  303. return
  304. }
  305. // cygx_10.9 未绑定联系方式的客户可以看到部分活动
  306. if user.UserId == 0 || user.CompanyId == 1 {
  307. conditionActivity = ` AND art.publish_status = 1 AND art.visible_range != 1 AND (art.is_limit_people = 0 OR (art.is_limit_people=1 AND art.is_all_customer_type=1)) ` + condition
  308. return
  309. }
  310. condition += ` AND art.publish_status = 1 `
  311. conditionActivity = condition
  312. //弘则可以查看所有活动
  313. if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || user.UserId == 0 {
  314. return
  315. }
  316. adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
  317. if err != nil {
  318. return
  319. }
  320. userType, permissionStr, permissionStrZhengShi, err := GetUserTypeZhengShi(user.CompanyId)
  321. if err != nil {
  322. return
  323. }
  324. //判断客户规模是否属于可见范围的活动
  325. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  326. if err != nil && err.Error() != utils.ErrNoRow() {
  327. return
  328. }
  329. isMaker := user.IsMaker
  330. slicePer := strings.Split(permissionStr, ",")
  331. var permissionSqlStr string
  332. var permissionNameStr string
  333. for _, v := range slicePer {
  334. if userType == 1 {
  335. //研选权限处理
  336. if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
  337. permissionNameStr += "'" + v + "',"
  338. }
  339. } else {
  340. permissionNameStr += "'" + v + "',"
  341. }
  342. }
  343. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  344. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  345. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  346. slicePerZhengShi := strings.Split(permissionStrZhengShi, ",")
  347. var permissionNameStrZhengShi string
  348. for _, v := range slicePerZhengShi {
  349. if userType == 1 {
  350. //研选权限处理
  351. if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
  352. permissionNameStrZhengShi += "'" + v + "',"
  353. }
  354. } else {
  355. permissionNameStrZhengShi += "'" + v + "',"
  356. }
  357. }
  358. permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(主观)", "", -1)
  359. permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(客观)", "", -1)
  360. permissionNameStrZhengShi = strings.TrimRight(permissionNameStrZhengShi, ",")
  361. mapUserType, e := GetActivityCcustomerTypeList()
  362. if e != nil {
  363. err = e
  364. return
  365. }
  366. var userTypeStr string
  367. userTypeStr = mapUserType[userType]
  368. // 查研观向7.4-始终查询宏观的权限(无论是否有权限)
  369. if permissionNameStr == `` {
  370. permissionNameStr = `'宏观'`
  371. } else {
  372. permissionNameStr += `, '宏观'`
  373. }
  374. var sqlExport string // 专家权限处理
  375. sqlExport = ` AND (art.customer_type_ids LIKE '%` + userTypeStr + `%' `
  376. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  377. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  378. }
  379. sqlExport += `) `
  380. if isPower == 1 {
  381. //permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionNameStr + `)`
  382. //condition += permissionSqlStr
  383. }
  384. var conditionOr string
  385. //查询全部可见的数据(是否全部客户可见)
  386. if adminIds != "" {
  387. condition += ` AND ( art.visible_range != 1 OR ( art.admin_id IN ( ` + adminIds + ` ) AND art.visible_range = 1 )) `
  388. }
  389. //活动仅决策人可见
  390. if isMaker == 0 {
  391. condition += ` AND art.is_maker_show = 0 `
  392. }
  393. //condition += ` AND art.visible_range != 1 `
  394. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  395. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  396. }
  397. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  398. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  399. }
  400. if userType == 1 {
  401. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  402. } else {
  403. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  404. }
  405. if userType == 6 || userType == 7 {
  406. conditionOr += ` OR ( art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' ` + condition + `) `
  407. }
  408. if companyProduct != nil {
  409. if companyProduct.Scale != "" {
  410. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  411. }
  412. }
  413. //if userType == 3 {
  414. // condition += ` AND art.chart_permission_name IN (` + permissionNameStrZhengShi + `) `
  415. //}
  416. condition += ` AND art.is_limit_people = 1 `
  417. conditionActivity = condition + permissionSqlStr + sqlExport + conditionOr
  418. return
  419. }
  420. // 5.3版本活动标签字符串处理
  421. func LabelStr(label string, isShowSubjectName int, temporaryLabel string) (labelNew string) {
  422. slicebr := strings.Split(label, "-")
  423. if len(slicebr) > 1 {
  424. if isShowSubjectName == 1 {
  425. labelNew = slicebr[1]
  426. } else {
  427. labelNew = slicebr[0]
  428. }
  429. } else {
  430. labelNew = label
  431. }
  432. if temporaryLabel != "" {
  433. labelNew = temporaryLabel
  434. }
  435. return labelNew
  436. }
  437. // 列表
  438. func HandleActivityTypeHomeList(listType []*models.ActivityTypeHome, listActivity []*models.CygxActivity, user *models.WxUserItem) (items []*models.ActivityTypeHome, err error) {
  439. mapActivity := make(map[int][]*models.CygxActivityLabelList)
  440. activityIds := make([]int, 0) // 用于查询活动【新】标签Map
  441. for _, v := range listActivity {
  442. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  443. if v.ActivityTypeId == 7 {
  444. v.ActivityTypeId = 2
  445. }
  446. // 如果是买方线下交流的活动,合并到专家线下交流
  447. if v.ActivityTypeId == 8 {
  448. v.ActivityTypeId = 5
  449. }
  450. //if v.ActivityTypeId == 1 {
  451. activityIds = append(activityIds, v.ActivityId)
  452. //}
  453. }
  454. // 活动【新】标签Map
  455. newLabelMap, _, e := GetActivityNewLabelMap(activityIds)
  456. if e != nil {
  457. err = errors.New("获取产业新标签Map失败,GetActivityNewLabelMap Err: " + e.Error())
  458. return
  459. }
  460. activityPointsByUserAllMap := GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动
  461. mapkeyWord := make(map[string]string)
  462. for _, v := range listActivity {
  463. if v.Label == "" {
  464. continue
  465. }
  466. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  467. if v.ActivityTypeId == 7 {
  468. v.ActivityTypeId = 2
  469. }
  470. item := new(models.CygxActivityLabelList)
  471. item.IsResearchPoints = activityPointsByUserAllMap[v.ActivityId]
  472. item.KeyWord = LabelStr(v.Label, v.IsShowSubjectName, v.TemporaryLabel)
  473. if _, ok := mapkeyWord[fmt.Sprint(v.ActivityTypeId, "-", item.KeyWord)]; ok {
  474. continue
  475. }
  476. item.Resource = 1
  477. item.ActivityId = v.ActivityId
  478. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  479. item.IsResearch = true
  480. }
  481. //易董同步过来的活动只展示外部资源标签
  482. if v.YidongActivityId != "" {
  483. item.IsResearchPoints = false
  484. item.IsResearch = false
  485. }
  486. if v.IsExternalLabel > 0 {
  487. item.IsExternalLabel = true
  488. }
  489. //if v.IsResearchPoints > 0 {
  490. item.IsResearchPoints = activityPointsByUserAllMap[v.ActivityId]
  491. //}
  492. item.City = v.City
  493. if utf8.RuneCountInString(v.City) != 2 {
  494. item.City = ""
  495. }
  496. item.IsNew = newLabelMap[v.ActivityId]
  497. mapActivity[v.ActivityTypeId] = append(mapActivity[v.ActivityTypeId], item)
  498. mapkeyWord[fmt.Sprint(v.ActivityTypeId, "-", item.KeyWord)] = item.KeyWord
  499. }
  500. for _, v := range listType {
  501. v.Resource = 1
  502. if len(mapActivity[v.ActivityTypeId]) > 0 {
  503. v.List = mapActivity[v.ActivityTypeId]
  504. } else {
  505. v.List = make([]*models.CygxActivityLabelList, 0)
  506. }
  507. }
  508. items = listType
  509. return
  510. }
  511. // GetActivityVoiceResp 处理活动音频回放
  512. func GetActivityVoiceResp(mapActivityId []int) (mapItem map[int]*models.CygxActivityVoiceReq, err error) {
  513. activityVoiceList, err := models.GetCygxActivityVoiceReqList(mapActivityId)
  514. if err != nil && err.Error() != utils.ErrNoRow() {
  515. return
  516. }
  517. mapActivityVoice := make(map[int]*models.CygxActivityVoiceReq)
  518. if len(activityVoiceList) > 0 {
  519. for _, v := range activityVoiceList {
  520. v.Type = 1 //活动音频为1
  521. mapActivityVoice[v.ActivityId] = v
  522. }
  523. }
  524. mapItem = mapActivityVoice
  525. return
  526. }
  527. // GetActivityVideoResp 处理活动视频频回放
  528. func GetActivityVideoResp(mapActivityId []int) (mapItem map[int]*models.CygxActivityVideoListResp, err error) {
  529. var condition string
  530. var ativityVIdstr string
  531. for _, v := range mapActivityId {
  532. ativityVIdstr += strconv.Itoa(v) + ","
  533. }
  534. if ativityVIdstr == "" {
  535. return
  536. }
  537. ativityVIdstr = strings.TrimRight(ativityVIdstr, ",")
  538. condition += ` AND art.activity_id IN (` + ativityVIdstr + `) `
  539. var pars []interface{}
  540. //endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
  541. //condition += ` AND art.activity_time > ? `
  542. //pars = append(pars, endTime)
  543. videoList, e := models.GetActivityVideoListAll(condition, pars, 0, 1000)
  544. if e != nil && e.Error() != utils.ErrNoRow() {
  545. err = e
  546. return
  547. }
  548. mapActivityVideo := make(map[int]*models.CygxActivityVideoListResp)
  549. if len(videoList) > 0 {
  550. for _, v := range videoList {
  551. v.Type = 2 // 活动视频为 2
  552. mapActivityVideo[v.ActivityId] = v
  553. }
  554. }
  555. mapItem = mapActivityVideo
  556. return
  557. }
  558. func ActivityButtonShow(item *models.ActivityDetail, user *models.WxUserItem, permissionArr []string) (itemActivity *models.ActivityListResp) {
  559. activityDetail := item
  560. //IsShowAppointment bool `description:"是否展示预约纪要"`
  561. //IsShowOutboundCall bool `description:"是否展示预约外呼"`
  562. //IsShowMeetingReminder bool `description:"是否展示会议提醒"`
  563. //IsShowHelpSsk bool `description:"是否展示帮我带问"`
  564. //IsShowSignup bool `description:"是否展示我要报名"`
  565. activityPointsByUserAllMap := GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动
  566. if strings.Contains(activityDetail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  567. activityDetail.IsResearch = true
  568. }
  569. //勾选【研选扣点】且扣点对象为参会人的活动,需要有买方研选的正式权限
  570. if strings.Contains(activityDetail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && activityPointsByUserAllMap[activityDetail.ActivityId] {
  571. activityDetail.IsResearchSpecial = true
  572. }
  573. if activityDetail.SiginupDeadline == utils.FormatDateTimeInit { //报名截止时间处理
  574. activityDetail.SiginupDeadline = ""
  575. }
  576. //如果报名截止时间不规范,或者是非研选扣点活动就把截止时间设置为空
  577. if activityDetail.CancelDeadline == utils.FormatDateTimeInit || !activityDetail.IsResearchPoints {
  578. activityDetail.CancelDeadline = ""
  579. }
  580. activityTimeText := activityDetail.ActivityTimeText
  581. activityTimeText = strings.Replace(activityTimeText, "(", "(", -1)
  582. activityTimeText = strings.Replace(activityTimeText, ")", ")", -1)
  583. activityDetail.ActivityTimeText = activityTimeText
  584. var yidongActivityUrl string
  585. activityDetail.IsShowAppointment = false
  586. //易董的操作按钮都隐藏
  587. if activityDetail.YidongActivityId != "" {
  588. activityDetail.IsShowSignup = false
  589. activityDetail.IsShowDetails = true
  590. if activityDetail.YidongActivityId != "" {
  591. ydTgc, _ := GetYiDongCreateUserInfo(user)
  592. yidongLongLink, _ := GetYiDongOriginalLink(activityDetail)
  593. if yidongLongLink != "" {
  594. yidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  595. }
  596. }
  597. } else {
  598. //专家电话会 1
  599. if activityDetail.ActivityTypeId == 1 && activityDetail.IsLimitPeople == 0 && (activityDetail.ActiveState == "1" || activityDetail.ActiveState == "2") {
  600. activityDetail.IsShowHelpSsk = true
  601. }
  602. if activityDetail.ActiveState == "1" {
  603. //新的是否展示规则
  604. if activityDetail.IsCanAppointmentMinutes == 1 {
  605. activityDetail.IsShowAppointment = true
  606. }
  607. //专家电话会 1
  608. if activityDetail.ActivityTypeId == 1 {
  609. if activityDetail.LimitPeopleNum == 0 {
  610. activityDetail.IsShowOutboundCall = true
  611. } else {
  612. activityDetail.IsShowSignup = true
  613. }
  614. activityDetail.IsShowMeetingReminder = true
  615. activityDetail.IsShowHelpSsk = true
  616. }
  617. //分析师电话会 2
  618. if activityDetail.ActivityTypeId == 2 {
  619. if activityDetail.LimitPeopleNum == 0 {
  620. activityDetail.IsShowOutboundCall = true
  621. } else {
  622. activityDetail.IsShowSignup = true
  623. }
  624. activityDetail.IsShowMeetingReminder = true
  625. }
  626. if activityDetail.ActivityTypeId == 3 {
  627. //司调研电话会(3)、扣点的研选活动只展示我要报名
  628. if activityDetail.IsResearchPoints || activityDetail.LimitPeopleNum > 0 {
  629. activityDetail.IsShowSignup = true
  630. } else {
  631. activityDetail.IsShowMeetingReminder = true
  632. activityDetail.IsShowOutboundCall = true
  633. }
  634. }
  635. //公司线下调研 4
  636. if activityDetail.ActivityTypeId == 4 {
  637. activityDetail.IsShowSignup = true
  638. }
  639. //专家线下沙龙 5
  640. if activityDetail.ActivityTypeId == 5 {
  641. activityDetail.IsShowSignup = true
  642. }
  643. //分析师线下沙龙 6
  644. if activityDetail.ActivityTypeId == 6 {
  645. activityDetail.IsShowSignup = true
  646. }
  647. //分析师电话会(C类) 7
  648. if activityDetail.ActivityTypeId == 7 {
  649. activityDetail.IsShowSignup = true
  650. activityDetail.IsShowMeetingReminder = true
  651. }
  652. //买方线下交流 8 // 查研观向 11.0
  653. if activityDetail.ActivityTypeId == 8 {
  654. activityDetail.IsShowSignup = true
  655. }
  656. //如果是易董创建的活动,展示我要报名,不展示预约外呼
  657. if activityDetail.IsYidongConduct {
  658. activityDetail.IsShowSignup = true
  659. activityDetail.IsShowOutboundCall = false
  660. }
  661. }
  662. }
  663. if activityDetail.ActivityTypeName == "买方线下交流" {
  664. activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_1
  665. }
  666. if activityDetail.ActivityTypeName == "专家电话会" || activityDetail.ActivityTypeName == "专家线下沙龙" {
  667. activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_2
  668. }
  669. if activityDetail.ActivityTypeName == "公司调研电话会" {
  670. activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_3
  671. }
  672. activityDetail.IsResearchPoints = activityPointsByUserAllMap[activityDetail.ActivityId]
  673. authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  674. if e != nil {
  675. e = errors.New("获取用户权限失败, Err: " + e.Error())
  676. return
  677. }
  678. //如果是易董同步过来的,只展示外部资源标签
  679. if activityDetail.YidongActivityId != "" {
  680. activityDetail.IsExternalLabel = true
  681. activityDetail.IsResearch = false
  682. activityDetail.IsResearchSpecial = false
  683. }
  684. v := activityDetail
  685. itemActivity = &models.ActivityListResp{
  686. ActivityId: v.ActivityId,
  687. ActivityTypeId: v.ActivityTypeId,
  688. ActivityTypeName: v.ActivityTypeName,
  689. ChartPermissionId: v.ChartPermissionId,
  690. ChartPermissionName: v.ChartPermissionName,
  691. IsLimitPeople: v.IsLimitPeople,
  692. LimitPeopleNum: v.LimitPeopleNum,
  693. LastUpdatedTime: v.LastUpdatedTime,
  694. ActivityTime: v.ActivityTime,
  695. ActivityTimeText: v.ActivityTimeText,
  696. DistinguishedGuest: v.DistinguishedGuest,
  697. Host: v.Host,
  698. Speaker: v.Speaker,
  699. MainlandTell: v.MainlandTell,
  700. HongKongTell: v.HongKongTell,
  701. TaiwanTell: v.TaiwanTell,
  702. AmericaTell: v.AmericaTell,
  703. ParticipationCode: v.ParticipationCode,
  704. Theme: v.Theme,
  705. Expert: v.Expert,
  706. ActivityName: v.ActivityName,
  707. OnlineParticipation: v.OnlineParticipation,
  708. ReportLink: v.ReportLink,
  709. AppAttendance: v.AppAttendance,
  710. ConferencePassword: v.ConferencePassword,
  711. City: v.City,
  712. Address: v.Address,
  713. Highlights: v.Highlights,
  714. Remarks: v.Remarks,
  715. IsSignup: v.IsSignup,
  716. IsCancelMeetingReminder: v.IsCancelMeetingReminder,
  717. IsAppointment: v.IsAppointment,
  718. ActiveState: v.ActiveState,
  719. IsShowSustainable: v.IsShowSustainable,
  720. Description: v.Description,
  721. IsResearch: v.IsResearch,
  722. IsHideAppointment: v.IsHideAppointment,
  723. IsCClassMeeting: v.IsCClassMeeting,
  724. Label: v.Label,
  725. ImgUrl: v.ImgUrl,
  726. ImgUrlText: v.ImgUrlText,
  727. ActivityType: v.ActivityType,
  728. IsShowOutboundCall: v.IsShowOutboundCall,
  729. IsShowMeetingReminder: v.IsShowMeetingReminder,
  730. IsShowHelpSsk: v.IsShowHelpSsk,
  731. IsShowSignup: v.IsShowSignup,
  732. IsShowAppointment: v.IsShowAppointment,
  733. IsShowDetails: v.IsShowDetails,
  734. AudioLink: v.AudioLink,
  735. VoiceDetail: v.VoiceList,
  736. VideoDetail: v.VideoDetail,
  737. FileType: v.FileType,
  738. SourceType: v.SourceType,
  739. SignupNum: v.SignupNum,
  740. YidongActivityUrl: yidongActivityUrl,
  741. Explain: utils.ACtIVITY_SPECIAL_EXPLAIN,
  742. TripImgLink: v.TripImgLink,
  743. Days: v.Days,
  744. SignupType: v.SignupType,
  745. IsYidongConduct: v.IsYidongConduct,
  746. IsCanOutboundCall: v.IsCanOutboundCall,
  747. TencentConferenceNumber: v.TencentConferenceNumber,
  748. IsResearchSpecial: v.IsResearchSpecial,
  749. LinkParticipants: v.LinkParticipants,
  750. IsResearchPoints: v.IsResearchPoints,
  751. IsResearchPointsByUser: v.IsResearchPointsByUser,
  752. IsExternalLabel: v.IsExternalLabel,
  753. SiginupDeadline: v.SiginupDeadline,
  754. CancelDeadline: v.CancelDeadline,
  755. LabelKeywordImgLink: v.LabelKeywordImgLink,
  756. IsShowWxPay: utils.IS_SHOW_WX_PAY,
  757. }
  758. au := new(models.UserPermissionAuthInfo)
  759. au.SellerName = authInfo.SellerName
  760. au.SellerMobile = authInfo.SellerMobile
  761. au.HasPermission = authInfo.HasPermission
  762. au.OperationMode = authInfo.OperationMode
  763. if au.HasPermission == 1 {
  764. // 非宏观权限进一步判断是否有权限
  765. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  766. au.HasPermission = 2
  767. }
  768. //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
  769. if v.YidongActivityId != "" {
  770. if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
  771. au.HasPermission = 1
  772. }
  773. }
  774. }
  775. // 无权限的弹框提示
  776. if au.HasPermission != 1 {
  777. if au.OperationMode == UserPermissionOperationModeCall {
  778. if v.FileType == 1 {
  779. au.PopupMsg = UserPermissionPopupMsgCallMicroVoice
  780. } else {
  781. au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
  782. }
  783. } else {
  784. if v.FileType == 1 {
  785. au.PopupMsg = UserPermissionPopupMsgApplyMicroVoice
  786. } else {
  787. au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
  788. }
  789. }
  790. }
  791. itemActivity.AuthInfo = au
  792. //处理用户已经报名了的行程
  793. var activityIds []int
  794. activityIds = append(activityIds, v.ActivityId)
  795. UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
  796. if e != nil {
  797. e = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
  798. return
  799. }
  800. if _, ok := UserMap[v.ActivityId]; ok {
  801. itemActivity.IsTrip = 1
  802. }
  803. if itemActivity.Days == 0 {
  804. itemActivity.TripStatus = 1
  805. //activityDetail.Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
  806. } else {
  807. itemActivity.TripStatus = 2
  808. //itemActivity.TripImgLink = itemActivity.TripImgLinkFix
  809. //activityDetail.Explain = utils.ACtIVITY_SPECIAL_TRIP_EXPLAIN
  810. }
  811. return
  812. }
  813. func ActivityArrButtonShow(items []*models.ActivityDetail, user *models.WxUserItem, permissionArr []string) (itemsActivity []*models.ActivityListResp) {
  814. var err error
  815. defer func() {
  816. if err != nil {
  817. fmt.Println(err)
  818. go utils.SendAlarmMsg(fmt.Sprint("获取用户十分钟之内是否有相同的文章订单信息失败 GetHaverEquallyOrderByUser10MinByArticle, err:", err.Error()), 2)
  819. }
  820. }()
  821. var activityIds []int
  822. userPermissionCode, e := GetUserPermissionCode(user.UserId, user.CompanyId)
  823. if e != nil {
  824. err = errors.New("获取用户权限失败, userPermissionCode Err: " + e.Error())
  825. return
  826. }
  827. authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  828. if e != nil {
  829. err = errors.New("获取用户权限失败, Err: " + e.Error())
  830. return
  831. }
  832. activityPointsByUserAllMap := GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动
  833. for _, v := range items {
  834. activityIds = append(activityIds, v.ActivityId)
  835. }
  836. virtualAssetActivityList, e := order.GetCygxOrderVirtualAssetActivityList(activityIds, user.Mobile) // 获取用户购买的单场活动信息
  837. if e != nil {
  838. err = errors.New("GetCygxOrderVirtualAssetActivityList, Err: " + e.Error())
  839. return
  840. }
  841. virtualAssetActivityIds := make(map[int]bool)
  842. for _, v := range virtualAssetActivityList {
  843. virtualAssetActivityIds[v.SourceId] = true
  844. }
  845. userCardTotal := GetCygxOrderUserCardTotal(user.Mobile) //用户是否持有有效卡片
  846. for _, activityDetail := range items {
  847. //IsShowAppointment bool `description:"是否展示预约纪要"`
  848. //IsShowOutboundCall bool `description:"是否展示预约外呼"`
  849. //IsShowMeetingReminder bool `description:"是否展示会议提醒"`
  850. //IsShowHelpSsk bool `description:"是否展示帮我带问"`
  851. //IsShowSignup bool `description:"是否展示我要报名"`
  852. if strings.Contains(activityDetail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  853. activityDetail.IsResearch = true
  854. }
  855. //如果是 公司调研电话会:3,或 专家线下沙龙:5 而且 除易董同步过来的以外的研选类型活动
  856. //if (activityDetail.ActivityTypeId == 3 || activityDetail.ActivityTypeId == 5) && activityDetail.YidongActivityId == "" && strings.Contains(activityDetail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  857. // activityDetail.IsResearchSpecial = true
  858. //}
  859. //勾选【研选扣点】且扣点对象为参会人的活动,需要有买方研选的正式权限
  860. if strings.Contains(activityDetail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && activityPointsByUserAllMap[activityDetail.ActivityId] {
  861. activityDetail.IsResearchSpecial = true
  862. }
  863. if activityDetail.SiginupDeadline == utils.FormatDateTimeInit { //报名截止时间处理
  864. activityDetail.SiginupDeadline = ""
  865. }
  866. //如果报名截止时间不规范,或者是非研选扣点活动就把截止时间设置为空
  867. if activityDetail.CancelDeadline == utils.FormatDateTimeInit || !activityDetail.IsResearchPoints {
  868. activityDetail.CancelDeadline = ""
  869. }
  870. activityTimeText := activityDetail.ActivityTimeText
  871. activityTimeText = strings.Replace(activityTimeText, "(", "(", -1)
  872. activityTimeText = strings.Replace(activityTimeText, ")", ")", -1)
  873. activityDetail.ActivityTimeText = activityTimeText
  874. var yidongActivityUrl string
  875. activityDetail.IsShowAppointment = false
  876. //易董的操作按钮都隐藏
  877. if activityDetail.YidongActivityId != "" {
  878. activityDetail.IsShowSignup = false
  879. activityDetail.IsShowDetails = true
  880. activityDetail.IsYidongActivity = true
  881. //if activityDetail.YidongActivityId != "" {
  882. // ydTgc, _ := GetYiDongCreateUserInfo(user)
  883. // yidongLongLink, _ := GetYiDongOriginalLink(activityDetail)
  884. // if yidongLongLink != "" {
  885. // yidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  886. // }
  887. //}
  888. } else {
  889. //专家电话会 1
  890. if activityDetail.ActivityTypeId == 1 && activityDetail.IsLimitPeople == 0 && (activityDetail.ActiveState == "1" || activityDetail.ActiveState == "2") {
  891. activityDetail.IsShowHelpSsk = true
  892. }
  893. if activityDetail.ActiveState == "1" {
  894. //新的是否展示规则
  895. if activityDetail.IsCanAppointmentMinutes == 1 {
  896. activityDetail.IsShowAppointment = true
  897. }
  898. //专家电话会 1
  899. if activityDetail.ActivityTypeId == 1 {
  900. if activityDetail.LimitPeopleNum == 0 {
  901. activityDetail.IsShowOutboundCall = true
  902. } else {
  903. activityDetail.IsShowSignup = true
  904. }
  905. activityDetail.IsShowMeetingReminder = true
  906. activityDetail.IsShowHelpSsk = true
  907. }
  908. //分析师电话会 2
  909. if activityDetail.ActivityTypeId == 2 {
  910. if activityDetail.LimitPeopleNum == 0 {
  911. activityDetail.IsShowOutboundCall = true
  912. } else {
  913. activityDetail.IsShowSignup = true
  914. }
  915. activityDetail.IsShowMeetingReminder = true
  916. }
  917. if activityDetail.ActivityTypeId == 3 {
  918. //司调研电话会(3)、扣点的研选活动只展示我要报名
  919. if activityDetail.IsResearchPoints || activityDetail.LimitPeopleNum > 0 {
  920. activityDetail.IsShowSignup = true
  921. } else {
  922. activityDetail.IsShowMeetingReminder = true
  923. activityDetail.IsShowOutboundCall = true
  924. }
  925. }
  926. //公司线下调研 4
  927. if activityDetail.ActivityTypeId == 4 {
  928. activityDetail.IsShowSignup = true
  929. }
  930. //专家线下沙龙 5
  931. if activityDetail.ActivityTypeId == 5 {
  932. activityDetail.IsShowSignup = true
  933. }
  934. //分析师线下沙龙 6
  935. if activityDetail.ActivityTypeId == 6 {
  936. activityDetail.IsShowSignup = true
  937. }
  938. //分析师电话会(C类) 7
  939. if activityDetail.ActivityTypeId == 7 {
  940. activityDetail.IsShowSignup = true
  941. activityDetail.IsShowMeetingReminder = true
  942. }
  943. //买方线下交流 8 // 查研观向 11.0
  944. if activityDetail.ActivityTypeId == 8 {
  945. activityDetail.IsShowSignup = true
  946. }
  947. //如果是易董创建的活动,展示我要报名,不展示预约外呼
  948. if activityDetail.IsYidongConduct {
  949. activityDetail.IsShowSignup = true
  950. activityDetail.IsShowOutboundCall = false
  951. }
  952. }
  953. }
  954. activityDetail.IsResearchPoints = activityPointsByUserAllMap[activityDetail.ActivityId]
  955. if activityDetail.ActivityTypeName == "买方线下交流" {
  956. activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_1
  957. }
  958. if activityDetail.ActivityTypeName == "专家电话会" || activityDetail.ActivityTypeName == "专家线下沙龙" {
  959. activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_2
  960. }
  961. if activityDetail.ActivityTypeName == "公司调研电话会" {
  962. activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_3
  963. }
  964. v := activityDetail
  965. itemActivity := &models.ActivityListResp{
  966. ActivityId: v.ActivityId,
  967. ActivityTypeId: v.ActivityTypeId,
  968. ActivityTypeName: v.ActivityTypeName,
  969. ChartPermissionId: v.ChartPermissionId,
  970. ChartPermissionName: v.ChartPermissionName,
  971. IsLimitPeople: v.IsLimitPeople,
  972. LimitPeopleNum: v.LimitPeopleNum,
  973. LastUpdatedTime: v.LastUpdatedTime,
  974. ActivityTime: v.ActivityTime,
  975. ActivityTimeText: v.ActivityTimeText,
  976. DistinguishedGuest: v.DistinguishedGuest,
  977. Host: v.Host,
  978. Speaker: v.Speaker,
  979. MainlandTell: v.MainlandTell,
  980. HongKongTell: v.HongKongTell,
  981. TaiwanTell: v.TaiwanTell,
  982. AmericaTell: v.AmericaTell,
  983. ParticipationCode: v.ParticipationCode,
  984. Theme: v.Theme,
  985. Expert: v.Expert,
  986. ActivityName: v.ActivityName,
  987. OnlineParticipation: v.OnlineParticipation,
  988. ReportLink: v.ReportLink,
  989. AppAttendance: v.AppAttendance,
  990. ConferencePassword: v.ConferencePassword,
  991. City: v.City,
  992. Address: v.Address,
  993. Highlights: v.Highlights,
  994. Remarks: v.Remarks,
  995. IsSignup: v.IsSignup,
  996. IsCancelMeetingReminder: v.IsCancelMeetingReminder,
  997. IsAppointment: v.IsAppointment,
  998. ActiveState: v.ActiveState,
  999. IsShowSustainable: v.IsShowSustainable,
  1000. Description: v.Description,
  1001. IsResearch: v.IsResearch,
  1002. IsHideAppointment: v.IsHideAppointment,
  1003. IsCClassMeeting: v.IsCClassMeeting,
  1004. Label: v.Label,
  1005. ImgUrl: v.ImgUrl,
  1006. ImgUrlText: v.ImgUrlText,
  1007. ActivityType: v.ActivityType,
  1008. IsShowOutboundCall: v.IsShowOutboundCall,
  1009. IsShowMeetingReminder: v.IsShowMeetingReminder,
  1010. IsShowHelpSsk: v.IsShowHelpSsk,
  1011. IsShowSignup: v.IsShowSignup,
  1012. IsShowAppointment: v.IsShowAppointment,
  1013. IsShowDetails: v.IsShowDetails,
  1014. AudioLink: v.AudioLink,
  1015. VoiceDetail: v.VoiceList,
  1016. VideoDetail: v.VideoDetail,
  1017. FileType: v.FileType,
  1018. SourceType: v.SourceType,
  1019. SignupNum: v.SignupNum,
  1020. YidongActivityUrl: yidongActivityUrl,
  1021. Explain: utils.ACtIVITY_SPECIAL_EXPLAIN,
  1022. TripImgLink: v.TripImgLink,
  1023. Days: v.Days,
  1024. SignupType: v.SignupType,
  1025. IsYidongConduct: v.IsYidongConduct,
  1026. IsCanOutboundCall: v.IsCanOutboundCall,
  1027. TencentConferenceNumber: v.TencentConferenceNumber,
  1028. IsResearchSpecial: v.IsResearchSpecial,
  1029. LinkParticipants: v.LinkParticipants,
  1030. IsResearchPoints: v.IsResearchPoints,
  1031. IsExternalLabel: v.IsExternalLabel,
  1032. SiginupDeadline: v.SiginupDeadline,
  1033. CancelDeadline: v.CancelDeadline,
  1034. IsYidongActivity: v.IsYidongActivity,
  1035. TopTime: v.TopTime,
  1036. LabelKeywordImgLink: v.LabelKeywordImgLink,
  1037. IsShowWxPay: utils.IS_SHOW_WX_PAY,
  1038. }
  1039. au := new(models.UserPermissionAuthInfo)
  1040. au.SellerName = authInfo.SellerName
  1041. au.SellerMobile = authInfo.SellerMobile
  1042. au.HasPermission = authInfo.HasPermission
  1043. au.OperationMode = authInfo.OperationMode
  1044. if au.HasPermission != 1 {
  1045. //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
  1046. if v.YidongActivityId != "" {
  1047. if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
  1048. au.HasPermission = 1
  1049. }
  1050. }
  1051. if (!v.IsResearchPoints && v.IsLimitPeople == 0) || v.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
  1052. if userCardTotal > 0 {
  1053. au.HasPermission = 1
  1054. }
  1055. }
  1056. if virtualAssetActivityIds[v.ActivityId] {
  1057. au.HasPermission = 1
  1058. }
  1059. }
  1060. if au.HasPermission != 1 {
  1061. // 非宏观权限进一步判断是否有权限
  1062. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  1063. au.HasPermission = userPermissionCode
  1064. }
  1065. }
  1066. // 无权限的弹框提示
  1067. if au.HasPermission != 1 {
  1068. au.HasPermission = userPermissionCode
  1069. if au.OperationMode == UserPermissionOperationModeCall {
  1070. if v.FileType == 1 {
  1071. au.PopupMsg = UserPermissionPopupMsgCallMicroVoice
  1072. } else {
  1073. au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
  1074. }
  1075. } else {
  1076. if v.FileType == 1 {
  1077. au.PopupMsg = UserPermissionPopupMsgApplyMicroVoice
  1078. } else {
  1079. au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
  1080. }
  1081. }
  1082. }
  1083. //如果是易董同步过来的,只展示外部资源标签
  1084. if activityDetail.YidongActivityId != "" {
  1085. itemActivity.IsExternalLabel = true
  1086. itemActivity.IsResearch = false
  1087. itemActivity.IsResearchSpecial = false
  1088. }
  1089. itemActivity.AuthInfo = au
  1090. //处理用户已经报名了的行程
  1091. //activityIds = append(activityIds, v.ActivityId)
  1092. itemsActivity = append(itemsActivity, itemActivity)
  1093. }
  1094. ////处理专项调研
  1095. //UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
  1096. //if e != nil {
  1097. // err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
  1098. // return
  1099. //}
  1100. //for _, v := range itemsActivity {
  1101. // if _, ok := UserMap[v.ActivityId]; ok {
  1102. // v.IsTrip = 1
  1103. // }
  1104. // if v.Days == 0 {
  1105. // v.TripStatus = 1
  1106. // } else {
  1107. // v.TripStatus = 2
  1108. // }
  1109. //}
  1110. return
  1111. }
  1112. func ActivityDetaailShow(activityInfo *models.ActivityListResp) (itemActivity *models.ActivityListResp, err error) {
  1113. itemActivity = activityInfo
  1114. if GetShowSustainable() && strings.Contains(itemActivity.ChartPermissionName, "研选") {
  1115. itemActivity.IsShowSustainable = true
  1116. }
  1117. if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
  1118. activityInfo.SignupNum = activityInfo.LimitPeopleNum
  1119. }
  1120. if activityInfo.ReportLink != "" {
  1121. artList, e := GetActivityReportLinkToArticleList(activityInfo)
  1122. if e != nil && e.Error() != utils.ErrNoRow() {
  1123. err = e
  1124. return
  1125. }
  1126. if len(artList) == 0 {
  1127. activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
  1128. } else {
  1129. activityInfo.ArticleList = artList
  1130. }
  1131. } else {
  1132. activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
  1133. }
  1134. activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
  1135. return
  1136. }
  1137. // GetActivityNewLabelMap 获取活动【新】标签Map
  1138. func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryNewMap map[int]bool, err error) {
  1139. labelMap = make(map[int]bool, 0)
  1140. industryNewMap = make(map[int]bool, 0)
  1141. if len(activityIds) == 0 {
  1142. return
  1143. }
  1144. // 获取活动关联的产业
  1145. var groupCond string
  1146. var groupPars []interface{}
  1147. groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) AND b.source = 1 `
  1148. groupPars = append(groupPars, activityIds)
  1149. groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
  1150. if e != nil {
  1151. err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
  1152. return
  1153. }
  1154. activityIndustryMap := make(map[int][]int, 0)
  1155. industryIds := make([]int, 0)
  1156. for i := range groups {
  1157. industryIds = append(industryIds, groups[i].IndustrialManagementId)
  1158. activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId)
  1159. }
  1160. // 获取新产业Map
  1161. industryLabelMap, e := GetIndustryNewLabelMap(industryIds)
  1162. if e != nil {
  1163. err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
  1164. return
  1165. }
  1166. // 判断活动是否为新
  1167. for k := range industryLabelMap {
  1168. for k2, v2 := range activityIndustryMap {
  1169. if labelMap[k2] {
  1170. continue
  1171. }
  1172. // 活动的产业ID中存在一个新产业即为新活动
  1173. if utils.InArrayByInt(v2, k) {
  1174. labelMap[k2] = true
  1175. }
  1176. }
  1177. }
  1178. //
  1179. //////产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签
  1180. //articNewLabel, e := GetArticNewLabelWhithActivity3Month()
  1181. //if e != nil {
  1182. // err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
  1183. // return
  1184. //}
  1185. //for k := range articNewLabel {
  1186. // labelMap[k] = true
  1187. //}
  1188. return
  1189. }
  1190. // GetIndustryNewLabelMap 获取产业【新】标签Map
  1191. func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error) {
  1192. labelMap = make(map[int]bool, 0)
  1193. industryIdLen := len(industryIds)
  1194. if industryIdLen == 0 {
  1195. return
  1196. }
  1197. // 获取产业关联的报告最早发布时间及最近的发布时间
  1198. var timeCond string
  1199. var timePars []interface{}
  1200. timeCond += ` AND b.publish_status = 1`
  1201. if industryIdLen > 0 {
  1202. timeCond += ` AND a.industrial_management_id IN (` + utils.GetOrmInReplace(industryIdLen) + `)`
  1203. timePars = append(timePars, industryIds)
  1204. }
  1205. //只要弘则报告,不要研选报告
  1206. timeCond += ` AND b.article_id < ? `
  1207. timePars = append(timePars, utils.SummaryArticleId)
  1208. industryTimeList, e := models.GetIndustryArticleMinMaxPublishTime(timeCond, timePars)
  1209. if e != nil {
  1210. err = errors.New("获取产业文章最大最小发布时间失败, Err: " + e.Error())
  1211. return
  1212. }
  1213. // 判断产业是否为新
  1214. nowTime := time.Now().Local()
  1215. threeMonthBefore := nowTime.AddDate(0, -3, 0)
  1216. nullTime, _ := time.ParseInLocation(utils.FormatDateTime, "0001-01-01 00:00:00", time.Local)
  1217. industryMap := make(map[int]*models.IndustryArticleMinMaxPublishTime, 0)
  1218. for i := range industryTimeList {
  1219. industryMap[industryTimeList[i].IndustrialManagementId] = industryTimeList[i]
  1220. }
  1221. for i := range industryIds {
  1222. iid := industryIds[i]
  1223. item := industryMap[iid]
  1224. if item != nil {
  1225. // 最早发布时间为空 / 最早发布时间在三个月前之后
  1226. if item.MinPublishTime.Equal(nullTime) || (item.MinPublishTime.After(threeMonthBefore)) {
  1227. labelMap[iid] = true
  1228. }
  1229. } else {
  1230. // 产业无报告, 则为新产业
  1231. labelMap[iid] = true
  1232. }
  1233. }
  1234. return
  1235. }
  1236. // GetSpecialDetailUserPower 处理用户查看详情的权限
  1237. func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.ActivityDetail) (havePower, isResearchSpecial bool, err error) {
  1238. var companyDetailStatus string
  1239. var userTypeStr string
  1240. userId := user.UserId
  1241. activityId := activityInfo.ActivityId
  1242. activityPointsByUserAllMap := GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动
  1243. //勾选【研选扣点】且扣点对象为参会人的活动,需要有买方研选的正式权限
  1244. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && activityPointsByUserAllMap[activityInfo.ActivityId] {
  1245. isResearchSpecial = true
  1246. }
  1247. //如果是弘则的用户或者宏观的权限不做校验
  1248. //if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME {
  1249. if GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID {
  1250. havePower = true
  1251. return
  1252. }
  1253. if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
  1254. //用户是否持有有效卡片
  1255. userCardTotal := GetCygxOrderUserCardTotal(user.Mobile)
  1256. if userCardTotal > 0 {
  1257. havePower = true
  1258. return
  1259. }
  1260. } else {
  1261. activtyPayTotal := GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId)
  1262. if activtyPayTotal > 0 {
  1263. havePower = true
  1264. return
  1265. }
  1266. }
  1267. userType, permissionStr, permissionStrZhengShi, e := GetUserTypeZhengShi(user.CompanyId)
  1268. if e != nil {
  1269. err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
  1270. return
  1271. }
  1272. //判断用户是否开通了个人研选权限,如果有权限后缀拼接权限名称
  1273. mfyxUserPermissionTotal := GetMfyxUserPermissionTotal(userId)
  1274. if mfyxUserPermissionTotal == 1 {
  1275. permissionStr += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN
  1276. //开通研选个人权限的可以查看非扣点的研选活动
  1277. if !isResearchSpecial {
  1278. havePower = true
  1279. return
  1280. }
  1281. }
  1282. //如果正式权限有开通 研选扣点包 ,那么就拼接一个 研选订阅的权限
  1283. if strings.Contains(permissionStrZhengShi, utils.YAN_XUAN_KOU_DIAN_BAO_NAME) {
  1284. permissionStr += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN
  1285. permissionStrZhengShi += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN
  1286. }
  1287. //如果测试权限有开通 研选扣点包 ,那么就拼接一个 研选订阅的权限
  1288. if strings.Contains(permissionStr, utils.YAN_XUAN_KOU_DIAN_BAO_NAME) {
  1289. permissionStr += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN
  1290. }
  1291. //如果一个权限都没有就返回无权限
  1292. if permissionStr == "" {
  1293. return
  1294. }
  1295. //永续客户,无法查看研选权限,但是下面的联系人,单独开通研选后,也可以查看研选内容
  1296. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && mfyxUserPermissionTotal == 0 {
  1297. havePower = false
  1298. return
  1299. }
  1300. permissionStr += "," + utils.HONG_GUAN_NAME // 添加一个宏观权限
  1301. if permissionStrZhengShi == "" {
  1302. permissionStrZhengShi = utils.HONG_GUAN_NAME // 添加一个宏观权限
  1303. } else {
  1304. permissionStrZhengShi += "," + utils.HONG_GUAN_NAME // 添加一个宏观权限
  1305. }
  1306. //如果是易董的活动,主、副权限有一个满足即可
  1307. if activityInfo.YidongActivityId != "" {
  1308. if strings.Contains(permissionStr, activityInfo.ChartPermissionName) || strings.Contains(permissionStr, activityInfo.ChartPermissionNameDeputy) {
  1309. havePower = true
  1310. return
  1311. }
  1312. }
  1313. //如果权限不包含那么直接返回
  1314. if !strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
  1315. return
  1316. }
  1317. //如果是 对用户的研选扣点的必须要有研选的正式权限
  1318. if activityInfo.IsResearchPoints {
  1319. //获取活动对用户要扣的点
  1320. userPointsNum, e := models.GetCygxActivityPointsSetUserNum(activityInfo.ActivityId)
  1321. if e != nil {
  1322. err = errors.New("GetActivitySignupSuccessByUserCountNoHz, Err: " + e.Error())
  1323. return
  1324. }
  1325. if userPointsNum > 0 {
  1326. //if !strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1327. // //如果连试用权限都没有,那么久按照普通的研选样式展示
  1328. // isResearchSpecial = false
  1329. //}
  1330. if !strings.Contains(permissionStrZhengShi, activityInfo.ChartPermissionName) {
  1331. havePower = false
  1332. return
  1333. }
  1334. }
  1335. }
  1336. //处理决策人可见权限
  1337. if user.IsMaker == 0 && activityInfo.IsMakerShow == 1 {
  1338. havePower = false
  1339. return
  1340. }
  1341. // 处理本组可见权限
  1342. if activityInfo.VisibleRange == 1 {
  1343. adminIds, e := models.GetSelleridWhichGroup(user.CompanyId, 2)
  1344. if e != nil {
  1345. err = errors.New("GetSelleridWhichGroup, Err: " + e.Error())
  1346. return
  1347. }
  1348. haveVisibleRange := false
  1349. adminIdSlice := strings.Split(adminIds, ",")
  1350. for _, v := range adminIdSlice {
  1351. if v == strconv.Itoa(activityInfo.AdminId) {
  1352. haveVisibleRange = true
  1353. }
  1354. }
  1355. if activityInfo.AdminId > 0 {
  1356. adminGroup := GetAdminActivityPermission(activityInfo.AdminId)
  1357. for _, v := range adminGroup {
  1358. if v == activityInfo.AdminId {
  1359. haveVisibleRange = true
  1360. }
  1361. }
  1362. }
  1363. if !haveVisibleRange {
  1364. havePower = false
  1365. return
  1366. }
  1367. }
  1368. if permissionStr == "" {
  1369. return
  1370. }
  1371. //如果是易董的活动且属于研选类型,只要开通任何权限就可以查看详情
  1372. if activityInfo.YidongActivityId != "" && permissionStr != "" && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1373. havePower = true
  1374. return
  1375. }
  1376. //医药消费,科技,智造四大行业,验证主客观。如果主客观校验不通过,那么直接返回
  1377. if strings.Contains(utils.YI_YAO_NAME+utils.XIAO_FEI_NAME+utils.KE_JI_NAME+utils.ZHI_ZAO_NAME, activityInfo.ChartPermissionName) {
  1378. if activityInfo.ActivityTypeId == 2 || activityInfo.ActivityTypeId == 6 || activityInfo.ActivityTypeId == 7 {
  1379. if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(主观)") {
  1380. havePower = true
  1381. } else {
  1382. havePower = false
  1383. }
  1384. } else {
  1385. if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(客观)") {
  1386. havePower = true
  1387. } else {
  1388. havePower = false
  1389. }
  1390. }
  1391. //如果主客观校验不通过,那么直接返回
  1392. if !havePower {
  1393. return
  1394. }
  1395. }
  1396. if activityInfo.LimitPeopleNum > 0 {
  1397. mapUserType, e := GetActivityCcustomerTypeList()
  1398. if e != nil {
  1399. err = e
  1400. return
  1401. }
  1402. userTypeStr = mapUserType[userType]
  1403. // 永续客户、大套餐客户、30W套餐客户可以查看行业升级套餐客户 权限
  1404. if userTypeStr == "1" || userTypeStr == "2" || userTypeStr == "AA" {
  1405. if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
  1406. havePower = true
  1407. //return
  1408. }
  1409. }
  1410. } else {
  1411. if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
  1412. havePower = true
  1413. return
  1414. }
  1415. }
  1416. //判断管理规模是否满足
  1417. companyProduct, e := models.GetCompanyProductDetail(user.CompanyId, 2)
  1418. if e != nil && e.Error() != utils.ErrNoRow() {
  1419. err = e
  1420. return
  1421. }
  1422. if companyProduct == nil {
  1423. err = nil
  1424. return
  1425. }
  1426. if companyProduct != nil && activityInfo.Scale != "" {
  1427. if strings.Contains(activityInfo.Scale, companyProduct.Scale) {
  1428. havePower = true
  1429. }
  1430. }
  1431. if user.CompanyId <= 1 {
  1432. return
  1433. } else {
  1434. if permissionStr == "" {
  1435. return
  1436. } else {
  1437. companyDetail, e := models.GetCompanyDetailById(user.CompanyId)
  1438. if e != nil {
  1439. err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
  1440. return
  1441. }
  1442. if companyDetail == nil {
  1443. err = errors.New("客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId))
  1444. return
  1445. }
  1446. companyDetailStatus = companyDetail.Status
  1447. }
  1448. }
  1449. //宏观满足用户可见身份验证权限既满足 2023-9-18
  1450. if activityInfo.ChartPermissionId == 1 {
  1451. if activityInfo.LimitPeopleNum > 0 {
  1452. if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) {
  1453. havePower = true
  1454. return
  1455. }
  1456. } else {
  1457. havePower = true
  1458. return
  1459. }
  1460. }
  1461. if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum == 0 {
  1462. havePower = true
  1463. } else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" && strings.Contains(activityInfo.CustomerTypeIds, "4") {
  1464. havePower = true
  1465. } else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") {
  1466. havePower = true
  1467. } else if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 4 || activityInfo.ActivityTypeId == 5) && strings.Contains(permissionStr, "专家") {
  1468. havePower = true
  1469. }
  1470. //fmt.Println(permissionStrZhengShi)
  1471. //if (strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略") && strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
  1472. // havePower = true
  1473. // return
  1474. //}
  1475. if strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略" {
  1476. if strings.Contains(activityInfo.CustomerTypeIds, "5") {
  1477. if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
  1478. havePower = true
  1479. return
  1480. }
  1481. } else {
  1482. if strings.Contains(permissionStrZhengShi, activityInfo.ChartPermissionName) {
  1483. havePower = true
  1484. return
  1485. }
  1486. }
  1487. }
  1488. permissionShengji, errs := models.GetCompanyPermissionByUserTrip(user.CompanyId)
  1489. if errs != nil {
  1490. err = errs
  1491. return
  1492. }
  1493. //fmt.Println("主客观2", havePower)
  1494. //if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) {
  1495. // havePower = true
  1496. //}
  1497. //fmt.Println("主客观3", havePower)
  1498. //处理升级权限以及用户身份的 双重判断
  1499. if activityInfo.CustomerTypeIds != "" {
  1500. if !strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) && userTypeStr != "8" {
  1501. havePower = false
  1502. if strings.Contains(permissionShengji, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
  1503. havePower = true
  1504. }
  1505. }
  1506. }
  1507. if havePower && activityInfo.LimitPeopleNum > 0 {
  1508. //对于一些特殊的活动,即使权限满足也不给产看
  1509. noPower, e := GetShareNoPowe(activityInfo, permissionStr, userType, user)
  1510. if e != nil {
  1511. err = errors.New("GetShareNoPowe, Err: " + e.Error())
  1512. return
  1513. }
  1514. if noPower {
  1515. havePower = false
  1516. }
  1517. }
  1518. return
  1519. }
  1520. // 校验被分享的用户是否有查看详情的权限
  1521. func GetShareNoPowe(activityInfo *models.ActivityDetail, permissionStr string, userType int, user *models.WxUserItem) (noPower bool, err error) {
  1522. //如果是弘则的就不进行可见权限校验
  1523. if user.CompanyId == utils.HZ_COMPANY_ID {
  1524. return
  1525. }
  1526. //var noPower bool
  1527. //if !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
  1528. // noPower = true
  1529. //}
  1530. //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
  1531. //if userType == 2 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
  1532. // noPower = true
  1533. //}
  1534. //if userType == 2 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
  1535. // noPower = true
  1536. //}
  1537. //if userType == 3 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
  1538. // noPower = true
  1539. //}
  1540. //if userType == 3 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
  1541. // noPower = true
  1542. //}
  1543. if userType == 8 {
  1544. permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
  1545. if errs != nil {
  1546. err = errs
  1547. return
  1548. }
  1549. if !strings.Contains(permissionShengji, activityInfo.ChartPermissionName) {
  1550. noPower = true
  1551. return
  1552. }
  1553. }
  1554. if !noPower {
  1555. noPower, err = CheckUserPowerByActivityChoose(user, activityInfo)
  1556. }
  1557. return
  1558. }
  1559. // 处理活动本组们是否决策人权限
  1560. func CheckUserPowerByActivityChoose(user *models.WxUserItem, activityInfo *models.ActivityDetail) (noPower bool, err error) {
  1561. //处理 见范围 1,仅本组可见 、2,全部客户可见
  1562. if activityInfo.VisibleRange == 1 {
  1563. adminIds, errAdmin := models.GetSelleridWhichGroup(user.CompanyId, 2)
  1564. if errAdmin != nil {
  1565. err = errAdmin
  1566. return
  1567. }
  1568. sliceAdminIds := strings.Split(adminIds, ",")
  1569. var haveAdminId bool
  1570. for _, v := range sliceAdminIds {
  1571. if v == strconv.Itoa(activityInfo.AdminId) {
  1572. haveAdminId = true
  1573. }
  1574. }
  1575. if !haveAdminId {
  1576. noPower = true
  1577. }
  1578. }
  1579. //处理 是否仅决策人可见 0,否 、1,是
  1580. if activityInfo.IsMakerShow == 1 {
  1581. if user.IsMaker == 0 {
  1582. noPower = true
  1583. }
  1584. }
  1585. return
  1586. }
  1587. // 判断预约纪要按钮是否显示
  1588. func IsShowAppointment(activityTypeId int, chartPermissionName string) (isShowAppointment bool) {
  1589. if activityTypeId == 1 || activityTypeId == 2 || activityTypeId == 3 || activityTypeId == 4 {
  1590. isShowAppointment = true
  1591. }
  1592. if activityTypeId == 5 && chartPermissionName == "医药" {
  1593. isShowAppointment = true
  1594. }
  1595. return
  1596. }
  1597. // GetindustryVideoDetailById 通过视频ID获取视频详情
  1598. func GetActivityVideoDetailById(user *models.WxUserItem, videoId int) (industryVideo *models.CygxActivityVideoDetailResp, AuthInfo *models.UserPermissionAuthInfo, err error) {
  1599. total, e := models.GetActivityVideoByVideoIdCount(videoId)
  1600. if e != nil {
  1601. err = errors.New("获取活动的视频失败,GetActivityVideoByVideoIdCount " + e.Error())
  1602. return
  1603. }
  1604. if total == 0 {
  1605. err = errors.New("视频不存在,或已取消发布")
  1606. return
  1607. }
  1608. // 用户权限
  1609. authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  1610. if e != nil {
  1611. err = errors.New("获取用户权限失败,GetUserRaiPermissionInfo " + e.Error())
  1612. return
  1613. }
  1614. videoSimple := new(models.CygxActivityVideoDetailResp)
  1615. // 权限
  1616. var au *models.UserPermissionAuthInfo
  1617. videoSimple, e = models.GetCygxActivityVideoById(videoId)
  1618. if e != nil {
  1619. err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
  1620. return
  1621. } else {
  1622. //videoSimple.Id = video.Id
  1623. //videoSimple.Title = video.Title
  1624. //videoSimple.ResourceUrl = video.ResourceUrl
  1625. //videoSimple.PlaySeconds = video.PlaySeconds
  1626. //videoSimple.ActivityId = video.ActivityId
  1627. //videoSimple.ChartPermissionId = video.ChartPermissionId
  1628. if videoSimple.BackgroundImg == "" {
  1629. // 获取默认图配置
  1630. _, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig()
  1631. if e != nil {
  1632. err = errors.New("获取视频默认配置图失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
  1633. return
  1634. }
  1635. videoSimple.BackgroundImg = videoMap[videoSimple.ChartPermissionId]
  1636. }
  1637. au = new(models.UserPermissionAuthInfo)
  1638. au.SellerName = authInfo.SellerName
  1639. au.SellerMobile = authInfo.SellerMobile
  1640. au.HasPermission = authInfo.HasPermission
  1641. au.OperationMode = authInfo.OperationMode
  1642. if au.HasPermission == 1 {
  1643. // 非宏观权限进一步判断是否有权限
  1644. if videoSimple.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, videoSimple.ChartPermissionName) {
  1645. au.HasPermission = 2
  1646. }
  1647. }
  1648. // 无权限的弹框提示
  1649. if au.HasPermission != 1 {
  1650. if au.OperationMode == UserPermissionOperationModeCall {
  1651. au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
  1652. } else {
  1653. au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
  1654. }
  1655. videoSimple.ResourceUrl = ""
  1656. }
  1657. }
  1658. videoSimple.Type = 2
  1659. industryVideo = videoSimple
  1660. AuthInfo = au
  1661. return
  1662. }
  1663. // 用户活动操作行为,模板消息推送
  1664. func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.ActivityDetail, source int) (err error) {
  1665. defer func() {
  1666. if err != nil {
  1667. go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "ActivityUserRemind ErrMsg:"+err.Error(), utils.EmailSendToUsers)
  1668. }
  1669. }()
  1670. //获取销售手机号
  1671. countUser, e := models.GetUserRemind(user.UserId)
  1672. if e != nil {
  1673. err = errors.New("GetUserRemind, Err: " + e.Error())
  1674. return
  1675. }
  1676. //获取销售手机号
  1677. sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1678. if e != nil && e.Error() != utils.ErrNoRow() {
  1679. err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
  1680. return
  1681. }
  1682. if sellerItemQy == nil {
  1683. err = nil
  1684. return
  1685. }
  1686. //某销售下的所有客户活动报名/预约外呼时,模板消息提醒该销售(可设置销售范围,随时增减销售)
  1687. conf, e := models.GetConfigByCode("tpl_msg_seller_mobile")
  1688. if e != nil {
  1689. err = errors.New("GetConfigByCode, Err: " + e.Error())
  1690. return
  1691. }
  1692. //如果用户没有设置消息提醒,而且销售的手机号也没有添加到配置中,那么就不推送模版消息
  1693. if countUser == 0 && !strings.Contains(conf.ConfigValue, sellerItemQy.Mobile) {
  1694. err = nil
  1695. return
  1696. }
  1697. var sourceMsg string
  1698. redirectUrl := ""
  1699. if source == 1 {
  1700. sourceMsg = "预约外呼"
  1701. } else if source == 2 {
  1702. sourceMsg = "设置会议提醒"
  1703. } else if source == 3 {
  1704. sourceMsg = "预约纪要"
  1705. } else if source == 4 {
  1706. sourceMsg = "活动报名"
  1707. }
  1708. sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
  1709. if e != nil {
  1710. err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
  1711. return
  1712. }
  1713. sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
  1714. var keyword1 string
  1715. var keyword2 string
  1716. keyword1 = activityDetail.ActivityName
  1717. keyword2 = fmt.Sprint("互动:", sourceMsg, ",", user.RealName, "--", user.CompanyName)
  1718. //SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
  1719. openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
  1720. if e != nil {
  1721. err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
  1722. return err
  1723. }
  1724. //查研观向小助手推送
  1725. SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
  1726. // 类目模版买方研选
  1727. openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
  1728. if e != nil {
  1729. err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
  1730. return err
  1731. }
  1732. keyword1 = utils.TruncateActivityNameString(user.RealName + "-" + user.CompanyName)
  1733. keyword2 = fmt.Sprint("互动提醒:", sourceMsg)
  1734. keyword3 := utils.TruncateActivityNameString(activityDetail.ActivityName)
  1735. keyword4 := time.Now().Format(utils.FormatDateTimeMinute2)
  1736. redirectUrl = utils.WX_MSG_PATH_YX_ACTIVITY_DETAIL + strconv.Itoa(activityDetail.ActivityId)
  1737. SendWxCategoryMsgWithActivityUserRemind(keyword1, keyword2, keyword3, keyword4, redirectUrl, openIdListMfyx, activityDetail.ActivityId)
  1738. return
  1739. }
  1740. // 用户音视频回放操作操作行为,模板消息推送
  1741. func ActivityVideoUserRmind(user *models.WxUserItem, activityId, fileType int) (err error) {
  1742. defer func() {
  1743. if err != nil {
  1744. go utils.SendAlarmMsg("用户音视频回放操作操作行为,模板消息推送失败"+err.Error(), 2)
  1745. }
  1746. }()
  1747. countUser, err := models.GetUserRemind(user.UserId)
  1748. if err != nil {
  1749. return err
  1750. }
  1751. if countUser == 0 {
  1752. return err
  1753. }
  1754. var first string
  1755. var keyword1 string
  1756. var keyword2 string
  1757. var keyword3 string
  1758. var keyword4 string
  1759. var remark string
  1760. //获取销售手机号
  1761. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1762. if err != nil && err.Error() != utils.ErrNoRow() {
  1763. return err
  1764. }
  1765. if sellerItemQy != nil {
  1766. sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
  1767. if e != nil {
  1768. err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
  1769. return
  1770. }
  1771. sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
  1772. openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
  1773. if e != nil {
  1774. err = errors.New("GetSellerByAdminId, Err: " + e.Error())
  1775. return
  1776. }
  1777. //TripStatus int `description:"行程进行状态 1:预报名,2:确定行程"`
  1778. if fileType == 1 {
  1779. activityInfo, e := models.GetCygxActivityVideoByActivityId(activityId)
  1780. if e != nil {
  1781. err = errors.New("GetCygxActivitySpecialDetailById, Err: " + e.Error())
  1782. return
  1783. }
  1784. if activityInfo == nil {
  1785. return
  1786. }
  1787. keyword1 = activityInfo.VideoName
  1788. keyword2 = fmt.Sprint("互动:播放视频,", user.RealName, "--", user.CompanyName)
  1789. first = fmt.Sprint(user.RealName, "--", user.CompanyName, ",有新的互动:播放视频")
  1790. } else {
  1791. activityInfo, e := models.GetCygxActivityVoiceByActivityId(activityId)
  1792. if e != nil {
  1793. err = errors.New("GetCygxActivitySpecialDetailById, Err: " + e.Error())
  1794. return
  1795. }
  1796. if activityInfo == nil {
  1797. return
  1798. }
  1799. keyword1 = activityInfo.VoiceName
  1800. keyword2 = fmt.Sprint("互动:播放音频,", user.RealName, "--", user.CompanyName)
  1801. first = fmt.Sprint(user.RealName, "--", user.CompanyName, ",有新的互动:播放音频")
  1802. }
  1803. //keyword2 = "__"
  1804. //remark = "点击查看活动详情"
  1805. openIdArr := make([]string, 0)
  1806. for _, v := range openIdList {
  1807. openIdArr = append(openIdArr, v.OpenId)
  1808. }
  1809. redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(activityId)
  1810. sendInfo := new(SendWxTemplate)
  1811. sendInfo.First = first
  1812. sendInfo.Keyword1 = keyword1
  1813. sendInfo.Keyword2 = keyword2
  1814. sendInfo.Keyword3 = keyword3
  1815. sendInfo.Keyword4 = keyword4
  1816. sendInfo.Remark = remark
  1817. sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
  1818. sendInfo.RedirectUrl = redirectUrl
  1819. sendInfo.RedirectTarget = 3
  1820. sendInfo.Resource = strconv.Itoa(activityId)
  1821. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
  1822. sendInfo.OpenIdArr = openIdArr
  1823. err = PublicSendTemplateMsg(sendInfo)
  1824. if err != nil {
  1825. return
  1826. }
  1827. }
  1828. return
  1829. }
  1830. // GetYanxuanActivityIds 获取研选活动ID
  1831. func GetYanxuanActivityIds(user *models.WxUserItem, activeState string) (activityIds []int) {
  1832. var err error
  1833. defer func() {
  1834. if err != nil {
  1835. fmt.Println(err)
  1836. go utils.SendAlarmMsg("获取研选活动ID GetYanxuanActivityIds,失败:"+err.Error(), 2)
  1837. }
  1838. }()
  1839. var condition string
  1840. var pars []interface{}
  1841. condition = ` AND chart_permission_id = 31 AND art.publish_status = 1 `
  1842. if activeState != "" {
  1843. condition += ` AND active_state IN (` + activeState + `) `
  1844. }
  1845. //pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN)
  1846. if user.CompanyId > 1 {
  1847. conditionActivity, e := ActivityConditioninitSql(user, condition, 0)
  1848. if e != nil && e.Error() != utils.ErrNoRow() {
  1849. err = errors.New("ActivityConditioninitSql, Err: " + e.Error())
  1850. return
  1851. }
  1852. condition += conditionActivity
  1853. }
  1854. condition += ` ORDER BY art.activity_time DESC , art.active_state ASC `
  1855. list, e := models.GetCygxActivityListPage(condition, pars, 0, 2000)
  1856. if e != nil {
  1857. err = errors.New("GetCygxActivityIdList, Err: " + e.Error())
  1858. return
  1859. }
  1860. for _, v := range list {
  1861. activityIds = append(activityIds, v.ActivityId)
  1862. }
  1863. return
  1864. }
  1865. // 获取活动分享封面图片
  1866. func GetActivityShareImg(activityDetail *models.ActivityDetail) (shareImg string) {
  1867. var err error
  1868. defer func() {
  1869. if err != nil {
  1870. go utils.SendAlarmMsg(fmt.Sprint("获取活动分享封面图片失败Err:", err.Error(), "活动ID:", activityDetail.ActivityId), 2)
  1871. }
  1872. }()
  1873. activityTypeId := activityDetail.ActivityTypeId
  1874. chartPermissionId := activityDetail.ChartPermissionId
  1875. city := activityDetail.City
  1876. //分析师C类电话会,等于分析师电话会
  1877. if activityTypeId == 7 {
  1878. activityTypeId = 2
  1879. }
  1880. defaultCity := []string{"北京", "广州", "杭州", "南京", "上海", "深圳", "苏州"} //几个默认城市
  1881. if city != "" {
  1882. if !utils.InArrayByStr(defaultCity, city) {
  1883. city = "其他"
  1884. }
  1885. }
  1886. imgDetail, e := models.CygxActivityShareImgDetail(activityTypeId, chartPermissionId, city)
  1887. if e != nil {
  1888. err = errors.New("CygxActivityShareImgDetail, Err: " + e.Error())
  1889. return
  1890. }
  1891. shareImg = imgDetail.Img
  1892. return
  1893. }