request_example.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package model
  2. import (
  3. "encoding/csv"
  4. "fmt"
  5. "time"
  6. xtime "go-common/library/time"
  7. )
  8. // QueryActivityByIDReq arg
  9. type QueryActivityByIDReq struct {
  10. FromDate string `form:"from_date"` // 20180101
  11. ToDate string `form:"to_date"` // 20180102 closed interval [20180101, 20180102]
  12. ID int64 `form:"id"` // activity id, if not 0, FromDate and toDate not used
  13. PageArg
  14. ExportArg
  15. }
  16. //UpSummaryBonusInfo bonus for one up info
  17. type UpSummaryBonusInfo struct {
  18. Mid int64 `json:"mid"`
  19. BilledMoney float64 `json:"billed_money"`
  20. UnbilledMoney float64 `json:"unbilled_money"`
  21. LastBillTime string `json:"last_bill_time"` // 20180101, 最近结算时间
  22. TmpBillTime xtime.Time `json:"-"` // 用来计算LastBillTime
  23. TotalBonusMoney float64 `json:"total_bonus_money"` // 所有的中奖金额
  24. }
  25. //QueryUpBonusByMidResult query result
  26. type QueryUpBonusByMidResult struct {
  27. Result []*UpSummaryBonusInfo `json:"result"`
  28. PageResult
  29. }
  30. //GetFileName get file name
  31. func (q *QueryUpBonusByMidResult) GetFileName() string {
  32. return fmt.Sprintf("%s_%s.csv", "结算记录", time.Now().Format(dateTimeFmt))
  33. }
  34. //ToCsv to buffer
  35. func (q *QueryUpBonusByMidResult) ToCsv(writer *csv.Writer) {
  36. var title = []string{
  37. "UID",
  38. "已结算",
  39. "未结算",
  40. "最近结算时间"}
  41. writer.Write(title)
  42. if q == nil {
  43. return
  44. }
  45. for _, v := range q.Result {
  46. var record []string
  47. record = append(record,
  48. intFormat(v.Mid),
  49. floatFormat(v.BilledMoney),
  50. floatFormat(v.UnbilledMoney),
  51. v.LastBillTime,
  52. )
  53. writer.Write(record)
  54. }
  55. }