Compare commits

..

No commits in common. "0d38872fa68cda3df274c131ac3162b1fff9cd60" and "e9d3dbece038c19fb5d1119961dae9286474c0ac" have entirely different histories.

3 changed files with 7 additions and 88 deletions

View File

@ -215,7 +215,7 @@ func queryOrder() {
OrderId: orderInfo.Id,
PayCallback: string(body),
Status: 0,
PayParam: "",
MerchantParam: "",
MerchantCallback: "",
}
_, err = orderLogRepo.OrderThirdPayLogInsertOne(&log)

View File

@ -31,11 +31,4 @@ const (
PAY_CHANNLE_TYPE_WECHAT = 1 // 支付类型: 微信
PAY_CHANNLE_TYPE_ZFB = 2 // 支付类型:支付宝
THIRD_ORDER_TYPE_PAY = 1 // 发起支付
THIRD_ORDER_TYPE_ORDER_QUERY = 2 // 查询订单
THIRD_ORDER_TYPE_REFUND = 3 // 发起退款
THIRD_ORDER_TYPE_REFUND_QUERY = 4 // 退款查询
THIRD_ORDER_TYPE_CLOSE = 5 // 关闭订单
THIRD_ORDER_TYPE_CALL_BACK = 6 // 支付回调
)

View File

@ -1,13 +1,8 @@
package paymentService
import (
"PaymentCenter/app/constants/common"
"PaymentCenter/app/data"
"PaymentCenter/app/models/orderthirdpaylogmodel"
"PaymentCenter/app/models/paychannelmodel"
"PaymentCenter/app/third/paymentService/payCommon"
"context"
"encoding/json"
"github.com/qit-team/snow-core/log/logger"
"strconv"
)
@ -46,7 +41,7 @@ type PayOrderResponse struct {
}
// PaymentService 统一发起支付
func PaymentService(c context.Context, payOrderRequest PayOrderRequest) PayOrderResponse {
func PaymentService(c context.Context, payOrderRequest PayOrderRequest) (payOrderResponse PayOrderResponse) {
logger.Info(c, "PaymentService 收到支付请求", payOrderRequest)
var err error
var info string
@ -69,20 +64,11 @@ func PaymentService(c context.Context, payOrderRequest PayOrderRequest) PayOrder
ErrorMsg: err.Error(),
}
}
payOrderResponse := PayOrderResponse{
return PayOrderResponse{
Code: payCommon.PAY_SUCCESS_CODE,
ErrorMsg: "",
Result: info,
}
// 记录日志
go func() {
orderId := payOrderRequest.OrderId
payCallback := info
payParam, _ := json.Marshal(payOrderRequest)
merchantCallback, _ := json.Marshal(payOrderResponse)
saveLog(orderId, common.THIRD_ORDER_TYPE_PAY, payCallback, string(payParam), string(merchantCallback))
}()
return payOrderResponse
}
type PayOrderQueryRequest struct {
@ -131,21 +117,10 @@ func PayOrderQuery(c context.Context, payOrderQueryRequest PayOrderQueryRequest)
ErrorMsg: err.Error(),
}
}
payOrderQueryResponse := PayOrderQueryResponse{
return PayOrderQueryResponse{
Code: payCommon.PAY_SUCCESS_CODE,
Result: info,
}
// 记录日志
go func() {
orderId := payOrderQueryRequest.OrderId
payCallback, _ := json.Marshal(info)
payParam, _ := json.Marshal(payOrderQueryRequest)
merchantCallback, _ := json.Marshal(payOrderQueryResponse)
saveLog(orderId, common.THIRD_ORDER_TYPE_ORDER_QUERY, string(payCallback), string(payParam), string(merchantCallback))
}()
return payOrderQueryResponse
}
type OrderRefundRequest struct {
@ -196,21 +171,10 @@ func OrderRefund(c context.Context, orderRefundRequest OrderRefundRequest) Order
ErrorMsg: err.Error(),
}
}
orderRefundResponse := OrderRefundResponse{
return OrderRefundResponse{
Code: payCommon.PAY_SUCCESS_CODE,
Result: info,
}
// 记录日志
go func() {
orderId := orderRefundRequest.OrderId
payCallback, _ := json.Marshal(info)
payParam, _ := json.Marshal(orderRefundRequest)
merchantCallback, _ := json.Marshal(orderRefundResponse)
saveLog(orderId, common.THIRD_ORDER_TYPE_REFUND, string(payCallback), string(payParam), string(merchantCallback))
}()
return orderRefundResponse
}
type OrderRefundQueryRequest struct {
@ -248,21 +212,10 @@ func OrderRefundQuery(c context.Context, orderRefundQueryRequest OrderRefundQuer
ErrorMsg: err.Error(),
}
}
orderRefundQueryResponse := OrderRefundQueryResponse{
return OrderRefundQueryResponse{
Code: payCommon.PAY_SUCCESS_CODE,
Result: info,
}
// 记录日志
go func() {
orderId := orderRefundQueryRequest.OrderId
payCallback, _ := json.Marshal(info)
payParam, _ := json.Marshal(orderRefundQueryRequest)
merchantCallback, _ := json.Marshal(orderRefundQueryResponse)
saveLog(orderId, common.THIRD_ORDER_TYPE_REFUND_QUERY, string(payCallback), string(payParam), string(merchantCallback))
}()
return orderRefundQueryResponse
}
type OrderCloseRequest struct {
@ -305,35 +258,8 @@ func OrderClose(c context.Context, orderCloseRequest OrderCloseRequest) OrderClo
ErrorMsg: err.Error(),
}
}
orderCloseResponse := OrderCloseResponse{
return OrderCloseResponse{
Code: payCommon.PAY_SUCCESS_CODE,
Result: info,
}
// 记录日志
go func() {
orderId := orderCloseRequest.OrderId
payCallback, _ := json.Marshal(info)
payParam, _ := json.Marshal(orderCloseRequest)
merchantCallback, _ := json.Marshal(orderCloseResponse)
saveLog(orderId, common.THIRD_ORDER_TYPE_CLOSE, string(payCallback), string(payParam), string(merchantCallback))
}()
return orderCloseResponse
}
// saveLog 记录操作日志
func saveLog(orderId int64, OType int, payCallback string, PayParam string, MerchantCallback string) {
thirdRepo := data.NewOrderThirdPayLogRepo(paychannelmodel.GetInstance().GetDb())
log := orderthirdpaylogmodel.OrderThirdPayLog{
OrderId: orderId,
PayCallback: payCallback,
Status: 0,
PayParam: PayParam,
MerchantCallback: MerchantCallback,
Type: OType,
}
_, err := thirdRepo.OrderThirdPayLogInsertOne(&log)
if err != nil {
return
}
}