|
@@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
+import com.fjhx.customer.entity.customer.po.CustomerUser;
|
|
|
import com.fjhx.customer.entity.customer.vo.CustomerVo;
|
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
|
+import com.fjhx.customer.service.customer.CustomerUserService;
|
|
|
import com.fjhx.mail.config.MailServiceConfig;
|
|
|
import com.fjhx.mail.entity.dto.GetMessagePageDto;
|
|
|
import com.fjhx.mail.entity.enterprise.po.EnterpriseDomain;
|
|
@@ -84,6 +86,8 @@ public class InfoServiceImpl implements InfoService {
|
|
|
private PersonalMessageMapper personalMessageMapper;
|
|
|
@Autowired
|
|
|
private CustomerService customerService;
|
|
|
+ @Autowired
|
|
|
+ private CustomerUserService customerUserService;
|
|
|
|
|
|
@Override
|
|
|
public List<SysUser> getUserList() {
|
|
@@ -247,6 +251,7 @@ public class InfoServiceImpl implements InfoService {
|
|
|
|
|
|
@Override
|
|
|
public Object getMessagePage(GetMessagePageDto dto) {
|
|
|
+ String keyword = dto.getKeyword();
|
|
|
|
|
|
Page<MessageVo> page;
|
|
|
|
|
@@ -264,15 +269,14 @@ public class InfoServiceImpl implements InfoService {
|
|
|
}
|
|
|
|
|
|
wrapper.eq(ObjectUtil.isNotEmpty(dto.getFolderId()), "pm.folder_id", dto.getFolderId());
|
|
|
- wrapper.and(ObjectUtil.isNotEmpty(dto.getKeyword()), q1 -> q1
|
|
|
- .like("pm.from_email", dto.getKeyword())
|
|
|
- .or().like("pm.subject", dto.getKeyword())
|
|
|
- .or().like("pmc.content", dto.getKeyword())
|
|
|
- .or().like("c.name", dto.getKeyword())
|
|
|
- .or().like("cu.name", dto.getKeyword())
|
|
|
- .or().like("pm.from_personal_name", dto.getKeyword())
|
|
|
+ wrapper.and(ObjectUtil.isNotEmpty(keyword), q1 -> q1
|
|
|
+ .like("pm.from_email", keyword)
|
|
|
+ .or().like("pm.subject", keyword)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ .or().like("pm.from_personal_name", keyword)
|
|
|
);
|
|
|
- wrapper.groupBy("pm.id");
|
|
|
wrapper.orderByDesc("pm.send_date");
|
|
|
page = personalMessageMapper.getPage(dto.getPage(), wrapper, SecurityUtils.getTenantId());
|
|
|
|
|
@@ -294,17 +298,22 @@ public class InfoServiceImpl implements InfoService {
|
|
|
wrapper.eq(ObjectUtil.isNotEmpty(dto.getMailboxId()), "em.mailbox_id", dto.getMailboxId());
|
|
|
|
|
|
wrapper.eq(ObjectUtil.isNotEmpty(dto.getFolderId()), "em.folder_id", dto.getFolderId());
|
|
|
- wrapper.and(ObjectUtil.isNotEmpty(dto.getKeyword()), q1 -> q1
|
|
|
- .like("em.from_email", dto.getKeyword())
|
|
|
- .or().like("em.subject", dto.getKeyword())
|
|
|
- .or().like("emc.content", dto.getKeyword())
|
|
|
- .or().like("c.name", dto.getKeyword())
|
|
|
- .or().like("cu.name", dto.getKeyword())
|
|
|
- .or().like("em.from_personal_name", dto.getKeyword())
|
|
|
- );
|
|
|
- wrapper.groupBy("em.id");
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(keyword)) {
|
|
|
+
|
|
|
+ wrapper.and(ObjectUtil.isNotEmpty(dto.getKeyword()), q1 -> q1
|
|
|
+ .like("em.from_email", dto.getKeyword())
|
|
|
+ .or().like("em.subject", dto.getKeyword())
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ .or().like("em.from_personal_name", dto.getKeyword())
|
|
|
+
|
|
|
+ );
|
|
|
+ }
|
|
|
wrapper.orderByDesc("em.send_date");
|
|
|
- page = enterpriseMessageMapper.getPage(dto.getPage(), wrapper, SecurityUtils.getTenantId());
|
|
|
+ page = enterpriseMessageMapper
|
|
|
+ .getPage(dto.getPage(), wrapper, SecurityUtils.getTenantId(), keyword);
|
|
|
|
|
|
if (page.getSize() == 0) {
|
|
|
return page;
|
|
@@ -319,13 +328,20 @@ public class InfoServiceImpl implements InfoService {
|
|
|
}
|
|
|
|
|
|
List<MessageVo> records = page.getRecords();
|
|
|
- List<Long> customerIds = records.stream().map(MessageVo::getCustomerId).collect(Collectors.toList());
|
|
|
|
|
|
-
|
|
|
- List<CustomerVo> customerInfoByIds = customerService.getCustomerInfoByIds(customerIds);
|
|
|
- Map<Long, CustomerVo> customerInfoMap = customerInfoByIds.stream().collect(Collectors.toMap(CustomerVo::getId, Function.identity()));
|
|
|
- for (MessageVo record : records) {
|
|
|
- record.setCustomerInfo(customerInfoMap.get(record.getCustomerId()));
|
|
|
+
|
|
|
+ List<String> eMailList = records.stream().map(MessageVo::getFromEmail).distinct().collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(eMailList)) {
|
|
|
+ List<Long> customerIds = customerUserService.listObject(CustomerUser::getCustomerId, q -> q.in(CustomerUser::getEmail, eMailList));
|
|
|
+ if (ObjectUtil.isEmpty(customerIds)) {
|
|
|
+ return R.ok(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CustomerVo> customerInfoByIds = customerService.getCustomerInfoByIds(customerIds);
|
|
|
+ Map<Long, CustomerVo> customerInfoMap = customerInfoByIds.stream().collect(Collectors.toMap(CustomerVo::getId, Function.identity()));
|
|
|
+ for (MessageVo record : records) {
|
|
|
+ record.setCustomerInfo(customerInfoMap.get(record.getCustomerId()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return R.ok(page);
|