多笔立减
This commit is contained in:
parent
e15b9ef6c3
commit
4ca489334a
|
|
@ -515,8 +515,8 @@ func (srv *MchConfig) Request2(host, method, path string, reqBody []byte) (respo
|
||||||
|
|
||||||
httpRequest.Header.Set("Authorization", authorization)
|
httpRequest.Header.Set("Authorization", authorization)
|
||||||
|
|
||||||
//hs, _ := json.Marshal(httpRequest.Header)
|
hs, _ := json.Marshal(httpRequest.Header)
|
||||||
//fmt.Printf("\npath=%s\nreqBody=%s\nheaders=%s\n", path, string(reqBody), string(hs))
|
fmt.Printf("\npath=%s\nreqBody=%s\nheaders=%s\n", path, string(reqBody), string(hs))
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
httpResponse, err := client.Do(httpRequest)
|
httpResponse, err := client.Do(httpRequest)
|
||||||
|
|
@ -529,6 +529,8 @@ func (srv *MchConfig) Request2(host, method, path string, reqBody []byte) (respo
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("\nrespBody=%s\n", string(respBody))
|
||||||
|
|
||||||
if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 {
|
if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 {
|
||||||
// 2XX 成功,验证应答签名
|
// 2XX 成功,验证应答签名
|
||||||
err = ValidateResponse(
|
err = ValidateResponse(
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,64 @@ func marketing() *marketing2.Marketing {
|
||||||
return &marketing2.Marketing{MchConfig: c}
|
return &marketing2.Marketing{MchConfig: c}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func marketingFJxw() *marketing2.Marketing {
|
||||||
|
|
||||||
|
dir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
parentDir := filepath.Dir(dir)
|
||||||
|
|
||||||
|
//openssl x509 -in xxx.pem -noout -serial
|
||||||
|
|
||||||
|
mchId := "1652465541"
|
||||||
|
wechatPayPublicKeyId := "PUB_KEY_ID_0117109533612025031800326400002563"
|
||||||
|
certificateSerialNo := "1E3F2CE013203BA9C3DEFC5782FCD3329C3DAC1C"
|
||||||
|
|
||||||
|
//mchId := "1652465541"
|
||||||
|
//wechatPayPublicKeyId := ""
|
||||||
|
//certificateSerialNo := "1E3F2CE013203BA9C3DEFC5782FCD3329C3DAC1C"
|
||||||
|
|
||||||
|
filePath := fmt.Sprintf("%s/cert/wechat/%s", parentDir, mchId)
|
||||||
|
|
||||||
|
c, err := utils.CreateMchConfig(
|
||||||
|
mchId, // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756
|
||||||
|
certificateSerialNo, // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053
|
||||||
|
fmt.Sprintf("%s/%s", filePath, "wechat_private_key.pem"), // 商户API证书私钥文件路径,本地文件路径
|
||||||
|
wechatPayPublicKeyId, // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816
|
||||||
|
fmt.Sprintf("%s/%s", filePath, "pub_key.pem"), // 微信支付公钥文件路径,本地文件路径
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &marketing2.Marketing{MchConfig: c}
|
||||||
|
}
|
||||||
|
|
||||||
func MarketingSend() {
|
func MarketingSend() {
|
||||||
|
|
||||||
openId := "oSNb4ftgnWC22Z0cWTjsQebdr2Yk"
|
//openId := "oSNb4ftgnWC22Z0cWTjsQebdr2Yk"
|
||||||
appId := "wx619991cc795028f5"
|
//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{
|
request := &marketing2.SendReq{
|
||||||
ActivityId: utils.String("11941580000000004"),
|
ActivityId: utils.String("11941580000000005"),
|
||||||
StockId: utils.String("20811630"),
|
StockId: utils.String("20847510"),
|
||||||
OutRequestNo: utils.String("20250801000000001"),
|
OutRequestNo: utils.String("195516196845312409613"),
|
||||||
Appid: utils.String(appId),
|
Appid: utils.String(appId),
|
||||||
StockCreatorMchId: utils.String("1652465541"),
|
StockCreatorMchId: utils.String("1652465541"),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,19 @@ func QueryCoupon() {
|
||||||
// Openid: core.String("oSNb4fpnLNdkFPk-O43o6f2hxxRo"),
|
// Openid: core.String("oSNb4fpnLNdkFPk-O43o6f2hxxRo"),
|
||||||
//}
|
//}
|
||||||
|
|
||||||
appId := "wx619991cc795028f5"
|
//appId := "wx619991cc795028f5"
|
||||||
openId := "oSNb4ftgnWC22Z0cWTjsQebdr2Yk"
|
//openId := "oSNb4ftgnWC22Z0cWTjsQebdr2Yk"
|
||||||
couponId := "113831004454"
|
//couponId := "113831004454"
|
||||||
|
//req := cashcoupons.QueryCouponRequest{
|
||||||
|
// CouponId: core.String(couponId),
|
||||||
|
// Appid: core.String(appId),
|
||||||
|
// Openid: core.String(openId),
|
||||||
|
//}
|
||||||
|
|
||||||
|
appId := "wx5d3e839568f24b2b"
|
||||||
|
openId := "ocuH-0Nymo4sJLRNabIBbg9H2XCo"
|
||||||
|
couponId := "116076813524"
|
||||||
|
|
||||||
req := cashcoupons.QueryCouponRequest{
|
req := cashcoupons.QueryCouponRequest{
|
||||||
CouponId: core.String(couponId),
|
CouponId: core.String(couponId),
|
||||||
Appid: core.String(appId),
|
Appid: core.String(appId),
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ func Test_QueryCoupon(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
SendCoupon()
|
QueryCoupon()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue