This commit is contained in:
2025-10-14 09:48:33 +08:00
parent d268c69ade
commit 8aed3e5aac
7 changed files with 395 additions and 316 deletions

View File

@@ -6,12 +6,13 @@ use app\common\model\MqLog;
use app\common\model\RabbitMqConfig;
use ba\Random;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use support\think\Db;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use think\facade\Log;
use support\Log;
class RabbProductUpdate extends Command
@@ -57,10 +58,11 @@ class RabbProductUpdate extends Command
// 'x-message-ttl' => ['I', 180000]
]);
$callback = function ($msg){
$callback = function ($msg) use ($queue){
$date_time = date('Y-m-d H:i:s');
$data = $msg->body;
Log::write('收到商品更新消息--->' . $data . '--->' . $date_time . "\n");
print_r('收到商品更新消息--->' . $data . '--->' . $date_time . "\n");
Log::info('收到商品更新消息--->' . $data . '--->' . $date_time . "\n");
// 如果是数字。则打印订单
$is_log = false;
$curl_error = '';
@@ -91,10 +93,10 @@ class RabbProductUpdate extends Command
$curl_error = 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
Log::write('内部通讯结果(商品更新)--->' . $output . '通讯ID--->shop_id-->' .$send_id. '---' . date('Y-m-d H:i:s') . "\n");
Log::info('内部通讯结果(商品更新)--->' . $output . '通讯ID--->shop_id-->' .$send_id. '---' . date('Y-m-d H:i:s') . "\n");
if($is_log) {
MqLog::create([
'queue' => '',
Db::table('tb_mq_log')->insert([
'queue' => $queue,
'msg' => $data,
'type' => 'product_update',
'plat' => 'product',