activity.go 148 KB

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