format.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package income
  2. import (
  3. "fmt"
  4. "strconv"
  5. model "go-common/app/admin/main/growup/model/income"
  6. )
  7. func formatUpWithdraw(ups []*model.UpWithdrawRes, isDeleted int) (data [][]string) {
  8. if len(ups) <= 0 {
  9. return
  10. }
  11. data = make([][]string, len(ups)+1)
  12. if isDeleted == 0 {
  13. data[0] = []string{"UID", "昵称", "已提现", "未提现", "最近提现时间"}
  14. for i := 1; i <= len(ups); i++ {
  15. up := ups[i-1]
  16. data[i] = []string{
  17. strconv.FormatInt(up.MID, 10),
  18. up.Nickname,
  19. up.WithdrawIncome,
  20. up.UnWithdrawIncome,
  21. up.WithdrawDate,
  22. }
  23. }
  24. } else {
  25. data[0] = []string{"UID", "昵称", "禁止提现", "禁止时间", "已提现", "最近提现时间"}
  26. for i := 1; i <= len(ups); i++ {
  27. up := ups[i-1]
  28. data[i] = []string{
  29. strconv.FormatInt(up.MID, 10),
  30. up.Nickname,
  31. up.UnWithdrawIncome,
  32. up.MTime.Time().Format(_layout),
  33. up.WithdrawIncome,
  34. up.WithdrawDate,
  35. }
  36. }
  37. }
  38. return
  39. }
  40. func formatUpIncomeWithdraw(ups []*model.UpIncomeWithdraw) (data [][]string) {
  41. if len(ups) <= 0 {
  42. return
  43. }
  44. data = make([][]string, len(ups)+1)
  45. data[0] = []string{"最近一次提现日期", "UP主ID", "UP主昵称", "已经提现的收入"}
  46. for i := 1; i <= len(ups); i++ {
  47. up := ups[i-1]
  48. data[i] = []string{
  49. up.MTime.Time().Format("2006-01-02"),
  50. strconv.FormatInt(up.MID, 10),
  51. up.Nickname,
  52. fmt.Sprintf("%.2f", fromYuanToFen(up.WithdrawIncome)),
  53. }
  54. }
  55. return
  56. }
  57. func formatUpIncome(ups []*model.UpIncome) (data [][]string) {
  58. if len(ups) <= 0 {
  59. return
  60. }
  61. data = make([][]string, 1)
  62. data[0] = []string{"时间", "UID", "昵称", "新增收入", "稿件数", "基础收入", "额外收入", "违规扣除", "扣税金额", "累计收入"}
  63. for _, up := range ups {
  64. data = append(data, []string{
  65. up.DateFormat,
  66. strconv.FormatInt(up.MID, 10),
  67. up.Nickname,
  68. fmt.Sprintf("%.2f", fromYuanToFen(up.Income)),
  69. strconv.FormatInt(up.AvCount, 10),
  70. fmt.Sprintf("%.2f", fromYuanToFen(up.BaseIncome)),
  71. fmt.Sprintf("%.2f", fromYuanToFen(up.ExtraIncome)),
  72. fmt.Sprintf("%.2f", fromYuanToFen(up.Breach)),
  73. fmt.Sprintf("%.2f", fromYuanToFen(up.TaxMoney)),
  74. fmt.Sprintf("%.2f", fromYuanToFen(up.TotalIncome)),
  75. })
  76. }
  77. return
  78. }
  79. func formatBreach(breachs []*model.AvBreach) (data [][]string) {
  80. if len(breachs) <= 0 {
  81. return
  82. }
  83. ctype := []string{"视频", "音频", "专栏", "素材"}
  84. data = make([][]string, 1)
  85. data[0] = []string{"日期", "稿件id", "稿件类型", "投稿时间", "UID", "up主昵称", "扣除金额", "扣除原因"}
  86. for _, b := range breachs {
  87. data = append(data, []string{
  88. b.CDate.Time().Format(_layout),
  89. strconv.FormatInt(b.AvID, 10),
  90. ctype[b.CType],
  91. b.UploadTime.Time().Format(_layout),
  92. strconv.FormatInt(b.MID, 10),
  93. b.Nickname,
  94. fmt.Sprintf("%.2f", fromYuanToFen(b.Money)),
  95. b.Reason,
  96. })
  97. }
  98. return
  99. }