activity.go 131 KB

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