From c6e1a412882b80aff448bc0c28405522e51be04c Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 30 Jul 2024 12:15:01 +0800 Subject: [PATCH] by Robin at 20240730; add delay --- apollostruct/auto_response.go | 1 + app/mix/service/apiservice.go | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/apollostruct/auto_response.go b/apollostruct/auto_response.go index 6703fb53..925c3cf1 100644 --- a/apollostruct/auto_response.go +++ b/apollostruct/auto_response.go @@ -3,5 +3,6 @@ package apollostruct type AutoResponseCfg struct { StartTime string `json:"start_time"` EndTime string `json:"end_time"` + Delay int64 `json:"delay"` Message string `json:"message"` } diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 6f15069e..89e0428e 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2022,19 +2022,20 @@ func (s *Service) ApiCreateContactCustomerService(ctx *gin.Context, req *contact return } if createTimes.CreateTimes == 0 { - err := _DefaultContactCustomerService.OpCreate(ctx, &contact_customer_service_proto.OpCreateReq{ - ContactCustomerService: &dbstruct.ContactCustomerService{ - SessionId: req.ContactCustomerService.SessionId, - Predicate: goproto.Int64(consts.ContactCustomerService_FromSupportor), - Message: goproto.String(cfg.Message), - IsRead: goproto.Int64(consts.ContactCustomerService_NotRead), - }, - }) - if err != nil { - logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeContactCustomerServiceSrvFail - return - } + go func() { + time.Sleep(time.Duration(cfg.Delay) * time.Second) + err := _DefaultContactCustomerService.OpCreate(ctx, &contact_customer_service_proto.OpCreateReq{ + ContactCustomerService: &dbstruct.ContactCustomerService{ + SessionId: req.ContactCustomerService.SessionId, + Predicate: goproto.Int64(consts.ContactCustomerService_FromSupportor), + Message: goproto.String(cfg.Message), + IsRead: goproto.Int64(consts.ContactCustomerService_NotRead), + }, + }) + if err != nil { + logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) + } + }() isAutoResponsed = consts.ContactCustomerService_AutoResponsed } }