activity.go 162 KB

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