Commit 6657470d by duwenjun

询价单

parent 1e329543
<?php
namespace App\Http\Queue;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
class RabbitQueueModel
{
private $connection;
public function __construct(string $connect_name = '')
{
if ($connect_name) {
$config = Config('rabbitmq.connections.' . $connect_name);
} else {
$default_connect_name = Config('rabbitmq.default');
$config = Config('rabbitmq.connections.' . $default_connect_name);
}
// 创建rabbitmq链接
$this->connection = new AMQPStreamConnection(
$config['host'], $config['port'], $config['login'], $config['password'], $config['vhost']
);
}
// 队列推送
public function push($queue_name, $content)
{
$channel = $this->connection->channel();
$channel->queue_declare($queue_name, false, true, false, false);
$message = new AMQPMessage($content);
$channel->basic_publish($message, '', $queue_name); // 推送消息
$channel->close();
$this->connection->close();
return true;
}
}
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Model; namespace App\Model;
use App\Http\Queue\RabbitQueueModel;
use App\map\InquiryMap; use App\map\InquiryMap;
use App\map\OperationLogMap; use App\map\OperationLogMap;
use App\map\QuoteMap; use App\map\QuoteMap;
...@@ -496,6 +497,10 @@ class InquiryModel extends Model ...@@ -496,6 +497,10 @@ class InquiryModel extends Model
(new InquiryItemsReportModel())->where("inquiry_items_id", $item['id'])->update($reportArr); (new InquiryItemsReportModel())->where("inquiry_items_id", $item['id'])->update($reportArr);
} }
// 加入队列, 后续会把询价单分发到云芯的供应商
$RabbitQueueModel = new RabbitQueueModel();
$RabbitQueueModel->push("frq_add_inquiry", $input["inquiry_id"]);
return [0, "操作成功"]; return [0, "操作成功"];
} }
......
<?php
return [
'default' => "cloud",
'connections' => [
'cloud' => [
'host' => get_resource_config_section('rabbit', 'rabbit')['host'],
'port' => get_resource_config_section('rabbit', 'rabbit')['port'],
'login' => get_resource_config_section('rabbit', 'rabbit')['user'],
'password' => get_resource_config_section('rabbit', 'rabbit')['passwd'],
'vhost' => get_resource_config_section('rabbit', 'rabbit')['vhost']
]
]
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment