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

40 lines
1.1 KiB

5 years ago
  1. package pay_service
  2. import (
  3. "errors"
  4. "hudongzhuanjia/libs/im"
  5. "hudongzhuanjia/models"
  6. im_service "hudongzhuanjia/services/im"
  7. "time"
  8. )
  9. //处理支付成功之后的回调问题
  10. // 直播红包
  11. func Handle(order *models.UserOrder) error {
  12. if order == nil {
  13. return errors.New("订单信息不存在")
  14. }
  15. if order.GoodType == 3 { // 直播红包
  16. info := new(models.LiveRedEnvelopeRule)
  17. exist, err := info.GetByOutTradeNo(order.OutTradeNo)
  18. if err != nil || !exist {
  19. return errors.New("直播红包信息异常")
  20. }
  21. return im_service.SendNoticeByActivityId(order.ActivityId, im.NoticeLiveRedPackStart,
  22. map[string]interface{}{
  23. "live_red_envelope_rule_id": info.Id,
  24. "timestamp": time.Now().Unix(),
  25. })
  26. } else if order.GoodType == 2 { // 打赏
  27. history := new(models.RewardHistory)
  28. _, err := history.UpdateStatusByOutTradeNo(order.OutTradeNo, 0)
  29. return err
  30. } else if order.GoodType == 1 { // 霸屏
  31. history := new(models.BullyScreenHistory)
  32. _, err := history.UpdateStatusByOutTradeNo(order.OutTradeNo, 0)
  33. return err
  34. }
  35. return nil
  36. }