activity.go 134 KB

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