b90f901fd9
- feishu_message 表新增 company_id 和 feishu_app_id 字段追踪消息发送者 - 修改 FeishuMessage::saveMessage() 支持保存公司和飞书应用信息 - 修改 FeishuNotificationService 使用原始发送者的飞书应用配置更新消息 - 新增 HttpClient::httpPatchJson() 方法支持 PATCH 请求 - 文档更新:PROJECT_ISSUES.md 添加问题31,APPROVAL_NOTIFICATION_ARCHITECTURE.md 添加多公司架构说明 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
79 lines
1.8 KiB
PHP
79 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace app\model;
|
|
|
|
use support\Model;
|
|
|
|
/**
|
|
* 飞书审批消息映射模型
|
|
*/
|
|
class FeishuMessage extends Model
|
|
{
|
|
protected $table = 'feishu_message';
|
|
|
|
protected $fillable = [
|
|
'order_id',
|
|
'node_id',
|
|
'user_id',
|
|
'company_id',
|
|
'feishu_app_id',
|
|
'message_id',
|
|
'msg_token',
|
|
'status',
|
|
];
|
|
|
|
const STATUS_ACTIVE = 'active';
|
|
const STATUS_UPDATED = 'updated';
|
|
const STATUS_DELETED = 'deleted';
|
|
|
|
/**
|
|
* 根据订单和节点获取消息列表
|
|
*/
|
|
public static function getMessagesByOrderAndNode(int $orderId, int $nodeId): array
|
|
{
|
|
return self::where('order_id', $orderId)
|
|
->where('node_id', $nodeId)
|
|
->where('status', self::STATUS_ACTIVE)
|
|
->get()
|
|
->toArray();
|
|
}
|
|
|
|
/**
|
|
* 保存消息映射
|
|
*/
|
|
public static function saveMessage(
|
|
int $orderId,
|
|
int $nodeId,
|
|
int $userId,
|
|
string $messageId,
|
|
?string $msgToken = null,
|
|
?int $companyId = null,
|
|
?int $feishuAppId = null
|
|
): self {
|
|
return self::updateOrCreate(
|
|
[
|
|
'order_id' => $orderId,
|
|
'node_id' => $nodeId,
|
|
'user_id' => $userId,
|
|
],
|
|
[
|
|
'message_id' => $messageId,
|
|
'msg_token' => $msgToken,
|
|
'company_id' => $companyId,
|
|
'feishu_app_id' => $feishuAppId,
|
|
'status' => self::STATUS_ACTIVE,
|
|
]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 标记消息为已更新
|
|
*/
|
|
public static function markAsUpdated(int $orderId, int $nodeId): bool
|
|
{
|
|
return self::where('order_id', $orderId)
|
|
->where('node_id', $nodeId)
|
|
->update(['status' => self::STATUS_UPDATED]) > 0;
|
|
}
|
|
}
|