Эх сурвалжийг харах

fix:信息撤回api接口修改

duxin 2 жил өмнө
parent
commit
3fac2934f7

+ 2 - 5
api/messagecenter/internal/logic/userlistlogic.go

@@ -1,11 +1,10 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
-	"context"
-
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+	"context"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -43,7 +42,5 @@ func (l *UserListLogic) UserList(req *types.UserReq) (*types.CommonRes, error) {
 	return &types.CommonRes{
 		Error_msg:  resp.ErrorMsg,
 		Error_code: int(resp.ErrorCode),
-		Data:       resp.Data,
-		Count:      resp.Count,
 	}, nil
 }

+ 6 - 8
api/messagecenter/internal/logic/withdrawmessagelogic.go

@@ -1,12 +1,10 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
-	"context"
-	"errors"
-
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+	"context"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -37,8 +35,8 @@ func (l *WithdrawMessageLogic) WithdrawMessage(req *types.ReadWithdrawReq) (resp
 	if err != nil {
 		return nil, err
 	}
-	if r.ErrorCode != 0 {
-		return nil, errors.New(r.ErrorMsg)
-	}
-	return
+	return &types.CommonRes{
+		Error_msg:  r.ErrorMsg,
+		Error_code: int(r.ErrorCode),
+	}, nil
 }

+ 2 - 2
api/messagecenter/internal/types/types.go

@@ -88,8 +88,8 @@ type ReadStateReq struct {
 
 type ReadWithdrawReq struct {
 	MessageId string `json:"messageId"`
-	EntUserId int64  `json:"entUserId"`
+	EntUserId string `json:"entUserId"`
 	Appid     string `header:"appid"`
-	NewUserId int64  `json:"newUserId"`
+	NewUserId string `json:"newUserId"`
 	UserType  int64  `json:"userType"`
 }

+ 2 - 2
api/messagecenter/messagecenter.api

@@ -78,9 +78,9 @@ type ReadStateReq {
 
 type ReadWithdrawReq {
 	MessageId string `json:"messageId"`
-	EntUserId int64  `json:"entUserId"`
+	EntUserId string `json:"entUserId"`
 	Appid     string `header:"appid"`
-	NewUserId int64  `json:"newUserId"`
+	NewUserId string `json:"newUserId"`
 	UserType  int64  `json:"userType"`
 }
 service messagecenter-api {

+ 3 - 5
rpc/messagecenter/internal/logic/withdrawmessagelogic.go

@@ -2,11 +2,10 @@ package logic
 
 import (
 	util "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
-	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/service"
-	"context"
-
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/service"
+	"context"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -36,7 +35,6 @@ func (l *WithdrawMessageLogic) WithdrawMessage(in *messagecenter.ReadWithdrawReq
 			ErrorMsg:  "撤回消息失败",
 		}, nil
 	}
-
 	return &messagecenter.CurrencyResp{ErrorCode: util.SUCCESS_CODE,
-		ErrorMsg: ""}, nil
+		ErrorMsg: "撤回消息成功"}, nil
 }

+ 2 - 2
rpc/messagecenter/messagecenter.proto

@@ -122,9 +122,9 @@ message ReadStateReq {
 
 message ReadWithdrawReq {
   string         messageId = 1;
-  int64        entUserId = 2;
+  string        entUserId = 2;
   string        appid=3;
-  int64 newUserId = 4;
+  string newUserId = 4;
   int64     userType=6;      //用户类型:2用户1客服
 }
 

+ 8 - 8
rpc/messagecenter/messagecenter/messagecenter.pb.go

@@ -1268,9 +1268,9 @@ type ReadWithdrawReq struct {
 	unknownFields protoimpl.UnknownFields
 
 	MessageId string `protobuf:"bytes,1,opt,name=messageId,proto3" json:"messageId,omitempty"`
-	EntUserId int64  `protobuf:"varint,2,opt,name=entUserId,proto3" json:"entUserId,omitempty"`
+	EntUserId string `protobuf:"bytes,2,opt,name=entUserId,proto3" json:"entUserId,omitempty"`
 	Appid     string `protobuf:"bytes,3,opt,name=appid,proto3" json:"appid,omitempty"`
-	NewUserId int64  `protobuf:"varint,4,opt,name=newUserId,proto3" json:"newUserId,omitempty"`
+	NewUserId string `protobuf:"bytes,4,opt,name=newUserId,proto3" json:"newUserId,omitempty"`
 	UserType  int64  `protobuf:"varint,6,opt,name=userType,proto3" json:"userType,omitempty"` //用户类型:2用户1客服
 }
 
@@ -1313,11 +1313,11 @@ func (x *ReadWithdrawReq) GetMessageId() string {
 	return ""
 }
 
-func (x *ReadWithdrawReq) GetEntUserId() int64 {
+func (x *ReadWithdrawReq) GetEntUserId() string {
 	if x != nil {
 		return x.EntUserId
 	}
-	return 0
+	return ""
 }
 
 func (x *ReadWithdrawReq) GetAppid() string {
@@ -1327,11 +1327,11 @@ func (x *ReadWithdrawReq) GetAppid() string {
 	return ""
 }
 
-func (x *ReadWithdrawReq) GetNewUserId() int64 {
+func (x *ReadWithdrawReq) GetNewUserId() string {
 	if x != nil {
 		return x.NewUserId
 	}
-	return 0
+	return ""
 }
 
 func (x *ReadWithdrawReq) GetUserType() int64 {
@@ -1573,10 +1573,10 @@ var file_messagecenter_proto_rawDesc = []byte{
 	0x61, 0x77, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
 	0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
 	0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
-	0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49,
+	0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49,
 	0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
 	0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x55, 0x73,
-	0x65, 0x72, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x55,
+	0x65, 0x72, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x55,
 	0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70,
 	0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70,
 	0x65, 0x22, 0x4a, 0x0a, 0x0c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x52, 0x65, 0x73,

+ 15 - 3
service/message_mail_box.go

@@ -158,11 +158,11 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 		if in.StartTime != "" {
 			startTimeSql = "AND  DATE_FORMAT(c.create_time,'%Y-%m-%d') >= '" + in.StartTime + "' "
 		}
-		idSql := fmt.Sprintf("d.customer_service_id = %d or d.customer_service_id =0 ", in.EntUserId)
+		idSql := fmt.Sprintf("(SELECT COUNT(e.id)  FROM socialize_chat_session e WHERE e.customer_service_id > 0 AND e.user_id = d.user_id ) =0 or d.customer_service_id=%d ", in.EntUserId)
 		if in.IsArtificial == 1 {
 			idSql = fmt.Sprintf("d.customer_service_id = %d ", in.EntUserId)
 		} else if in.IsArtificial == 2 {
-			idSql = "d.customer_service_id =0 "
+			idSql = "(SELECT COUNT(e.id)  FROM socialize_chat_session e WHERE e.customer_service_id > 0 AND e.user_id = d.user_id ) =0 "
 		}
 		endTimeSql := ""
 		if in.EndTime != "" {
@@ -681,11 +681,23 @@ func (b MessaggeService) UpdateReadById(in *messagecenter.ReadStateReq) bool {
 // WithdrawMessage 撤回消息
 func (b MessaggeService) WithdrawMessage(in *messagecenter.ReadWithdrawReq) bool {
 	messageId := encrypt.SE.Decode4Hex(in.MessageId)
+	newUserId := encrypt.SE.Decode4Hex(in.NewUserId)
+	entUserId := encrypt.SE.Decode4Hex(in.EntUserId)
+	msg := util.Mysql.FindOne(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId}, "create_time", "")
+	if msg == nil || len(*msg) <= 0 {
+		log.Println("查询消息id失败")
+		return false
+	}
+	createTime, _ := time.Parse(util.Date_Full_Layout, quitl.InterfaceToStr((*msg)["create_time"]))
+	if createTime.Unix()+60*2 < time.Now().Unix() {
+		log.Println("消息已超过2分钟,撤回失败")
+		return false
+	}
 	nowForm := time.Now().Local()
 	m := util.Mysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX,
 		map[string]interface{}{"messag_id": messageId}, map[string]interface{}{"iswithdraw": 1, "withdraw_time": nowForm.Format(util.Date_Full_Layout)})
 	if m {
-		b.Count(in.NewUserId, in.UserType, in.EntUserId, true)
+		b.Count(quitl.Int64All(newUserId), in.UserType, quitl.Int64All(entUserId), true)
 	}
 	return m
 }