feat: 支持人工修改蝦皮规格 (#215)

This commit is contained in:
chengma
2026-08-13 12:14:02 +08:00
parent 5b7d92289e
commit 4752fef54f
16 changed files with 403 additions and 34 deletions
+21
View File
@@ -6,6 +6,7 @@ import (
"net/url"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
@@ -119,6 +120,7 @@ func (h *Handler) renderShopeeList(c *gin.Context, keyword, searchFieldRaw, stat
"Pagination": service.NewPaginationView(result.Page, result.TotalPages, values.Encode()),
"CurrentPage": result.Page,
"DetailURL": "/shopee/detail?" + detailValuesForShopee(values, result.Page),
"AutoOpenDetailID": strings.TrimSpace(c.Query("open_id")),
"AssignableClients": assignableClients,
}))
}
@@ -158,6 +160,22 @@ func (h *Handler) ShopeeSave(c *gin.Context) {
h.shopeeRedirect(c, fmt.Sprintf("已关联 PDD 商品 %s,可继续创建采集任务", goodsID))
}
// ShopeeSpecSave 保存一条现有蝦皮 SKU 的人工颜色、尺码和建议说明。
func (h *Handler) ShopeeSpecSave(c *gin.Context) {
err := service.UpdateShopeeSKUManual(h.db, currentUser(c), c.PostForm("shopee_goods_id"),
c.PostForm("sku_record_id"), c.PostForm("color"), c.PostForm("size"),
c.PostForm("advice"), time.Now())
if err != nil {
if service.IsValidationError(err) {
h.shopeeRedirect(c, "规格未保存:"+err.Error())
return
}
fail(c, http.StatusInternalServerError, "保存蝦皮规格失败,数据没有被改动。请刷新页面后重试。")
return
}
h.shopeeRedirect(c, "蝦皮规格已保存,人工字段不会被后续导入覆盖")
}
// ShopeeDelete 批量删除勾选的行。
func (h *Handler) ShopeeDelete(c *gin.Context) {
count, err := service.DeleteShopeeProducts(h.db, currentUser(c), c.PostFormArray("ids"))
@@ -246,6 +264,9 @@ func (h *Handler) shopeeRedirect(c *gin.Context, msg string) {
if value := strings.TrimSpace(c.PostForm("page")); value != "" {
params.Set("page", value)
}
if value := strings.TrimSpace(c.PostForm("open_id")); value != "" {
params.Set("open_id", value)
}
if msg != "" {
params.Set("msg", msg)
}
+1
View File
@@ -57,6 +57,7 @@ func Register(r *gin.Engine, db *sql.DB, onlineThreshold time.Duration) {
pages.GET("/shopee", h.ShopeeList)
pages.GET("/shopee/detail", h.ShopeeDetail) // 双击行时前端来取弹窗内容
pages.POST("/shopee/save", h.ShopeeSave)
pages.POST("/shopee/spec/save", h.ShopeeSpecSave)
pages.POST("/shopee/collect", h.ShopeeCollect)
pages.POST("/shopee/collect-batch", h.ShopeeCollectBatch)
shopeeAdmin := pages.Group("/shopee", AdminRequired())