fix(backend): 财务汇总 500(only_full_group_by 预处理协议回归)+ summary 加 draft_count

- /finance/summary:SEC-001 给 JOIN 加 shop_id 条件后,MySQL 预处理协议推导不出
  p.name 函数依赖 → 1055(文本协议可过,CLI 无法复现)。GROUP BY 补 p.name 修复,
  并给该 handler 加错误日志(此前吞错致排查困难)。v1.0.85 起全店受影响。
- 出入库 summary 新增 draft_count(草稿单数 KPI 卡数据源)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
This commit is contained in:
wangjia
2026-07-03 14:31:50 +08:00
parent cd3cc0d8fe
commit 4d1d69595b
3 changed files with 11 additions and 1 deletions
+2
View File
@@ -117,6 +117,8 @@ func (h *StockOutHandler) Summary(c *gin.Context) {
s.LastMonthCount, s.LastMonthAmount = agg(prevFrom, prevTo)
h.db.Model(&model.StockOutOrder{}).
Where("shop_id = ? AND status = ? AND deleted_at IS NULL", shopID, "pending").Count(&s.PendingCount)
h.db.Model(&model.StockOutOrder{}).
Where("shop_id = ? AND status = ? AND deleted_at IS NULL", shopID, "draft").Count(&s.DraftCount)
c.JSON(http.StatusOK, s)
}