activity.go 129 KB

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