fix: 允许已采集 PDD 商品重新采集 (#121)
This commit is contained in:
@@ -101,11 +101,17 @@ func (h *Handler) PddDetail(c *gin.Context) {
|
||||
fail(c, http.StatusNotFound, "这个商品不存在或已被删除,请刷新页面。")
|
||||
return
|
||||
}
|
||||
assignableClients, err := service.ListAssignableClients(h.db, currentUser(c), h.onlineThreshold)
|
||||
if err != nil {
|
||||
fail(c, http.StatusInternalServerError, "读取可选客户端失败,数据没有被改动。刷新页面重试。")
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "pdd/edit_modal", gin.H{
|
||||
"D": detail,
|
||||
"CSRFToken": csrfToken(c),
|
||||
"Keyword": c.Query("q"), "StatusFilter": c.Query("status"),
|
||||
"D": detail,
|
||||
"CSRFToken": csrfToken(c),
|
||||
"AssignableClients": assignableClients,
|
||||
"Keyword": c.Query("q"), "StatusFilter": c.Query("status"),
|
||||
"CurrentPage": service.ParsePage(c.Query("page")),
|
||||
})
|
||||
}
|
||||
@@ -233,6 +239,24 @@ func (h *Handler) PddCollect(c *gin.Context) {
|
||||
h.pddRedirect(c, service.FormatCollectTaskMessage(result))
|
||||
}
|
||||
|
||||
// PddRecollect 处理商品详情里操作员明确点击的“重新采集”。
|
||||
// 它与批量创建任务分开,避免普通批量入口意外重采所有已完成商品。
|
||||
func (h *Handler) PddRecollect(c *gin.Context) {
|
||||
result, err := service.RecollectPddProductForUser(
|
||||
h.db, currentUser(c), c.PostForm("goods_id"), c.PostForm("client_id"))
|
||||
if err != nil {
|
||||
status := http.StatusInternalServerError
|
||||
message := "创建重新采集任务失败,商品和任务均未改动。请稍后重试。"
|
||||
if service.IsValidationError(err) {
|
||||
status = http.StatusBadRequest
|
||||
message = err.Error() + "。没有创建任务。"
|
||||
}
|
||||
fail(c, status, message)
|
||||
return
|
||||
}
|
||||
h.pddRedirect(c, service.FormatCollectTaskMessage(result))
|
||||
}
|
||||
|
||||
// PddDelete 批量软删除。
|
||||
func (h *Handler) PddDelete(c *gin.Context) {
|
||||
ids := c.PostFormArray("ids")
|
||||
|
||||
@@ -68,6 +68,7 @@ func Register(r *gin.Engine, db *sql.DB, onlineThreshold time.Duration) {
|
||||
pages.POST("/pdd/import", h.PddImport)
|
||||
pages.POST("/pdd/save", h.PddSave)
|
||||
pages.POST("/pdd/collect", h.PddCollect)
|
||||
pages.POST("/pdd/recollect", h.PddRecollect)
|
||||
pages.POST("/pdd/delete", h.PddDelete)
|
||||
|
||||
// 3. 顺运宝数据
|
||||
|
||||
Reference in New Issue
Block a user