修复二维码库存与过期时间编辑
This commit is contained in:
@@ -12,8 +12,8 @@ import (
|
||||
|
||||
// 会话类型常量
|
||||
const (
|
||||
ConversationTypeOrderGroup = "order_group"
|
||||
ConversationTypeListingGroup = "listing_group"
|
||||
ConversationTypeOrderGroup = "order_group"
|
||||
ConversationTypeListingGroup = "listing_group"
|
||||
ConversationTypeGeneralSupport = "general_support"
|
||||
)
|
||||
|
||||
@@ -297,6 +297,7 @@ func checkQrCodeStockAndAlert(tx *gorm.DB, conversation *model.ChatConversation)
|
||||
var count int64
|
||||
if err := tx.Model(&model.ChatQrCode{}).
|
||||
Where("status = ?", QrCodeStatusUnused).
|
||||
Where("expires_at IS NULL OR expires_at > ?", time.Now()).
|
||||
Count(&count).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -319,6 +320,7 @@ func checkQrCodeStockAndAlert(tx *gorm.DB, conversation *model.ChatConversation)
|
||||
|
||||
// 发送站内信给所有客服
|
||||
var entries []interface{}
|
||||
now := time.Now()
|
||||
for _, admin := range csAdmins {
|
||||
entries = append(entries, map[string]interface{}{
|
||||
"admin_user_id": admin.ID,
|
||||
@@ -326,13 +328,13 @@ func checkQrCodeStockAndAlert(tx *gorm.DB, conversation *model.ChatConversation)
|
||||
"title": "二维码库存预警",
|
||||
"content": alertContent,
|
||||
"is_read": false,
|
||||
"created_at": time.Now(),
|
||||
"updated_at": time.Now(),
|
||||
"created_at": now,
|
||||
"updated_at": now,
|
||||
})
|
||||
}
|
||||
|
||||
if len(entries) > 0 {
|
||||
// 批量插入通知
|
||||
// 批量插入管理员通知
|
||||
if err := tx.Table("admin_notifications").Create(entries).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user