activity.go 131 KB

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