广告平台(站长使用)
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.

svc_settle_center_medium.go 3.0 KiB

2 months ago
1 month ago
2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 SettleCenterMediumList(c *gin.Context, req md.SettleCenterDataReq) md.SettleCenterDataRes {
  11. engine := db.Db
  12. NewOriginalWxAdDataDb := implement.NewMediumListDb(engine)
  13. user := GetUser(c)
  14. appId := GetMediumIdStr(c, user.AdmId, req.Name, req.Account)
  15. MediumList, total, _ := NewOriginalWxAdDataDb.FindMediumListBySettleType(c.GetString("mid"), appId, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  16. data := make([]md.SettleCenterDataData, 0)
  17. if len(MediumList) > 0 {
  18. for _, v := range MediumList {
  19. var tmp = md.SettleCenterDataData{
  20. Id: utils.IntToStr(v.MediumId),
  21. SettleType: utils.IntToStr(v.SettlementType),
  22. UpdateAt: v.UpdateAt,
  23. }
  24. tmpApplet := GetMediumInfo(c, v.MediumId)
  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 SettleCenterMediumSave(c *gin.Context, req md.SettleCenterDataSaveReq) {
  42. NewMediumListDb := implement.NewMediumListDb(db.Db)
  43. data, _ := NewMediumListDb.GetMediumList(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 SettleCenterMediumDetail(c *gin.Context, req md.SettleCenterDataDetailReq) md.SettleCenterDataDetailRes {
  54. engine := db.Db
  55. NewMediumSettlementDb := implement.NewMediumSettlementDb(engine)
  56. MediumList, total, _ := NewMediumSettlementDb.FindMediumSettlementList(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(MediumList) > 0 {
  59. for _, v := range MediumList {
  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. }