Files
huangjingfen/pro_v3.5.1/app/jobs/community/CommunityCommentJob.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

79 lines
2.7 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace app\jobs\community;
use app\services\community\CommunityCommentServices;
use app\services\community\CommunityRecordServices;
use app\services\community\CommunityServices;
use app\services\community\CommunityUserServices;
use crmeb\basic\BaseJobs;
use crmeb\traits\QueueTrait;
use think\facade\Log;
/**
* 社区帖子评论
* Class CommunityJob
* @package app\jobs\community
*/
class CommunityCommentJob extends BaseJobs
{
use QueueTrait;
/**
* 用户评论数数据矫正
* @param $id
* @return true
* User: liusl
* DateTime: 2024/9/10 11:08
*/
public function communityCommentSync($id)
{
try {
$communityCommentServices = app()->make(CommunityCommentServices::class);
$communityCommentServices->syncCommentNum($id);
} catch (\Throwable $e) {
response_log_write([
'message' => '用户评论数数据矫正失败:' . $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine()
]);
}
return true;
}
public function communityMessage($id)
{
try {
$communityServices = app()->make(CommunityServices::class);
$communityCommentServices = app()->make(CommunityCommentServices::class);
$communityRecordServices = app()->make(CommunityRecordServices::class);
$info = $communityCommentServices->get(['id' => $id, 'is_verify' => 1, 'is_show' => 1, 'is_del' => 0]);
if ($info) {
$relation_id = $communityServices->value(['id' => $info['community_id']], 'relation_id');
$communityRecordServices->save([
'uid' => $info['is_reply'] == 1 ? $relation_id : ($info['reply_id'] ? $info['reply_uid'] : $info['comment_reply_uid']),
'relation_id' => $info['uid'],
'type' => CommunityRecordServices::SET_TYPE_COMMENT,
'link_id' => $info['community_id'],
'comment_id' => $info['id'],
'comment_type' => $info['is_reply'] == 1 ? 1 : 2,
'content' => $info['content'],
'add_time' => time()
]);
}
} catch (\Throwable $e) {
response_log_write([
'message' => '新增帖子评论消息记录失败:' . $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine()
]);
}
return true;
}
}