fix(chat): 回复后再移出待处理
This commit is contained in:
@@ -239,6 +239,7 @@ func (r *Repository) listAdminConversations(ctx context.Context, principal Princ
|
||||
COALESCE(explicit_lo.handoff_status, listing_lo.handoff_status) AS latest_handoff_status,
|
||||
COALESCE(explicit_lo.refund_status, listing_lo.refund_status) AS latest_refund_status,
|
||||
lm.sender_type AS last_sender_type, lm.sender_id AS last_sender_id, lm.sender_role AS last_sender_role,
|
||||
CASE WHEN ` + adminNeedsReplyExpression() + ` THEN 1 ELSE 0 END AS needs_reply,
|
||||
(
|
||||
SELECT COUNT(1)
|
||||
FROM chat_messages AS cm
|
||||
@@ -414,13 +415,7 @@ func adminChatStageCondition(stage string, principal Principal) (string, []inter
|
||||
latestRefundStatus := "COALESCE(explicit_lo.refund_status, listing_lo.refund_status)"
|
||||
switch stage {
|
||||
case adminChatStagePending:
|
||||
return `EXISTS (
|
||||
SELECT 1
|
||||
FROM chat_messages AS cm_pending
|
||||
WHERE cm_pending.conversation_id = c.id
|
||||
AND (cm_pending.admin_attention_type <> '' OR cm_pending.sender_type = 'user')
|
||||
AND cm_pending.id > COALESCE(cas.last_read_message_id, 0)
|
||||
)`, nil
|
||||
return adminNeedsReplyExpression(), nil
|
||||
case adminChatStageUnjoined:
|
||||
return latestID + " IS NULL", nil
|
||||
case adminChatStageHandoff:
|
||||
@@ -438,6 +433,20 @@ func adminChatStageCondition(stage string, principal Principal) (string, []inter
|
||||
}
|
||||
}
|
||||
|
||||
func adminNeedsReplyExpression() string {
|
||||
return `COALESCE((
|
||||
SELECT MAX(cm_attention.id)
|
||||
FROM chat_messages AS cm_attention
|
||||
WHERE cm_attention.conversation_id = c.id
|
||||
AND (cm_attention.admin_attention_type <> '' OR cm_attention.sender_type = 'user')
|
||||
), 0) > COALESCE((
|
||||
SELECT MAX(cm_admin.id)
|
||||
FROM chat_messages AS cm_admin
|
||||
WHERE cm_admin.conversation_id = c.id
|
||||
AND cm_admin.sender_type = 'admin'
|
||||
), 0)`
|
||||
}
|
||||
|
||||
// ArchiveListingConversation 将商品关联的发布群标记为已归档(解散),并写入系统提示。
|
||||
// 用于客服封存订单时同事务解散群聊;发布群不存在时静默跳过,不阻断封存流程。
|
||||
// 归档后 SendMessage 的 status 校验会阻断所有成员继续发言。
|
||||
|
||||
Reference in New Issue
Block a user