feat: update issues
This commit is contained in:
@@ -50,7 +50,7 @@ func (ctl *posts) Mine(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
|
||||
// Buy
|
||||
// @Router /buy/:id [get]
|
||||
// @Bind id path
|
||||
func (ctl *posts) Buy(ctx fiber.Ctx, id int64) (*string, error) {
|
||||
func (ctl *posts) Buy(ctx fiber.Ctx, id int64) (*wepay.PrepayData, error) {
|
||||
var userId int64 = 1
|
||||
|
||||
user, err := models.Users.GetByID(ctx.Context(), userId)
|
||||
@@ -69,17 +69,16 @@ func (ctl *posts) Buy(ctx fiber.Ctx, id int64) (*string, error) {
|
||||
return nil, errors.Wrap(err, "订单创建失败")
|
||||
}
|
||||
|
||||
body := ctl.wepay.
|
||||
BodyMap().
|
||||
Expire(30 * time.Minute).
|
||||
Description(post.Title).
|
||||
OutTradeNo(order.OrderNo).
|
||||
Payer(user.OpenID)
|
||||
|
||||
prePayResp, err := ctl.wepay.V3TransactionJsapi(ctx.Context(), body)
|
||||
prePayResp, err := ctl.wepay.V3TransactionJsapi(ctx.Context(), func(bm *wepay.BodyMap) {
|
||||
bm.
|
||||
Expire(30 * time.Minute).
|
||||
Description(post.Title).
|
||||
OutTradeNo(order.OrderNo).
|
||||
Payer(user.OpenID)
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("wepay.V3TransactionJsapi err: %v", err)
|
||||
return nil, errors.Wrap(err, "微信支付失败")
|
||||
}
|
||||
return &prePayResp.Response.PrepayId, nil
|
||||
return prePayResp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user