RetailStoreActApi.md 24 KB

retailstore/RetailStoreActApi

所有URI均基于微信支付 API 地址: https://api.mch.weixin.qq.com

方法名 HTTP 请求 描述
AddRepresentative Put /v3/marketing/goods-subsidy-activity/retail-store-act/{activity_id}/representative 添加零售小店活动业务代理
AddStores Post /v3/marketing/goods-subsidy-activity/retail-store-act/{brand_id}/stores 添加小店活动门店
CreateMaterials Post /v3/marketing/goods-subsidy-activity/retail-store-act/{brand_id}/materials 生成小店活动物料码
DeleteRepresentative Delete /v3/marketing/goods-subsidy-activity/retail-store-act/{activity_id}/representative 删除零售小店活动业务代理
DeleteStores Delete /v3/marketing/goods-subsidy-activity/retail-store-act/{brand_id}/stores 删除小店活动门店
GetStore Get /v3/marketing/goods-subsidy-activity/retail-store-act/{brand_id}/stores/{store_code} 查询小店活动门店详情
ListRepresentative Get /v3/marketing/goods-subsidy-activity/retail-store-act/{activity_id}/representatives 查询零售小店活动业务代理
ListStore Get /v3/marketing/goods-subsidy-activity/retail-store-act/{brand_id}/stores 查询小店活动门店列表

AddRepresentative

AddRepresentativesResponse AddRepresentative(AddRepresentativeRequest)

添加零售小店活动业务代理

调用示例

package main

import (
	"context"
	"log"

	"git.nanodreamtech.com/sg/wechatpay-go/core"
	"git.nanodreamtech.com/sg/wechatpay-go/services/retailstore"
	"git.nanodreamtech.com/sg/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := retailstore.RetailStoreActApiService{Client: client}
	resp, result, err := svc.AddRepresentative(ctx,
		retailstore.AddRepresentativeRequest{
			ActivityId: core.String("3118550000000004"),
			RepresentativeInfoList: []retailstore.RepresentativeInfo{retailstore.RepresentativeInfo{
				Openid: core.String("oK7fFt8zzEZ909XH-LE2#"),
			}},
			OutRequestNo: core.String("1002600620019090123143254436"),
			AddTime:      core.String("2015-05-20T13:29:35+08:00"),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call AddRepresentative err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}

参数列表

参数名 参数类型 参数描述
ctx context.Context Golang 上下文,可用于日志、请求取消、请求跟踪等功能
req AddRepresentativeRequest API retailstore 所定义的本接口需要的所有参数,包括Path/Query/Body 3类参数

返回结果

Name Type Description
resp *AddRepresentativesResponse 结构化的接口返回结果
result *core.APIResult 本次 API 访问的请求与应答信息
err error 本次 API 访问中发生的错误,当且仅当 API 失败时存在

[返回顶部] [返回接口列表] [返回类型列表] [返回服务README]

AddStores

AddStoresResponse AddStores(AddStoresRequest)

添加小店活动门店

调用示例

package main

import (
	"context"
	"log"

	"git.nanodreamtech.com/sg/wechatpay-go/core"
	"git.nanodreamtech.com/sg/wechatpay-go/services/retailstore"
	"git.nanodreamtech.com/sg/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := retailstore.RetailStoreActApiService{Client: client}
	resp, result, err := svc.AddStores(ctx,
		retailstore.AddStoresRequest{
			BrandId:      core.String("1001"),
			OutRequestNo: core.String("1002600620019090123143254436"),
			AddTime:      core.String("2015-05-20T13:29:35+08:00"),
			Stores: []retailstore.RetailStoreInfo{retailstore.RetailStoreInfo{
				StoreCode: core.String("abc_001"),
				StoreName: core.String("幸福小店"),
			}},
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call AddStores err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}

参数列表

参数名 参数类型 参数描述
ctx context.Context Golang 上下文,可用于日志、请求取消、请求跟踪等功能
req AddStoresRequest API retailstore 所定义的本接口需要的所有参数,包括Path/Query/Body 3类参数

返回结果

Name Type Description
resp *AddStoresResponse 结构化的接口返回结果
result *core.APIResult 本次 API 访问的请求与应答信息
err error 本次 API 访问中发生的错误,当且仅当 API 失败时存在

[返回顶部] [返回接口列表] [返回类型列表] [返回服务README]

CreateMaterials

Materials CreateMaterials(CreateMaterialsRequest)

生成小店活动物料码

调用示例

package main

import (
	"context"
	"log"

	"git.nanodreamtech.com/sg/wechatpay-go/core"
	"git.nanodreamtech.com/sg/wechatpay-go/services/retailstore"
	"git.nanodreamtech.com/sg/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := retailstore.RetailStoreActApiService{Client: client}
	resp, result, err := svc.CreateMaterials(ctx,
		retailstore.CreateMaterialsRequest{
			BrandId:      core.String("1001"),
			OutRequestNo: core.String("1002600620019090123143254436"),
			MaterialNum:  core.Int64(100),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call CreateMaterials err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}

参数列表

参数名 参数类型 参数描述
ctx context.Context Golang 上下文,可用于日志、请求取消、请求跟踪等功能
req CreateMaterialsRequest API retailstore 所定义的本接口需要的所有参数,包括Path/Query/Body 3类参数

返回结果

Name Type Description
resp *Materials 结构化的接口返回结果
result *core.APIResult 本次 API 访问的请求与应答信息
err error 本次 API 访问中发生的错误,当且仅当 API 失败时存在

[返回顶部] [返回接口列表] [返回类型列表] [返回服务README]

DeleteRepresentative

DeleteRepresentativeResponse DeleteRepresentative(DeleteRepresentativeRequest)

删除零售小店活动业务代理

调用示例

package main

import (
	"context"
	"log"

	"git.nanodreamtech.com/sg/wechatpay-go/core"
	"git.nanodreamtech.com/sg/wechatpay-go/services/retailstore"
	"git.nanodreamtech.com/sg/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := retailstore.RetailStoreActApiService{Client: client}
	resp, result, err := svc.DeleteRepresentative(ctx,
		retailstore.DeleteRepresentativeRequest{
			ActivityId: core.String("3118550000000004"),
			RepresentativeInfoList: []retailstore.RepresentativeInfo{retailstore.RepresentativeInfo{
				Openid: core.String("oK7fFt8zzEZ909XH-LE2#"),
			}},
			OutRequestNo: core.String("1002600620019090123143254436"),
			DeleteTime:   core.String("2015-05-20T13:29:35.120+08:00"),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call DeleteRepresentative err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}

参数列表

参数名 参数类型 参数描述
ctx context.Context Golang 上下文,可用于日志、请求取消、请求跟踪等功能
req DeleteRepresentativeRequest API retailstore 所定义的本接口需要的所有参数,包括Path/Query/Body 3类参数

返回结果

Name Type Description
resp *DeleteRepresentativeResponse 结构化的接口返回结果
result *core.APIResult 本次 API 访问的请求与应答信息
err error 本次 API 访问中发生的错误,当且仅当 API 失败时存在

[返回顶部] [返回接口列表] [返回类型列表] [返回服务README]

DeleteStores

DeleteStoresResponse DeleteStores(DeleteStoresRequest)

删除小店活动门店

调用示例

package main

import (
	"context"
	"log"

	"git.nanodreamtech.com/sg/wechatpay-go/core"
	"git.nanodreamtech.com/sg/wechatpay-go/services/retailstore"
	"git.nanodreamtech.com/sg/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := retailstore.RetailStoreActApiService{Client: client}
	resp, result, err := svc.DeleteStores(ctx,
		retailstore.DeleteStoresRequest{
			BrandId:      core.String("1001"),
			OutRequestNo: core.String("1002600620019090123143254436"),
			DeleteTime:   core.String("2015-05-20T13:29:35+08:00"),
			Stores: []retailstore.RetailStoreInfo{retailstore.RetailStoreInfo{
				StoreCode: core.String("abc_001"),
				StoreName: core.String("幸福小店"),
			}},
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call DeleteStores err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}

参数列表

参数名 参数类型 参数描述
ctx context.Context Golang 上下文,可用于日志、请求取消、请求跟踪等功能
req DeleteStoresRequest API retailstore 所定义的本接口需要的所有参数,包括Path/Query/Body 3类参数

返回结果

Name Type Description
resp *DeleteStoresResponse 结构化的接口返回结果
result *core.APIResult 本次 API 访问的请求与应答信息
err error 本次 API 访问中发生的错误,当且仅当 API 失败时存在

[返回顶部] [返回接口列表] [返回类型列表] [返回服务README]

GetStore

RetailStoreInfo GetStore(GetStoreRequest)

查询小店活动门店详情

调用示例

package main

import (
	"context"
	"log"

	"git.nanodreamtech.com/sg/wechatpay-go/core"
	"git.nanodreamtech.com/sg/wechatpay-go/services/retailstore"
	"git.nanodreamtech.com/sg/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := retailstore.RetailStoreActApiService{Client: client}
	resp, result, err := svc.GetStore(ctx,
		retailstore.GetStoreRequest{
			BrandId:   core.String("1001"),
			StoreCode: core.String("abc_001"),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call GetStore err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}

参数列表

参数名 参数类型 参数描述
ctx context.Context Golang 上下文,可用于日志、请求取消、请求跟踪等功能
req GetStoreRequest API retailstore 所定义的本接口需要的所有参数,包括Path/Query/Body 3类参数

返回结果

Name Type Description
resp *RetailStoreInfo 结构化的接口返回结果
result *core.APIResult 本次 API 访问的请求与应答信息
err error 本次 API 访问中发生的错误,当且仅当 API 失败时存在

[返回顶部] [返回接口列表] [返回类型列表] [返回服务README]

ListRepresentative

ListRepresentativeResponse ListRepresentative(ListRepresentativeRequest)

查询零售小店活动业务代理

调用示例

package main

import (
	"context"
	"log"

	"git.nanodreamtech.com/sg/wechatpay-go/core"
	"git.nanodreamtech.com/sg/wechatpay-go/services/retailstore"
	"git.nanodreamtech.com/sg/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := retailstore.RetailStoreActApiService{Client: client}
	resp, result, err := svc.ListRepresentative(ctx,
		retailstore.ListRepresentativeRequest{
			ActivityId: core.String("3118550000000004"),
			Offset:     core.Int64(0),
			Limit:      core.Int64(10),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call ListRepresentative err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}

参数列表

参数名 参数类型 参数描述
ctx context.Context Golang 上下文,可用于日志、请求取消、请求跟踪等功能
req ListRepresentativeRequest API retailstore 所定义的本接口需要的所有参数,包括Path/Query/Body 3类参数

返回结果

Name Type Description
resp *ListRepresentativeResponse 结构化的接口返回结果
result *core.APIResult 本次 API 访问的请求与应答信息
err error 本次 API 访问中发生的错误,当且仅当 API 失败时存在

[返回顶部] [返回接口列表] [返回类型列表] [返回服务README]

ListStore

ListStoreResponse ListStore(ListStoreRequest)

查询小店活动门店列表

调用示例

package main

import (
	"context"
	"log"

	"git.nanodreamtech.com/sg/wechatpay-go/core"
	"git.nanodreamtech.com/sg/wechatpay-go/services/retailstore"
	"git.nanodreamtech.com/sg/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := retailstore.RetailStoreActApiService{Client: client}
	resp, result, err := svc.ListStore(ctx,
		retailstore.ListStoreRequest{
			BrandId: core.String("1001"),
			Offset:  core.Int64(0),
			Limit:   core.Int64(10),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call ListStore err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}

参数列表

参数名 参数类型 参数描述
ctx context.Context Golang 上下文,可用于日志、请求取消、请求跟踪等功能
req ListStoreRequest API retailstore 所定义的本接口需要的所有参数,包括Path/Query/Body 3类参数

返回结果

Name Type Description
resp *ListStoreResponse 结构化的接口返回结果
result *core.APIResult 本次 API 访问的请求与应答信息
err error 本次 API 访问中发生的错误,当且仅当 API 失败时存在

[返回顶部] [返回接口列表] [返回类型列表] [返回服务README]