Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YZ4DskSRKsSiheQonFtQvx
This commit is contained in:
@@ -240,3 +240,18 @@ func (h *StockOutHandler) Reject(c *gin.Context) {
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "rejected"})
|
||||
}
|
||||
|
||||
// Withdraw PUT /api/v1/stock-out/orders/:id/withdraw
|
||||
// 审核中(pending)撤回为草稿(draft),供管理员修改后重新提交。仅 pending 可撤回;
|
||||
// 已审核(approved)单据只读、库存已变动,不可撤回。
|
||||
func (h *StockOutHandler) Withdraw(c *gin.Context) {
|
||||
shopID := middleware.GetShopID(c)
|
||||
result := h.db.Model(&model.StockOutOrder{}).
|
||||
Where("id = ? AND shop_id = ? AND status = 'pending'", c.Param("id"), shopID).
|
||||
Update("status", "draft")
|
||||
if result.RowsAffected == 0 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "order not found or not in pending status"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "withdrawn"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user