|
@@ -73,7 +73,8 @@ func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.Ba
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 发送内容处理下,json_decode
|
|
|
+ // 把 req.Msg 字符串的内容 json_decode 到 msgArray
|
|
|
+ // 然后再把每一条信息都给所有指定的用户记录到 message_records 表
|
|
|
var err error
|
|
|
var msgArray []custom_types.Action
|
|
|
|
|
@@ -84,17 +85,17 @@ func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.Ba
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var actionMessage []custom_types.Action
|
|
|
+ var msgActionList []custom_types.Action
|
|
|
if len(msgArray) > 0 {
|
|
|
- actionMessage = make([]custom_types.Action, len(msgArray))
|
|
|
+ msgActionList = make([]custom_types.Action, len(msgArray))
|
|
|
for i, msg := range msgArray {
|
|
|
if msg.Type == 1 {
|
|
|
- actionMessage[i] = custom_types.Action{
|
|
|
+ msgActionList[i] = custom_types.Action{
|
|
|
Type: msg.Type,
|
|
|
Content: msg.Content,
|
|
|
}
|
|
|
} else {
|
|
|
- actionMessage[i] = custom_types.Action{
|
|
|
+ msgActionList[i] = custom_types.Action{
|
|
|
Type: msg.Type,
|
|
|
Content: msg.Content,
|
|
|
Meta: &custom_types.Meta{
|
|
@@ -150,6 +151,9 @@ func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.Ba
|
|
|
|
|
|
// 开始事务
|
|
|
tx, err := l.svcCtx.DB.Tx(context.Background())
|
|
|
+ if err != nil {
|
|
|
+ return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
+ }
|
|
|
|
|
|
_, err = l.svcCtx.DB.BatchMsg.Create().
|
|
|
SetNotNilBatchNo(&batchNo).
|
|
@@ -170,7 +174,7 @@ func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.Ba
|
|
|
for _, user := range userlist {
|
|
|
// 每个用户的所有 信息 组合到一个数组里然后批量插入,减少DB的压力
|
|
|
bulkCreate := make([]*ent.MessageRecordsCreate, 0)
|
|
|
- for _, msg := range actionMessage {
|
|
|
+ for _, msg := range msgActionList {
|
|
|
bulkCreate = append(bulkCreate, l.svcCtx.DB.MessageRecords.Create().
|
|
|
SetStatus(1).
|
|
|
SetNotNilBotWxid(req.Fromwxid).
|