63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package thirdpay
|
|
|
|
import (
|
|
"PaymentCenter/app/constants/errorcode"
|
|
"PaymentCenter/app/http/entities/front"
|
|
"PaymentCenter/app/models/ordersmodel"
|
|
"PaymentCenter/app/services"
|
|
thirdpay "PaymentCenter/app/services/thirdpay/do"
|
|
"PaymentCenter/app/services/thirdpay/types"
|
|
"context"
|
|
)
|
|
|
|
func ThirdPayWeb(check *thirdpay.PayCheck) *thirdpay.Pay {
|
|
pay := thirdpay.NewPay(check)
|
|
// 创建订单
|
|
pay.CreateOrder()
|
|
if pay.PayCode != errorcode.Success {
|
|
return pay
|
|
}
|
|
// 支付
|
|
pay.Pay()
|
|
return pay
|
|
}
|
|
|
|
func ThirdPayCheck(ctx context.Context, req *front.PayReqs, appCheck *services.AppCheck, ip string) (check *thirdpay.PayCheck) {
|
|
check = thirdpay.NewPayCheck(&ctx, req, appCheck, ip)
|
|
// 校验表单
|
|
check.CheckForm()
|
|
if check.CheckCode != errorcode.Success {
|
|
return
|
|
}
|
|
// 校验订单
|
|
check.CheckOrder()
|
|
if check.CheckCode != errorcode.Success {
|
|
return
|
|
}
|
|
// 校验商户
|
|
check.CheckMerchant()
|
|
if check.CheckCode != errorcode.Success {
|
|
return
|
|
}
|
|
// 校验支付通道
|
|
check.CheckPayChannel()
|
|
if check.CheckCode != errorcode.Success {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func PayCallBack(order *ordersmodel.Orders, isNew bool) *types.PayResp {
|
|
res := &types.PayResp{
|
|
OrderNo: order.Id,
|
|
OrderType: order.OrderType,
|
|
Amount: order.Amount,
|
|
Desc: order.Desc,
|
|
IsNewCreate: isNew,
|
|
Status: order.Status,
|
|
}
|
|
|
|
return res
|
|
}
|