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.
|
|
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 == 4 { // 直播商品
customerOrder := new(models.CustomerOrder) exist, err := customerOrder.GetByOutTradeNO(order.OutTradeNo) if err != nil || !exist { return errors.New("直播商品信息异常") }
activity := new(models.Activity) exist, err = models.GetById(activity, order.ActivityId) if err != nil || !exist { return errors.New("互动信息异常") }
gift := new(models.OrderGift) exist, err = gift.GetByActivityId(order.ActivityId) if err != nil { return err } prize := new(models.UserPrize) prize.UserId = order.UserId prize.ActivityId = order.ActivityId prize.RehearsalId = activity.RehearsalId prize.ActivityName = activity.Name prize.PrizeName = gift.GiftName prize.PrizeImg = gift.GiftPicUrl prize.PrizeType = 4 prize.IsDelete = false prize.CreatedAt = time.Now() prize.UpdatedAt = time.Now() if exist { if gift.Num < 0 { } else if gift.Num > 0 { count, err := new(models.CustomerOrder).Count(activity.Id, activity.RehearsalId, customerOrder.CreatedAt) if err != nil { return err }
if gift.Num <= int(count) { // 人数足够
return nil } } // gift.Num = 0 and
_, err = prize.Add() if err != nil { return err } }
} else 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 }
|