feat: support refund
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -63,6 +63,11 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
Query[OrderListQuery]("query"),
|
||||
))
|
||||
|
||||
router.Post("/admin/orders/:id/refund", Func1(
|
||||
r.orders.Refund,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
|
||||
// 注册路由组: posts
|
||||
router.Get("/admin/posts", DataFunc2(
|
||||
r.posts.List,
|
||||
|
||||
Reference in New Issue
Block a user