feat(tenant): 隔离客服通知文件与后台任务

This commit is contained in:
yml
2026-11-15 16:23:28 +08:00
parent c7dacfa025
commit e994fd9166
52 changed files with 1670 additions and 254 deletions
+11 -3
View File
@@ -27,6 +27,7 @@ func NewRepository(db *gorm.DB) *Repository {
// - 被租用需辅助:每个订单发一次,同一账号被反复租用会分别提醒;
// - 上架未成交:同一账号只发一次。
type Entry struct {
TenantID uint64
UserID uint64
Phone string
Node string
@@ -48,11 +49,17 @@ func Enqueue(tx *gorm.DB, entry Entry) (bool, error) {
return false, nil
}
tenantID := entry.TenantID
phone := strings.TrimSpace(entry.Phone)
if phone == "" {
if phone == "" || tenantID == 0 {
var user model.User
if err := tx.Select("id", "phone").First(&user, entry.UserID).Error; err == nil {
phone = strings.TrimSpace(user.Phone)
if err := tx.Select("id", "phone", "tenant_id").First(&user, entry.UserID).Error; err == nil {
if phone == "" {
phone = strings.TrimSpace(user.Phone)
}
if tenantID == 0 {
tenantID = user.TenantID
}
}
}
@@ -66,6 +73,7 @@ func Enqueue(tx *gorm.DB, entry Entry) (bool, error) {
}
row := model.SmsMessage{
TenantID: tenantID,
UserID: entry.UserID,
Phone: phone,
Node: node,