add wechat auth code

This commit is contained in:
lwl0608 2024-02-20 23:13:17 +08:00
parent 201e1f4c5c
commit 98ea808079
2 changed files with 20 additions and 13 deletions

View File

@ -139,6 +139,7 @@ type H5DirectUnlockWechatReq struct {
base.BaseRequest
Uid int64 `json:"uid"` // 主播id
PayType string `json:"pay_type"` // 支付类型
WechatAuthCode string `json:"wechat_auth_code"` // 微信auth_code
InviterMid int64
}

View File

@ -215,6 +215,11 @@ func (v *Vas) CreateOrder(ctx *gin.Context, req *vasproto.CreateOrderReq) (data
}
req.Oid3 = wxpayCli.AppId
case vasproto.PayTypeWxpayJsapi:
if len(req.WechatAuthCode) <= 0 {
err = errors.New("invalid WechatAuthCode")
return
}
wxpayCli := wxpaycli.GetDefaultWxpayClient()
var openid string
openid, err = wxpayCli.GetOpenIdByAuthCode(ctx, req.WechatAuthCode)
@ -1533,6 +1538,7 @@ func (v *Vas) H5DirectUnlockWechat(ctx *gin.Context, req *vasproto.H5DirectUnloc
PayType: req.PayType,
From: dbstruct.VasCoinOrderFromH5,
CustomCoins: uVas.GetH5WechatCoinPrice(),
WechatAuthCode: req.WechatAuthCode,
CalcPrice: uVas.GetH5WechatCoinPrice() * 10,
Uid: uid,
Oid1: fmt.Sprintf("%d", uid),