蛋蛋星球 后台端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 4 седмици
преди 3 седмици
преди 4 седмици
преди 3 седмици
преди 2 седмици
преди 4 седмици
преди 3 седмици
преди 3 седмици
преди 3 седмици
преди 4 седмици
преди 3 седмици
преди 4 седмици
преди 2 седмици
преди 4 седмици
преди 2 седмици
преди 2 седмици
преди 4 седмици
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. package notice
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/utils"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  9. "github.com/gin-gonic/gin"
  10. "time"
  11. )
  12. func List(c *gin.Context) {
  13. var req *md.NoticeListReq
  14. if err := c.ShouldBindJSON(&req); err != nil {
  15. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  16. return
  17. }
  18. var resp md.NoticeListResp
  19. noticeList := make([]md.NoticeList, 0)
  20. NewJpushNoticeDb := implement.NewJpushNoticeDb(db.Db)
  21. notice, total, _ := NewJpushNoticeDb.FindJpushNoticeAndTotal(req.Page, req.Limit, "")
  22. resp.Total = total
  23. resp.ChangeData = []map[string]string{
  24. {"name": "昵称", "value": "{昵称}"},
  25. {"name": "手机号", "value": "{手机号}"},
  26. {"name": "金额", "value": "{金额}"},
  27. {"name": "小时", "value": "{小时}"},
  28. {"name": "升级后等级", "value": "{升级后等级}"},
  29. }
  30. resp.SelectData = []map[string]string{
  31. {"name": "X小时未签到提醒", "value": "sign"},
  32. {"name": "X小时未登录提醒", "value": "login"},
  33. {"name": "提现到账提醒", "value": "withdraw"},
  34. {"name": "升级提醒", "value": "update"},
  35. }
  36. if notice != nil {
  37. for _, v := range *notice {
  38. tmp := md.NoticeList{
  39. Id: utils.IntToStr(v.Id),
  40. Day: utils.IntToStr(v.Day),
  41. NoticeDay: utils.IntToStr(v.NoticeDay),
  42. JpushOpen: utils.IntToStr(v.JpushOpen),
  43. SmsOpen: utils.IntToStr(v.SmsOpen),
  44. SmsCode: v.SmsCode,
  45. Title: v.Title,
  46. Content: v.Content,
  47. Type: v.Type,
  48. }
  49. noticeList = append(noticeList, tmp)
  50. }
  51. }
  52. resp.List = noticeList
  53. e.OutSuc(c, resp, nil)
  54. return
  55. }
  56. func Save(c *gin.Context) {
  57. var req *md.NoticeSaveReq
  58. if err := c.ShouldBindJSON(&req); err != nil {
  59. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  60. return
  61. }
  62. var data = new(model.JpushNotice)
  63. if utils.StrToInt(req.Id) > 0 {
  64. NewJpushNoticeDb := implement.NewJpushNoticeDb(db.Db)
  65. notice, _ := NewJpushNoticeDb.GetJpushNotice(req.Id)
  66. if notice == nil {
  67. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  68. return
  69. }
  70. data = notice
  71. } else {
  72. data.CreateAt = time.Now()
  73. db.Db.Insert(data)
  74. }
  75. data.UpdateAt = time.Now()
  76. data.Content = req.Content
  77. data.Type = req.Type
  78. data.Title = req.Title
  79. data.Day = utils.StrToInt(req.Day)
  80. data.NoticeDay = utils.StrToInt(req.NoticeDay)
  81. db.Db.Where("id=?", data.Id).Update(data)
  82. e.OutSuc(c, "success", nil)
  83. return
  84. }
  85. func Del(c *gin.Context) {
  86. var req *md.NoticeDelReq
  87. if err := c.ShouldBindJSON(&req); err != nil {
  88. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  89. return
  90. }
  91. db.Db.In("id", req.Id).Delete(&model.JpushNotice{})
  92. e.OutSuc(c, "success", nil)
  93. return
  94. }
  95. func PushList(c *gin.Context) {
  96. var req *md.NoticeListReq
  97. if err := c.ShouldBindJSON(&req); err != nil {
  98. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  99. return
  100. }
  101. var resp md.NoticePushListResp
  102. noticeList := make([]md.NoticePushList, 0)
  103. resp.PlatformData = []map[string]string{
  104. {"name": "全平台", "value": "all"},
  105. {"name": "安卓", "value": "android"},
  106. {"name": "iOS", "value": "ios"},
  107. }
  108. resp.TargetData = []map[string]string{
  109. {"name": "全部会员", "value": "0"},
  110. {"name": "指定会员", "value": "1"},
  111. {"name": "指定等级", "value": "2"},
  112. {"name": "指定标签", "value": "3"},
  113. }
  114. NewJpushRecordDb := implement.NewJpushRecordDb(db.Db)
  115. notice, total, _ := NewJpushRecordDb.FindJpushRecordAndTotal(req.Page, req.Limit, "")
  116. resp.Total = total
  117. if notice != nil {
  118. for _, v := range *notice {
  119. tmp := md.NoticePushList{
  120. Id: utils.IntToStr(v.Id),
  121. Title: v.Title,
  122. Content: v.Content,
  123. Platform: v.Platform,
  124. Target: v.Target,
  125. SendType: utils.IntToStr(v.SendType),
  126. State: utils.IntToStr(v.State),
  127. }
  128. if v.SendStartTime.IsZero() == false {
  129. tmp.SendStartTime = v.SendStartTime.Format("2006-01-02 15:04:05")
  130. }
  131. if v.SendEndTime.IsZero() == false {
  132. tmp.SendEndTime = v.SendEndTime.Format("2006-01-02 15:04:05")
  133. }
  134. noticeList = append(noticeList, tmp)
  135. }
  136. }
  137. resp.List = noticeList
  138. e.OutSuc(c, resp, nil)
  139. return
  140. }
  141. func PushSave(c *gin.Context) {
  142. var req *md.NoticePushSaveReq
  143. if err := c.ShouldBindJSON(&req); err != nil {
  144. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  145. return
  146. }
  147. if utils.StrToInt(req.Id) > 0 {
  148. } else {
  149. data := &model.JpushRecord{
  150. Platform: req.Platform,
  151. Target: req.Target,
  152. UserId: utils.SerializeStr(req.UserList),
  153. TagId: utils.SerializeStr(req.TagList),
  154. Level: utils.SerializeStr(req.Level),
  155. Title: req.Title,
  156. Content: req.Content,
  157. SendType: utils.StrToInt(req.SendType),
  158. SendStartTime: utils.TimeParseStd(req.SendStartTime),
  159. SendEndTime: utils.TimeParseStd(req.SendStartTime),
  160. CreateAt: time.Now(),
  161. UpdateAt: time.Now(),
  162. }
  163. db.Db.Insert(data)
  164. }
  165. e.OutSuc(c, "success", nil)
  166. return
  167. }