|
@@ -5,6 +5,7 @@ import (
|
|
|
"encoding/json"
|
|
|
logger "eta/eta_mini_ht_api/common/component/log"
|
|
|
"eta/eta_mini_ht_api/domian/message"
|
|
|
+ productDao "eta/eta_mini_ht_api/models/merchant"
|
|
|
messageDao "eta/eta_mini_ht_api/models/message"
|
|
|
userDao "eta/eta_mini_ht_api/models/user"
|
|
|
"fmt"
|
|
@@ -22,10 +23,11 @@ type MessageDTO struct {
|
|
|
}
|
|
|
|
|
|
type MyMessage struct {
|
|
|
- Id int `json:"messageId"`
|
|
|
- SourceId int `json:"SourceId"`
|
|
|
- Type string `json:"Type"`
|
|
|
- Message string `json:"Message"`
|
|
|
+ Id int `json:"messageId"`
|
|
|
+ SourceId int `json:"SourceId"`
|
|
|
+ ProductId int `json:"ProductId"`
|
|
|
+ Type string `json:"Type"`
|
|
|
+ Message string `json:"Message"`
|
|
|
}
|
|
|
|
|
|
const (
|
|
@@ -36,6 +38,14 @@ const (
|
|
|
RefundMessageTemplate = "订单:{{.ProductOrderNo}},姓名:{{.RealName}},退款{{.Result}}!"
|
|
|
)
|
|
|
|
|
|
+var (
|
|
|
+ transMap = map[messageDao.SourceType]productDao.MerchantProductType{
|
|
|
+ messageDao.ReportSourceType: productDao.Report,
|
|
|
+ messageDao.VideoSourceType: productDao.Video,
|
|
|
+ messageDao.AudioSourceType: productDao.Audio,
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
type MessageInfo struct {
|
|
|
analyst string
|
|
|
}
|
|
@@ -131,8 +141,15 @@ func GetUnReadMessageList(userId int) (messageList []MyMessage, err error) {
|
|
|
logger.Error("获取我的未读消息失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- for _, message := range list {
|
|
|
- messageList = append(messageList, convertToMyMessage(message))
|
|
|
+ for _, messageDTO := range list {
|
|
|
+ myMessage := convertToMyMessage(messageDTO)
|
|
|
+ product, productErr := productDao.GetMerchantProductBySourceId(messageDTO.SourceId, transMap[messageDTO.Type])
|
|
|
+ if productErr != nil {
|
|
|
+ logger.Error("获取产品信息失败:%v", productErr)
|
|
|
+ } else {
|
|
|
+ myMessage.ProductId = product.Id
|
|
|
+ }
|
|
|
+ messageList = append(messageList, myMessage)
|
|
|
}
|
|
|
return
|
|
|
}
|