广告平台(媒体使用)
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

72 líneas
2.3 KiB

  1. package svc
  2. import (
  3. "applet/app/md"
  4. "applet/app/utils"
  5. db "code.fnuoos.com/zhimeng/model.git/src"
  6. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  7. "fmt"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func FinancialDynamicsMediumList(c *gin.Context, req md.FinancialDynamicsMediumListReq) md.FinancialDynamicsMediumListRes {
  11. engine := db.Db
  12. NewMediumFinancialDynamicsDb := implement.NewMediumFinancialDynamicsDb(engine)
  13. user := GetUser(c)
  14. list, total, _ := NewMediumFinancialDynamicsDb.FindMediumFinancialDynamics(c.GetString("mid"), utils.IntToStr(user.MediumId), req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  15. data := make([]md.FinancialDynamicsMediumListData, 0)
  16. if len(list) > 0 {
  17. for _, v := range list {
  18. var tmp = md.FinancialDynamicsMediumListData{
  19. Id: utils.IntToStr(v.Id),
  20. PayTime: v.PayTime,
  21. Amount: v.Amount,
  22. PayMethod: utils.IntToStr(v.PayMethod),
  23. Certificate: v.Certificate,
  24. Memo: v.Memo,
  25. BusinessKind: utils.IntToStr(v.BusinessKind),
  26. }
  27. data = append(data, tmp)
  28. }
  29. }
  30. res := md.FinancialDynamicsMediumListRes{
  31. List: data,
  32. Total: total,
  33. PayMethod: md.PayMethod,
  34. BusinessKind: md.BusinessKind,
  35. }
  36. return res
  37. }
  38. func FinancialDynamicsMediumTotal(c *gin.Context, req md.FinancialDynamicsMediumTotalReq) md.FinancialDynamicsMediumTotalRes {
  39. engine := db.Db
  40. sql := `select sum(amount) as amount,COUNT(*) as count from %s where %s`
  41. where := "uuid=" + c.GetString("mid")
  42. user := GetUser(c)
  43. where += " and medium_id=" + utils.IntToStr(user.MediumId)
  44. sql1 := fmt.Sprintf(sql, "medium_list", where)
  45. res := md.FinancialDynamicsMediumTotalRes{
  46. BalanceAmount: "0.00",
  47. AllAmount: "0.00",
  48. UseAmount: "0.00",
  49. PayCount: "0",
  50. }
  51. nativeString, _ := db.QueryNativeString(engine, sql1)
  52. for _, v := range nativeString {
  53. if utils.StrToFloat64(v["amount"]) > 0 {
  54. res.BalanceAmount = v["amount"]
  55. }
  56. }
  57. sql2 := fmt.Sprintf(sql, "medium_financial_dynamics", where)
  58. nativeString2, _ := db.QueryNativeString(engine, sql2)
  59. for _, v := range nativeString2 {
  60. if utils.StrToFloat64(v["amount"]) > 0 {
  61. res.AllAmount = v["amount"]
  62. }
  63. if utils.StrToFloat64(v["count"]) > 0 {
  64. res.PayCount = v["count"]
  65. }
  66. }
  67. res.UseAmount = utils.Float64ToStr(utils.StrToFloat64(res.AllAmount) - utils.StrToFloat64(res.BalanceAmount))
  68. return res
  69. }