新增支付平台通联宝测试
This commit is contained in:
@@ -378,7 +378,7 @@ func CreateUser(user *model.User, creatorName string) (err error) {
|
|||||||
dao.WrapAddIDCULDEntity(user, creatorName)
|
dao.WrapAddIDCULDEntity(user, creatorName)
|
||||||
user.UserID = utils.GetUUID()
|
user.UserID = utils.GetUUID()
|
||||||
user.Status = model.UserStatusNormal
|
user.Status = model.UserStatusNormal
|
||||||
user.DividePercentage = 5
|
user.DividePercentage = 1
|
||||||
return dao.CreateEntity(nil, user)
|
return dao.CreateEntity(nil, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
PayTypeWX = 1 // 微信支付
|
PayTypeWX = 1 // 微信支付
|
||||||
|
PayTypeTL = 2 // 通联宝支付
|
||||||
|
|
||||||
PayStatusNo = 0
|
PayStatusNo = 0
|
||||||
PayStatusYes = 1
|
PayStatusYes = 1
|
||||||
@@ -317,7 +318,7 @@ type OrderPay struct {
|
|||||||
|
|
||||||
PrepayID string `orm:"column(prepay_id);index;size(48)" json:"prepayID"` // 下单后,支付前,支付方生成的事务ID
|
PrepayID string `orm:"column(prepay_id);index;size(48)" json:"prepayID"` // 下单后,支付前,支付方生成的事务ID
|
||||||
TransactionID string `orm:"column(transaction_id);index;size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务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:"-"`
|
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())
|
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
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:
|
default:
|
||||||
err = fmt.Errorf("支付方式:%d当前不支持", payType)
|
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
|
||||||
|
}
|
||||||
@@ -56,6 +56,11 @@ wxpayAppKey = "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD"
|
|||||||
wxpayAppMchID = "1390686702"
|
wxpayAppMchID = "1390686702"
|
||||||
wxpayNotifyURL = "http://callback.test.jxc4.com/wxpay/msg/"
|
wxpayNotifyURL = "http://callback.test.jxc4.com/wxpay/msg/"
|
||||||
|
|
||||||
|
tonglianPayAppID = "00183083"
|
||||||
|
tonglianPayKey = "18048531223"
|
||||||
|
tonglianPayCusID = "56065105499TVAH"
|
||||||
|
tonglianPayNotifyURL = "http://callback.test.jxc4.com/tlpay/msg/"
|
||||||
|
|
||||||
backstageHost = "http://www.jxc4.com"
|
backstageHost = "http://www.jxc4.com"
|
||||||
wxBackstageHost = "http://wx.jxc4.com"
|
wxBackstageHost = "http://wx.jxc4.com"
|
||||||
|
|
||||||
@@ -187,6 +192,10 @@ weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d"
|
|||||||
|
|
||||||
wxpayNotifyURL = "http://callback.jxc4.com/wxpay/msg/"
|
wxpayNotifyURL = "http://callback.jxc4.com/wxpay/msg/"
|
||||||
|
|
||||||
|
tonglianPayAppID = "00183083"
|
||||||
|
tonglianPayCusID = "56065105499TVAH"
|
||||||
|
tonglianPayNotifyURL = "http://callback.jxc4.com/tlpay/msg/"
|
||||||
|
|
||||||
dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
|
|
||||||
enableStoreWrite = true
|
enableStoreWrite = true
|
||||||
|
|||||||
41
controllers/tonglian_callback.go
Normal file
41
controllers/tonglian_callback.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/wxpayapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
"github.com/astaxie/beego"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TongLianController struct {
|
||||||
|
beego.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *TongLianController) Msg() {
|
||||||
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
|
msg, callbackResponse := api.WxpayAPI.GetCallbackMsg(c.Ctx.Request)
|
||||||
|
globals.SugarLogger.Debugf("tonglianapi callback msg:%s, callbackResponse:%s, %t", utils.Format4Output(msg, true), utils.Format4Output(callbackResponse, true), callbackResponse == nil)
|
||||||
|
var err error
|
||||||
|
if callbackResponse == nil {
|
||||||
|
if msg.MsgType == wxpayapi.MsgTypeUnkown {
|
||||||
|
err = fmt.Errorf("未知的通联宝支付回调类型:%d", msg.MsgType)
|
||||||
|
} else {
|
||||||
|
err = localjx.OnWxPayCallback(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if callbackResponse == nil {
|
||||||
|
callbackResponse = wxpayapi.SuccessResponse
|
||||||
|
} else if err != nil {
|
||||||
|
callbackResponse = wxpayapi.Err2CallbackResponse(err, "")
|
||||||
|
}
|
||||||
|
c.Data["json"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
} else {
|
||||||
|
c.Abort("404")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ package api
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/tonglianpayapi"
|
||||||
|
|
||||||
aliyunsmsclient "github.com/KenmyZhang/aliyun-communicate"
|
aliyunsmsclient "github.com/KenmyZhang/aliyun-communicate"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi"
|
"git.rosy.net.cn/baseapi/platformapi"
|
||||||
@@ -50,7 +52,8 @@ var (
|
|||||||
WeixinMiniAPI *weixinapi.API // 小程序
|
WeixinMiniAPI *weixinapi.API // 小程序
|
||||||
WeixinMiniAPI2 *weixinapi.API // 小程序2
|
WeixinMiniAPI2 *weixinapi.API // 小程序2
|
||||||
WeixinMiniAppID2 string
|
WeixinMiniAppID2 string
|
||||||
WxpayAPI *wxpayapi.API // 微信支付API
|
WxpayAPI *wxpayapi.API // 微信支付API
|
||||||
|
TLpayAPI *tonglianpayapi.API //通联收银宝api
|
||||||
|
|
||||||
WeixinPageAPI *weixinapi.API // 用户微信扫码登录
|
WeixinPageAPI *weixinapi.API // 用户微信扫码登录
|
||||||
|
|
||||||
@@ -181,6 +184,10 @@ func Init() {
|
|||||||
WxpayAPI = wxpayapi.NewWithCertificate(beego.AppConfig.String("wxpayAppID"), beego.AppConfig.String("wxpayAppKey"), beego.AppConfig.String("wxpayAppMchID"),
|
WxpayAPI = wxpayapi.NewWithCertificate(beego.AppConfig.String("wxpayAppID"), beego.AppConfig.String("wxpayAppKey"), beego.AppConfig.String("wxpayAppMchID"),
|
||||||
"conf/apiclient_cert.pem", "conf/apiclient_key.pem")
|
"conf/apiclient_cert.pem", "conf/apiclient_key.pem")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if globals.TLPayNotifyURL != "" {
|
||||||
|
TLpayAPI = tonglianpayapi.New(beego.AppConfig.String("tonglianPayAppID"), beego.AppConfig.String("tonglianPayKey"), beego.AppConfig.String("tonglianPayCusID"), beego.AppConfig.String("wxpayAppID"))
|
||||||
|
}
|
||||||
AutonaviAPI = autonavi.New(beego.AppConfig.String("autonaviKey"))
|
AutonaviAPI = autonavi.New(beego.AppConfig.String("autonaviKey"))
|
||||||
BaiDuNaviAPI = baidunavi.New(beego.AppConfig.String("baidunaviAK"), beego.AppConfig.String("baidunaviSK"))
|
BaiDuNaviAPI = baidunavi.New(beego.AppConfig.String("baidunaviAK"), beego.AppConfig.String("baidunaviSK"))
|
||||||
QiniuAPI = qbox.NewMac(beego.AppConfig.String("qiniuAK"), beego.AppConfig.String("qiniuSK"))
|
QiniuAPI = qbox.NewMac(beego.AppConfig.String("qiniuAK"), beego.AppConfig.String("qiniuSK"))
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ var (
|
|||||||
DisableWXAuth1 bool
|
DisableWXAuth1 bool
|
||||||
|
|
||||||
WxpayNotifyURL string
|
WxpayNotifyURL string
|
||||||
|
TLPayNotifyURL string
|
||||||
|
|
||||||
JdOrgCode string
|
JdOrgCode string
|
||||||
Jd2OrgCode string
|
Jd2OrgCode string
|
||||||
@@ -118,6 +119,7 @@ func Init() {
|
|||||||
DisableWXAuth1 = true
|
DisableWXAuth1 = true
|
||||||
|
|
||||||
WxpayNotifyURL = beego.AppConfig.DefaultString("wxpayNotifyURL", "")
|
WxpayNotifyURL = beego.AppConfig.DefaultString("wxpayNotifyURL", "")
|
||||||
|
TLPayNotifyURL = beego.AppConfig.DefaultString("tonglianPayNotifyURL", "")
|
||||||
JdOrgCode = beego.AppConfig.DefaultString("jdOrgCode", "")
|
JdOrgCode = beego.AppConfig.DefaultString("jdOrgCode", "")
|
||||||
Jd2OrgCode = beego.AppConfig.DefaultString("jd2OrgCode", "")
|
Jd2OrgCode = beego.AppConfig.DefaultString("jd2OrgCode", "")
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ func init() {
|
|||||||
beego.AutoRouter(&controllers.DingDingController{})
|
beego.AutoRouter(&controllers.DingDingController{})
|
||||||
beego.AutoRouter(&controllers.WXPayController{})
|
beego.AutoRouter(&controllers.WXPayController{})
|
||||||
beego.AutoRouter(&controllers.Djsw2Controller{})
|
beego.AutoRouter(&controllers.Djsw2Controller{})
|
||||||
|
beego.AutoRouter(&controllers.TongLianController{})
|
||||||
|
|
||||||
// 如下都是用于检测存活的空接口
|
// 如下都是用于检测存活的空接口
|
||||||
beego.Any("/", func(ctx *beecontext.Context) {
|
beego.Any("/", func(ctx *beecontext.Context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user