feat(tenant): 隔离客服通知文件与后台任务
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user