多笔立减
This commit is contained in:
parent
c873859c1a
commit
4a65fa66c0
|
|
@ -1,12 +1,16 @@
|
|||
package wechatrepoimpl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
err2 "voucher/api/err"
|
||||
"voucher/internal/biz/bo"
|
||||
"voucher/internal/biz/wechatrepo"
|
||||
"voucher/internal/conf"
|
||||
"voucher/internal/data"
|
||||
"voucher/internal/pkg/wechat/srv/marketing"
|
||||
"voucher/internal/pkg/wechat/utils"
|
||||
)
|
||||
|
||||
type BankMultiActivityImpl struct {
|
||||
|
|
@ -37,6 +41,15 @@ func (w *BankMultiActivityImpl) Order(order *bo.OrderBo) (couponId string, err e
|
|||
|
||||
if err != nil {
|
||||
|
||||
var e *utils.ApiException
|
||||
if errors.As(err, &e) {
|
||||
apiErr, err3 := marketing.BuildErr(e.Body())
|
||||
if err3 != nil {
|
||||
return "", fmt.Errorf("ApiException analysis err: %+v", err3)
|
||||
}
|
||||
return "", err2.ErrorWechatFAIL("%s-%s", apiErr.Code, apiErr.Message)
|
||||
}
|
||||
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package marketing
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type SendReq struct {
|
||||
ActivityId *string `json:"activity_id"`
|
||||
StockId *string `json:"stock_id"`
|
||||
|
|
@ -11,3 +13,15 @@ type SendReq struct {
|
|||
type SendResp struct {
|
||||
CouponId *string `json:"coupon_id"`
|
||||
}
|
||||
|
||||
// Err {"code":"INVALID_REQUEST","message":"对应单号已超出重试期;请查单确认后决定是否换单请求"}
|
||||
type Err struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func BuildErr(body []byte) (*Err, error) {
|
||||
ret := &Err{}
|
||||
err := json.Unmarshal(body, &ret)
|
||||
return ret, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -515,8 +515,8 @@ func (srv *MchConfig) Request2(host, method, path string, reqBody []byte) (respo
|
|||
|
||||
httpRequest.Header.Set("Authorization", authorization)
|
||||
|
||||
hs, _ := json.Marshal(httpRequest.Header)
|
||||
fmt.Printf("\npath=%s\nreqBody=%s\nheaders=%s\n", path, string(reqBody), string(hs))
|
||||
//hs, _ := json.Marshal(httpRequest.Header)
|
||||
//fmt.Printf("\npath=%s\nreqBody=%s\nheaders=%s\n", path, string(reqBody), string(hs))
|
||||
|
||||
client := &http.Client{}
|
||||
httpResponse, err := client.Do(httpRequest)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -57,7 +58,19 @@ func MarketingSend() {
|
|||
|
||||
response, err := marketing().Send(openId, request)
|
||||
if err != nil {
|
||||
fmt.Printf("请求失败: %+v\n", err)
|
||||
|
||||
var e *utils.ApiException
|
||||
if errors.As(err, &e) {
|
||||
|
||||
apiErr, err3 := marketing2.BuildErr(e.Body())
|
||||
if err3 != nil {
|
||||
fmt.Printf("请求失败: %+v\n", err3)
|
||||
} else {
|
||||
fmt.Printf("请求失败: %s-%s\n", apiErr.Code, apiErr.Message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue