Skip to content

Commit

Permalink
Wechat v3 busifavor (#166)
Browse files Browse the repository at this point in the history
* 新增 商家券 相关接口
* 修复已知的问题
  • Loading branch information
iGoogle-ink authored Aug 5, 2021
1 parent 6452164 commit cf76118
Show file tree
Hide file tree
Showing 9 changed files with 800 additions and 43 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,22 @@ func main() {
* 下载批次退款明细:`client.V3FavorRefundFlowDownload()`
* 设置消息通知地址:`client.V3FavorCallbackUrlSet()`
* <font color='#07C160' size='4'>商家券</font>
* 待实现
* 创建商家券:`client.V3BusiFavorBatchCreate()`
* 查询商家券详情:`client.V3BusiFavorBatchDetail()`
* 核销用户券:`client.V3BusiFavorUse()`
* 根据过滤条件查询用户券:`client.V3BusiFavorUserCoupons()`
* 查询用户单张券详情:`client.V3BusiFavorUserCouponDetail()`
* 上传预存code:`client.V3BusiFavorCodeUpload()`
* 设置商家券事件通知地址:`client.V3BusiFavorCallbackUrlSet()`
* 查询商家券事件通知地址:`client.V3BusiFavorCallbackUrl()`
* 关联订单信息:`client.V3BusiFavorAssociate()`
* 取消关联订单信息:`client.V3BusiFavorDisassociate()`
* 修改批次预算:`client.V3BusiFavorBatchUpdate()`
* 修改商家券基本信息:`client.V3BusiFavorInfoUpdate()`
* 申请退券:`client.V3BusiFavorReturn()`
* 使券失效:`client.V3BusiFavorDeactivate()`
* 营销补差付款:`client.V3BusiFavorSubsidyPay()`
* 查询营销补差付款单详情:`client.V3BusiFavorSubsidyPayDetail()`
* <font color='#07C160' size='4'>委托营销</font>
* 待实现
* <font color='#07C160' size='4'>消费卡</font>
Expand Down
2 changes: 2 additions & 0 deletions release_note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
修改记录:
(1) 微信V3:wechat.NewClientV3(),去掉初始化参数 appid,所以方法中需要 appid 或sp_appid 的,需要自行传参
(2) 微信V3:新增 代金券 相关接口
(3) 微信V3:新增 商家券 相关接口
(4) 微信V2、V3:修复部分接口发现的Bug

版本号:Release 1.5.54
修改记录:
Expand Down
51 changes: 26 additions & 25 deletions wechat/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,31 +660,32 @@ type ProfitSharingResponse struct {

// ProfitSharingQueryResponse 查询分账结果
type ProfitSharingQueryResponse struct {
ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` // 返回状态码 SUCCESS/FAIL 此字段是通信标识,非交易标识
ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` // 返回信息,如非空,为错误原因
ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` // 业务结果 SUCCESS:分账申请接收成功,结果通过分账查询接口查询 FAIL :提交业务失败
ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` // 错误代码
ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` // 错误代码描述
MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` // 商户号
NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` // 随机字符串
Sign string `xml:"sign,omitempty" json:"sign,omitempty"` // 签名
TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` // 微信订单号
OutOrderNo string `xml:"out_order_no,omitempty" json:"out_order_no,omitempty"` // 商户分账单号
OrderId string `xml:"order_id,omitempty" json:"order_id,omitempty"` // 微信分账单号
Status string `xml:"status,omitempty" json:"status,omitempty"` // 分账单状态 ACCEPTED—受理成功 PROCESSING—处理中 FINISHED—处理完成 CLOSED—处理失败,已关单
CloseReason string `xml:"close_reason,omitempty" json:"close_reason,omitempty"` // 关单原因 NO_AUTH:分账授权已解除
Receivers []*profitSharingReceiver `xml:"receivers,omitempty" json:"receivers,omitempty"`
}

type profitSharingReceiver struct {
Amount int `xml:"amount,omitempty" json:"amount,omitempty"` // 分账金额 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
Description string `xml:"description,omitempty" json:"description,omitempty"` // 分账描述
ReceiverType string `xml:"type,omitempty" json:"type,omitempty"` // 分账接收方类型 MERCHANT_ID:商户ID ;PERSONAL_OPENID:个人openid
Account string `xml:"account,omitempty" json:"account,omitempty"` // 分账接收方账号
Result string `xml:"result,omitempty" json:"result,omitempty"` // 分账结果 PENDING:待分账 SUCCESS:分账成功 ADJUST:分账失败待调账 RETURNED:已转回分账方 CLOSED: 已关闭
FinishTime string `xml:"finish_time,omitempty" json:"finish_time,omitempty"` // 分账完成时间
FailReason string `xml:"fail_reason,omitempty" json:"fail_reason,omitempty"` // 分账失败原因 ACCOUNT_ABNORMAL:分账接收账户异常 NO_RELATION:分账关系已解除 RECEIVER_HIGH_RISK:高风险接收方
}
ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` // 返回状态码 SUCCESS/FAIL 此字段是通信标识,非交易标识
ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` // 返回信息,如非空,为错误原因
ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` // 业务结果 SUCCESS:分账申请接收成功,结果通过分账查询接口查询 FAIL :提交业务失败
ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` // 错误代码
ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` // 错误代码描述
MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` // 商户号
NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` // 随机字符串
Sign string `xml:"sign,omitempty" json:"sign,omitempty"` // 签名
TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` // 微信订单号
OutOrderNo string `xml:"out_order_no,omitempty" json:"out_order_no,omitempty"` // 商户分账单号
OrderId string `xml:"order_id,omitempty" json:"order_id,omitempty"` // 微信分账单号
Status string `xml:"status,omitempty" json:"status,omitempty"` // 分账单状态 ACCEPTED—受理成功 PROCESSING—处理中 FINISHED—处理完成 CLOSED—处理失败,已关单
CloseReason string `xml:"close_reason,omitempty" json:"close_reason,omitempty"` // 关单原因 NO_AUTH:分账授权已解除
Receivers string `xml:"receivers,omitempty" json:"receivers,omitempty"`
}

//
//type profitSharingReceiver struct {
// Amount int `xml:"amount,omitempty" json:"amount,omitempty"` // 分账金额 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
// Description string `xml:"description,omitempty" json:"description,omitempty"` // 分账描述
// ReceiverType string `xml:"type,omitempty" json:"type,omitempty"` // 分账接收方类型 MERCHANT_ID:商户ID ;PERSONAL_OPENID:个人openid
// Account string `xml:"account,omitempty" json:"account,omitempty"` // 分账接收方账号
// Result string `xml:"result,omitempty" json:"result,omitempty"` // 分账结果 PENDING:待分账 SUCCESS:分账成功 ADJUST:分账失败待调账 RETURNED:已转回分账方 CLOSED: 已关闭
// FinishTime string `xml:"finish_time,omitempty" json:"finish_time,omitempty"` // 分账完成时间
// FailReason string `xml:"fail_reason,omitempty" json:"fail_reason,omitempty"` // 分账失败原因 ACCOUNT_ABNORMAL:分账接收账户异常 NO_RELATION:分账关系已解除 RECEIVER_HIGH_RISK:高风险接收方
//}

// ProfitSharingAddReceiverResponse 添加分账接收者结果
type ProfitSharingAddReceiverResponse struct {
Expand Down
4 changes: 3 additions & 1 deletion wechat/v3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ func TestV3ProfitSharingDeleteReceiver(t *testing.T) {
}

func TestV3ProfitSharingQuery(t *testing.T) {
wxRsp, err := client.V3ProfitShareOrderQuery("202106071738581340", "4200001149202106084654939138")
bm := make(gopay.BodyMap)
bm.Set("transaction_id", "4200001149202106084654939138")
wxRsp, err := client.V3ProfitShareOrderQuery("P20150806125346", bm)
if err != nil {
xlog.Error(err)
return
Expand Down
12 changes: 6 additions & 6 deletions wechat/v3/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ const (

// 商家券
v3BusiFavorBatchCreate = "/v3/marketing/busifavor/stocks" // 创建商家券 POST
v3BusiFavorBatchDetailQuery = "/v3/marketing/busifavor/stocks/%s" // stock_id 查询商家券详情 GET
v3BusiFavorBatchDetail = "/v3/marketing/busifavor/stocks/%s" // stock_id 查询商家券详情 GET
v3BusiFavorUse = "/v3/marketing/busifavor/coupons/use" // 核销用户券 POST
v3BusiFavorUserQuery = "/v3/marketing/busifavor/users/%s/coupons" // openid 根据过滤条件查询用户券 GET
v3BusiFavorUserDetail = "/v3/marketing/busifavor/users/%s/coupons/%s/appids/%s" // openid、coupon_code、appid 查询用户单张券详情 GET
v3BusiFavorUserCoupons = "/v3/marketing/busifavor/users/%s/coupons" // openid 根据过滤条件查询用户券 GET
v3BusiFavorUserCouponDetail = "/v3/marketing/busifavor/users/%s/coupons/%s/appids/%s" // openid、coupon_code、appid 查询用户单张券详情 GET
v3BusiFavorCodeUpload = "/v3/marketing/busifavor/stocks/%s/couponcodes" // stock_id 上传预存code POST
v3BusiFavorCallbackUrlSet = "/v3/marketing/busifavor/callbacks" // 设置商家券事件通知地址 POST
v3BusiFavorCallbackUrlQuery = "/v3/marketing/busifavor/callbacks" // 查询商家券事件通知地址 GET
v3BusiFavorCallbackUrl = "/v3/marketing/busifavor/callbacks" // 查询商家券事件通知地址 GET
v3BusiFavorAssociate = "/v3/marketing/busifavor/coupons/associate" // 关联订单信息 POST
v3BusiFavorDisassociate = "/v3/marketing/busifavor/coupons/disassociate" // 取消关联订单信息 POST
v3BusiFavorBatchUpdate = "/v3/marketing/busifavor/stocks/%s/budget" // stock_id 修改批次预算 PATCH
v3BusiFavorInfoUpdate = "/v3/marketing/busifavor/stocks/%s" // stock_id 修改商家券基本信息 PATCH
v3BusiFavorReturn = "/v3/marketing/busifavor/coupons/return" // 申请退券 POST
v3BusiFavorDeactivate = "/v3/marketing/busifavor/coupons/deactivate" // 使券失效 POST
v3BusiFavorSubsidy = "/v3/marketing/busifavor/subsidy/pay-receipts" // 营销补差付款 POST
v3BusiFavorSubsidyDetail = "/v3/marketing/busifavor/subsidy/pay-receipts/%s" // subsidy_receipt_id 查询营销补差付款单详情 GET
v3BusiFavorSubsidyPay = "/v3/marketing/busifavor/subsidy/pay-receipts" // 营销补差付款 POST
v3BusiFavorSubsidyPayDetail = "/v3/marketing/busifavor/subsidy/pay-receipts/%s" // subsidy_receipt_id 查询营销补差付款单详情 GET

// 点金计划
v3GoldPlanManage = "/v3/goldplan/merchants/changegoldplanstatus" // 点金计划管理 POST
Expand Down
Loading

0 comments on commit cf76118

Please sign in to comment.