wxpay
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user