提交 de594746 authored 作者: gukai's avatar gukai

推送消息增加请求日志

上级 39bef359
...@@ -21,6 +21,9 @@ const ( ...@@ -21,6 +21,9 @@ const (
MsgCloudTopic = "newShopApi" MsgCloudTopic = "newShopApi"
//通知消息系统topic //通知消息系统topic
NotifyTopic = "notifyMessage" NotifyTopic = "notifyMessage"
//API请求日志
ApiRequestTopic = "apiRequest"
//消息类型 //消息类型
...@@ -203,3 +206,17 @@ func (p *NsqProducer) NotifyServer(notifyServer *NotifyServer) (err error) { ...@@ -203,3 +206,17 @@ func (p *NsqProducer) NotifyServer(notifyServer *NotifyServer) (err error) {
} }
return return
} }
/*
api请求日志 20220310 gk
*/
func (p *NsqProducer) NotifyApiLog(notifyApiLog *NotifyApiLog) (err error) {
jsonBytes, _ := json.Marshal(notifyApiLog)
err = NsqProducers.Publish(ApiRequestTopic, string(jsonBytes))
if !logs.CheckErr(err, "NotifyApiLog") {
logs.Info("NotifyApiLog", "消息内容:【%v】", string(jsonBytes))
}
return
}
\ No newline at end of file
package notify package notify
//推送到消息系统的公共消息 //推送到消息系统的公共消息
type NotifyServer struct { type NotifyServer struct {
MsgType int `json:"msg_type"` MsgType int `json:"msg_type"`
...@@ -14,11 +12,13 @@ type NotifyServer struct { ...@@ -14,11 +12,13 @@ type NotifyServer struct {
type NotifyRefundData struct { type NotifyRefundData struct {
AfsServiceId interface{} `json:"afs_service_id"` //三方服务单号 AfsServiceId interface{} `json:"afs_service_id"` //三方服务单号
} }
//推送到消息系统的订单消息 //推送到消息系统的订单消息
type NotifyOrderData struct { type NotifyOrderData struct {
ThirdChildOrderSn string `json:"third_child_order_sn"`//三方子订单号 ThirdChildOrderSn string `json:"third_child_order_sn"` //三方子订单号
ThirdOrderSn string `json:"third_order_sn"` //三方订单号 ThirdOrderSn string `json:"third_order_sn"` //三方订单号
} }
//推送到消息系统的商品消息 //推送到消息系统的商品消息
type NotifyGoodsData struct { type NotifyGoodsData struct {
ThirdGoodsInfo []ThirdGoods `json:"third_goods"` //三方商品信息 ThirdGoodsInfo []ThirdGoods `json:"third_goods"` //三方商品信息
...@@ -44,19 +44,35 @@ type NotifyMessage struct { ...@@ -44,19 +44,35 @@ type NotifyMessage struct {
type GoodsMsgData struct { type GoodsMsgData struct {
GoodsIDs []int `json:"goods_id"` GoodsIDs []int `json:"goods_id"`
} }
//通知客户订单消息 //通知客户订单消息
type OrderMsgData struct { type OrderMsgData struct {
OrderSn string `json:"orderSn"` OrderSn string `json:"orderSn"`
Sku uint `json:"sku"` Sku uint `json:"sku"`
} }
//通知客户售后消息 //通知客户售后消息
type RefundMsgData struct { type RefundMsgData struct {
AfterSaleID uint `json:"afterSaleId"` AfterSaleID uint `json:"afterSaleId"`
OrderSn string `json:"orderSn"` OrderSn string `json:"orderSn"`
Sku uint `json:"sku"` Sku uint `json:"sku"`
} }
//通知客户标签消息 //通知客户标签消息
type TagsMsgData struct { type TagsMsgData struct {
Tags string `json:"tags"` Tags string `json:"tags"`
} }
//通知api请求日志
type NotifyApiLog struct {
ID int `json:"id"`
Type string `json:"type"` //api类型 goods/order
Method string `json:"method"` //请求方式
RequestUri string `json:"request_uri"` //请求路径
AppID int `json:"app_id"`
RequestTime int `json:"request_time"` //请求时间戳
Body string `json:"body"` //请求参数
ResponseTime int `json:"response_time"` //响应时间
ResponseBody string `json:"response_body"` //响应参数
Error string `json:"error"` //错误信息
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论