刘俊驰 7 bulan lalu
induk
melakukan
5315eeeb4a
20 mengubah file dengan 224 tambahan dan 90 penghapusan
  1. 10 8
      cooleshow-app/src/main/java/com/yonge/cooleshow/student/task/TaskController.java
  2. 20 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherHomeController.java
  3. 2 4
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/UserTenantAlbumRecord.java
  4. 7 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/MessageTypeEnum.java
  5. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/DiscountCardRecordMapper.java
  6. 4 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/UserTenantAlbumRecordMapper.java
  7. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/DiscountCardRecordService.java
  8. 6 4
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java
  9. 5 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java
  10. 61 11
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/DiscountCardRecordServiceImpl.java
  11. 38 46
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserTenantAlbumRecordServiceImpl.java
  12. 2 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/VipCardRecordServiceImpl.java
  13. 26 3
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TeacherIndexWrapper.java
  14. 8 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/DiscountCardRecordMapper.xml
  15. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/ExposureRecordDao.xml
  16. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/HomeMapper.xml
  17. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/SysMusicCompareRecordMapper.xml
  18. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/UserOrderRefundMapper.xml
  19. 25 3
      cooleshow-user/user-biz/src/main/resources/config/mybatis/UserTenantAlbumRecordMapper.xml
  20. 2 2
      cooleshow-user/user-biz/src/main/resources/config/mybatis/VipCardRecordMapper.xml

+ 10 - 8
cooleshow-app/src/main/java/com/yonge/cooleshow/student/task/TaskController.java

@@ -1,10 +1,7 @@
 package com.yonge.cooleshow.student.task;
 
 import com.yonge.cooleshow.biz.dal.entity.StudentTotal;
-import com.yonge.cooleshow.biz.dal.service.CourseRepliedService;
-import com.yonge.cooleshow.biz.dal.service.StudentTimeService;
-import com.yonge.cooleshow.biz.dal.service.StudentTotalService;
-import com.yonge.cooleshow.biz.dal.service.VipCardRecordService;
+import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
@@ -23,13 +21,15 @@ import java.util.List;
 @RequestMapping("${app-config.url.student:}/task")
 @ApiIgnore
 public class TaskController extends BaseController {
-    @Autowired
+    @Resource
     private StudentTotalService studentTotalService;
-    @Autowired
+    @Resource
     private StudentTimeService studentTimeService;
-    @Autowired
+    @Resource
     private VipCardRecordService vipCardRecordService;
-    @Autowired
+    @Resource
+    private DiscountCardRecordService discountCardRecordService;
+    @Resource
     private CourseRepliedService repliedService;
     /***
      * 查询所有学生统计数据
@@ -52,6 +52,8 @@ public class TaskController extends BaseController {
     public HttpResponseResult<Boolean> halfHourTask() {
         //会员卡到期提醒
         vipCardRecordService.pollExpireMsg();
+        //畅学卡到期提醒
+        discountCardRecordService.pollExpireMsg();
         return succeed(true);
     }
 

+ 20 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherHomeController.java

@@ -1,20 +1,28 @@
 package com.yonge.cooleshow.teacher.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.yonge.cooleshow.biz.dal.dto.excel.UserWithdrawalExport;
+import com.yonge.cooleshow.biz.dal.dto.search.TeacherWithdrawalSearch;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.vo.PianoRoomTimeVo;
 import com.yonge.cooleshow.biz.dal.vo.TeacherHomeStatisticalVo;
+import com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo;
 import com.yonge.cooleshow.biz.dal.wrapper.TeacherIndexWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.page.PageInfo;
 import com.yonge.toolset.mybatis.support.PageUtil;
+import com.yonge.toolset.utils.easyexcel.ExcelUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -138,4 +146,16 @@ public class TeacherHomeController extends BaseController {
         return succeed(teacherIncomePageInfo);
     }
 
+    @PostMapping("/exportStudentPractice")
+    @ApiOperation(value = "查询导出首页练习数据学员列表")
+    public void exportExcel(@RequestBody TeacherIndexWrapper.StudentSearch studentSearch) {
+        studentSearch.setTeacherId(sysUserService.getUserId());
+        studentSearch.setLimit(10000);
+        List<TeacherIndexWrapper.StudentPracticeSummaryDto> teacherHomeStudent = homeService.getTeacherHomeStudent(studentSearch);
+        List<TeacherIndexWrapper.StudentPracticeSummaryExportDto> list =
+                JSON.parseArray(JSON.toJSONString(teacherHomeStudent), TeacherIndexWrapper.StudentPracticeSummaryExportDto.class);
+        ExcelUtils.exportExcel(list, "学员练习统计" + System.currentTimeMillis(),
+                "列表数据");
+    }
+
 }

+ 2 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/UserTenantAlbumRecord.java

@@ -33,8 +33,6 @@ public class UserTenantAlbumRecord implements Serializable {
 	@TableField(value = "user_id_")
     private Long userId;
 
-
-
     @ApiModelProperty("机构ID")
     @TableField(value = "tenant_id_")
     private Long tenantId;
@@ -87,9 +85,9 @@ public class UserTenantAlbumRecord implements Serializable {
 	@TableField(value = "times_")
     private Integer times;
 
-    @ApiModelProperty("消息发送 0、未发送 1、已发送提前3天消息 2、已发送会员过期消息 暂时不用") 
+    @ApiModelProperty("消息发送 0、未发送 1、已发送提前3天消息 2、已发送会员过期消息")
 	@TableField(value = "msg_status_")
-    private Boolean msgStatus;
+    private Integer msgStatus;
 
     @ApiModelProperty("备注") 
 	@TableField(value = "reason_")

+ 7 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/MessageTypeEnum.java

@@ -82,11 +82,15 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     SMS_NEW_VIP_BUY_SUCCESS("会员购买成功(短信)"),
     SMS_TEACHER_NEW_VIP_BUY_SUCCESS("会员购买成功(短信)"),
 
+    DISCOUNT_EXPIRE_THIRTY_DAY("畅学卡到期前3天"),
+
     VIP_EXPIRE_THIRTY_DAY("VIP会员到期前3天"),
     SVIP_EXPIRE_THIRTY_DAY("SVIP会员到期前3天"),
     SMS_VIP_EXPIRE_THIRTY_DAY("VIP会员到期前3天(短信)"),
     SMS_SVIP_EXPIRE_THIRTY_DAY("SVIP会员到期前3天(短信)"),
 
+    DISCOUNT_EXPIRE("畅学卡到期"),
+
     VIP_EXPIRE("VIP会员到期"),
     SVIP_EXPIRE("SVIP会员到期"),
     SMS_VIP_EXPIRE("VIP会员到期(短信)"),
@@ -159,7 +163,8 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     TENANT_VIP_EXPIRE("平台会员到期"),
     TENANT_PLATFORM_ADD_VIP("后台添加平台会员"),
     TENANT_ALBUM_BUY("购买训练教程"),
-    TENANT_ALBUM_EXPIRE("训练教程到期"),
+    TENANT_ALBUM_EXPIRE("训练教程即将到期"),
+    TENANT_ALBUM_EXPIRE_THIRTY_DAY("训练教程3天后到期"),
     TENANT_SEND_CODE("发放激活码"),
     TENANT_CODE_SENDCANCEL("激活码被撤回"),
     TENANT_MUSIC_BUY("购买曲目"),
@@ -186,7 +191,7 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     GROUP_FAIL_STUDENT("小组课成课失败"),
     GROUP_FAIL_TEACHER("小组课成课失败"),
     DEDUCTION_DISCOUNT_SMS("扣减畅学卡"),
-    ADD_DISCOUNT_SMS("扣减畅学卡"),
+    ADD_DISCOUNT_SMS("添加畅学卡"),
     ;
 
     MessageTypeEnum(String msg) {

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/DiscountCardRecordMapper.java

@@ -24,4 +24,6 @@ public interface DiscountCardRecordMapper extends BaseMapper<DiscountCardRecord>
                                                                    @Param("param") DiscountCardRecordWrapper.DiscountCardRecordQuery query);
 
     void updateUserDiscountTime(@Param("userId") Long userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    void updateMsgStatus(@Param("ids") List<Long> ids, @Param("msgStatus") int msgStatus);
 }

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/UserTenantAlbumRecordMapper.java

@@ -40,5 +40,9 @@ public interface UserTenantAlbumRecordMapper extends BaseMapper<UserTenantAlbumR
 
     List<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> selectTemporaryRecord();
 
+    List<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> selectTemporaryRecord1();
+
     List<TenantGroupAlbumWrapper.TenantAlbumSort> getTenantAlbumMaxCreateTime(@Param("userId") Long userId, @Param("clientType") ClientEnum clientType, @Param("tenantAlbumIds") List<Long> tenantAlbumIds);
+
+    void updateMsgStatus(@Param("ids") List<Long> ids, @Param("msgStatus") int msgStatus);
 }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/DiscountCardRecordService.java

@@ -31,4 +31,6 @@ public interface DiscountCardRecordService extends IService<DiscountCardRecord>
      *
      */
     void deduction(DiscountCardRecordWrapper.DeductionDiscountCardRecord result);
+
+    void pollExpireMsg();
 }

+ 6 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java

@@ -566,6 +566,8 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
         List<CourseScheduleStudentPayment> studentPayments = courseScheduleStudentPaymentService.lambdaQuery()
                 .eq(CourseScheduleStudentPayment::getCourseGroupId, groupId)
                 .isNotNull(CourseScheduleStudentPayment::getUserId)
+                .groupBy(CourseScheduleStudentPayment::getUserId)
+                .orderByDesc(CourseScheduleStudentPayment::getId)
                 .list();
         if (CollectionUtils.isNotEmpty(studentPayments)) {
             List<Long> userIds = studentPayments.stream().map(CourseScheduleStudentPayment::getUserId).distinct().collect(Collectors.toList());
@@ -573,14 +575,14 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
             //获取用户声部列表
             Map<Long, com.yonge.cooleshow.biz.dal.entity.SysUser> mapByIds = sysUserService.getMapByIds(userIds);
             List<CourseGroupWrapper.CourseStudentVo> result = new ArrayList<>();
-            userIds.forEach(e -> {
+            studentPayments.forEach(e -> {
                 CourseGroupWrapper.CourseStudentVo vo = new CourseGroupWrapper.CourseStudentVo();
-                vo.setStudentId(e);
-                com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = mapByIds.get(e);
+                vo.setStudentId(e.getUserId());
+                com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = mapByIds.get(e.getUserId());
                 vo.setStudentName(sysUser.getRealName());
                 vo.setUserName(sysUser.getUsername());
                 vo.setAvatar(sysUser.getAvatar());
-                vo.setSubjectId(studentMap.get(e).getSubjectId());
+                vo.setSubjectId(studentMap.get(e.getUserId()).getSubjectId());
                 if(StringUtils.isNotEmpty(vo.getSubjectId())){
                     List<Subject> subjectList = subjectService.findBySubjectByIdList(vo.getSubjectId());
                     if(CollectionUtils.isNotEmpty(subjectList)){

+ 5 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -3077,7 +3077,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         //距离开课时间小于等于20分钟
         List<CourseSchedule> courseSchedules = this.lambdaQuery()
                 .eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START.getCode())
-                .in(CourseSchedule::getType, CourseScheduleEnum.PRACTICE.getCode(), CourseScheduleEnum.VIP.getCode())
+                .in(CourseSchedule::getType, CourseScheduleEnum.PRACTICE.getCode(), CourseScheduleEnum.VIP.getCode(), CourseScheduleEnum.GROUP.getCode())
                 .eq(CourseSchedule::getPushStartMsg, false)
                 .eq(CourseSchedule::getLock, 0)
                 .lt(CourseSchedule::getStartTime, DateUtil.offsetMinute(new Date(), 21))
@@ -3102,6 +3102,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
                 sendStartRemind(CourseScheduleEnum.PRACTICE,sendTeacherMap,courseList);
             }else if(CourseScheduleEnum.VIP.getCode().equals(type)){
                 sendStartRemind(CourseScheduleEnum.VIP,sendTeacherMap,courseList);
+            }else if(CourseScheduleEnum.GROUP.getCode().equals(type)){
+                sendStartRemind(CourseScheduleEnum.GROUP,sendTeacherMap,courseList);
             }
         });
 
@@ -3111,6 +3113,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
                 sendStartRemind(CourseScheduleEnum.PRACTICE,courseList,sendStudentMap);
             }else if(CourseScheduleEnum.VIP.getCode().equals(type)){
                 sendStartRemind(CourseScheduleEnum.VIP,courseList,sendStudentMap);
+            }else if(CourseScheduleEnum.GROUP.getCode().equals(type)){
+                sendStartRemind(CourseScheduleEnum.GROUP,courseList,sendStudentMap);
             }
         });
         this.lambdaUpdate().set(CourseSchedule::getPushStartMsg,true)

+ 61 - 11
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/DiscountCardRecordServiceImpl.java

@@ -3,7 +3,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 import cn.hutool.core.thread.ThreadUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.microsvc.toolkit.common.webportal.exception.BizException;
 import com.yonge.cooleshow.biz.dal.entity.DiscountCardRecord;
@@ -17,18 +17,17 @@ import com.yonge.cooleshow.biz.dal.wrapper.DiscountCardRecordWrapper;
 import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
 import com.yonge.toolset.utils.date.DateUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
 import java.util.*;
 import java.util.stream.Collectors;
 
-
 /**
  * 购买会员卡记录表
  * 2024-11-15 10:57:20
@@ -37,16 +36,13 @@ import java.util.stream.Collectors;
 @Service
 public class DiscountCardRecordServiceImpl extends ServiceImpl<DiscountCardRecordMapper, DiscountCardRecord> implements DiscountCardRecordService {
 
-    @Autowired
+    @Resource
     private MemberPriceSettingsService memberPriceSettingsService;
-
-    @Autowired
+    @Resource
     private StudentService studentService;
-
-    @Autowired
+    @Resource
     private SysUserService sysUserService;
-
-    @Autowired
+    @Resource
     private SysMessageService sysMessageService;
 
     @Override
@@ -116,7 +112,7 @@ public class DiscountCardRecordServiceImpl extends ServiceImpl<DiscountCardRecor
         try {
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, messageTypeEnum,receivers,
                     null,0,null,ClientEnum.STUDENT.name()
-                    ,Math.abs(num) + period.name(),reason);
+                    ,Math.abs(num) + period.getMsg(),reason);
         } catch (Exception e) {
             log.error("消息发送失败 ", e);
         }
@@ -352,4 +348,58 @@ public class DiscountCardRecordServiceImpl extends ServiceImpl<DiscountCardRecor
         }
         return discountCardRecord;
     }
+
+    @Override
+    public void pollExpireMsg() {
+        //会员提前三天提示
+        List<DiscountCardRecord> records = this.lambdaQuery()
+                .eq(DiscountCardRecord::getEfficientFlag, true)
+                .eq(DiscountCardRecord::getMsgStatus, 0)
+                .lt(DiscountCardRecord::getEndTime, DateUtil.localDateTimeToDate(LocalDateTime.now().plusDays(4)))
+                .list();
+        if(CollectionUtils.isNotEmpty(records)){
+            //获取用户编号
+            List<Long> userIds = records.stream().map(DiscountCardRecord::getUserId).collect(Collectors.toList());
+            Map<Long,String> receivers = sysUserService.getDao().selectBatchIds(userIds).stream().collect(Collectors.toMap(SysUser::getId, SysUser::getPhone));
+            temporary3DaysSend(receivers);
+            //更新状态
+            List<Long> ids = records.stream().map(DiscountCardRecord::getId).collect(Collectors.toList());
+            baseMapper.updateMsgStatus(ids,1);
+        }
+
+        //会员到期提示
+        List<DiscountCardRecord> expireRecords = this.lambdaQuery()
+                .eq(DiscountCardRecord::getEfficientFlag, true)
+                .in(DiscountCardRecord::getMsgStatus, 0,1)
+                .lt(DiscountCardRecord::getEndTime, DateUtil.localDateTimeToDate(LocalDateTime.now().plusDays(1)))
+                .list();
+        if (CollectionUtils.isNotEmpty(expireRecords)) {
+            //获取用户编号
+            List<Long> userIds = expireRecords.stream().map(DiscountCardRecord::getUserId).collect(Collectors.toList());
+            Map<Long,String> receivers = sysUserService.getDao().selectBatchIds(userIds).stream().collect(Collectors.toMap(SysUser::getId, SysUser::getPhone));
+            expireSend(receivers);
+            //更新状态
+            List<Long> ids = expireRecords.stream().map(DiscountCardRecord::getId).collect(Collectors.toList());
+            baseMapper.updateMsgStatus(ids,2);
+        }
+    }
+
+    private void temporary3DaysSend(Map<Long, String> receivers) {
+        try {
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,MessageTypeEnum.DISCOUNT_EXPIRE_THIRTY_DAY
+                    , receivers, null, 0, null, ClientEnum.STUDENT.getCode());
+        } catch (Exception e) {
+            log.error("畅学卡到期3天极光消息推送异常");
+        }
+    }
+
+    private void expireSend(Map<Long, String> receivers) {
+        try {
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,MessageTypeEnum.DISCOUNT_EXPIRE
+                    ,receivers, null, 0, null, ClientEnum.STUDENT.getCode());
+        } catch (Exception e) {
+            log.error("畅学卡到期极光消息推送异常");
+        }
+    }
+
 }

+ 38 - 46
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserTenantAlbumRecordServiceImpl.java

@@ -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);
         }

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/VipCardRecordServiceImpl.java

@@ -204,7 +204,7 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
 
     @Override
     public void pollExpireMsg() {
-        //提前三天提示
+        //会员提前三天提示
         List<VipCardRecordVo> temporaryRecords = baseMapper.selectTemporaryRecord();
         if(CollectionUtils.isNotEmpty(temporaryRecords)){
             Map<ClientEnum,List<VipCardRecordVo>> map = temporaryRecords.stream().collect(Collectors.groupingBy(VipCardRecordVo::getClientType));
@@ -223,7 +223,7 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
             baseMapper.updateMsgStatus(ids,1);
         }
 
-        //到期提示
+        //会员到期提示
         List<VipCardRecordVo> expireRecords = baseMapper.selectExpireRecord();
         if (CollectionUtils.isNotEmpty(expireRecords)){
             Map<ClientEnum,List<VipCardRecordVo>> map = expireRecords.stream().collect(Collectors.groupingBy(VipCardRecordVo::getClientType));

+ 26 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TeacherIndexWrapper.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.biz.dal.wrapper;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.yonge.toolset.base.page.QueryInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -53,6 +54,9 @@ public class TeacherIndexWrapper {
 
         @ApiModelProperty("排序方式 ,ASC升序,DESC降序")
         private String sortType;
+
+        @ApiModelProperty("查询条数")
+        private Integer limit = 10;
     }
 
     @Data
@@ -69,9 +73,6 @@ public class TeacherIndexWrapper {
 
         @ApiModelProperty("练习人数")
         private List<PracticeTimeDto> practiceCounts;
-
-        @ApiModelProperty("学员练习统计")
-        private List<StudentPracticeSummaryDto> studentPracticeSummary;
     }
 
     @Data
@@ -127,6 +128,28 @@ public class TeacherIndexWrapper {
     @Data
     @Builder
     @NoArgsConstructor
+    @AllArgsConstructor
+    public static class StudentPracticeSummaryExportDto{
+
+        @ExcelProperty(value = "学员姓名",index = 0)
+        private String studentName;
+
+        @ExcelProperty(value = "乐器",index = 1)
+        private String subjectName;
+
+        @ExcelProperty(value = "练习总时长",index = 2)
+        private Long totalPracticeTime;
+
+        @ExcelProperty(value = "练习天数",index = 3)
+        private Integer practiceDays;
+
+        @ExcelProperty(value = "平均练习时长",index = 4)
+        private Long averagePracticeTime;
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
     public static class CourseExposureTotal{
 
         @ApiModelProperty("日期")

+ 8 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/DiscountCardRecordMapper.xml

@@ -29,6 +29,14 @@
         , t.efficient_flag_ AS efficientFlag
         , t.send_msg_ AS sendMsg
         </sql>
+    <update id="updateMsgStatus">
+        update discount_card_record
+        set msg_status_ = #{msgStatus},update_time_ = now()
+        where id_ IN
+        <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </update>
 
     <select id="detail" resultType="com.yonge.cooleshow.biz.dal.entity.MemberPriceSettings">
         SELECT

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/ExposureRecordDao.xml

@@ -20,7 +20,7 @@
 		<if test="param.type != null and param.type != ''">
 			and er.object_type_ = #{param.type}
 		</if>
-		group by er.object_type_,DATE_FORMAT(er.exposure_time_, #{groupBy})
+		group by DATE_FORMAT(er.exposure_time_, #{groupBy})
 		ORDER BY 'date'
 	</select>
 </mapper>

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/HomeMapper.xml

@@ -569,7 +569,7 @@
 			left join course_group cg ON cg.id_ = cs.course_group_id_
 		</if>
 		<if test="param.type == 'MUSIC'">
-			left join music_sheet cg ON cg.id_ = ttar.biz_id_
+			left join music_sheet cg ON cg.id_ = ucar.biz_id_
 		</if>
 		where uo.status_ = 'PAID' AND ucar.in_or_out_ = 'IN'
 		AND uo.create_time_ BETWEEN #{param.startTime} AND #{param.endTime} AND ucar.account_id_ = #{param.teacherId}

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/SysMusicCompareRecordMapper.xml

@@ -656,7 +656,7 @@
 		<if test="param.sortField == null or param.sortField == ''">
 			ORDER BY totalPracticeTime DESC
 		</if>
-		LIMIT 10
+		LIMIT ${param.limit}
 	</select>
 	<!--曲目练习统计-->
 

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserOrderRefundMapper.xml

@@ -81,7 +81,7 @@
     <select id="getByOrderNo" resultMap="BaseResultMap">
         SELECT <include refid="baseColumns" /> FROM user_order_refund t
         WHERE t.order_no_ = #{orderNo} and
-        <foreach collection="orderDetailIds" item="item" open="(" separator="," close=")">
+        <foreach collection="orderDetailIds" item="item" open="(" separator=" or " close=")">
             FIND_IN_SET(#{item}, t.oredr_detil_ids_)
         </foreach>
     </select>

+ 25 - 3
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserTenantAlbumRecordMapper.xml

@@ -23,8 +23,16 @@
         , t.times_ AS times
         , t.msg_status_ AS msgStatus
         , t.reason_ AS reason
-        </sql> 
-    
+        </sql>
+    <update id="updateMsgStatus">
+        update user_tenant_album_record
+        set msg_status_ = #{msgStatus},update_time_ = now()
+        where id_ IN
+        <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </update>
+
     <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper$TenantAlbum">
 		SELECT         
         	<include refid="baseColumns" />
@@ -87,11 +95,25 @@
         ) a
         left join user_tenant_album_record t on a.id_ = t.id_
         left join sys_user u on t.user_id_ = u.id_
-        where t.end_time_ &lt;= now()
+        where DATE_ADD(now(), INTERVAL 4 DAY) > t.end_time_
         and (msg_status_ = 0 or msg_status_ is null)
         order by end_time_ desc
     </select>
 
+    <select id="selectTemporaryRecord1" resultType="com.yonge.cooleshow.biz.dal.wrapper.UserTenantAlbumRecordWrapper$UserTenantAlbumRecord">
+        select
+        <include refid="baseColumns"/>,
+        u.phone_ as phone
+        from (
+        select max(id_) as id_ from user_tenant_album_record group by user_id_
+        ) a
+        left join user_tenant_album_record t on a.id_ = t.id_
+        left join sys_user u on t.user_id_ = u.id_
+        where DATE_ADD(now(), INTERVAL 1 DAY) > t.end_time_
+        and (msg_status_ IN (0,1) or msg_status_ is null)
+        order by end_time_ desc
+    </select>
+
     <select id="selectUserTenantAlbumRecordPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.UserTenantAlbumRecordWrapper$UserTenantAlbumRecord">
         SELECT
         <include refid="baseColumns" />

+ 2 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/VipCardRecordMapper.xml

@@ -100,7 +100,7 @@
         having 1
         order by end_time_ desc) t
         group by t.user_id_, t.client_type_, t.vip_type_
-        having (DATE_ADD(now(), INTERVAL 3 DAY) > vipEndTime or DATE_ADD(now(), INTERVAL 3 DAY) > svipEndTime)
+        having (DATE_ADD(now(), INTERVAL 4 DAY) > vipEndTime or DATE_ADD(now(), INTERVAL 4 DAY) > svipEndTime)
         ) a
         left join vip_card_record t on a.id_ = t.id_
         left join sys_user u on t.user_id_ = u.id_
@@ -125,7 +125,7 @@
             having 1
             order by end_time_ desc) t
             group by t.user_id_, t.client_type_, t.vip_type_
-            having ( now() > vipEndTime or now()> svipEndTime)
+            having (DATE_ADD(now(), INTERVAL 1 DAY) > vipEndTime or DATE_ADD(now(), INTERVAL 1 DAY) > svipEndTime)
         ) a
         left join vip_card_record t on a.id_ = t.id_
         left join sys_user u on t.user_id_ = u.id_