Browse Source

订单送礼

master
黄梓健 5 years ago
parent
commit
dbe6912cc1
  1. 3
      controllers/client/order_entry.go
  2. 90
      services/pay/handle.go

3
controllers/client/order_entry.go

@ -97,7 +97,6 @@ func (t *OrderEntryCtl) Order() {
session.Rollback()
t.CheckErr(err)
}
} else if gift.Num > 0 {
count, err := core.GetXormAuto().Where("activity_id=? and rehearsal_id=? and is_delete=0",
activityId, activity.RehearsalId).Count(new(models.CustomerOrder))
@ -119,10 +118,10 @@ func (t *OrderEntryCtl) Order() {
order.UserPrizeId = prize.Id
order.AreaId = entryPerson.AreaId
order.AreaName = area.Name
order.RehearsalId = activity.RehearsalId
order.BuyerId = userId
order.GoodsId = goodId
order.ActivityId = activityId
order.RehearsalId = activity.RehearsalId
order.OrderEntryPersonId = entryPerson.Id
order.GoodsName = good.Name
order.TotalAmount = good.Price

90
services/pay/handle.go

@ -17,11 +17,6 @@ func HandleSuccess(param *OrderDelayQueueParam) (err error) {
var exist bool
if param.Order.GoodType == 4 { // 直播商品
customerOrder := new(models.CustomerOrder)
//exist, err := customerOrder.GetByOutTradeNO(order.OutTradeNo)
//if err != nil || !exist {
// return errors.New("直播商品信息异常")
//}
if customerOrder.Status == 1 {
return errors.New("商品已经支付")
}
@ -31,49 +26,50 @@ func HandleSuccess(param *OrderDelayQueueParam) (err error) {
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
// }
//}
activity := new(models.Activity)
exist, err = models.GetById(activity, param.Order.ActivityId)
if err != nil || !exist {
return errors.New("互动信息异常")
}
gift := new(models.OrderGift)
exist, err = gift.GetByActivityId(param.Order.ActivityId)
if err != nil {
return err
}
prize := new(models.UserPrize)
prize.UserId = param.Order.UserId
prize.ActivityId = param.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 {
err = fmt.Errorf("订单人数统计失败: err->%v, out_trade_no->%v", err, param.Order.OutTradeNo)
return err
}
if gift.Num <= int(count) { // 人数足够
return nil
}
}
// gift.Num = 0 and
_, err = prize.Add()
if err != nil {
err = fmt.Errorf("奖品添加失败: err->%v, out_trade_no->%v", err, param.Order.OutTradeNo)
return err
}
}
} else if param.Order.GoodType == 3 { // 直播红包
info := new(models.LiveRedEnvelopeRule)
_, err = info.UpdateStatusByOutTradeNo(param.Order.OutTradeNo, 1)

Loading…
Cancel
Save