feat(merchant-products): 开放商品编辑功能,支持超级管理员与商户修改售价积分、成本价与库存模式
1. 后端 Handler 新增 UpdateProduct 方法,并在 /api/merchant/products/:id 注册 PATCH 路由,支持修改商品显示名称、对外售价积分、成本价与库存; 2. 前端商户中心 merchantApi 扩充 updateProduct 接口对接; 3. 商品列表(ProductsTab)操作列新增【编辑】按钮与模态框,提供商品名称、对外售价(积分)、成本价(积分)、无限库存/指定限量模式及上架状态编辑功能; 4. 修复超级管理员在自营或商户商品列表中无法自由调价与调整库存的交互缺失问题。
This commit is contained in:
@@ -77,6 +77,32 @@ type merchantProductStatusReq struct {
|
||||
|
||||
// UpdateProductStatus PATCH /api/merchant/products/:id/status
|
||||
// 商户仅能上架/下架商品,价格、成本等配置由平台管理员维护。
|
||||
// UpdateProduct PATCH /api/merchant/products/:id — 编辑商品(显示名称、售价、成本、库存、状态)。
|
||||
func (h *MerchantHandler) UpdateProduct(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
if id == 0 {
|
||||
response.BadRequest(c, "参数错误")
|
||||
return
|
||||
}
|
||||
var req merchantProductUpdateReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.BadRequest(c, "参数错误")
|
||||
return
|
||||
}
|
||||
if err := h.merchantSvc.UpdateMerchantProduct(middleware.GetMerchantID(c), uint(id), service.UpdateMerchantProductInput{
|
||||
DisplayName: req.DisplayName,
|
||||
PriceAmount: req.PriceAmount,
|
||||
CostAmount: req.CostAmount,
|
||||
Stock: req.Stock,
|
||||
Status: req.Status,
|
||||
FulfillmentConfig: req.FulfillmentConfig,
|
||||
}, middleware.GetUserID(c)); err != nil {
|
||||
response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
response.OK(c, nil)
|
||||
}
|
||||
|
||||
func (h *MerchantHandler) UpdateProductStatus(c *gin.Context) {
|
||||
var req merchantProductStatusReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user