| | |
| | | package com.dsh.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.account.entity.TAppUser; |
| | | import com.dsh.account.entity.TStudent; |
| | | import com.dsh.account.feignclient.activity.IntroduceRewardsClient; |
| | | import com.dsh.account.feignclient.competition.DeductionCompetitionsClient; |
| | | import com.dsh.account.feignclient.competition.model.PurchaseRecordVo; |
| | | import com.dsh.account.feignclient.course.CancelListClient; |
| | | import com.dsh.account.feignclient.course.CoursePaymentClient; |
| | | import com.dsh.account.feignclient.course.CourseRecordClient; |
| | | import com.dsh.account.feignclient.course.CourseSessionNameClient; |
| | | import com.dsh.account.feignclient.course.model.StuSessionDetailsVo; |
| | | import com.dsh.account.feignclient.course.model.StuWithCoursesListVo; |
| | | import com.dsh.account.mapper.TAppUserMapper; |
| | | import com.dsh.account.mapper.TStudentMapper; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.ClassDetailsInsVo; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.StuDetailsReq; |
| | | import com.dsh.account.service.TStudentService; |
| | | import com.dsh.account.util.DateTimeHelper; |
| | | import com.dsh.account.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Autowired |
| | | private CourseSessionNameClient sessionNameClient; |
| | | |
| | | @Autowired |
| | | private DeductionCompetitionsClient dcttClient; |
| | | |
| | | @Autowired |
| | | private CancelListClient cancelcClient; |
| | | |
| | | @Autowired |
| | | private IntroduceRewardsClient idrClient; |
| | | |
| | | @Autowired |
| | | private CourseRecordClient crClient; |
| | | |
| | | @Autowired |
| | | private CoursePaymentClient couPayClient; |
| | | |
| | | @Autowired |
| | | private TAppUserMapper tauMapper; |
| | | |
| | | @Override |
| | | public void addStuOfAppUser(StuDetailsReq stu,Integer appUserId) { |
| | |
| | | @Override |
| | | public ClassDetailsInsVo querySessionDetailsDt(Integer userIdFormRedis, Integer lessonId, Integer stuId) { |
| | | ClassDetailsInsVo insVo = new ClassDetailsInsVo(); |
| | | List<StuSessionDetailsVo> stuSessionList = sessionNameClient.getStuSessionList(stuId,userIdFormRedis); |
| | | Date localMonthStart = DateTimeHelper.getCurrentMouthStart(); |
| | | Date localMonthEnd = DateTimeHelper.getCurrentMouthEnd(); |
| | | List<StuSessionDetailsVo> stuSessionList = sessionNameClient.getStuSessionList(localMonthStart,localMonthEnd,stuId,userIdFormRedis); |
| | | TStudent tStudent = this.baseMapper.selectById(stuId); |
| | | if (ToolUtil.isNotEmpty(tStudent)){ |
| | | insVo.setStuId(tStudent.getId()); |
| | | insVo.setStuName(tStudent.getName()); |
| | | insVo.setStuImage(tStudent.getHeadImg()); |
| | | |
| | | insVo.setSessionNames(stuSessionList); |
| | | List<PurchaseRecordVo> purchaseRecordVoList = new ArrayList<>(); |
| | | |
| | | List<PurchaseRecordVo> stuSourseList = dcttClient.getStuSourseList(localMonthStart,localMonthEnd,userIdFormRedis); |
| | | purchaseRecordVoList.addAll(stuSourseList); |
| | | List<PurchaseRecordVo> cancelCourseList = cancelcClient.getCancelCourseList(localMonthStart,localMonthEnd,stuId,userIdFormRedis); |
| | | purchaseRecordVoList.addAll(cancelCourseList); |
| | | List<PurchaseRecordVo> purchaseRecordVos = sessionNameClient.queryCourseDetails(localMonthStart,localMonthEnd,stuId,userIdFormRedis); |
| | | purchaseRecordVoList.addAll(purchaseRecordVos); |
| | | List<TAppUser> tAppUsers = tauMapper.selectList(new QueryWrapper<TAppUser>() |
| | | .eq("referralUserId",userIdFormRedis ) |
| | | .between("insertTime",localMonthStart ,localMonthEnd)); |
| | | List<Integer> userIds = tAppUsers.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | List<PurchaseRecordVo> purchaseRecordVos1 = idrClient.queryAppUsersofIntroduce(localMonthStart, localMonthEnd, userIds); |
| | | purchaseRecordVoList.addAll(purchaseRecordVos1); |
| | | insVo.setSessionNames(stuSessionList); |
| | | insVo.setDetails(dealDataOfTime(purchaseRecordVoList)); |
| | | StuWithCoursesListVo stuOfCoursesDetails = couPayClient.getStuOfCoursesDetails(stuId, userIdFormRedis); |
| | | insVo.setTotalNums(stuOfCoursesDetails.getTotalNums()); |
| | | insVo.setDeductedNums(stuOfCoursesDetails.getDeductedNums()); |
| | | insVo.setRemainingNums(stuOfCoursesDetails.getRemainingNums()); |
| | | Integer deductionClassHour = crClient.getDeductionClassHour(lessonId, stuId, userIdFormRedis); |
| | | insVo.setDeductionClassHours(deductionClassHour); |
| | | } |
| | | |
| | | return insVo; |
| | | } |
| | | |
| | | |
| | | public static List<PurchaseRecordVo> dealDataOfTime(List<PurchaseRecordVo> purchaseRecords) { |
| | | Collections.sort(purchaseRecords, new Comparator<PurchaseRecordVo>() { |
| | | @Override |
| | | public int compare(PurchaseRecordVo record1, PurchaseRecordVo record2) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm"); |
| | | Date date1 = null; |
| | | Date date2 = null; |
| | | try { |
| | | date1 = dateFormat.parse(record1.getPurchaseTime()); |
| | | date2 = dateFormat.parse(record2.getPurchaseTime()); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // 倒序排序 |
| | | return date2.compareTo(date1); |
| | | } |
| | | }); |
| | | return purchaseRecords; |
| | | } |
| | | |
| | | |
| | | // public static List<String> dealDataOfTime(List<String> timeStrings) { |
| | | // Collections.sort(timeStrings, new Comparator<String>() { |
| | | // @Override |
| | | // public int compare(String time1, String time2) { |
| | | // String[] parts1 = time1.split(" "); |
| | | // String[] parts2 = time2.split(" "); |
| | | // String[] dateParts1 = parts1[0].split("-"); |
| | | // String[] dateParts2 = parts2[0].split("-"); |
| | | // String[] timeParts1 = parts1[1].split(":"); |
| | | // String[] timeParts2 = parts2[1].split(":"); |
| | | // int month1 = Integer.parseInt(dateParts1[0]); |
| | | // int day1 = Integer.parseInt(dateParts1[1]); |
| | | // int hour1 = Integer.parseInt(timeParts1[0]); |
| | | // int minute1 = Integer.parseInt(timeParts1[1]); |
| | | // int month2 = Integer.parseInt(dateParts2[0]); |
| | | // int day2 = Integer.parseInt(dateParts2[1]); |
| | | // int hour2 = Integer.parseInt(timeParts2[0]); |
| | | // int minute2 = Integer.parseInt(timeParts2[1]); |
| | | // // 倒序排序 |
| | | // if (month1 != month2) { |
| | | // return month2 - month1; |
| | | // } else if (day1 != day2) { |
| | | // return day2 - day1; |
| | | // } else if (hour1 != hour2) { |
| | | // return hour2 - hour1; |
| | | // } else { |
| | | // return minute2 - minute1; |
| | | // } |
| | | // } |
| | | // }); |
| | | // return timeStrings; |
| | | // } |
| | | } |