广告平台(站长使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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