activity.go 135 KB

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