...
|
...
|
@@ -4,13 +4,20 @@ import com.alibaba.fastjson.JSONException; |
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.yoho.core.common.utils.Marker;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.service.model.response.PageResponseBO;
|
|
|
import com.yoho.service.model.union.request.ChannelMessageRequest;
|
|
|
import com.yoho.service.model.union.request.ChannelUserBO;
|
|
|
import com.yoho.service.model.union.request.ChannelUserRequest;
|
|
|
import com.yoho.service.model.union.response.ChannelMessageDetailBO;
|
|
|
import com.yoho.unions.channel.service.IChannelUserService;
|
|
|
import com.yoho.unions.common.service.IBusinessExportService;
|
|
|
import com.yoho.unions.dal.IChannelGroupBatchDAO;
|
|
|
import com.yoho.unions.dal.IChannelSmsDetailDAO;
|
|
|
import com.yoho.unions.dal.IChannelUserDAO;
|
|
|
import com.yoho.unions.dal.model.ChannelGroupBatch;
|
|
|
import com.yoho.unions.dal.model.ChannelSmsDetail;
|
|
|
import com.yoho.unions.dal.model.ChannelUser;
|
|
|
import com.yoho.unions.utils.MapUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
...
|
...
|
@@ -24,6 +31,10 @@ import org.springframework.stereotype.Service; |
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.yoho.unions.common.utils.YHPreconditions.*;
|
|
|
|
|
|
/**
|
|
|
* 范渠道用户管理
|
...
|
...
|
@@ -37,6 +48,12 @@ public class ChannelUserServiceImpl implements IChannelUserService, IBusinessExp |
|
|
@Autowired
|
|
|
private IChannelUserDAO channelUserDAO;
|
|
|
|
|
|
@Autowired
|
|
|
private IChannelSmsDetailDAO channelSmsDetailDAO;
|
|
|
|
|
|
@Autowired
|
|
|
private IChannelGroupBatchDAO channelGroupBatchDAO;
|
|
|
|
|
|
@Override
|
|
|
public PageResponseBO<ChannelUserBO> list(ChannelUserRequest request) {
|
|
|
// 设置查询参数
|
...
|
...
|
@@ -59,6 +76,7 @@ public class ChannelUserServiceImpl implements IChannelUserService, IBusinessExp |
|
|
List<ChannelUserBO> list = Lists.transform(users, input -> {
|
|
|
ChannelUserBO output = new ChannelUserBO();
|
|
|
BeanUtils.copyProperties(input, output);
|
|
|
output.setMobile(Marker.maskNumber(input.getMobile()));
|
|
|
return output;
|
|
|
});
|
|
|
|
...
|
...
|
@@ -118,6 +136,49 @@ public class ChannelUserServiceImpl implements IChannelUserService, IBusinessExp |
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageResponseBO<ChannelMessageDetailBO> listMessage(ChannelMessageRequest request) {
|
|
|
|
|
|
ChannelUser channelUser = channelUserDAO.selectByPrimaryKey(request.getId());
|
|
|
checkNotNull(channelUser, "用户为空");
|
|
|
request.setMobile(channelUser.getMobile());
|
|
|
|
|
|
checkArgument(StringUtils.isNotBlank(request.getMobile()), "手机号不能为空");
|
|
|
|
|
|
// 先查手机号的发送记录
|
|
|
int count = channelSmsDetailDAO.selectCount(request.getMobile());
|
|
|
request.checkCurrentPage(count);
|
|
|
|
|
|
// 查询列表
|
|
|
List<ChannelSmsDetail> details = Collections.emptyList();
|
|
|
if (count > 0) {
|
|
|
details = channelSmsDetailDAO.selectPage(request.getMobile(), request.getStart(), request.getSize());
|
|
|
}
|
|
|
// 然后查询批次内容
|
|
|
List<Integer> batchIds = details.stream().map(ChannelSmsDetail::getGroupBatchId).collect(Collectors.toList());
|
|
|
List<ChannelGroupBatch> batchList = channelGroupBatchDAO.selectBatch(batchIds);
|
|
|
Map<Integer, ChannelGroupBatch> batchMap = batchList.stream().collect(Collectors.toMap(ChannelGroupBatch::getId, Function.identity()));
|
|
|
|
|
|
// 内容组装
|
|
|
List<ChannelMessageDetailBO> list = Lists.transform(details, input -> {
|
|
|
ChannelMessageDetailBO output = new ChannelMessageDetailBO();
|
|
|
output.setGroupBatchId(input.getGroupBatchId());
|
|
|
output.setStatus(input.getStatus() == null ? 0 : Integer.valueOf(input.getStatus()));
|
|
|
output.setSendTime(input.getCreateTime());
|
|
|
ChannelGroupBatch batch = batchMap.get(input.getGroupBatchId());
|
|
|
if (batch != null) {
|
|
|
output.setContent(batch.getContent());
|
|
|
}
|
|
|
return output;
|
|
|
});
|
|
|
|
|
|
// 设置返回参数
|
|
|
PageResponseBO<ChannelMessageDetailBO> page = new PageResponseBO<>();
|
|
|
page.setPage(request.getPage());
|
|
|
page.setPageSize(request.getSize());
|
|
|
page.setTotal(count);
|
|
|
page.setList(list);
|
|
|
|
|
|
return page;
|
|
|
}
|
|
|
} |
...
|
...
|
|