新增支付平台通联宝测试
This commit is contained in:
@@ -378,7 +378,7 @@ func CreateUser(user *model.User, creatorName string) (err error) {
|
||||
dao.WrapAddIDCULDEntity(user, creatorName)
|
||||
user.UserID = utils.GetUUID()
|
||||
user.Status = model.UserStatusNormal
|
||||
user.DividePercentage = 5
|
||||
user.DividePercentage = 1
|
||||
return dao.CreateEntity(nil, user)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ const (
|
||||
|
||||
const (
|
||||
PayTypeWX = 1 // 微信支付
|
||||
PayTypeTL = 2 // 通联宝支付
|
||||
|
||||
PayStatusNo = 0
|
||||
PayStatusYes = 1
|
||||
@@ -317,7 +318,7 @@ type OrderPay struct {
|
||||
|
||||
PrepayID string `orm:"column(prepay_id);index;size(48)" json:"prepayID"` // 下单后,支付前,支付方生成的事务ID
|
||||
TransactionID string `orm:"column(transaction_id);index;size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
||||
CodeURL string `orm:"column(code_url);size(256)" json:"codeURL"`
|
||||
CodeURL string `orm:"column(code_url);size(3200)" json:"codeURL"`
|
||||
OriginalData string `orm:"type(text)" json:"-"`
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,11 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
case model.PayTypeTL:
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, vendorPayType); err == nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
default:
|
||||
err = fmt.Errorf("支付方式:%d当前不支持", payType)
|
||||
}
|
||||
|
||||
57
business/partner/purchase/jx/localjx/tonglianpay.go
Normal file
57
business/partner/purchase/jx/localjx/tonglianpay.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package localjx
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/tonglianpayapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayType string) (orderPay *model.OrderPay, err error) {
|
||||
payCreatedAt := time.Now()
|
||||
// param := &wxpayapi.CreateOrderParam{
|
||||
// OutTradeNo: utils.Int64ToStr(GenPayOrderID(order)),
|
||||
// Body: getOrderBrief(order),
|
||||
// NotifyURL: globals.TLPayNotifyURL,
|
||||
// SpbillCreateIP: ctx.GetRealRemoteIP(),
|
||||
// TradeType: vendorPayType2WxpayType(vendorPayType),
|
||||
// TotalFee: int(order.ActualPayPrice),
|
||||
|
||||
// TimeStart: wxpayapi.Time2PayTime(payCreatedAt),
|
||||
// // TimeExpire: wxpayapi.Time2PayTime(payCreatedAt.Add(PayWaitingTime)),
|
||||
// ProfitSharing: wxpayapi.OptYes,
|
||||
// }
|
||||
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
||||
Trxamt: int(order.ActualPayPrice),
|
||||
NotifyUrl: globals.TLPayNotifyURL,
|
||||
Reqsn: order.VendorOrderID,
|
||||
}
|
||||
|
||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini {
|
||||
param.Acct = authInfo.GetAuthID()
|
||||
}
|
||||
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
||||
if err == nil {
|
||||
orderPay = &model.OrderPay{
|
||||
PayOrderID: param.Reqsn,
|
||||
PayType: model.PayTypeTL,
|
||||
VendorPayType: vendorPayType,
|
||||
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
VendorID: order.VendorID,
|
||||
Status: 0,
|
||||
PayCreatedAt: payCreatedAt,
|
||||
PrepayID: result.TrxID,
|
||||
CodeURL: utils.LimitUTF8StringLen(result.PayInfo, 3200),
|
||||
TotalFee: int(order.ActualPayPrice),
|
||||
}
|
||||
}
|
||||
return orderPay, err
|
||||
}
|
||||
Reference in New Issue
Block a user