小程序一些功能更新

This commit is contained in:
李琦
2026-09-29 10:57:01 +08:00
parent 0cb70a7618
commit 3bb7fa8db3
96 changed files with 13890 additions and 213 deletions

93
api/admin/v1/promo.go Normal file
View File

@@ -0,0 +1,93 @@
package v1
import "github.com/gogf/gf/v2/frame/g"
// ============================================================================
// 管理端优惠码契约(A1–A5):list / save / toggle / delete / usages
// ============================================================================
// PromoItem 优惠码列表项(响应 snake_case)
type PromoItem struct {
Id int64 `json:"id"`
Code string `json:"code"`
ProductId string `json:"product_id"`
PriceCents int64 `json:"price_cents"`
Scope int `json:"scope"`
ScopeKeys []string `json:"scope_keys"`
MaxUses int `json:"max_uses"`
UsedCount int `json:"used_count"`
PerUserLimit int `json:"per_user_limit"`
ValidFrom string `json:"valid_from"`
ValidTo string `json:"valid_to"`
Status int `json:"status"`
Remark string `json:"remark"`
}
// PromoListReq 优惠码列表(A1)
type PromoListReq struct {
g.Meta `path:"/promo/list" method:"get" tags:"promo" summary:"优惠码列表"`
Keyword string `json:"keyword"`
Status *int `json:"status"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
}
type PromoListRes struct {
List []PromoItem `json:"list"`
Total int `json:"total"`
}
// PromoSaveReq 新增/编辑优惠码(A2)。编辑(id>0)时 code 不可改(跨端契约)。
type PromoSaveReq struct {
g.Meta `path:"/promo/save" method:"post" tags:"promo" summary:"保存优惠码"`
Id int64 `json:"id"`
Code string `v:"required#优惠码不能为空" json:"code"`
ProductId string `v:"required#支付道具不能为空" json:"productId"`
PriceCents int64 `v:"min:0#价格不能为负" json:"priceCents"`
Scope int `json:"scope"`
ScopeKeys []string `json:"scopeKeys"`
MaxUses int `v:"min:0#总上限不能为负" json:"maxUses"`
PerUserLimit int `v:"min:0#单人限用不能为负" json:"perUserLimit"`
ValidFrom string `json:"validFrom"`
ValidTo string `json:"validTo"`
Status int `json:"status"`
Remark string `json:"remark"`
}
type PromoSaveRes struct {
Id int64 `json:"id"`
}
// PromoToggleReq 启停优惠码(A3)
type PromoToggleReq struct {
g.Meta `path:"/promo/toggle" method:"post" tags:"promo" summary:"启停优惠码"`
Id int64 `v:"required" json:"id"`
Status int `json:"status"`
}
type PromoToggleRes struct{}
// PromoDeleteReq 删除优惠码(A4)
type PromoDeleteReq struct {
g.Meta `path:"/promo/delete" method:"post" tags:"promo" summary:"删除优惠码"`
Id int64 `v:"required" json:"id"`
}
type PromoDeleteRes struct{}
// PromoUsageItem 优惠码使用明细项(A5,响应 snake_case)
type PromoUsageItem struct {
At string `json:"at"`
User string `json:"user"`
OutTradeNo string `json:"out_trade_no"`
OriginPriceCents int64 `json:"origin_price_cents"`
PaidPriceCents int64 `json:"paid_price_cents"`
}
// PromoUsagesReq 优惠码使用明细(A5)
type PromoUsagesReq struct {
g.Meta `path:"/promo/usages" method:"get" tags:"promo" summary:"优惠码使用明细"`
PromoId int64 `json:"promoId"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
}
type PromoUsagesRes struct {
List []PromoUsageItem `json:"list"`
Total int `json:"total"`
}