activity_special_trip.go 35 KB

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