Commit a70c17c5 by 朱继来

添加日志

parent 4a022dd9
package OrderActionLog
import (
"database/sql"
"go-queue-server/dal/db"
"go-queue-server/util"
"fmt"
"log"
"time"
)
type ActionLog struct {
LogId int `db:"log_id"`
OrderId int `db:"order_id"`
OperatorId int `db:"operator_id"`
OperatorType int `db:"operator_type"`
Event string `db:"event"`
Ip string `db:"ip"`
CreateTime int `db:"create_time"`
}
func initDb(dns string) (err error) {
err = db.Init(dns)
if err != nil {
return
}
return
}
func AddLog() (err error) {
initDb(util.Configs.Liexin_databases.Dns) //初始化db
// QueryRow()
// Query()
Insert(3340, 1000, 2, "go test")
return
}
// 单行查询
func QueryRow() {
var actionLog ActionLog
err1 := db.DB.Get(&actionLog, "select * from lie_order_action_log where order_id = 3340")
if err1 == sql.ErrNoRows {
log.Printf("not found data of the id:%d", 1)
}
if err1 != nil {
panic(err1)
}
fmt.Printf("actionLog: %v\n", actionLog)
}
// 多行查询
func Query() {
var actionLog2 []*ActionLog
err2 := db.DB.Select(&actionLog2, "select * from lie_order_action_log where order_id = 3340")
if err2 == sql.ErrNoRows {
log.Printf("not found data of the id:%d", 1)
}
if err2 != nil {
panic(err2)
}
for _, v := range actionLog2 {
fmt.Println(v)
}
}
func Insert(order_id int, operator_id int, operator_type int, event string) (err error) {
create_time := time.Now().Unix()
result, err := db.DB.Exec("insert into lie_order_action_log (order_id, operator_id, operator_type, event, create_time) values (?, ?, ?, ?, ?)", order_id, operator_id, operator_type, event, create_time)
if err != nil {
panic(err)
}
// id, err := result.LastInsertId()
// if err != nil {
// panic(err)
// }
// affected, err := result.RowsAffected()
// if err != nil {
// panic(err)
// }
// fmt.Printf("last insert id:%d affect rows:%d\n", id, affected)
return err
}
\ No newline at end of file
2020-01-02 18:00:15.702 INFO (main.go:main.(*RecvPro).Consumer:24) 111111111111111111
2020-01-02 18:09:34.288 INFO (main.go:main.(*RecvPro).Consumer:24) {"data":[{"orderNum":"ZTY-SZ201912240009","goods":"GRM033R71A822KA01D","purchasingPrice":"0.005900","unitPrice":"0.005900","brand":"ICCNEXERGY","nums":"10000","currency":"\u4eba\u6c11\u5e01","totalPrice":"59.00","remarks":"xxx","material":"4VSqC0NYQzi8gWpBuK630IiIKlg=","purchasing":"\u6731\u7ee7\u6765","projectId":1,"deliveryTime":"v001","send_email":"zjl@ichunt.com"}],"toUser":["zjl@ichunt.com"],"ccUser":["zgj@ichunt.com","zjl@ichunt.com"],"combined":"259.00","order_amount":"259.00","date":"2020-01-02","kefu_remark":"","id":"\u5f20\u5a77\u7389"}
2020-01-02 18:10:43.112 INFO (main.go:main.(*RecvPro).Consumer:24) 111111111
2020-01-02 18:10:46.918 INFO (main.go:main.(*RecvPro).Consumer:24) 111111111
2020-01-02 18:14:04.999 INFO (main.go:main.(*RecvPro).Consumer:24) 111111111
2020-01-02 18:19:24.511 INFO (main.go:main.(*RecvPro).Consumer:24) {"data":[{"orderNum":"ZTY-SZ201912240009","goods":"GRM033R71A822KA01D","purchasingPrice":"0.005900","unitPrice":"0.005900","brand":"ICCNEXERGY","nums":"10000","currency":"\u4eba\u6c11\u5e01","totalPrice":"59.00","remarks":"xxx","material":"4VSqC0NYQzi8gWpBuK630IiIKlg=","purchasing":"\u6731\u7ee7\u6765","projectId":1,"deliveryTime":"v001","send_email":"zjl@ichunt.com"}],"toUser":["zjl@ichunt.com"],"ccUser":["long@ichunt.com"],"combined":"259.00","order_amount":"259.00","date":"2020-01-02","kefu_remark":"","id":"\u5f20\u5a77\u7389"}
2020-01-02 18:19:36.357 INFO (main.go:main.(*RecvPro).Consumer:24) {"data":[{"orderNum":"ZTY-SZ201912240009","goods":"GRM033R71A822KA01D","purchasingPrice":"0.005900","unitPrice":"0.005900","brand":"ICCNEXERGY","nums":"10000","currency":"\u4eba\u6c11\u5e01","totalPrice":"59.00","remarks":"xxx","material":"4VSqC0NYQzi8gWpBuK630IiIKlg=","purchasing":"\u6731\u7ee7\u6765","projectId":1,"deliveryTime":"v001","send_email":"zjl@ichunt.com"}],"toUser":["zjl@ichunt.com"],"ccUser":["long@ichunt.com"],"combined":"259.00","order_amount":"259.00","date":"2020-01-02","kefu_remark":"","id":"\u5f20\u5a77\u7389"}
2020-01-02 18:25:18.573 INFO (main.go:main.(*RecvPro).Consumer:24) {"data":[{"orderNum":"ZTY-SZ201912240009","goods":"GRM033R71A822KA01D","purchasingPrice":"0.005900","unitPrice":"0.005900","brand":"ICCNEXERGY","nums":"10000","currency":"\u4eba\u6c11\u5e01","totalPrice":"59.00","remarks":"xxx","material":"4VSqC0NYQzi8gWpBuK630IiIKlg=","purchasing":"\u6731\u7ee7\u6765","projectId":1,"deliveryTime":"v001","send_email":"zjl@ichunt.com"}],"toUser":["zjl@ichunt.com"],"ccUser":["long@ichunt.com"],"combined":"259.00","order_amount":"259.00","date":"2020-01-02","kefu_remark":"","id":"\u5f20\u5a77\u7389"}
2020-01-02 18:25:46.351 INFO (main.go:main.(*RecvPro).Consumer:24) {"data":[{"orderNum":"ZTY-SZ201912240009","goods":"GRM033R71A822KA01D","purchasingPrice":"0.005900","unitPrice":"0.005900","brand":"ICCNEXERGY","nums":"10000","currency":"\u4eba\u6c11\u5e01","totalPrice":"59.00","remarks":"xxx","material":"4VSqC0NYQzi8gWpBuK630IiIKlg=","purchasing":"\u6731\u7ee7\u6765","projectId":1,"deliveryTime":"v001","send_email":"zjl@ichunt.com"}],"toUser":["zjl@ichunt.com"],"ccUser":["long@ichunt.com"],"combined":"259.00","order_amount":"259.00","date":"2020-01-02","kefu_remark":"","id":"\u5f20\u5a77\u7389"}
2020-01-02 18:26:14.331 INFO (main.go:main.(*RecvPro).Consumer:24) {"data":[{"orderNum":"ZTY-SZ201912240009","goods":"GRM033R71A822KA01D","purchasingPrice":"0.005900","unitPrice":"0.005900","brand":"ICCNEXERGY","nums":"10000","currency":"\u4eba\u6c11\u5e01","totalPrice":"59.00","remarks":"xxx","material":"4VSqC0NYQzi8gWpBuK630IiIKlg=","purchasing":"\u6731\u7ee7\u6765","projectId":1,"deliveryTime":"v001","send_email":"zjl@ichunt.com"}],"toUser":["zjl@ichunt.com"],"ccUser":["long@ichunt.com"],"combined":"259.00","order_amount":"259.00","date":"2020-01-02","kefu_remark":"","id":"\u5f20\u5a77\u7389"}
2020-01-02 18:27:28.381 INFO (main.go:main.(*RecvPro).Consumer:24) {"data":[{"orderNum":"ZTY-SZ201912240009","goods":"GRM033R71A822KA01D","purchasingPrice":"0.005900","unitPrice":"0.005900","brand":"ICCNEXERGY","nums":"10000","currency":"\u4eba\u6c11\u5e01","totalPrice":"59.00","remarks":"xxx","material":"4VSqC0NYQzi8gWpBuK630IiIKlg=","purchasing":"\u6731\u7ee7\u6765","projectId":1,"deliveryTime":"v001","send_email":"zjl@ichunt.com"}],"toUser":["zjl@ichunt.com"],"ccUser":["long@ichunt.com"],"combined":"259.00","order_amount":"259.00","date":"2020-01-02","kefu_remark":"","id":"\u5f20\u5a77\u7389"}
......@@ -9,6 +9,7 @@ import (
"go-queue-server/logger"
"sync"
"time"
"go-queue-server/dal/order/OrderActionLog"
)
......
......@@ -2,7 +2,6 @@ package sendEmail
import (
"fmt"
// "go-queue-server/dal/db"
"go-queue-server/util"
"net/http"
"encoding/json"
......@@ -43,8 +42,17 @@ func SendPurchaseEmail(data string) (err error) {
fmt.Println(err1)
}
fmt.Println(res)
var data_map map[string]interface{}
json.Unmarshal([]byte(data), &data_map)
order_id := data_map["order_id"];
// 添加操作日志
// 推送ERP
return
}
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