wxpay
This commit is contained in:
@@ -481,7 +481,7 @@ func CheckWeixinminiAuthBind(userID string) (err error) {
|
||||
var (
|
||||
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 {
|
||||
return fmt.Errorf("请绑定微信认证方式!")
|
||||
} else {
|
||||
|
||||
@@ -88,9 +88,6 @@ func (a *MiniAuther) GetUserType() (userType int8) {
|
||||
|
||||
func getWxApp(appID string) (miniApi *weixinapi.API) {
|
||||
miniApi = api.WeixinMiniAPI
|
||||
if len(appID) > 0 && appID == api.WeixinMiniAppID2 {
|
||||
miniApi = api.WeixinMiniAPI2
|
||||
}
|
||||
return miniApi
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"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 (
|
||||
db = dao.GetDB()
|
||||
order *model.Order
|
||||
@@ -33,6 +33,7 @@ func CreateOrder(ctx *jxcontext.Context, orderType, price int, lng, lat float64)
|
||||
OrderID: utils.Int64ToStr(jxutils.GenOrderNo()),
|
||||
UserID: ctx.GetUserID(),
|
||||
Type: orderType,
|
||||
Way: way,
|
||||
Status: model.OrderStatusWait4Pay,
|
||||
PayPrice: price,
|
||||
Lng: lng,
|
||||
|
||||
@@ -26,6 +26,13 @@ const (
|
||||
sigTypeSha256 = "HMAC-SHA256"
|
||||
)
|
||||
|
||||
var (
|
||||
payMap = map[string]*wxpayapi.API{
|
||||
"weixinapp": api.WxpayAPI,
|
||||
"weixinmini": api.WxpayAPI2,
|
||||
}
|
||||
)
|
||||
|
||||
func (p *PayHandler) CreatePay() (err error) {
|
||||
switch p.PayType {
|
||||
case model.PayTypeTL:
|
||||
@@ -59,7 +66,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
||||
TimeStart: wxpayapi.Time2PayTime(time.Now()),
|
||||
// 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 {
|
||||
return err
|
||||
}
|
||||
@@ -67,7 +74,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
||||
return fmt.Errorf("未绑定微信认证方式!")
|
||||
}
|
||||
param.OpenID = authBinds[0].AuthID
|
||||
result, err2 := api.WxpayAPI.CreateUnifiedOrder(param)
|
||||
result, err2 := payMap[p.Order.Way].CreateUnifiedOrder(param)
|
||||
if err2 == nil {
|
||||
param2 := make(map[string]interface{})
|
||||
param2["prepayid"] = result.PrepayID
|
||||
@@ -151,7 +158,7 @@ func (p *PayHandler) CreateRefund() (err error) {
|
||||
// param.OpenID = authInfo.GetAuthID()
|
||||
// }
|
||||
// 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 {
|
||||
// p.Order.PayFinishedAt = utils.Str2Time(result.PaymentTime)
|
||||
// p.Order.Comment = result.DeviceInfo
|
||||
|
||||
@@ -53,6 +53,7 @@ type Order struct {
|
||||
OrderID string `orm:"column(order_id)" json:"orderID"` //订单号
|
||||
UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID
|
||||
Type int `json:"type"` //订单类型
|
||||
Way string `json:"way"` //weixinapp ,weixinmini
|
||||
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
||||
PayPrice int `json:"payPrice"` //支付金额
|
||||
TransactionID string `orm:"column(transaction_id);size(48)" json:"transactionID"` // 支付成功后,支付方生成的事务ID
|
||||
|
||||
Reference in New Issue
Block a user