|
@@ -5,6 +5,7 @@ import { BaseService } from 'free-midway-component';
|
|
|
import { Room } from '../entity/chat/room.entity';
|
|
|
import get = require('lodash/get');
|
|
|
import { ChatRecord } from '../entity/chat/chatRecord.entity';
|
|
|
+
|
|
|
type modelType = ReturnModelType<typeof Room>;
|
|
|
@Provide()
|
|
|
export class RoomService extends BaseService<modelType> {
|
|
@@ -18,8 +19,8 @@ export class RoomService extends BaseService<modelType> {
|
|
|
}
|
|
|
async countNotRead(filter, data) {
|
|
|
const query: any = { room: data._id, is_read: '0' };
|
|
|
- if (filter.customer) query.speaker = filter.customer;
|
|
|
- else if (filter.shop) query.speaker = filter.shop;
|
|
|
+ if (filter.customer) query.speaker = get(data, 'shop._id');
|
|
|
+ else if (filter.shop) query.speaker = get(data, 'customer._id');
|
|
|
else return data;
|
|
|
const num = await this.chatRecordModel.count(query);
|
|
|
data.not_read = num;
|