activity.go 139 KB

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