提交1: 数据层改造 - 发布群与企业微信群二维码

- 新增数据库迁移 000008: chat_conversations 增加 listing_id, 新建 chat_qrcode_pool 表
- 更新 GORM 模型: ChatConversation 新增 ListingID 字段, 新增 ChatQrCode 模型
- 实现二维码池管理后端 API: 创建/列表/统计/更新/删除
- 新增管理后台路由: /api/admin/chats/qrcodes
- 新增系统配置: chat.listing_group_welcome, chat.qrcode_low_stock_threshold
- 更新优化方案文档: 废弃双群方案, 采用单群方案

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
yml
2026-06-17 15:57:10 +08:00
co-authored by Claude Opus 4.8
parent 87483ea6a8
commit 423c142967
7 changed files with 989 additions and 1 deletions
+18
View File
@@ -9,6 +9,7 @@ import (
type ChatConversation struct {
ID uint64 `gorm:"primaryKey" json:"id"`
OrderID *uint64 `gorm:"uniqueIndex" json:"order_id"`
ListingID *uint64 `gorm:"index" json:"listing_id"`
Type string `gorm:"size:32;not null;default:'order_group'" json:"type"`
Title string `gorm:"size:128;not null" json:"title"`
Status string `gorm:"size:32;not null;default:'active'" json:"status"`
@@ -55,3 +56,20 @@ type ChatMessage struct {
func (ChatMessage) TableName() string {
return "chat_messages"
}
type ChatQrCode struct {
ID uint64 `gorm:"primaryKey" json:"id"`
ImageURL string `gorm:"size:512;not null" json:"image_url"`
Status string `gorm:"size:16;not null;default:'unused'" json:"status"`
ConversationID *uint64 `gorm:"index" json:"conversation_id"`
UsedAt *time.Time `json:"used_at"`
ExpiresAt *time.Time `json:"expires_at"`
CreatedBy uint64 `gorm:"not null" json:"created_by"`
Note string `gorm:"size:255;not null;default:''" json:"note"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (ChatQrCode) TableName() string {
return "chat_qrcode_pool"
}