|
|
@ -17,51 +17,62 @@ func Handle(order *models.UserOrder) error { |
|
|
|
} |
|
|
|
if order.GoodType == 4 { // 直播商品
|
|
|
|
customerOrder := new(models.CustomerOrder) |
|
|
|
exist, err := customerOrder.GetByOutTradeNO(order.OutTradeNo) |
|
|
|
if err != nil || !exist { |
|
|
|
return errors.New("直播商品信息异常") |
|
|
|
} |
|
|
|
//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("互动信息异常") |
|
|
|
if customerOrder.Status == 1 { |
|
|
|
return errors.New("商品已经支付") |
|
|
|
} |
|
|
|
|
|
|
|
gift := new(models.OrderGift) |
|
|
|
exist, err = gift.GetByActivityId(order.ActivityId) |
|
|
|
_, err := customerOrder.UpdateStatusBy(order.OutTradeNo, 0, 1) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return errors.New("更新状态发送错误") |
|
|
|
} |
|
|
|
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 |
|
|
|
} |
|
|
|
} |
|
|
|
//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) |
|
|
|