feat: support refund
This commit is contained in:
@@ -2,6 +2,7 @@ package http
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -272,13 +273,22 @@ func (ctl *posts) Buy(ctx fiber.Ctx, id int64, user *model.Users) (*wechat.JSAPI
|
||||
return nil, errors.Wrap(err, "订单创建失败")
|
||||
}
|
||||
|
||||
payPrice := post.Price * int64(post.Discount) / 100
|
||||
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).
|
||||
CNYAmount(post.Price * int64(post.Discount) / 100)
|
||||
CNYAmount(payPrice).
|
||||
Detail([]wepay.GoodsInfo{
|
||||
{
|
||||
GoodsName: post.Title,
|
||||
UnitPrice: payPrice,
|
||||
MerchantGoodsID: fmt.Sprintf("%d", post.ID),
|
||||
Quantity: 1,
|
||||
},
|
||||
})
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("wepay.V3TransactionJsapi err: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user