| | |
| | | package com.dsh.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.account.entity.Coach; |
| | |
| | | import com.dsh.account.mapper.TStudentMapper; |
| | | import com.dsh.account.model.vo.classDetails.AppointmentRecordVo; |
| | | import com.dsh.account.model.vo.classDetails.ClasspaymentRequest; |
| | | import com.dsh.account.model.vo.classDetails.StuEditInfoReq; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.ClassDetailsInsVo; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.StuDetailsReq; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.StuListVo; |
| | | 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; |
| | |
| | | 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); |
| | |
| | | @Override |
| | | public List<PurchaseRecordVo> queryDeduRecordDetails(RecordTimeRequest timeRequest,Integer appUserId) { |
| | | List<PurchaseRecordVo> purchaseRecordVoList = new ArrayList<>(); |
| | | 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); |
| | |
| | | List<TAppUser> tAppUsers = tauMapper.selectList(new QueryWrapper<TAppUser>() |
| | | .eq("referralUserId",appUserId ) |
| | | .between("insertTime",startTime ,endTime)); |
| | | List<Integer> userIds = tAppUsers.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | IntrduceOfUserRequest request = new IntrduceOfUserRequest(); |
| | | request.setStartTime(startTime); |
| | | request.setEndTime(endTime); |
| | | request.setUserIds(userIds); |
| | | List<PurchaseRecordVo> purchaseRecordVos1 = idrClient.queryAppUsersofIntroduce(request); |
| | | purchaseRecordVoList.addAll(purchaseRecordVos1); |
| | | if (ToolUtil.isNotEmpty(tAppUsers)){ |
| | | List<Integer> userIds = tAppUsers.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | IntrduceOfUserRequest request = new IntrduceOfUserRequest(); |
| | | request.setStartTime(startTime); |
| | | request.setEndTime(endTime); |
| | | request.setUserIds(userIds); |
| | | List<PurchaseRecordVo> purchaseRecordVos1 = idrClient.queryAppUsersofIntroduce(request); |
| | | purchaseRecordVoList.addAll(purchaseRecordVos1); |
| | | } |
| | | |
| | | if (purchaseRecordVoList.size() > 0 ){ |
| | | purchaseRecordVoList = purchaseRecordVoList.stream() |
| | | .filter(record -> { |
| | | String fieldValue = record.getPurchaseAmount(); |
| | | if (ToolUtil.isNotEmpty(timeRequest.getType())){ |
| | | switch (timeRequest.getType()){ |
| | | case 1: |
| | | return fieldValue != null && !fieldValue.isEmpty() && fieldValue.charAt(0) == '-'; |
| | | case 2: |
| | | return fieldValue != null && !fieldValue.isEmpty() && fieldValue.charAt(0) == '+'; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | return false; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | purchaseRecordVoList = dealDataOfTime(purchaseRecordVoList); |
| | | return purchaseRecordVoList; |
| | |
| | | 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(); |
| | |
| | | if (ToolUtil.isNotEmpty(tStudent)){ |
| | | recordVo.setStuId(tStudent.getId()); |
| | | recordVo.setStuName(tStudent.getName()); |
| | | List<RecordAppoint> recordAppoints = couPayClient.obtainStudentClassDetailsData(stuId); |
| | | WeeksOfCourseRest courseRest = new WeeksOfCourseRest(); |
| | | courseRest.setAppUserId(appUserId); |
| | | courseRest.setStuId(stuId); |
| | | List<RecordAppoint> recordAppoints = couPayClient.obtainStudentClassDetailsData(courseRest); |
| | | if (ToolUtil.isEmpty(appointStatus)){ |
| | | recordVo.setAppointStatus(0); |
| | | }else { |
| | | recordVo.setAppointStatus(appointStatus); |
| | | recordAppoints = recordAppoints.stream() |
| | | .filter(record -> record.getStatus().equals(appointStatus)) |
| | | .collect(Collectors.toList()); |
| | | if (recordAppoints.size() > 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 (recordAppoints.size() > 0 ){ |
| | | recordAppoints = recordAppoints.stream() |
| | | .filter(record -> record.getCoursePackageName().contains(search)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |
| | | if (ToolUtil.isNotEmpty(timeType)){ |
| | | Date lastOfDate = DateUtil.getLastOfDate(); |
| | | 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()); |
| | | if (recordAppoints.size() > 0 ){ |
| | | 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()); |
| | | if (recordAppoints.size() > 0 ){ |
| | | 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()); |
| | | if (recordAppoints.size() > 0 ){ |
| | | 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; |
| | |
| | | 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 |
| | |
| | | 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()); |
| | |
| | | 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; |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil commitEditStudentInfo(StuEditInfoReq stu, Integer userIdFormRedis) { |
| | | TStudent tStudent = this.baseMapper.selectOne(new LambdaQueryWrapper<TStudent>() |
| | | .eq(TStudent::getId,stu.getId()) |
| | | .eq(TStudent::getAppUserId,userIdFormRedis)); |
| | | if (ToolUtil.isEmpty(tStudent)){ |
| | | ResultUtil.error("会员信息不存在!"); |
| | | } |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | tStudent.setHeadImg(stu.getHeadImg()); |
| | | tStudent.setName(stu.getName()); |
| | | tStudent.setPhone(ToolUtil.isEmpty(stu.getPhone()) ? "":stu.getPhone()); |
| | | try { |
| | | tStudent.setBirthday(simpleDateFormat.parse(stu.getBirthday())); |
| | | } catch (ParseException e) { |
| | | ResultUtil.runErr(); |
| | | } |
| | | tStudent.setSex(stu.getSex()); |
| | | tStudent.setHeight(stu.getHeight()); |
| | | tStudent.setWeight(stu.getWeight()); |
| | | tStudent.setIdCard(ToolUtil.isEmpty(stu.getIdCard()) ? "" : stu.getIdCard()); |
| | | this.baseMapper.updateById(tStudent); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | } |