From 19a3ecc0df7b470378bccbfc1980ae3bc9d6bd27 Mon Sep 17 00:00:00 2001 From: ziming Date: Tue, 22 Apr 2025 17:52:30 +0800 Subject: [PATCH] test --- internal/data/wechat_test.go | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/internal/data/wechat_test.go b/internal/data/wechat_test.go index 7c00fcd..61c5c7c 100644 --- a/internal/data/wechat_test.go +++ b/internal/data/wechat_test.go @@ -44,3 +44,40 @@ func TestGetClient(t *testing.T) { t.Log(response) } + +func TestCoupon(t *testing.T) { + + server := Server{ + MchID: "1710953361", // 证书所属商户 蓝色兄弟服务商立减金配置 + MchCertificateSerialNumber: "6006B8208815DB5EAC5BF2E783CB9D34082C3772", + } + + ctx := context.Background() + + client, err := GetClient(ctx, server) + if err != nil { + t.Error(err) + return + } + + req := cashcoupons.SendCouponRequest{ + OutRequestNo: core.String("123456"), + // 微信为发券方商户分配的公众账号ID,接口传入的所有appid应该为公众号的appid(在mp.weixin.qq.com申请的),不能为APP的appid(在open.weixin.qq.com申请的)。 + Appid: core.String("wx619991cc795028f5"), + Openid: core.String("oSNb4ftgnWC22Z0cWTjsQebdr2Yk"), + StockId: core.String("20395589"), + StockCreatorMchid: core.String("1652465541"), + } + + svc := cashcoupons.CouponApiService{Client: client} + + resp, result, err := svc.SendCoupon(ctx, req) + + if err != nil { + t.Error(err) + return + } + + t.Logf("\nresp:%+v\n result:%+v", resp, result) + return +}