蛋蛋星球-制度模式
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.

marketing_api_test.go 3.1 KiB

1 month ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package alipay
  2. import (
  3. "io"
  4. "os"
  5. "testing"
  6. "github.com/go-pay/gopay"
  7. "github.com/go-pay/xlog"
  8. )
  9. func TestOpenAppQrcodeCreate(t *testing.T) {
  10. // 请求参数
  11. bm := make(gopay.BodyMap)
  12. bm.Set("url_param", "page/component/component-pages/view/view").
  13. Set("query_param", "x=1").
  14. Set("describe", "二维码描述")
  15. // 发起请求
  16. aliRsp, err := client.OpenAppQrcodeCreate(ctx, bm)
  17. if err != nil {
  18. xlog.Error(err)
  19. return
  20. }
  21. xlog.Debug("aliRsp.Response:", aliRsp.Response)
  22. }
  23. func TestMarketingCampaignCashCreate(t *testing.T) {
  24. // 请求参数
  25. bm := make(gopay.BodyMap)
  26. bm.Set("coupon_name", "test_name").
  27. Set("prize_type", "0").
  28. Set("total_money", "0.1").
  29. Set("total_num", "1").
  30. Set("prize_msg", "test_prize_msg").
  31. Set("start_time", "0").
  32. Set("end_time", "0").
  33. Set("merchant_link", "0")
  34. // 发起请求
  35. aliRsp, err := client.MarketingCampaignCashCreate(ctx, bm)
  36. if err != nil {
  37. xlog.Error(err)
  38. return
  39. }
  40. xlog.Debug("aliRsp.Response:", aliRsp.Response)
  41. }
  42. func TestMarketingCampaignCashTrigger(t *testing.T) {
  43. // 请求参数
  44. bm := make(gopay.BodyMap)
  45. bm.Set("user_id", "1").
  46. Set("crowd_no", "1").
  47. Set("login_id", "1").
  48. Set("order_price", "0").
  49. Set("out_biz_no", "1")
  50. // 发起请求
  51. aliRsp, err := client.MarketingCampaignCashTrigger(ctx, bm)
  52. if err != nil {
  53. xlog.Error(err)
  54. return
  55. }
  56. xlog.Debug("aliRsp.Response:", aliRsp.Response)
  57. }
  58. func TestMarketingCampaignCashStatusModify(t *testing.T) {
  59. // 请求参数
  60. bm := make(gopay.BodyMap)
  61. bm.Set("crowd_no", "1").
  62. Set("camp_status", "1")
  63. // 发起请求
  64. aliRsp, err := client.MarketingCampaignCashStatusModify(ctx, bm)
  65. if err != nil {
  66. xlog.Error(err)
  67. return
  68. }
  69. xlog.Debug("aliRsp.Response:", aliRsp.Response)
  70. }
  71. func TestMarketingCampaignCashListQuery(t *testing.T) {
  72. // 请求参数
  73. bm := make(gopay.BodyMap)
  74. bm.Set("camp_status", "1").
  75. Set("page_size", "1").
  76. Set("page_index", "1")
  77. // 发起请求
  78. aliRsp, err := client.MarketingCampaignCashListQuery(ctx, bm)
  79. if err != nil {
  80. xlog.Error(err)
  81. return
  82. }
  83. xlog.Debug("aliRsp.Response:", aliRsp.Response)
  84. }
  85. func TestMarketingCampaignCashDetailQuery(t *testing.T) {
  86. // 请求参数
  87. bm := make(gopay.BodyMap)
  88. bm.Set("crowd_no", "POYb84lfiKVdIfERAYsqPL_KQRIpfQbl47xfRmmPBlDMnSZ96O-zxUfKlHp5cxmx")
  89. // 发起请求
  90. aliRsp, err := client.MarketingCampaignCashDetailQuery(ctx, bm)
  91. if err != nil {
  92. xlog.Error(err)
  93. return
  94. }
  95. xlog.Debug("aliRsp.Response:", aliRsp.Response)
  96. }
  97. func TestMarketingMaterialImageUpload(t *testing.T) {
  98. // 请求参数
  99. logo, err := os.Open("../logo.png")
  100. if err != nil {
  101. xlog.Errorf("os.Open(%s),error:%+v", "../logo.png", err)
  102. return
  103. }
  104. xlog.Warnf("fileName: %s", logo.Name())
  105. allBs, err := io.ReadAll(logo)
  106. if err != nil {
  107. xlog.Errorf("io.ReadAll(%s),error:%+v", logo.Name(), err)
  108. return
  109. }
  110. f := &gopay.File{
  111. Name: "logo.png",
  112. Content: allBs,
  113. }
  114. bm := make(gopay.BodyMap)
  115. bm.Set("file_key", "PROMO_VOUCHER_IMAGE").
  116. SetFormFile("file_content", f)
  117. aliRsp, err := client.MarketingMaterialImageUpload(ctx, bm)
  118. if err != nil {
  119. xlog.Errorf("client.MarketingMaterialImageUpload(),error:%+v", err)
  120. return
  121. }
  122. xlog.Debug("aliRsp:", *aliRsp)
  123. }