activity_special_trip.go 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/tealeg/xlsx"
  6. "hongze/hz_crm_api/controllers"
  7. "hongze/hz_crm_api/models"
  8. "hongze/hz_crm_api/models/cygx"
  9. "hongze/hz_crm_api/models/system"
  10. "hongze/hz_crm_api/services"
  11. cygxService "hongze/hz_crm_api/services/cygx"
  12. "hongze/hz_crm_api/utils"
  13. "os"
  14. "path/filepath"
  15. "strconv"
  16. "strings"
  17. "time"
  18. )
  19. // 专项调研行程
  20. type ActivitySpecialTripCoAntroller struct {
  21. controllers.BaseAuthController
  22. }
  23. // @Title 新增报名
  24. // @Description 新增报名接口
  25. // @Param request body cygx.AddMeetingReminderReq true "type json string"
  26. // @Success 200 操作成功
  27. // @router /special/trip/addUser [post]
  28. func (this *ActivitySpecialTripCoAntroller) AddUser() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. AdminUser := this.SysUser
  35. if AdminUser == nil {
  36. br.Msg = "请登录"
  37. br.ErrMsg = "请登录,SysUser Is Empty"
  38. return
  39. }
  40. var req cygx.AddMeetingReminderReq
  41. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  42. if err != nil {
  43. br.Msg = "参数解析异常!"
  44. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  45. return
  46. }
  47. roleTypeCode := AdminUser.RoleTypeCode
  48. var items []*cygx.CygxActivitySpecialTrip
  49. var itemsBill []*cygx.CygxActivitySpecialTripBill
  50. var itemsMeet []*cygx.CygxActivitySpecialMeetingDetail
  51. activityIds := req.ActivityIds
  52. uidList := req.List
  53. if activityIds == "" {
  54. br.Msg = "请选择活动"
  55. br.ErrMsg = "活动ID不能为空"
  56. return
  57. }
  58. activityIdList := strings.Split(activityIds, ",")
  59. var uids string
  60. for _, v := range uidList {
  61. uids += strconv.Itoa(v.UserId) + ","
  62. }
  63. uids = strings.TrimRight(uids, ",")
  64. for _, v := range uidList {
  65. uid := v.UserId
  66. wxUser, userErr := models.GetWxUserByUserId(uid)
  67. if userErr != nil {
  68. br.Msg = "编辑失败!查询用户信息失败"
  69. br.ErrMsg = "查询用户信息失败,Err:" + userErr.Error() + "用户UID:" + strconv.Itoa(uid) + "不存在"
  70. return
  71. }
  72. for _, vact := range activityIdList {
  73. activityId, _ := strconv.Atoi(vact)
  74. activityInfo, err := cygx.GetAddActivityInfoSpecialById(activityId)
  75. if err != nil {
  76. br.Msg = "活动不存在"
  77. br.ErrMsg = "活动ID错误,Err:activityId:" + strconv.Itoa(activityId)
  78. return
  79. }
  80. limitPeopleNum := activityInfo.LimitPeopleNum
  81. if limitPeopleNum > 0 {
  82. if AdminUser.RoleTypeCode != "admin" {
  83. havePower, err := cygxService.GetSpecialDetailUserPower(wxUser, activityInfo)
  84. if err != nil {
  85. br.Msg = "用户权限校验失败!"
  86. br.ErrMsg = "GetActivityDetailUserPower,Err:" + err.Error() + fmt.Sprint("UserId", wxUser.UserId, "ActivityId:", activityInfo.ActivityId)
  87. return
  88. }
  89. if !havePower {
  90. br.Msg = "当前活动对该客户不可见,无法报名"
  91. br.ErrMsg = "活动ID:" + strconv.Itoa(activityId) + "活动名称:" + activityInfo.ResearchTheme + "用户ID:" + strconv.Itoa(int(wxUser.UserId))
  92. return
  93. }
  94. }
  95. //获取这个活动已经报名的用户数量
  96. totalSignup, errSignup := cygx.GetActivitySpecialTripCountByActivityId(activityId)
  97. if errSignup != nil {
  98. br.Msg = "获取失败"
  99. br.ErrMsg = "获取失败,Err:" + errSignup.Error()
  100. return
  101. }
  102. //获取这个活动中输入的这些用户的报名数量
  103. totalThisUser, errThisUser := cygx.GetActivitySpecialTripCountByThisUser(activityId, uids)
  104. if errThisUser != nil {
  105. br.Msg = "获取失败"
  106. br.ErrMsg = "获取失败,Err:" + errThisUser.Error()
  107. return
  108. }
  109. //如果是限制人数的就做报名人数限制判断
  110. if limitPeopleNum < totalSignup+len(uidList)-totalThisUser {
  111. br.Msg = "新增失败,活动人数超限"
  112. br.ErrMsg = "当前活动报名人数已满,活动:" + activityInfo.ResearchTheme
  113. return
  114. }
  115. }
  116. //total, errtotal := cygx.GetActivitySpecialTripCount(uid, activityId)
  117. //if errtotal != nil {
  118. // br.Msg = "获取失败"
  119. // br.ErrMsg = "获取失败,Err:" + errtotal.Error()
  120. // return
  121. //}
  122. infoUser, err := cygx.GetUserAndCompanyNameList(uid)
  123. if err != nil {
  124. br.Msg = "获取失败"
  125. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  126. return
  127. }
  128. //if total == 0 {
  129. totalAll, err := cygx.GetUserActivitySpecialTripCount(uid, activityId)
  130. if err != nil {
  131. br.Msg = "获取信息失败"
  132. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  133. return
  134. }
  135. //流水记录表
  136. itemBill := new(cygx.CygxActivitySpecialTripBill)
  137. itemBill.UserId = infoUser.UserId
  138. itemBill.ActivityId = activityInfo.ActivityId
  139. itemBill.CreateTime = time.Now()
  140. itemBill.Mobile = infoUser.Mobile
  141. itemBill.Email = infoUser.Email
  142. itemBill.CompanyId = infoUser.CompanyId
  143. itemBill.CompanyName = infoUser.CompanyName
  144. itemBill.RealName = infoUser.RealName
  145. itemBill.Source = 2
  146. itemBill.DoType = 1
  147. itemBill.BillDetailed = -1 // 流水减一
  148. itemBill.RegisterPlatform = 3
  149. itemBill.ChartPermissionId = activityInfo.ChartPermissionId
  150. itemBill.ChartPermissionName = activityInfo.ChartPermissionName
  151. itemBill.AdminId = AdminUser.AdminId
  152. //if activityInfo.ChartPermissionName == utils.CE_LUE_NAME || activityInfo.ChartPermissionName == utils.GU_SHOU_NAME {
  153. if utils.InArrayByStr(utils.ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER, activityInfo.ChartPermissionName) {
  154. //如果是策略、固收、周期行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
  155. maxChartPermissionId, maxChartPermissionName, err := cygxService.GetSpecialBillMaxChartPermissionId(infoUser)
  156. if err != nil {
  157. br.Msg = "操作失败"
  158. br.ErrMsg = "获取销售信息失败,GetSpecialBillMaxChartPermissionId Err:" + err.Error()
  159. return
  160. }
  161. itemBill.ChartPermissionId = maxChartPermissionId
  162. itemBill.ChartPermissionName = maxChartPermissionName
  163. }
  164. if totalAll == 0 {
  165. item := new(cygx.CygxActivitySpecialTrip)
  166. item.UserId = infoUser.UserId
  167. item.RealName = infoUser.RealName
  168. item.SellerName = infoUser.SellerName
  169. item.ActivityId = activityId
  170. item.CreateTime = time.Now()
  171. item.Mobile = infoUser.Mobile
  172. item.Email = infoUser.Email
  173. item.CompanyId = infoUser.CompanyId
  174. item.CompanyName = infoUser.CompanyName
  175. item.AdminId = AdminUser.AdminId
  176. item.Source = 2
  177. //优先绑定用户修改过的外呼手机号
  178. if infoUser.OutboundMobile != "" {
  179. item.OutboundMobile = infoUser.OutboundMobile
  180. if infoUser.OutboundCountryCode == "" {
  181. item.CountryCode = "86"
  182. } else {
  183. item.CountryCode = infoUser.OutboundCountryCode
  184. }
  185. } else {
  186. item.OutboundMobile = infoUser.Mobile
  187. if infoUser.CountryCode == "" {
  188. item.CountryCode = "86"
  189. } else {
  190. item.CountryCode = infoUser.CountryCode
  191. }
  192. }
  193. items = append(items, item)
  194. err = cygxService.DeductTripRemainingtimesByUser(infoUser, activityInfo, roleTypeCode) //扣除用户专项调研剩余次数
  195. if err != nil {
  196. br.Msg = "操作失败"
  197. br.ErrMsg = "操作失败,Err:" + err.Error()
  198. return
  199. }
  200. } else {
  201. err = cygx.UpdateSpecialTrip(1, 0, uid, activityId)
  202. if err != nil {
  203. br.Msg = "报名失败,"
  204. br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
  205. return
  206. }
  207. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
  208. //48小时之内的取消也扣除一次参会记录
  209. if time.Now().Add(+time.Hour * 48).After(resultTime) {
  210. itemBill.BillDetailed = 0 //48小时之内,取消报名之后二次报名,不扣除流水记录
  211. } else {
  212. err = cygxService.DeductTripRemainingtimesByUser(infoUser, activityInfo, roleTypeCode) //扣除用户专项调研剩余次数
  213. if err != nil {
  214. br.Msg = "操作失败"
  215. br.ErrMsg = "操作失败,Err:" + err.Error()
  216. return
  217. }
  218. }
  219. }
  220. //userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
  221. //if err != nil {
  222. // br.Msg = "获取专项调研剩余次数失败"
  223. // br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
  224. // return
  225. //}
  226. //if userType == 2 {
  227. // tripRemaining = tripRemaining + itemBill.BillDetailed - i
  228. // itemBill.Total = strconv.Itoa(tripRemaining) + "次"
  229. //} else {
  230. // for k, num := range mapChartName {
  231. // if activityInfo.ChartPermissionName == k {
  232. // num = num + itemBill.BillDetailed - i
  233. // }
  234. // itemBill.Total += k + strconv.Itoa(num) + "次+"
  235. // }
  236. // itemBill.Total = strings.TrimRight(itemBill.Total, "+")
  237. //}
  238. totalText, err := cygxService.HandleActivitySpecialTripBillTotalText(infoUser.CompanyId)
  239. if err != nil {
  240. br.Msg = "报名失败,"
  241. br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
  242. return
  243. }
  244. itemBill.Total = totalText
  245. itemsBill = append(itemsBill, itemBill)
  246. //}
  247. var itemMeeting = new(cygx.CygxActivitySpecialMeetingDetail)
  248. itemMeeting.UserId = v.UserId
  249. itemMeeting.ActivityId = activityId
  250. itemMeeting.CreateTime = time.Now()
  251. itemMeeting.Mobile = infoUser.Mobile
  252. itemMeeting.Email = infoUser.Email
  253. itemMeeting.CompanyId = infoUser.CompanyId
  254. itemMeeting.CompanyName = infoUser.CompanyName
  255. itemMeeting.RealName = infoUser.RealName
  256. itemsMeet = append(itemsMeet, itemMeeting)
  257. }
  258. }
  259. err = cygx.AddCygxActivitySpecialTrip(items, itemsBill, itemsMeet)
  260. if err != nil {
  261. br.Msg = "操作失败"
  262. br.ErrMsg = "新增用户失败,Err:" + err.Error()
  263. return
  264. }
  265. br.Ret = 200
  266. br.Success = true
  267. br.Msg = "操作成功"
  268. br.IsAddLog = true
  269. }
  270. // @Title 报名列表
  271. // @Description 报名列表接口
  272. // @Param ActivityId query int true "活动ID"
  273. // @Param IsExport query bool false "是否导出excel,默认是false"
  274. // @Success 200 {object} cygx.GetAppointmentSpecialListRsep
  275. // @router /special/tripList [get]
  276. func (this *ActivitySpecialTripCoAntroller) TripList() {
  277. br := new(models.BaseResponse).Init()
  278. defer func() {
  279. this.Data["json"] = br
  280. this.ServeJSON()
  281. }()
  282. sysUser := this.SysUser
  283. if sysUser == nil {
  284. br.Msg = "请登录"
  285. br.ErrMsg = "请登录,SysUser Is Empty"
  286. return
  287. }
  288. isExport, _ := this.GetBool("IsExport", false)
  289. activityId, _ := this.GetInt("ActivityId")
  290. if activityId < 1 {
  291. br.Msg = "活动不存在"
  292. return
  293. }
  294. respList := new(cygx.GetAppointmentSpecialListRsep)
  295. activityInfo, _ := cygx.GetAddActivityInfoSpecialById(activityId)
  296. if activityInfo == nil {
  297. br.Msg = "活动不存在"
  298. br.ErrMsg = "活动ID错误,Err:activityId:" + strconv.Itoa(activityId)
  299. return
  300. }
  301. //超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
  302. resp := new(cygx.CanDownload)
  303. adminInfo, errAdmin := system.GetSysUserById(sysUser.AdminId)
  304. if errAdmin != nil {
  305. br.Msg = "获取失败"
  306. br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
  307. return
  308. }
  309. if adminInfo.Role == "admin" || adminInfo.Role == "researcher" {
  310. resp.IsCanDownload = true
  311. }
  312. memberType := "Admin"
  313. sqlStr := ` AND s.is_cancel = 0`
  314. totalStr := sqlStr
  315. list, err := cygx.GetCygxActivitySpecialTripList(activityId, sqlStr)
  316. if err != nil {
  317. br.Msg = "获取失败"
  318. br.ErrMsg = "获取失败,Err:" + err.Error()
  319. return
  320. }
  321. //线上活动,销售查看自己客户,销售组长查看组员
  322. if resp.IsCanDownload == false && activityInfo.SpecialType == 1 {
  323. mapMobile, err := cygxService.GetAdminLookUserMobile(adminInfo)
  324. if err != nil {
  325. br.Msg = "获取失败"
  326. br.ErrMsg = "获取失败,销售对应权限,Err:" + err.Error()
  327. return
  328. }
  329. for _, v := range list {
  330. if _, ok := mapMobile[v.Mobile]; ok {
  331. respList.List = append(respList.List, v)
  332. }
  333. }
  334. if adminInfo.RoleTypeCode == "rai_group" {
  335. //组长查看本组所有组员
  336. memberType = "GroupLeader"
  337. } else {
  338. //组员查看自己
  339. memberType = "Sale"
  340. }
  341. } else {
  342. respList.List = list
  343. }
  344. if len(respList.List) == 0 {
  345. respList.List = make([]*cygx.CygxActivitySpecialTripResp, 0)
  346. }
  347. //导出excel
  348. if isExport {
  349. TripListExport(this, respList.List)
  350. return
  351. }
  352. total, errtotal := cygx.GetActivitySpecialTripTotal(activityId, totalStr)
  353. if errtotal != nil {
  354. br.Msg = "获取失败"
  355. br.ErrMsg = "客户总数获取失败,Err:" + errtotal.Error()
  356. return
  357. }
  358. myTotal := len(respList.List)
  359. respList.Source = 1
  360. respList.Total = total
  361. respList.MyTotal = myTotal
  362. respList.ActivityId = activityId
  363. respList.SpecialType = activityInfo.SpecialType
  364. if activityInfo.LimitPeopleNum > 0 {
  365. respList.IsLimitPeople = 1
  366. }
  367. respList.MemberType = memberType
  368. br.Ret = 200
  369. br.Success = true
  370. br.Msg = "获取成功"
  371. br.Data = respList
  372. }
  373. // TripListExport 下载报名信息
  374. func TripListExport(this *ActivitySpecialTripCoAntroller, listDate []*cygx.CygxActivitySpecialTripResp) {
  375. br := new(models.BaseResponse).Init()
  376. defer func() {
  377. this.Data["json"] = br
  378. this.ServeJSON()
  379. }()
  380. sysUser := this.SysUser
  381. if sysUser == nil {
  382. br.Msg = "请登录"
  383. br.ErrMsg = "请登录,SysUser Is Empty"
  384. return
  385. }
  386. activityId, _ := this.GetInt("ActivityId")
  387. activityInfo, _ := cygx.GetAddActivityInfoSpecialById(activityId)
  388. if activityInfo == nil {
  389. br.Msg = "活动不存在"
  390. br.ErrMsg = "活动ID错误,Err:activityId:" + strconv.Itoa(activityId)
  391. return
  392. }
  393. //超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
  394. resp := new(cygx.CanDownload)
  395. adminInfo, errAdmin := system.GetSysUserById(sysUser.AdminId)
  396. if errAdmin != nil {
  397. br.Msg = "获取失败"
  398. br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
  399. return
  400. }
  401. if adminInfo.Role == "admin" || adminInfo.Role == "researcher" {
  402. resp.IsCanDownload = true
  403. }
  404. //创建excel
  405. dir, err := os.Executable()
  406. exPath := filepath.Dir(dir)
  407. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  408. xlsxFile := xlsx.NewFile()
  409. if err != nil {
  410. br.Msg = "生成文件失败"
  411. br.ErrMsg = "生成文件失败"
  412. return
  413. }
  414. style := xlsx.NewStyle()
  415. alignment := xlsx.Alignment{
  416. Horizontal: "center",
  417. Vertical: "center",
  418. WrapText: true,
  419. }
  420. style.Alignment = alignment
  421. style.ApplyAlignment = true
  422. sheetName := "报名名单"
  423. sheet, err := xlsxFile.AddSheet(sheetName)
  424. if err != nil {
  425. br.Msg = "新增Sheet失败"
  426. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  427. return
  428. }
  429. //标头
  430. if activityInfo.SpecialType == 1 || resp.IsCanDownload {
  431. rowTitle := sheet.AddRow()
  432. cellA := rowTitle.AddCell()
  433. cellA.Value = "姓名"
  434. cellB := rowTitle.AddCell()
  435. cellB.Value = "手机号"
  436. cellC := rowTitle.AddCell()
  437. cellC.Value = "公司名称"
  438. cellD := rowTitle.AddCell()
  439. cellD.Value = "所属销售"
  440. for _, item := range listDate {
  441. row := sheet.AddRow()
  442. cellA := row.AddCell()
  443. cellA.Value = item.RealName
  444. cellB := row.AddCell()
  445. cellB.Value = item.Mobile
  446. cellC := row.AddCell()
  447. cellC.Value = item.CompanyName
  448. cellD := row.AddCell()
  449. cellD.Value = item.SellerName
  450. }
  451. } else {
  452. rowTitle := sheet.AddRow()
  453. cellA := rowTitle.AddCell()
  454. cellA.Value = "姓名"
  455. cellB := rowTitle.AddCell()
  456. cellB.Value = "公司名称"
  457. cellC := rowTitle.AddCell()
  458. cellC.Value = "所属销售"
  459. for _, item := range listDate {
  460. row := sheet.AddRow()
  461. cellA := row.AddCell()
  462. cellA.Value = item.RealName
  463. cellB := row.AddCell()
  464. cellB.Value = item.CompanyName
  465. cellC := row.AddCell()
  466. cellC.Value = item.SellerName
  467. }
  468. }
  469. err = xlsxFile.Save(downLoadnFilePath)
  470. if err != nil {
  471. br.Msg = "保存文件失败"
  472. br.ErrMsg = "保存文件失败"
  473. return
  474. }
  475. downloadFileName := activityInfo.ResearchTheme + ".xlsx"
  476. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  477. defer func() {
  478. os.Remove(downLoadnFilePath)
  479. }()
  480. br.Success = true
  481. br.Ret = 200
  482. br.IsAddLog = true
  483. }
  484. // @Title 取消报名
  485. // @Description 取消报名接口
  486. // @Param request body cygx.ActivitySpecialTripCancelReq true "type json string"
  487. // @Success 200 操作成功
  488. // @router /special/trip/cancel [post]
  489. func (this *ActivitySpecialTripCoAntroller) TripCancel() {
  490. br := new(models.BaseResponse).Init()
  491. defer func() {
  492. this.Data["json"] = br
  493. this.ServeJSON()
  494. }()
  495. sysUser := this.SysUser
  496. if sysUser == nil {
  497. br.Msg = "请登录"
  498. br.ErrMsg = "请登录,SysUser Is Empty"
  499. return
  500. }
  501. var req cygx.ActivitySpecialTripCancelReq
  502. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  503. if err != nil {
  504. br.Msg = "参数解析异常!"
  505. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  506. return
  507. }
  508. userId := req.UserId
  509. activityId := req.ActivityId
  510. total, err := cygx.GetActivitySpecialTripCountByThisUser(activityId, strconv.Itoa(userId))
  511. if err != nil {
  512. br.Msg = "获取失败"
  513. br.ErrMsg = "获取失败,Err:" + err.Error()
  514. return
  515. }
  516. if total == 0 {
  517. br.Msg = "获取报名信息失败"
  518. br.ErrMsg = "获取失败,activityId:" + strconv.Itoa(activityId)
  519. return
  520. }
  521. activityInfo, errInfo := cygx.GetAddActivityInfoSpecialById(activityId)
  522. if activityInfo == nil {
  523. br.Msg = "操作失败"
  524. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  525. return
  526. }
  527. if errInfo != nil {
  528. br.Msg = "操作失败"
  529. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  530. return
  531. }
  532. infoUser, err := cygx.GetUserAndCompanyNameList(userId)
  533. if err != nil {
  534. br.Msg = "获取失败"
  535. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  536. return
  537. }
  538. //流水记录表
  539. itemBill := new(cygx.CygxActivitySpecialTripBill)
  540. itemBill.UserId = infoUser.UserId
  541. itemBill.ActivityId = activityInfo.ActivityId
  542. itemBill.CreateTime = time.Now()
  543. itemBill.Mobile = infoUser.Mobile
  544. itemBill.Email = infoUser.Email
  545. itemBill.CompanyId = infoUser.CompanyId
  546. itemBill.CompanyName = infoUser.CompanyName
  547. itemBill.RealName = infoUser.RealName
  548. itemBill.Source = 2
  549. itemBill.DoType = 2
  550. itemBill.BillDetailed = 1 // 流水加一
  551. itemBill.RegisterPlatform = 3
  552. itemBill.ChartPermissionId = activityInfo.ChartPermissionId
  553. itemBill.ChartPermissionName = activityInfo.ChartPermissionName
  554. itemBill.AdminId = sysUser.AdminId
  555. //if activityInfo.ChartPermissionName == utils.CE_LUE_NAME || activityInfo.ChartPermissionName == utils.GU_SHOU_NAME {
  556. if utils.InArrayByStr(utils.ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER, activityInfo.ChartPermissionName) {
  557. //如果是策略、固收行业,把代扣行业信息放入流水表,取消报名的时候,返点使用
  558. lastTripBill, err := cygx.GetCygxActivitySpecialTripBillLastDetialByActivityId(activityInfo.ActivityId, userId)
  559. if err != nil {
  560. br.Msg = "操作失败"
  561. br.ErrMsg = "获取销售信息失败,GetCygxActivitySpecialTripBillLastDetialByActivityId Err:" + err.Error()
  562. return
  563. }
  564. itemBill.ChartPermissionId = lastTripBill.ChartPermissionId
  565. itemBill.ChartPermissionName = lastTripBill.ChartPermissionName
  566. }
  567. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
  568. //48小时之内的取消也扣除一次参会记录
  569. var isValid int
  570. if time.Now().Add(+time.Hour * 48).After(resultTime) {
  571. isValid = 1
  572. itemBill.BillDetailed = 0 // 48小时之内取消的,照样扣点,流水不进行加一
  573. } else {
  574. err = cygxService.RebateTripRemainingtimesByUser(infoUser, activityInfo) // 返点
  575. if err != nil {
  576. br.Msg = "操作失败"
  577. br.ErrMsg = "操作失败,RebateTripRemainingtimesByUserErr:" + err.Error()
  578. return
  579. }
  580. }
  581. err = cygx.ActivitySpecialTripCancel(isValid, activityId, userId)
  582. if err != nil {
  583. br.Msg = "修改失败"
  584. br.ErrMsg = "修改失败 Err:" + err.Error()
  585. return
  586. }
  587. //userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(infoUser.CompanyId)
  588. //if err != nil {
  589. // br.Msg = "获取专项调研剩余次数失败"
  590. // br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
  591. // return
  592. //}
  593. //if userType == 2 {
  594. // tripRemaining += itemBill.BillDetailed
  595. // itemBill.Total = strconv.Itoa(tripRemaining) + "次"
  596. //} else {
  597. // for k, num := range mapChartName {
  598. // if activityInfo.ChartPermissionName == k {
  599. // num += itemBill.BillDetailed
  600. // }
  601. // itemBill.Total += k + strconv.Itoa(num) + "次+"
  602. // }
  603. // itemBill.Total = strings.TrimRight(itemBill.Total, "+")
  604. //}
  605. totalText, err := cygxService.HandleActivitySpecialTripBillTotalText(infoUser.CompanyId)
  606. if err != nil {
  607. br.Msg = "报名失败,"
  608. br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
  609. return
  610. }
  611. itemBill.Total = totalText
  612. err = cygx.AddCygxActivitySpecialTripBill(itemBill)
  613. if err != nil {
  614. br.Msg = "修改失败"
  615. br.ErrMsg = "修改失败流水记录添加失败 Err:" + err.Error()
  616. return
  617. }
  618. br.Ret = 200
  619. br.Success = true
  620. br.Msg = "操作成功"
  621. br.IsAddLog = true
  622. }
  623. // @Title 到会详情/提交到会详情
  624. // @Description 报名详情列表接口
  625. // @Param ActivityId query int true "活动ID"
  626. // @Success 200 {object} cygx.GetAppointmentSpecialListRsep
  627. // @router /special/trip/meetDetial [get]
  628. func (this *ActivitySpecialTripCoAntroller) MeetDetial() {
  629. br := new(models.BaseResponse).Init()
  630. defer func() {
  631. this.Data["json"] = br
  632. this.ServeJSON()
  633. }()
  634. AdminUser := this.SysUser
  635. if AdminUser == nil {
  636. br.Msg = "请登录"
  637. br.ErrMsg = "请登录,SysUser Is Empty"
  638. return
  639. }
  640. activityId, _ := this.GetInt("ActivityId")
  641. if activityId < 1 {
  642. br.Msg = "活动不存在"
  643. return
  644. }
  645. activityInfo, err := cygx.GetAddActivityInfoSpecialById(activityId)
  646. if err != nil {
  647. br.Msg = "活动不存在"
  648. br.ErrMsg = "活动ID错误,Err:activityId:" + strconv.Itoa(activityId)
  649. return
  650. }
  651. respList := new(cygx.SpecialMeetingDetailRespList)
  652. if activityInfo.IsSubmitMeeting == 0 {
  653. sqlStr := ` AND s.is_cancel = 0`
  654. list, err := cygx.GetCygxActivitySpecialTripList(activityId, sqlStr)
  655. if err != nil {
  656. br.Msg = "获取失败"
  657. br.ErrMsg = "获取失败,Err:" + err.Error()
  658. return
  659. }
  660. for _, v := range list {
  661. item := new(cygx.CygxActivitySpecialMeetingDetailResp)
  662. item.UserId = v.UserId
  663. item.RealName = v.RealName
  664. item.CompanyName = v.CompanyName
  665. respList.List = append(respList.List, item)
  666. }
  667. } else {
  668. respList.List, err = cygx.GetCygxActivitySpecialMeetingDetailListByActivity(activityId)
  669. if err != nil {
  670. br.Msg = "获取失败"
  671. br.ErrMsg = "获取失败,Err:" + err.Error()
  672. return
  673. }
  674. UserMap, err := cygxService.GetSpecialTripUserMap(activityId)
  675. if err != nil {
  676. br.Msg = "获取失败"
  677. br.ErrMsg = "获取失败,Err:" + err.Error()
  678. return
  679. }
  680. for k, v := range respList.List {
  681. if v.IsMeeting == 1 {
  682. if _, ok := UserMap[v.UserId]; !ok {
  683. respList.List[k].IsMeeting = 2
  684. }
  685. respList.List[k].Operation = true
  686. }
  687. }
  688. }
  689. br.Ret = 200
  690. br.Success = true
  691. br.Msg = "获取成功"
  692. br.Data = respList
  693. }
  694. // @Title 提交线下到会情况
  695. // @Description 提交线下到会情况接口
  696. // @Param request body cygx.MeetingDoRep true "type json string"
  697. // @Success 200 操作成功
  698. // @router /special/trip/meetingDo [post]
  699. func (this *ActivitySpecialTripCoAntroller) MeetingDo() {
  700. br := new(models.BaseResponse).Init()
  701. defer func() {
  702. this.Data["json"] = br
  703. this.ServeJSON()
  704. }()
  705. AdminUser := this.SysUser
  706. if AdminUser == nil {
  707. br.Msg = "请登录"
  708. br.ErrMsg = "请登录,用户信息为空"
  709. br.Ret = 408
  710. return
  711. }
  712. var req cygx.MeetingSpeciaDoRep
  713. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  714. if err != nil {
  715. br.Msg = "参数解析异常!"
  716. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  717. return
  718. }
  719. var userIdArr []int
  720. var newMeetingUserid = make(map[int]bool) //新提交的到会的额用户ID
  721. meetingUids := req.UserIds
  722. if len(meetingUids) == 0 {
  723. meetingUids = "0"
  724. } else {
  725. //过滤字段
  726. slice := strings.Split(meetingUids, ",")
  727. meetingUids = ""
  728. for _, v := range slice {
  729. if v != "" {
  730. meetingUids += v + ","
  731. userId, _ := strconv.Atoi(v)
  732. if userId > 0 {
  733. userIdArr = append(userIdArr, userId)
  734. newMeetingUserid[userId] = true
  735. }
  736. }
  737. }
  738. meetingUids = strings.TrimRight(meetingUids, ",")
  739. }
  740. activityId := req.ActivityId
  741. activityInfo, err := cygx.GetAddActivityInfoSpecialById(activityId)
  742. if err != nil {
  743. br.Msg = "活动不存在"
  744. br.ErrMsg = "活动ID错误,Err:activityId:" + strconv.Itoa(activityId)
  745. return
  746. }
  747. //校验活动后台管理员、销售是否有修改权限
  748. havePower, popupMsg, err := cygxService.CheckActivitySpecialUpdatePower(AdminUser.AdminId, activityInfo)
  749. if err != nil {
  750. br.Msg = "获取管理员身份信息失败"
  751. br.ErrMsg = "获取管理员身份信息失败,Err:" + err.Error()
  752. return
  753. }
  754. if !havePower {
  755. br.Msg = popupMsg
  756. return
  757. }
  758. noMeetingUids, err := cygx.GetSpecialTripUserIds(activityId, meetingUids) //未到会的用户ID
  759. if err != nil {
  760. br.Msg = "获取信息失败"
  761. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  762. return
  763. }
  764. var allUids string
  765. if len(noMeetingUids) > 0 {
  766. allUids = noMeetingUids + "," + meetingUids
  767. } else {
  768. allUids = meetingUids
  769. }
  770. listUser, err := cygx.GetUserAndCompanyNameListByUids(allUids)
  771. if err != nil {
  772. br.Msg = "获取失败"
  773. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  774. return
  775. }
  776. UserMap, err := cygxService.GetSpecialTripUserMap(activityId)
  777. if err != nil {
  778. br.Msg = "获取失败"
  779. br.ErrMsg = "获取失败,Err:" + err.Error()
  780. return
  781. }
  782. var condition string
  783. var pars []interface{}
  784. condition += " AND is_meeting = 1 AND activity_id = ? "
  785. pars = append(pars, activityId)
  786. listOldMeetingDetail, err := cygx.GetCygxActivitySpecialMeetingDetailList(condition, pars)
  787. if err != nil && err.Error() != utils.ErrNoRow() {
  788. br.Msg = "获取失败"
  789. br.ErrMsg = "GetCygxActivitySpecialMeetingDetailList,Err:" + err.Error()
  790. return
  791. }
  792. //获取之前已经到会的人
  793. //var oldMeetingUserid = make(map[int]bool)
  794. pars = make([]interface{}, 0)
  795. condition = " AND activity_id = ? "
  796. pars = append(pars, activityId)
  797. listTripBill, err := cygx.GetCygxActivitySpecialTripBill(condition, pars)
  798. if err != nil && err.Error() != utils.ErrNoRow() {
  799. br.Msg = "获取失败"
  800. br.ErrMsg = "GetCygxActivitySpecialTripBill,Err:" + err.Error()
  801. return
  802. }
  803. //获取用户最后一次的扣点状态
  804. mapUserLastTripBill := make(map[int]*cygx.CygxActivitySpecialTripBill)
  805. for _, v := range listTripBill {
  806. mapUserLastTripBill[v.UserId] = v
  807. }
  808. var items []*cygx.CygxActivitySpecialMeetingDetail
  809. var itemsBill []*cygx.CygxActivitySpecialTripBill
  810. if len(listOldMeetingDetail) > 0 {
  811. for _, v := range listOldMeetingDetail {
  812. if mapUserLastTripBill[v.UserId] == nil {
  813. continue
  814. }
  815. //如果上一次空降的用户,这一次提交的时候没有带入,而且还被扣点了,那么就进行返点处理
  816. if !newMeetingUserid[v.UserId] && v.IsAirborne == 1 && mapUserLastTripBill[v.UserId].BillDetailed < 0 {
  817. var itemBill = new(cygx.CygxActivitySpecialTripBill)
  818. //流水记录表
  819. itemBill.UserId = v.UserId
  820. itemBill.ActivityId = activityInfo.ActivityId
  821. itemBill.CreateTime = time.Now()
  822. itemBill.Mobile = v.Mobile
  823. itemBill.Email = v.Email
  824. itemBill.CompanyId = v.CompanyId
  825. itemBill.CompanyName = v.CompanyName
  826. itemBill.RealName = v.RealName
  827. itemBill.Source = 2
  828. itemBill.DoType = 2
  829. itemBill.BillDetailed = 1 // 流水加一
  830. itemBill.RegisterPlatform = 1
  831. itemBill.ChartPermissionId = activityInfo.ChartPermissionId
  832. itemBill.ChartPermissionName = activityInfo.ChartPermissionName
  833. itemBill.AdminId = AdminUser.AdminId
  834. itemBill.Way = 2
  835. userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(v.CompanyId)
  836. if err != nil {
  837. br.Msg = "获取专项调研剩余次数失败"
  838. br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
  839. return
  840. }
  841. if userType == 2 {
  842. tripRemaining += itemBill.BillDetailed
  843. itemBill.Total = strconv.Itoa(tripRemaining) + "次"
  844. } else {
  845. for k, num := range mapChartName {
  846. if activityInfo.ChartPermissionName == k {
  847. num += itemBill.BillDetailed
  848. }
  849. itemBill.Total += k + strconv.Itoa(num) + "次+"
  850. }
  851. itemBill.Total = strings.TrimRight(itemBill.Total, "+")
  852. }
  853. itemsBill = append(itemsBill, itemBill)
  854. }
  855. }
  856. }
  857. for _, v := range listUser {
  858. var item = new(cygx.CygxActivitySpecialMeetingDetail)
  859. item.UserId = v.UserId
  860. item.ActivityId = activityId
  861. item.CreateTime = time.Now()
  862. item.Mobile = v.Mobile
  863. item.Email = v.Email
  864. item.CompanyId = v.CompanyId
  865. item.CompanyName = v.CompanyName
  866. item.IsMeeting = 1
  867. item.RealName = v.RealName
  868. //添加空降人员字段
  869. if _, ok := UserMap[v.UserId]; !ok {
  870. item.IsAirborne = 1
  871. }
  872. var itemBill = new(cygx.CygxActivitySpecialTripBill)
  873. //如果是空降客户,(没有扣点记录,或者上一次的流水不为负) 就进行扣点处理
  874. if item.IsAirborne == 1 && (mapUserLastTripBill[v.UserId] == nil || mapUserLastTripBill[v.UserId].BillDetailed >= 0) {
  875. //流水记录表
  876. itemBill.UserId = v.UserId
  877. itemBill.ActivityId = activityInfo.ActivityId
  878. itemBill.CreateTime = time.Now()
  879. itemBill.Mobile = v.Mobile
  880. itemBill.Email = v.Email
  881. itemBill.CompanyId = v.CompanyId
  882. itemBill.CompanyName = v.CompanyName
  883. itemBill.RealName = v.RealName
  884. itemBill.Source = 2
  885. itemBill.DoType = 1
  886. itemBill.BillDetailed = -1 // 流水减一
  887. itemBill.RegisterPlatform = 1
  888. itemBill.ChartPermissionId = activityInfo.ChartPermissionId
  889. itemBill.ChartPermissionName = activityInfo.ChartPermissionName
  890. itemBill.AdminId = AdminUser.AdminId
  891. itemBill.Way = 2
  892. userType, tripRemaining, mapChartName, err := cygxService.GetChartPermissionSpecialSurplusByCompany(v.CompanyId)
  893. if err != nil {
  894. br.Msg = "获取专项调研剩余次数失败"
  895. br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
  896. return
  897. }
  898. if userType == 2 {
  899. tripRemaining -= 1
  900. itemBill.Total = strconv.Itoa(tripRemaining) + "次"
  901. } else {
  902. for k, num := range mapChartName {
  903. if activityInfo.ChartPermissionName == k {
  904. num -= 1
  905. }
  906. itemBill.Total += k + strconv.Itoa(num) + "次+"
  907. }
  908. itemBill.Total = strings.TrimRight(itemBill.Total, "+")
  909. }
  910. itemsBill = append(itemsBill, itemBill)
  911. }
  912. items = append(items, item)
  913. }
  914. err = cygx.MeetingDopecialMeet(meetingUids, noMeetingUids, activityId, items, itemsBill)
  915. if err != nil {
  916. br.Msg = "操作失败"
  917. br.ErrMsg = "操作失败,Err:" + err.Error()
  918. return
  919. }
  920. go cygxService.ActivitySpecialUserLabelLogAdd(activityId, userIdArr)
  921. //添加操作日志记录
  922. br.Ret = 200
  923. br.Success = true
  924. br.Msg = "操作成功"
  925. br.IsAddLog = true
  926. }
  927. // @Title 修改外呼号码
  928. // @Description 修改外呼号码接口
  929. // @Param request body cygx.OutboundMobileEditResp true "type json string"
  930. // @Success 200 操作成功
  931. // @router /special/trip/outboundMobileEdit [post]
  932. func (this *ActivitySpecialTripCoAntroller) OutboundMobileEdit() {
  933. br := new(models.BaseResponse).Init()
  934. defer func() {
  935. this.Data["json"] = br
  936. this.ServeJSON()
  937. }()
  938. sysUser := this.SysUser
  939. if sysUser == nil {
  940. br.Msg = "请登录"
  941. br.ErrMsg = "请登录,SysUser Is Empty"
  942. return
  943. }
  944. var req cygx.OutboundMobileEditResp
  945. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  946. if err != nil {
  947. br.Msg = "参数解析异常!"
  948. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  949. return
  950. }
  951. id := req.Id
  952. outboundMobile := req.OutboundMobile
  953. countryCode := req.CountryCode
  954. err = cygx.SpecialTripOutboundMobileEdit(id, outboundMobile, countryCode)
  955. if err != nil {
  956. br.Msg = "修改失败"
  957. br.ErrMsg = "修改失败 Err:" + err.Error()
  958. return
  959. }
  960. br.Ret = 200
  961. br.Success = true
  962. br.Msg = "操作成功"
  963. br.IsAddLog = true
  964. }
  965. // @Title 模版消息发送客户类型列表
  966. // @Description 模版消息发送客户类型列表接口
  967. // @Success Ret=200
  968. // @router /special/trip/tempMsg/sendGroupList [get]
  969. func (this *ActivitySpecialTripCoAntroller) SendGroupList() {
  970. br := new(models.BaseResponse).Init()
  971. defer func() {
  972. this.Data["json"] = br
  973. this.ServeJSON()
  974. }()
  975. AdminUser := this.SysUser
  976. if AdminUser == nil {
  977. br.Msg = "请登录"
  978. br.ErrMsg = "请登录,SysUser Is Empty"
  979. return
  980. }
  981. list := make([]cygx.SendGroup, 0)
  982. list = append(list, cygx.SendGroup{
  983. Id: 1,
  984. Name: "已报名客户",
  985. })
  986. br.Ret = 200
  987. br.Success = true
  988. br.Data = list
  989. }
  990. // @Title 发送模版消息
  991. // @Description 发送模版消息接口
  992. // @Param request body cygx.AddOutboundPersonnelItm true "type json string"
  993. // @Success 200 操作成功
  994. // @router /special/trip/tempMsg [post]
  995. func (this *ActivitySpecialTripCoAntroller) TempMsg() {
  996. br := new(models.BaseResponse).Init()
  997. defer func() {
  998. this.Data["json"] = br
  999. this.ServeJSON()
  1000. }()
  1001. AdminUser := this.SysUser
  1002. if AdminUser == nil {
  1003. br.Msg = "请登录"
  1004. br.ErrMsg = "请登录,SysUser Is Empty"
  1005. return
  1006. }
  1007. var req cygx.ActivitySpecialSignupTempMsgReq
  1008. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1009. if err != nil {
  1010. br.Msg = "参数解析异常!"
  1011. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1012. return
  1013. }
  1014. idSlice := strings.Split(req.ActivityIds, ",")
  1015. for _, sId := range idSlice {
  1016. id, e := strconv.Atoi(sId)
  1017. if e != nil {
  1018. br.Msg = "活动Id参数异常"
  1019. br.ErrMsg = "参数解析异常, Err:" + e.Error()
  1020. return
  1021. }
  1022. var openIdList []*cygx.OpenIdList
  1023. idMap := make(map[string]string, 0)
  1024. //1已报名
  1025. if strings.Contains(req.SendGroup, "1") {
  1026. listSignup, err := cygx.GetCygxActivitySpecialTripListByActivityId(id)
  1027. if err != nil {
  1028. br.Msg = "查询报名信息失败失败"
  1029. br.ErrMsg = "GetCygxActivitySpecialTripListByActivityId,Err:" + err.Error()
  1030. return
  1031. }
  1032. if len(listSignup) == 0 {
  1033. continue
  1034. }
  1035. var mobileArr []string
  1036. for _, v := range listSignup {
  1037. if v.Mobile != "" {
  1038. mobileArr = append(mobileArr, v.Mobile)
  1039. }
  1040. }
  1041. mobileLen := len(mobileArr)
  1042. var condition string
  1043. var pars []interface{}
  1044. if mobileLen > 0 {
  1045. condition += ` AND u.mobile IN (` + utils.GetOrmInReplace(mobileLen) + `)`
  1046. pars = append(pars, mobileArr)
  1047. }
  1048. //list, err := models.GetActivitySpecialOpenIdListMobile(condition, pars)
  1049. //if err != nil {
  1050. // br.Msg = "查询openId失败"
  1051. // br.ErrMsg = "查询openId失败,Err:" + err.Error()
  1052. // return
  1053. //}
  1054. if mobileLen == 0 {
  1055. return
  1056. }
  1057. list, err := cygx.GetUserRecordListByMobileArr(mobileArr)
  1058. for _, idList := range list {
  1059. openIdList = append(openIdList, idList)
  1060. idMap[idList.OpenId] = idList.OpenId
  1061. }
  1062. }
  1063. if len(openIdList) > 0 {
  1064. openIdArr := make([]string, len(openIdList))
  1065. for i, v := range openIdList {
  1066. openIdArr[i] = v.OpenId
  1067. }
  1068. sendInfo := new(services.SendWxTemplate)
  1069. sendInfo.Keyword1 = req.ResearchTheme
  1070. sendInfo.Keyword2 = req.Content
  1071. sendInfo.TemplateId = utils.WxMsgTemplateIdActivityChangeApplyXzs
  1072. sendInfo.RedirectUrl = utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(id)
  1073. if utils.RunMode == "debug" {
  1074. sendInfo.RedirectUrl = utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(110) //测试环境调正式的ID
  1075. }
  1076. sendInfo.RedirectTarget = 3
  1077. sendInfo.Resource = strconv.Itoa(id)
  1078. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_CUSTOMIZE
  1079. sendInfo.OpenIdArr = openIdArr
  1080. e = services.SendTemplateMsg(sendInfo)
  1081. if e != nil {
  1082. br.Msg = "推送模板消息失败!"
  1083. br.ErrMsg = "参数解析失败,Err:" + e.Error()
  1084. return
  1085. }
  1086. }
  1087. }
  1088. br.Ret = 200
  1089. br.Success = true
  1090. br.Msg = "发送成功"
  1091. }