|
@@ -1,5 +1,6 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -12,19 +13,18 @@ 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.entity.*;
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.PeriodEnum;
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.*;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.*;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.StudentVo;
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.DiscountCardRecordWrapper;
|
|
|
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.thirdparty.message.MessageSenderPluginContext;
|
|
|
+import com.yonge.toolset.utils.date.DateUtil;
|
|
|
import com.yonge.toolset.utils.obj.ObjectUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
@@ -36,6 +36,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -97,6 +100,10 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
|
|
|
@Autowired
|
|
|
private CoursewareFeignService coursewareFeignService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserService sysUserService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询详情
|
|
|
*
|
|
@@ -151,50 +158,6 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
vo.setTenantName(tenantInfo.getName());
|
|
|
vo.setTenantImg(tenantInfo.getLogo());
|
|
|
}
|
|
|
- //查询机构专辑曲目表
|
|
|
-// List<TenantAlbumMusic> tenantAlbumMusics = tenantAlbumMusicService.lambdaQuery()
|
|
|
-// .eq(TenantAlbumMusic::getTenantAlbumId, i.getId())
|
|
|
-// .eq(TenantAlbumMusic::getDelFlag, false)
|
|
|
-// .list();
|
|
|
-//
|
|
|
-// Map<SubjectTypeEnum, List<TenantAlbumMusic>> groupByType =
|
|
|
-// tenantAlbumMusics.stream().collect(Collectors.groupingBy(TenantAlbumMusic::getSubjectType));
|
|
|
-//
|
|
|
-// List<Long> musicSheetIdlist = tenantAlbumMusics.stream().map(next -> next.getMusicSheetId()).distinct().collect(Collectors.toList());
|
|
|
-
|
|
|
-// StudentMusicSheetSearch search = new StudentMusicSheetSearch();
|
|
|
-// search.setMusicSheetIdlist(musicSheetIdlist);
|
|
|
-// search.setPage(1);
|
|
|
-// search.setRows(9999);
|
|
|
-//
|
|
|
-// IPage<MusicSheetVo> records = musicSheetService.selectStudentPage(PageUtil.getPage(search), search, ClientEnum.TENANT_STUDENT);
|
|
|
-//
|
|
|
-// Map<Long, MusicSheetVo> idMsMap = records.getRecords().stream()
|
|
|
-// .collect(Collectors.toMap(MusicSheet::getId, Function.identity()));
|
|
|
-//
|
|
|
-// List<TenantAlbumWrapper.MusicSheetData> musicSheetData = vo.getMusicSheetData();
|
|
|
-//
|
|
|
-// groupByType.forEach((key, value) -> {
|
|
|
-// value.sort(Comparator.comparing(TenantAlbumMusic::getSortNumber));
|
|
|
-// TenantAlbumWrapper.MusicSheetData sheetData = new TenantAlbumWrapper.MusicSheetData();
|
|
|
-// sheetData.setSubjectType(key);
|
|
|
-// List<TenantAlbumWrapper.TenantAlbumSheet> tenantAlbumSheets = value.stream().map(next -> {
|
|
|
-//
|
|
|
-// TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
|
|
|
-// BeanUtils.copyProperties(next, tenantAlbumSheet);
|
|
|
-// Long musicSheetId = tenantAlbumSheet.getMusicSheetId();
|
|
|
-// MusicSheetVo musicSheet = idMsMap.getOrDefault(musicSheetId, new MusicSheetVo());
|
|
|
-// tenantAlbumSheet.setMusicSheetName(musicSheet.getMusicSheetName());
|
|
|
-// tenantAlbumSheet.setMusicTag(musicSheet.getMusicTag());
|
|
|
-// tenantAlbumSheet.setComposer(musicSheet.getComposer());
|
|
|
-// return tenantAlbumSheet;
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-//
|
|
|
-//
|
|
|
-// sheetData.setTenantAlbumSheetList(tenantAlbumSheets);
|
|
|
-// musicSheetData.add(sheetData);
|
|
|
-// vo.setMusicSheetData(musicSheetData);
|
|
|
-// });
|
|
|
list.add(vo);
|
|
|
});
|
|
|
}
|
|
@@ -233,7 +196,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Boolean add(UserTenantAlbumRecord userTenantAlbumRecord) {
|
|
|
+ public Boolean add(UserTenantAlbumRecord userTenantAlbumRecord,boolean sendMsg) {
|
|
|
Long tenantAlbumId = userTenantAlbumRecord.getTenantAlbumId();
|
|
|
TenantAlbum tenantAlbum = tenantAlbumMapper.selectById(tenantAlbumId);
|
|
|
if (tenantAlbum == null || Boolean.TRUE.equals(tenantAlbum.getDelFlag())) {
|
|
@@ -264,41 +227,19 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
}
|
|
|
userTenantAlbumRecord.setStartTime(instance.getTime());
|
|
|
|
|
|
- String type = userTenantAlbumRecord.getType();
|
|
|
- if ("DAY".equals(type)) {
|
|
|
- instance.add(Calendar.DAY_OF_MONTH, userTenantAlbumRecord.getTimes());
|
|
|
- } else if ("MONTH".equals(type)) {
|
|
|
- instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes());
|
|
|
- } else if ("YEAR".equals(type)) {
|
|
|
- instance.add(Calendar.YEAR, userTenantAlbumRecord.getTimes());
|
|
|
- } else {
|
|
|
- throw new BizException("不支持的周期类型");
|
|
|
- }
|
|
|
-
|
|
|
- instance.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
- instance.set(Calendar.MINUTE, 59);
|
|
|
- instance.set(Calendar.SECOND, 59);
|
|
|
- instance.set(Calendar.MILLISECOND, 0);
|
|
|
- userTenantAlbumRecord.setEndTime(instance.getTime());
|
|
|
+ userTenantAlbumRecord.setEndTime(addTime(userTenantAlbumRecord.getStartTime(), PeriodEnum.valueOf(userTenantAlbumRecord.getType()), userTenantAlbumRecord.getTimes(),1));
|
|
|
+ formatVipRecordTime(userTenantAlbumRecord);
|
|
|
userTenantAlbumRecord.setCreateTime(new Date());
|
|
|
userTenantAlbumRecord.setUpdateTime(new Date());
|
|
|
+ userTenantAlbumRecord.setEstimatedEndTime(userTenantAlbumRecord.getEndTime());
|
|
|
+ userTenantAlbumRecord.setEstimatedStartTime(userTenantAlbumRecord.getStartTime());
|
|
|
this.save(userTenantAlbumRecord);
|
|
|
|
|
|
- SysUser sysUser = sysUserMapper.getByUserId(userTenantAlbumRecord.getUserId());
|
|
|
- sendMessage(userTenantAlbumRecord.getUserId(), sysUser.getPhone(), ClientEnum.STUDENT, userTenantAlbumRecord.getTimes(), PeriodEnum.valueOf(userTenantAlbumRecord.getType()),
|
|
|
- tenantAlbum.getName(), userTenantAlbumRecord.getReason());
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- private void sendMessage(Long userId, String phone, ClientEnum client, Integer times, PeriodEnum type, String tenantAlbumName, String reason) {
|
|
|
- try {
|
|
|
- Map<Long, String> receivers = new HashMap<>();
|
|
|
- receivers.put(userId, phone);
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.USER_TENANT_ALBUM_VIP,
|
|
|
- receivers, null, 0, null, client.getCode(), times, type.getMsg(), tenantAlbumName, reason);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("机构专辑会员赠送消息发送失败 : {}", e.getMessage());
|
|
|
+ if (sendMsg) {
|
|
|
+ sendVipDeductionMessage(userTenantAlbumRecord.getUserId(),userTenantAlbumRecord.getTimes(),
|
|
|
+ PeriodEnum.valueOf(userTenantAlbumRecord.getType()),userTenantAlbumRecord.getReason(),tenantAlbum.getName());
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -736,6 +677,97 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
return userTenantAlbumRecords;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 扣除用户专辑记录
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private int deductionRecord(UserTenantAlbumRecordWrapper.DeductionUserTenantAlbumRecord result) {
|
|
|
+
|
|
|
+ // 查找被扣除的记录
|
|
|
+ UserTenantAlbumRecord record = this.getById(result.getRecordId());
|
|
|
+ if (record == null) {
|
|
|
+ throw new BizException("记录不存在");
|
|
|
+ }
|
|
|
+ if (record.getDeductionTime() != null) {
|
|
|
+ throw new BizException("记录已扣除");
|
|
|
+ }
|
|
|
+ Date endTime = record.getEndTime();
|
|
|
+ if (endTime.before(new Date())) {
|
|
|
+ throw new BizException("记录已过期");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取 剩余时长
|
|
|
+ int days =0;
|
|
|
+ if (record.getStartTime().before(new Date())) {
|
|
|
+ days = DateUtil.daysBetweenUp(new Date(), endTime);
|
|
|
+ } else {
|
|
|
+ days = DateUtil.daysBetweenUp(record.getStartTime(), endTime);
|
|
|
+ }
|
|
|
+ UserTenantAlbumRecord userTenantAlbumRecord = new UserTenantAlbumRecord();
|
|
|
+ userTenantAlbumRecord.setId(record.getId());
|
|
|
+ userTenantAlbumRecord.setDeductionTime(new Date());
|
|
|
+ userTenantAlbumRecord.setDeductionReason(result.getReason());
|
|
|
+ userTenantAlbumRecord.setEndTime(addTime(record.getEndTime(), PeriodEnum.DAY, -days,1));
|
|
|
+ userTenantAlbumRecord.setDeductionBy(result.getCreateBy());
|
|
|
+ userTenantAlbumRecord.setDeductionStatus(EDeductionStatus.DEDUCT);
|
|
|
+ userTenantAlbumRecord.setEfficientFlag(false);
|
|
|
+ this.updateById(userTenantAlbumRecord);
|
|
|
+
|
|
|
+ // 对比剩余天数
|
|
|
+
|
|
|
+ // 获取其他有效的记录
|
|
|
+ List<UserTenantAlbumRecord> list = this.lambdaQuery()
|
|
|
+ .eq(UserTenantAlbumRecord::getUserId, record.getUserId())
|
|
|
+ .gt(UserTenantAlbumRecord::getEndTime, endTime)
|
|
|
+ .eq(UserTenantAlbumRecord::getEfficientFlag, 1)
|
|
|
+ .eq(UserTenantAlbumRecord::getTenantAlbumId, record.getTenantAlbumId())
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return days;
|
|
|
+ }
|
|
|
+ List<UserTenantAlbumRecord> updateList = new ArrayList<>();
|
|
|
+ for (UserTenantAlbumRecord discountCardRecord : list) {
|
|
|
+ UserTenantAlbumRecord cardRecord = new UserTenantAlbumRecord();
|
|
|
+ cardRecord.setId(discountCardRecord.getId());
|
|
|
+ cardRecord.setStartTime(addTime(discountCardRecord.getStartTime(), PeriodEnum.DAY, -days,0));
|
|
|
+ cardRecord.setEndTime(addTime(discountCardRecord.getEndTime(), PeriodEnum.DAY, -days,1));
|
|
|
+ updateList.add(cardRecord);
|
|
|
+ }
|
|
|
+ this.updateBatchById(updateList);
|
|
|
+
|
|
|
+
|
|
|
+ return days;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Date addTime(Date time, PeriodEnum period, Integer times, int type) {
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(time);
|
|
|
+
|
|
|
+ if (PeriodEnum.DAY.equals(period)) {
|
|
|
+ cal.add(Calendar.DAY_OF_MONTH, times);
|
|
|
+ } else if (PeriodEnum.MONTH.equals(period)) {
|
|
|
+ cal.add(Calendar.MONTH, times);
|
|
|
+ } else if (PeriodEnum.YEAR.equals(period)) {
|
|
|
+ cal.add(Calendar.YEAR, times);
|
|
|
+ } else if (PeriodEnum.PERPETUAL.equals(period)) {
|
|
|
+ cal.add(Calendar.YEAR, 100);
|
|
|
+ }
|
|
|
+ if (type ==0) {
|
|
|
+ cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ cal.set(Calendar.MINUTE, 0);
|
|
|
+ cal.set(Calendar.SECOND, 0);
|
|
|
+ } else {
|
|
|
+ cal.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
+ cal.set(Calendar.MINUTE, 59);
|
|
|
+ cal.set(Calendar.SECOND, 59);
|
|
|
+ cal.set(Calendar.MILLISECOND, 0);
|
|
|
+ }
|
|
|
+ cal.set(Calendar.MILLISECOND, 0);
|
|
|
+ return cal.getTime();
|
|
|
+ }
|
|
|
|
|
|
private void temporary3DaySend(Long userId,String phone, String tenantAlbumName) {
|
|
|
Map<Long, String> receivers = new HashMap<>();
|
|
@@ -749,6 +781,139 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 扣减畅学卡
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void deduction(UserTenantAlbumRecordWrapper.DeductionUserTenantAlbumRecord result) {
|
|
|
+ // 判断是否是生效中
|
|
|
+
|
|
|
+ UserTenantAlbumRecord discountCardRecord = this.getById(result.getRecordId());
|
|
|
+ if (discountCardRecord == null) {
|
|
|
+ throw new BizException("畅学卡记录不存在");
|
|
|
+ }
|
|
|
+ if (discountCardRecord.getEndTime().before(new Date())) {
|
|
|
+ throw new BizException("畅学卡已过期");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int days = deductionRecord(result);
|
|
|
+
|
|
|
+ TenantAlbum tenantAlbum = tenantAlbumMapper.selectById(discountCardRecord.getTenantAlbumId());
|
|
|
+ if (tenantAlbum == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Boolean.TRUE.equals(result.getSendMsg())) {
|
|
|
+ ThreadUtil.execute(() -> sendVipDeductionMessage(result.getUserId(),-days
|
|
|
+ ,discountCardRecord.getType().equals(PeriodEnum.PERPETUAL.name())?PeriodEnum.PERPETUAL:PeriodEnum.DAY,result.getReason(),tenantAlbum.getName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<UserTenantAlbumRecordWrapper.AdminUserTenantAlbumRecord> selectAdminPage(IPage<UserTenantAlbumRecordWrapper.AdminUserTenantAlbumRecord> page, UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery query) {
|
|
|
+ List<UserTenantAlbumRecordWrapper.AdminUserTenantAlbumRecord> records = baseMapper.selectAdminPage(page, query);
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ List<Long> tenantAlbumIds = records.stream().map(UserTenantAlbumRecordWrapper.AdminUserTenantAlbumRecord::getTenantAlbumId).distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, TenantAlbum> albumIdMap = tenantAlbumService.getMapByIds(tenantAlbumIds);
|
|
|
+
|
|
|
+ // 创建人ID集合
|
|
|
+ List<Long> createByList = records.stream()
|
|
|
+ .map(UserTenantAlbumRecordWrapper.AdminUserTenantAlbumRecord::getOperatorId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, com.yonge.cooleshow.biz.dal.entity.SysUser> userMap = sysUserService.getMapByIds(createByList);
|
|
|
+ records.forEach(userTenantAlbumRecord -> {
|
|
|
+ com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = userMap.get(userTenantAlbumRecord.getOperatorId());
|
|
|
+ if (sysUser != null) {
|
|
|
+ userTenantAlbumRecord.setOperatorName(sysUser.getRealName());
|
|
|
+ }
|
|
|
+ TenantAlbum tenantAlbum = albumIdMap.get(userTenantAlbumRecord.getTenantAlbumId());
|
|
|
+ if (tenantAlbum != null) {
|
|
|
+ userTenantAlbumRecord.setTenantAlbumName(tenantAlbum.getName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return page.setRecords(records);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<UserTenantAlbumRecordWrapper.Info> info(UserTenantAlbumRecordWrapper.InfoQuery infoQuery) {
|
|
|
+ List<UserTenantAlbumRecordWrapper.Info> infos = new ArrayList<>();
|
|
|
+
|
|
|
+ List<UserTenantAlbumRecord> list = this.lambdaQuery()
|
|
|
+ .eq(UserTenantAlbumRecord::getUserId, infoQuery.getUserId())
|
|
|
+ .eq(UserTenantAlbumRecord::getEfficientFlag, 1)
|
|
|
+ .gt(UserTenantAlbumRecord::getEndTime, new Date())
|
|
|
+ .list();
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return infos;
|
|
|
+ }
|
|
|
+ Map<Long, List<UserTenantAlbumRecord>> map = list.stream().collect(Collectors.groupingBy(UserTenantAlbumRecord::getTenantAlbumId));
|
|
|
+ List<Long> tenantAlbumIds = list.stream().map(UserTenantAlbumRecord::getTenantAlbumId).collect(Collectors.toList());
|
|
|
+ Map<Long, TenantAlbum> albumIdMap = tenantAlbumService.getMapByIds(tenantAlbumIds);
|
|
|
+ map.forEach((k, v) -> {
|
|
|
+ TenantAlbum tenantAlbum = albumIdMap.get(k);
|
|
|
+ if (tenantAlbum == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 过滤出永久的
|
|
|
+ List<UserTenantAlbumRecord> collect = v.stream().filter(x -> x.getType().equals(PeriodEnum.PERPETUAL.name())).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
+ v.removeAll(collect);
|
|
|
+ }
|
|
|
+ UserTenantAlbumRecordWrapper.Info info = new UserTenantAlbumRecordWrapper.Info();
|
|
|
+ info.setTenantAlbumId(k);
|
|
|
+ info.setTenantAlbumName(tenantAlbum.getName());
|
|
|
+ info.setPerpetualFlag(CollectionUtils.isNotEmpty(collect));
|
|
|
+ int surplusDay = 0;
|
|
|
+ if (CollectionUtils.isNotEmpty(v)) {
|
|
|
+ Date endTime = v.get(0).getEndTime();
|
|
|
+ if (v.get(0).getStartTime().before(new Date())) {
|
|
|
+ surplusDay += DateUtil.daysBetweenUp(new Date(), endTime);
|
|
|
+ } else {
|
|
|
+ surplusDay += DateUtil.daysBetweenUp(v.get(0).getStartTime(), endTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ info.setSurplusDay(surplusDay);
|
|
|
+ infos.add(info);
|
|
|
+ });
|
|
|
+ return infos;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void sendVipDeductionMessage(Long userId, Integer num,PeriodEnum period,String reason,String tenantAlbumName) {
|
|
|
+ // 添加VIP时长短信
|
|
|
+ SysUser sysUser = sysUserService.getByUserId(userId);
|
|
|
+ if (sysUser == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, String> receivers = new HashMap<>();
|
|
|
+ receivers.put(sysUser.getId(), sysUser.getPhone());
|
|
|
+
|
|
|
+
|
|
|
+ // 短信
|
|
|
+ MessageTypeEnum messageTypeEnum = MessageTypeEnum.ADD_TENANT_ALBUM_JG;
|
|
|
+ if (num < 0) {
|
|
|
+ messageTypeEnum = MessageTypeEnum.DEDUCTION_TENANT_ALBUM_JG;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String string = Math.abs(num) + period.getMsg();
|
|
|
+ if (period == PeriodEnum.PERPETUAL) {
|
|
|
+ string = "永久";
|
|
|
+ }
|
|
|
+
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, messageTypeEnum,receivers,
|
|
|
+ null,0,null,ClientEnum.STUDENT.name()
|
|
|
+ , string,tenantAlbumName,reason);
|
|
|
+ } 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);
|
|
@@ -758,5 +923,32 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
|
|
|
} catch (Exception e) {
|
|
|
log.error("机构学生训练教材过期", e);
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public UserTenantAlbumRecord formatVipRecordTime(UserTenantAlbumRecord userTenantAlbumRecord) {
|
|
|
+ // 如果开始时间是23:59:59,开始时间改为第二天的00:00:00
|
|
|
+ LocalDateTime startTime = userTenantAlbumRecord.getStartTime().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ if (startTime.toLocalTime().equals(LocalTime.of(23, 59, 59))) {
|
|
|
+ startTime = startTime.plusDays(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ startTime = startTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ // 如果结束时间是00:00:00,开始时间改为前一天的23:59:59
|
|
|
+ LocalDateTime endTime = userTenantAlbumRecord.getEndTime().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ if (endTime.toLocalTime().equals(LocalTime.of(0, 0, 0))) {
|
|
|
+ endTime = endTime.plusDays(-1);
|
|
|
+ }
|
|
|
+ endTime = endTime.withHour(23).withMinute(59).withSecond(59).withNano(0);
|
|
|
+ userTenantAlbumRecord.setStartTime(Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()));
|
|
|
+ userTenantAlbumRecord.setEndTime(Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant()));
|
|
|
+ if (userTenantAlbumRecord.getStartTime().after(userTenantAlbumRecord.getEndTime())) {
|
|
|
+ userTenantAlbumRecord.setEndTime(userTenantAlbumRecord.getStartTime());
|
|
|
+ }
|
|
|
+ return userTenantAlbumRecord;
|
|
|
}
|
|
|
}
|