Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
php_frq_api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6657470d
authored
May 20, 2021
by
duwenjun
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
询价单
parent
1e329543
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
app/Http/Queue/RabbitQueueModel.php
app/Model/InquiryModel.php
config/rabbitmq.php
app/Http/Queue/RabbitQueueModel.php
0 → 100644
View file @
6657470d
<?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
app/Model/InquiryModel.php
View file @
6657470d
...
@@ -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
,
"操作成功"
];
}
}
...
...
config/rabbitmq.php
0 → 100644
View file @
6657470d
<?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'
]
]
]
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment