activity.go 122 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/utils"
  8. "sort"
  9. "strconv"
  10. "strings"
  11. "time"
  12. "github.com/medivhzhan/weapp/v2"
  13. "github.com/rdlucklib/rdluck_tools/paging"
  14. )
  15. // 活动
  16. type ActivityCoAntroller struct {
  17. BaseAuthController
  18. }
  19. type ActivityABaseController struct {
  20. BaseCommonController
  21. }
  22. // @Title 活动类型列表
  23. // @Description活动类型列表接口
  24. // @Success 200 {object} models.ActivityTypeListResp
  25. // @router /activityTypelist [get]
  26. func (this *ActivityCoAntroller) List() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请登录"
  35. br.ErrMsg = "请登录,SysUser Is Empty"
  36. br.Ret = 408
  37. return
  38. }
  39. resp := new(models.ActivityTypeListResp)
  40. list, err := models.GetActivityTypeList()
  41. if err != nil {
  42. br.Msg = "获取失败"
  43. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  44. return
  45. }
  46. resp.List = list
  47. br.Ret = 200
  48. br.Success = true
  49. br.Msg = "获取成功"
  50. br.Data = resp
  51. }
  52. // @Title 我的日程
  53. // @Description 我的日程列表接口
  54. // @Param PageSize query int true "每页数据条数"
  55. // @Param CurrentIndex query int true "当前页页码,从1开始"
  56. // @Param Source query int false "来源 0:手机 ,1:Pc 默认0"
  57. // @Success 200 {object} models.GetCygxActivityListRep
  58. // @router /scheduleList [get]
  59. func (this *ActivityCoAntroller) ScheduleList() {
  60. br := new(models.BaseResponse).Init()
  61. defer func() {
  62. this.Data["json"] = br
  63. this.ServeJSON()
  64. }()
  65. user := this.User
  66. if user == nil {
  67. br.Msg = "请登录"
  68. br.ErrMsg = "请登录,SysUser Is Empty"
  69. return
  70. }
  71. uid := user.UserId
  72. pageSize, _ := this.GetInt("PageSize")
  73. currentIndex, _ := this.GetInt("CurrentIndex")
  74. source, _ := this.GetInt("Source")
  75. var startSize int
  76. if pageSize <= 0 {
  77. pageSize = utils.PageSize20
  78. }
  79. if currentIndex <= 0 {
  80. currentIndex = 1
  81. }
  82. startSize = utils.StartIndex(currentIndex, pageSize)
  83. var condition string
  84. var conditionCount string
  85. var pars []interface{}
  86. condition += ` AND art.publish_status = 1 `
  87. if source == 1 {
  88. condition += ` AND art.yidong_activity_id = '' `
  89. conditionCount += ` AND art.yidong_activity_id = '' `
  90. }
  91. total, err := models.GetScheduleCount(conditionCount, uid)
  92. specialtotal, err := models.GetSpecialScheduleCount(uid)
  93. page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
  94. if err != nil {
  95. br.Msg = "获取失败"
  96. br.ErrMsg = "获取失败,Err:" + err.Error()
  97. return
  98. }
  99. conditionCount = ` AND art.active_state = 2 `
  100. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  101. if err != nil {
  102. br.Msg = "获取失败"
  103. br.ErrMsg = "获取失败,Err:" + err.Error()
  104. return
  105. }
  106. var list []*models.ActivityDetail
  107. //全部都是进行中的活动
  108. if totalCount > currentIndex*pageSize {
  109. condition += ` AND art.active_state IN(2) `
  110. if source == 1 {
  111. condition += ` AND art.yidong_activity_id = '' `
  112. }
  113. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  114. list = listHave
  115. if errList != nil {
  116. br.Msg = "获取失败"
  117. br.ErrMsg = "获取失败,Err:" + errList.Error()
  118. return
  119. }
  120. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  121. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  122. if source == 1 {
  123. condition += ` AND art.yidong_activity_id = '' `
  124. }
  125. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  126. list = listHave
  127. if errList != nil {
  128. br.Msg = "获取失败"
  129. br.ErrMsg = "获取失败,Err:" + errList.Error()
  130. return
  131. }
  132. pageSize = pageSize - len(listHave)
  133. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
  134. if source == 1 {
  135. condition += ` AND art.yidong_activity_id = '' `
  136. }
  137. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  138. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  139. if errList != nil {
  140. br.Msg = "获取失败"
  141. br.ErrMsg = "获取失败,Err:" + errList.Error()
  142. return
  143. }
  144. if len(listOther) > 0 {
  145. for _, v := range listOther {
  146. list = append(list, v)
  147. }
  148. }
  149. } else {
  150. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  151. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  152. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  153. list = listOther
  154. if errList != nil {
  155. br.Msg = "获取失败"
  156. br.ErrMsg = "获取失败,Err:" + errList.Error()
  157. return
  158. }
  159. }
  160. var isShow bool
  161. isShow = services.GetShowSustainable()
  162. detail, err := models.GetConfigByCode("city_img_url")
  163. if err != nil {
  164. br.Msg = "获取数据失败"
  165. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  166. return
  167. }
  168. detailChart, err := models.GetConfigByCode("chart_img_url")
  169. if err != nil {
  170. br.Msg = "获取数据失败"
  171. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  172. return
  173. }
  174. addressList := strings.Split(detail.ConfigValue, "{|}")
  175. mapAddress := make(map[string]string)
  176. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  177. mapChart := make(map[string]string)
  178. var cityName string
  179. var chartName string
  180. var imgUrl string
  181. var imgUrlChart string
  182. var mapActivityId []int
  183. for _, v := range addressList {
  184. vslice := strings.Split(v, "_")
  185. cityName = vslice[0]
  186. imgUrl = vslice[len(vslice)-1]
  187. mapAddress[cityName] = imgUrl
  188. }
  189. for _, v := range chartList {
  190. vslice := strings.Split(v, "_")
  191. chartName = vslice[0]
  192. imgUrlChart = vslice[len(vslice)-1]
  193. mapChart[chartName] = imgUrlChart
  194. }
  195. for k, v := range list {
  196. if strings.Contains(v.ActivityName, "【") {
  197. list[k].IsBrackets = 1
  198. }
  199. if v.SignupNum > v.LimitPeopleNum {
  200. list[k].SignupNum = v.LimitPeopleNum
  201. }
  202. //是否展示限免标签
  203. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  204. list[k].IsShowSustainable = true
  205. }
  206. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  207. list[k].ActivityTypeName = "买方研选电话会"
  208. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  209. }
  210. if v.ActivityType == 0 {
  211. if mapAddress[v.City] != "" {
  212. list[k].ImgUrl = mapAddress[v.City]
  213. } else {
  214. list[k].ImgUrl = mapAddress["其它"]
  215. }
  216. } else {
  217. if mapChart[v.ChartPermissionName] != "" {
  218. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  219. }
  220. }
  221. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  222. list[k].Expert = expertTxt
  223. if v.IsHideAppointment == 0 {
  224. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  225. }
  226. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  227. list[k].IsCClassMeeting = true
  228. }
  229. mapActivityId = append(mapActivityId, v.ActivityId)
  230. }
  231. //添加我的日程访问记录
  232. item := new(models.CygxPageHistoryRecord)
  233. item.UserId = user.UserId
  234. item.CreateTime = time.Now()
  235. item.Mobile = user.Mobile
  236. item.Email = user.Email
  237. item.CompanyId = user.CompanyId
  238. item.CompanyName = user.CompanyName
  239. item.PageType = "MySchedule"
  240. go models.AddCygxPageHistoryRecord(item)
  241. resp := new(models.GetCygxActivityListRep)
  242. //处理音频回放
  243. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  244. if err != nil {
  245. br.Msg = "获取信息失败"
  246. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  247. return
  248. }
  249. //处理视频回放
  250. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  251. if err != nil {
  252. br.Msg = "获取信息失败"
  253. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  254. return
  255. }
  256. //处理不同的报名方式按钮回显
  257. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  258. if err != nil {
  259. br.Msg = "获取信息失败"
  260. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  261. return
  262. }
  263. for k, v := range list {
  264. if mapActivityVoice[v.ActivityId] != nil {
  265. list[k].FileType = 1
  266. list[k].AudioLink = true
  267. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  268. }
  269. if mapActivityVideo[v.ActivityId] != nil {
  270. list[k].FileType = 2
  271. list[k].AudioLink = true
  272. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  273. }
  274. v.SignupType = mapActivitySignup[v.ActivityId]
  275. //处理列表的标签是否展示逻辑
  276. resp.List = append(resp.List, services.ActivityButtonShow(v))
  277. }
  278. resp.Paging = page
  279. br.Ret = 200
  280. br.Success = true
  281. br.Msg = "获取成功"
  282. br.Data = resp
  283. }
  284. // @Title 活动详情
  285. // @Description 获取活动详情接口
  286. // @Param ActivityId query int true "活动ID"
  287. // @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
  288. // @Success Ret=200 {object} models.CygxActivityResp
  289. // @router /detail [get]
  290. func (this *ActivityCoAntroller) Detail() {
  291. br := new(models.BaseResponse).Init()
  292. defer func() {
  293. this.Data["json"] = br
  294. this.ServeJSON()
  295. }()
  296. user := this.User
  297. if user == nil {
  298. br.Msg = "请登录"
  299. br.ErrMsg = "请登录,用户信息为空"
  300. br.Ret = 408
  301. return
  302. }
  303. uid := user.UserId
  304. activityId, _ := this.GetInt("ActivityId")
  305. isSendWx, _ := this.GetInt("IsSendWx")
  306. if activityId < 1 {
  307. br.Msg = "请输入活动ID"
  308. return
  309. }
  310. resp := new(models.CygxActivityResp)
  311. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  312. if err != nil && err.Error() != utils.ErrNoRow() {
  313. br.Msg = "获取信息失败"
  314. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  315. return
  316. }
  317. if activityInfo == nil {
  318. br.Msg = "活动不存在"
  319. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  320. return
  321. }
  322. // 判断是否属于研选类型的活动
  323. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  324. resp.IsResearch = true
  325. }
  326. signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  327. if err != nil {
  328. br.Msg = "获取信息"
  329. br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  330. return
  331. }
  332. activityInfo.SignupNum = signupCount
  333. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  334. if err != nil {
  335. br.Msg = "获取信息失败"
  336. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  337. return
  338. }
  339. if havePower {
  340. //是否展示限免标签
  341. if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  342. activityInfo.IsShowSustainable = true
  343. }
  344. resp.HasPermission = 1
  345. configCode := "description_of_research"
  346. detail, err := models.GetConfigByCode(configCode)
  347. if err != nil {
  348. br.Msg = "获取数据失败"
  349. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  350. return
  351. }
  352. activityInfo.Description = detail.ConfigValue
  353. if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
  354. activityInfo.SignupNum = activityInfo.LimitPeopleNum
  355. }
  356. if activityInfo.ChartPermissionNames != "" {
  357. activityInfo.ChartPermissionName = activityInfo.ChartPermissionNames
  358. }
  359. if activityInfo.IsHideAppointment == 0 {
  360. activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName)
  361. }
  362. activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
  363. //处理活动关联的产业
  364. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  365. if err != nil && err.Error() != utils.ErrNoRow() {
  366. br.Msg = "获取信息失败"
  367. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  368. return
  369. }
  370. if activityInfo.TemporaryLabel != "" {
  371. industrialList = make([]*models.IndustrialManagementRep, 0)
  372. item := new(models.IndustrialManagementRep)
  373. item.IndustryName = activityInfo.Label
  374. industrialList = append(industrialList, item)
  375. } else {
  376. industryIds := make([]int, 0)
  377. var industrialManagementId string
  378. for k, v := range industrialList {
  379. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  380. industrialList[k].IsResearch = true
  381. }
  382. industryIds = append(industryIds, v.IndustrialManagementId)
  383. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  384. }
  385. // 查研观向7.4-行业新标签
  386. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  387. if e != nil {
  388. br.Msg = "获取信息失败"
  389. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  390. return
  391. }
  392. //判断产业下是否有关联的报告,并处理是否跳转
  393. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  394. if industrialManagementId != "" {
  395. var condition string
  396. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  397. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  398. listIndustrialGrop, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  399. if err != nil && err.Error() != utils.ErrNoRow() {
  400. br.Msg = "获取信息失败"
  401. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  402. return
  403. }
  404. mapIndustrial := make(map[int]int)
  405. if len(listIndustrialGrop) > 0 {
  406. for _, v := range listIndustrialGrop {
  407. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  408. }
  409. }
  410. for k, v := range industrialList {
  411. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  412. industrialList[k].IsJump = true
  413. }
  414. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  415. }
  416. }
  417. }
  418. activityInfo.Listndustrial = industrialList
  419. if activityInfo.YidongActivityId != "" {
  420. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  421. yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  422. if err != nil {
  423. br.Msg = "获取信息失败"
  424. br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  425. return
  426. }
  427. //yidongKwy := activityInfo.YidongActivityUrl
  428. //activityInfo.YidongActivityUrl = yidongLongLink + "?source=11&fromHz=true&tgc=" + ydTgc
  429. activityInfo.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  430. }
  431. //处理音频回放
  432. var mapActivityId []int
  433. mapActivityId = append(mapActivityId, activityId)
  434. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  435. if err != nil {
  436. br.Msg = "获取信息失败"
  437. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  438. return
  439. }
  440. if mapActivityVoice[activityId] != nil {
  441. activityInfo.FileType = 1
  442. activityInfo.AudioLink = true
  443. activityInfo.VoiceList = mapActivityVoice[activityId]
  444. }
  445. //处理视频回放
  446. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  447. if err != nil {
  448. br.Msg = "获取信息失败"
  449. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  450. return
  451. }
  452. if mapActivityVideo[activityId] != nil {
  453. activityInfo.FileType = 2
  454. activityInfo.AudioLink = true
  455. activityInfo.VideoDetail = mapActivityVideo[activityId]
  456. }
  457. //8.5 小程序活动详情页 除专家电话外 其余属于新产业的活动 ,不显示 new 标签
  458. if activityInfo.ActivityTypeName != "专家电话会" {
  459. for _, rep := range activityInfo.Listndustrial {
  460. rep.IndustryNewLabel = false
  461. }
  462. }
  463. //8.5 买方研选的活动去掉限免标签
  464. if strings.Contains(activityInfo.ChartPermissionName, "研选") {
  465. activityInfo.IsShowSustainable = false
  466. }
  467. //处理不同的报名方式按钮回显
  468. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  469. if err != nil {
  470. br.Msg = "获取信息失败"
  471. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  472. return
  473. }
  474. activityInfo.SignupType = mapActivitySignup[activityId]
  475. //处理活动关联的产业
  476. industrialListNew, err := models.GetIndustrialActivityGroupManagementList(activityId)
  477. if err != nil && err.Error() != utils.ErrNoRow() {
  478. br.Msg = "获取信息失败"
  479. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  480. return
  481. }
  482. //判断是不是通过微信模版推送消息进来的
  483. if isSendWx == 1 && len(industrialListNew) > 0 {
  484. industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
  485. if err != nil {
  486. br.Msg = "获取信息失败"
  487. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  488. return
  489. }
  490. for _, v := range industrialListNew {
  491. if industryUserFollowMap[v.IndustrialManagementId] {
  492. activityInfo.IsFollowButton = true
  493. }
  494. }
  495. activityInfo.IsShowFollowButton = true
  496. }
  497. if activityInfo.ReportLink != "" {
  498. artList, err := services.GetActivityReportLinkToArticleList(activityInfo)
  499. if err != nil && err.Error() != utils.ErrNoRow() {
  500. br.Msg = "获取信息失败"
  501. br.ErrMsg = "解析文章关联的报告内容失败:" + activityInfo.ReportLink
  502. return
  503. }
  504. activityInfo.ArticleList = artList
  505. } else {
  506. activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
  507. }
  508. if (activityInfo.ActivityTypeId == 5 || activityInfo.ActivityTypeId == 6) && services.GetBelongingRai(user.Mobile) && activityInfo.SigninImg != "" {
  509. activityInfo.IsShowSigninButton = true
  510. activityInfo.IsShowSignUpDetail = true
  511. }
  512. //处理按钮是否展示问题
  513. resp.Detail = services.ActivityButtonShow(activityInfo)
  514. // 暂时写死,客户需要 5.16
  515. if activityInfo.ActivityId == 2992 {
  516. activityInfo.ActivityTypeName = "分析师线下沙龙"
  517. }
  518. } else {
  519. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  520. if err != nil {
  521. br.Msg = "获取信息失败"
  522. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  523. return
  524. }
  525. resp.PopupMsg = popupMsg
  526. resp.HasPermission = hasPermission
  527. resp.SellerName = sellerName
  528. resp.SellerMobile = sellerMobile
  529. }
  530. collectCount1, err := models.GetActivityVoiceCollectCount(uid, activityId)
  531. if err != nil && err.Error() != utils.ErrNoRow() {
  532. br.Msg = "获取信息失败"
  533. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
  534. return
  535. }
  536. collectCount2, err := models.GetActivityVideoCollectCountByActivityId(uid, activityId)
  537. if err != nil && err.Error() != utils.ErrNoRow() {
  538. br.Msg = "获取信息失败"
  539. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
  540. return
  541. }
  542. if collectCount1+collectCount2 > 0 {
  543. resp.Detail.IsCollect = true
  544. }
  545. br.Ret = 200
  546. br.Success = true
  547. br.Msg = "获取成功"
  548. br.Data = resp
  549. }
  550. // @Title 活动报名
  551. // @Description 活动报名接口
  552. // @Param request body models.ActivitySingnupRep true "type json string"
  553. // @Success Ret=200 {object} models.SignupStatus
  554. // @router /signup/add [post]
  555. func (this *ActivityCoAntroller) SignupAdd() {
  556. br := new(models.BaseResponse).Init()
  557. defer func() {
  558. this.Data["json"] = br
  559. this.ServeJSON()
  560. }()
  561. user := this.User
  562. if user == nil {
  563. br.Msg = "请登录"
  564. br.ErrMsg = "请登录,用户信息为空"
  565. br.Ret = 408
  566. return
  567. }
  568. uid := user.UserId
  569. signupStatus := ""
  570. var req models.ActivitySingnupRep
  571. resp := new(models.SignupStatus)
  572. var total int
  573. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  574. if err != nil {
  575. br.Msg = "参数解析异常!"
  576. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  577. return
  578. }
  579. if user.Mobile == "" {
  580. user.Mobile = user.OutboundMobile
  581. }
  582. activityId := req.ActivityId
  583. signupType := req.SignupType
  584. hasPermission := 0
  585. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  586. resp.GoBindEmail = true
  587. }
  588. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  589. if activityInfo == nil {
  590. br.Msg = "操作失败"
  591. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  592. return
  593. }
  594. if errInfo != nil {
  595. br.Msg = "操作失败"
  596. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  597. return
  598. }
  599. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  600. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  601. signupType = 4
  602. }
  603. //SignupStatus "报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  604. //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  605. var userType int
  606. userType, _, err = services.GetUserType(user.CompanyId)
  607. if err != nil {
  608. br.Msg = "获取信息失败!"
  609. br.ErrMsg = "获取失败,Err:" + err.Error()
  610. return
  611. }
  612. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  613. br.Msg = "您暂无查看该活动权限"
  614. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  615. return
  616. }
  617. item := new(models.CygxActivitySignup)
  618. // 判断是否属于研选类型的活动
  619. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  620. resp.IsResearch = true
  621. }
  622. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  623. if err != nil {
  624. br.Msg = "获取信息失败"
  625. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  626. return
  627. }
  628. if havePower {
  629. hasPermission = 1
  630. signupStatus = "Success"
  631. resp.HasPermission = hasPermission
  632. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  633. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  634. signupStatus = "Overtime"
  635. resp.SignupType = signupType
  636. resp.SignupStatus = signupStatus
  637. resp.HasPermission = hasPermission
  638. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  639. br.Ret = 200
  640. br.Success = true
  641. br.Msg = ""
  642. br.Data = resp
  643. return
  644. }
  645. var sellerName string
  646. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  647. if err != nil {
  648. br.Msg = "报名失败!"
  649. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  650. return
  651. }
  652. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  653. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  654. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  655. if activityInfo.IsLimitPeople == 1 {
  656. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  657. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  658. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  659. if err != nil {
  660. br.Msg = "获取信息失败"
  661. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  662. return
  663. }
  664. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  665. if err != nil {
  666. br.Msg = "获取失败"
  667. br.ErrMsg = "获取失败,Err:" + err.Error()
  668. return
  669. }
  670. //解除报名限制之后二次报名相同活动
  671. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  672. item.UserId = uid
  673. item.RealName = user.RealName
  674. item.SellerName = sellerName
  675. item.ActivityId = activityId
  676. item.CreateTime = time.Now()
  677. item.Mobile = user.Mobile
  678. item.Email = user.Email
  679. item.CompanyId = user.CompanyId
  680. item.CompanyName = user.CompanyName
  681. item.SignupType = signupType
  682. item.FailType = 0
  683. item.DoFailType = 0
  684. _, errSignup := models.AddActivitySignupByRestrict(item)
  685. if errSignup != nil {
  686. br.Msg = "操作失败"
  687. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  688. return
  689. }
  690. resp.HaqveJurisdiction = true
  691. resp.SignupType = signupType
  692. resp.SignupStatus = "Success"
  693. resp.HasPermission = hasPermission
  694. resp.ActivityId = activityId
  695. total, err = models.GetUserMeetingReminderCount(user.UserId)
  696. if err != nil {
  697. br.Msg = "获取信息失败"
  698. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  699. return
  700. }
  701. if total == 0 {
  702. resp.GoFollow = true
  703. }
  704. br.Ret = 200
  705. br.Success = true
  706. br.Msg = "操作成功"
  707. br.Data = resp
  708. return
  709. }
  710. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  711. if err != nil {
  712. br.Msg = "获取失败"
  713. br.ErrMsg = "获取失败,Err:" + err.Error()
  714. return
  715. }
  716. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  717. item.UserId = uid
  718. item.RealName = user.RealName
  719. item.SellerName = sellerName
  720. item.ActivityId = activityId
  721. item.CreateTime = time.Now()
  722. item.Mobile = user.Mobile
  723. item.Email = user.Email
  724. item.CompanyId = user.CompanyId
  725. item.CompanyName = user.CompanyName
  726. item.SignupType = signupType
  727. item.DoFailType = item.FailType
  728. if user.OutboundMobile != "" {
  729. item.OutboundMobile = user.OutboundMobile
  730. if user.OutboundCountryCode == "" {
  731. item.CountryCode = "86"
  732. } else {
  733. item.CountryCode = user.OutboundCountryCode
  734. }
  735. } else {
  736. item.OutboundMobile = user.Mobile
  737. if user.CountryCode == "" {
  738. item.CountryCode = "86"
  739. } else {
  740. item.CountryCode = user.CountryCode
  741. }
  742. }
  743. //添加报名信息,但是不加入日程
  744. _, errSignup := models.AddActivitySignupNoSchedule(item)
  745. if errSignup != nil {
  746. br.Msg = "操作失败"
  747. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  748. return
  749. }
  750. }
  751. }
  752. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  753. if err != nil {
  754. br.Msg = "获取失败"
  755. br.ErrMsg = "获取失败,Err:" + err.Error()
  756. return
  757. }
  758. if totalMySuccess > 0 {
  759. br.Msg = "您已报名这个活动"
  760. return
  761. }
  762. if signupStatus == "Success" && resp.GoBindEmail != true {
  763. item.UserId = uid
  764. item.RealName = user.RealName
  765. item.SellerName = sellerName
  766. item.ActivityId = activityId
  767. item.CreateTime = time.Now()
  768. item.Mobile = user.Mobile
  769. item.Email = user.Email
  770. item.CompanyId = user.CompanyId
  771. item.CompanyName = user.CompanyName
  772. item.SignupType = signupType
  773. item.FailType = 0
  774. item.DoFailType = 0
  775. item.OutboundMobile = user.Mobile
  776. if user.OutboundMobile != "" {
  777. item.OutboundMobile = user.OutboundMobile
  778. if user.OutboundCountryCode == "" {
  779. item.CountryCode = "86"
  780. } else {
  781. item.CountryCode = user.OutboundCountryCode
  782. }
  783. } else {
  784. item.OutboundMobile = user.Mobile
  785. if user.CountryCode == "" {
  786. item.CountryCode = "86"
  787. } else {
  788. item.CountryCode = user.CountryCode
  789. }
  790. }
  791. _, errSignup := models.AddActivitySignup(item)
  792. if errSignup != nil {
  793. br.Msg = "操作失败"
  794. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  795. return
  796. }
  797. resp.HaqveJurisdiction = true
  798. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  799. if signupType == 1 {
  800. go services.ActivityUserRemind(user, activityInfo, 1)
  801. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  802. } else if signupType == 4 {
  803. go services.ActivityUserRemind(user, activityInfo, 4)
  804. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  805. } else {
  806. go services.ActivityUserRemind(user, activityInfo, 4)
  807. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  808. }
  809. }
  810. } else {
  811. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  812. if err != nil {
  813. br.Msg = "获取信息失败"
  814. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  815. return
  816. }
  817. resp.PopupMsg = popupMsg
  818. resp.HasPermission = hasPermission
  819. resp.SellerName = sellerName
  820. resp.SellerMobile = sellerMobile
  821. }
  822. // 判断是否属于研选类型的活动
  823. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  824. resp.IsResearch = true
  825. }
  826. //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  827. if signupStatus == "Success" {
  828. go services.SendResearchActivitiesTemplateMsg(user, activityInfo)
  829. }
  830. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  831. resp.GoOutboundMobile = true
  832. if user.Mobile != "" || user.OutboundMobile != "" {
  833. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  834. }
  835. }
  836. if user.OutboundMobile == "" {
  837. resp.Mobile = user.Mobile
  838. if user.CountryCode == "" && len(user.Mobile) == 11 {
  839. resp.CountryCode = "86"
  840. } else {
  841. resp.CountryCode = user.CountryCode
  842. }
  843. } else {
  844. resp.Mobile = user.OutboundMobile
  845. resp.CountryCode = user.OutboundCountryCode
  846. }
  847. //如果用户有绑定手机号,但是没有绑定外呼手机号
  848. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  849. var countryCode string
  850. if len(user.Mobile) == 8 {
  851. countryCode = "852"
  852. } else if len(user.Mobile) == 9 {
  853. countryCode = "886"
  854. } else if len(user.Mobile) == 10 {
  855. countryCode = "1"
  856. } else if len(user.Mobile) >= 11 {
  857. countryCode = "86"
  858. }
  859. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  860. }
  861. resp.SignupType = signupType
  862. resp.SignupStatus = signupStatus
  863. //resp.HasPermission = hasPermission
  864. //if signupStatus == "Success" {
  865. resp.ActivityId = activityId
  866. //}
  867. total, err = models.GetUserSignupCount(user.UserId)
  868. if err != nil {
  869. br.Msg = "获取信息失败"
  870. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  871. return
  872. }
  873. if total <= 1 {
  874. resp.GoFollow = true
  875. }
  876. br.Ret = 200
  877. br.Success = true
  878. br.Msg = "操作成功"
  879. br.Data = resp
  880. }
  881. // @Title 活动取消报名
  882. // @Description 活动取消报名接口
  883. // @Param request body models.ActivitySingnupRep true "type json string"
  884. // @Success Ret=200 {object} models.SignupStatus
  885. // @router /signup/cancel [post]
  886. func (this *ActivityCoAntroller) SignupCancel() {
  887. br := new(models.BaseResponse).Init()
  888. defer func() {
  889. this.Data["json"] = br
  890. this.ServeJSON()
  891. }()
  892. user := this.User
  893. if user == nil {
  894. br.Msg = "请登录"
  895. br.ErrMsg = "请登录,用户信息为空"
  896. br.Ret = 408
  897. return
  898. }
  899. uid := user.UserId
  900. var req models.ActivitySingnupRep
  901. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  902. if err != nil {
  903. br.Msg = "参数解析异常!"
  904. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  905. return
  906. }
  907. activityId := req.ActivityId
  908. signupType := req.SignupType
  909. item := new(models.CygxActivitySignup)
  910. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  911. if activityInfo == nil {
  912. br.Msg = "操作失败"
  913. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  914. return
  915. }
  916. if errInfo != nil {
  917. br.Msg = "操作失败"
  918. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  919. return
  920. }
  921. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  922. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  923. if signupType == 1 {
  924. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  925. } else {
  926. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  927. }
  928. return
  929. }
  930. total, err := models.GetActivitySignupCount(uid, activityId)
  931. if err != nil {
  932. br.Msg = "获取失败"
  933. br.ErrMsg = "获取失败,Err:" + err.Error()
  934. return
  935. }
  936. if total == 0 {
  937. br.Msg = "您暂未报名这个活动"
  938. return
  939. }
  940. item.UserId = uid
  941. item.ActivityId = activityId
  942. item.CreateTime = time.Now()
  943. item.Mobile = user.Mobile
  944. item.Email = user.Email
  945. item.CompanyId = user.CompanyId
  946. item.CompanyName = user.CompanyName
  947. resp := new(models.SignupStatus)
  948. resp.ActivityId = activityId
  949. _, errSignup := models.CancelActivitySignup(item)
  950. if errSignup != nil {
  951. br.Msg = "操作失败"
  952. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  953. return
  954. }
  955. br.Ret = 200
  956. br.Success = true
  957. br.Msg = "操作成功"
  958. br.Data = resp
  959. }
  960. // @Title 用户搜索详情
  961. // @Description 获取用户搜索详情接口
  962. // @Param IsShowJurisdiction query int true "是否仅展示有权限的,默认为0,1是,2否 "
  963. // @Success Ret=200 {object} models.ActivityUserSearchContentList
  964. // @router /getUserSearchContent [get]
  965. func (this *ActivityCoAntroller) GetUserSearchContent() {
  966. br := new(models.BaseResponse).Init()
  967. defer func() {
  968. this.Data["json"] = br
  969. this.ServeJSON()
  970. }()
  971. user := this.User
  972. if user == nil {
  973. br.Msg = "请登录"
  974. br.ErrMsg = "请登录,用户信息为空"
  975. br.Ret = 408
  976. return
  977. }
  978. uid := user.UserId
  979. detailSeearch := new(models.CygxActivityUserSearchContent)
  980. detailSeearch.IsShowJurisdiction = 0
  981. detailSeearch.ChartPermissionids = ""
  982. detailSeearch.ActiveState = ""
  983. resp := new(models.ActivityUserSearchContentList)
  984. detail, _ := models.GetUserSearchContentByUid(uid)
  985. if detail == nil {
  986. detail = detailSeearch
  987. }
  988. isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
  989. listActivityType, errActivityType := models.GetActivityTypeList()
  990. if errActivityType != nil {
  991. br.Msg = "获取失败"
  992. br.ErrMsg = "获取数据失败,Err:" + errActivityType.Error()
  993. return
  994. }
  995. var listChartPermissionid []*models.ActivityChartPermission
  996. var errChart error
  997. if isShowJurisdiction == 1 {
  998. listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
  999. listChartPermissionid = listChartPermissionidAll
  1000. errChart = errChartAll
  1001. } else if isShowJurisdiction == 2 {
  1002. listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
  1003. listChartPermissionid = listChartPermissionidAll
  1004. errChart = errChartAll
  1005. } else {
  1006. if detail.IsShowJurisdiction == 1 {
  1007. listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
  1008. listChartPermissionid = listChartPermissionidAll
  1009. errChart = errChartAll
  1010. } else {
  1011. listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
  1012. listChartPermissionid = listChartPermissionidAll
  1013. errChart = errChartAll
  1014. }
  1015. }
  1016. if errChart != nil {
  1017. br.Msg = "获取信息失败"
  1018. br.ErrMsg = "获取品种信息失败,Err:" + errChart.Error()
  1019. return
  1020. }
  1021. if detail.IsShowJurisdiction == 1 {
  1022. resp.IsShowJurisdiction = true
  1023. }
  1024. if isShowJurisdiction == 1 || detail.IsShowJurisdiction == 1 {
  1025. resp.IsShowJurisdiction = true
  1026. for k, _ := range listChartPermissionid {
  1027. listChartPermissionid[k].IsChoose = true
  1028. }
  1029. }
  1030. if isShowJurisdiction == 2 {
  1031. resp.IsShowJurisdiction = false
  1032. }
  1033. activeStateList := []models.ActivityStaus{models.ActivityStaus{Id: 1, StatusName: "未开始", IsChoose: true}, models.ActivityStaus{Id: 2, StatusName: "进行中"}, models.ActivityStaus{Id: 3, StatusName: "已结束"}}
  1034. list2, err := models.GetChartPermissionActivity()
  1035. if err != nil {
  1036. br.Msg = "获取信息失败"
  1037. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1038. return
  1039. }
  1040. if activeStateList[1].IsChoose == activeStateList[2].IsChoose == false {
  1041. activeStateList[0].IsChoose = true
  1042. }
  1043. var userType int
  1044. userType, _, err = services.GetUserType(user.CompanyId)
  1045. if err != nil {
  1046. br.Msg = "获取信息失败!"
  1047. br.ErrMsg = "获取失败,Err:" + err.Error()
  1048. return
  1049. }
  1050. var listChartPermissionidNew2 []*models.ActivityChartPermission
  1051. for _, v := range list2 {
  1052. if userType == 1 {
  1053. //if v.PermissionName != "研选" {
  1054. if !strings.Contains(v.PermissionName, "研选") {
  1055. listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
  1056. }
  1057. } else {
  1058. listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
  1059. }
  1060. }
  1061. resp.ListChartPermission2 = listChartPermissionidNew2
  1062. var listChartPermissionidNew []*models.ActivityChartPermission
  1063. for _, v := range listChartPermissionid {
  1064. if userType == 1 {
  1065. if !strings.Contains(v.PermissionName, "研选") {
  1066. listChartPermissionidNew = append(listChartPermissionidNew, v)
  1067. }
  1068. } else {
  1069. listChartPermissionidNew = append(listChartPermissionidNew, v)
  1070. }
  1071. }
  1072. resp.ListActivityType = listActivityType
  1073. resp.ListChartPermission = listChartPermissionidNew
  1074. resp.ListActivityStaus = activeStateList
  1075. br.Ret = 200
  1076. br.Success = true
  1077. br.Msg = "获取成功"
  1078. br.Data = resp
  1079. }
  1080. // @Title 添加会议提醒
  1081. // @Description 添加会议提醒接口
  1082. // @Param request body models.ActivityIdRep true "type json string"
  1083. // @Success Ret=200 {object} models.SignupStatus
  1084. // @router /meetingReminder/add [post]
  1085. func (this *ActivityCoAntroller) MeetingReminderAdd() {
  1086. br := new(models.BaseResponse).Init()
  1087. defer func() {
  1088. this.Data["json"] = br
  1089. this.ServeJSON()
  1090. }()
  1091. user := this.User
  1092. if user == nil {
  1093. br.Msg = "请登录"
  1094. br.ErrMsg = "请登录,用户信息为空"
  1095. br.Ret = 408
  1096. return
  1097. }
  1098. uid := user.UserId
  1099. //var signupStatus string
  1100. signupStatus := "Success"
  1101. var req models.ActivityIdRep
  1102. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1103. if err != nil {
  1104. br.Msg = "参数解析异常!"
  1105. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1106. return
  1107. }
  1108. activityId := req.ActivityId
  1109. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1110. if activityInfo == nil {
  1111. br.Msg = "操作失败"
  1112. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1113. return
  1114. }
  1115. if errInfo != nil {
  1116. br.Msg = "操作失败"
  1117. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1118. return
  1119. }
  1120. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1121. item := new(models.CygxActivityMeetingReminder)
  1122. resp := new(models.SignupStatus)
  1123. hasPermission := 0
  1124. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1125. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1126. br.Msg = "活动开始前15分钟无法设置会议提醒"
  1127. return
  1128. }
  1129. // 判断是否属于研选类型的活动
  1130. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1131. resp.IsResearch = true
  1132. }
  1133. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  1134. if err != nil {
  1135. br.Msg = "获取信息失败"
  1136. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1137. return
  1138. }
  1139. if havePower {
  1140. hasPermission = 1
  1141. signupStatus = "Success"
  1142. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1143. if errMeeting != nil {
  1144. br.Msg = "获取失败"
  1145. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1146. return
  1147. }
  1148. if totalMeeting > 0 {
  1149. br.Msg = "您已预约,请勿重复预约"
  1150. return
  1151. }
  1152. item.UserId = uid
  1153. item.ActivityId = activityId
  1154. item.CreateTime = time.Now()
  1155. item.Mobile = user.Mobile
  1156. item.Email = user.Email
  1157. item.CompanyId = user.CompanyId
  1158. item.CompanyName = user.CompanyName
  1159. resp.HasPermission = hasPermission
  1160. _, errSignup := models.AddActivityMeetingReminder(item)
  1161. if errSignup != nil {
  1162. br.Msg = "操作失败"
  1163. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1164. return
  1165. }
  1166. resp.HaqveJurisdiction = true
  1167. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1168. go services.ActivityUserRemind(user, activityInfo, 2)
  1169. } else {
  1170. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1171. if err != nil {
  1172. br.Msg = "获取信息失败"
  1173. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1174. return
  1175. }
  1176. resp.PopupMsg = popupMsg
  1177. resp.HasPermission = hasPermission
  1178. resp.SellerName = sellerName
  1179. resp.SellerMobile = sellerMobile
  1180. }
  1181. // 判断是否属于研选类型的活动
  1182. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1183. resp.IsResearch = true
  1184. }
  1185. resp.SignupStatus = signupStatus
  1186. resp.ActivityId = activityId
  1187. var total int
  1188. total, err = models.GetUserActivityMeetingReminderCount(user.UserId)
  1189. if err != nil {
  1190. br.Msg = "获取信息失败"
  1191. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1192. return
  1193. }
  1194. if total <= 1 {
  1195. resp.GoFollow = true
  1196. }
  1197. br.Ret = 200
  1198. br.Success = true
  1199. if hasPermission == 1 {
  1200. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1201. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1202. }
  1203. br.Data = resp
  1204. }
  1205. // @Title 取消会议提醒
  1206. // @Description 取消会议提醒接口
  1207. // @Param request body models.ActivityIdRep true "type json string"
  1208. // @Success Ret=200 {object} models.SignupStatus
  1209. // @router /meetingReminder/cancel [post]
  1210. func (this *ActivityCoAntroller) MeetingReminderCancel() {
  1211. br := new(models.BaseResponse).Init()
  1212. defer func() {
  1213. this.Data["json"] = br
  1214. this.ServeJSON()
  1215. }()
  1216. user := this.User
  1217. if user == nil {
  1218. br.Msg = "请登录"
  1219. br.ErrMsg = "请登录,用户信息为空"
  1220. br.Ret = 408
  1221. return
  1222. }
  1223. uid := user.UserId
  1224. var req models.ActivityIdRep
  1225. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1226. if err != nil {
  1227. br.Msg = "参数解析异常!"
  1228. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1229. return
  1230. }
  1231. activityId := req.ActivityId
  1232. signupStatus := "Success"
  1233. item := new(models.CygxActivityMeetingReminder)
  1234. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1235. if activityInfo == nil {
  1236. br.Msg = "操作失败"
  1237. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1238. return
  1239. }
  1240. if errInfo != nil {
  1241. br.Msg = "操作失败"
  1242. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1243. return
  1244. }
  1245. //if signupStatus == "Success" {
  1246. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1247. if err != nil {
  1248. br.Msg = "获取失败"
  1249. br.ErrMsg = "获取失败,Err:" + err.Error()
  1250. return
  1251. }
  1252. if total == 0 {
  1253. br.Msg = "您暂未添加该活动会议提醒"
  1254. return
  1255. }
  1256. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1257. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1258. br.Msg = "活动开始前15分钟无法取消会议提醒"
  1259. return
  1260. }
  1261. item.UserId = uid
  1262. item.ActivityId = activityId
  1263. item.CreateTime = time.Now()
  1264. item.Mobile = user.Mobile
  1265. item.Email = user.Email
  1266. item.CompanyId = user.CompanyId
  1267. item.CompanyName = user.CompanyName
  1268. _, errSignup := models.CancelActivityMeetingReminder(item)
  1269. if errSignup != nil {
  1270. br.Msg = "操作失败"
  1271. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1272. return
  1273. }
  1274. //}
  1275. resp := new(models.SignupStatus)
  1276. resp.SignupStatus = signupStatus
  1277. resp.ActivityId = activityId
  1278. br.Ret = 200
  1279. br.Success = true
  1280. br.Msg = "会议提醒已取消"
  1281. br.Data = resp
  1282. }
  1283. // @Title 敏捷搜索关键词的列表
  1284. // @Description 获取敏捷搜索关键词的列表接口
  1285. // @Success 200 {object} models.ActivityFastsearchKeywordsListResp
  1286. // @router /fastSearchKeWord [get]
  1287. func (this *ActivityABaseController) FastSearch() {
  1288. br := new(models.BaseResponse).Init()
  1289. defer func() {
  1290. this.Data["json"] = br
  1291. this.ServeJSON()
  1292. }()
  1293. resp := new(models.ActivityFastsearchKeywordsListResp)
  1294. list, err := models.GetActivityFastsearchKeywordsList()
  1295. if err != nil {
  1296. br.Msg = "获取失败"
  1297. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1298. return
  1299. }
  1300. resp.List = list
  1301. br.Ret = 200
  1302. br.Success = true
  1303. br.Msg = "获取成功"
  1304. br.Data = resp
  1305. }
  1306. // @Title 活动带问
  1307. // @Description 新增活动带问接口
  1308. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1309. // @Success Ret=200 新增成功
  1310. // @router /askAdd [post]
  1311. func (this *ActivityCoAntroller) AskAdd() {
  1312. br := new(models.BaseResponse).Init()
  1313. defer func() {
  1314. this.Data["json"] = br
  1315. this.ServeJSON()
  1316. }()
  1317. user := this.User
  1318. if user == nil {
  1319. br.Msg = "请登录"
  1320. br.ErrMsg = "请登录,SysUser Is Empty"
  1321. br.Ret = 408
  1322. return
  1323. }
  1324. var req models.CygxActivityHelpAsk
  1325. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1326. if err != nil {
  1327. br.Msg = "参数解析异常!"
  1328. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1329. return
  1330. }
  1331. if req.Content == "" {
  1332. br.Msg = "建议内容不可为空"
  1333. return
  1334. }
  1335. content := req.Content
  1336. itemToken, err := services.WxGetToken()
  1337. if err != nil {
  1338. br.Msg = "GetWxAccessToken Err:" + err.Error()
  1339. return
  1340. }
  1341. if itemToken.AccessToken == "" {
  1342. br.Msg = "accessToken is empty"
  1343. return
  1344. }
  1345. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1346. if err != nil {
  1347. br.Msg = "内容校验失败!"
  1348. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1349. return
  1350. }
  1351. if commerr.ErrCode != 0 {
  1352. br.Msg = "内容违规,请重新提交!"
  1353. br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  1354. return
  1355. }
  1356. activityId := req.ActivityId
  1357. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1358. if activityInfo == nil {
  1359. br.Msg = "操作失败"
  1360. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1361. return
  1362. }
  1363. if errInfo != nil {
  1364. br.Msg = "操作失败"
  1365. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1366. return
  1367. }
  1368. //resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1369. //if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1370. // if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1371. // br.Msg = "活动开始前15分钟内无法提交问题"
  1372. // return
  1373. // }
  1374. //} else {
  1375. // if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1376. // br.Msg = "活动开始前1小时内无法提交问题"
  1377. // return
  1378. // }
  1379. //}
  1380. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1381. if err != nil {
  1382. br.Msg = "提交失败!"
  1383. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1384. return
  1385. }
  1386. if companyDetail == nil {
  1387. br.Msg = "提交失败!"
  1388. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1389. return
  1390. }
  1391. item := new(models.CygxActivityHelpAsk)
  1392. item.UserId = user.UserId
  1393. item.ActivityId = req.ActivityId
  1394. item.CompanyId = user.CompanyId
  1395. item.CompanyName = companyDetail.CompanyName
  1396. item.CreateTime = time.Now()
  1397. item.Mobile = user.Mobile
  1398. item.Email = user.Email
  1399. item.Content = content
  1400. msgId, err := models.AddActivityHelpAsk(item)
  1401. if err != nil {
  1402. br.Msg = "提交失败"
  1403. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1404. return
  1405. }
  1406. var isSendMsg bool
  1407. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1408. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1409. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1410. isSendMsg = true
  1411. }
  1412. } else {
  1413. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1414. isSendMsg = true
  1415. }
  1416. }
  1417. if isSendMsg {
  1418. listEmail, err := models.GetAskEmail()
  1419. if err != nil {
  1420. br.Msg = "提交失败"
  1421. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1422. return
  1423. }
  1424. var sendMobile string
  1425. for _, v := range listEmail {
  1426. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1427. sendMobile = v.Mobile
  1428. }
  1429. }
  1430. //如果是研选的就推送给汪洋
  1431. if activityInfo.ChartPermissionId == 31 {
  1432. sendMobile = utils.ActSendMsgMobile
  1433. }
  1434. //获取销售信息
  1435. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1436. if err != nil && err.Error() != utils.ErrNoRow() {
  1437. br.Msg = "提交失败"
  1438. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1439. return
  1440. }
  1441. //给研究员发送消息
  1442. if sendMobile != "" {
  1443. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1444. if openIpItem != nil && openIpItem.OpenId != "" {
  1445. if sellerItem != nil {
  1446. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1447. }
  1448. }
  1449. }
  1450. // 给所属销售发送消息
  1451. if sellerItem != nil {
  1452. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1453. if openIpItem != nil && openIpItem.OpenId != "" {
  1454. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1455. }
  1456. }
  1457. }
  1458. br.Ret = 200
  1459. br.Success = true
  1460. br.Msg = "提交成功"
  1461. }
  1462. // @Title 更多主题列表(4.3版本)
  1463. // @Description 获取活动更多主题列表接口(4.3版本)
  1464. // @Success 200 {object} models.GetCygxActivityLabelListRep
  1465. // @router /labelMoreList [get]
  1466. func (this *ActivityCoAntroller) LabelMoreList() {
  1467. br := new(models.BaseResponse).Init()
  1468. defer func() {
  1469. this.Data["json"] = br
  1470. this.ServeJSON()
  1471. }()
  1472. user := this.User
  1473. if user == nil {
  1474. br.Msg = "请登录"
  1475. br.ErrMsg = "请登录,SysUser Is Empty"
  1476. return
  1477. }
  1478. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  1479. if err != nil {
  1480. br.Msg = "获取失败"
  1481. br.ErrMsg = "获取失败,Err:" + err.Error()
  1482. return
  1483. }
  1484. var startSize, pageSize int
  1485. pageSize = 24
  1486. var condition string
  1487. var sortTime string
  1488. //var conditionStatus string
  1489. var pars []interface{}
  1490. //活动可见限制
  1491. var sqlExport string
  1492. resp := new(models.GetCygxActivityLabelListRep)
  1493. slicePer := strings.Split(permissionStr, ",")
  1494. var permissionSqlStr string
  1495. for _, v := range slicePer {
  1496. if userType == 1 {
  1497. //if v != "研选" {
  1498. if !strings.Contains(v, "研选") {
  1499. permissionSqlStr += "'" + v + "',"
  1500. }
  1501. } else {
  1502. permissionSqlStr += "'" + v + "',"
  1503. }
  1504. }
  1505. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  1506. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  1507. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  1508. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  1509. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  1510. if userType == 2 {
  1511. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  1512. }
  1513. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  1514. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  1515. }
  1516. sqlExport += `) `
  1517. //进行中的活动
  1518. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 2 `
  1519. var conditionOr string
  1520. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  1521. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  1522. }
  1523. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  1524. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  1525. }
  1526. if userType == 1 {
  1527. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  1528. } else {
  1529. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  1530. }
  1531. //判断客户规模是否属于可见范围的活动
  1532. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  1533. if err != nil && err.Error() != utils.ErrNoRow() {
  1534. br.Msg = "获取信息失败"
  1535. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1536. return
  1537. }
  1538. if companyProduct != nil {
  1539. if companyProduct.Scale != "" {
  1540. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  1541. }
  1542. }
  1543. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  1544. //进行中的活动
  1545. sortTime = ` mintimesort ASC `
  1546. list, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  1547. if errList != nil {
  1548. br.Msg = "获取失败"
  1549. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1550. return
  1551. }
  1552. //已结束的活动
  1553. conditionOr = ""
  1554. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 3 `
  1555. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  1556. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  1557. }
  1558. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  1559. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  1560. }
  1561. if userType == 1 {
  1562. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  1563. } else {
  1564. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  1565. }
  1566. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  1567. startSize = 0
  1568. pageSize = 24 - len(list)
  1569. //已结束的活动
  1570. sortTime = ` timesort DESC `
  1571. listEnd, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  1572. if err != nil {
  1573. br.Msg = "获取失败"
  1574. br.ErrMsg = "获取失败,Err:" + err.Error()
  1575. return
  1576. }
  1577. for _, v := range listEnd {
  1578. list = append(list, v)
  1579. }
  1580. //标签字段关联的产业与标签处理
  1581. for k, v := range list {
  1582. list[k].KeyWord = services.LabelStr(v.KeyWord)
  1583. }
  1584. //添加更多主题访问记录
  1585. item := new(models.CygxPageHistoryRecord)
  1586. item.UserId = user.UserId
  1587. item.CreateTime = time.Now()
  1588. item.Mobile = user.Mobile
  1589. item.Email = user.Email
  1590. item.CompanyId = user.CompanyId
  1591. item.CompanyName = user.CompanyName
  1592. item.PageType = "LabelMore"
  1593. go models.AddCygxPageHistoryRecord(item)
  1594. resp.List = list
  1595. br.Ret = 200
  1596. br.Success = true
  1597. br.Msg = "获取成功"
  1598. br.Data = resp
  1599. }
  1600. // @Title 活动列表(4.3版本)
  1601. // @Description 获取活动列表接口(4.3版本)
  1602. // @Param PageSize query int true "每页数据条数"
  1603. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1604. // @Param Label query string false "搜索主题 多个用 , 隔开"
  1605. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  1606. // @Param WhichDay query string false "哪一天 1今天、2明天,3本周,4上周,5本月,6上月 多个用 , 隔开"
  1607. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  1608. // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
  1609. // @Param Source query int false "来源 0手机 ,1Pc 默认0"
  1610. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  1611. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  1612. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  1613. // @Param ActivityId query int false "活动列表传过来的活动ID"
  1614. // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
  1615. // @Param TypeName query string false "电话会类型 ,1专家电话会 2分析师电话会"
  1616. // @Success 200 {object} models.GetCygxActivityListRep
  1617. // @router /listNew [get]
  1618. func (this *ActivityCoAntroller) ActivityListNew() {
  1619. br := new(models.BaseResponse).Init()
  1620. defer func() {
  1621. this.Data["json"] = br
  1622. this.ServeJSON()
  1623. }()
  1624. user := this.User
  1625. if user == nil {
  1626. br.Msg = "请登录"
  1627. br.ErrMsg = "请登录,SysUser Is Empty"
  1628. return
  1629. }
  1630. uid := user.UserId
  1631. pageSize, _ := this.GetInt("PageSize")
  1632. currentIndex, _ := this.GetInt("CurrentIndex")
  1633. source, _ := this.GetInt("Source")
  1634. label := this.GetString("Label")
  1635. chartPermissionIds := this.GetString("ChartPermissionIds")
  1636. whichDay := this.GetString("WhichDay")
  1637. activeState := this.GetString("ActiveState")
  1638. activityTypeId := this.GetString("ActivityTypeId")
  1639. keyWord := this.GetString("KeyWord")
  1640. playBack, _ := this.GetInt("PlayBack")
  1641. filter, _ := this.GetInt("Filter")
  1642. typeName := this.GetString("TypeName")
  1643. activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
  1644. if label == "undefined" {
  1645. label = ""
  1646. }
  1647. if chartPermissionIds == "undefined" {
  1648. chartPermissionIds = ""
  1649. }
  1650. // 查研观向7.4-始终查询宏观的活动
  1651. if chartPermissionIds != "" {
  1652. chartPermissionIds += ",1"
  1653. }
  1654. if whichDay == "undefined" {
  1655. whichDay = ""
  1656. }
  1657. if activeState == "undefined" {
  1658. activeState = ""
  1659. }
  1660. if activityTypeId == "undefined" {
  1661. activityTypeId = ""
  1662. }
  1663. var startSize int
  1664. if pageSize <= 0 {
  1665. pageSize = utils.PageSize20
  1666. }
  1667. if currentIndex <= 0 {
  1668. currentIndex = 1
  1669. }
  1670. startSize = utils.StartIndex(currentIndex, pageSize)
  1671. //userType, permissionStr, err := services.GetUserType(user.CompanyId)
  1672. var condition string
  1673. var pars []interface{}
  1674. var activityList []*models.ActivityDetail
  1675. mapDingActivityId := make(map[int]int)
  1676. //进行中的活动拍在最上面
  1677. //if keyWord != "" {
  1678. // conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, strconv.Itoa(2), label, 0, source, keyWord)
  1679. // if err != nil && err.Error() != utils.ErrNoRow() {
  1680. // br.Msg = "获取失败"
  1681. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1682. // return
  1683. // }
  1684. // if source == 1 {
  1685. // condition += ` AND art.yidong_activity_id = '' `
  1686. // }
  1687. // condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  1688. // condition += ` ORDER BY art.activity_time ASC `
  1689. // listDing, err := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
  1690. // if err != nil && err.Error() != utils.ErrNoRow() {
  1691. // br.Msg = "获取失败"
  1692. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1693. // return
  1694. // }
  1695. // if len(listDing) > 0 {
  1696. // for _, v := range listDing {
  1697. // activityList = append(activityList, v)
  1698. // mapDingActivityId[v.ActivityId] = v.ActivityId
  1699. // }
  1700. // }
  1701. //}
  1702. //condition = " AND art.is_limit_people = 1 AND art.publish_status = 1 "
  1703. //活动可见限制
  1704. conditionActivityAll, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 3)
  1705. if err != nil && err.Error() != utils.ErrNoRow() {
  1706. br.Msg = "获取失败"
  1707. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1708. return
  1709. }
  1710. if source == 1 {
  1711. condition += ` AND art.yidong_activity_id = '' `
  1712. }
  1713. var conditionCount string
  1714. conditionCount = condition + conditionActivityAll
  1715. total, err := models.GetActivityCount(conditionCount, playBack, pars, filter)
  1716. if err != nil {
  1717. br.Msg = "获取失败"
  1718. br.ErrMsg = "获取失败,Err:" + err.Error()
  1719. return
  1720. }
  1721. //搜索关键词初始化
  1722. conditionActivityKey, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 1)
  1723. if err != nil && err.Error() != utils.ErrNoRow() {
  1724. br.Msg = "获取失败"
  1725. br.ErrMsg = "获取失败,Err:" + err.Error()
  1726. return
  1727. }
  1728. var conditionOrder string
  1729. if activeState == "2" || activeState == "3" {
  1730. conditionOrder = ` ORDER BY art.activity_time DESC `
  1731. } else if activeState == "2,3" {
  1732. conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
  1733. } else {
  1734. conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
  1735. }
  1736. if label != "" && activeState == "1" {
  1737. conditionOrder = ` ORDER BY art.activity_time ASC `
  1738. }
  1739. if activeState == "1" {
  1740. conditionOrder = ` ORDER BY art.activity_time ASC `
  1741. }
  1742. conditionActivityKey += condition + conditionOrder
  1743. //fmt.Println(conditionOrder)
  1744. list, errList := models.GetActivityListNew(conditionActivityKey, pars, uid, startSize, pageSize, playBack, filter, typeName)
  1745. if errList != nil {
  1746. br.Msg = "获取失败"
  1747. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1748. return
  1749. }
  1750. if keyWord != "" {
  1751. keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
  1752. if err != nil {
  1753. br.Msg = "获取失败"
  1754. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  1755. return
  1756. }
  1757. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  1758. startSizeIk := utils.StartIndex(currentIndex, pageSize)
  1759. startSizeIk = startSizeIk - total
  1760. if startSizeIk < 0 {
  1761. startSizeIk = 0
  1762. }
  1763. var pageSizeIk int
  1764. pageSizeIk = pageSize - len(list)
  1765. if pageSizeIk > 0 {
  1766. //搜索关键词联想
  1767. conditionActivityIk, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 2)
  1768. if err != nil {
  1769. br.Msg = "获取失败"
  1770. br.ErrMsg = "获取失败,Err:" + err.Error()
  1771. return
  1772. }
  1773. conditionActivityIk += condition + conditionOrder
  1774. listIk, errList := models.GetActivityListNew(conditionActivityIk, pars, uid, startSizeIk, pageSizeIk, playBack, filter, typeName)
  1775. if errList != nil {
  1776. br.Msg = "获取失败"
  1777. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1778. return
  1779. }
  1780. for _, item := range listIk {
  1781. list = append(list, item)
  1782. }
  1783. }
  1784. }
  1785. var isShow bool
  1786. isShow = services.GetShowSustainable()
  1787. detail, err := models.GetConfigByCode("city_img_url")
  1788. if err != nil {
  1789. br.Msg = "获取数据失败"
  1790. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  1791. return
  1792. }
  1793. detailChart, err := models.GetConfigByCode("chart_img_url")
  1794. if err != nil {
  1795. br.Msg = "获取数据失败"
  1796. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  1797. return
  1798. }
  1799. addressList := strings.Split(detail.ConfigValue, "{|}")
  1800. mapAddress := make(map[string]string)
  1801. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  1802. mapChart := make(map[string]string)
  1803. var cityName string
  1804. var chartName string
  1805. var imgUrl string
  1806. var imgUrlChart string
  1807. var mapActivityId []int
  1808. for _, v := range addressList {
  1809. vslice := strings.Split(v, "_")
  1810. cityName = vslice[0]
  1811. imgUrl = vslice[len(vslice)-1]
  1812. mapAddress[cityName] = imgUrl
  1813. }
  1814. for _, v := range chartList {
  1815. vslice := strings.Split(v, "_")
  1816. chartName = vslice[0]
  1817. imgUrlChart = vslice[len(vslice)-1]
  1818. mapChart[chartName] = imgUrlChart
  1819. }
  1820. for k, v := range list {
  1821. if strings.Contains(v.ActivityName, "【") {
  1822. list[k].IsBrackets = 1
  1823. }
  1824. if v.SignupNum > v.LimitPeopleNum {
  1825. list[k].SignupNum = v.LimitPeopleNum
  1826. }
  1827. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  1828. list[k].IsShowSustainable = true
  1829. }
  1830. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  1831. list[k].ActivityTypeName = "买方研选电话会"
  1832. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  1833. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  1834. }
  1835. if v.ActivityType == 0 {
  1836. if mapAddress[v.City] != "" {
  1837. list[k].ImgUrl = mapAddress[v.City]
  1838. } else {
  1839. list[k].ImgUrl = mapAddress["其它"]
  1840. }
  1841. } else {
  1842. if mapChart[v.ChartPermissionName] != "" {
  1843. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  1844. }
  1845. }
  1846. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  1847. list[k].Expert = expertTxt
  1848. if v.IsHideAppointment == 0 {
  1849. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  1850. }
  1851. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  1852. list[k].IsCClassMeeting = true
  1853. }
  1854. mapActivityId = append(mapActivityId, v.ActivityId)
  1855. }
  1856. page := paging.GetPaging(currentIndex, pageSize, total)
  1857. resp := new(models.GetCygxActivityListRep)
  1858. resp.Label = label
  1859. if activityTypeId != "" {
  1860. activityTypeIdint, err := strconv.Atoi(activityTypeId)
  1861. if err == nil {
  1862. detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
  1863. if errDetail != nil {
  1864. br.Msg = "获取信息失败"
  1865. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  1866. return
  1867. }
  1868. resp.ImgUrl = detail.OnlineIco
  1869. resp.Label = detail.ActivityTypeName
  1870. }
  1871. }
  1872. //处理音频回放
  1873. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  1874. if err != nil {
  1875. br.Msg = "获取信息失败"
  1876. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  1877. return
  1878. }
  1879. //处理视频回放
  1880. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  1881. if err != nil {
  1882. br.Msg = "获取信息失败"
  1883. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  1884. return
  1885. }
  1886. //处理不同的报名方式按钮回显
  1887. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  1888. if err != nil {
  1889. br.Msg = "获取信息失败"
  1890. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  1891. return
  1892. }
  1893. for _, v := range list {
  1894. if mapDingActivityId[v.ActivityId] == 0 {
  1895. activityList = append(activityList, v)
  1896. }
  1897. v.SignupType = mapActivitySignup[v.ActivityId]
  1898. }
  1899. for _, v := range activityList {
  1900. if v.ActivityType == 0 {
  1901. if mapAddress[v.City] != "" {
  1902. v.ImgUrl = mapAddress[v.City]
  1903. } else {
  1904. v.ImgUrl = mapAddress["其它"]
  1905. }
  1906. } else {
  1907. if mapChart[v.ChartPermissionName] != "" {
  1908. v.ImgUrl = mapChart[v.ChartPermissionName]
  1909. }
  1910. }
  1911. if mapActivityVoice[v.ActivityId] != nil {
  1912. v.AudioLink = true
  1913. v.VoiceList = mapActivityVoice[v.ActivityId]
  1914. }
  1915. }
  1916. for k, v := range activityList {
  1917. if mapActivityVoice[v.ActivityId] != nil {
  1918. list[k].FileType = 1
  1919. list[k].AudioLink = true
  1920. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  1921. }
  1922. if mapActivityVideo[v.ActivityId] != nil {
  1923. list[k].FileType = 2
  1924. list[k].AudioLink = true
  1925. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  1926. }
  1927. resp.List = append(resp.List, services.ActivityButtonShow(v))
  1928. }
  1929. // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
  1930. if label != "" {
  1931. industry, e := models.GetIndustryByName(label)
  1932. if e != nil && e.Error() != utils.ErrNoRow() {
  1933. br.Msg = "获取信息失败"
  1934. br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
  1935. return
  1936. }
  1937. if industry != nil {
  1938. sourceIndustry, e := models.GetSourceIndustryByName(label)
  1939. if e != nil && e.Error() != utils.ErrNoRow() {
  1940. br.Msg = "获取信息失败"
  1941. br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
  1942. return
  1943. }
  1944. if sourceIndustry != nil {
  1945. resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
  1946. resp.IsJump = true
  1947. // 研选产业不跳资源包
  1948. if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  1949. resp.IsJump = false
  1950. }
  1951. }
  1952. }
  1953. // 新标签
  1954. if activityId > 0 {
  1955. activityIds := []int{activityId}
  1956. activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
  1957. if e != nil {
  1958. br.Msg = "获取信息失败"
  1959. br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
  1960. return
  1961. }
  1962. resp.IndustryNewLabel = activityNewMap[activityId]
  1963. }
  1964. }
  1965. //添加活动搜索记录
  1966. if keyWord != "" {
  1967. go services.AddActivitykeyWordSearch(keyWord, user)
  1968. }
  1969. resp.Paging = page
  1970. br.Ret = 200
  1971. br.Success = true
  1972. br.Msg = "获取成功"
  1973. br.Data = resp
  1974. }
  1975. // @Title 校验活动带问是否有权限
  1976. // @Description 校验活动带问是否有权限接口
  1977. // @Param request body models.ActivityIdRep true "type json string"
  1978. // @Success Ret=200 {object} models.SignupStatus
  1979. // @router /checkAsk [post]
  1980. func (this *ActivityCoAntroller) CheckAsk() {
  1981. br := new(models.BaseResponse).Init()
  1982. defer func() {
  1983. this.Data["json"] = br
  1984. this.ServeJSON()
  1985. }()
  1986. user := this.User
  1987. if user == nil {
  1988. br.Msg = "请登录"
  1989. br.ErrMsg = "请登录,用户信息为空"
  1990. br.Ret = 408
  1991. return
  1992. }
  1993. var signupStatus string
  1994. var req models.ActivityIdRep
  1995. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1996. if err != nil {
  1997. br.Msg = "参数解析异常!"
  1998. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1999. return
  2000. }
  2001. activityId := req.ActivityId
  2002. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2003. if activityInfo == nil {
  2004. br.Msg = "操作失败"
  2005. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2006. return
  2007. }
  2008. if errInfo != nil {
  2009. br.Msg = "操作失败"
  2010. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2011. return
  2012. }
  2013. resp := new(models.SignupStatus)
  2014. hasPermission := 0
  2015. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  2016. if err != nil {
  2017. br.Msg = "获取信息失败"
  2018. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2019. return
  2020. }
  2021. if havePower {
  2022. hasPermission = 1
  2023. signupStatus = "Success"
  2024. resp.HaqveJurisdiction = true
  2025. resp.HasPermission = hasPermission
  2026. resp.SignupStatus = signupStatus
  2027. } else {
  2028. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  2029. if err != nil {
  2030. br.Msg = "获取信息失败"
  2031. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2032. return
  2033. }
  2034. resp.PopupMsg = popupMsg
  2035. resp.HasPermission = hasPermission
  2036. resp.SellerName = sellerName
  2037. resp.SellerMobile = sellerMobile
  2038. }
  2039. // 判断是否属于研选类型的活动
  2040. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2041. resp.IsResearch = true
  2042. }
  2043. resp.ActivityId = activityId
  2044. br.Ret = 200
  2045. br.Success = true
  2046. br.Data = resp
  2047. }
  2048. // @Title 活动类型下的主题列表(5.3版本)
  2049. // @Description 获取活动类型下的主题列表接口(5.3版本)
  2050. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  2051. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  2052. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  2053. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  2054. // @Param WhichWeek query string false "哪一周 本周:1 上周:2"
  2055. // @Param WhichMonth query string false "哪一月 本月:1 上月:2"
  2056. // @Param WhichMonth query string false "哪一月 本月:1 上月:2"
  2057. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  2058. // @Success 200 {object} models.ActivityTypeListHomeResp
  2059. // @router /labelTypeListV5 [get]
  2060. func (this *ActivityCoAntroller) LabelTypeListV5() {
  2061. br := new(models.BaseResponse).Init()
  2062. defer func() {
  2063. this.Data["json"] = br
  2064. this.ServeJSON()
  2065. }()
  2066. user := this.User
  2067. if user == nil {
  2068. br.Msg = "请登录"
  2069. br.ErrMsg = "请登录,SysUser Is Empty"
  2070. return
  2071. }
  2072. pageSize, _ := this.GetInt("PageSize")
  2073. isPower, _ := this.GetInt("IsPower")
  2074. chartPermissionIds := this.GetString("ChartPermissionIds")
  2075. whichDay := this.GetString("WhichDay")
  2076. activeState := this.GetString("ActiveState")
  2077. //入参为 undefined 时的处理
  2078. if chartPermissionIds == "undefined" {
  2079. chartPermissionIds = ""
  2080. }
  2081. if whichDay == "undefined" {
  2082. whichDay = ""
  2083. }
  2084. if activeState == "undefined" || activeState == "" {
  2085. activeState = "1"
  2086. }
  2087. // 查研观向7.4-始终查询宏观的活动
  2088. if chartPermissionIds != "" {
  2089. chartPermissionIds += ",1"
  2090. }
  2091. userType, _, err := services.GetUserType(user.CompanyId)
  2092. if err != nil {
  2093. br.Msg = "获取失败"
  2094. br.ErrMsg = "获取失败,Err:" + err.Error()
  2095. return
  2096. }
  2097. var startSize int
  2098. pageSize = 1000
  2099. var sortTime string
  2100. var pars []interface{}
  2101. //活动可见限制
  2102. permissionZhengShiStr, err := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
  2103. if err != nil {
  2104. br.Msg = "获取失败"
  2105. br.ErrMsg = "获取失败,Err:" + err.Error()
  2106. return
  2107. }
  2108. slicePer := strings.Split(permissionZhengShiStr, ",")
  2109. //var permissionSqlStr string
  2110. var permissionNameStr string
  2111. for _, v := range slicePer {
  2112. if userType == 1 {
  2113. //if v != "研选" {
  2114. if !strings.Contains(v, "研选") {
  2115. permissionNameStr += "'" + v + "',"
  2116. }
  2117. } else {
  2118. permissionNameStr += "'" + v + "',"
  2119. }
  2120. }
  2121. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  2122. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  2123. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  2124. // 查研观向7.4-始终查询宏观的权限(无论是否有权限)
  2125. if permissionNameStr == `` {
  2126. permissionNameStr = `'宏观'`
  2127. } else {
  2128. permissionNameStr += `, '宏观'`
  2129. }
  2130. var condition string
  2131. conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
  2132. if err != nil && err.Error() != utils.ErrNoRow() {
  2133. br.Msg = "获取失败"
  2134. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  2135. return
  2136. }
  2137. condition += `AND art.is_limit_people = 1 ` + conditionActivity
  2138. sortTime = ` mintimesort ASC `
  2139. listActivity, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  2140. if err != nil {
  2141. br.Msg = "获取失败"
  2142. br.ErrMsg = "获取失败,Err:" + err.Error()
  2143. return
  2144. }
  2145. mapCity, err := services.GetActivityCityResp()
  2146. if err != nil {
  2147. br.Msg = "获取失败"
  2148. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2149. return
  2150. }
  2151. mapActivity := make(map[int][]*models.CygxActivityLabelList)
  2152. mapkeyWord := make(map[string]string)
  2153. for _, v := range listActivity {
  2154. if v.KeyWord == "" {
  2155. continue
  2156. }
  2157. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  2158. if v.ActivityTypeId == 7 {
  2159. v.ActivityTypeId = 2
  2160. }
  2161. item := new(models.CygxActivityLabelList)
  2162. item.City = mapCity[fmt.Sprint(v.KeyWord, "{|}", v.ActivityTypeId)]
  2163. item.KeyWord = services.LabelStrV5(v.KeyWord, v.IsShowSubjectName, v.TemporaryLabel)
  2164. if _, ok := mapkeyWord[fmt.Sprint(v.ActivityTypeId, "-", item.KeyWord)]; ok {
  2165. continue
  2166. }
  2167. item.Resource = 1
  2168. item.ActivityId = v.ActivityId
  2169. //if v.YidongActivityId > 0 {
  2170. item.IsExternalLabel = v.IsExternalLabel
  2171. //}
  2172. mapActivity[v.ActivityTypeId] = append(mapActivity[v.ActivityTypeId], item)
  2173. mapkeyWord[fmt.Sprint(v.ActivityTypeId, "-", item.KeyWord)] = item.KeyWord
  2174. }
  2175. //
  2176. list, err := models.GetActivityTypeHomeList()
  2177. if err != nil {
  2178. br.Msg = "获取失败"
  2179. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2180. return
  2181. }
  2182. //判断客户规模是否属于可见范围的活动
  2183. //companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  2184. //if err != nil && err.Error() != utils.ErrNoRow() {
  2185. // br.Msg = "获取信息失败"
  2186. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2187. // return
  2188. //}
  2189. //isMaker := user.IsMaker
  2190. //var sqlExport string
  2191. resp := new(models.ActivityTypeListHomeResp)
  2192. for k, v := range list {
  2193. if len(mapActivity[v.ActivityTypeId]) > 0 {
  2194. for _, v2 := range mapActivity[v.ActivityTypeId] {
  2195. v2.ImgUrlBg = v.ImgUrlBgs
  2196. }
  2197. }
  2198. list[k].List = mapActivity[v.ActivityTypeId]
  2199. list[k].Resource = 1
  2200. }
  2201. //获取对应活动的数量并排序
  2202. activityIds := make([]int, 0) // 用于查询活动【新】标签Map
  2203. intArr := make([]int, 0)
  2204. var items []*models.ActivityTypeHome
  2205. for _, v := range list {
  2206. item := new(models.ActivityTypeHome)
  2207. if len(v.List) > 0 {
  2208. for i := range v.List {
  2209. activityIds = append(activityIds, v.List[i].ActivityId)
  2210. }
  2211. item.List = v.List
  2212. item.ActivityTypeName = v.ActivityTypeName
  2213. item.ActivityTypeId = v.ActivityTypeId
  2214. item.ImgUrlBg = v.ImgUrlBg
  2215. item.ImgUrl = v.ImgUrl
  2216. item.Resource = v.Resource
  2217. items = append(items, item)
  2218. intArr = append(intArr, len(v.List))
  2219. }
  2220. }
  2221. sort.Sort(sort.Reverse(sort.IntSlice(intArr)))
  2222. // 活动【新】标签Map
  2223. newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
  2224. if e != nil {
  2225. br.Msg = "获取失败"
  2226. br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
  2227. return
  2228. }
  2229. for k, v := range list {
  2230. if v.ActivityTypeId == 1 {
  2231. for k2 := range list[k].List {
  2232. list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
  2233. }
  2234. }
  2235. }
  2236. var itemsNew []*models.ActivityTypeHome
  2237. activityMap := make(map[int]int)
  2238. for _, v := range intArr {
  2239. for _, v2 := range items {
  2240. item := new(models.ActivityTypeHome)
  2241. if len(v2.List) > 0 && v == len(v2.List) && activityMap[v2.ActivityTypeId] == 0 {
  2242. item.List = v2.List
  2243. item.ActivityTypeName = v2.ActivityTypeName
  2244. item.ActivityTypeId = v2.ActivityTypeId
  2245. item.ImgUrlBg = v2.ImgUrlBg
  2246. item.ImgUrl = v2.ImgUrl
  2247. item.Resource = v2.Resource
  2248. itemsNew = append(itemsNew, item)
  2249. activityMap[v2.ActivityTypeId] = len(v2.List)
  2250. }
  2251. }
  2252. }
  2253. var lenList int
  2254. //按照像素进行排序
  2255. rowHeight := 83 //每一行的行高
  2256. basicsHeight := 178 // 基础高度
  2257. position := 1 // 初始化位置 ,1,左边, 2 右边
  2258. var leftPx, rightPx int
  2259. for k, v := range itemsNew {
  2260. if leftPx <= rightPx {
  2261. position = 1
  2262. } else {
  2263. position = 2
  2264. }
  2265. itemsNew[k].Position = position
  2266. lenList = len(v.List)
  2267. if lenList > 8 {
  2268. lenList = 8
  2269. }
  2270. if position == 1 {
  2271. leftPx += basicsHeight + rowHeight*lenList
  2272. if lenList > 8 {
  2273. lenList = leftPx - 41
  2274. }
  2275. } else {
  2276. rightPx += basicsHeight + rowHeight*lenList
  2277. if lenList > 8 {
  2278. lenList = leftPx - 41
  2279. }
  2280. }
  2281. }
  2282. //查询专项产业调研展示权限 仅对大套餐客户跟永续客户展示
  2283. if whichDay == "" {
  2284. speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
  2285. if err != nil {
  2286. br.Msg = "获取失败"
  2287. br.ErrMsg = "获取失败,Err:" + err.Error()
  2288. return
  2289. }
  2290. if leftPx > rightPx {
  2291. speciaItem.Position = 2
  2292. } else {
  2293. speciaItem.Position = 1
  2294. }
  2295. if len(speciaItem.List) > 0 {
  2296. itemsNew = append(itemsNew, speciaItem)
  2297. }
  2298. }
  2299. //记录用户搜索的筛选条件
  2300. item := new(models.CygxActivitySearchHistory)
  2301. item.UserId = user.UserId
  2302. item.Mobile = user.Mobile
  2303. item.CompanyId = user.CompanyId
  2304. item.CompanyName = user.CompanyName
  2305. item.CreateTime = time.Now()
  2306. item.ChartPermissionIds = chartPermissionIds
  2307. item.IsPower = isPower
  2308. item.WhichDay = whichDay
  2309. go models.AddCygxActivitySearchHistory(item)
  2310. resp.List = itemsNew
  2311. br.Ret = 200
  2312. br.Success = true
  2313. br.Msg = "获取成功"
  2314. br.Data = resp
  2315. }
  2316. // @Title 专项产业调研列表
  2317. // @Description 获取专项产业调研列表接口
  2318. // @Param PageSize query int true "每页数据条数"
  2319. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2320. // @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
  2321. // @router /special/del_list [get]
  2322. func (this *ActivityCoAntroller) SpecialList() {
  2323. br := new(models.BaseResponse).Init()
  2324. defer func() {
  2325. this.Data["json"] = br
  2326. this.ServeJSON()
  2327. }()
  2328. user := this.User
  2329. if user == nil {
  2330. br.Msg = "请登录"
  2331. br.ErrMsg = "请登录,SysUser Is Empty"
  2332. return
  2333. }
  2334. uid := user.UserId
  2335. pageSize, _ := this.GetInt("PageSize")
  2336. currentIndex, _ := this.GetInt("CurrentIndex")
  2337. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2338. var startSize int
  2339. if pageSize <= 0 {
  2340. pageSize = utils.PageSize20
  2341. }
  2342. if currentIndex <= 0 {
  2343. currentIndex = 1
  2344. }
  2345. startSize = utils.StartIndex(currentIndex, pageSize)
  2346. var condition string
  2347. var pars []interface{}
  2348. //活动可见限制
  2349. var sqlExport string
  2350. slicePer := strings.Split(permissionStr, ",")
  2351. var permissionSqlStr string
  2352. for _, v := range slicePer {
  2353. if userType == 1 {
  2354. //if v != "研选" {
  2355. if !strings.Contains(v, "研选") {
  2356. permissionSqlStr += "'" + v + "',"
  2357. }
  2358. } else {
  2359. permissionSqlStr += "'" + v + "',"
  2360. }
  2361. }
  2362. //判断客户规模是否属于可见范围的活动
  2363. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  2364. if err != nil && err.Error() != utils.ErrNoRow() {
  2365. br.Msg = "获取信息失败"
  2366. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2367. return
  2368. }
  2369. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  2370. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  2371. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  2372. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  2373. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  2374. if userType == 2 {
  2375. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  2376. }
  2377. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  2378. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  2379. }
  2380. sqlExport += `) `
  2381. condition += ` AND art.publish_status = 1 `
  2382. condition = ` AND art.publish_status = 1 AND art.label != '' `
  2383. var conditionOr string
  2384. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  2385. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  2386. }
  2387. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  2388. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  2389. }
  2390. if userType == 1 {
  2391. conditionOr += ` OR ( 1=1` + condition + permissionSqlStr + `) `
  2392. }
  2393. if companyProduct != nil {
  2394. if companyProduct.Scale != "" {
  2395. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  2396. }
  2397. }
  2398. if companyProduct != nil {
  2399. if companyProduct.Scale != "" {
  2400. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  2401. }
  2402. }
  2403. condition += sqlExport + conditionOr
  2404. total, err := models.GetActivitySpecialCount(condition, pars)
  2405. if err != nil {
  2406. br.Msg = "获取失败"
  2407. br.ErrMsg = "获取失败,Err:" + err.Error()
  2408. return
  2409. }
  2410. list, errList := models.GetCygxActivitySpecialDetailList(condition, pars, uid, startSize, pageSize)
  2411. if errList != nil {
  2412. br.Msg = "获取失败"
  2413. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2414. return
  2415. }
  2416. detail, err := models.GetConfigByCode("city_img_url")
  2417. if err != nil {
  2418. br.Msg = "获取数据失败"
  2419. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  2420. return
  2421. }
  2422. detailChart, err := models.GetConfigByCode("chart_img_url")
  2423. if err != nil {
  2424. br.Msg = "获取数据失败"
  2425. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  2426. return
  2427. }
  2428. addressList := strings.Split(detail.ConfigValue, "{|}")
  2429. mapAddress := make(map[string]string)
  2430. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  2431. mapChart := make(map[string]string)
  2432. var cityName string
  2433. var chartName string
  2434. var imgUrl string
  2435. var imgUrlChart string
  2436. for _, v := range addressList {
  2437. vslice := strings.Split(v, "_")
  2438. cityName = vslice[0]
  2439. imgUrl = vslice[len(vslice)-1]
  2440. mapAddress[cityName] = imgUrl
  2441. }
  2442. for _, v := range chartList {
  2443. vslice := strings.Split(v, "_")
  2444. chartName = vslice[0]
  2445. imgUrlChart = vslice[len(vslice)-1]
  2446. mapChart[chartName] = imgUrlChart
  2447. }
  2448. for k, v := range list {
  2449. list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  2450. if mapChart[v.ChartPermissionName] != "" {
  2451. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  2452. }
  2453. list[k].ActivityTypeName = "专项调研"
  2454. }
  2455. page := paging.GetPaging(currentIndex, pageSize, total)
  2456. resp := new(models.GetCygxActivitySpecialDetailListResp)
  2457. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  2458. if err != nil {
  2459. br.Msg = "获取数据失败!"
  2460. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2461. return
  2462. }
  2463. if count == 1 && user.UserId > 0 {
  2464. resp.IsFollow = true
  2465. }
  2466. if user.Mobile != "" {
  2467. resp.IsBindingMobile = true
  2468. }
  2469. resp.List = list
  2470. resp.Paging = page
  2471. br.Ret = 200
  2472. br.Success = true
  2473. br.Msg = "获取成功"
  2474. br.Data = resp
  2475. }
  2476. // @Title 专项产业调研详情
  2477. // @Description 获取专项产业调研详情接口
  2478. // @Param ActivityId query int true "活动ID"
  2479. // @Success Ret=200 {object} models.CygxActivitySpecialResp
  2480. // @router /special/detail [get]
  2481. func (this *ActivityCoAntroller) SpecialDetail() {
  2482. br := new(models.BaseResponse).Init()
  2483. defer func() {
  2484. this.Data["json"] = br
  2485. this.ServeJSON()
  2486. }()
  2487. user := this.User
  2488. if user == nil {
  2489. br.Msg = "请登录"
  2490. br.ErrMsg = "请登录,用户信息为空"
  2491. br.Ret = 408
  2492. return
  2493. }
  2494. uid := user.UserId
  2495. activityId, _ := this.GetInt("ActivityId")
  2496. if activityId < 1 {
  2497. br.Msg = "请输入活动ID"
  2498. return
  2499. }
  2500. resp := new(models.CygxActivitySpecialResp)
  2501. hasPermission := 0
  2502. activityInfo, err := models.GetCygxActivitySpecialDetailById(uid, activityId)
  2503. if err != nil && err.Error() != utils.ErrNoRow() {
  2504. br.Msg = "获取信息失败"
  2505. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2506. return
  2507. }
  2508. if activityInfo == nil {
  2509. br.Msg = "活动不存在"
  2510. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  2511. return
  2512. }
  2513. applyCount, err := models.GetApplyRecordCount(uid)
  2514. if err != nil && err.Error() != utils.ErrNoRow() {
  2515. br.Msg = "获取信息失败"
  2516. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2517. return
  2518. }
  2519. //获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
  2520. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  2521. if err != nil && err.Error() != utils.ErrNoRow() {
  2522. br.Msg = "获取信息失败"
  2523. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2524. return
  2525. }
  2526. if user.CompanyId <= 1 {
  2527. //companyDetailStatus = ""
  2528. } else {
  2529. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  2530. if err != nil {
  2531. br.Msg = "获取信息失败"
  2532. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2533. return
  2534. }
  2535. if companyPermission == "" {
  2536. if applyCount > 0 {
  2537. hasPermission = 4
  2538. } else {
  2539. if sellerItem != nil {
  2540. hasPermission = 5
  2541. } else {
  2542. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  2543. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2544. if err != nil && err.Error() != utils.ErrNoRow() {
  2545. br.Msg = "获取信息失败"
  2546. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2547. return
  2548. }
  2549. if sellerItemQy != nil {
  2550. hasPermission = 2
  2551. resp.SellerMobile = sellerItemQy.Mobile
  2552. resp.SellerName = sellerItemQy.RealName
  2553. } else {
  2554. hasPermission = 3
  2555. }
  2556. }
  2557. }
  2558. resp.HasPermission = hasPermission
  2559. resp.OperationMode = "Apply"
  2560. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  2561. br.Ret = 200
  2562. br.Success = true
  2563. br.Msg = "获取成功"
  2564. br.Data = resp
  2565. return
  2566. }
  2567. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  2568. if err != nil {
  2569. br.Msg = "获取信息失败!"
  2570. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2571. return
  2572. }
  2573. if companyDetail == nil {
  2574. br.Msg = "获取信息失败!"
  2575. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  2576. return
  2577. }
  2578. }
  2579. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2580. if err != nil {
  2581. br.Msg = "获取信息失败"
  2582. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2583. return
  2584. }
  2585. itemAct := new(models.ActivityDetail)
  2586. itemAct.CustomerTypeIds = activityInfo.CustomerTypeIds
  2587. noPower, err := services.GetShareNoPowe(itemAct, permissionStr, userType, user)
  2588. if err != nil {
  2589. br.Msg = "获取信息失败"
  2590. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2591. return
  2592. }
  2593. //获取用户的产业规模,判断是否允许可见
  2594. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  2595. if err != nil && err.Error() != utils.ErrNoRow() {
  2596. br.Msg = "获取信息失败"
  2597. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2598. return
  2599. }
  2600. if companyProduct != nil {
  2601. if companyProduct.Scale != "" {
  2602. if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
  2603. noPower = false
  2604. }
  2605. }
  2606. }
  2607. if noPower {
  2608. br.Msg = "您暂无查看该活动权限"
  2609. br.ErrMsg = "被分享客户不可见,获取信息失败"
  2610. br.IsSendEmail = false
  2611. return
  2612. }
  2613. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  2614. br.Msg = "您暂无查看该活动权限"
  2615. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  2616. return
  2617. }
  2618. //判断是否已经申请过
  2619. if user.CompanyId > 1 {
  2620. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  2621. if err != nil {
  2622. br.Msg = "获取信息失败"
  2623. br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
  2624. return
  2625. }
  2626. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  2627. //冻结客户
  2628. if err != nil {
  2629. if err.Error() == utils.ErrNoRow() {
  2630. if applyCount > 0 {
  2631. hasPermission = 4
  2632. } else {
  2633. if sellerItem != nil {
  2634. hasPermission = 5
  2635. } else {
  2636. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  2637. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2638. if err != nil && err.Error() != utils.ErrNoRow() {
  2639. br.Msg = "获取信息失败"
  2640. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2641. return
  2642. }
  2643. if sellerItemQy != nil {
  2644. hasPermission = 2
  2645. resp.SellerMobile = sellerItemQy.Mobile
  2646. resp.SellerName = sellerItemQy.RealName
  2647. } else {
  2648. hasPermission = 3
  2649. }
  2650. }
  2651. }
  2652. resp.HasPermission = hasPermission
  2653. resp.OperationMode = "Apply"
  2654. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  2655. br.Ret = 200
  2656. br.Success = true
  2657. br.Msg = "获取成功"
  2658. br.Data = resp
  2659. return
  2660. } else {
  2661. br.Msg = "获取信息失败"
  2662. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  2663. return
  2664. }
  2665. }
  2666. var havePower bool
  2667. if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
  2668. havePower = true
  2669. }
  2670. if havePower {
  2671. hasPermission = 1
  2672. resp.HaqveJurisdiction = true
  2673. } else {
  2674. if permissionStr == "专家" {
  2675. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  2676. resp.MsgType = "Type"
  2677. } else {
  2678. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  2679. resp.MsgType = "Industry"
  2680. }
  2681. if companyItem.ProductId == 2 {
  2682. resp.SellerMobile = companyItem.Mobile
  2683. resp.SellerName = companyItem.SellerName
  2684. resp.OperationMode = "Call"
  2685. hasPermission = 2
  2686. } else {
  2687. hasPermission = 5
  2688. }
  2689. }
  2690. } else { //潜在客户
  2691. if applyCount > 0 {
  2692. hasPermission = 4
  2693. } else {
  2694. if sellerItem != nil {
  2695. hasPermission = 5
  2696. } else {
  2697. hasPermission = 3
  2698. }
  2699. }
  2700. resp.OperationMode = "Apply"
  2701. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  2702. }
  2703. if hasPermission == 1 {
  2704. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  2705. if err != nil {
  2706. br.Msg = "获取数据失败!"
  2707. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2708. return
  2709. }
  2710. if count == 1 {
  2711. resp.IsFollow = true
  2712. }
  2713. activityInfo.ActivityTypeName = "专项调研"
  2714. resp.Detail = activityInfo
  2715. }
  2716. resp.HasPermission = hasPermission
  2717. br.Ret = 200
  2718. br.Success = true
  2719. br.Msg = "获取成功"
  2720. br.Data = resp
  2721. }
  2722. // @Title 感兴趣、不感兴趣
  2723. // @Description 感兴趣、不感兴趣接口
  2724. // @Param request body models.ActivityIdRep true "type json string"
  2725. // @Success Ret=200 {object} models.SignupSpecialStatus
  2726. // @router /special/signup/add [post]
  2727. func (this *ActivityCoAntroller) SpecialSignupAdd() {
  2728. br := new(models.BaseResponse).Init()
  2729. defer func() {
  2730. this.Data["json"] = br
  2731. this.ServeJSON()
  2732. }()
  2733. user := this.User
  2734. if user == nil {
  2735. br.Msg = "请登录"
  2736. br.ErrMsg = "请登录,用户信息为空"
  2737. br.Ret = 408
  2738. return
  2739. }
  2740. uid := user.UserId
  2741. var req models.ActivityIdRep
  2742. resp := new(models.SignupSpecialStatus)
  2743. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2744. if err != nil {
  2745. br.Msg = "参数解析异常!"
  2746. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2747. return
  2748. }
  2749. activityId := req.ActivityId
  2750. activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
  2751. if activityInfo == nil {
  2752. br.Msg = "操作失败"
  2753. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2754. return
  2755. }
  2756. if errInfo != nil {
  2757. br.Msg = "操作失败"
  2758. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2759. return
  2760. }
  2761. havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
  2762. if err != nil {
  2763. br.Msg = "获取信息失败"
  2764. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2765. return
  2766. }
  2767. //判断有没有对应的权限,如果没有则给出对应的状态码
  2768. if havePower {
  2769. resp.HasPermission = 1
  2770. total, err := models.GetUserCygxActivitySpecialSignup(user.UserId, activityId)
  2771. if err != nil {
  2772. br.Msg = "获取信息失败"
  2773. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  2774. return
  2775. }
  2776. resp.SignupStatus = 1
  2777. //判断是删除还是添加
  2778. if total == 0 {
  2779. //获取销售信息
  2780. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2781. if err != nil {
  2782. br.Msg = "操作失败"
  2783. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2784. return
  2785. }
  2786. item := new(models.CygxActivitySpecialSignup)
  2787. item.UserId = uid
  2788. item.RealName = user.RealName
  2789. item.ActivityId = activityId
  2790. item.CreateTime = time.Now()
  2791. item.Mobile = user.Mobile
  2792. item.Email = user.Email
  2793. item.CompanyId = user.CompanyId
  2794. item.CompanyName = user.CompanyName
  2795. if sellerItem != nil {
  2796. item.SellerName = sellerItem.RealName
  2797. }
  2798. err = models.AddCygxActivitySpecialSignup(item)
  2799. if err != nil {
  2800. br.Msg = "操作失败"
  2801. br.ErrMsg = "操作失败,Err:" + err.Error()
  2802. return
  2803. }
  2804. resp.Status = 1
  2805. resp.PopupMsg = "感谢反馈"
  2806. resp.PopupMsg2 = "此调研具体行程尚未确认,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确认行程中再次报名才完成占位。"
  2807. //给所属销售发送消息
  2808. //if sellerItem.Mobile != "" {
  2809. // openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  2810. // if openIpItem != nil && openIpItem.OpenId != "" {
  2811. // if sellerItem != nil {
  2812. // go services.SendSpecialTemplateMsg(user.RealName+"【"+user.CompanyName+"】", time.Now().Format(utils.FormatDateTime), user.Mobile, activityInfo.ResearchTheme, "sale", openIpItem)
  2813. // }
  2814. // }
  2815. //}
  2816. // 给芳姐发消息
  2817. //cnf, _ := models.GetConfigByCode("tpl_msg")
  2818. actList, _ := models.GetActivityListSpecialByActivityId(activityId)
  2819. //if cnf != nil {
  2820. // openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
  2821. // if openIpItem != nil && openIpItem.OpenId != "" {
  2822. // if len(actList) == 5 {
  2823. // var companyName string
  2824. // for _, v := range actList {
  2825. // companyName += "【" + v.CompanyName + "】"
  2826. // }
  2827. // go services.SendSpecialTemplateMsg(companyName, "", "", activityInfo.ResearchTheme, "", openIpItem)
  2828. // }
  2829. // }
  2830. //}
  2831. //感兴趣人数到达10人时,模板消息发送给活动负责人
  2832. if len(actList) == 10 {
  2833. go services.SendWxMsgActivitySpecial10(activityInfo)
  2834. }
  2835. //用户专项调研操作行为,模板消息推送
  2836. //go services.SpecialActivityUserRemind(user, activityInfo, 1)
  2837. //用户相关行为,给对应销售发模板消息
  2838. go services.ActivitySpecialUserRmind(user, activityId, 1)
  2839. } else {
  2840. err = models.DeleteCygxActivitySpecialSignup(user.UserId, activityId)
  2841. if err != nil {
  2842. br.Msg = "操作失败"
  2843. br.ErrMsg = "操作失败,Err:" + err.Error()
  2844. return
  2845. }
  2846. resp.Status = 2
  2847. }
  2848. } else {
  2849. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2850. if err != nil {
  2851. br.Msg = "获取信息失败"
  2852. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2853. return
  2854. }
  2855. resp.PopupMsg = popupMsg
  2856. resp.HasPermission = hasPermission
  2857. resp.SellerName = sellerName
  2858. resp.SellerMobile = sellerMobile
  2859. }
  2860. br.Ret = 200
  2861. br.Success = true
  2862. br.Msg = "操作成功"
  2863. br.Data = resp
  2864. }
  2865. // @Title 新调研通知取消跟添加
  2866. // @Description 新调研通知取消跟添加接口
  2867. // @Param request body models.ArticleCollectResp true "type json string"
  2868. // @Success 200
  2869. // @router /special/follow [post]
  2870. func (this *ActivityCoAntroller) SpecialMsg() {
  2871. br := new(models.BaseResponse).Init()
  2872. defer func() {
  2873. this.Data["json"] = br
  2874. this.ServeJSON()
  2875. }()
  2876. user := this.User
  2877. if user == nil {
  2878. br.Msg = "请重新登录"
  2879. br.Ret = 408
  2880. return
  2881. }
  2882. resp := new(models.ArticleCollectResp)
  2883. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  2884. if err != nil {
  2885. br.Msg = "获取数据失败!"
  2886. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2887. return
  2888. }
  2889. if count == 0 {
  2890. item := new(models.CygxUserFollowSpecial)
  2891. item.UserId = user.UserId
  2892. item.RealName = user.RealName
  2893. item.CreateTime = time.Now()
  2894. item.Mobile = user.Mobile
  2895. item.Email = user.Email
  2896. item.CompanyId = user.CompanyId
  2897. item.CompanyName = user.CompanyName
  2898. item.CreateTime = time.Now()
  2899. err := models.AddUserFollowSpecial(item)
  2900. if err != nil {
  2901. br.Msg = "操作失败!"
  2902. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2903. return
  2904. }
  2905. resp.Status = 1
  2906. } else {
  2907. err := models.DeleteCygxUserFollowSpecial(user.UserId)
  2908. if err != nil {
  2909. br.Msg = "操作失败!"
  2910. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2911. return
  2912. }
  2913. resp.Status = 2
  2914. }
  2915. br.Ret = 200
  2916. br.Data = resp
  2917. br.Success = true
  2918. br.Msg = "操作成功!"
  2919. }
  2920. // @Title 活动类型下的主题列表(6.0Pc版本)
  2921. // @Description 获取活动类型下的主题列表接口(6.0Pc版本)
  2922. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  2923. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  2924. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  2925. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  2926. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  2927. // @Success 200 {object} models.ActivityTypeListHomeRespPc
  2928. // @router /labelTypeListV6Pc [get]
  2929. func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
  2930. br := new(models.BaseResponse).Init()
  2931. defer func() {
  2932. this.Data["json"] = br
  2933. this.ServeJSON()
  2934. }()
  2935. user := this.User
  2936. if user == nil {
  2937. br.Msg = "请登录"
  2938. br.ErrMsg = "请登录,SysUser Is Empty"
  2939. return
  2940. }
  2941. pageSize, _ := this.GetInt("PageSize")
  2942. isPower, _ := this.GetInt("IsPower")
  2943. playBack, _ := this.GetInt("PlayBack")
  2944. //currentIndex, _ := this.GetInt("CurrentIndex")
  2945. chartPermissionIds := this.GetString("ChartPermissionIds")
  2946. //activityTypeIds := this.GetString("ActivityTypeIds")
  2947. whichDay := this.GetString("WhichDay")
  2948. activeState := this.GetString("ActiveState")
  2949. //入参为 undefined 时的处理
  2950. if chartPermissionIds == "undefined" {
  2951. chartPermissionIds = ""
  2952. }
  2953. // 查研观向7.4-始终查询宏观的活动
  2954. if chartPermissionIds != "" {
  2955. chartPermissionIds += ",1"
  2956. }
  2957. if whichDay == "undefined" {
  2958. whichDay = ""
  2959. }
  2960. if activeState == "undefined" || activeState == "" || activeState == "1" {
  2961. activeState = "1,2"
  2962. }
  2963. //adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
  2964. //if err != nil {
  2965. // br.Msg = "获取失败"
  2966. // br.ErrMsg = "获取本组下的销售失败,Err:" + err.Error()
  2967. // return
  2968. //}
  2969. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2970. if err != nil {
  2971. br.Msg = "获取失败"
  2972. br.ErrMsg = "获取失败,Err:" + err.Error()
  2973. return
  2974. }
  2975. //isMaker := user.IsMaker
  2976. var startSize int
  2977. pageSize = 8
  2978. var sortTime string
  2979. var pars []interface{}
  2980. //活动可见限制
  2981. slicePer := strings.Split(permissionStr, ",")
  2982. var permissionNameStr string
  2983. for _, v := range slicePer {
  2984. if userType == 1 {
  2985. //if v != "研选" {
  2986. if !strings.Contains(v, "研选") {
  2987. permissionNameStr += "'" + v + "',"
  2988. }
  2989. } else {
  2990. permissionNameStr += "'" + v + "',"
  2991. }
  2992. }
  2993. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  2994. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  2995. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  2996. // 查研观向7.4-始终查询宏观的权限(无论是否有权限)
  2997. if permissionNameStr == `` {
  2998. permissionNameStr = `'宏观'`
  2999. } else {
  3000. permissionNameStr += `, '宏观'`
  3001. }
  3002. list, err := models.GetActivityTypeHomeListPc()
  3003. if err != nil {
  3004. br.Msg = "获取失败"
  3005. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  3006. return
  3007. }
  3008. //判断客户规模是否属于可见范围的活动
  3009. //companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3010. //if err != nil && err.Error() != utils.ErrNoRow() {
  3011. // br.Msg = "获取信息失败"
  3012. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3013. // return
  3014. //}
  3015. var sqlExport string
  3016. //处理专家权限的查询
  3017. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  3018. if userType == 2 {
  3019. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  3020. }
  3021. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  3022. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  3023. }
  3024. sqlExport += `) `
  3025. resp := new(models.ActivityTypeListHomeRespPc)
  3026. for k, v := range list {
  3027. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  3028. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  3029. continue
  3030. }
  3031. var condition string
  3032. conditionActivity, err := services.GetActivityonditionList(user, strconv.Itoa(v.ActivityTypeId), chartPermissionIds, whichDay, activeState, "", isPower, 1, "", playBack, 1)
  3033. if err != nil && err.Error() != utils.ErrNoRow() {
  3034. br.Msg = "获取失败"
  3035. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  3036. return
  3037. }
  3038. //condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  3039. condition += `AND art.is_limit_people = 1 AND art.yidong_activity_id = '' ` + conditionActivity
  3040. sortTime = ` mintimesort ASC `
  3041. labelList, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  3042. if err != nil {
  3043. br.Msg = "获取失败"
  3044. br.ErrMsg = "获取失败,Err:" + err.Error()
  3045. return
  3046. }
  3047. //标签字段关联的产业与标签处理
  3048. for k2, v2 := range labelList {
  3049. labelList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
  3050. labelList[k2].Resource = 1
  3051. }
  3052. list[k].List = labelList
  3053. list[k].Resource = 1
  3054. }
  3055. if whichDay == "" {
  3056. //查询专项产业调研展示权限
  3057. //var scale string
  3058. //if companyProduct != nil {
  3059. // scale = companyProduct.Scale
  3060. //}
  3061. speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
  3062. if err != nil {
  3063. br.Msg = "获取失败"
  3064. br.ErrMsg = "获取失败,Err:" + err.Error()
  3065. return
  3066. }
  3067. if len(speciaItem.List) > 0 {
  3068. itemList := new(models.ActivityTypeHomePc)
  3069. itemList.ActivityTypeName = "专项产业调研"
  3070. itemList.Resource = 2
  3071. itemList.List = speciaItem.List
  3072. itemList.ActivityTypeId = 7
  3073. itemList.OnlineIco = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/0H4md6VgZMuIttggMUnJxgrlayxC.png"
  3074. itemList.ImgUrlBgPc = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
  3075. list = append(list, itemList)
  3076. }
  3077. }
  3078. // 查研观向7.4-活动【新】标签
  3079. activityIds := make([]int, 0)
  3080. for _, v := range list {
  3081. if len(v.List) > 0 {
  3082. for i := range v.List {
  3083. activityIds = append(activityIds, v.List[i].ActivityId)
  3084. }
  3085. }
  3086. }
  3087. newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
  3088. if e != nil {
  3089. br.Msg = "获取失败"
  3090. br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
  3091. return
  3092. }
  3093. for k := range list {
  3094. for k2 := range list[k].List {
  3095. list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
  3096. }
  3097. }
  3098. //记录用户搜索的筛选条件
  3099. {
  3100. item := new(models.CygxActivitySearchHistory)
  3101. item.UserId = user.UserId
  3102. item.Mobile = user.Mobile
  3103. item.CompanyId = user.CompanyId
  3104. item.CompanyName = user.CompanyName
  3105. item.CreateTime = time.Now()
  3106. item.ChartPermissionIds = chartPermissionIds
  3107. item.IsPower = isPower
  3108. item.WhichDay = whichDay
  3109. go models.AddCygxActivitySearchHistory(item)
  3110. }
  3111. resp.List = list
  3112. br.Ret = 200
  3113. br.Success = true
  3114. br.Msg = "获取成功"
  3115. br.Data = resp
  3116. }
  3117. // @Title 预约纪要
  3118. // @Description 预约纪要接口
  3119. // @Param request body models.ActivityIdRep true "type json string"
  3120. // @Success Ret=200 {object} models.AppointmentResp
  3121. // @router /appointment/add [post]
  3122. func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
  3123. br := new(models.BaseResponse).Init()
  3124. defer func() {
  3125. this.Data["json"] = br
  3126. this.ServeJSON()
  3127. }()
  3128. user := this.User
  3129. if user == nil {
  3130. br.Msg = "请登录"
  3131. br.ErrMsg = "请登录,用户信息为空"
  3132. br.Ret = 408
  3133. return
  3134. }
  3135. uid := user.UserId
  3136. signupStatus := "Success"
  3137. var req models.ActivityIdRep
  3138. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3139. if err != nil {
  3140. br.Msg = "参数解析异常!"
  3141. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3142. return
  3143. }
  3144. activityId := req.ActivityId
  3145. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  3146. if activityInfo == nil {
  3147. br.Msg = "操作失败"
  3148. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  3149. return
  3150. }
  3151. if errInfo != nil {
  3152. br.Msg = "操作失败"
  3153. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3154. return
  3155. }
  3156. //判断是否已经预约过
  3157. totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  3158. if err != nil {
  3159. br.Msg = "获取失败"
  3160. br.ErrMsg = "获取失败,Err:" + err.Error()
  3161. return
  3162. }
  3163. if totalAppointment > 0 {
  3164. br.Msg = "您已预约!"
  3165. return
  3166. }
  3167. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  3168. item := new(models.CygxActivityAppointment)
  3169. resp := new(models.SignupStatus)
  3170. hasPermission := 0
  3171. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  3172. if err != nil {
  3173. br.Msg = "获取信息失败"
  3174. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  3175. return
  3176. }
  3177. if havePower {
  3178. hasPermission = 1
  3179. signupStatus = "Success"
  3180. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  3181. if errMeeting != nil {
  3182. br.Msg = "获取失败"
  3183. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  3184. return
  3185. }
  3186. if totalMeeting > 0 {
  3187. br.Msg = "您已预约,请勿重复预约"
  3188. return
  3189. }
  3190. var sellerName string
  3191. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3192. if err != nil {
  3193. br.Msg = "报名失败!"
  3194. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3195. return
  3196. }
  3197. item.UserId = uid
  3198. item.ActivityId = activityId
  3199. item.CreateTime = time.Now()
  3200. item.Mobile = user.Mobile
  3201. item.Email = user.Email
  3202. item.CompanyId = user.CompanyId
  3203. item.CompanyName = user.CompanyName
  3204. item.SellerName = sellerName
  3205. item.RealName = user.RealName
  3206. err = models.AddCygxActivityAppointment(item)
  3207. if err != nil {
  3208. br.Msg = "操作失败"
  3209. br.ErrMsg = "操作失败,Err:" + err.Error()
  3210. return
  3211. }
  3212. resp.HaqveJurisdiction = true
  3213. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  3214. go services.ActivityUserRemind(user, activityInfo, 3)
  3215. resp.HasPermission = hasPermission
  3216. resp.SignupStatus = signupStatus
  3217. } else {
  3218. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  3219. if err != nil {
  3220. br.Msg = "获取信息失败"
  3221. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3222. return
  3223. }
  3224. resp.PopupMsg = popupMsg
  3225. resp.HasPermission = hasPermission
  3226. resp.SellerName = sellerName
  3227. resp.SellerMobile = sellerMobile
  3228. }
  3229. // 判断是否属于研选类型的活动
  3230. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  3231. resp.IsResearch = true
  3232. }
  3233. resp.ActivityId = activityId
  3234. var total int
  3235. total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
  3236. if err != nil {
  3237. br.Msg = "获取信息失败"
  3238. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  3239. return
  3240. }
  3241. if total <= 1 {
  3242. resp.GoFollow = true
  3243. }
  3244. br.Ret = 200
  3245. br.Success = true
  3246. if hasPermission == 1 {
  3247. br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  3248. resp.PopupMsg = "会议纪要预约成功<br/><br/>请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  3249. }
  3250. br.Data = resp
  3251. }
  3252. // @Title 取消预约纪要
  3253. // @Description 取消预约纪要接口
  3254. // @Param request body models.ActivityIdRep true "type json string"
  3255. // @Success Ret=200 {object} models.SignupStatus
  3256. // @router /appointment/cancel [post]
  3257. func (this *ActivityCoAntroller) ActivityAppointmentCancel() {
  3258. br := new(models.BaseResponse).Init()
  3259. defer func() {
  3260. this.Data["json"] = br
  3261. this.ServeJSON()
  3262. }()
  3263. user := this.User
  3264. if user == nil {
  3265. br.Msg = "请登录"
  3266. br.ErrMsg = "请登录,用户信息为空"
  3267. br.Ret = 408
  3268. return
  3269. }
  3270. uid := user.UserId
  3271. var req models.ActivityIdRep
  3272. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3273. if err != nil {
  3274. br.Msg = "参数解析异常!"
  3275. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3276. return
  3277. }
  3278. activityId := req.ActivityId
  3279. signupStatus := "Success"
  3280. item := new(models.CygxActivityAppointment)
  3281. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  3282. if activityInfo == nil {
  3283. br.Msg = "操作失败"
  3284. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  3285. return
  3286. }
  3287. if errInfo != nil {
  3288. br.Msg = "操作失败"
  3289. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3290. return
  3291. }
  3292. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  3293. if err != nil {
  3294. br.Msg = "获取失败"
  3295. br.ErrMsg = "获取失败,Err:" + err.Error()
  3296. return
  3297. }
  3298. if total == 0 {
  3299. br.Msg = "您暂未预约该纪要"
  3300. return
  3301. }
  3302. item.UserId = uid
  3303. item.ActivityId = activityId
  3304. item.CreateTime = time.Now()
  3305. item.Mobile = user.Mobile
  3306. item.Email = user.Email
  3307. item.CompanyId = user.CompanyId
  3308. item.CompanyName = user.CompanyName
  3309. _, errSignup := models.CancelcygxActivityAppointment(item)
  3310. if errSignup != nil {
  3311. br.Msg = "操作失败"
  3312. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  3313. return
  3314. }
  3315. resp := new(models.SignupStatus)
  3316. resp.SignupStatus = signupStatus
  3317. resp.ActivityId = activityId
  3318. br.Ret = 200
  3319. br.Success = true
  3320. br.Msg = "已取消"
  3321. br.Data = resp
  3322. }
  3323. // @Title 记录用户浏览音频回放接口
  3324. // @Description 记录用户浏览音频回放接口
  3325. // @Param request body models.ActivityIdRep true "type json string"
  3326. // @Success Ret=200 {object} models.AppointmentResp
  3327. // @router /voiceHistory/add [post]
  3328. func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
  3329. br := new(models.BaseResponse).Init()
  3330. defer func() {
  3331. this.Data["json"] = br
  3332. this.ServeJSON()
  3333. }()
  3334. user := this.User
  3335. if user == nil {
  3336. br.Msg = "请登录"
  3337. br.ErrMsg = "请登录,用户信息为空"
  3338. br.Ret = 408
  3339. return
  3340. }
  3341. uid := user.UserId
  3342. var req models.ActivityIdRep
  3343. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3344. if err != nil {
  3345. br.Msg = "参数解析异常!"
  3346. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3347. return
  3348. }
  3349. activityId := req.ActivityId
  3350. playSeconds := req.PlaySeconds
  3351. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  3352. if activityInfo == nil {
  3353. br.Msg = "操作失败"
  3354. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  3355. return
  3356. }
  3357. if errInfo != nil {
  3358. br.Msg = "操作失败"
  3359. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3360. return
  3361. }
  3362. var sellerName string
  3363. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3364. if err != nil {
  3365. br.Msg = "报名失败!"
  3366. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3367. return
  3368. }
  3369. item := models.CygxActivityVoiceHistory{
  3370. ActivityId: activityId,
  3371. UserId: uid,
  3372. CreateTime: time.Now(),
  3373. Mobile: user.Mobile,
  3374. Email: user.Email,
  3375. CompanyId: user.CompanyId,
  3376. CompanyName: user.CompanyName,
  3377. RealName: user.RealName,
  3378. SellerName: sellerName,
  3379. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3380. ModifyTime: time.Now(),
  3381. }
  3382. if playSeconds != 0 {
  3383. lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
  3384. if err != nil {
  3385. br.Msg = "操作失败"
  3386. br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
  3387. return
  3388. }
  3389. err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3390. if err != nil {
  3391. br.Msg = "更新失败"
  3392. br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
  3393. return
  3394. }
  3395. } else {
  3396. err = models.AddCygxActivityVoiceHistory(&item)
  3397. if err != nil {
  3398. br.Msg = "操作失败"
  3399. br.ErrMsg = "操作失败,Err:" + err.Error()
  3400. return
  3401. }
  3402. err = models.UpdateCygxActivityVoiceCounts(activityId)
  3403. if err != nil {
  3404. br.Msg = "更新失败"
  3405. br.ErrMsg = "更新失败,Err:" + err.Error()
  3406. return
  3407. }
  3408. go services.ActivityVideoUserRmind(user, activityId, 2)
  3409. }
  3410. br.Ret = 200
  3411. br.Success = true
  3412. br.Msg = "操作成功"
  3413. return
  3414. }
  3415. // @Title 记录用户浏览视频回放接口
  3416. // @Description 记录用户浏览音频回放接口
  3417. // @Param request body models.ActivityIdRep true "type json string"
  3418. // @Success Ret=200 {object} models.AppointmentResp
  3419. // @router /videoHistory/add [post]
  3420. func (this *ActivityCoAntroller) ActivityVideoHistoryAdd() {
  3421. br := new(models.BaseResponse).Init()
  3422. defer func() {
  3423. this.Data["json"] = br
  3424. this.ServeJSON()
  3425. }()
  3426. user := this.User
  3427. if user == nil {
  3428. br.Msg = "请登录"
  3429. br.ErrMsg = "请登录,用户信息为空"
  3430. br.Ret = 408
  3431. return
  3432. }
  3433. uid := user.UserId
  3434. var req models.ActivityIdRep
  3435. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3436. if err != nil {
  3437. br.Msg = "参数解析异常!"
  3438. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3439. return
  3440. }
  3441. activityId := req.ActivityId
  3442. activityInfo, errInfo := models.GetCygxActivityVideoByActivityId(activityId)
  3443. if activityInfo == nil {
  3444. br.Msg = "操作失败"
  3445. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  3446. return
  3447. }
  3448. if errInfo != nil {
  3449. br.Msg = "操作失败"
  3450. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3451. return
  3452. }
  3453. var sellerName string
  3454. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3455. if err != nil {
  3456. br.Msg = "报名失败!"
  3457. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3458. return
  3459. }
  3460. item := models.CygxActivityVideoHistory{
  3461. ActivityId: activityId,
  3462. VideoId: activityInfo.VideoId,
  3463. UserId: uid,
  3464. CreateTime: time.Now(),
  3465. Mobile: user.Mobile,
  3466. Email: user.Email,
  3467. CompanyId: user.CompanyId,
  3468. CompanyName: user.CompanyName,
  3469. RealName: user.RealName,
  3470. SellerName: sellerName,
  3471. ModifyTime: time.Now(),
  3472. }
  3473. err = models.AddCygxActivityVideoHistory(&item)
  3474. if err != nil {
  3475. br.Msg = "操作失败"
  3476. br.ErrMsg = "操作失败,Err:" + err.Error()
  3477. return
  3478. }
  3479. err = models.UpdateActivityVideoCounts(activityId)
  3480. if err != nil {
  3481. br.Msg = "更新失败"
  3482. br.ErrMsg = "更新失败,Err:" + err.Error()
  3483. return
  3484. }
  3485. br.Ret = 200
  3486. br.Success = true
  3487. br.Msg = "操作成功"
  3488. return
  3489. }
  3490. // @Title 活动、专项调研搜索
  3491. // @Description 活动、专项调研搜索接口
  3492. // @Param PageSize query int true "每页数据条数"
  3493. // @Param CurrentIndex query int true "当前页页码,从1开始"
  3494. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  3495. // @Success 200 {object} models.GetCygxActivityListRep
  3496. // @router /listSearch [get]
  3497. func (this *ActivityCoAntroller) ActivityListSearch() {
  3498. br := new(models.BaseResponse).Init()
  3499. defer func() {
  3500. this.Data["json"] = br
  3501. this.ServeJSON()
  3502. }()
  3503. user := this.User
  3504. if user == nil {
  3505. br.Msg = "请登录"
  3506. br.ErrMsg = "请登录,SysUser Is Empty"
  3507. return
  3508. }
  3509. pageSize, _ := this.GetInt("PageSize")
  3510. currentIndex, _ := this.GetInt("CurrentIndex")
  3511. source, _ := this.GetInt("Source")
  3512. keyWord := this.GetString("KeyWord")
  3513. playBack, _ := this.GetInt("PlayBack")
  3514. var startSize int
  3515. if pageSize <= 0 {
  3516. pageSize = utils.PageSize20
  3517. }
  3518. if currentIndex <= 0 {
  3519. currentIndex = 1
  3520. }
  3521. startSize = utils.StartIndex(currentIndex, pageSize)
  3522. var condition string
  3523. //活动可见限制
  3524. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "", "", 0, 1, keyWord, playBack, 1)
  3525. if err != nil && err.Error() != utils.ErrNoRow() {
  3526. br.Msg = "获取失败"
  3527. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  3528. return
  3529. }
  3530. if source == 1 {
  3531. condition += ` AND art.yidong_activity_id = '' `
  3532. }
  3533. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  3534. list, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, keyWord)
  3535. if err != nil {
  3536. br.Msg = "获取失败"
  3537. br.ErrMsg = "获取失败,Err:" + err.Error()
  3538. return
  3539. }
  3540. page := paging.GetPaging(currentIndex, pageSize, total)
  3541. resp := new(models.GetCygxActivityListRep)
  3542. //添加活动搜索记录
  3543. if keyWord != "" {
  3544. go services.AddActivitykeyWordSearch(keyWord, user)
  3545. }
  3546. resp.Paging = page
  3547. resp.List = list
  3548. br.Ret = 200
  3549. br.Success = true
  3550. br.Msg = "获取成功"
  3551. br.Data = resp
  3552. }
  3553. // @Title 已结束的活动
  3554. // @Description 获取已结束的活动接口
  3555. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  3556. // @Param WhichDay query string false "哪一天 3本周、4上周,5本月,6上月 可多选"
  3557. // @Param IsPower query string false "是否选择有权限行业 ,1是 0 否 默认0"
  3558. // @Param TypeName query string false "电话会类型 ,1专家电话会 2分析师电话会"
  3559. // @Success 200 {object} models.GetCygxActivityLabelListRep
  3560. // @router /overActivityList [get]
  3561. func (this *ActivityCoAntroller) OverActivityList() {
  3562. br := new(models.BaseResponse).Init()
  3563. defer func() {
  3564. this.Data["json"] = br
  3565. this.ServeJSON()
  3566. }()
  3567. user := this.User
  3568. if user == nil {
  3569. br.Msg = "请登录"
  3570. br.ErrMsg = "请登录,SysUser Is Empty"
  3571. return
  3572. }
  3573. isPower, _ := this.GetInt("IsPower")
  3574. chartPermissionIds := this.GetString("ChartPermissionIds")
  3575. whichDay := this.GetString("WhichDay")
  3576. fmt.Println("whichDay:", whichDay)
  3577. typeName := this.GetString("TypeName")
  3578. //入参为 undefined 时的处理
  3579. if chartPermissionIds == "undefined" {
  3580. chartPermissionIds = ""
  3581. }
  3582. if whichDay == "undefined" {
  3583. whichDay = ""
  3584. }
  3585. resp := new(models.GetCygxActivityLabelListRep)
  3586. if user.CompanyId <= 1 {
  3587. resp.List = make([]*models.CygxActivityLabelList, 0)
  3588. br.Ret = 200
  3589. br.Success = true
  3590. br.Msg = "获取成功"
  3591. br.Data = resp
  3592. return
  3593. }
  3594. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  3595. if err != nil {
  3596. br.Msg = "获取失败"
  3597. br.ErrMsg = "获取失败,Err:" + err.Error()
  3598. return
  3599. }
  3600. //var startSize, pageSize int
  3601. //pageSize = 24
  3602. var condition string
  3603. var conditionSpecial string
  3604. var sortTime string
  3605. //var conditionStatus string
  3606. var pars []interface{}
  3607. //活动可见限制
  3608. var sqlExport string
  3609. slicePer := strings.Split(permissionStr, ",")
  3610. var permissionSqlStr string
  3611. for _, v := range slicePer {
  3612. if userType == 1 {
  3613. //if v != "研选" {
  3614. if !strings.Contains(v, "研选") {
  3615. permissionSqlStr += "'" + v + "',"
  3616. }
  3617. } else {
  3618. permissionSqlStr += "'" + v + "',"
  3619. }
  3620. }
  3621. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  3622. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  3623. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  3624. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  3625. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  3626. if userType == 2 {
  3627. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  3628. }
  3629. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  3630. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  3631. }
  3632. sqlExport += `) `
  3633. //已结束的活动
  3634. var conditionOr string
  3635. conditionOr = ""
  3636. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 3 `
  3637. if isPower == 1 {
  3638. condition += permissionSqlStr + sqlExport + conditionOr
  3639. }
  3640. if whichDay != "" {
  3641. var startDate string
  3642. var endDate string
  3643. if whichDay == "3" {
  3644. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  3645. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  3646. } else if whichDay == "4" {
  3647. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  3648. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  3649. } else if whichDay == "5" {
  3650. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  3651. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  3652. } else if whichDay == "6" {
  3653. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  3654. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  3655. } else if whichDay == "3,4" {
  3656. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  3657. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  3658. } else if whichDay == "5,6" {
  3659. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  3660. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  3661. } else {
  3662. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  3663. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  3664. }
  3665. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  3666. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  3667. conditionSpecial += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  3668. conditionSpecial += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  3669. }
  3670. if len(chartPermissionIds) > 0 {
  3671. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  3672. }
  3673. conditionActivity, err := services.GetActivityonditionList(user, typeName, chartPermissionIds, whichDay, "3", "", 0, 0, "", 0, 1)
  3674. if err != nil && err.Error() != utils.ErrNoRow() {
  3675. br.Msg = "获取失败"
  3676. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  3677. return
  3678. }
  3679. //已结束的活动
  3680. sortTime = ` activity_time DESC `
  3681. //如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
  3682. companyDetail, err := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
  3683. if err != nil {
  3684. br.Msg = "获取失败"
  3685. br.ErrMsg = "获取失败,Err:" + err.Error()
  3686. return
  3687. }
  3688. if companyDetail.Status == "永续" {
  3689. conditionSpecial, err = services.HandleActivityLabelSpecialPermission(user)
  3690. } else {
  3691. conditionSpecial, _, err = services.HandleActivityLabelSpecialTripPermission(user)
  3692. }
  3693. if err != nil {
  3694. br.Msg = "获取失败"
  3695. br.ErrMsg = "获取失败,Err:" + err.Error()
  3696. return
  3697. }
  3698. conditionSpecial += ` AND art.days >0 AND art.publish_status =1 AND art.is_offline = 0 `
  3699. conditionSpecial += ` AND art.activity_time_end < ` + "'" + time.Now().Format(utils.FormatDateTime) + "'"
  3700. condition += conditionActivity
  3701. list, err := models.GetActivityLabelListAllNoLimit(condition, sortTime, pars, conditionSpecial)
  3702. if err != nil {
  3703. br.Msg = "获取失败"
  3704. br.ErrMsg = "获取失败,Err:" + err.Error()
  3705. return
  3706. }
  3707. //标签字段关联的产业与标签处理
  3708. mapKeyWord := make(map[string]string)
  3709. for _, v := range list {
  3710. keyWord := services.LabelStr(v.KeyWord)
  3711. if _, ok := mapKeyWord[keyWord]; ok {
  3712. continue
  3713. }
  3714. if keyWord == "" {
  3715. continue
  3716. }
  3717. v.KeyWord = keyWord
  3718. resp.List = append(resp.List, v)
  3719. mapKeyWord[keyWord] = keyWord
  3720. }
  3721. //添加更多主题访问记录
  3722. item := new(models.CygxPageHistoryRecord)
  3723. item.UserId = user.UserId
  3724. item.CreateTime = time.Now()
  3725. item.Mobile = user.Mobile
  3726. item.Email = user.Email
  3727. item.CompanyId = user.CompanyId
  3728. item.CompanyName = user.CompanyName
  3729. item.PageType = "OverActivity"
  3730. go models.AddCygxPageHistoryRecord(item)
  3731. br.Ret = 200
  3732. br.Success = true
  3733. br.Msg = "获取成功"
  3734. br.Data = resp
  3735. }