广告平台(站长使用)
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

87 lignes
2.9 KiB

  1. package svc
  2. import (
  3. "applet/app/e"
  4. "applet/app/md"
  5. "applet/app/utils"
  6. db "code.fnuoos.com/zhimeng/model.git/src"
  7. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func SettleCenterAgentList(c *gin.Context, req md.SettleCenterDataReq) md.SettleCenterDataRes {
  11. engine := db.Db
  12. NewOriginalWxAdDataDb := implement.NewAgentListDb(engine)
  13. appId := GetAgentByAccountId(c, req.Name, req.Account)
  14. AgentList, total, _ := NewOriginalWxAdDataDb.FindAgentListBySettleType(c.GetString("mid"), appId, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  15. data := make([]md.SettleCenterDataData, 0)
  16. if len(AgentList) > 0 {
  17. for _, v := range AgentList {
  18. var tmp = md.SettleCenterDataData{
  19. Id: utils.IntToStr(v.AgentId),
  20. SettleType: utils.IntToStr(v.SettlementType),
  21. UpdateAt: v.UpdateAt,
  22. }
  23. tmpApplet := GetAgentInfo(c, v.AgentId)
  24. if tmpApplet["account"] != "" {
  25. tmp.Account = tmpApplet["account"]
  26. }
  27. if tmpApplet["name"] != "" {
  28. tmp.Name = tmpApplet["name"]
  29. }
  30. data = append(data, tmp)
  31. }
  32. }
  33. res := md.SettleCenterDataRes{
  34. List: data,
  35. Total: total,
  36. State: md.AccountSettleState,
  37. }
  38. return res
  39. }
  40. func SettleCenterAgentSave(c *gin.Context, req md.SettleCenterDataSaveReq) {
  41. NewAgentListDb := implement.NewAgentListDb(db.Db)
  42. data, _ := NewAgentListDb.GetAgentList(utils.StrToInt(req.Id))
  43. if data == nil {
  44. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  45. return
  46. }
  47. data.SettlementType = utils.StrToInt(req.SettleType)
  48. db.Db.Where("id=?", data.Id).Cols("settlement_type").Update(data)
  49. e.OutSuc(c, "success", nil)
  50. return
  51. }
  52. func SettleCenterAgentDetail(c *gin.Context, req md.SettleCenterDataDetailReq) md.SettleCenterDataDetailRes {
  53. engine := db.Db
  54. NewAgentSettlementDb := implement.NewAgentSettlementDb(engine)
  55. AgentList, total, _ := NewAgentSettlementDb.FindAgentSettlementList(c.GetString("mid"), req.Id, "", "", "", req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  56. data := make([]md.SettleCenterDataDetailData, 0)
  57. if len(AgentList) > 0 {
  58. for _, v := range AgentList {
  59. var tmp = md.SettleCenterDataDetailData{
  60. TimeStr: v.StartDate,
  61. BusinessKind: utils.IntToStr(v.BusinessKind),
  62. SettleType: utils.IntToStr(v.Kind),
  63. AllIncome: utils.Float64ToStr(float64(v.OtherIncome+v.BasicIncome) / 100),
  64. BasicIncome: utils.Float64ToStr(float64(v.BasicIncome) / 100),
  65. OtherIncome: utils.Float64ToStr(float64(v.OtherIncome) / 100),
  66. PayState: utils.IntToStr(v.PayState),
  67. State: utils.IntToStr(v.State),
  68. }
  69. if v.EndDate != "" && v.EndDate != "0000-00-00" {
  70. tmp.TimeStr += "~" + v.EndDate
  71. }
  72. data = append(data, tmp)
  73. }
  74. }
  75. res := md.SettleCenterDataDetailRes{
  76. List: data,
  77. Total: total,
  78. SettleType: md.AccountSettleState,
  79. BusinessKind: md.BusinessKind,
  80. SettlePayState: md.SettlePayState,
  81. SettleState: md.SettleState,
  82. }
  83. return res
  84. }