add clear unpaid order functions

This commit is contained in:
RockYang
2024-08-07 18:00:28 +08:00
parent c9d0700fd9
commit 7a11a9ef15
4 changed files with 34 additions and 3 deletions

View File

@@ -93,10 +93,20 @@ func (h *OrderHandler) Remove(c *gin.Context) {
}
err := h.DB.Unscoped().Where("id = ?", id).Delete(&model.Order{}).Error
if res.Error != nil {
if err != nil {
resp.ERROR(c, err.Error())
return
}
}
resp.SUCCESS(c)
}
func (h *OrderHandler) Clear(c *gin.Context) {
err := h.DB.Unscoped().Where("status <> ?", 2).Where("pay_time", 0).Delete(&model.Order{}).Error
if err != nil {
resp.ERROR(c, err.Error())
return
}
resp.SUCCESS(c)
}

View File

@@ -392,6 +392,7 @@ func main() {
group := s.Engine.Group("/api/admin/order/")
group.POST("list", h.List)
group.GET("remove", h.Remove)
group.GET("clear", h.Clear)
}),
fx.Invoke(func(s *core.AppServer, h *handler.OrderHandler) {
group := s.Engine.Group("/api/order/")