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

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