Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
F-1: 佣金链断裂时创建 status=99 零额待审记录,新增修正接口 POST /commission-records/:id/resolve F-4: C端订单查询从 Handler 迁移至 Service 层,移除 SkipPermissionCtx J-1: 富友支付 JSAPI/MiniApp 预下单实现,回调补全签名验证 J-2: 平台钱包代购支持(buyerType 为空时使用资产所属代理钱包) J-3: 套餐激活后自动更新卡/设备 status=3,最后套餐过期后更新 status=4 支付抽象: 引入 PaymentProvider 接口 + 微信/富友适配器,CreateOrder 支持多支付渠道 修复: 设备/IoT卡响应 DTO 移除 omitempty,空值字段返回 null 而非省略
93 lines
2.8 KiB
Go
93 lines
2.8 KiB
Go
package admin
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
|
shopCommissionService "github.com/break/junhong_cmp_fiber/internal/service/shop_commission"
|
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
|
)
|
|
|
|
type ShopCommissionHandler struct {
|
|
service *shopCommissionService.Service
|
|
}
|
|
|
|
func NewShopCommissionHandler(service *shopCommissionService.Service) *ShopCommissionHandler {
|
|
return &ShopCommissionHandler{service: service}
|
|
}
|
|
|
|
func (h *ShopCommissionHandler) ListCommissionSummary(c *fiber.Ctx) error {
|
|
var req dto.ShopCommissionSummaryListReq
|
|
if err := c.QueryParser(&req); err != nil {
|
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
|
}
|
|
|
|
result, err := h.service.ListShopCommissionSummary(c.UserContext(), &req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return response.SuccessWithPagination(c, result.Items, result.Total, result.Page, result.Size)
|
|
}
|
|
|
|
func (h *ShopCommissionHandler) ListWithdrawalRequests(c *fiber.Ctx) error {
|
|
shopID, err := strconv.ParseUint(c.Params("shop_id"), 10, 64)
|
|
if err != nil {
|
|
return errors.New(errors.CodeInvalidParam, "无效的店铺 ID")
|
|
}
|
|
|
|
var req dto.ShopWithdrawalRequestListReq
|
|
if err := c.QueryParser(&req); err != nil {
|
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
|
}
|
|
|
|
result, err := h.service.ListShopWithdrawalRequests(c.UserContext(), uint(shopID), &req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return response.SuccessWithPagination(c, result.Items, result.Total, result.Page, result.Size)
|
|
}
|
|
|
|
func (h *ShopCommissionHandler) ListCommissionRecords(c *fiber.Ctx) error {
|
|
shopID, err := strconv.ParseUint(c.Params("shop_id"), 10, 64)
|
|
if err != nil {
|
|
return errors.New(errors.CodeInvalidParam, "无效的店铺 ID")
|
|
}
|
|
|
|
var req dto.ShopCommissionRecordListReq
|
|
if err := c.QueryParser(&req); err != nil {
|
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
|
}
|
|
|
|
result, err := h.service.ListShopCommissionRecords(c.UserContext(), uint(shopID), &req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return response.SuccessWithPagination(c, result.Items, result.Total, result.Page, result.Size)
|
|
}
|
|
|
|
// ResolveCommissionRecord 修正待审佣金记录
|
|
// POST /api/admin/commission-records/:id/resolve
|
|
func (h *ShopCommissionHandler) ResolveCommissionRecord(c *fiber.Ctx) error {
|
|
recordID, err := strconv.ParseUint(c.Params("id"), 10, 64)
|
|
if err != nil || recordID == 0 {
|
|
return errors.New(errors.CodeInvalidParam, "无效的佣金记录ID")
|
|
}
|
|
|
|
var req dto.CommissionRecordResolveRequest
|
|
if err := c.BodyParser(&req); err != nil {
|
|
return errors.New(errors.CodeInvalidParam)
|
|
}
|
|
|
|
if err := h.service.ResolveCommissionRecord(c.UserContext(), uint(recordID), &req); err != nil {
|
|
return err
|
|
}
|
|
|
|
return response.Success(c, nil)
|
|
}
|