This commit is contained in:
ziming 2025-12-10 09:00:36 +08:00
parent f206764800
commit 7dccb67de3
3 changed files with 33 additions and 37 deletions

View File

@ -56,13 +56,9 @@ func marketingFJxw() *marketing2.Marketing {
//openssl x509 -in xxx.pem -noout -serial
mchId := "1652465541"
wechatPayPublicKeyId := "PUB_KEY_ID_0117109533612025031800326400002563"
wechatPayPublicKeyId := " PUB_KEY_ID_0116524655412025070900181741001803"
certificateSerialNo := "1E3F2CE013203BA9C3DEFC5782FCD3329C3DAC1C"
//mchId := "1652465541"
//wechatPayPublicKeyId := ""
//certificateSerialNo := "1E3F2CE013203BA9C3DEFC5782FCD3329C3DAC1C"
filePath := fmt.Sprintf("%s/cert/wechat/%s", parentDir, mchId)
c, err := utils.CreateMchConfig(
@ -84,20 +80,6 @@ func MarketingSend() {
openId := "oSNb4ftgnWC22Z0cWTjsQebdr2Yk"
appId := "wx619991cc795028f5"
//195516196845312409613
//openId := "ocuH-0Nymo4sJLRNabIBbg9H2XCo"
//appId := "wx5d3e839568f24b2b"
//respBody={"coupon_id":"116076813524"}
//openId := "ocZ-njugTd_fgCJMHTG8PukPAVm4"
//appId := "wxd9137161bc8f9ca9"
//respBody={"coupon_id":"117888124542"}
//195516196845312409613
//1958100775326560252
//1958100775326560251
//19581007753265602565
//19581007753265602564
request := &marketing2.SendReq{
ActivityId: utils.String("11941580000000012"),
StockId: utils.String("20964154"),
@ -128,13 +110,6 @@ func MarketingSend() {
fmt.Printf("请求成功: %s\n", *response.CouponId)
}
func MarketingQuery(appId, openId, couponId string) {
response, err := marketing().Query(appId, openId, couponId)
if err != nil {
fmt.Print(err)
return
}
fmt.Printf("请求成功: %+v\n", response)
func MarketingQuery(appId, openId, couponId string) (response *marketing2.SendResp, err error) {
return marketingFJxw().Query(appId, openId, couponId)
}

View File

@ -26,12 +26,24 @@ func Test_MarketingQuery(t *testing.T) {
name: "查询绑定多笔立减活动的代金券详情", // 查询的商户非创建方商户 查询商户要为创建方商户
appId: "wx619991cc795028f5",
openId: "oSNb4ftgnWC22Z0cWTjsQebdr2Yk",
couponId: "122529292094",
couponId: "139923450432",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
MarketingQuery(tt.appId, tt.openId, tt.couponId)
resp, err := MarketingQuery(tt.appId, tt.openId, tt.couponId)
if err != nil {
t.Errorf("MarketingQuery() error = %v", err)
return
}
t.Logf("MarketingQuery() = %v", resp)
})
}
// 合单订单就是没有核销回调通知的
// {"code":"APPID_MCHID_NOT_MATCH","message":"商户号与AppID不匹配"}
// APPID_MCHID_NOT_MATCH 商户号与AppID不匹配 调用接口的商户号需与接口传入的AppID有绑定关系
//openid不是自己的appid下的喔这也能查询到吗”
//不行的需要是在自己appid下的才能查到
}

View File

@ -24,6 +24,15 @@ var bc = &conf.Bootstrap{
},
}
var bc2 = &conf.Bootstrap{
Wechat: &conf.Wechat{
MchID: "1652465541", // notifyUrl https://nsall.86698.cn/wechatPay/coupon_notify/fjxingwang
MchCertificateSerialNumber: "1E3F2CE013203BA9C3DEFC5782FCD3329C3DAC1C",
WechatPayPublicKeyID: "PUB_KEY_ID_0116524655412025070900181741001803",
Name: "福建兴旺",
},
}
func SendCoupon() {
ctx := context.Background()
@ -94,8 +103,8 @@ func QueryCoupon() {
}
appId := "wx619991cc795028f5"
openId := "oSNb4ftgnWC22Z0cWTjsQebdr2Yk"
couponId := "122529292094"
openId := "oSNb4fulXAleiammvWXnz1pRghAE"
couponId := "142388354994"
req := cashcoupons.QueryCouponRequest{
CouponId: core.String(couponId),
@ -148,8 +157,8 @@ func QueryProduct() {
}
req := cashcoupons.QueryStockRequest{
StockId: core.String("20965520"),
StockCreatorMchid: core.String("1652465541"),
StockId: core.String("21386505"),
StockCreatorMchid: core.String("1715349578"),
}
svc := cashcoupons.StockApiService{Client: client}
@ -226,9 +235,9 @@ func QueryCallback() {
parentDir := filepath.Dir(dir)
server := data.Server{
MchID: bc.Wechat.MchID,
MchCertificateSerialNumber: bc.Wechat.MchCertificateSerialNumber,
WechatPayPublicKeyID: bc.Wechat.WechatPayPublicKeyID,
MchID: bc2.Wechat.MchID,
MchCertificateSerialNumber: bc2.Wechat.MchCertificateSerialNumber,
WechatPayPublicKeyID: bc2.Wechat.WechatPayPublicKeyID,
Dir: parentDir,
}
client, err := data.GetClient(ctx, server)