liujie
2023-08-07 f5ca8f01cf6b8256a25e8c6838d805fe3fca43fc
cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java
@@ -33,13 +33,16 @@
import com.dsh.account.model.vo.exploreDetail.LonLatRequest;
import com.dsh.account.model.vo.exploreDetail.QuestionIns;
import com.dsh.account.model.vo.exploreDetail.StoreDetailsVo;
import com.dsh.account.model.vo.exploreDetail.StoreOfCourseVo;
import com.dsh.account.model.vo.sourceDetail.CouponStuAvailableVo;
import com.dsh.account.model.vo.sourceDetail.CourseDetailsOfContinuationResp;
import com.dsh.account.model.vo.sourceDetail.RecordTimeRequest;
import com.dsh.account.model.vo.userBenefitDetail.Goods;
import com.dsh.account.service.TStudentService;
import com.dsh.account.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -203,9 +206,9 @@
            getStuOfCoursesDetails.setStuId(stuId);
            getStuOfCoursesDetails.setAppUserId(userIdFormRedis);
            StuWithCoursesListVo stuOfCoursesDetails = couPayClient.getStuOfCoursesDetails(getStuOfCoursesDetails);
            insVo.setTotalNums(stuOfCoursesDetails.getTotalNums());
            insVo.setDeductedNums(stuOfCoursesDetails.getDeductedNums());
            insVo.setRemainingNums(stuOfCoursesDetails.getRemainingNums());
            insVo.setTotalNums(ToolUtil.isEmpty(stuOfCoursesDetails.getTotalNums()) ? 0 : stuOfCoursesDetails.getTotalNums());
            insVo.setDeductedNums(ToolUtil.isEmpty(stuOfCoursesDetails.getDeductedNums()) ? 0 : stuOfCoursesDetails.getDeductedNums());
            insVo.setRemainingNums(ToolUtil.isEmpty(stuOfCoursesDetails.getRemainingNums()) ? 0 : stuOfCoursesDetails.getRemainingNums());
            GetStudentCourse course = new GetStudentCourse();
            course.setCourseId(lessonId);
            course.setStuId(stuId);
@@ -220,9 +223,20 @@
    @Override
    public List<PurchaseRecordVo> queryDeduRecordDetails(RecordTimeRequest timeRequest,Integer appUserId) {
        List<PurchaseRecordVo> purchaseRecordVoList = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date startTime = DateTimeHelper.getCurrentIdetMouthStart(timeRequest.getStartTime());
        Date endTime = DateTimeHelper.getCurrentIdeaMouthEnd(timeRequest.getEndTime());
        String time = timeRequest.getTime();
        Date monthStart = null;
        Date monthEnd = null;
        if (StringUtils.hasText(time)) {
            monthStart = DateTimeHelper.getCurrentIdetMouthStart(time);
            monthEnd = DateTimeHelper.getCurrentIdeaMouthEnd(time);
        } else {
            monthStart = DateTimeHelper.getCurrentMouthStart();
            monthEnd = DateTimeHelper.getCurrentMouthEnd();
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
        Date startTime = DateTimeHelper.getCurrentIdetMouthStart(simpleDateFormat.format(monthStart));
        Date endTime = DateTimeHelper.getCurrentIdeaMouthEnd(simpleDateFormat.format(monthEnd));
        GetStuSourseList getStuSourseList = new GetStuSourseList();
        getStuSourseList.setStartTime(startTime);
        getStuSourseList.setEndTime(endTime);
@@ -586,83 +600,85 @@
        return ResultUtil.success();
    }
    /**
     *
     * @param stuId 学员id
     * @param appUserId 用户id
     * @param appointStatus  预约状态 0=全部 1=待上课 2=已完成 3=已取消
     * @param timeType 时间类型 0=全部 1=近一周 2=近一个月 3=近一年
     * @param search 课程名称
     * @return
     */
    @Override
    public AppointmentRecordVo getAppointmentRecords(Integer stuId, Integer appUserId,Integer appointStatus,Integer timeType,String search) {
        AppointmentRecordVo recordVo = new AppointmentRecordVo();
        TStudent tStudent = this.baseMapper.selectOne(new QueryWrapper<TStudent>()
                .eq("id",stuId )
                .eq("appUserId",appUserId));
        if (ToolUtil.isNotEmpty(tStudent)){
            recordVo.setStuId(tStudent.getId());
            recordVo.setStuName(tStudent.getName());
            List<RecordAppoint> recordAppoints = couPayClient.obtainStudentClassDetailsData(stuId);
            if (ToolUtil.isEmpty(appointStatus)){
                recordVo.setAppointStatus(0);
            }else {
                recordVo.setAppointStatus(appointStatus);
                recordAppoints = recordAppoints.stream()
                        .filter(record -> record.getStatus().equals(appointStatus))
                        .collect(Collectors.toList());
    public List<RecordAppoint> getAppointmentRecords(Integer stuId, Integer appUserId,Integer appointStatus,Integer timeType,String search) {
        WeeksOfCourseRest courseRest = new WeeksOfCourseRest();
        courseRest.setAppUserId(appUserId);
        courseRest.setStuId(stuId);
        List<RecordAppoint> recordAppoints = couPayClient.obtainStudentClassDetailsData(courseRest);
        if (recordAppoints.size() > 0) {
            if (ToolUtil.isNotEmpty(appointStatus) && appointStatus != 0) {
                    recordAppoints = recordAppoints.stream()
                            .filter(record -> record.getStatus().equals(appointStatus))
                            .collect(Collectors.toList());
            }
            if (ToolUtil.isNotEmpty(search)){
                recordVo.setAppointStatus(appointStatus);
                recordAppoints = recordAppoints.stream()
                        .filter(record -> record.getCoursePackageName().contains(search))
                        .collect(Collectors.toList());
            if (ToolUtil.isNotEmpty(search)) {
                    recordAppoints = recordAppoints.stream()
                            .filter(record -> record.getCoursePackageName().contains(search))
                            .collect(Collectors.toList());
            }
            if (ToolUtil.isNotEmpty(timeType)){
            if (ToolUtil.isNotEmpty(timeType) && timeType != 0) {
                Date lastOfDate = DateUtil.getLastOfDate();
                switch (timeType){
                switch (timeType) {
                    case 1:
                        Date lastWeekStartDate = DateUtil.getLastWeekStartDate();
                        recordAppoints = recordAppoints.stream()
                                .filter(record -> {
                                    try {
                                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                        Date time = sdf.parse(record.getTimeFrame().substring(11));
                                        return !time.before(lastWeekStartDate) && !time.after(lastOfDate);
                                    } catch (ParseException e) {
                                        return false;
                                    }
                                })
                                .collect(Collectors.toList());
                            recordAppoints = recordAppoints.stream()
                                    .filter(record -> {
                                        try {
                                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                            Date time = sdf.parse(record.getTimeFrame().substring(11));
                                            return !time.before(lastWeekStartDate) && !time.after(lastOfDate);
                                        } catch (ParseException e) {
                                            return false;
                                        }
                                    })
                                    .collect(Collectors.toList());
                        break;
                    case 2:
                        Date lastMonthStartDate = DateUtil.getLastMonthStartDate();
                        recordAppoints = recordAppoints.stream()
                                .filter(record -> {
                                    try {
                                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                                        Date time = sdf.parse(record.getTimeFrame().substring(11));
                                        return !time.before(lastMonthStartDate) && !time.after(lastOfDate);
                                    } catch (ParseException e) {
                                        return false;
                                    }
                                })
                                .collect(Collectors.toList());
                            recordAppoints = recordAppoints.stream()
                                    .filter(record -> {
                                        try {
                                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                                            Date time = sdf.parse(record.getTimeFrame().substring(11));
                                            return !time.before(lastMonthStartDate) && !time.after(lastOfDate);
                                        } catch (ParseException e) {
                                            return false;
                                        }
                                    })
                                    .collect(Collectors.toList());
                        break;
                    case 3:
                        Date lastYearStartDate = DateUtil.getLastYearStartDate();
                        recordAppoints = recordAppoints.stream()
                                .filter(record -> {
                                    try {
                                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                        Date time = sdf.parse(record.getTimeFrame().substring(11));
                                        return !time.before(lastYearStartDate) && !time.after(lastOfDate);
                                    } catch (ParseException e) {
                                        return false;
                                    }
                                })
                                .collect(Collectors.toList());
                            recordAppoints = recordAppoints.stream()
                                    .filter(record -> {
                                        try {
                                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                            Date time = sdf.parse(record.getTimeFrame().substring(11));
                                            return !time.before(lastYearStartDate) && !time.after(lastOfDate);
                                        } catch (ParseException e) {
                                            return false;
                                        }
                                    })
                                    .collect(Collectors.toList());
                        break;
                    default:
                        break;
                }
            }
            recordVo.setAppointList(recordAppoints);
        }
        return recordVo;
        return recordAppoints;
    }
    @Override
@@ -682,14 +698,35 @@
        return null;
    }
    /**
     *
     * @param space 1=升序/2=降序
     * @param cityCode 城市code
     * @param latitude
     * @param longitude
     * @return
     */
    @Override
    public List<StoreDetailList> queryStoreList(Integer space,String cityCode,String latitude,String longitude) {
    public List<StoreDetailList> queryStoreList(Integer space,String cityCode,String latitude,String longitude,String search) {
        StoreOfCitycodeResp citycodeResp = new StoreOfCitycodeResp();
        citycodeResp.setSpace(space);
        citycodeResp.setCityCode(cityCode);
        citycodeResp.setLongitude(latitude);
        citycodeResp.setLatitude(longitude);
        return storeClient.getQueryStoreList(citycodeResp);
        List<StoreDetailList> queryStoreList = storeClient.getQueryStoreList(citycodeResp);
        if (queryStoreList.size() > 0){
            if (ToolUtil.isEmpty(space) || space == 2){
                queryStoreList = queryStoreList.stream()
                        .sorted(Comparator.comparing(StoreDetailList::getStoreDistance).reversed())
                        .collect(Collectors.toList());
            }else {
                queryStoreList =  queryStoreList.stream().sorted(Comparator.comparing(o -> o.getStoreDistance())).collect(Collectors.toList());
            }
            if (ToolUtil.isNotEmpty(search)){
                queryStoreList =  queryStoreList.stream().filter(o -> o.getStoreName().contains(search)).collect(Collectors.toList());
            }
        }
        return queryStoreList;
    }
    @Override
@@ -697,8 +734,10 @@
        Store store = storeClient.queryStoreById(storeId);
        StoreDetailsVo detailsVo = new StoreDetailsVo();
        String realPicture = store.getRealPicture();
        String[] split = realPicture.split(",");
        detailsVo.setImages(Arrays.asList(split));
        if (ToolUtil.isNotEmpty(realPicture)){
            String[] split = realPicture.split(",");
            detailsVo.setImages(Arrays.asList(split));
        }
        detailsVo.setStoreId(store.getId());
        detailsVo.setStoreName(store.getName());
        detailsVo.setStoreAddress(store.getAddress());
@@ -708,7 +747,9 @@
        detailsVo.setLat(store.getLat());
        detailsVo.setPhone(store.getPhone());
        detailsVo.setVenueList(steClient.getAppUserSiteList());
        detailsVo.setCourseVoList(culisClient.getStoreOfCourseList(storeId));
        List<StoreOfCourseVo> storeOfCourseList = culisClient.getStoreOfCourseList(storeId);
        System.out.println(storeOfCourseList);
        detailsVo.setCourseVoList(storeOfCourseList);
        return detailsVo;
    }