activity.go 129 KB

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