activity.go 132 KB

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