必要位置添加日志
This commit is contained in:
parent
a79b18d279
commit
4842aa47a3
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-pay/gopay"
|
"github.com/go-pay/gopay"
|
||||||
"github.com/go-pay/gopay/alipay"
|
"github.com/go-pay/gopay/alipay"
|
||||||
|
"github.com/qit-team/snow-core/log/logger"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
@ -80,6 +81,7 @@ func ALiH5PayInfo(c context.Context, payOrderRequest PayOrderRequest) (string, e
|
||||||
|
|
||||||
aliRsp, err := aliClient.TradeWapPay(c, bm)
|
aliRsp, err := aliClient.TradeWapPay(c, bm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Error(c, "ALiH5PayInfo 发生错误", fmt.Sprintf("错误信息:%s", err.Error()))
|
||||||
if bizErr, ok := alipay.IsBizError(err); ok {
|
if bizErr, ok := alipay.IsBizError(err); ok {
|
||||||
return "", bizErr
|
return "", bizErr
|
||||||
}
|
}
|
||||||
|
@ -182,6 +184,7 @@ func AliRefundOrder(ctx context.Context, orderRefundRequest OrderRefundRequest)
|
||||||
// 发起退款请求
|
// 发起退款请求
|
||||||
aliRsp, err := aliClient.TradeRefund(ctx, bm)
|
aliRsp, err := aliClient.TradeRefund(ctx, bm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Error(ctx, "AliRefundOrder 发生错误", fmt.Sprintf("申请退款接口失败,错误信息:%s", err.Error()))
|
||||||
if bizErr, ok := alipay.IsBizError(err); ok {
|
if bizErr, ok := alipay.IsBizError(err); ok {
|
||||||
return OrderRefundInfo{}, bizErr
|
return OrderRefundInfo{}, bizErr
|
||||||
}
|
}
|
||||||
|
@ -253,9 +256,10 @@ func AliCloseOrder(ctx context.Context, orderCloseRequest OrderCloseRequest) (Or
|
||||||
bm := make(gopay.BodyMap)
|
bm := make(gopay.BodyMap)
|
||||||
bm.Set("out_trade_no", orderCloseRequest.OrderId)
|
bm.Set("out_trade_no", orderCloseRequest.OrderId)
|
||||||
|
|
||||||
// 条码支付
|
// 关闭订单
|
||||||
aliRsp, err := aliClient.TradeClose(ctx, bm)
|
aliRsp, err := aliClient.TradeClose(ctx, bm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Error(ctx, "AliCloseOrder 发生错误", fmt.Sprintf("申请退款接口失败,错误信息:%s", err.Error()))
|
||||||
if bizErr, ok := alipay.IsBizError(err); ok {
|
if bizErr, ok := alipay.IsBizError(err); ok {
|
||||||
return OrderCloseInfo{}, bizErr
|
return OrderCloseInfo{}, bizErr
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package paymentService
|
||||||
import (
|
import (
|
||||||
"PaymentCenter/app/third/paymentService/payCommon"
|
"PaymentCenter/app/third/paymentService/payCommon"
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/qit-team/snow-core/log/logger"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ type PayOrderResponse struct {
|
||||||
|
|
||||||
// PaymentService 统一发起支付
|
// PaymentService 统一发起支付
|
||||||
func PaymentService(c context.Context, payOrderRequest PayOrderRequest) (payOrderResponse PayOrderResponse) {
|
func PaymentService(c context.Context, payOrderRequest PayOrderRequest) (payOrderResponse PayOrderResponse) {
|
||||||
|
logger.Info(c, "PaymentService 收到支付请求", payOrderRequest)
|
||||||
var err error
|
var err error
|
||||||
var info string
|
var info string
|
||||||
switch payOrderRequest.ChannelType {
|
switch payOrderRequest.ChannelType {
|
||||||
|
@ -147,6 +149,7 @@ type OrderRefundInfo struct {
|
||||||
|
|
||||||
// OrderRefund 订单退款
|
// OrderRefund 订单退款
|
||||||
func OrderRefund(c context.Context, orderRefundRequest OrderRefundRequest) OrderRefundResponse {
|
func OrderRefund(c context.Context, orderRefundRequest OrderRefundRequest) OrderRefundResponse {
|
||||||
|
logger.Info(c, "PaymentService 收到退款请求", orderRefundRequest)
|
||||||
var err error
|
var err error
|
||||||
var info OrderRefundInfo
|
var info OrderRefundInfo
|
||||||
switch orderRefundRequest.PayChannel {
|
switch orderRefundRequest.PayChannel {
|
||||||
|
@ -233,6 +236,7 @@ type OrderCloseInfo struct {
|
||||||
|
|
||||||
// OrderClose 关闭订单
|
// OrderClose 关闭订单
|
||||||
func OrderClose(c context.Context, orderCloseRequest OrderCloseRequest) OrderCloseResponse {
|
func OrderClose(c context.Context, orderCloseRequest OrderCloseRequest) OrderCloseResponse {
|
||||||
|
logger.Info(c, "PaymentService 收到关闭订单请求", orderCloseRequest)
|
||||||
var err error
|
var err error
|
||||||
var info OrderCloseInfo
|
var info OrderCloseInfo
|
||||||
switch orderCloseRequest.PayChannel {
|
switch orderCloseRequest.PayChannel {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-pay/gopay"
|
"github.com/go-pay/gopay"
|
||||||
"github.com/go-pay/gopay/wechat/v3"
|
"github.com/go-pay/gopay/wechat/v3"
|
||||||
|
"github.com/qit-team/snow-core/log/logger"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -62,7 +63,6 @@ func WxH5PayInfo(c context.Context, payOrderRequest PayOrderRequest) (string, er
|
||||||
// 获取微信客户端
|
// 获取微信客户端
|
||||||
wxClient, err := GetClient()
|
wxClient, err := GetClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Failed to get client:", err)
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
expire := time.Now().Add(10 * time.Minute).Format(time.RFC3339)
|
expire := time.Now().Add(10 * time.Minute).Format(time.RFC3339)
|
||||||
|
@ -91,6 +91,7 @@ func WxH5PayInfo(c context.Context, payOrderRequest PayOrderRequest) (string, er
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if wxRsp.Code != wechat.Success || wxRsp.Response.H5Url == "" {
|
if wxRsp.Code != wechat.Success || wxRsp.Response.H5Url == "" {
|
||||||
|
logger.Error(c, "WxH5PayInfo 发生错误", fmt.Sprintf("错误状态码:%d, 错误信息:%s", wxRsp.Code, wxRsp.Error))
|
||||||
return "", errors.New(fmt.Sprintf("发起支付失败,失败状态码:%d, 失败原因:%s", wxRsp.Code, wxRsp.Error))
|
return "", errors.New(fmt.Sprintf("发起支付失败,失败状态码:%d, 失败原因:%s", wxRsp.Code, wxRsp.Error))
|
||||||
}
|
}
|
||||||
return wxRsp.Response.H5Url, nil
|
return wxRsp.Response.H5Url, nil
|
||||||
|
@ -104,7 +105,6 @@ func WxPayCallBack(notifyReq *wechat.V3NotifyReq, wxConfig WxPay) error {
|
||||||
// 获取微信客户端
|
// 获取微信客户端
|
||||||
wxClient, err := GetClient()
|
wxClient, err := GetClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Failed to get client:", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,6 @@ func WxOrderQuery(ctx context.Context, wxConfig WxPay, orderNo string) (PayOrder
|
||||||
// 获取微信客户端
|
// 获取微信客户端
|
||||||
wxClient, err := GetClient()
|
wxClient, err := GetClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Failed to get client:", err)
|
|
||||||
return PayOrderQueryInfo{}, err
|
return PayOrderQueryInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +218,7 @@ func WxOrderRefund(ctx context.Context, orderRefundRequest OrderRefundRequest) (
|
||||||
|
|
||||||
// 将非正常退款异常记录
|
// 将非正常退款异常记录
|
||||||
if refund.Code != wechat.Success {
|
if refund.Code != wechat.Success {
|
||||||
|
logger.Error(ctx, "WxOrderRefund 发生错误", fmt.Sprintf("申请退款接口失败,错误状态码:%d, 错误信息:%s", refund.Code, refund.Error))
|
||||||
// 这里时对非正常退款的一些处理message,我们将code统一使用自定义的,然后把message抛出去
|
// 这里时对非正常退款的一些处理message,我们将code统一使用自定义的,然后把message抛出去
|
||||||
return OrderRefundInfo{}, errors.New(fmt.Sprintf("申请退款接口失败,错误状态码:%d, 错误信息:%s", refund.Code, refund.Error))
|
return OrderRefundInfo{}, errors.New(fmt.Sprintf("申请退款接口失败,错误状态码:%d, 错误信息:%s", refund.Code, refund.Error))
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,6 @@ func WxOrderRefundQuery(ctx context.Context, orderRefundQueryRequest OrderRefund
|
||||||
// 获取微信客户端
|
// 获取微信客户端
|
||||||
wxClient, err := GetClient()
|
wxClient, err := GetClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Failed to get client:", err)
|
|
||||||
return OrderRefundInfo{}, err
|
return OrderRefundInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,6 +302,7 @@ func WxCloseOrder(ctx context.Context, orderCloseRequest OrderCloseRequest) (Ord
|
||||||
return OrderCloseInfo{}, err
|
return OrderCloseInfo{}, err
|
||||||
}
|
}
|
||||||
if wxRsp.Code != wechat.Success {
|
if wxRsp.Code != wechat.Success {
|
||||||
|
logger.Error(ctx, "WxCloseOrder 发生错误", fmt.Sprintf("查询订单接口错误,错误状态码:%d, 错误信息:%s", wxRsp.Code, wxRsp.Error))
|
||||||
return OrderCloseInfo{}, errors.New(fmt.Sprintf("查询订单接口错误,错误状态码:%d, 错误信息:%s", wxRsp.Code, wxRsp.Error))
|
return OrderCloseInfo{}, errors.New(fmt.Sprintf("查询订单接口错误,错误状态码:%d, 错误信息:%s", wxRsp.Code, wxRsp.Error))
|
||||||
}
|
}
|
||||||
return OrderCloseInfo{
|
return OrderCloseInfo{
|
||||||
|
|
Loading…
Reference in New Issue