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