mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	add clear unpaid order functions
This commit is contained in:
		@@ -6,6 +6,7 @@
 | 
			
		||||
* Bug修复:修复后台拖动排序组件 Bug
 | 
			
		||||
* 功能优化:更新数据库失败时候显示具体的的报错信息
 | 
			
		||||
* Bug修复:修复管理后台对话详情页内容显示异常问题
 | 
			
		||||
* 功能优化:管理后台新增清空所有未支付订单的功能
 | 
			
		||||
 | 
			
		||||
## v4.1.1
 | 
			
		||||
* Bug修复:修复 GPT 模型 function call 调用后没有输出的问题
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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/")
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@
 | 
			
		||||
          style="margin: 0 10px;width: 200px; position: relative;top:3px;"
 | 
			
		||||
      />
 | 
			
		||||
      <el-button type="primary" :icon="Search" @click="fetchData">搜索</el-button>
 | 
			
		||||
      <el-button type="danger" :icon="Delete" @click="clearOrders">清空未支付订单</el-button>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <el-row>
 | 
			
		||||
@@ -76,9 +77,9 @@
 | 
			
		||||
<script setup>
 | 
			
		||||
import {onMounted, ref} from "vue";
 | 
			
		||||
import {httpGet, httpPost} from "@/utils/http";
 | 
			
		||||
import {ElMessage} from "element-plus";
 | 
			
		||||
import {ElMessage, ElMessageBox} from "element-plus";
 | 
			
		||||
import {dateFormat, removeArrayItem} from "@/utils/libs";
 | 
			
		||||
import {Search} from "@element-plus/icons-vue";
 | 
			
		||||
import {Delete, Search} from "@element-plus/icons-vue";
 | 
			
		||||
 | 
			
		||||
// 变量定义
 | 
			
		||||
const items = ref([])
 | 
			
		||||
@@ -123,6 +124,24 @@ const remove = function (row) {
 | 
			
		||||
    ElMessage.error("删除失败:" + e.message)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const clearOrders = () => {
 | 
			
		||||
  ElMessageBox.confirm(
 | 
			
		||||
      '此操作将会删除所有未支付订单,继续操作吗?',
 | 
			
		||||
      '删除提示',
 | 
			
		||||
      {
 | 
			
		||||
        confirmButtonText: '确认',
 | 
			
		||||
        cancelButtonText: '取消',
 | 
			
		||||
        type: 'warning',
 | 
			
		||||
      }
 | 
			
		||||
  ).then(() => {
 | 
			
		||||
    httpGet("/api/admin/order/clear").then(() => {
 | 
			
		||||
      ElMessage.success("订单删除成功")
 | 
			
		||||
      page.value = 0
 | 
			
		||||
     fetchData()
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style lang="stylus" scoped>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user