wxpay
This commit is contained in:
@@ -481,7 +481,7 @@ func CheckWeixinminiAuthBind(userID string) (err error) {
|
|||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
authBinds, err := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "", "")
|
authBinds, err := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{"weixinmini", "weixinapp"}, "", "", "")
|
||||||
if len(authBinds) == 0 {
|
if len(authBinds) == 0 {
|
||||||
return fmt.Errorf("请绑定微信认证方式!")
|
return fmt.Errorf("请绑定微信认证方式!")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -88,9 +88,6 @@ func (a *MiniAuther) GetUserType() (userType int8) {
|
|||||||
|
|
||||||
func getWxApp(appID string) (miniApi *weixinapi.API) {
|
func getWxApp(appID string) (miniApi *weixinapi.API) {
|
||||||
miniApi = api.WeixinMiniAPI
|
miniApi = api.WeixinMiniAPI
|
||||||
if len(appID) > 0 && appID == api.WeixinMiniAppID2 {
|
|
||||||
miniApi = api.WeixinMiniAPI2
|
|
||||||
}
|
|
||||||
return miniApi
|
return miniApi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateOrder(ctx *jxcontext.Context, orderType, price int, lng, lat float64) (orderID string, err error) {
|
func CreateOrder(ctx *jxcontext.Context, orderType int, way string, price int, lng, lat float64) (orderID string, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
order *model.Order
|
order *model.Order
|
||||||
@@ -33,6 +33,7 @@ func CreateOrder(ctx *jxcontext.Context, orderType, price int, lng, lat float64)
|
|||||||
OrderID: utils.Int64ToStr(jxutils.GenOrderNo()),
|
OrderID: utils.Int64ToStr(jxutils.GenOrderNo()),
|
||||||
UserID: ctx.GetUserID(),
|
UserID: ctx.GetUserID(),
|
||||||
Type: orderType,
|
Type: orderType,
|
||||||
|
Way: way,
|
||||||
Status: model.OrderStatusWait4Pay,
|
Status: model.OrderStatusWait4Pay,
|
||||||
PayPrice: price,
|
PayPrice: price,
|
||||||
Lng: lng,
|
Lng: lng,
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ const (
|
|||||||
sigTypeSha256 = "HMAC-SHA256"
|
sigTypeSha256 = "HMAC-SHA256"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
payMap = map[string]*wxpayapi.API{
|
||||||
|
"weixinapp": api.WxpayAPI,
|
||||||
|
"weixinmini": api.WxpayAPI2,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func (p *PayHandler) CreatePay() (err error) {
|
func (p *PayHandler) CreatePay() (err error) {
|
||||||
switch p.PayType {
|
switch p.PayType {
|
||||||
case model.PayTypeTL:
|
case model.PayTypeTL:
|
||||||
@@ -59,7 +66,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
|||||||
TimeStart: wxpayapi.Time2PayTime(time.Now()),
|
TimeStart: wxpayapi.Time2PayTime(time.Now()),
|
||||||
// ProfitSharing: wxpayapi.OptYes,
|
// ProfitSharing: wxpayapi.OptYes,
|
||||||
}
|
}
|
||||||
authBinds, err := dao.GetUserBindAuthInfo(dao.GetDB(), p.Ctx.GetUserID(), model.AuthBindTypeAuth, []string{"weixinmini"}, "", "", "")
|
authBinds, err := dao.GetUserBindAuthInfo(dao.GetDB(), p.Ctx.GetUserID(), model.AuthBindTypeAuth, []string{p.Order.Way}, "", "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -67,7 +74,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
|||||||
return fmt.Errorf("未绑定微信认证方式!")
|
return fmt.Errorf("未绑定微信认证方式!")
|
||||||
}
|
}
|
||||||
param.OpenID = authBinds[0].AuthID
|
param.OpenID = authBinds[0].AuthID
|
||||||
result, err2 := api.WxpayAPI.CreateUnifiedOrder(param)
|
result, err2 := payMap[p.Order.Way].CreateUnifiedOrder(param)
|
||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
param2 := make(map[string]interface{})
|
param2 := make(map[string]interface{})
|
||||||
param2["prepayid"] = result.PrepayID
|
param2["prepayid"] = result.PrepayID
|
||||||
@@ -151,7 +158,7 @@ func (p *PayHandler) CreateRefund() (err error) {
|
|||||||
// param.OpenID = authInfo.GetAuthID()
|
// param.OpenID = authInfo.GetAuthID()
|
||||||
// }
|
// }
|
||||||
// globals.SugarLogger.Debugf("CreateRefund wx param: %v", utils.Format4Output(param, false))
|
// globals.SugarLogger.Debugf("CreateRefund wx param: %v", utils.Format4Output(param, false))
|
||||||
// result, err2 := api.WxpayAPI.Transfers(param)
|
// result, err2 := payMap[p.Order.Way].Transfers(param)
|
||||||
// if err2 == nil {
|
// if err2 == nil {
|
||||||
// p.Order.PayFinishedAt = utils.Str2Time(result.PaymentTime)
|
// p.Order.PayFinishedAt = utils.Str2Time(result.PaymentTime)
|
||||||
// p.Order.Comment = result.DeviceInfo
|
// p.Order.Comment = result.DeviceInfo
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ type Order struct {
|
|||||||
OrderID string `orm:"column(order_id)" json:"orderID"` //订单号
|
OrderID string `orm:"column(order_id)" json:"orderID"` //订单号
|
||||||
UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID
|
UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID
|
||||||
Type int `json:"type"` //订单类型
|
Type int `json:"type"` //订单类型
|
||||||
|
Way string `json:"way"` //weixinapp ,weixinmini
|
||||||
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
||||||
PayPrice int `json:"payPrice"` //支付金额
|
PayPrice int `json:"payPrice"` //支付金额
|
||||||
TransactionID string `orm:"column(transaction_id);size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
TransactionID string `orm:"column(transaction_id);size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
||||||
|
|||||||
@@ -59,14 +59,6 @@ weixinMsgKey = "duyaeVYUsz8LuKBqJeQO1NX6KmoC43yfMsbJybcRJ3e"
|
|||||||
weixinPageAppID = "wx018dbe7daa3d5627"
|
weixinPageAppID = "wx018dbe7daa3d5627"
|
||||||
weixinPageSecret = "c7a84ed3ef3ae04ac78e02fb593ffbe5"
|
weixinPageSecret = "c7a84ed3ef3ae04ac78e02fb593ffbe5"
|
||||||
|
|
||||||
weixinMiniAppID = "wxa4a76d7b4c88604e"
|
|
||||||
weixinMiniSecret = "dc0fd8dc3042f383347e0502b73ab1d2"
|
|
||||||
|
|
||||||
wxpayAppID = "wx70d0943e61e0d15c"
|
|
||||||
wxpayAppKey = "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD"
|
|
||||||
wxpayAppMchID = "1603491062"
|
|
||||||
wxpayNotifyURL = "http://callback.rsm.jxc4.com/wxpay/msg/"
|
|
||||||
|
|
||||||
tonglianPayAppID = "00183083"
|
tonglianPayAppID = "00183083"
|
||||||
tonglianPayKey = "18048531223"
|
tonglianPayKey = "18048531223"
|
||||||
tonglianPayCusID = "56065105499TVAH"
|
tonglianPayCusID = "56065105499TVAH"
|
||||||
@@ -246,19 +238,18 @@ ebaiSecret = "c3db75b754ea2d89"
|
|||||||
mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605"
|
mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605"
|
||||||
mtpsSecret = "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE"
|
mtpsSecret = "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE"
|
||||||
|
|
||||||
weixinAppID = "wx2bb99eb5d2c9b82c"
|
weixinAppID = "wx70d0943e61e0d15c"
|
||||||
weixinSecret = "6bbbed1443cc062c20a015a64c07a531"
|
weixinAppSecret = "c2908eeab509314936c4f535dc03e6de"
|
||||||
weixinMiniAppID2 = "wx4b5930c13f8b1170"
|
weixinMiniAppID = "wxa4a76d7b4c88604e"
|
||||||
weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d"
|
weixinMiniSecret = "dc0fd8dc3042f383347e0502b73ab1d2"
|
||||||
weixinMiniAppID3 = "wx70d0943e61e0d15c"
|
|
||||||
weixinMiniSecret3 = "c2908eeab509314936c4f535dc03e6de"
|
|
||||||
|
|
||||||
yinbaoAppKey = "682628966212343269"
|
yinbaoAppKey = "682628966212343269"
|
||||||
yinbaoAppID = "18C0E0867E467DBC26EFF5E957B02EC4"
|
yinbaoAppID = "18C0E0867E467DBC26EFF5E957B02EC4"
|
||||||
|
|
||||||
aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54"
|
aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54"
|
||||||
|
|
||||||
wxpayAppID = "wx70d0943e61e0d15c"
|
wxpayAppID1 = "wx70d0943e61e0d15c"
|
||||||
|
wxpayAppID2 = "wxa4a76d7b4c88604e"
|
||||||
wxpayAppKey = "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD"
|
wxpayAppKey = "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD"
|
||||||
wxpayAppMchID = "1603491062"
|
wxpayAppMchID = "1603491062"
|
||||||
wxpayNotifyURL = "http://callback.rsm.jxc4.com/wxpay/msg/"
|
wxpayNotifyURL = "http://callback.rsm.jxc4.com/wxpay/msg/"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
@@ -45,28 +44,6 @@ type Message struct {
|
|||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title 得到微信小程序码
|
|
||||||
// @Description 得到微信小程序码
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param scene formData string true "最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)"
|
|
||||||
// @Param page formData string false "必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /GetWeixinUnlimited [post]
|
|
||||||
func (c *EventController) GetWeixinUnlimited() {
|
|
||||||
c.callGetWeixinUnlimited(func(params *tEventGetWeixinUnlimitedParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
// api.WeixinMiniAPI2.CBRetrieveToken()
|
|
||||||
result, err := api.WeixinMiniAPI2.GetUnlimited(params.Scene, params.Page)
|
|
||||||
if err != nil || result == nil {
|
|
||||||
return retVal, "", err
|
|
||||||
}
|
|
||||||
fileName := "wxcode" + utils.Int64ToStr(time.Now().Unix()) + ".jpg"
|
|
||||||
retVal, err = jxutils.UploadExportContent([]byte(result["fakeData"].(string)), fileName)
|
|
||||||
// tasks.RefreshWeixinToken()
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 测试websocket
|
// @Title 测试websocket
|
||||||
// @Description 测试websocket
|
// @Description 测试websocket
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (c *OrderController) Cash() {
|
|||||||
// @Description 创建订单
|
// @Description 创建订单
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param type formData int true "支付类型/账单类型"
|
// @Param type formData int true "支付类型/账单类型"
|
||||||
|
// @Param way formData string true "认证方式"
|
||||||
// @Param price formData int true "支付金额"
|
// @Param price formData int true "支付金额"
|
||||||
// @Param lng formData float64 true "经纬度"
|
// @Param lng formData float64 true "经纬度"
|
||||||
// @Param lat formData float64 true "经纬度"
|
// @Param lat formData float64 true "经纬度"
|
||||||
@@ -54,7 +55,7 @@ func (c *OrderController) Cash() {
|
|||||||
// @router /CreateOrder [post]
|
// @router /CreateOrder [post]
|
||||||
func (c *OrderController) CreateOrder() {
|
func (c *OrderController) CreateOrder() {
|
||||||
c.callCreateOrder(func(params *tOrderCreateOrderParams) (retVal interface{}, errCode string, err error) {
|
c.callCreateOrder(func(params *tOrderCreateOrderParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = cms.CreateOrder(params.Ctx, params.Type, params.Price, params.Lng, params.Lat)
|
retVal, err = cms.CreateOrder(params.Ctx, params.Type, params.Way, params.Price, params.Lng, params.Lat)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,18 +60,17 @@ var (
|
|||||||
EbaiAPI *ebaiapi.API
|
EbaiAPI *ebaiapi.API
|
||||||
Ebai2API *ebaiapi.API
|
Ebai2API *ebaiapi.API
|
||||||
|
|
||||||
MtwmAPI *mtwmapi.API
|
MtwmAPI *mtwmapi.API
|
||||||
MtpsAPI *mtpsapi.API
|
MtpsAPI *mtpsapi.API
|
||||||
DadaAPI *dadaapi.API
|
DadaAPI *dadaapi.API
|
||||||
WeixinAPI *weixinapi.API // 微信公众号
|
WeixinAPI *weixinapi.API // 微信公众号
|
||||||
WeixinMiniAPI *weixinapi.API // 小程序
|
WeixinMiniAPI *weixinapi.API // 小程序
|
||||||
WeixinMiniAPI2 *weixinapi.API // 小程序2
|
WeixinApp *weixinapi.API // app微信登录
|
||||||
WeixinApp *weixinapi.API // app微信登录
|
WxpayAPI *wxpayapi.API // 微信支付AppAPI
|
||||||
WeixinMiniAppID2 string
|
WxpayAPI2 *wxpayapi.API // 微信支付小程序API
|
||||||
WeixinMiniAppID3 string
|
|
||||||
WxpayAPI *wxpayapi.API // 微信支付API
|
TLpayAPI *tonglianpayapi.API //通联收银宝api
|
||||||
TLpayAPI *tonglianpayapi.API //通联收银宝api
|
MtMemberAPI *mtmemberapi.API
|
||||||
MtMemberAPI *mtmemberapi.API
|
|
||||||
|
|
||||||
YinBaoAPI *yinbaoapi.API //银豹平台api
|
YinBaoAPI *yinbaoapi.API //银豹平台api
|
||||||
|
|
||||||
@@ -221,21 +220,14 @@ func Init() {
|
|||||||
WeimobAPI = nil
|
WeimobAPI = nil
|
||||||
}
|
}
|
||||||
WeixinMiniAPI = weixinapi.New(beego.AppConfig.String("weixinMiniAppID"), beego.AppConfig.String("weixinMiniSecret"))
|
WeixinMiniAPI = weixinapi.New(beego.AppConfig.String("weixinMiniAppID"), beego.AppConfig.String("weixinMiniSecret"))
|
||||||
if WeixinMiniAppID2 = beego.AppConfig.String("weixinMiniAppID2"); WeixinMiniAppID2 != "" {
|
WeixinApp = weixinapi.New(beego.AppConfig.String("weixinAppID"), beego.AppConfig.String("weixinAppSecret"))
|
||||||
WeixinMiniAPI2 = weixinapi.New(WeixinMiniAppID2, beego.AppConfig.String("weixinMiniSecret2"))
|
|
||||||
}
|
|
||||||
WeixinPageAPI = weixinapi.New(beego.AppConfig.String("weixinPageAppID"), beego.AppConfig.String("weixinPageSecret"))
|
|
||||||
if WeixinMiniAppID3 = beego.AppConfig.String("weixinMiniAppID3"); WeixinMiniAppID3 != "" {
|
|
||||||
WeixinApp = weixinapi.New(WeixinMiniAppID3, beego.AppConfig.String("weixinMiniSecret3"))
|
|
||||||
}
|
|
||||||
// if globals.WxpayNotifyURL != "" {
|
|
||||||
// WxpayAPI = wxpayapi.New(beego.AppConfig.String("wxpayAppID"), beego.AppConfig.String("wxpayAppKey"), beego.AppConfig.String("wxpayAppMchID"))
|
|
||||||
certPEMBlock, _ := ioutil.ReadFile("conf/apiclient_cert.pem")
|
certPEMBlock, _ := ioutil.ReadFile("conf/apiclient_cert.pem")
|
||||||
keyPEMBlock, _ := ioutil.ReadFile("conf/apiclient_key.pem")
|
keyPEMBlock, _ := ioutil.ReadFile("conf/apiclient_key.pem")
|
||||||
// rootCa, _ := ioutil.ReadFile("conf/cacert.pem")
|
WxpayAPI = wxpayapi.NewWithCertificate(beego.AppConfig.String("wxpayAppID1"), beego.AppConfig.String("wxpayAppKey"), beego.AppConfig.String("wxpayAppMchID"),
|
||||||
WxpayAPI = wxpayapi.NewWithCertificate(beego.AppConfig.String("wxpayAppID"), beego.AppConfig.String("wxpayAppKey"), beego.AppConfig.String("wxpayAppMchID"),
|
certPEMBlock, keyPEMBlock)
|
||||||
|
WxpayAPI2 = wxpayapi.NewWithCertificate(beego.AppConfig.String("wxpayAppID2"), beego.AppConfig.String("wxpayAppKey"), beego.AppConfig.String("wxpayAppMchID"),
|
||||||
certPEMBlock, keyPEMBlock)
|
certPEMBlock, keyPEMBlock)
|
||||||
// }
|
|
||||||
|
|
||||||
if globals.TLPayNotifyURL != "" {
|
if globals.TLPayNotifyURL != "" {
|
||||||
TLpayAPI = tonglianpayapi.New(beego.AppConfig.String("tonglianPayAppID"), beego.AppConfig.String("tonglianPayKey"), beego.AppConfig.String("tonglianPayCusID"), beego.AppConfig.String("wxpayAppID"))
|
TLpayAPI = tonglianpayapi.New(beego.AppConfig.String("tonglianPayAppID"), beego.AppConfig.String("tonglianPayKey"), beego.AppConfig.String("tonglianPayCusID"), beego.AppConfig.String("wxpayAppID"))
|
||||||
|
|||||||
Reference in New Issue
Block a user