记录third表的日志信息
This commit is contained in:
parent
e5f50423ad
commit
6357d6706d
|
@ -45,6 +45,10 @@ const (
|
||||||
THIRD_ORDER_TYPE_REFUND_QUERY = 4 // 退款查询
|
THIRD_ORDER_TYPE_REFUND_QUERY = 4 // 退款查询
|
||||||
THIRD_ORDER_TYPE_CLOSE = 5 // 关闭订单
|
THIRD_ORDER_TYPE_CLOSE = 5 // 关闭订单
|
||||||
THIRD_ORDER_TYPE_CALL_BACK = 6 // 支付回调
|
THIRD_ORDER_TYPE_CALL_BACK = 6 // 支付回调
|
||||||
|
|
||||||
|
THIRD_ORDER_LOG_STATUS_COMMON = 0 // 第三方日志状态 未知
|
||||||
|
THIRD_ORDER_LOG_STATUS_FAIL = 1 // 第三方日志状态 失败
|
||||||
|
THIRD_ORDER_LOG_STATUS_SUCCESS = 2 // 第三方日志状态 成功
|
||||||
)
|
)
|
||||||
|
|
||||||
var PayChannelList = map[int]string{
|
var PayChannelList = map[int]string{
|
||||||
|
|
|
@ -132,7 +132,8 @@ func ALiCallBack(notifyReq gopay.BodyMap, aliConfig AliPay) error {
|
||||||
go func() {
|
go func() {
|
||||||
payCallback, _ := json.Marshal(notifyReq)
|
payCallback, _ := json.Marshal(notifyReq)
|
||||||
payParam := "{}"
|
payParam := "{}"
|
||||||
SaveLog(int64(orderId), common.THIRD_ORDER_TYPE_CALL_BACK, string(payCallback), payParam, string(merchantCallback))
|
status := common.THIRD_ORDER_LOG_STATUS_SUCCESS
|
||||||
|
SaveLog(int64(orderId), common.THIRD_ORDER_TYPE_CALL_BACK, string(payCallback), payParam, "{}", status)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if res.ErrCode != errorcode.Success {
|
if res.ErrCode != errorcode.Success {
|
||||||
|
|
|
@ -59,6 +59,7 @@ func PaymentService(c context.Context, payOrderRequest PayOrderRequest) PayOrder
|
||||||
logger.Info(c, "PaymentService 收到支付请求", payOrderRequest)
|
logger.Info(c, "PaymentService 收到支付请求", payOrderRequest)
|
||||||
var err error
|
var err error
|
||||||
var info string
|
var info string
|
||||||
|
var payOrderResponse PayOrderResponse
|
||||||
switch payOrderRequest.ChannelType {
|
switch payOrderRequest.ChannelType {
|
||||||
case payCommon.PAY_CHANNEL_WECHAT_H5:
|
case payCommon.PAY_CHANNEL_WECHAT_H5:
|
||||||
// 微信H5支付
|
// 微信H5支付
|
||||||
|
@ -67,29 +68,35 @@ func PaymentService(c context.Context, payOrderRequest PayOrderRequest) PayOrder
|
||||||
// 支付宝H5支付
|
// 支付宝H5支付
|
||||||
info, err = ALiH5PayInfo(c, payOrderRequest)
|
info, err = ALiH5PayInfo(c, payOrderRequest)
|
||||||
default:
|
default:
|
||||||
return PayOrderResponse{
|
payOrderResponse = PayOrderResponse{
|
||||||
Code: payCommon.PAY_NOT_FOUND_CODE,
|
Code: payCommon.PAY_NOT_FOUND_CODE,
|
||||||
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logStatus := common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return PayOrderResponse{
|
payOrderResponse = PayOrderResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
|
logStatus = common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
|
} else {
|
||||||
|
payOrderResponse = PayOrderResponse{
|
||||||
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
|
ErrorMsg: "",
|
||||||
|
Result: info,
|
||||||
|
}
|
||||||
|
logStatus = common.THIRD_ORDER_LOG_STATUS_SUCCESS
|
||||||
}
|
}
|
||||||
payOrderResponse := PayOrderResponse{
|
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
|
||||||
ErrorMsg: "",
|
|
||||||
Result: info,
|
|
||||||
}
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
go func() {
|
go func() {
|
||||||
orderId := payOrderRequest.OrderId
|
orderId := payOrderRequest.OrderId
|
||||||
payCallback := fmt.Sprintf("{%s}", info)
|
payCallback := fmt.Sprintf("{%s}", info)
|
||||||
payParam, _ := json.Marshal(payOrderRequest)
|
payParam, _ := json.Marshal(payOrderRequest)
|
||||||
merchantCallback, _ := json.Marshal(payOrderResponse)
|
merchantCallback, _ := json.Marshal(payOrderResponse)
|
||||||
SaveLog(orderId, common.THIRD_ORDER_TYPE_PAY, payCallback, string(payParam), string(merchantCallback))
|
SaveLog(orderId, common.THIRD_ORDER_TYPE_PAY, payCallback, string(payParam), string(merchantCallback), logStatus)
|
||||||
}()
|
}()
|
||||||
return payOrderResponse
|
return payOrderResponse
|
||||||
}
|
}
|
||||||
|
@ -122,6 +129,7 @@ type PayOrderQueryInfo struct {
|
||||||
func PayOrderQuery(c context.Context, payOrderQueryRequest PayOrderQueryRequest) PayOrderQueryResponse {
|
func PayOrderQuery(c context.Context, payOrderQueryRequest PayOrderQueryRequest) PayOrderQueryResponse {
|
||||||
var err error
|
var err error
|
||||||
var info PayOrderQueryInfo
|
var info PayOrderQueryInfo
|
||||||
|
var payOrderQueryResponse PayOrderQueryResponse
|
||||||
switch payOrderQueryRequest.PayChannel {
|
switch payOrderQueryRequest.PayChannel {
|
||||||
case payCommon.PAY_CHANNLE_TYPE_WECHAT:
|
case payCommon.PAY_CHANNLE_TYPE_WECHAT:
|
||||||
// 微信H5支付
|
// 微信H5支付
|
||||||
|
@ -129,21 +137,25 @@ func PayOrderQuery(c context.Context, payOrderQueryRequest PayOrderQueryRequest)
|
||||||
case payCommon.PAY_CHANNLE_TYPE_ZFB:
|
case payCommon.PAY_CHANNLE_TYPE_ZFB:
|
||||||
info, err = ALiOrderQuery(c, payOrderQueryRequest.Ali, strconv.FormatInt(payOrderQueryRequest.OrderId, 10))
|
info, err = ALiOrderQuery(c, payOrderQueryRequest.Ali, strconv.FormatInt(payOrderQueryRequest.OrderId, 10))
|
||||||
default:
|
default:
|
||||||
return PayOrderQueryResponse{
|
payOrderQueryResponse = PayOrderQueryResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logStatus := common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return PayOrderQueryResponse{
|
payOrderQueryResponse = PayOrderQueryResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
logStatus = common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
|
} else {
|
||||||
payOrderQueryResponse := PayOrderQueryResponse{
|
payOrderQueryResponse = PayOrderQueryResponse{
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
Result: info,
|
Result: info,
|
||||||
|
}
|
||||||
|
logStatus = common.THIRD_ORDER_LOG_STATUS_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
|
@ -152,7 +164,7 @@ func PayOrderQuery(c context.Context, payOrderQueryRequest PayOrderQueryRequest)
|
||||||
payCallback, _ := json.Marshal(info)
|
payCallback, _ := json.Marshal(info)
|
||||||
payParam, _ := json.Marshal(payOrderQueryRequest)
|
payParam, _ := json.Marshal(payOrderQueryRequest)
|
||||||
merchantCallback, _ := json.Marshal(payOrderQueryResponse)
|
merchantCallback, _ := json.Marshal(payOrderQueryResponse)
|
||||||
SaveLog(orderId, common.THIRD_ORDER_TYPE_ORDER_QUERY, string(payCallback), string(payParam), string(merchantCallback))
|
SaveLog(orderId, common.THIRD_ORDER_TYPE_ORDER_QUERY, string(payCallback), string(payParam), string(merchantCallback), logStatus)
|
||||||
}()
|
}()
|
||||||
return payOrderQueryResponse
|
return payOrderQueryResponse
|
||||||
}
|
}
|
||||||
|
@ -187,6 +199,7 @@ func OrderRefund(c context.Context, orderRefundRequest OrderRefundRequest) Order
|
||||||
logger.Info(c, "PaymentService 收到退款请求", orderRefundRequest)
|
logger.Info(c, "PaymentService 收到退款请求", orderRefundRequest)
|
||||||
var err error
|
var err error
|
||||||
var info OrderRefundInfo
|
var info OrderRefundInfo
|
||||||
|
var orderRefundResponse OrderRefundResponse
|
||||||
switch orderRefundRequest.PayChannel {
|
switch orderRefundRequest.PayChannel {
|
||||||
case payCommon.PAY_CHANNLE_TYPE_WECHAT:
|
case payCommon.PAY_CHANNLE_TYPE_WECHAT:
|
||||||
// 微信H5支付
|
// 微信H5支付
|
||||||
|
@ -194,31 +207,35 @@ func OrderRefund(c context.Context, orderRefundRequest OrderRefundRequest) Order
|
||||||
case payCommon.PAY_CHANNLE_TYPE_ZFB:
|
case payCommon.PAY_CHANNLE_TYPE_ZFB:
|
||||||
info, err = AliRefundOrder(c, orderRefundRequest)
|
info, err = AliRefundOrder(c, orderRefundRequest)
|
||||||
default:
|
default:
|
||||||
return OrderRefundResponse{
|
orderRefundResponse = OrderRefundResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logStatus := common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return OrderRefundResponse{
|
orderRefundResponse = OrderRefundResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
|
logStatus = common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
|
} else {
|
||||||
|
orderRefundResponse = OrderRefundResponse{
|
||||||
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
|
Result: info,
|
||||||
|
}
|
||||||
|
logStatus = common.THIRD_ORDER_LOG_STATUS_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
orderRefundResponse := OrderRefundResponse{
|
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
|
||||||
Result: info,
|
|
||||||
}
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
go func() {
|
go func() {
|
||||||
orderId := orderRefundRequest.OrderId
|
orderId := orderRefundRequest.OrderId
|
||||||
payCallback, _ := json.Marshal(info)
|
payCallback, _ := json.Marshal(info)
|
||||||
payParam, _ := json.Marshal(orderRefundRequest)
|
payParam, _ := json.Marshal(orderRefundRequest)
|
||||||
merchantCallback, _ := json.Marshal(orderRefundResponse)
|
merchantCallback, _ := json.Marshal(orderRefundResponse)
|
||||||
SaveLog(orderId, common.THIRD_ORDER_TYPE_REFUND, string(payCallback), string(payParam), string(merchantCallback))
|
SaveLog(orderId, common.THIRD_ORDER_TYPE_REFUND, string(payCallback), string(payParam), string(merchantCallback), logStatus)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return orderRefundResponse
|
return orderRefundResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +256,7 @@ type OrderRefundQueryResponse struct {
|
||||||
func OrderRefundQuery(c context.Context, orderRefundQueryRequest OrderRefundQueryRequest) OrderRefundQueryResponse {
|
func OrderRefundQuery(c context.Context, orderRefundQueryRequest OrderRefundQueryRequest) OrderRefundQueryResponse {
|
||||||
var err error
|
var err error
|
||||||
var info OrderRefundInfo
|
var info OrderRefundInfo
|
||||||
|
var orderRefundQueryResponse OrderRefundQueryResponse
|
||||||
switch orderRefundQueryRequest.PayChannel {
|
switch orderRefundQueryRequest.PayChannel {
|
||||||
case payCommon.PAY_CHANNLE_TYPE_WECHAT:
|
case payCommon.PAY_CHANNLE_TYPE_WECHAT:
|
||||||
// 微信H5支付
|
// 微信H5支付
|
||||||
|
@ -246,20 +264,25 @@ func OrderRefundQuery(c context.Context, orderRefundQueryRequest OrderRefundQuer
|
||||||
case payCommon.PAY_CHANNLE_TYPE_ZFB:
|
case payCommon.PAY_CHANNLE_TYPE_ZFB:
|
||||||
info, err = AliRefundOrderQuery(c, orderRefundQueryRequest)
|
info, err = AliRefundOrderQuery(c, orderRefundQueryRequest)
|
||||||
default:
|
default:
|
||||||
return OrderRefundQueryResponse{
|
orderRefundQueryResponse = OrderRefundQueryResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logStatus := common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return OrderRefundQueryResponse{
|
orderRefundQueryResponse = OrderRefundQueryResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
logStatus = common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
orderRefundQueryResponse := OrderRefundQueryResponse{
|
} else {
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
orderRefundQueryResponse = OrderRefundQueryResponse{
|
||||||
Result: info,
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
|
Result: info,
|
||||||
|
}
|
||||||
|
logStatus = common.THIRD_ORDER_LOG_STATUS_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
|
@ -268,9 +291,8 @@ func OrderRefundQuery(c context.Context, orderRefundQueryRequest OrderRefundQuer
|
||||||
payCallback, _ := json.Marshal(info)
|
payCallback, _ := json.Marshal(info)
|
||||||
payParam, _ := json.Marshal(orderRefundQueryRequest)
|
payParam, _ := json.Marshal(orderRefundQueryRequest)
|
||||||
merchantCallback, _ := json.Marshal(orderRefundQueryResponse)
|
merchantCallback, _ := json.Marshal(orderRefundQueryResponse)
|
||||||
SaveLog(orderId, common.THIRD_ORDER_TYPE_REFUND_QUERY, string(payCallback), string(payParam), string(merchantCallback))
|
SaveLog(orderId, common.THIRD_ORDER_TYPE_REFUND_QUERY, string(payCallback), string(payParam), string(merchantCallback), logStatus)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return orderRefundQueryResponse
|
return orderRefundQueryResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,6 +318,7 @@ func OrderClose(c context.Context, orderCloseRequest OrderCloseRequest) OrderClo
|
||||||
logger.Info(c, "PaymentService 收到关闭订单请求", orderCloseRequest)
|
logger.Info(c, "PaymentService 收到关闭订单请求", orderCloseRequest)
|
||||||
var err error
|
var err error
|
||||||
var info OrderCloseInfo
|
var info OrderCloseInfo
|
||||||
|
var orderCloseResponse OrderCloseResponse
|
||||||
switch orderCloseRequest.PayChannel {
|
switch orderCloseRequest.PayChannel {
|
||||||
case payCommon.PAY_CHANNLE_TYPE_WECHAT:
|
case payCommon.PAY_CHANNLE_TYPE_WECHAT:
|
||||||
// 微信H5支付
|
// 微信H5支付
|
||||||
|
@ -303,40 +326,45 @@ func OrderClose(c context.Context, orderCloseRequest OrderCloseRequest) OrderClo
|
||||||
case payCommon.PAY_CHANNLE_TYPE_ZFB:
|
case payCommon.PAY_CHANNLE_TYPE_ZFB:
|
||||||
info, err = AliCloseOrder(c, orderCloseRequest)
|
info, err = AliCloseOrder(c, orderCloseRequest)
|
||||||
default:
|
default:
|
||||||
return OrderCloseResponse{
|
orderCloseResponse = OrderCloseResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
ErrorMsg: "暂不支持该支付渠道,请后续再使用",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logStatus := common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return OrderCloseResponse{
|
orderCloseResponse = OrderCloseResponse{
|
||||||
Code: payCommon.PAY_ERROR_CODE,
|
Code: payCommon.PAY_ERROR_CODE,
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
|
logStatus = common.THIRD_ORDER_LOG_STATUS_FAIL
|
||||||
|
} else {
|
||||||
|
orderCloseResponse = OrderCloseResponse{
|
||||||
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
|
Result: info,
|
||||||
|
}
|
||||||
|
logStatus = common.THIRD_ORDER_LOG_STATUS_SUCCESS
|
||||||
}
|
}
|
||||||
orderCloseResponse := OrderCloseResponse{
|
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
|
||||||
Result: info,
|
|
||||||
}
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
go func() {
|
go func() {
|
||||||
orderId := orderCloseRequest.OrderId
|
orderId := orderCloseRequest.OrderId
|
||||||
payCallback, _ := json.Marshal(info)
|
payCallback, _ := json.Marshal(info)
|
||||||
payParam, _ := json.Marshal(orderCloseRequest)
|
payParam, _ := json.Marshal(orderCloseRequest)
|
||||||
merchantCallback, _ := json.Marshal(orderCloseResponse)
|
merchantCallback, _ := json.Marshal(orderCloseResponse)
|
||||||
SaveLog(orderId, common.THIRD_ORDER_TYPE_CLOSE, string(payCallback), string(payParam), string(merchantCallback))
|
SaveLog(orderId, common.THIRD_ORDER_TYPE_CLOSE, string(payCallback), string(payParam), string(merchantCallback), logStatus)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return orderCloseResponse
|
return orderCloseResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveLog 记录操作日志
|
// SaveLog 记录操作日志
|
||||||
func SaveLog(orderId int64, OType int, payCallback string, PayParam string, MerchantCallback string) {
|
func SaveLog(orderId int64, OType int, payCallback string, PayParam string, MerchantCallback string, status int) {
|
||||||
thirdRepo := data.NewOrderThirdPayLogRepo(paychannelmodel.GetInstance().GetDb())
|
thirdRepo := data.NewOrderThirdPayLogRepo(paychannelmodel.GetInstance().GetDb())
|
||||||
log := orderthirdpaylogmodel.OrderThirdPayLog{
|
log := orderthirdpaylogmodel.OrderThirdPayLog{
|
||||||
OrderId: orderId,
|
OrderId: orderId,
|
||||||
PayCallback: payCallback,
|
PayCallback: payCallback,
|
||||||
Status: 0,
|
Status: status,
|
||||||
PayParam: PayParam,
|
PayParam: PayParam,
|
||||||
MerchantCallback: MerchantCallback,
|
MerchantCallback: MerchantCallback,
|
||||||
Type: OType,
|
Type: OType,
|
||||||
|
|
|
@ -166,7 +166,8 @@ func WxPayCallBack(notifyReq *wechat.V3NotifyReq, wxConfig WxPay) error {
|
||||||
go func() {
|
go func() {
|
||||||
payCallback, _ := json.Marshal(CallBackInfo)
|
payCallback, _ := json.Marshal(CallBackInfo)
|
||||||
payParam := "{}"
|
payParam := "{}"
|
||||||
SaveLog(int64(orderId), common.THIRD_ORDER_TYPE_CALL_BACK, string(payCallback), payParam, string(merchantCallback))
|
status := common.THIRD_ORDER_LOG_STATUS_SUCCESS
|
||||||
|
SaveLog(int64(orderId), common.THIRD_ORDER_TYPE_CALL_BACK, string(payCallback), payParam, "{}", status)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if res.ErrCode != errorcode.Success {
|
if res.ErrCode != errorcode.Success {
|
||||||
|
|
Loading…
Reference in New Issue