From caa04809a933fae1c73f411efb2482663518267b Mon Sep 17 00:00:00 2001 From: mzl Date: Tue, 29 Jul 2025 19:39:17 +0800 Subject: [PATCH] Merge branch 'master' into develop # Conflicts: # app/command/DomainCommand.php # app/common/utils/FeishuMessage.php # app/queue/redis/FeishuMessage.php # app/queue/redis/InquiryToCrm.php --- app/command/DomainCommand.php | 2 +- app/command/FixInquiryLogOrderNo.php | 100 +++++++++++++++++++++++++++ app/common/utils/FeishuMessage.php | 18 +++-- app/queue/redis/FeishuMessage.php | 14 ++-- app/queue/redis/InquiryToCrm.php | 1 + 5 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 app/command/FixInquiryLogOrderNo.php diff --git a/app/command/DomainCommand.php b/app/command/DomainCommand.php index d3c7496..d23e755 100644 --- a/app/command/DomainCommand.php +++ b/app/command/DomainCommand.php @@ -41,7 +41,7 @@ class DomainCommand extends Command * @param string $oldDomain 旧域名(如: http://219.157.255.213:25326) * @return string 处理后的富文本内容 */ -function processRichTextImagesEnhanced($content, $newDomain = 'https://fdesk.hnxinyouhe.com', $oldDomain = 'http://219.157.255.213:25326') { +function processRichTextImagesEnhanced($content, $newDomain = 'https://x-server.hnxinyouhe.com', $oldDomain = 'http://219.157.255.213:25326') { // 标准化域名格式(去除末尾斜杠) $newDomain = rtrim($newDomain, '/'); $oldDomain = rtrim($oldDomain, '/'); diff --git a/app/command/FixInquiryLogOrderNo.php b/app/command/FixInquiryLogOrderNo.php new file mode 100644 index 0000000..ed959cd --- /dev/null +++ b/app/command/FixInquiryLogOrderNo.php @@ -0,0 +1,100 @@ +writeln('Starting duplicate order_no fix process...'); + + // Find all duplicate order_no values using Laravel-style query + $duplicates = Db::table('inquiry_log') + ->select('order_no', Db::raw('COUNT(*) as count')) + ->groupBy('order_no') + ->having('count', '>', 1) + ->get(); + + if ($duplicates->isEmpty()) { + $output->writeln('No duplicate order_no values found.'); + Db::commit(); + return self::SUCCESS; + } + + $output->writeln(sprintf('Found %d order_no values with duplicates.', $duplicates->count())); + + $totalFixed = 0; + + foreach ($duplicates as $dup) { + $orderNo = $dup->order_no; + + $output->writeln("Processing duplicates for order_no: {$orderNo}"); + + // Get all records with this order_no, ordered by created_at (oldest first) + $records = Db::table('inquiry_log') + ->where('order_no', $orderNo) + ->orderBy('created_at', 'asc') + ->get(); + + // Keep the first record as is, modify the rest + $keepOriginal = true; + + foreach ($records as $record) { + if ($keepOriginal) { + $output->writeln("Keeping original record ID {$record->id} with order_no {$record->order_no}"); + $keepOriginal = false; + continue; + } + + // Generate new order_no by appending suffix + $newOrderNo = orderNum(); + $output->writeln("Updating record ID {$record->id} from {$record->order_no} to {$newOrderNo}"); + + // Update the record + Db::table('inquiry_log') + ->where('id', $record->id) + ->update(['order_no' => $newOrderNo]); + + $totalFixed++; + + sleep(1); + } + } + + Db::commit(); + $output->writeln("Successfully fixed {$totalFixed} duplicate records."); + + // Verify no duplicates remain + $remainingDuplicates = Db::table('inquiry_log') + ->select('order_no', Db::raw('COUNT(*) as count')) + ->groupBy('order_no') + ->having('count', '>', 1) + ->get(); + + if ($remainingDuplicates->isEmpty()) { + $output->writeln('Verification: No duplicate order_no values remain.'); + } else { + $output->writeln('Warning: Some duplicates still remain. Please run the command again.'); + } + + return self::SUCCESS; + } catch (\Throwable $e) { + Db::rollback(); + $output->writeln("Error: " . $e->getMessage()); + Log::error("FixInquiryLogOrderNo command failed: " . $e->getMessage()); + return self::FAILURE; + } + } +} \ No newline at end of file diff --git a/app/common/utils/FeishuMessage.php b/app/common/utils/FeishuMessage.php index 311ffd9..4783a9c 100644 --- a/app/common/utils/FeishuMessage.php +++ b/app/common/utils/FeishuMessage.php @@ -7,13 +7,23 @@ use Webman\Exception\BusinessException; class FeishuMessage { - protected $app_id = 'cli_a72f13d6c022500d'; - protected $app_secret = 'Kxtbq70OQWrEhpltrufRZc76z7kjDqPT'; + protected $app_id = 'cli_a6183b882cb8500d'; + protected $app_secret = 'VqYib48u4EtDIa6nG9qH3f0fYCA1bCvs'; + protected $state = 'hesu'; protected $class = null; - public function __construct() + public function __construct($options = []) { - $this->class = new Feishu($this->app_id, $this->app_secret); + if (isset($options['app_id']) && $options['app_id']) { + $this->app_id = $options['app_id']; + } + if (isset($options['app_secret']) && $options['app_secret']) { + $this->app_secret = $options['app_secret']; + } + if (isset($options['state']) && $options['state']) { + $this->state = $options['state']; + } + $this->class = new Feishu($this->app_id, $this->app_secret, $this->state); } /** diff --git a/app/queue/redis/FeishuMessage.php b/app/queue/redis/FeishuMessage.php index c2663c6..7aa510c 100644 --- a/app/queue/redis/FeishuMessage.php +++ b/app/queue/redis/FeishuMessage.php @@ -49,6 +49,7 @@ class FeishuMessage implements Consumer 'app_id' => $feishuAppInfo->app_id, 'app_secret' => $feishuAppInfo->app_secret, + 'state' => $feishuAppInfo->state, 'msg_type' => 'interactive', 'receive_id_type' => 'open_id', 'receive_id' => $reInfo->open_id @@ -62,9 +63,10 @@ class FeishuMessage implements Consumer // 接受者处理 if ($data['receive_type'] == 'group') { - $appId = 'cli_a72f13d6c022500d'; - $appSecret = 'Kxtbq70OQWrEhpltrufRZc76z7kjDqPT'; - $receiveId = 'oc_4f574e6f8bc5b8f3e5175e67ebc5725c'; + $appId = 'cli_a6183b882cb8500d'; + $appSecret = 'VqYib48u4EtDIa6nG9qH3f0fYCA1bCvs'; + $state = 'hesu'; + $receiveId = 'oc_a52d9f89ad76735279088c78beade8dc'; $receiveIdType = 'chat_id'; } else { // 跟单人 @@ -75,6 +77,7 @@ class FeishuMessage implements Consumer // 推送信息 $appId = $feishuAppInfo->app_id; $appSecret = $feishuAppInfo->app_secret; + $state = $feishuAppInfo->state; $receiveId = $reInfo->open_id; $receiveIdType = 'open_id'; } @@ -91,13 +94,14 @@ class FeishuMessage implements Consumer 'app_id' => $appId, 'app_secret' => $appSecret, + 'state' => $state, 'msg_type' => 'interactive', 'receive_id_type' => $receiveIdType, 'receive_id' => $receiveId ]; } - - $feishuMsg = new FeishuMsg(); + + $feishuMsg = new FeishuMsg($options); $feishuMsg->messageSend($data['scene'], $options); } catch (\Throwable $th) { throw $th; diff --git a/app/queue/redis/InquiryToCrm.php b/app/queue/redis/InquiryToCrm.php index ecac73e..ac27813 100644 --- a/app/queue/redis/InquiryToCrm.php +++ b/app/queue/redis/InquiryToCrm.php @@ -24,6 +24,7 @@ class InquiryToCrm implements Consumer try { // 获取询盘信息 $info = InquiryLog::with(['channelInfo', 'countryInfo', 'enter'])->where('id', $data['id'])->where('sync_crm', 0)->first(); + if ($info) { // 获取用户信息 $recipient = 0;