order.go 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package service
  2. import (
  3. "time"
  4. "go-common/app/admin/main/tv/model"
  5. "go-common/library/log"
  6. )
  7. const (
  8. _orderTable = "tv_pay_order"
  9. )
  10. //OrderList user tv-vip order list
  11. func (s *Service) OrderList(mid, pn, ps, paymentStime, paymentEtime int64, status int8, orderNo string) (data *model.OrderPageHelper, err error) {
  12. var (
  13. db = s.dao.DB.Table(_orderTable)
  14. orders []*model.TvPayOrderResp
  15. )
  16. data = &model.OrderPageHelper{}
  17. if mid != 0 {
  18. db = db.Where("mid = ?", mid)
  19. }
  20. if orderNo != "" {
  21. db = db.Where("order_no = ?", orderNo)
  22. }
  23. if status != 0 {
  24. db = db.Where("status = ?", status)
  25. }
  26. if paymentStime != 0 {
  27. db = db.Where("payment_time > ?", time.Unix(paymentStime, 0))
  28. }
  29. if paymentEtime != 0 {
  30. db = db.Where("payment_time < ?", time.Unix(paymentEtime, 0))
  31. }
  32. db.Count(&data.Total)
  33. if err := db.Offset((pn - 1) * ps).Limit(ps).Find(&orders).Error; err != nil {
  34. log.Error("OrderList %v, Err %v", orders, err)
  35. }
  36. data.Items = orders
  37. return
  38. }