Browse Source

Merge branch 'fixbug/20250322' into debug

jimmyyem 1 month ago
parent
commit
5d986e3f50

+ 2 - 0
desc/wechat/batch_msg.api

@@ -16,6 +16,8 @@ type (
 
         // 发送方微信ID 
         Fromwxid  *string `json:"fromwxid,optional"`
+		// 发送方微信称呼
+		FromName  *string `json:"fromName,optional"`
 
         // 内容 
         Msg  *string `json:"msg,optional"`

+ 25 - 0
internal/logic/batch_msg/get_batch_msg_list_logic.go

@@ -2,6 +2,7 @@ package batch_msg
 
 import (
 	"context"
+	"wechat-api/ent/wx"
 
 	"wechat-api/ent/batchmsg"
 	"wechat-api/ent/predicate"
@@ -63,7 +64,17 @@ func (l *GetBatchMsgListLogic) GetBatchMsgList(req *types.BatchMsgListReq) (*typ
 	resp.Msg = errormsg.Success
 	resp.Data.Total = data.PageDetails.Total
 
+	batchMsgWxId := make([]string, 0, len(resp.Data.Data))
 	for _, v := range data.List {
+		batchMsgWxId = append(batchMsgWxId, v.Fromwxid)
+	}
+	batchMsgWxName := l.getBatchMsgWxName(batchMsgWxId)
+
+	for _, v := range data.List {
+		fromName, ok := batchMsgWxName[v.Fromwxid]
+		if !ok {
+			fromName = ""
+		}
 		resp.Data.Data = append(resp.Data.Data,
 			types.BatchMsgInfo{
 				BaseIDInfo: types.BaseIDInfo{
@@ -75,6 +86,7 @@ func (l *GetBatchMsgListLogic) GetBatchMsgList(req *types.BatchMsgListReq) (*typ
 				BatchNo:      &v.BatchNo,
 				TaskName:     &v.TaskName,
 				Fromwxid:     &v.Fromwxid,
+				FromName:     &fromName,
 				Msg:          &v.Msg,
 				Tag:          &v.Tag,
 				Total:        &v.Total,
@@ -90,3 +102,16 @@ func (l *GetBatchMsgListLogic) GetBatchMsgList(req *types.BatchMsgListReq) (*typ
 
 	return resp, nil
 }
+
+// GetBatchMsgListLogic() 批量根据wxid获取昵称
+func (l *GetBatchMsgListLogic) getBatchMsgWxName(batchMsgWxId []string) map[string]string {
+	batchMsgWxName := make(map[string]string)
+	list, err := l.svcCtx.DB.Wx.Query().Where(wx.WxidIn(batchMsgWxId...)).All(l.ctx)
+	if err != nil {
+		return batchMsgWxName
+	}
+	for _, v := range list {
+		batchMsgWxName[v.Wxid] = v.Nickname
+	}
+	return batchMsgWxName
+}

+ 1 - 1
internal/logic/sop_task/get_sop_task_by_id_logic.go

@@ -34,7 +34,7 @@ func (l *GetSopTaskByIdLogic) GetSopTaskById(req *types.IDReq) (*types.SopTaskIn
 	data, err := l.svcCtx.DB.SopTask.Query().
 		Where(soptask.ID(req.Id), soptask.OrganizationIDEQ(organizationId)).
 		WithTaskStages(func(q *ent.SopStageQuery) {
-			q.Order(ent.Asc("index_sort"))
+			q.Order(ent.Asc("index_sort"), ent.Desc("updated_at"))
 		}).
 		Only(l.ctx)
 	if err != nil {

+ 0 - 4
internal/logic/sop_task/update_sop_task_logic.go

@@ -36,10 +36,6 @@ func (l *UpdateSopTaskLogic) UpdateSopTask(req *types.SopTaskInfo) (*types.BaseM
 		return nil, dberrorhandler.DefaultEntError(l.Logger, fmt.Errorf("planEndTime must be greater than planStartTime"), req)
 	}
 
-	if len(req.BotWxidList) == 0 {
-		return nil, errorx.NewInvalidArgumentError("发信人不能为空")
-	}
-
 	err := l.svcCtx.DB.SopTask.UpdateOneID(*req.Id).
 		Where(soptask.StatusEQ(1), soptask.OrganizationID(organizationId)).
 		SetNotNilStatus(req.Status).

+ 2 - 0
internal/types/types.go

@@ -2094,6 +2094,8 @@ type BatchMsgInfo struct {
 	TaskName *string `json:"taskName,optional"`
 	// 发送方微信ID
 	Fromwxid *string `json:"fromwxid,optional"`
+	// 发送方微信称呼
+	FromName *string `json:"fromName,optional"`
 	// 内容
 	Msg *string `json:"msg,optional"`
 	// 发送规则 all 全部 tag1,tag2 按tag发送