<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

View File

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

View File

@ -8,7 +8,6 @@ import (
"PaymentCenter/app/services" "PaymentCenter/app/services"
"PaymentCenter/app/services/thirdpay/api" "PaymentCenter/app/services/thirdpay/api"
thirdpay "PaymentCenter/app/services/thirdpay/do" thirdpay "PaymentCenter/app/services/thirdpay/do"
"PaymentCenter/app/services/thirdpay/notify"
"context" "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 { func ThirdPayRefund(check *thirdpay.PayCheck) *thirdpay.Pay {
pay := thirdpay.NewPay(check) pay := thirdpay.NewPay(check)
// 创建订单 // 创建订单

View File

@ -1,4 +1,4 @@
package notify package thirdpay_notify
import ( import (
"PaymentCenter/app/constants/common" "PaymentCenter/app/constants/common"
@ -46,6 +46,17 @@ type OrderNotifySendContent struct {
MerchantId int64 `json:"merchant_id"` 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 { func (o *OrderNotify) NotifyRespFail(errorCode int) *OrderNotifyResp {
return &OrderNotifyResp{ return &OrderNotifyResp{
OrderId: o.OrderId, OrderId: o.OrderId,

View File

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

View File

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