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

package pay_service
import (
"errors"
"hudongzhuanjia/libs/im"
"hudongzhuanjia/models"
im_service "hudongzhuanjia/services/im"
"time"
)
//处理支付成功之后的回调问题
// 直播红包
func Handle(order *models.UserOrder) error {
if order == nil {
return errors.New("订单信息不存在")
}
if order.GoodType == 3 { // 直播红包
info := new(models.LiveRedEnvelopeRule)
exist, err := info.GetByOutTradeNo(order.OutTradeNo)
if err != nil || !exist {
return errors.New("直播红包信息异常")
}
return im_service.SendNoticeByActivityId(order.ActivityId, im.NoticeLiveRedPackStart,
map[string]interface{}{
"live_red_envelope_rule_id": info.Id,
"timestamp": time.Now().Unix(),
})
} else if order.GoodType == 2 { // 打赏
history := new(models.RewardHistory)
_, err := history.UpdateStatusByOutTradeNo(order.OutTradeNo, 0)
return err
} else if order.GoodType == 1 { // 霸屏
history := new(models.BullyScreenHistory)
_, err := history.UpdateStatusByOutTradeNo(order.OutTradeNo, 0)
return err
}
return nil
}