feat: 增加顺运宝批量 AI 规格匹配 (#202)
This commit is contained in:
@@ -179,6 +179,46 @@ func (h *Handler) renderSybListWithLoginReason(c *gin.Context, keyword, pageRaw,
|
||||
rangeWarning = defaults.Warning
|
||||
}
|
||||
|
||||
actor := currentUser(c)
|
||||
aiBatchID := strings.TrimSpace(c.Query("ai_batch_id"))
|
||||
var aiBatch *service.AIMatchBatchView
|
||||
if aiBatchID != "" {
|
||||
aiBatch, err = service.GetAIMatchBatchView(h.db, actor, aiBatchID)
|
||||
if errors.Is(err, service.ErrForbidden) {
|
||||
fail(c, http.StatusForbidden, "没有权限查看这个 AI 匹配批次。")
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
fail(c, http.StatusInternalServerError, "读取 AI 匹配批次失败,请刷新页面后重试。")
|
||||
return
|
||||
}
|
||||
if aiBatch == nil {
|
||||
fail(c, http.StatusNotFound, "AI 匹配批次不存在,可能已被清理。")
|
||||
return
|
||||
}
|
||||
}
|
||||
latestAIBatchID, err := service.LatestAIMatchBatchID(h.db, actor)
|
||||
if err != nil {
|
||||
fail(c, http.StatusInternalServerError, "读取最近 AI 匹配批次失败,请刷新页面后重试。")
|
||||
return
|
||||
}
|
||||
aiBatchPageURL := func(id string) string {
|
||||
query := url.Values{"ai_batch_id": {id}}
|
||||
if keyword != "" {
|
||||
query.Set("order_no", keyword)
|
||||
}
|
||||
if shop != "" {
|
||||
query.Set("shop", shop)
|
||||
}
|
||||
if stage != "" {
|
||||
query.Set("stage", stage)
|
||||
}
|
||||
query.Set("page", strconv.Itoa(result.Page))
|
||||
query.Set("date_from", dateFrom)
|
||||
query.Set("date_to", dateTo)
|
||||
return "/syb?" + query.Encode()
|
||||
}
|
||||
|
||||
cfg, cfgErr := config.Load()
|
||||
switch {
|
||||
case cfgErr != nil:
|
||||
@@ -238,6 +278,19 @@ func (h *Handler) renderSybListWithLoginReason(c *gin.Context, keyword, pageRaw,
|
||||
"AssignableClients": purchaseClients.Rows,
|
||||
"PurchaseClientCount": purchaseClients.SelectableCount,
|
||||
"EnabledSyncShopCount": enabledShopCount,
|
||||
"AIMatchBatch": aiBatch,
|
||||
"AIMatchBatchFetchURL": func() string {
|
||||
if aiBatch == nil {
|
||||
return ""
|
||||
}
|
||||
return "/syb/ai-match/" + url.PathEscape(aiBatch.BatchID)
|
||||
}(),
|
||||
"LatestAIMatchBatchURL": func() string {
|
||||
if latestAIBatchID == "" {
|
||||
return ""
|
||||
}
|
||||
return aiBatchPageURL(latestAIBatchID)
|
||||
}(),
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user