广告平台(站长使用)
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

109 rindas
3.0 KiB

  1. package hdl
  2. import (
  3. "applet/app/e"
  4. "applet/app/lib/wechat"
  5. "applet/app/md"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
  9. db "code.fnuoos.com/zhimeng/model.git/src"
  10. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  11. "fmt"
  12. "github.com/gin-gonic/gin"
  13. )
  14. func Demo(c *gin.Context) {
  15. for {
  16. mediumId := utils.GenerateUniqueRandomNumbers(8)
  17. fmt.Println(mediumId)
  18. }
  19. appId := c.DefaultQuery("app_id", "")
  20. masterId := svc.GetMasterId(c)
  21. adUnitId := c.DefaultQuery("adunit_id", "")
  22. // 1、查找对应 user_wx_applet_list 记录
  23. userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db)
  24. UserWxAppletList, err := userWxAppletListDb.GetUserWxAppletList(masterId)
  25. if err != nil {
  26. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  27. return
  28. }
  29. if UserWxAppletList == nil {
  30. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  31. return
  32. }
  33. wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db)
  34. wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId))
  35. if err != nil {
  36. e.OutErr(c, e.ERR, err.Error())
  37. return
  38. }
  39. if wxOpenThirdPartyAppList == nil {
  40. e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录")
  41. return
  42. }
  43. ch, err := rabbit.Cfg.Pool.GetChannel()
  44. if err != nil {
  45. return
  46. }
  47. defer ch.Release()
  48. var arg = md.ZhiosAdOriginalDataApplication{
  49. Mid: "123456",
  50. AppId: "123",
  51. AdId: "123",
  52. Date: "123",
  53. ComponentAppsecret: wxOpenThirdPartyAppList.AppSecret,
  54. ComponentAppid: wxOpenThirdPartyAppList.Appid,
  55. }
  56. err = ch.PublishV2(md.AdOriginalData, arg, md.AdOriginalDataApplication)
  57. if err != nil {
  58. ch.PublishV2(md.AdOriginalData, arg, md.AdOriginalDataApplication)
  59. }
  60. return
  61. wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret)
  62. if err != nil {
  63. e.OutErr(c, e.ERR, err.Error())
  64. return
  65. }
  66. err, args := wxApiService.GetAdposDetail(appId, 1, 10, "2024-08-19", "2024-08-23", adUnitId)
  67. if err != nil {
  68. e.OutErr(c, e.ERR, err.Error())
  69. return
  70. }
  71. e.OutSuc(c, map[string]interface{}{
  72. "args": args,
  73. }, nil)
  74. return
  75. }
  76. func GetAuthToken(c *gin.Context) {
  77. masterId := c.DefaultQuery("master_id", "")
  78. wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db)
  79. wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId))
  80. if err != nil {
  81. e.OutErr(c, e.ERR, err.Error())
  82. return
  83. }
  84. if wxOpenThirdPartyAppList == nil {
  85. e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录")
  86. return
  87. }
  88. wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret)
  89. if err != nil {
  90. e.OutErr(c, e.ERR, err.Error())
  91. return
  92. }
  93. auth, err := wxApiService.GetAuth("wxe3e570bee013db1e")
  94. if err != nil {
  95. e.OutErr(c, e.ERR, err.Error())
  96. return
  97. }
  98. e.OutSuc(c, map[string]interface{}{
  99. "data": auth,
  100. }, nil)
  101. return
  102. }