activity_special_trip.go 34 KB

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