广告平台(站长下代理使用)
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

svc_financial_dynamics.go 2.3 KiB

2 meses atrás
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 FinancialDynamicsAgentList(c *gin.Context, req md.FinancialDynamicsAgentListReq) md.FinancialDynamicsAgentListRes {
  11. engine := db.Db
  12. NewAgentFinancialDynamicsDb := implement.NewAgentFinancialDynamicsDb(engine)
  13. user := GetUser(c)
  14. list, total, _ := NewAgentFinancialDynamicsDb.FindAgentFinancialDynamics(c.GetString("mid"), utils.IntToStr(user.AgentId), req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  15. data := make([]md.FinancialDynamicsAgentListData, 0)
  16. if len(list) > 0 {
  17. for _, v := range list {
  18. var tmp = md.FinancialDynamicsAgentListData{
  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.FinancialDynamicsAgentListRes{
  31. List: data,
  32. Total: total,
  33. PayMethod: md.PayMethod,
  34. BusinessKind: md.BusinessKind,
  35. }
  36. return res
  37. }
  38. func FinancialDynamicsAgentTotal(c *gin.Context, req md.FinancialDynamicsAgentTotalReq) md.FinancialDynamicsAgentTotalRes {
  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 agent_id=" + utils.IntToStr(user.AgentId)
  44. sql1 := fmt.Sprintf(sql, "agent_list", where)
  45. res := md.FinancialDynamicsAgentTotalRes{
  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, "agent_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. }