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
This commit is contained in:
@@ -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, '/');
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
namespace app\command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use support\Db;
|
||||
use support\Log;
|
||||
|
||||
class FixInquiryLogOrderNo extends Command
|
||||
{
|
||||
protected static $defaultName = 'sn';
|
||||
protected static $defaultDescription = 'Fix duplicate order_no values in inquiry_log table';
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
// Start transaction for safety
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
$output->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user