|
@@ -91,21 +91,73 @@ public class IpadSendServer {
|
|
|
if(fsUser != null && StringUtils.isNotEmpty(fsUser.getAppId()) && !"".equals( fsUser.getAppId())){
|
|
if(fsUser != null && StringUtils.isNotEmpty(fsUser.getAppId()) && !"".equals( fsUser.getAppId())){
|
|
|
// 获取用户看过的小程序ID集合
|
|
// 获取用户看过的小程序ID集合
|
|
|
List<String> miniAppList = Arrays.asList(fsUser.getAppId().split(","));
|
|
List<String> miniAppList = Arrays.asList(fsUser.getAppId().split(","));
|
|
|
- // 根据小程序ID查询小程序列表
|
|
|
|
|
List<FsCoursePlaySourceConfig> configList = playSourceConfigService.selectByAppIds(miniAppList);
|
|
List<FsCoursePlaySourceConfig> configList = playSourceConfigService.selectByAppIds(miniAppList);
|
|
|
- //优先筛选半封禁的数据
|
|
|
|
|
- Optional<FsCoursePlaySourceConfig> optional = configList.stream()
|
|
|
|
|
|
|
+ Optional<FsCoursePlaySourceConfig> halfBanned = configList.stream()
|
|
|
.filter(e -> e.getStatus() != null && e.getStatus() == 1)
|
|
.filter(e -> e.getStatus() != null && e.getStatus() == 1)
|
|
|
.findFirst();
|
|
.findFirst();
|
|
|
- //如果没找到半封禁,再找 正常的
|
|
|
|
|
- if (!optional.isPresent()) {
|
|
|
|
|
- optional = configList.stream()
|
|
|
|
|
- .filter(e -> e.getStatus() != null && e.getStatus() == 0)
|
|
|
|
|
- .findFirst();
|
|
|
|
|
- }
|
|
|
|
|
- // 判断是否找到
|
|
|
|
|
- if (optional.isPresent()) {
|
|
|
|
|
- appid = optional.get().getAppid();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (halfBanned.isPresent()) {
|
|
|
|
|
+ appid = halfBanned.get().getAppid();
|
|
|
|
|
+ log.info("ID:{}, qwUserId:{},externalId:{},发送用户看过的半封禁小程序:{}",
|
|
|
|
|
+ vo.getId(), vo.getQwUserId(), vo.getExId(), appid);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<CompanyMiniapp> backupList = list.stream()
|
|
|
|
|
+ .filter(e -> Integer.valueOf(1).equals(e.getType()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ if (!backupList.isEmpty()) {
|
|
|
|
|
+ String backupAppId = backupList.get(0).getAppId();
|
|
|
|
|
+
|
|
|
|
|
+ //检查备用小程序是否在用户看过的列表中
|
|
|
|
|
+ Optional<FsCoursePlaySourceConfig> backupInUserList = configList.stream()
|
|
|
|
|
+ .filter(e -> e.getStatus() != null && e.getStatus() == 0)
|
|
|
|
|
+ .filter(e -> backupAppId.equals(e.getAppid()))
|
|
|
|
|
+ .findFirst();
|
|
|
|
|
+
|
|
|
|
|
+ if (backupInUserList.isPresent()) {
|
|
|
|
|
+ appid = backupInUserList.get().getAppid();
|
|
|
|
|
+ log.info("ID:{}, qwUserId:{},externalId:{},发送用户看过的备用小程序:{}",
|
|
|
|
|
+ vo.getId(), vo.getQwUserId(), vo.getExId(), appid);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //用户没看过这个备用小程序,用第一个正常的
|
|
|
|
|
+ Optional<FsCoursePlaySourceConfig> normal = configList.stream()
|
|
|
|
|
+ .filter(e -> e.getStatus() != null && e.getStatus() == 0)
|
|
|
|
|
+ .findFirst();
|
|
|
|
|
+
|
|
|
|
|
+ if (normal.isPresent()) {
|
|
|
|
|
+ appid = normal.get().getAppid();
|
|
|
|
|
+ log.info("ID:{}, qwUserId:{},externalId:{},发送用户看过的正常小程序:{}",
|
|
|
|
|
+ vo.getId(), vo.getQwUserId(), vo.getExId(), appid);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //用户没看过任何正常小程序,只能用备用小程序
|
|
|
|
|
+ appid = backupAppId;
|
|
|
|
|
+ log.info("ID:{}, qwUserId:{},externalId:{},发送备用小程序(用户没看过):{}",
|
|
|
|
|
+ vo.getId(), vo.getQwUserId(), vo.getExId(), appid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Optional<FsCoursePlaySourceConfig> normal = configList.stream()
|
|
|
|
|
+ .filter(e -> e.getStatus() != null && e.getStatus() == 0)
|
|
|
|
|
+ .findFirst();
|
|
|
|
|
+
|
|
|
|
|
+ if (normal.isPresent()) {
|
|
|
|
|
+ appid = normal.get().getAppid();
|
|
|
|
|
+ log.info("ID:{}, qwUserId:{},externalId:{},发送用户看过的正常小程序(无备用):{}",
|
|
|
|
|
+ vo.getId(), vo.getQwUserId(), vo.getExId(), appid);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<CompanyMiniapp> mainList = list.stream()
|
|
|
|
|
+ .filter(e -> Integer.valueOf(0).equals(e.getType()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if(!mainList.isEmpty()){
|
|
|
|
|
+ appid = mainList.get(0).getAppId();
|
|
|
|
|
+ log.info("ID:{}, qwUserId:{},externalId:{},发送主要小程序:{}",
|
|
|
|
|
+ vo.getId(), vo.getQwUserId(), vo.getExId(), appid);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ log.info("ID:{}, qwUserId:{},externalId:{},销售公司没可用小程序:{}",
|
|
|
|
|
+ vo.getId(), vo.getQwUserId(), vo.getExId(), appid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}else{
|
|
}else{
|
|
|
// 获取用户的创建时间
|
|
// 获取用户的创建时间
|