Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
golang-queue-server
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
d4ca9b0b
authored
Apr 14, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
tuangou
parent
114fb871
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
0 deletions
config/db.toml.demo
dal/order/Order/Order.go
go.mod
util/config.go
config/db.toml.demo
View file @
d4ca9b0b
...
...
@@ -14,3 +14,8 @@ host="192.168.1.235"
password="icDb29mLy2s"
port="6379"
[rabbitmq_order_push_stock]
queue_name="order_push_stock"
dns="amqp://guest:guest@192.168.2.232:5672/"
dal/order/Order/Order.go
View file @
d4ca9b0b
...
...
@@ -2,8 +2,11 @@ package Order
import
(
_
"database/sql"
"fmt"
_
"fmt"
"github.com/ichunt2019/logger"
"github.com/streadway/amqp"
"go-queue-server/util"
"go-queue-server/dal/db"
_
"time"
)
...
...
@@ -19,5 +22,53 @@ func UpdateStatus(order_id int, status_extend int) (err error) {
return
err1
}
err
=
makeOrder
(
order_id
)
return
err
}
func
makeOrder
(
order_id
int
)
(
err
error
)
{
conn
,
err
:=
amqp
.
Dial
(
util
.
Configs
.
Rabbitmq_order_push_stock
.
Dns
)
if
(
err
!=
nil
)
{
logger
.
Fatal
(
fmt
.
Sprintf
(
" err %s 推入仓库失败 订单号 %d"
,
err
,
order_id
))
}
defer
conn
.
Close
()
//通道
ch
,
err
:=
conn
.
Channel
()
if
(
err
!=
nil
)
{
logger
.
Fatal
(
fmt
.
Sprintf
(
" err %s 推入仓库失败 订单号 %d"
,
err
,
order_id
))
}
defer
ch
.
Close
()
//设置数据
q
,
err
:=
ch
.
QueueDeclare
(
util
.
Configs
.
Rabbitmq_order_push_stock
.
QueueName
,
// name
true
,
// durable
false
,
// delete when unused
false
,
// exclusive
false
,
// no-wait
nil
,
// arguments
)
if
(
err
!=
nil
)
{
logger
.
Fatal
(
fmt
.
Sprintf
(
" err %s 推入仓库失败 订单号 %d"
,
err
,
order_id
))
}
body
:=
fmt
.
Sprintf
(
"{
\"
order_id
\"
:%d}"
,
order_id
)
err
=
ch
.
Publish
(
""
,
// exchange
q
.
Name
,
// routing key
false
,
// mandatory
false
,
// immediate
amqp
.
Publishing
{
ContentType
:
"text/plain"
,
Body
:
[]
byte
(
body
),
})
if
(
err
!=
nil
)
{
logger
.
Fatal
(
fmt
.
Sprintf
(
" err %s 推入仓库失败 订单号 %d"
,
err
,
order_id
))
}
return
}
\ No newline at end of file
go.mod
View file @
d4ca9b0b
...
...
@@ -12,5 +12,6 @@ require (
github.com/ichunt2019/logger v1.0.5
github.com/jmoiron/sqlx v1.2.0
github.com/prometheus/common v0.7.0 // indirect
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271
github.com/tealeg/xlsx v1.0.5
)
util/config.go
View file @
d4ca9b0b
...
...
@@ -9,6 +9,7 @@ import (
type
Config
struct
{
Liexin_databases
*
LiexinMysqlConfig
Rabbitmq_ichunt
*
RabbitmqIchunt
Rabbitmq_order_push_stock
*
RabbitmqOrderPushStock
Crm_domain
*
SendMail
Ding_msg
*
Ding
Api_domain
*
ApiDomain
...
...
@@ -28,6 +29,11 @@ type RabbitmqIchunt struct {
Dns
string
`toml:"dns"`
}
type
RabbitmqOrderPushStock
struct
{
QueueName
string
`toml:"queue_name"`
Dns
string
`toml:"dns"`
}
type
SendMail
struct
{
SendMailUrl
string
`toml:"send_mail"`
}
...
...
@@ -66,4 +72,5 @@ func Init(ConfigDir string){
//fmt.Printf("%+v",Configs.Crm_domain)
//fmt.Printf("%+v",Configs.Rabbitmq_ichunt)
//fmt.Printf("%+v",Configs.Redis_config)
//fmt.Printf("%+v",Configs.Rabbitmq_order_push_stock)
}
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