cash.out.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package shanghu
  2. import (
  3. "duoduo/apis/shanghu/models"
  4. "duoduo/models/shanghu"
  5. "duoduo/tools/app"
  6. "fmt"
  7. "github.com/gin-gonic/gin"
  8. "time"
  9. )
  10. func CashOutList(c *gin.Context) {
  11. var inData models.CashOutListRequest
  12. var sqlData shanghu.CashOut
  13. var outData []models.CashOutListReply
  14. err := c.ShouldBindJSON(&inData)
  15. if err != nil {
  16. app.Error(c, 400, err, err.Error())
  17. return
  18. }
  19. var pageSize = 10
  20. var pageIndex = 1
  21. if inData.PageSize != 0 {
  22. pageSize = inData.PageSize
  23. }
  24. if inData.PageIndex != 0 {
  25. pageIndex = inData.PageIndex
  26. }
  27. fmt.Println(inData.OpenId)
  28. sqlData.OpenID = inData.OpenId
  29. sqlData.AppID = inData.Appid
  30. cashOutList, count, err := sqlData.GetCashOutList(pageSize, pageIndex)
  31. if err != nil {
  32. app.Error(c, 500, err, err.Error())
  33. return
  34. }
  35. for i := 0; i < len(cashOutList); i++ {
  36. var cashOut models.CashOutListReply
  37. cashOut.Amount = cashOutList[i].Amount.Sub(cashOutList[i].Fee)
  38. cashOut.TotalAmount = cashOutList[i].Amount
  39. cashOut.CreateAt = cashOutList[i].CreatedAt.Format(time.DateTime)
  40. cashOut.Fee = cashOutList[i].Fee
  41. if cashOutList[i].Status == 1 {
  42. cashOut.Des = "提现中"
  43. } else if cashOutList[i].Status == 2 {
  44. cashOut.Des = "提现失败"
  45. } else if cashOutList[i].Status == 3 {
  46. cashOut.Des = "提现成功"
  47. } else if cashOutList[i].Status == 99 {
  48. cashOut.Des = "提现完成"
  49. }
  50. outData = append(outData, cashOut)
  51. }
  52. app.PageOK(c, outData, count, pageIndex, pageSize, app.Success)
  53. }