|
@@ -166,10 +166,10 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
|
} else {
|
|
|
var timeSql, phoneSql, filtrationSql string
|
|
|
if in.StartTime != "" {
|
|
|
- timeSql += fmt.Sprintf(" AND a.timestamp > '%s'", in.StartTime)
|
|
|
+ timeSql += fmt.Sprintf(" AND a.timestamp >= '%s'", in.StartTime)
|
|
|
}
|
|
|
if in.EndTime != "" {
|
|
|
- timeSql += fmt.Sprintf(" AND a.timestamp < '%s'", in.EndTime)
|
|
|
+ timeSql += fmt.Sprintf(" AND a.timestamp =< '%s'", in.EndTime)
|
|
|
}
|
|
|
if in.Phone != "" {
|
|
|
phoneSql = " AND b.phone like '%" + in.Phone + "%'"
|
|
@@ -504,6 +504,9 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
|
messageMailBox["receive_user_id"] = in.ReceiveId
|
|
|
userType = 1
|
|
|
userId = in.ReceiveId
|
|
|
+ if in.ItemType == 4 {
|
|
|
+ messageMailBox["isread"] = 1
|
|
|
+ }
|
|
|
} else {
|
|
|
//客服发送(用户接收信息)
|
|
|
messageMailBox["own_type"] = 2
|
|
@@ -579,14 +582,14 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
|
return ok > 1 && receiveOk > 1
|
|
|
})
|
|
|
if fool {
|
|
|
- go UserSynchronousList(customer_service_id, userid, entid, message_id, create_time, quitl.Int64All(quitl.If(userType == 1, 2, 1)))
|
|
|
+ go UserSynchronousList(customer_service_id, userid, entid, message_id, create_time, quitl.Int64All(quitl.If(userType == 1, 2, 1)), in.ItemType)
|
|
|
}
|
|
|
return fool, "", in.Content, messageId, nowForm.Unix()
|
|
|
}
|
|
|
|
|
|
// 客服 用户聊天消息列表同步
|
|
|
// sendUserType 发送人类型 1客服 2用户
|
|
|
-func UserSynchronousList(customerServiceId, userId, entId, messageId int64, createTime string, sendUserType int64) {
|
|
|
+func UserSynchronousList(customerServiceId, userId, entId, messageId int64, createTime string, sendUserType, itemType int64) {
|
|
|
log.Printf("同步最后消息参数customerServiceId:%d,userId:%d,entId%d,messageId:%d", customerServiceId, userId, entId, messageId)
|
|
|
/* rwLock.Lock()
|
|
|
defer rwLock.Unlock()*/
|
|
@@ -596,15 +599,21 @@ func UserSynchronousList(customerServiceId, userId, entId, messageId int64, crea
|
|
|
data := IC.BaseMysql.FindOne(util.SOCIALIZE_SUMMARY, map[string]interface{}{"user_id": userId, "ent_id": entId}, "customer_service_access", "")
|
|
|
customer_service_access := 0
|
|
|
if data != nil && len(*data) > 0 {
|
|
|
- if (*data)["customer_service_access"] == 0 && customerServiceId > 0 {
|
|
|
+ if quitl.IntAll((*data)["customer_service_access"]) == 0 && customerServiceId > 0 {
|
|
|
customer_service_access = 1
|
|
|
} else {
|
|
|
customer_service_access = quitl.IntAll((*data)["customer_service_access"])
|
|
|
}
|
|
|
+ log.Println(customer_service_access, "customer_service_access打印", (*data)["customer_service_access"], customerServiceId, quitl.IntAll((*data)["customer_service_access"]) == 0 && customerServiceId > 0)
|
|
|
//更新汇总表
|
|
|
ok := int64(0)
|
|
|
if sendUserType == 1 {
|
|
|
- ok = IC.BaseMysql.UpdateOrDeleteBySql(fmt.Sprintf("UPDATE socialize_summary SET message_id = %d, unread = unread+1, customer_service_access = %d WHERE user_id = %d and ent_id= %d", messageId, customer_service_access, userId, entId))
|
|
|
+ if itemType == 4 {
|
|
|
+ //机器人消息保存处理
|
|
|
+ ok = IC.BaseMysql.UpdateOrDeleteBySql(fmt.Sprintf("UPDATE socialize_summary SET message_id = %d WHERE user_id = %d and ent_id= %d", messageId, customer_service_access, userId, entId))
|
|
|
+ } else {
|
|
|
+ ok = IC.BaseMysql.UpdateOrDeleteBySql(fmt.Sprintf("UPDATE socialize_summary SET message_id = %d, unread = unread+1, customer_service_access = %d WHERE user_id = %d and ent_id= %d", messageId, customer_service_access, userId, entId))
|
|
|
+ }
|
|
|
} else {
|
|
|
ok = IC.BaseMysql.UpdateOrDeleteBySql(fmt.Sprintf("UPDATE socialize_summary SET message_id = %d, customer_service_access = %d WHERE user_id = %d and ent_id= %d", messageId, customer_service_access, userId, entId))
|
|
|
}
|
|
@@ -905,11 +914,12 @@ func (b *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId in
|
|
|
customer_service_id = entUserId
|
|
|
userid = userId
|
|
|
entid = entId
|
|
|
- go UserSynchronousList(customer_service_id, userid, entid, message_id, nowFormat, userType)
|
|
|
+ go UserSynchronousList(customer_service_id, userid, entid, message_id, nowFormat, userType, 6)
|
|
|
}
|
|
|
return ok1, messageId
|
|
|
}
|
|
|
|
|
|
+// 修改未读状态
|
|
|
// 修改未读状态
|
|
|
func (b MessaggeService) UpdateReadById(in *messagecenter.ReadStateReq) {
|
|
|
updateMap := map[string]interface{}{}
|