互动
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.

130 lines
4.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package common
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/logger"
  5. "hudongzhuanjia/models"
  6. im_service "hudongzhuanjia/services/im"
  7. "time"
  8. )
  9. type ImTestCtl struct {
  10. controllers.BaseCtl
  11. }
  12. func (t *ImTestCtl) SendNotice() {
  13. activityId := t.MustGetInt64("activity_id")
  14. status := t.MustGetInt("status")
  15. im_service.SendGroupCustomMessage(1, activityId, im_service.NoticeStatus(status), map[string]interface{}{
  16. "customer_id": 16,
  17. "shake_red_envelope_rule_id": 5,
  18. "timestamp": time.Now().Unix(),
  19. })
  20. t.SUCCESS("发送成功")
  21. }
  22. func (t *ImTestCtl) SendRedPack() {
  23. activityId := t.MustGetInt64("activity_id")
  24. prompt := t.MustGet("prompt")
  25. im_service.SendGroupCustomMessage(1, activityId, im_service.NoticeLiveRedPackStart,
  26. map[string]interface{}{
  27. "live_red_envelope_rule_id": 1,
  28. "prompt": prompt,
  29. "timestamp": time.Now().Unix(),
  30. })
  31. t.SUCCESS("发送成功")
  32. }
  33. type LotteryUser struct {
  34. UserId int64
  35. Username string
  36. UserPhone string
  37. Avatar string
  38. PrizeName string
  39. LadderId int64
  40. PrizeImg string
  41. }
  42. func (t *ImTestCtl) SendLottery() {
  43. activityId := t.MustGetInt64("activity_id")
  44. ladderId := t.MustGetInt64("lottery_draw_ladder_id")
  45. desc := t.MustGet("desc")
  46. notice := t.MustGetInt("notice")
  47. if notice == 264 {
  48. winners := make([]*LotteryUser, 0)
  49. winners = append(winners, &LotteryUser{
  50. UserId: 1,
  51. Username: "哗啦啦@黄梓健",
  52. UserPhone: "18814098671",
  53. Avatar: "http://thirdwx.qlogo.cn/mmopen/vi_32/U8krFYdib9PITkDicbaNPnJHKpUMJ8unribzyPcUKWKGyJovoKmES6UHW1Zl6bVsUUtmFjyzsUTrajAJ53icZpEcgw/132",
  54. PrizeName: "白金王座",
  55. LadderId: ladderId,
  56. PrizeImg: "http://thirdwx.qlogo.cn/mmopen/vi_32/U8krFYdib9PITkDicbaNPnJHKpUMJ8unribzyPcUKWKGyJovoKmES6UHW1Zl6bVsUUtmFjyzsUTrajAJ53icZpEcgw/132",
  57. })
  58. winners = append(winners, &LotteryUser{
  59. UserId: 3,
  60. Username: "明月清风",
  61. UserPhone: "18814098673",
  62. Avatar: "http://thirdwx.qlogo.cn/mmopen/vi_32/ZbibUK9Ywia2TtmQCxlyQPrxqKKzed1q4IWA5EUhMEgDiaKOnDODVrAvtKGE9qpFFZYoYfdsZrm63HKMKMA7on38A/132",
  63. PrizeName: "白银王座",
  64. LadderId: ladderId,
  65. PrizeImg: "http://thirdwx.qlogo.cn/mmopen/vi_32/U8krFYdib9PITkDicbaNPnJHKpUMJ8unribzyPcUKWKGyJovoKmES6UHW1Zl6bVsUUtmFjyzsUTrajAJ53icZpEcgw/132",
  66. })
  67. winners = append(winners, &LotteryUser{
  68. UserId: 4,
  69. Username: "Liujw",
  70. UserPhone: "18814098672",
  71. Avatar: "http://thirdwx.qlogo.cn/mmopen/vi_32/ajNVdqHZLLCO4qnL4BtyfjDQHhYmU8MgUZK11cABc8KFY7oenQYNErtm0n2ibfFB4QkFXfT3tVNMGqibDb3Oib30Q/132",
  72. PrizeName: "青铜王座",
  73. LadderId: ladderId,
  74. PrizeImg: "http://thirdwx.qlogo.cn/mmopen/vi_32/ajNVdqHZLLCO4qnL4BtyfjDQHhYmU8MgUZK11cABc8KFY7oenQYNErtm0n2ibfFB4QkFXfT3tVNMGqibDb3Oib30Q/132",
  75. })
  76. im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeStatus(notice),
  77. map[string]interface{}{
  78. "lottery_draw_ladder_id": ladderId,
  79. "winners": winners,
  80. "timestamp": time.Now().Unix(),
  81. "desc": desc,
  82. })
  83. } else {
  84. num := t.MustGetInt("num")
  85. im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeStatus(notice),
  86. map[string]interface{}{
  87. "lottery_draw_ladder_id": ladderId,
  88. "timestamp": time.Now().Unix(),
  89. "desc": desc,
  90. "number": num,
  91. })
  92. }
  93. t.SUCCESS("恭喜这B")
  94. }
  95. func (t *ImTestCtl) SendGood() {
  96. userId := t.MustGetInt64("user_id")
  97. orderNo := t.MustGet("order_no")
  98. activityId := t.MustGetInt64("activity_id")
  99. subs, err := models.GetCustomerOrderSubsByOrderNos(orderNo)
  100. if err != nil {
  101. logger.Error("商品子订单查询异常", err)
  102. }
  103. for _, sub := range subs {
  104. err = im_service.SendGroupCustomMessage(userId, activityId, im_service.NoticeLiveGoodBuy,
  105. map[string]interface{}{
  106. "goods_pic_url": sub.GoodsPicUrl,
  107. "goods_num": sub.GoodsNum,
  108. "good_name": sub.GoodName,
  109. "good_price": sub.GoodPrice,
  110. "goods_id": sub.GoodsId,
  111. "timestamp": time.Now().Unix(),
  112. })
  113. if err != nil {
  114. logger.Error("直播商品子订单信息发送异常异常", err)
  115. }
  116. }
  117. t.SUCCESS("发送成功")
  118. }