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