|
@@ -11,7 +11,6 @@ import com.google.common.collect.Lists;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.StudentDao;
|
|
|
-import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
|
|
@@ -19,29 +18,25 @@ import com.yonge.cooleshow.biz.dal.enums.PeriodEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.*;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
-import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.StudentVo;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupAlbumWrapper;
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.UserTenantAlbumRecordWrapper;
|
|
|
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
-import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.yonge.toolset.utils.obj.ObjectUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
import org.joda.time.DateTime;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import com.yonge.cooleshow.biz.dal.wrapper.UserTenantAlbumRecordWrapper;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -63,12 +58,6 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
private TenantInfoService tenantInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
- private TenantAlbumMusicService tenantAlbumMusicService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private MusicSheetService musicSheetService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private StudentService studentService;
|
|
|
|
|
|
@Autowired
|
|
@@ -81,9 +70,6 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
private StudentDao studentDao;
|
|
|
|
|
|
@Autowired
|
|
|
- private TenantAlbumPurchaseMapper tenantAlbumPurchaseMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private UserTenantAlbumRecordService userTenantAlbumRecordService;
|
|
|
|
|
|
|
|
@@ -100,9 +86,6 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
private SysUserMapper sysUserMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private TenantInfoMapper tenantInfoMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private TenantGroupAlbumService tenantGroupAlbumService;
|
|
|
|
|
|
|
|
@@ -665,25 +648,31 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
|
|
|
@Override
|
|
|
public void sendTenantAlbumMessage() {
|
|
|
+ //3天内到期的专辑
|
|
|
List<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> userTenantAlbumRecords = baseMapper.selectTemporaryRecord();
|
|
|
- if (CollectionUtils.isEmpty(userTenantAlbumRecords)) {
|
|
|
- return;
|
|
|
+ if (CollectionUtils.isNotEmpty(userTenantAlbumRecords)) {
|
|
|
+ //获取专辑名称
|
|
|
+ List<Long> tenantAlbumIds = userTenantAlbumRecords.stream().map(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord::getTenantAlbumId).collect(Collectors.toList());
|
|
|
+ Map<Long, String> albumIdMap = tenantAlbumService.lambdaQuery()
|
|
|
+ .in(TenantAlbum::getId, tenantAlbumIds)
|
|
|
+ .list().stream().collect(Collectors.toMap(TenantAlbum::getId, TenantAlbum::getName));
|
|
|
+ //发送消息
|
|
|
+ userTenantAlbumRecords.forEach(record -> temporary3DaySend(record.getUserId(),record.getPhone(), albumIdMap.get(record.getTenantAlbumId())));
|
|
|
+ List<Long> ids = userTenantAlbumRecords.stream().map(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord::getId).collect(Collectors.toList());
|
|
|
+ baseMapper.updateMsgStatus(ids,1);
|
|
|
}
|
|
|
- //标识
|
|
|
- Map<Long, Long> temporaryFlagMap = new HashMap<>();
|
|
|
- for (UserTenantAlbumRecordWrapper.UserTenantAlbumRecord record : userTenantAlbumRecords) {
|
|
|
- if (null != temporaryFlagMap.get(record.getUserId())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- temporaryFlagMap.put(record.getUserId(), record.getUserId());
|
|
|
+ //即将到期的专辑
|
|
|
+ List<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> userTenantAlbumRecords1 = baseMapper.selectTemporaryRecord1();
|
|
|
+ if (CollectionUtils.isNotEmpty(userTenantAlbumRecords1)) {
|
|
|
+ //获取专辑名称
|
|
|
+ List<Long> tenantAlbumIds = userTenantAlbumRecords1.stream().map(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord::getTenantAlbumId).collect(Collectors.toList());
|
|
|
+ Map<Long, String> albumIdMap = tenantAlbumService.lambdaQuery()
|
|
|
+ .in(TenantAlbum::getId, tenantAlbumIds)
|
|
|
+ .list().stream().collect(Collectors.toMap(TenantAlbum::getId, TenantAlbum::getName));
|
|
|
//发送消息
|
|
|
- CompletableFuture.runAsync(() -> temporarySend(record.getUserId(), record.getTenantAlbumId()));
|
|
|
- UserTenantAlbumRecord userTenantAlbumRecord = new UserTenantAlbumRecord();
|
|
|
- userTenantAlbumRecord.setMsgStatus(true);
|
|
|
- userTenantAlbumRecord.setUpdateTime(new Date());
|
|
|
- userTenantAlbumRecord.setId(record.getId());
|
|
|
-
|
|
|
- baseMapper.updateById(userTenantAlbumRecord);
|
|
|
+ userTenantAlbumRecords1.forEach(record -> temporarySend(record.getUserId(),record.getPhone(), albumIdMap.get(record.getTenantAlbumId())));
|
|
|
+ List<Long> ids = userTenantAlbumRecords1.stream().map(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord::getId).collect(Collectors.toList());
|
|
|
+ baseMapper.updateMsgStatus(ids,2);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -748,21 +737,24 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void temporarySend(Long userId, Long tenantAlbumId) {
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserById(userId);
|
|
|
- if (null == sysUser) {
|
|
|
- return;
|
|
|
- }
|
|
|
- TenantAlbum tenantAlbum = tenantAlbumService.getById(tenantAlbumId);
|
|
|
- if (tenantAlbum == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ private void temporary3DaySend(Long userId,String phone, String tenantAlbumName) {
|
|
|
Map<Long, String> receivers = new HashMap<>();
|
|
|
- receivers.put(userId, sysUser.getPhone());
|
|
|
+ receivers.put(userId, phone);
|
|
|
+ try {
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TENANT_ALBUM_EXPIRE_THIRTY_DAY,
|
|
|
+ receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(),tenantAlbumName);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("机构学生训练教材过期", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ private void temporarySend(Long userId,String phone, String tenantAlbumName) {
|
|
|
+ Map<Long, String> receivers = new HashMap<>();
|
|
|
+ receivers.put(userId, phone);
|
|
|
try {
|
|
|
sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TENANT_ALBUM_EXPIRE,
|
|
|
- receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(), tenantAlbum.getName());
|
|
|
+ receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(),tenantAlbumName);
|
|
|
} catch (Exception e) {
|
|
|
log.error("机构学生训练教材过期", e);
|
|
|
}
|