From 0ecf17693e167e46933fec753a220371f621b2ba Mon Sep 17 00:00:00 2001 From: Jerry <85411418@qq.com> Date: Sat, 13 Jul 2024 00:43:02 +0800 Subject: [PATCH] v1.5.103 --- README.md | 7 +-- alipay/marketing_voucher.go | 92 +++++++++++++++++++++++++++++++++++++ alipay/model_market.go | 68 +++++++++++++++++++++++++-- doc/alipay.md | 24 +++++----- release_note.txt | 23 +++++----- 5 files changed, 182 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index d6e2927c..285f88dc 100644 --- a/README.md +++ b/README.md @@ -60,11 +60,8 @@ func main() { # 三、其他说明 -* 如需自定义Log输出,请调用以下方法设置自定义Logger,实现 `xlog.XLogger` 接口即可。 - * `xlog.SetDebugLog()` - * `xlog.SetInfoLog()` - * `xlog.SetWarnLog()` - * `xlog.SetErrLog()` +* 如需自定义Log输出,New Client 后,调用 `client.SetLogger()` 方法设置自定义Logger,自定义Logger实现 `xlog.XLogger` interface即可。 + * 各支付方式接入,请仔细查看 `xxx_test.go` 使用方式 * `gopay/wechat/v3/client_test.go` * `gopay/alipay/client_test.go` diff --git a/alipay/marketing_voucher.go b/alipay/marketing_voucher.go index fdacb38e..d14d7de4 100644 --- a/alipay/marketing_voucher.go +++ b/alipay/marketing_voucher.go @@ -286,3 +286,95 @@ func (a *Client) MarketingActivityOrderVoucherAppend(ctx context.Context, bm gop aliRsp.SignData = signData return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) } + +// alipay.marketing.activity.ordervoucher.use(同步券核销状态) +// 文档地址:https://opendocs.alipay.com/open/3ffce87f_alipay.marketing.activity.ordervoucher.use +func (a *Client) MarketingActivityOrderVoucherUse(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherUseRsp, err error) { + err = bm.CheckEmptyError("biz_dt", "activity_id", "voucher_code", "trade_channel", "total_fee", "out_biz_no") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.use"); err != nil { + return nil, err + } + aliRsp = new(MarketingActivityOrderVoucherUseRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.activity.ordervoucher.refund(取消券核销状态) +// 文档地址:https://opendocs.alipay.com/open/4682759b_alipay.marketing.activity.ordervoucher.refund?scene=common +func (a *Client) MarketingActivityOrderVoucherRefund(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherRefundRsp, err error) { + err = bm.CheckEmptyError("biz_dt", "activity_id", "voucher_code", "out_biz_no") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.refund"); err != nil { + return nil, err + } + aliRsp = new(MarketingActivityOrderVoucherRefundRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.activity.ordervoucher.query(查询商家券活动) +// 文档地址:https://opendocs.alipay.com/open/51f5946e_alipay.marketing.activity.ordervoucher.query +func (a *Client) MarketingActivityOrderVoucherQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherQueryRsp, err error) { + err = bm.CheckEmptyError("activity_id", "merchant_access_mode") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingActivityOrderVoucherQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.activity.ordervoucher.codecount(统计商家券券码数量) +// 文档地址:https://opendocs.alipay.com/open/f6e49e82_alipay.marketing.activity.ordervoucher.codecount +func (a *Client) MarketingActivityOrderVoucherCodeCount(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingActivityOrderVoucherCodeCountRsp, err error) { + err = bm.CheckEmptyError("activity_id", "merchant_access_mode") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.activity.ordervoucher.codecount"); err != nil { + return nil, err + } + aliRsp = new(MarketingActivityOrderVoucherCodeCountRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} diff --git a/alipay/model_market.go b/alipay/model_market.go index 14ab47f3..951d2b58 100644 --- a/alipay/model_market.go +++ b/alipay/model_market.go @@ -205,9 +205,37 @@ type MarketingActivityOrderVoucherStopRsp struct { type MarketingActivityOrderVoucherAppendRsp struct { Response *MarketingActivityOrderVoucherAppend `json:"alipay_marketing_activity_ordervoucher_append_response"` - AlipayCertSn string `json:"alipay_cert_sn,omitempty"` - SignData string `json:"-"` - Sign string `json:"sign"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingActivityOrderVoucherUseRsp struct { + Response *MarketingActivityOrderVoucherUse `json:"alipay_marketing_activity_ordervoucher_use_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingActivityOrderVoucherRefundRsp struct { + Response *MarketingActivityOrderVoucherRefund `json:"alipay_marketing_activity_ordervoucher_refund_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingActivityOrderVoucherQueryRsp struct { + Response *MarketingActivityOrderVoucherQuery `json:"alipay_marketing_activity_ordervoucher_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingActivityOrderVoucherCodeCountRsp struct { + Response *MarketingActivityOrderVoucherCodeCount `json:"alipay_marketing_activity_ordervoucher_codecount_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` } // =========================================================分割========================================================= @@ -386,6 +414,7 @@ type ActivityBaseInfo struct { ActivityId string `json:"activity_id"` ActivityName string `json:"activity_name,omitempty"` BelongMerchantInfo *BelongMerchantInfo `json:"belong_merchant_info"` + CodeMode string `json:"code_mode,omitempty"` ActivityOperationStatus string `json:"activity_operation_status,omitempty"` ActivityStatus string `json:"activity_status"` ActivityProductType string `json:"activity_product_type,omitempty"` @@ -865,3 +894,36 @@ type MarketingActivityOrderVoucherStop struct { type MarketingActivityOrderVoucherAppend struct { ErrorResponse } + +type MarketingActivityOrderVoucherUse struct { + ErrorResponse + ActivityId string `json:"activity_id"` + VoucherUseDetailResultInfo *VoucherUseDetailResultInfo `json:"voucher_use_detail_result_info"` +} + +type VoucherUseDetailResultInfo struct { + VoucherMaxUnUseTimes int `json:"voucher_max_un_use_times"` +} + +type MarketingActivityOrderVoucherRefund struct { + ErrorResponse + ActivityId string `json:"activity_id"` + VoucherUseDetailResultInfo *VoucherUseDetailResultInfo `json:"voucher_use_detail_result_info"` +} + +type MarketingActivityOrderVoucherQuery struct { + ErrorResponse + ActivityBaseInfo *ActivityBaseInfo `json:"activity_base_info"` + VoucherSendModeInfo *VoucherSendModeInfo `json:"voucher_send_mode_info"` + VoucherDeductInfo *VoucherDeductInfo `json:"voucher_deduct_info"` + VoucherAvailableScopeInfo *VoucherAvailableScopeInfo `json:"voucher_available_scope_info"` + VoucherUseRuleInfo *VoucherUseRuleInfo `json:"voucher_use_rule_info"` + VoucherDisplayPatternInfo *VoucherDisplayPatternInfo `json:"voucher_display_pattern_info"` + VoucherCustomerGuideInfo *VoucherCustomerGuideInfo `json:"voucher_customer_guide_info"` + VoucherInventoryInfo *VoucherInventoryInfo `json:"voucher_inventory_info"` +} + +type MarketingActivityOrderVoucherCodeCount struct { + ErrorResponse + SuccessCount int `json:"success_count"` +} diff --git a/doc/alipay.md b/doc/alipay.md index 951e43df..41a26fb8 100644 --- a/doc/alipay.md +++ b/doc/alipay.md @@ -326,20 +326,20 @@ xlog.Infof("%+v", phone) * 预算追加 * 修改商家券活动发券数量上限接口:`client.MarketingActivityOrderVoucherAppend()` * 活动发放 - * 活动领取咨询接口:TODO:https://opendocs.alipay.com/open/cdf2e908_alipay.marketing.activity.consult + * 活动领取咨询接口:`client.MarketingActivityConsult()` * 优惠券核销 - * 同步券核销状态接口:TODO:https://opendocs.alipay.com/open/3ffce87f_alipay.marketing.activity.ordervoucher.use - * 取消券核销状态接口:TODO:https://opendocs.alipay.com/open/4682759b_alipay.marketing.activity.ordervoucher.refund + * 同步券核销状态接口:`client.MarketingActivityOrderVoucherUse()` + * 取消券核销状态接口:`client.MarketingActivityOrderVoucherRefund()` * 活动查询 - * 查询商家券活动接口:TODO:https://opendocs.alipay.com/open/51f5946e_alipay.marketing.activity.ordervoucher.query - * 查询活动详情接口:TODO:https://opendocs.alipay.com/open/f76b603f_alipay.marketing.activity.query - * 统计商家券券码数量接口:TODO:https://opendocs.alipay.com/open/f6e49e82_alipay.marketing.activity.ordervoucher.codecount - * 条件查询活动列表接口:TODO:https://opendocs.alipay.com/open/55aa8ee8_alipay.marketing.activity.batchquery - * 条件查询用户券接口:TODO:https://opendocs.alipay.com/open/300dff38_alipay.marketing.activity.user.batchqueryvoucher - * 查询用户券详情接口:TODO:https://opendocs.alipay.com/open/abffd3f6_alipay.marketing.activity.user.queryvoucher - * 查询活动可用小程序接口:TODO:https://opendocs.alipay.com/open/634212b2_alipay.marketing.activity.app.batchquery - * 查询活动可用门店接口:TODO:https://opendocs.alipay.com/open/cf4e0873_alipay.marketing.activity.shop.batchquery - * 查询活动适用商品接口:TODO:https://opendocs.alipay.com/open/1bee5767_alipay.marketing.activity.goods.batchquery + * 查询商家券活动接口:`client.MarketingActivityOrderVoucherQuery()` + * 查询活动详情接口:`client.MarketingActivityQuery()` + * 统计商家券券码数量接口:`client.MarketingActivityOrderVoucherCodeCount()` + * 条件查询活动列表接口:`client.MarketingActivityBatchQuery()` + * 条件查询用户券接口:`client.MarketingActivityQueryUserBatchQueryVoucher()` + * 查询用户券详情接口:`client.MarketingActivityQueryUserQueryVoucher()` + * 查询活动可用小程序接口:`client.MarketingActivityQueryAppBatchQuery()` + * 查询活动可用门店接口:`client.MarketingActivityQueryShopBatchQuery()` + * 查询活动适用商品接口:`client.MarketingActivityQueryGoodsBatchQuery()` * 商家会员卡 * 基础功能 * 会员卡模板创建接口:TODO:https://opendocs.alipay.com/open/b2854ad3_alipay.marketing.card.template.create diff --git a/release_note.txt b/release_note.txt index ea01d39d..3e367571 100644 --- a/release_note.txt +++ b/release_note.txt @@ -1,18 +1,17 @@ 版本号:Release 1.5.103 修改记录: (1) gopay:xlog 库更新,支持接口自定义logger。 - (1) gopay:go mod 版本升级至 1.21。 - (1) 支付宝:新增 client.PayAppMarketingConsult(),商户前置内容咨询接口。 - (2) 支付宝:新增 client.MarketingActivityOrderVoucherCreate(),创建商家券活动接口 - (3) 支付宝:新增 client.MarketingActivityOrderVoucherCodeDeposit(),同步商家券券码接口 - (4) 支付宝:新增 client.MarketingActivityOrderVoucherModify(),修改商家券活动基本信息接口 - (4) 支付宝:新增 client.MarketingActivityOrderVoucherStop(),停止商家券活动接口 - (4) 支付宝:新增 client.MarketingActivityOrderVoucherAppend(),修改商家券活动发券数量上限接口 - (4) 支付宝:新增 - (4) 支付宝:新增 - (4) 支付宝:新增 - (4) 支付宝:新增 - (4) 支付宝:新增 + (2) gopay:go mod 版本升级至 1.21。 + (3) 支付宝:新增 client.PayAppMarketingConsult(),商户前置内容咨询接口。 + (4) 支付宝:新增 client.MarketingActivityOrderVoucherCreate(),创建商家券活动接口 + (5) 支付宝:新增 client.MarketingActivityOrderVoucherCodeDeposit(),同步商家券券码接口 + (6) 支付宝:新增 client.MarketingActivityOrderVoucherModify(),修改商家券活动基本信息接口 + (7) 支付宝:新增 client.MarketingActivityOrderVoucherStop(),停止商家券活动接口 + (8) 支付宝:新增 client.MarketingActivityOrderVoucherAppend(),修改商家券活动发券数量上限接口 + (9) 支付宝:新增 client.MarketingActivityOrderVoucherUse(),同步券核销状态接口 + (10) 支付宝:新增 client.MarketingActivityOrderVoucherRefund(),取消券核销状态接口 + (11) 支付宝:新增 client.MarketingActivityOrderVoucherQuery(),查询商家券活动接口 + (12) 支付宝:新增 client.MarketingActivityOrderVoucherCodeCount(),统计商家券券码数量接口 版本号:Release 1.5.102 修改记录: