<feat>调整代码结构

This commit is contained in:
Rzy 2024-08-08 11:15:50 +08:00
parent cb14c35aa9
commit aa43040aa2
5 changed files with 19 additions and 20 deletions
app
console
services/thirdpay
pay.go
thirdpay_notify
third/paymentService

View File

@ -6,7 +6,7 @@ import (
"PaymentCenter/app/http/entities"
"PaymentCenter/app/http/entities/backend"
"PaymentCenter/app/models/ordersmodel"
"PaymentCenter/app/services/thirdpay"
"PaymentCenter/app/services/thirdpay/thirdpay_notify"
"PaymentCenter/app/third/paymentService"
"PaymentCenter/app/third/paymentService/payCommon"
"PaymentCenter/app/utils"
@ -181,7 +181,7 @@ func queryOrder() {
status = common.ORDER_STATUS_CLOSE
}
// 回调通知下游 todo
notifyResult := thirdpay.NewOrderNotifyWithHandle(orderInfo.Id, status, int(result.Result.PayerTotal), "")
notifyResult := thirdpay_notify.NewOrderNotifyWithHandle(orderInfo.Id, status, int(result.Result.PayerTotal), "")
utils.Log(nil, "主动查询订单支付状态,回调下游", notifyResult)
}
}(orderInfo)
@ -278,7 +278,7 @@ func queryRefundOrder() {
status = common.ORDER_STATUS_FAILED
}
// 回调通知下游 todo
notifyResult := thirdpay.NewOrderNotifyWithHandle(orderInfo.Id, status, int(result.Result.RefundFee), "")
notifyResult := thirdpay_notify.NewOrderNotifyWithHandle(orderInfo.Id, status, int(result.Result.RefundFee), "")
utils.Log(nil, "主动查询退款订单状态,回调下游", notifyResult)
}
}(orderInfo)

View File

@ -8,7 +8,6 @@ import (
"PaymentCenter/app/services"
"PaymentCenter/app/services/thirdpay/api"
thirdpay "PaymentCenter/app/services/thirdpay/do"
"PaymentCenter/app/services/thirdpay/notify"
"context"
)
@ -31,17 +30,6 @@ func NewOrdersResp(db *ordersmodel.Orders) *api.OrdersResp {
}
}
func NewOrderNotifyWithHandle(orderId int64, Status int, actualAmount int, msg string) *notify.OrderNotifyResp {
orderNotify := &notify.OrderNotify{
OrderId: orderId,
Status: Status,
ActualAmount: actualAmount,
Msg: msg,
Code: errorcode.Success,
}
return orderNotify.Handle()
}
func ThirdPayRefund(check *thirdpay.PayCheck) *thirdpay.Pay {
pay := thirdpay.NewPay(check)
// 创建订单

View File

@ -1,4 +1,4 @@
package notify
package thirdpay_notify
import (
"PaymentCenter/app/constants/common"
@ -46,6 +46,17 @@ type OrderNotifySendContent struct {
MerchantId int64 `json:"merchant_id"`
}
func NewOrderNotifyWithHandle(orderId int64, Status int, actualAmount int, msg string) *OrderNotifyResp {
orderNotify := &OrderNotify{
OrderId: orderId,
Status: Status,
ActualAmount: actualAmount,
Msg: msg,
Code: errorcode.Success,
}
return orderNotify.Handle()
}
func (o *OrderNotify) NotifyRespFail(errorCode int) *OrderNotifyResp {
return &OrderNotifyResp{
OrderId: o.OrderId,

View File

@ -3,7 +3,7 @@ package paymentService
import (
"PaymentCenter/app/constants/common"
"PaymentCenter/app/constants/errorcode"
"PaymentCenter/app/services/thirdpay"
"PaymentCenter/app/services/thirdpay/thirdpay_notify"
"PaymentCenter/app/third/paymentService/payCommon"
"PaymentCenter/config"
"context"
@ -126,7 +126,7 @@ func ALiCallBack(notifyReq gopay.BodyMap, aliConfig AliPay) error {
return errors.New("订单状态异常,无法进行后续回调")
}
res := thirdpay.NewOrderNotifyWithHandle(int64(orderId), errCode, payerTotal, msg)
res := thirdpay_notify.NewOrderNotifyWithHandle(int64(orderId), errCode, payerTotal, msg)
merchantCallback, _ := json.Marshal(res)
// 记录日志
go func() {

View File

@ -3,7 +3,7 @@ package paymentService
import (
"PaymentCenter/app/constants/common"
"PaymentCenter/app/constants/errorcode"
"PaymentCenter/app/services/thirdpay"
"PaymentCenter/app/services/thirdpay/thirdpay_notify"
"PaymentCenter/app/third/paymentService/payCommon"
"PaymentCenter/config"
"context"
@ -160,7 +160,7 @@ func WxPayCallBack(notifyReq *wechat.V3NotifyReq, wxConfig WxPay) error {
// 触发下游回调的格式
orderId, _ := strconv.Atoi(CallBackInfo.OutTradeNo)
res := thirdpay.NewOrderNotifyWithHandle(int64(orderId), errCode, int(CallBackInfo.Amount.PayerTotal), msg)
res := thirdpay_notify.NewOrderNotifyWithHandle(int64(orderId), errCode, int(CallBackInfo.Amount.PayerTotal), msg)
merchantCallback, _ := json.Marshal(res)
// 记录日志
go func() {