多笔立减
This commit is contained in:
parent
90150e36e0
commit
c873859c1a
|
|
@ -59,7 +59,7 @@ func buildWx(wx *conf.Wechat) (*marketing.Marketing, error) {
|
|||
cc, err := utils2.CreateMchConfig(
|
||||
wx.MchID, // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756
|
||||
wx.MchCertificateSerialNumber, // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053
|
||||
fmt.Sprintf("%s/%s", filePath, "apiclient_key.pem"), // 商户API证书私钥文件路径,本地文件路径
|
||||
fmt.Sprintf("%s/%s", filePath, "wechat_private_key.pem"), // 商户API证书私钥文件路径,本地文件路径
|
||||
wx.WechatPayPublicKeyID, // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816
|
||||
fmt.Sprintf("%s/%s", filePath, "pub_key.pem"), // 微信支付公钥文件路径,本地文件路径
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
marketing2 "voucher/internal/pkg/wechat/srv/marketing"
|
||||
"voucher/internal/pkg/wechat/utils"
|
||||
)
|
||||
|
||||
func marketing() *marketing2.Marketing {
|
||||
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
parentDir := filepath.Dir(dir)
|
||||
|
||||
//openssl x509 -in xxx.pem -noout -serial
|
||||
|
||||
mchId := "1710953361"
|
||||
wechatPayPublicKeyId := "PUB_KEY_ID_0117109533612025031800326400002563"
|
||||
certificateSerialNo := "6006B8208815DB5EAC5BF2E783CB9D34082C3772"
|
||||
|
||||
//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() {
|
||||
|
||||
openId := "oSNb4ftgnWC22Z0cWTjsQebdr2Yk"
|
||||
appId := "wx619991cc795028f5"
|
||||
request := &marketing2.SendReq{
|
||||
ActivityId: utils.String("11941580000000004"),
|
||||
StockId: utils.String("20811630"),
|
||||
OutRequestNo: utils.String("20250801000000001"),
|
||||
Appid: utils.String(appId),
|
||||
StockCreatorMchId: utils.String("1652465541"),
|
||||
}
|
||||
|
||||
response, err := marketing().Send(openId, request)
|
||||
if err != nil {
|
||||
fmt.Printf("请求失败: %+v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("请求成功: %+v\n", response)
|
||||
fmt.Printf("请求成功: %s\n", *response.CouponId)
|
||||
}
|
||||
|
||||
func MarketingQuery() {
|
||||
|
||||
appId := "wx619991cc795028f5"
|
||||
openId := "oSNb4ftgnWC22Z0cWTjsQebdr2Yk"
|
||||
couponId := "113831004454"
|
||||
|
||||
response, err := marketing().Query(appId, openId, couponId)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("请求成功: %+v\n", response)
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package test
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMarketingSend(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
}{
|
||||
{
|
||||
name: "给指定用户报名多笔立减活动",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
MarketingSend()
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue