package common import ( "hudongzhuanjia/controllers" "hudongzhuanjia/logger" "hudongzhuanjia/models" im_service "hudongzhuanjia/services/im" "time" ) type ImTestCtl struct { controllers.BaseCtl } func (t *ImTestCtl) SendNotice() { activityId := t.MustGetInt64("activity_id") status := t.MustGetInt("status") im_service.SendGroupCustomMessage(1, activityId, im_service.NoticeStatus(status), map[string]interface{}{ "customer_id": 16, "shake_red_envelope_rule_id": 5, "timestamp": time.Now().Unix(), }) t.SUCCESS("发送成功") } func (t *ImTestCtl) SendRedPack() { activityId := t.MustGetInt64("activity_id") prompt := t.MustGet("prompt") im_service.SendGroupCustomMessage(1, activityId, im_service.NoticeLiveRedPackStart, map[string]interface{}{ "live_red_envelope_rule_id": 1, "prompt": prompt, "timestamp": time.Now().Unix(), }) t.SUCCESS("发送成功") } type LotteryUser struct { UserId int64 Username string UserPhone string Avatar string PrizeName string LadderId int64 PrizeImg string } func (t *ImTestCtl) SendLottery() { activityId := t.MustGetInt64("activity_id") ladderId := t.MustGetInt64("lottery_draw_ladder_id") desc := t.MustGet("desc") notice := t.MustGetInt("notice") if notice == 264 { winners := make([]*LotteryUser, 0) winners = append(winners, &LotteryUser{ UserId: 1, Username: "哗啦啦@黄梓健", UserPhone: "18814098671", Avatar: "http://thirdwx.qlogo.cn/mmopen/vi_32/U8krFYdib9PITkDicbaNPnJHKpUMJ8unribzyPcUKWKGyJovoKmES6UHW1Zl6bVsUUtmFjyzsUTrajAJ53icZpEcgw/132", PrizeName: "白金王座", LadderId: ladderId, PrizeImg: "http://thirdwx.qlogo.cn/mmopen/vi_32/U8krFYdib9PITkDicbaNPnJHKpUMJ8unribzyPcUKWKGyJovoKmES6UHW1Zl6bVsUUtmFjyzsUTrajAJ53icZpEcgw/132", }) winners = append(winners, &LotteryUser{ UserId: 3, Username: "明月清风", UserPhone: "18814098673", Avatar: "http://thirdwx.qlogo.cn/mmopen/vi_32/ZbibUK9Ywia2TtmQCxlyQPrxqKKzed1q4IWA5EUhMEgDiaKOnDODVrAvtKGE9qpFFZYoYfdsZrm63HKMKMA7on38A/132", PrizeName: "白银王座", LadderId: ladderId, PrizeImg: "http://thirdwx.qlogo.cn/mmopen/vi_32/U8krFYdib9PITkDicbaNPnJHKpUMJ8unribzyPcUKWKGyJovoKmES6UHW1Zl6bVsUUtmFjyzsUTrajAJ53icZpEcgw/132", }) winners = append(winners, &LotteryUser{ UserId: 4, Username: "Liujw", UserPhone: "18814098672", Avatar: "http://thirdwx.qlogo.cn/mmopen/vi_32/ajNVdqHZLLCO4qnL4BtyfjDQHhYmU8MgUZK11cABc8KFY7oenQYNErtm0n2ibfFB4QkFXfT3tVNMGqibDb3Oib30Q/132", PrizeName: "青铜王座", LadderId: ladderId, PrizeImg: "http://thirdwx.qlogo.cn/mmopen/vi_32/ajNVdqHZLLCO4qnL4BtyfjDQHhYmU8MgUZK11cABc8KFY7oenQYNErtm0n2ibfFB4QkFXfT3tVNMGqibDb3Oib30Q/132", }) im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeStatus(notice), map[string]interface{}{ "lottery_draw_ladder_id": ladderId, "winners": winners, "timestamp": time.Now().Unix(), "desc": desc, }) } else { num := t.MustGetInt("num") im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeStatus(notice), map[string]interface{}{ "lottery_draw_ladder_id": ladderId, "timestamp": time.Now().Unix(), "desc": desc, "number": num, }) } t.SUCCESS("恭喜这B") } func (t *ImTestCtl) SendGood() { userId := t.MustGetInt64("user_id") orderNo := t.MustGet("order_no") activityId := t.MustGetInt64("activity_id") subs, err := models.GetCustomerOrderSubsByOrderNos(orderNo) if err != nil { logger.Error("商品子订单查询异常", err) } for _, sub := range subs { err = im_service.SendGroupCustomMessage(userId, activityId, im_service.NoticeLiveGoodBuy, map[string]interface{}{ "goods_pic_url": sub.GoodsPicUrl, "goods_num": sub.GoodsNum, "good_name": sub.GoodName, "good_price": sub.GoodPrice, "goods_id": sub.GoodsId, "timestamp": time.Now().Unix(), }) if err != nil { logger.Error("直播商品子订单信息发送异常异常", err) } } t.SUCCESS("发送成功") }