Merge branch 'feature_413_cjh' into dev/dev1.0
This commit is contained in:
commit
0d38872fa6
|
@ -215,7 +215,7 @@ func queryOrder() {
|
||||||
OrderId: orderInfo.Id,
|
OrderId: orderInfo.Id,
|
||||||
PayCallback: string(body),
|
PayCallback: string(body),
|
||||||
Status: 0,
|
Status: 0,
|
||||||
MerchantParam: "",
|
PayParam: "",
|
||||||
MerchantCallback: "",
|
MerchantCallback: "",
|
||||||
}
|
}
|
||||||
_, err = orderLogRepo.OrderThirdPayLogInsertOne(&log)
|
_, err = orderLogRepo.OrderThirdPayLogInsertOne(&log)
|
||||||
|
|
|
@ -31,4 +31,11 @@ const (
|
||||||
|
|
||||||
PAY_CHANNLE_TYPE_WECHAT = 1 // 支付类型: 微信
|
PAY_CHANNLE_TYPE_WECHAT = 1 // 支付类型: 微信
|
||||||
PAY_CHANNLE_TYPE_ZFB = 2 // 支付类型:支付宝
|
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 // 支付回调
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
package paymentService
|
package paymentService
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"PaymentCenter/app/constants/common"
|
||||||
|
"PaymentCenter/app/data"
|
||||||
|
"PaymentCenter/app/models/orderthirdpaylogmodel"
|
||||||
|
"PaymentCenter/app/models/paychannelmodel"
|
||||||
"PaymentCenter/app/third/paymentService/payCommon"
|
"PaymentCenter/app/third/paymentService/payCommon"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"github.com/qit-team/snow-core/log/logger"
|
"github.com/qit-team/snow-core/log/logger"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
@ -41,7 +46,7 @@ type PayOrderResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PaymentService 统一发起支付
|
// PaymentService 统一发起支付
|
||||||
func PaymentService(c context.Context, payOrderRequest PayOrderRequest) (payOrderResponse PayOrderResponse) {
|
func PaymentService(c context.Context, payOrderRequest PayOrderRequest) PayOrderResponse {
|
||||||
logger.Info(c, "PaymentService 收到支付请求", payOrderRequest)
|
logger.Info(c, "PaymentService 收到支付请求", payOrderRequest)
|
||||||
var err error
|
var err error
|
||||||
var info string
|
var info string
|
||||||
|
@ -64,11 +69,20 @@ func PaymentService(c context.Context, payOrderRequest PayOrderRequest) (payOrde
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PayOrderResponse{
|
payOrderResponse := PayOrderResponse{
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
ErrorMsg: "",
|
ErrorMsg: "",
|
||||||
Result: info,
|
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 {
|
type PayOrderQueryRequest struct {
|
||||||
|
@ -117,10 +131,21 @@ func PayOrderQuery(c context.Context, payOrderQueryRequest PayOrderQueryRequest)
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PayOrderQueryResponse{
|
|
||||||
|
payOrderQueryResponse := PayOrderQueryResponse{
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
Result: info,
|
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 {
|
type OrderRefundRequest struct {
|
||||||
|
@ -171,10 +196,21 @@ func OrderRefund(c context.Context, orderRefundRequest OrderRefundRequest) Order
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OrderRefundResponse{
|
|
||||||
|
orderRefundResponse := OrderRefundResponse{
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
Result: info,
|
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 {
|
type OrderRefundQueryRequest struct {
|
||||||
|
@ -212,10 +248,21 @@ func OrderRefundQuery(c context.Context, orderRefundQueryRequest OrderRefundQuer
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OrderRefundQueryResponse{
|
orderRefundQueryResponse := OrderRefundQueryResponse{
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
Result: info,
|
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 {
|
type OrderCloseRequest struct {
|
||||||
|
@ -258,8 +305,35 @@ func OrderClose(c context.Context, orderCloseRequest OrderCloseRequest) OrderClo
|
||||||
ErrorMsg: err.Error(),
|
ErrorMsg: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OrderCloseResponse{
|
orderCloseResponse := OrderCloseResponse{
|
||||||
Code: payCommon.PAY_SUCCESS_CODE,
|
Code: payCommon.PAY_SUCCESS_CODE,
|
||||||
Result: info,
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue