Browse Source

fix:edit batch_msg/create,list

jimmyyem 9 months ago
parent
commit
3010aadad7
1 changed files with 3 additions and 3 deletions
  1. 3 3
      internal/logic/batch_msg/create_batch_msg_logic.go

+ 3 - 3
internal/logic/batch_msg/create_batch_msg_logic.go

@@ -166,6 +166,7 @@ func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.Ba
 		SetNotNilMsg(req.Msg).
 		SetNotNilTag(req.Tag).
 		SetTotal(total).
+		SetNotNilTaskName(req.TaskName).
 		SetNotNilStartTime(&startTime).
 		SetNotNilSendTime(&sendTime).
 		Save(l.ctx)
@@ -176,10 +177,10 @@ func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.Ba
 	}
 
 	// 批量记录信息到 message_records 表里
-	for idx, user := range userlist {
+	for _, user := range userlist {
 		// 每个用户的所有 信息 组合到一个数组里然后批量插入,减少DB的压力
 		bulkCreate := make([]*ent.MessageRecordsCreate, 0)
-		for _, msg := range msgActionList {
+		for idx, msg := range msgActionList {
 			bulkCreate = append(bulkCreate, l.svcCtx.DB.MessageRecords.Create().
 				SetStatus(1).
 				SetNotNilBotWxid(req.Fromwxid).
@@ -195,7 +196,6 @@ func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.Ba
 				SetSubSourceID(uint64(idx)).      // 用索引作为 sub_source_id
 				SetOrganizationID(organizationId),
 			)
-			randSubSourceId++
 		}
 		err = l.svcCtx.DB.MessageRecords.CreateBulk(bulkCreate...).Exec(l.ctx)
 		if err != nil {