Commit d4ca9b0b by 孙龙

tuangou

parent 114fb871
......@@ -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/"
......@@ -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
......@@ -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
)
......@@ -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)
}
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