feat: support refund

This commit is contained in:
Rogee
2025-05-06 21:16:23 +08:00
parent 533c9b70af
commit 811ed3a41f
6 changed files with 101 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
package admin
import (
"fmt"
"quyun/app/models"
"quyun/app/requests"
"quyun/database/fields"
@@ -30,7 +32,7 @@ func (ctl *orders) List(ctx fiber.Ctx, pagination *requests.Pagination, query *O
}
// Refund
// @Router /admin/orders/{id}/refund [post]
// @Router /admin/orders/:id/refund [post]
// @Bind id path
func (ctl *orders) Refund(ctx fiber.Ctx, id int64) error {
order, err := models.Orders.GetByID(ctx.Context(), id)
@@ -51,7 +53,15 @@ func (ctl *orders) Refund(ctx fiber.Ctx, id int64) error {
TransactionID(order.TransactionID).
CNYRefundAmount(refundTotal, refundTotal).
RefundReason("管理员退款").
RefundGoodsInfo(post.Title)
RefundGoods([]wepay.RefundGoodsInfo{
{
MerchantGoodsID: fmt.Sprintf("%d", order.PostID),
GoodsName: post.Title,
RefundQuantity: 1,
RefundAmount: refundTotal,
UnitPrice: order.Price,
},
})
})
if err != nil {
return err