|
@@ -625,7 +625,8 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
|
|
|
}
|
|
|
switch in.MsgType {
|
|
|
case 2: //点对点聊天
|
|
|
- sqlStr = fmt.Sprintf("SELECT a.messag_id as messageId,a.send_user_type,a.type AS itemType,b.* ,if(a.own_id = a.send_user_id,1,2) as fool "+
|
|
|
+ sqlStr = fmt.Sprintf("SELECT a.messag_id as messageId,a.send_user_type,a.type AS itemType,b.* ,if(a.own_id = a.send_user_id,1,2) as fool, "+
|
|
|
+ "IF ( a.own_id = a.send_user_id, 0, a.send_user_id ) AS send_position_id "+
|
|
|
"FROM %s a "+
|
|
|
"LEFT JOIN %s b on a.messag_id=b.id "+
|
|
|
"LEFT JOIN %s c on c.id=a.send_user_id "+
|
|
@@ -647,7 +648,7 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
|
|
|
"IF ( a.own_id = a.send_user_id, 0, a.send_user_id ) AS send_position_id,"+
|
|
|
"a.send_user_type,a.type AS itemType FROM %s a "+
|
|
|
"LEFT JOIN %s b ON a.messag_id = b.id "+
|
|
|
- "WHERE a.own_type = 2 AND a.own_id = %d "+
|
|
|
+ "WHERE a.own_type = 2 and a.iswithdraw = 0 AND a.own_id = %d "+
|
|
|
"AND a.chat_group_id = %d AND a.type IN ( 3, 6 ) %s "+
|
|
|
"ORDER BY a.create_time desc,a.id DESC "+
|
|
|
"LIMIT 0, %d",
|
|
@@ -709,9 +710,10 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
|
|
|
_, _, positionData := EntPerson(in.EntId, true)
|
|
|
for _, v := range *data {
|
|
|
positionId := quitl.IntAll(v["send_position_id"])
|
|
|
+ log.Println("________", positionData[positionId])
|
|
|
if positionId != 0 {
|
|
|
v["userName"] = positionData[positionId]
|
|
|
- //log.Println(v["userName"], positionData[positionId])
|
|
|
+ log.Println(v["userName"], positionData[positionId])
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -726,7 +728,7 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
|
|
|
|
|
|
updateMap = map[string]interface{}{
|
|
|
"own_type": 2,
|
|
|
- "own_id": in.NewUserId,
|
|
|
+ "own_id": in.PositionId,
|
|
|
"send_user_id": in.SendId,
|
|
|
"type": 2,
|
|
|
"isread": 0,
|
|
@@ -734,7 +736,7 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
|
|
|
IC.BaseMysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap, map[string]interface{}{"isread": 1, "read_time": time.Now().Local().Format(util.Date_Full_Layout)})
|
|
|
//更新socialize_summary表未读消息数量
|
|
|
updateQuery := map[string]interface{}{
|
|
|
- "my_position_id": in.NewUserId,
|
|
|
+ "my_position_id": in.PositionId,
|
|
|
"your_position_id": in.SendId,
|
|
|
}
|
|
|
IC.BaseMysql.Update(util.SOCIALIZE_SUMMARY, updateQuery, map[string]interface{}{"unread": 0})
|
|
@@ -749,7 +751,7 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
|
|
|
IC.BaseMysql.UpdateOrDeleteBySql(sqlStr)
|
|
|
//更新socialize_summary表未读消息数量
|
|
|
updateQuery := map[string]interface{}{
|
|
|
- "my_position_id": in.NewUserId,
|
|
|
+ "my_position_id": in.PositionId,
|
|
|
"chat_group_id": in.ChatGroupId,
|
|
|
}
|
|
|
IC.BaseMysql.Update(util.SOCIALIZE_SUMMARY, updateQuery, map[string]interface{}{"unread": 0})
|
|
@@ -763,14 +765,14 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
|
|
|
"AND a.isread = 0 "+
|
|
|
"AND a.own_id IN (SELECT id FROM %s WHERE user_id = %d)",
|
|
|
util.SOCIALIZE_MESSAGE_MAILBOX, util.BASE_POSITION, in.NewUserId)
|
|
|
- unreadSql = fmt.Sprintf("UPDATE %s SET unread = 0 WHERE user_id = %d", util.Socialize_customer_service_user, in.NewUserId)
|
|
|
+ unreadSql = fmt.Sprintf("UPDATE %s SET unread = 0 WHERE user_id = %d AND customer_service_id = %d", util.Socialize_customer_service_user, in.NewUserId, in.EntUserId)
|
|
|
} else { //2用户
|
|
|
sqlStr = fmt.Sprintf("UPDATE %s a SET a.isread = 1, a.read_time = now( ) "+
|
|
|
"WHERE a.own_type = 2 and a.iswithdraw = 0 "+
|
|
|
"AND a.type IN ( 4,5,6,7 ) "+
|
|
|
"AND a.isread = 0 "+
|
|
|
"AND a.own_id in (%s) ", util.SOCIALIZE_MESSAGE_MAILBOX, positionStr)
|
|
|
- unreadSql = fmt.Sprintf("UPDATE %s SET unread = 0 WHERE user_id = %d", util.SOCIALIZE_SUMMARY, in.NewUserId)
|
|
|
+ unreadSql = fmt.Sprintf("UPDATE %s SET unread = 0 WHERE user_id = %d AND ent_id = %d", util.SOCIALIZE_SUMMARY, in.NewUserId, in.EntId)
|
|
|
}
|
|
|
IC.BaseMysql.UpdateOrDeleteBySql(sqlStr)
|
|
|
IC.BaseMysql.UpdateOrDeleteBySql(unreadSql)
|