| | |
| | | import com.dsh.course.feignclient.account.AppUserClient; |
| | | import com.dsh.course.feignclient.account.CoachClient; |
| | | import com.dsh.course.feignclient.account.StudentClient; |
| | | import com.dsh.course.feignclient.account.model.AppUser; |
| | | import com.dsh.course.feignclient.account.model.Coach; |
| | | import com.dsh.course.feignclient.account.model.Student; |
| | | import com.dsh.course.feignclient.account.model.TCourseInfoRecord; |
| | | import com.dsh.course.feignclient.account.UserIntegralChangesClient; |
| | | import com.dsh.course.feignclient.account.model.*; |
| | | import com.dsh.course.feignclient.activity.BenefitVideoClient; |
| | | import com.dsh.course.feignclient.activity.CouponClient; |
| | | import com.dsh.course.feignclient.activity.model.BenefitsVideos; |
| | |
| | | @Autowired |
| | | private ICoursePackageSchedulingService coursePackageSchedulingService; |
| | | |
| | | |
| | | @Autowired |
| | | private RestTemplate internalRestTemplate; |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private UserIntegralChangesClient userIntegralChangesClient; |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public int changeState(CoursePackagePayDTO dto) { |
| | | List<String> ids = dto.getIds(); |
| | | List<Long> list = new ArrayList<>(); |
| | | for (String id : ids) { |
| | | long value = Long.parseLong(id); |
| | | list.add(value); |
| | | } |
| | | return cpConfigMapper.changeState(list,dto.getPayUserName(),dto.getUserId()); |
| | | |
| | | return cpConfigMapper.changeState(Long.valueOf(dto.getIds()), dto.getPayUserName(), dto.getUserId()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | STime = query.getRegisterTime().split(" - ")[0] + " 00:00:00"; |
| | | ETime = query.getRegisterTime().split(" - ")[1] + " 23:59:59"; |
| | | } |
| | | return cpConfigMapper.listAllRegister(query,STime,ETime,query.getAmount()); |
| | | return cpConfigMapper.listAllRegister(query, STime, ETime, query.getAmount()); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getStudentTotal(StudentQeryDto studentQeryDto) { |
| | | List<Map<String, Object>> studentTotal = this.baseMapper.getStudentTotal(studentQeryDto); |
| | | // String cityCode = studentQeryDto.getCityCode(); |
| | | // String start = studentQeryDto.getStart(); |
| | | // String end = studentQeryDto.getEnd(); |
| | | // //获取用户数据 |
| | | // List<Integer> appUserIds = null; |
| | | // if(ToolUtil.isNotEmpty(cityCode)){ |
| | | // List<AppUser> appUsers = appuClient.queryAppUserByCityCode(cityCode); |
| | | // if(appUsers.size() > 0){ |
| | | // appUserIds = appUsers.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | // } |
| | | // } |
| | | // QueryWrapper<CoursePackageStudent> status = new QueryWrapper<CoursePackageStudent>().eq("payStatus", 2).eq("status", 1); |
| | | // if(null != appUserIds){ |
| | | // status.in("appUserId", appUserIds); |
| | | // } |
| | | // List<Map<String, Object>> maps = this.baseMapper.getStudentTotal(appUserIds, studentQeryDto.getStart(), studentQeryDto.getEnd()); |
| | | // List<Map<String, Object>> list = new ArrayList<>(); |
| | | // for (Map<String, Object> objectMap : maps) { |
| | | // Integer studentId = Integer.valueOf(objectMap.get("studentId").toString()); |
| | | // Integer appUserId = Integer.valueOf(objectMap.get("appUserId").toString()); |
| | | // Integer coursePackageId = Integer.valueOf(objectMap.get("coursePackageId").toString()); |
| | | // Integer number = Integer.valueOf(objectMap.get("number").toString()); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // Student student = studentClient.queryStudentById(studentId); |
| | | // map.put("studentName", student.getName()); |
| | | // AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | // map.put("province", appUser.getProvince()); |
| | | // map.put("provinceCode", appUser.getProvinceCode()); |
| | | // map.put("city", appUser.getCity()); |
| | | // map.put("cityCode", appUser.getCityCode()); |
| | | // TCoursePackage coursePackage = coursePackageService.getById(coursePackageId); |
| | | // map.put("courseName", coursePackage.getName()); |
| | | // map.put("totalClassHours", number); |
| | | // map.put("cashPayment", coursePackageOrder.getCashPayment()); |
| | | // map.put("hasHours", ) |
| | | // |
| | | // |
| | | // } |
| | | |
| | | for (Map<String, Object> student : studentTotal) { |
| | | Integer appUserId = (Integer) student.get("appUserId"); |
| | | AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | student.put("province", appUser.getProvince()); |
| | | student.put("provinceCode", appUser.getProvinceCode()); |
| | | |
| | | student.put("city", appUser.getCity()); |
| | | student.put("cityCode", appUser.getCityCode()); |
| | | |
| | | Student studentId = studentClient.queryStudentById((Integer) student.get("studentId")); |
| | | student.put("studentName", studentId.getName()); |
| | | BigDecimal cashPayment = (BigDecimal) student.get("cashPayment"); |
| | | BigDecimal totalClassHours = (BigDecimal) student.get("totalClassHours"); |
| | | BigDecimal hasHours = (BigDecimal) student.get("hasHours"); |
| | | if (cashPayment==null){ |
| | | continue; |
| | | } |
| | | if (totalClassHours.compareTo(BigDecimal.ZERO)==0){ |
| | | totalClassHours = totalClassHours.add(new BigDecimal("1")); |
| | | } |
| | | BigDecimal hasPayment = cashPayment.divide(totalClassHours, 2, RoundingMode.HALF_UP) |
| | | .multiply(hasHours).setScale(2, RoundingMode.HALF_UP); |
| | | student.put("hasPayment", hasPayment); |
| | | } |
| | | |
| | | if (studentQeryDto.getCityCode()!=null&&studentQeryDto.getCityCode()!="") { |
| | | String value = studentQeryDto.getCityCode(); |
| | | boolean allZeros = value.substring(value.length() - 4).endsWith("0000"); |
| | | System.out.println(allZeros); // Output: true |
| | | if (allZeros){ |
| | | Iterator<Map<String, Object>> iterator = studentTotal.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Map<String, Object> student = iterator.next(); |
| | | String cityCode = (String) student.get("provinceCode"); |
| | | if (!cityCode.equals(studentQeryDto.getCityCode())) { |
| | | iterator.remove(); // Remove the element from the list |
| | | } |
| | | } |
| | | }else{ |
| | | Iterator<Map<String, Object>> iterator = studentTotal.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Map<String, Object> student = iterator.next(); |
| | | String cityCode = (String) student.get("cityCode"); |
| | | if (!cityCode.equals(studentQeryDto.getCityCode())) { |
| | | iterator.remove(); // Remove the element from the list |
| | | } |
| | | }} |
| | | } |
| | | |
| | | if (studentQeryDto.getStudentName()!=null&&studentQeryDto.getStudentName()!=""){ |
| | | List<Map<String, Object>> totallike = new ArrayList<>(); |
| | | for (Map<String, Object> student : studentTotal) { |
| | | String studentName = (String) student.get("studentName"); |
| | | if (studentName.contains(studentQeryDto.getStudentName())){ |
| | | totallike.add(student); |
| | | } |
| | | |
| | | } |
| | | return totallike; |
| | | } |
| | | return studentTotal; |
| | | // List<Map<String, Object>> studentTotal = this.baseMapper.getStudentTotal(studentQeryDto); |
| | | // for (Map<String, Object> student : studentTotal) { |
| | | // Integer appUserId = (Integer) student.get("appUserId"); |
| | | // AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | // student.put("province", appUser.getProvince()); |
| | | // student.put("provinceCode", appUser.getProvinceCode()); |
| | | // |
| | | // student.put("city", appUser.getCity()); |
| | | // student.put("cityCode", appUser.getCityCode()); |
| | | // |
| | | // Student studentId = studentClient.queryStudentById((Integer) student.get("studentId")); |
| | | // student.put("studentName", studentId.getName()); |
| | | // BigDecimal cashPayment = (BigDecimal) student.get("cashPayment"); |
| | | // BigDecimal totalClassHours = (BigDecimal) student.get("totalClassHours"); |
| | | // BigDecimal hasHours = (BigDecimal) student.get("hasHours"); |
| | | // if (cashPayment == null) { |
| | | // continue; |
| | | // } |
| | | // if (totalClassHours.compareTo(BigDecimal.ZERO) == 0) { |
| | | // totalClassHours = totalClassHours.add(new BigDecimal("1")); |
| | | // } |
| | | // BigDecimal hasPayment = cashPayment.divide(totalClassHours, 2, RoundingMode.HALF_UP) |
| | | // .multiply(hasHours).setScale(2, RoundingMode.HALF_UP); |
| | | // student.put("hasPayment", hasPayment); |
| | | // } |
| | | // |
| | | // if (studentQeryDto.getCityCode() != null && studentQeryDto.getCityCode() != "") { |
| | | // String value = studentQeryDto.getCityCode(); |
| | | // boolean allZeros = value.substring(value.length() - 4).endsWith("0000"); |
| | | // System.out.println(allZeros); // Output: true |
| | | // if (allZeros) { |
| | | // Iterator<Map<String, Object>> iterator = studentTotal.iterator(); |
| | | // while (iterator.hasNext()) { |
| | | // Map<String, Object> student = iterator.next(); |
| | | // String cityCode = (String) student.get("provinceCode"); |
| | | // if (!cityCode.equals(studentQeryDto.getCityCode())) { |
| | | // iterator.remove(); // Remove the element from the list |
| | | // } |
| | | // } |
| | | // } else { |
| | | // Iterator<Map<String, Object>> iterator = studentTotal.iterator(); |
| | | // while (iterator.hasNext()) { |
| | | // Map<String, Object> student = iterator.next(); |
| | | // String cityCode = (String) student.get("cityCode"); |
| | | // if (!cityCode.equals(studentQeryDto.getCityCode())) { |
| | | // iterator.remove(); // Remove the element from the list |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // if (studentQeryDto.getStudentName() != null && studentQeryDto.getStudentName() != "") { |
| | | // List<Map<String, Object>> totallike = new ArrayList<>(); |
| | | // for (Map<String, Object> student : studentTotal) { |
| | | // String studentName = (String) student.get("studentName"); |
| | | // if (studentName.contains(studentQeryDto.getStudentName())) { |
| | | // totallike.add(student); |
| | | // } |
| | | // |
| | | // } |
| | | // return totallike; |
| | | // } |
| | | // return studentTotal; |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> bypac(PacQueryDto pacQueryDto) { |
| | | if (pacQueryDto.getCityCode()!=null&&pacQueryDto.getCityCode()!=""){ |
| | | if (pacQueryDto.getCityCode() != null && pacQueryDto.getCityCode() != "") { |
| | | String value = pacQueryDto.getCityCode(); |
| | | boolean allZeros = value.substring(value.length() - 4).endsWith("0000"); |
| | | System.out.println(allZeros); // Output: true |
| | | |
| | | if (allZeros){ |
| | | if (allZeros) { |
| | | pacQueryDto.setProvinceCode(pacQueryDto.getCityCode()); |
| | | pacQueryDto.setCityCode(null); |
| | | } |
| | |
| | | } |
| | | List<Map<String, Object>> maps = this.baseMapper.pacQueryDto(pacQueryDto); |
| | | |
| | | if (pacQueryDto.getName()!=null&&pacQueryDto.getName()!=""){ |
| | | if (pacQueryDto.getName() != null && pacQueryDto.getName() != "") { |
| | | List<Map<String, Object>> totallike = new ArrayList<>(); |
| | | for (Map<String, Object> student : maps) { |
| | | String studentName = (String) student.get("name"); |
| | | if (studentName.contains(pacQueryDto.getName())){ |
| | | if (studentName.contains(pacQueryDto.getName())) { |
| | | totallike.add(student); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 获取课包购买人数 |
| | | * |
| | | * @param coursePackageId |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<AppUserVideoResponse> queryAfterVideo(CourseOfAfterRequest search,List<Integer> courseIds) { |
| | | public List<AppUserVideoResponse> queryAfterVideo(CourseOfAfterRequest search, List<Integer> courseIds) { |
| | | List<AppUserVideoResponse> responses = new ArrayList<>(); |
| | | List<PostCourseVideo> videoList = new ArrayList<>(); |
| | | LambdaQueryWrapper<PostCourseVideo> queryWrapper = new LambdaQueryWrapper<PostCourseVideo>(); |
| | | if (courseIds.size() > 0 ){ |
| | | queryWrapper.in(PostCourseVideo::getCoursePackageId,courseIds); |
| | | if (courseIds.size() > 0) { |
| | | queryWrapper.in(PostCourseVideo::getCoursePackageId, courseIds); |
| | | } |
| | | videoList = pcvMapper.selectList(queryWrapper); |
| | | System.out.println(videoList); |
| | | if (videoList.size() > 0){ |
| | | if (videoList.size() > 0) { |
| | | List<Integer> videoIds = videoList.stream().map(PostCourseVideo::getCourseId).collect(Collectors.toList()); |
| | | List<UserVideoDetails> userVideoDetails = uvdmapper.selectList(new QueryWrapper<UserVideoDetails>() |
| | | .in("courseId", videoIds)); |
| | | if (userVideoDetails.size() > 0){ |
| | | if (userVideoDetails.size() > 0) { |
| | | for (UserVideoDetails userVideoDetail : userVideoDetails) { |
| | | AppUserVideoResponse response = new AppUserVideoResponse(); |
| | | TCoursePackage coursePackage = tcpmapper.selectById(userVideoDetail.getCoursePackageId()); |
| | |
| | | } |
| | | Collections.sort(responses, Comparator.comparing(AppUserVideoResponse::getStudyStatus)); |
| | | } |
| | | if (ToolUtil.isNotEmpty(search.getSearch())){ |
| | | if (ToolUtil.isNotEmpty(search.getSearch())) { |
| | | responses = responses.stream() |
| | | .filter(person -> person.getPackageName().contains(search.getSearch())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | if (ToolUtil.isNotEmpty(search.getCourseTypeId())){ |
| | | if (ToolUtil.isNotEmpty(search.getCourseTypeId())) { |
| | | responses = responses.stream() |
| | | .filter(person -> Objects.equals(person.getCoursePackageId(), search.getCourseTypeId())) |
| | | .collect(Collectors.toList()); |
| | |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | @Autowired |
| | | private TCourseService courseService; |
| | | |
| | | @Override |
| | | public CourseOfVideoResponse queryVideoDetails(CourseWithDetailsRequest detailsRequest,Integer appUserId) { |
| | | public CourseOfVideoResponse queryVideoDetails(CourseWithDetailsRequest detailsRequest, Integer appUserId) { |
| | | CourseOfVideoResponse response = new CourseOfVideoResponse(); |
| | | // BenefitsVideos videosWithIds = bfvoClient.getVideosWithIds(detailsRequest.getVideoId()); |
| | | TCourse byId = courseService.getById(detailsRequest.getVideoId()); |
| | | TCoursePackage coursePackage = tcpmapper.selectById(detailsRequest.getCoursePackageId()); |
| | | CoursePackageScheduling byId1 = new CoursePackageScheduling(); |
| | | if (detailsRequest.getScId() != null) { |
| | | byId1 = coursePackageSchedulingService.getById(detailsRequest.getScId()); |
| | | } |
| | | |
| | | if (null != coursePackage){ |
| | | if (null != coursePackage) { |
| | | response.setCoursePackageId(coursePackage.getId()); |
| | | response.setVideoId(byId.getId()); |
| | | response.setVideoURL(byId.getCourseVideo()); |
| | | response.setVideoName(coursePackage.getName()); |
| | | // response.setIntegral(byId.getIntegral()); |
| | | UserVideoDetails userVideoDetails = uvdmapper.selectOne(new QueryWrapper<UserVideoDetails>() |
| | | .eq("appUserId",appUserId ) |
| | | .eq("coursePackageId",coursePackage.getId()) |
| | | .eq("courseId",detailsRequest.getVideoId())); |
| | | .eq("appUserId", appUserId) |
| | | .eq("coursePackageId", coursePackage.getId()) |
| | | .eq("courseId", detailsRequest.getVideoId())); |
| | | |
| | | if (userVideoDetails!=null) { |
| | | if (userVideoDetails != null) { |
| | | response.setStudyStatus(userVideoDetails.getState()); |
| | | }else { |
| | | } else { |
| | | response.setStudyStatus(1); |
| | | } |
| | | response.setPackageName(coursePackage.getName()); |
| | | response.setSynopsis(byId.getIntroduce()); |
| | | response.setDetailedDiagram(byId.getIntroductionDrawing()); |
| | | response.setCover(byId.getCoverDrawing()); |
| | | if (byId1.getIntegral() != null) { |
| | | response.setIntegral(String.valueOf(byId1.getIntegral())); |
| | | } |
| | | |
| | | } |
| | | |
| | | return response; |
| | |
| | | @Override |
| | | public String updateVideoStatus(UpdateCourseVideoStatusRequest detailsRequest, Integer appUserId) { |
| | | UserVideoDetails userVideoDetails = uvdmapper.selectOne(new QueryWrapper<UserVideoDetails>() |
| | | .eq("appUserId",appUserId ) |
| | | .eq("coursePackageId",detailsRequest.getCoursePackageId()) |
| | | .eq("courseId",detailsRequest.getVideoId()) |
| | | ); |
| | | if (null != userVideoDetails && userVideoDetails.getState() ==1 && detailsRequest.getIsOver() == 1){ |
| | | .eq("appUserId", appUserId) |
| | | .eq("coursePackageId", detailsRequest.getCoursePackageId()) |
| | | .eq("courseId", detailsRequest.getVideoId()) |
| | | ); |
| | | if (null != userVideoDetails && userVideoDetails.getState() == 1 && detailsRequest.getIsOver() == 1) { |
| | | userVideoDetails.setState(2); |
| | | userVideoDetails.setUpdateTime(new Date()); |
| | | uvdmapper.updateById(userVideoDetails); |
| | | |
| | | CoursePackageScheduling coursePackageScheduling = coursePackageSchedulingService.getById(detailsRequest.getScId()); |
| | | //添加积分 |
| | | AppUser appUser = appuClient.queryAppUser(coursePackageScheduling.getAppUserId()); |
| | | appUser.setIntegral((null == appUser.getIntegral() ? 0 : appUser.getIntegral()) + (null == coursePackageScheduling.getIntegral() ? 0 : coursePackageScheduling.getIntegral())); |
| | | appuClient.updateAppUser(appUser); |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(coursePackageScheduling.getAppUserId()); |
| | | vo.setIntegral(coursePackageScheduling.getIntegral()); |
| | | vo.setType(4); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | return "SUCCESS"; |
| | | } |
| | | return "ERROR"; |
| | | } |
| | | |
| | | @Autowired |
| | | private TOrderService orderService; |
| | | |
| | | @Override |
| | | public List<RegisterCourseVo> queryRegisteredCourseList(CourseOfAfterRequest courseTypeId, Integer appUserId) { |
| | | List<RegisterCourseVo> courseVos = new ArrayList<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = this.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",appUserId )); |
| | | |
| | | List<TOrder> orders = orderService.list(new QueryWrapper<TOrder>().eq("appUserId", appUserId)); |
| | | |
| | | List<String> paysId = new ArrayList<>(); |
| | | |
| | | List<TCoursePackagePayment> tCoursePackagePayments = new ArrayList<>(); |
| | | for (TOrder order : orders) { |
| | | String[] split = order.getPaysId().split(","); |
| | | // paysId.add(split[0]); |
| | | TCoursePackagePayment byId = this.getById(split[0]); |
| | | byId.setPayStatus(order.getIsPay()); |
| | | byId.setOrderId(order.getId()); |
| | | tCoursePackagePayments.add(byId); |
| | | } |
| | | |
| | | // List<TCoursePackagePayment> tCoursePackagePayments = this.list(new QueryWrapper<TCoursePackagePayment>() |
| | | // .eq("appUserId",appUserId )); |
| | | // List<TCoursePackagePayment> tCoursePackagePayments = this.list(new QueryWrapper<TCoursePackagePayment>() |
| | | // .in("id",paysId )); |
| | | |
| | | |
| | | System.out.println(tCoursePackagePayments); |
| | | if (tCoursePackagePayments.size() > 0){ |
| | | if (tCoursePackagePayments.size() > 0) { |
| | | try { |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | TCoursePackage coursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); |
| | |
| | | // 2.0 |
| | | registerCourseVo.setType(coursePackage.getType()); |
| | | |
| | | registerCourseVo.setOrderId(tCoursePackagePayment.getOrderId().longValue()); |
| | | registerCourseVo.setCoursePayId(tCoursePackagePayment.getId()); |
| | | registerCourseVo.setCoursePackageId(tCoursePackagePayment.getCoursePackageId()); |
| | | registerCourseVo.setCoursePackTypeId(coursePackage.getCoursePackageTypeId()); |
| | | registerCourseVo.setPackageImg(coursePackage.getCoverDrawing()); |
| | | String storeAndCourse = coursePackage.getName()+"("+ store.getName() +")"; |
| | | String storeAndCourse = coursePackage.getName() + "(" + store.getName() + ")"; |
| | | registerCourseVo.setCourseNameStore(storeAndCourse); |
| | | // registerCourseVo.setCourseTime(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); |
| | | // 2.0 |
| | | registerCourseVo.setCourseTime(new SimpleDateFormat("yyyy-MM-dd").format(tCoursePackagePayment.getInsertTime())); |
| | | Coach coach = coachClient.queryCoachById(coursePackage.getCoachId()); |
| | | registerCourseVo.setCourseTeacher(ToolUtil.isEmpty(coach) ? "" : coach.getName()); |
| | | if (coursePackage.getType()==2) { |
| | | if (coursePackage.getType() == 2) { |
| | | registerCourseVo.setTime(new SimpleDateFormat("yyyy-MM-dd").format(coursePackage.getStartTime()) + "-" + new SimpleDateFormat("yyyy-MM-dd").format(coursePackage.getEndTime())); |
| | | } |
| | | List<CoursePackageStudent> coursePackageStudents = cpsMapper.selectList(new QueryWrapper<CoursePackageStudent>() |
| | | .eq("coursePackageId",coursePackage.getId()) |
| | | .eq("appUserId",appUserId )); |
| | | .eq("coursePackageId", coursePackage.getId()) |
| | | .eq("appUserId", appUserId)); |
| | | |
| | | List<Long> ids = new ArrayList<>(); |
| | | for (CoursePackageStudent coursePackageStudent : coursePackageStudents) { |
| | | ids.add(coursePackageStudent.getCoursePackageSchedulingId()); |
| | | } |
| | | List<CoursePackageScheduling> cps =new ArrayList<>(); |
| | | List<CoursePackageScheduling> cps = new ArrayList<>(); |
| | | |
| | | if (!ids.isEmpty()) { |
| | | cps = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id", ids)); |
| | | cps = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id", ids)); |
| | | } |
| | | Integer counts = 0; |
| | | |
| | | for (CoursePackageScheduling cp : cps) { |
| | | if (cp.getDeductClassHour()!=null) { |
| | | if (cp.getDeductClassHour() != null) { |
| | | counts = counts + cp.getDeductClassHour(); |
| | | } |
| | | } |
| | |
| | | // .eq("coursePackageId",coursePackage.getId()) |
| | | // .eq("appUserId",appUserId )); |
| | | |
| | | if (coursePackageStudents.size() > 0 ){ |
| | | if (coursePackageStudents.size() > 0) { |
| | | // registerCourseVo.setCourseNums(coursePackageStudents.size() * 2); |
| | | registerCourseVo.setCourseNums(counts); |
| | | } |
| | | // registerCourseVo.setPayStatus(tCoursePackagePayment.getPayStatus()); |
| | | registerCourseVo.setPayStatus(tCoursePackagePayment.getPayStatus()); |
| | | |
| | | courseVos.add(registerCourseVo); |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (ToolUtil.isNotEmpty(courseTypeId.getSearch())){ |
| | | if (ToolUtil.isNotEmpty(courseTypeId.getSearch())) { |
| | | courseVos = courseVos.stream() |
| | | .filter(person -> person.getCourseNameStore().contains(courseTypeId.getSearch())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | if (ToolUtil.isNotEmpty(courseTypeId.getCourseTypeId())){ |
| | | if (ToolUtil.isNotEmpty(courseTypeId.getCourseTypeId())) { |
| | | courseVos = courseVos.stream() |
| | | .filter(person -> Objects.equals(person.getCoursePackTypeId(), courseTypeId.getCourseTypeId())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | if (courseVos.size() > 0 ){ |
| | | if (courseVos.size() > 0) { |
| | | courseVos = courseVos.stream() |
| | | .sorted(Comparator.comparingInt(person -> person.getPayStatus() == 1 ? -1 : 1)) |
| | | .collect(Collectors.toList()); |
| | |
| | | } |
| | | |
| | | @Autowired |
| | | private ICoursePackagePaymentConfigService coursePackagePaymentConfigService; |
| | | private ICoursePackagePaymentConfigService coursePackagePaymentConfigService; |
| | | |
| | | @Autowired |
| | | private TCoursePackageDiscountService coursePackageDiscountService; |
| | | private TCoursePackageDiscountService coursePackageDiscountService; |
| | | |
| | | @Resource |
| | | StoreClient storeClient; |
| | | |
| | | @Autowired |
| | | private ICoursePackageOrderService coursePackageOrderService; |
| | | |
| | | @Autowired |
| | | private ICoursePackageOrderStudentService coursePackageOrderStudentService; |
| | | |
| | | @Autowired |
| | | private TCoursePackageService coursePackageService; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public CourseDetailsResponse queryRegisteredCourseDetails(Long coursePayId, Integer appUserId) { |
| | | public CourseDetailsResponse queryRegisteredCourseDetails(Long coursePayId, Integer appUserId, String lon, String lat) { |
| | | AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | CourseDetailsResponse response = new CourseDetailsResponse(); |
| | | TCoursePackagePayment tCoursePackagePayment = this.baseMapper.selectById(coursePayId); |
| | | CoursePackageOrder coursePackageOrder = coursePackageOrderService.getById(coursePayId); |
| | | if (coursePackageOrder==null){ |
| | | // student = coursePackageStudentService.getById(coursePayId); |
| | | CoursePackageOrderStudent student = coursePackageOrderStudentService.getById(coursePayId); |
| | | |
| | | if (null != tCoursePackagePayment){ |
| | | TCoursePackage coursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); |
| | | if (coursePackage.getType()==2) { |
| | | coursePackageOrder = coursePackageOrderService.getOne(new QueryWrapper<CoursePackageOrder>().eq("appUserId", student.getAppUserId()).like("studentIds", student.getStudentId()).eq("coursePackageId", student.getCoursePackageId()).orderByDesc("insertTime").last("limit 1")); |
| | | |
| | | } |
| | | response.setOrinPrice(coursePackageOrder.getOriginalPrice()); |
| | | |
| | | |
| | | response.setChooseHours(coursePackageOrder.getClassHours()); |
| | | response.setStuIds(coursePackageOrder.getStudentIds().split(",")); |
| | | response.setPayType(coursePackageOrder.getPayType()); |
| | | response.setPayPrice(coursePackageOrder.getCashPayment()); |
| | | response.setCoinPrice(coursePackageOrder.getPlayPaiCoin()); |
| | | |
| | | if (null != coursePackageOrder) { |
| | | TCoursePackage coursePackage = tcpmapper.selectById(coursePackageOrder.getCoursePackageId()); |
| | | if (coursePackage.getType() == 2) { |
| | | response.setTime(new SimpleDateFormat("yyyy.MM.dd").format(coursePackage.getStartTime()) + "-" + new SimpleDateFormat("yyyy.MM.dd").format(coursePackage.getEndTime())); |
| | | } |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | response.setStoreName(store.getName()); |
| | | response.setStoreAddress(store.getAddress()); |
| | | |
| | | |
| | | response.setCoursePackageId(tCoursePackagePayment.getCoursePackageId()); |
| | | if (ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)) { |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); |
| | | double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | response.setDistance(wgs84); |
| | | } |
| | | response.setCoursePackageId(coursePackageOrder.getCoursePackageId()); |
| | | response.setCoverDrawing(coursePackage.getCoverDrawing()); |
| | | response.setDetailDrawing(coursePackage.getDetailDrawing()); |
| | | response.setCoursePackageName(coursePackage.getName()); |
| | | response.setCoursePayId(tCoursePackagePayment.getId()); |
| | | response.setCoursePayId(coursePackageOrder.getId()); |
| | | response.setType(coursePackage.getType()); |
| | | List<Integer> integers = StrUtils.dealStrToList(coursePackage.getClassWeeks()); |
| | | String classWeeks = coursePackage.getClassWeeks(); |
| | | if (integers.size() > 0){ |
| | | StringBuilder courWeeks = new StringBuilder("每"+classWeeks); |
| | | // for (Integer integer : integers) { |
| | | // courWeeks.append(integer).append("、"); |
| | | // } |
| | | // if (courWeeks.length() > 0 && courWeeks.charAt(courWeeks.length() - 1) == '、'){ |
| | | // courWeeks.deleteCharAt(courWeeks.length() - 1); |
| | | // } |
| | | if (integers.size() > 0) { |
| | | StringBuilder courWeeks = new StringBuilder("每" + classWeeks); |
| | | response.setWeeks(courWeeks.toString()); |
| | | } |
| | | ArrayList<String> classTime = new ArrayList<>(); |
| | | String[] split4 = coursePackage.getClassStartTime().split(","); |
| | | String[] split3 = coursePackage.getClassEndTime().split(","); |
| | | if(ToolUtil.isNotEmpty(coursePackage.getClassStartTime())){ |
| | | if (ToolUtil.isNotEmpty(coursePackage.getClassStartTime())) { |
| | | for (int i = 0; i < split4.length; i++) { |
| | | String s = split4[i].substring(0,5) + "-" + split3[i].substring(0,5); |
| | | String s = split4[i].substring(0, 5) + "-" + split3[i].substring(0, 5); |
| | | classTime.add(s); |
| | | } |
| | | } |
| | |
| | | response.setCourseTimeFrame(joinedString); |
| | | |
| | | |
| | | // response.setCourseTimeFrame(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); |
| | | response.setIntroduceDrawing(coursePackage.getIntroduceDrawing()); |
| | | |
| | | Integer payType = tCoursePackagePayment.getPayType(); |
| | | BigDecimal cashPayment = tCoursePackagePayment.getCashPayment(); |
| | | double cashPaymentValue = 0.0; |
| | | if(cashPayment!=null){ |
| | | |
| | | cashPaymentValue = cashPayment.doubleValue(); |
| | | Integer payType = coursePackageOrder.getPayType(); |
| | | if(null == payType){ |
| | | CoursePackagePaymentConfig config = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours")).get(0); |
| | | if (ToolUtil.isNotEmpty(config.getCashPayment()) && config.getCashPayment() > 0 && ToolUtil.isNotEmpty(config.getPlayPaiCoin()) && config.getPlayPaiCoin() > 0) { |
| | | payType = 3; |
| | | } else if (ToolUtil.isNotEmpty(config.getCashPayment()) && config.getCashPayment() > 0) { |
| | | payType = 1; |
| | | } else if (ToolUtil.isNotEmpty(config.getPlayPaiCoin()) && config.getPlayPaiCoin() > 0) { |
| | | payType = 2; |
| | | } |
| | | } |
| | | Integer playPaiCoin = tCoursePackagePayment.getPlayPaiCoin(); |
| | | BigDecimal cashPayment = coursePackageOrder.getCashPayment(); |
| | | double cashPaymentValue = 0.0; |
| | | if (cashPayment != null) { |
| | | |
| | | cashPaymentValue = cashPayment.doubleValue(); |
| | | } |
| | | Integer playPaiCoin = coursePackageOrder.getPlayPaiCoin(); |
| | | TCoursePackageDiscount coursePackageDiscount = tcpdMapper.selectOne(new QueryWrapper<TCoursePackageDiscount>() |
| | | .eq("coursePackageId",coursePackage.getId() ) |
| | | .eq("type",1) |
| | | .eq("auditStatus",2)); |
| | | .eq("coursePackageId", coursePackage.getId()) |
| | | .eq("type", 1) |
| | | .eq("auditStatus", 2)); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | double discountMember = 0.0; |
| | | if(coursePackageDiscount!=null){ |
| | | if (coursePackageDiscount != null) { |
| | | String content = coursePackageDiscount.getContent(); |
| | | DiscountJsonDto discountJsonDto = null; |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | // switch (payType) { |
| | | // case 1: |
| | | // case 2: |
| | | // response.setAmount(cashPaymentValue); |
| | | // response.setVipAmount(discountMember); |
| | | // break; |
| | | // case 3: |
| | | // response.setWpGold(playPaiCoin); |
| | | // break; |
| | | // } |
| | | switch (payType) { |
| | | case 1: |
| | | case 3: |
| | | response.setAmount(cashPaymentValue); |
| | | response.setVipAmount(discountMember); |
| | | break; |
| | | case 2: |
| | | if (playPaiCoin!=null) { |
| | | response.setWpGold(playPaiCoin); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | // coursePackage.get |
| | | |
| | | |
| | | response.setPayStatus(tCoursePackagePayment.getPayStatus()); |
| | | response.setPayStatus(coursePackageOrder.getPayStatus()); |
| | | |
| | | |
| | | List<CoursePackagePaymentConfigVo> list = new ArrayList<>(); |
| | |
| | | coursePackagePaymentConfigVo.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePaymentConfigVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | |
| | | if(ToolUtil.isNotEmpty(coursePackagePaymentConfig.getCashPayment()) && coursePackagePaymentConfig.getCashPayment()>0 && ToolUtil.isNotEmpty(coursePackagePaymentConfig.getPlayPaiCoin()) && coursePackagePaymentConfig.getPlayPaiCoin()>0 ){ |
| | | if (ToolUtil.isNotEmpty(coursePackagePaymentConfig.getCashPayment()) && coursePackagePaymentConfig.getCashPayment() > 0 && ToolUtil.isNotEmpty(coursePackagePaymentConfig.getPlayPaiCoin()) && coursePackagePaymentConfig.getPlayPaiCoin() > 0) { |
| | | coursePackagePaymentConfigVo.setPayType(3); |
| | | }else if(ToolUtil.isNotEmpty(coursePackagePaymentConfig.getCashPayment()) && coursePackagePaymentConfig.getCashPayment()>0){ |
| | | } else if (ToolUtil.isNotEmpty(coursePackagePaymentConfig.getCashPayment()) && coursePackagePaymentConfig.getCashPayment() > 0) { |
| | | coursePackagePaymentConfigVo.setPayType(1); |
| | | }else if( ToolUtil.isNotEmpty(coursePackagePaymentConfig.getPlayPaiCoin()) && coursePackagePaymentConfig.getPlayPaiCoin()>0 ){ |
| | | } else if (ToolUtil.isNotEmpty(coursePackagePaymentConfig.getPlayPaiCoin()) && coursePackagePaymentConfig.getPlayPaiCoin() > 0) { |
| | | coursePackagePaymentConfigVo.setPayType(2); |
| | | } |
| | | |
| | | // coursePackagePaymentConfigVo.setPayType(coursePackage.getPayType()); |
| | | //会员显示原价和支付价(会员价)。非会员显示会员价和支付价(最低) |
| | | if(appUser.getIsVip() == 0){//非会员 |
| | | if (appUser.getIsVip() == 0) {//非会员 |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount1 : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount1.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | if (vipPrice.compareTo(num1) > 0) { |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | |
| | | Date startDate_date = sdf.parse(startDate); |
| | | Date endDate_date = sdf.parse(endDate); |
| | | long timeMillis = System.currentTimeMillis(); |
| | | if(timeMillis >= startDate_date.getTime() && timeMillis < endDate_date.getTime()){ |
| | | if (timeMillis >= startDate_date.getTime() && timeMillis < endDate_date.getTime()) { |
| | | Date date = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int week = calendar.get(Calendar.DAY_OF_WEEK); |
| | | boolean isFirstSunday = (calendar.getFirstDayOfWeek() == Calendar.SUNDAY); |
| | | if(isFirstSunday){ |
| | | if (isFirstSunday) { |
| | | week = week - 1; |
| | | if(week == 0){ |
| | | if (week == 0) { |
| | | week = 7; |
| | | } |
| | | } |
| | | if(!weeks.contains(week)){ |
| | | if (!weeks.contains(week)) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | e.set(Calendar.MINUTE, Integer.valueOf(split2[1])); |
| | | e.set(Calendar.SECOND, Integer.valueOf(split2[2])); |
| | | |
| | | if(hour1 > hour2){ |
| | | if(s.getTimeInMillis() > date.getTime()){ |
| | | if (hour1 > hour2) { |
| | | if (s.getTimeInMillis() > date.getTime()) { |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) - 1); |
| | | }else{ |
| | | } else { |
| | | e.set(Calendar.DAY_OF_YEAR, e.get(Calendar.DAY_OF_YEAR) + 1); |
| | | } |
| | | } |
| | | if(timeMillis >= s.getTimeInMillis() && timeMillis < e.getTimeInMillis() && paymentPrice.compareTo(cashPayment2) > 0){ |
| | | if (timeMillis >= s.getTimeInMillis() && timeMillis < e.getTimeInMillis() && paymentPrice.compareTo(cashPayment2) > 0) { |
| | | paymentPrice = cashPayment2; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | coursePackagePaymentConfigVo.setPaymentPrice(paymentPrice); |
| | | |
| | | if (coursePackagePaymentConfigVo.getPaymentPrice()<coursePackagePaymentConfigVo.getVipPrice()){ |
| | | |
| | | TCoursePackageDiscount discount = coursePackageDiscountService.getOne(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 2).eq("auditStatus", 2)); |
| | | |
| | | // Double continuingMember = JSON.parseObject(discount.getContent()).getDouble("continuingUser"); |
| | | // Double vipcontinuingMember = JSON.parseObject(discount.getContent()).getDouble("continuingMember"); |
| | | // |
| | | // |
| | | // if (coursePackagePaymentConfigVo.getPaymentPrice() > continuingMember) { |
| | | // coursePackagePaymentConfigVo.setPaymentPrice(continuingMember); |
| | | // } |
| | | // if (coursePackagePaymentConfigVo.getVipPrice() > vipcontinuingMember) { |
| | | // coursePackagePaymentConfigVo.setVipPrice(vipcontinuingMember); |
| | | // } |
| | | |
| | | |
| | | if (coursePackagePaymentConfigVo.getPaymentPrice() < coursePackagePaymentConfigVo.getVipPrice()) { |
| | | coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | coursePackagePaymentConfigVo.setVipPrice(null); |
| | | } |
| | | |
| | | } |
| | | else{ |
| | | } else { |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount3 : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount3.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | if (vipPrice.compareTo(num1) > 0) { |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | |
| | | } |
| | | list.add(coursePackagePaymentConfigVo); |
| | | }); |
| | | // coursePackageInfo.setList(list); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | response.setList(list); |
| | | } |
| | | return response; |
| | | } |
| | |
| | | String code = ""; |
| | | BigDecimal money = tCoursePackagePayment.getCashPayment(); |
| | | Integer wpGold = tCoursePackagePayment.getPlayPaiCoin(); |
| | | if (tCoursePackagePayment.getPayStatus() == 1){ |
| | | if (tCoursePackagePayment.getPayStatus() == 1) { |
| | | // 待支付的订单 |
| | | code = tCoursePackagePayment.getCode(); |
| | | tCoursePackagePayment.setPayType(request.getPayType()); |
| | | if (request.getUseConpon() == 1){ |
| | | if (request.getUseConpon() == 1) { |
| | | tCoursePackagePayment.setUserCouponId(Long.valueOf(request.getUseConpon())); |
| | | } |
| | | this.baseMapper.updateById(tCoursePackagePayment); |
| | | }else { |
| | | } else { |
| | | // 续课的订单 |
| | | // 查询是否续课优惠 |
| | | |
| | |
| | | .eq("type", 2) |
| | | .eq("auditStatus", 1) |
| | | .eq("coursePackagePaymentConfigId", paymentConfig.getCoursePackageId())); |
| | | if (ToolUtil.isNotEmpty(coursePackageDiscount)){ |
| | | if (ToolUtil.isNotEmpty(coursePackageDiscount)) { |
| | | String content = coursePackageDiscount.getContent(); |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | if (userIdFormRedis.getIsVip() == 1){ |
| | | if (userIdFormRedis.getIsVip() == 1) { |
| | | Double jsonObjectDouble = jsonObject.getDouble("num1"); |
| | | money = BigDecimal.valueOf(jsonObjectDouble); |
| | | }else { |
| | | } else { |
| | | Double jsonObjectDouble = jsonObject.getDouble("num2"); |
| | | money = BigDecimal.valueOf(jsonObjectDouble); |
| | | } |
| | |
| | | newPayment.setOriginalPrice(tCoursePackagePayment.getOriginalPrice()); |
| | | newPayment.setTotalClassHours(tCoursePackagePayment.getTotalClassHours()); |
| | | newPayment.setLaveClassHours(tCoursePackagePayment.getTotalClassHours()); |
| | | if (request.getUseConpon() == 1){ |
| | | if (request.getUseConpon() == 1) { |
| | | newPayment.setUserCouponId(Long.valueOf(request.getUseConpon())); |
| | | } |
| | | newPayment.setAbsencesNumber(0); |
| | |
| | | this.baseMapper.insert(newPayment); |
| | | code = newPayment.getCode(); |
| | | } |
| | | switch (request.getPayType()){ |
| | | switch (request.getPayType()) { |
| | | case 1: |
| | | if (request.getUseConpon() == 1){ |
| | | if (request.getUseConpon() == 1) { |
| | | Coupon coupon = client.queryCouponById(request.getConponId()); |
| | | if (coupon.getType() == 1){ |
| | | if (coupon.getType() == 1) { |
| | | Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | Double conditionalAmount = (Double) couponRules.get("conditionalAmount"); |
| | | Double deductionAmount = (Double) couponRules.get("deductionAmount"); |
| | | if (money.compareTo(BigDecimal.valueOf(conditionalAmount)) >= 0){ |
| | | if (money.compareTo(BigDecimal.valueOf(conditionalAmount)) >= 0) { |
| | | money = BigDecimal.valueOf(deductionAmount); |
| | | } |
| | | } |
| | | if (coupon.getType() == 2){ |
| | | if (coupon.getType() == 2) { |
| | | Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | Object amount = couponRules.get("deductionAmount"); |
| | | money = BigDecimal.valueOf((Double) amount); |
| | | } |
| | | } |
| | | try { |
| | | return WeChatPayment(code,money); |
| | | }catch (Exception e){ |
| | | return WeChatPayment(code, money); |
| | | } catch (Exception e) { |
| | | return ResultUtil.runErr(); |
| | | } |
| | | case 2: |
| | | if (request.getUseConpon() == 1){ |
| | | if (request.getUseConpon() == 1) { |
| | | Coupon coupon = client.queryCouponById(request.getConponId()); |
| | | if (coupon.getType() == 1){ |
| | | if (coupon.getType() == 1) { |
| | | Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | Double conditionalAmount = (Double) couponRules.get("conditionalAmount"); |
| | | Double deductionAmount = (Double) couponRules.get("deductionAmount"); |
| | | if (money.compareTo(BigDecimal.valueOf(conditionalAmount)) >= 0){ |
| | | if (money.compareTo(BigDecimal.valueOf(conditionalAmount)) >= 0) { |
| | | money = BigDecimal.valueOf(deductionAmount); |
| | | } |
| | | } |
| | | if (coupon.getType() == 2){ |
| | | if (coupon.getType() == 2) { |
| | | Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | Object amount = couponRules.get("deductionAmount"); |
| | | money = BigDecimal.valueOf((Double) amount); |
| | | } |
| | | } |
| | | return AlipayPayment(code,money); |
| | | return AlipayPayment(code, money); |
| | | case 3: |
| | | PlaypaiGoldPayment(userIdFormRedis,code,wpGold); |
| | | PlaypaiGoldPayment(userIdFormRedis, code, wpGold); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | TCoursePackagePaymentMapper baseMapper1 = this.baseMapper; |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("课包续费", "", code, request.toString(), |
| | | "/base/coursePackage/wechatRegisteredCoursesCallback", "APP", ""); |
| | | if(weixinpay.getCode() == 200){ |
| | | if (weixinpay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10){ |
| | | while (num <= 10) { |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | TCoursePackagePayment coursePackagePayment = baseMapper1.getCoursePackagePaymentByCode(code); |
| | | if(coursePackagePayment.getPayStatus() == 2){ |
| | | if (coursePackagePayment.getPayStatus() == 2) { |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(code, ""); |
| | | if(resultUtil.getCode() == 200 && coursePackagePayment.getPayStatus() == 1){ |
| | | if (resultUtil.getCode() == 200 && coursePackagePayment.getPayStatus() == 1) { |
| | | /** |
| | | * SUCCESS—支付成功, |
| | | * REFUND—转入退款, |
| | |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("trade_state"); |
| | | String transaction_id = data1.get("transaction_id"); |
| | | if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){ |
| | | if ("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10) { |
| | | coursePackagePayment.setState(3); |
| | | baseMapper1.deleteById(coursePackagePayment.getId()); |
| | | break; |
| | | } |
| | | if("SUCCESS".equals(s)){ |
| | | if ("SUCCESS".equals(s)) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(transaction_id); |
| | | baseMapper1.updateById(coursePackagePayment); |
| | | break; |
| | | } |
| | | if("USERPAYING".equals(s)){ |
| | | if ("USERPAYING".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public ResultUtil AlipayPayment(String code, BigDecimal request){ |
| | | public ResultUtil AlipayPayment(String code, BigDecimal request) { |
| | | TCoursePackagePaymentMapper baseMapper1 = this.baseMapper; |
| | | ResultUtil alipay = payMoneyUtil.alipay("课包购买", "课包购买", "", code, request.toString(), |
| | | "/base/coursePackage/alipayRegisteredCoursesCallback"); |
| | | if(alipay.getCode() == 200){ |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10){ |
| | | while (num <= 10) { |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | TCoursePackagePayment coursePackagePayment = baseMapper1.getCoursePackagePaymentByCode(code); |
| | | if(coursePackagePayment.getPayStatus() == 2){ |
| | | if (coursePackagePayment.getPayStatus() == 2) { |
| | | break; |
| | | } |
| | | AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(code); |
| | | |
| | | if(coursePackagePayment.getPayStatus() == 1){ |
| | | if (coursePackagePayment.getPayStatus() == 1) { |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | |
| | | // Map<String, String> data1 = resultUtil.getData(); |
| | | String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){ |
| | | if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | coursePackagePayment.setState(3); |
| | | baseMapper1.deleteById(coursePackagePayment.getId()); |
| | | break; |
| | | } |
| | | if("TRADE_SUCCESS".equals(s)){ |
| | | if ("TRADE_SUCCESS".equals(s)) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(tradeNo); |
| | | baseMapper1.updateById(coursePackagePayment); |
| | | break; |
| | | } |
| | | if("WAIT_BUYER_PAY".equals(s)){ |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | return alipay; |
| | | } |
| | | |
| | | public ResultUtil PlaypaiGoldPayment(AppUser appUser,String code, Integer wpGold){ |
| | | public ResultUtil PlaypaiGoldPayment(AppUser appUser, String code, Integer wpGold) { |
| | | TCoursePackagePayment packagePayment = this.baseMapper.selectOne(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("code",code )); |
| | | if (appUser.getPlayPaiCoins() < wpGold){ |
| | | .eq("code", code)); |
| | | if (appUser.getPlayPaiCoins() < wpGold) { |
| | | return ResultUtil.error("玩牌币不足!"); |
| | | } |
| | | packagePayment.setPayStatus(2); |
| | |
| | | packagePayment.setPlayPaiCoin(wpGold); |
| | | this.baseMapper.updateById(packagePayment); |
| | | |
| | | appUser.setPlayPaiCoins(ToolUtil.isNotEmpty(appUser.getPlayPaiCoins()) ? appUser.getPlayPaiCoins()-wpGold : wpGold); |
| | | appUser.setPlayPaiCoins(ToolUtil.isNotEmpty(appUser.getPlayPaiCoins()) ? appUser.getPlayPaiCoins() - wpGold : wpGold); |
| | | appuClient.updateAppUser(appUser); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<RecordAppoint> obtainStuClassDetails(Integer stuId, Integer appUserId,Integer pageNum) { |
| | | public List<RecordAppoint> obtainStuClassDetails(Integer stuId, Integer appUserId, Integer pageNum) { |
| | | List<RecordAppoint> recordVoList = new ArrayList<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = this.baseMapper.selectList(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("studentId",stuId ) |
| | | .eq("appUserId",appUserId ) |
| | | .eq("payStatus",2 ) |
| | | .eq("status",1 ) |
| | | .eq("studentId", stuId) |
| | | .eq("appUserId", appUserId) |
| | | .eq("payStatus", 2) |
| | | .eq("status", 1) |
| | | .orderByDesc("insertTime")); |
| | | |
| | | List<Integer> ids = new ArrayList<>(); |
| | |
| | | } |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd"); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); |
| | | if (tCoursePackagePayments.size() > 0 ){ |
| | | if (tCoursePackagePayments.size() > 0) { |
| | | |
| | | // int pageNum = 1; // 页码 |
| | | int pageSize = 100; // 每页记录数 |
| | | int pageSize = 10; // 每页记录数 |
| | | Page<CoursePackageStudent> page = new Page<>(pageNum, pageSize); |
| | | |
| | | // for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | |
| | | List<CoursePackageStudent> coursePackageStudent1 = coursePackageStudentPage.getRecords(); |
| | | |
| | | |
| | | if (ToolUtil.isNotEmpty(coursePackageStudent1) && coursePackageStudent1.size() > 0){ |
| | | TCoursePackage coursePackage = new TCoursePackage(); |
| | | Integer coursePackageId = -1; |
| | | for (CoursePackageStudent coursePackageStudent : coursePackageStudent1) { |
| | | RecordAppoint recordVo = new RecordAppoint(); |
| | | recordVo.setCoursePackageId(coursePackageStudent.getCoursePackageId()); |
| | | if (ToolUtil.isNotEmpty(coursePackageStudent1) && coursePackageStudent1.size() > 0) { |
| | | TCoursePackage coursePackage = new TCoursePackage(); |
| | | Integer coursePackageId = -1; |
| | | for (CoursePackageStudent coursePackageStudent : coursePackageStudent1) { |
| | | RecordAppoint recordVo = new RecordAppoint(); |
| | | recordVo.setCoursePackageId(coursePackageStudent.getCoursePackageId()); |
| | | |
| | | if (!coursePackageStudent.getCoursePackageId().equals(coursePackageId)) { |
| | | coursePackage = tcpmapper.selectById(coursePackageStudent.getCoursePackageId()); |
| | | coursePackageId = coursePackageStudent.getCoursePackageId(); |
| | | if (!coursePackageStudent.getCoursePackageId().equals(coursePackageId)) { |
| | | coursePackage = tcpmapper.selectById(coursePackageStudent.getCoursePackageId()); |
| | | coursePackageId = coursePackageStudent.getCoursePackageId(); |
| | | } |
| | | |
| | | recordVo.setSid(Arrays.asList(coursePackage.getStoreId())); |
| | | List<Integer> rid = stoClient.querySiteId(coursePackage.getStoreId()); |
| | | recordVo.setRid(rid); |
| | | recordVo.setUserId(appUserId); |
| | | recordVo.setSiteId(coursePackage.getSiteId()); |
| | | List<Integer> ids1 = getIds(coursePackage.getSiteId()); |
| | | recordVo.setIds(ids1); |
| | | |
| | | recordVo.setCoursePackageName(coursePackage.getName()); |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | if (Objects.equals(coursePackageStudent.getCoursePackageId(), tCoursePackagePayment.getCoursePackageId())) { |
| | | recordVo.setCourseHours(tCoursePackagePayment.getClassHours()); |
| | | |
| | | } |
| | | |
| | | recordVo.setSid(Arrays.asList(coursePackage.getStoreId())); |
| | | List<Integer> rid = stoClient.querySiteId(coursePackage.getStoreId()); |
| | | recordVo.setRid(rid); |
| | | recordVo.setUserId(appUserId); |
| | | recordVo.setSiteId(coursePackage.getSiteId()); |
| | | List<Integer> ids1 = getIds(coursePackage.getSiteId()); |
| | | recordVo.setIds(ids1); |
| | | |
| | | recordVo.setCoursePackageName(coursePackage.getName()); |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | if (Objects.equals(coursePackageStudent.getCoursePackageId(), tCoursePackagePayment.getCoursePackageId())){ |
| | | recordVo.setCourseHours(tCoursePackagePayment.getClassHours()); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // recordVo.setCourseHours(tCoursePackagePayment.getClassHours()); |
| | | Date date = DateUtil.getDate(); |
| | | Date date = DateUtil.getDate(); |
| | | |
| | | |
| | | CoursePackageScheduling byId = coursePackageSchedulingService.getById(coursePackageStudent.getCoursePackageSchedulingId()); |
| | | CoursePackageScheduling byId = coursePackageSchedulingService.getById(coursePackageStudent.getCoursePackageSchedulingId()); |
| | | // String classStartTime = coursePackage.getClassStartTime(); |
| | | // String classEndTime = coursePackage.getClassEndTime(); |
| | | //这里是过滤今天之后的数据 |
| | | //这里是过滤今天之后的数据 |
| | | |
| | | // if (byId == null||byId.getClassDate().after(new Date())){ |
| | | // continue; |
| | | // } |
| | | |
| | | if (byId == null){ |
| | | continue; |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String dateString1 = sdf.format(byId.getClassDate()); |
| | | String dateString2 = sdf.format(byId.getEndDate()); |
| | | if (byId == null) { |
| | | continue; |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String dateString1 = sdf.format(byId.getClassDate()); |
| | | String dateString2 = sdf.format(byId.getEndDate()); |
| | | |
| | | |
| | | recordVo.setTimeFrame(dateString1 + "-" + dateString2.substring(11)); |
| | | recordVo.setTimeFrame(dateString1 + "-" + dateString2.substring(11)); |
| | | |
| | | // recordVo.setTimeFrame(simpleDateFormat.format(date)+" "+classStartTime+"-"+classEndTime); |
| | | Store store = stoClient.queryStoreById(coursePackage.getStoreId()); |
| | | recordVo.setStoreNameAddr(store.getName()+store.getAddress()); |
| | | recordVo.setCourseStuRecordId(coursePackageStudent.getId()); |
| | | String classWeeks = coursePackage.getClassWeeks(); |
| | | String[] split = classWeeks.split(";"); |
| | | List<String> integerList = Arrays.asList(split); |
| | | String weekOfDate = DateTimeHelper.getWeekOfDate(new Date()); |
| | | if (integerList.contains(weekOfDate)){ |
| | | String dat = simpleDateFormat.format(byId.getClassDate()) +" "+ dateString1.substring(11); |
| | | Store store = stoClient.queryStoreById(coursePackage.getStoreId()); |
| | | recordVo.setStoreNameAddr(store.getName() + store.getAddress()); |
| | | recordVo.setCourseStuRecordId(coursePackageStudent.getId()); |
| | | String classWeeks = coursePackage.getClassWeeks(); |
| | | String[] split = classWeeks.split(";"); |
| | | List<String> integerList = Arrays.asList(split); |
| | | String weekOfDate = DateTimeHelper.getWeekOfDate(new Date()); |
| | | if (integerList.contains(weekOfDate)) { |
| | | String dat = simpleDateFormat.format(byId.getClassDate()) + " " + dateString1.substring(11); |
| | | |
| | | Date start = null; |
| | | try { |
| | | start = format.parse(dat); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | //已取消 |
| | | if (byId.getStatus()==4){ |
| | | recordVo.setStatus(4); |
| | | } else if(coursePackageStudent.getSignInOrNot()==2){ |
| | | //已请假 |
| | | recordVo.setStatus(5); |
| | | } |
| | | else if (start.after(new Date())){ |
| | | //待上课 |
| | | recordVo.setStatus(1); |
| | | } |
| | | Date start = null; |
| | | try { |
| | | start = format.parse(dat); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | //已取消 |
| | | if (byId.getStatus() == 4) { |
| | | recordVo.setStatus(4); |
| | | } else if (coursePackageStudent.getSignInOrNot() == 2) { |
| | | //已请假 |
| | | recordVo.setStatus(5); |
| | | } else if (start.after(new Date())) { |
| | | //待上课 |
| | | recordVo.setStatus(1); |
| | | } |
| | | // else if(coursePackageStudent.getSignInOrNot()==2){ |
| | | // recordVo.setStatus(5); |
| | | // } |
| | | else { |
| | | else { |
| | | // CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | // .eq("coursePackageId",coursePackageStudent.getCoursePackageId())); |
| | | CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | .eq("coursePackageSchedulingId",byId.getId())); |
| | | if (ToolUtil.isNotEmpty(cancelledClasses)){ |
| | | CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | .eq("coursePackageSchedulingId", byId.getId()).last("limit 1")); |
| | | if (ToolUtil.isNotEmpty(cancelledClasses)) { |
| | | recordVo.setStatus(3); |
| | | // 消课 到课状态0 旷课 |
| | | if (coursePackageStudent.getSignInOrNot() == 0) { |
| | | recordVo.setStatus(6); |
| | | } |
| | | |
| | | } else { |
| | | Date now = new Date(); |
| | | if (now.after(byId.getClassDate()) && now.before(byId.getEndDate())) { |
| | | recordVo.setStatus(2); |
| | | } else { |
| | | recordVo.setStatus(3); |
| | | // 消课 到课状态0 旷课 |
| | | if(coursePackageStudent.getSignInOrNot()==0){ |
| | | recordVo.setStatus(6); |
| | | } |
| | | |
| | | }else { |
| | | Date now = new Date(); |
| | | if (now.after(byId.getClassDate())&&now.before(byId.getEndDate())){ |
| | | recordVo.setStatus(2); |
| | | }else { |
| | | recordVo.setStatus(3); |
| | | |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | recordVo.setStatus(1); |
| | | } |
| | | recordVoList.add(recordVo); |
| | | } else { |
| | | recordVo.setStatus(1); |
| | | } |
| | | |
| | | }else { |
| | | // recordVo.setStatus(4); |
| | | recordVoList.add(recordVo); |
| | | } |
| | | |
| | | } else { |
| | | // recordVo.setStatus(4); |
| | | } |
| | | |
| | | } |
| | | // } |
| | | |
| | | return recordVoList; |
| | | } |
| | | public List<Integer> getIds(Integer siteId) { |
| | | |
| | | public List<Integer> getIds(Integer siteId) { |
| | | HttpRequest httpRequest = HttpRequest.get("https://try.daowepark.com/v7/user_api/general/get_space_area?space_id=" + siteId); |
| | | HttpResponse execute = httpRequest.execute(); |
| | | String body = execute.body(); |
| | | JSONObject jsonObject = JSONObject.parseObject(body); |
| | | Object data = jsonObject.get("data"); |
| | | JSONArray array = JSONArray.parseArray(data.toString()); |
| | | List<Integer> ids =new ArrayList<>(); |
| | | List<Integer> ids = new ArrayList<>(); |
| | | for (Object o : array) { |
| | | JSONObject jsonObject1 = JSONObject.parseObject(o.toString()); |
| | | Object id = jsonObject1.get("id"); |
| | |
| | | return ids; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil insertVipPaymentCallback(String code, String orderNumber) { |
| | | TCoursePackagePayment coursePackagePayment = this.baseMapper.getCoursePackagePaymentByCode(code); |
| | | if(coursePackagePayment.getPayStatus() != 1){ |
| | | if (coursePackagePayment.getPayStatus() != 1) { |
| | | return ResultUtil.success(); |
| | | } |
| | | coursePackagePayment.setPayStatus(2); |
| | |
| | | |
| | | @Override |
| | | public List<BillingRequest> queryAmountDatas(Integer appUserId, String monthStart, String monthEnd) { |
| | | return this.baseMapper.billingDataRequestVo(appUserId,monthStart,monthEnd); |
| | | return this.baseMapper.billingDataRequestVo(appUserId, monthStart, monthEnd); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课包报名信息 |
| | | * |
| | | * @param page |
| | | * @param queryRegistrationRecord |
| | | * @return |
| | |
| | | @Override |
| | | public List<Map<String, Object>> queryRegistrationRecord(Page<Map<String, Object>> page, QueryRegistrationRecord queryRegistrationRecord) { |
| | | Integer coursePackageId = queryRegistrationRecord.getCoursePackageId(); |
| | | TCoursePackage coursePackage = coursePackageService.getById(coursePackageId); |
| | | String userName = queryRegistrationRecord.getUserName(); |
| | | List<Integer> userIds = null; |
| | | List<Integer> studentIds = null; |
| | | if(ToolUtil.isNotEmpty(userName)){ |
| | | if (ToolUtil.isNotEmpty(userName)) { |
| | | List<AppUser> appUsers = appuClient.queryAppUserListByName(userName); |
| | | if(appUsers.size() > 0){ |
| | | if (appUsers.size() > 0) { |
| | | userIds = appUsers.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | String studentName = queryRegistrationRecord.getStudentName(); |
| | | if(ToolUtil.isNotEmpty(studentName)){ |
| | | if (ToolUtil.isNotEmpty(studentName)) { |
| | | List<Student> students = studentClient.queryStudentListByName(studentName); |
| | | if(students.size() > 0){ |
| | | if (students.size() > 0) { |
| | | studentIds = students.stream().map(Student::getId).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | List<Map<String, Object>> list = this.baseMapper.queryRegistrationRecord(page, coursePackageId, userIds, studentIds); |
| | | |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | |
| | | if (coursePackage.getType()==1){ |
| | | list = this.baseMapper.queryRegistrationRecord(page, coursePackageId, userIds, studentIds); |
| | | }else { |
| | | list = this.baseMapper.queryRegistrationRecord1(page, coursePackageId, userIds, studentIds); |
| | | } |
| | | |
| | | list.addAll(this.baseMapper.queryRegistrationRecord3(coursePackageId,userIds,studentIds)); |
| | | for (Map<String, Object> map : list) { |
| | | |
| | | |
| | | Long id = Long.valueOf(map.get("id").toString()); |
| | | Integer appUserId = Integer.valueOf(map.get("appUserId").toString()); |
| | | Integer studentId = Integer.valueOf(map.get("studentId").toString()); |
| | | Integer studentId = 0; |
| | | if (coursePackage.getType()==1) { |
| | | studentId = Integer.valueOf(map.get("studentId").toString()); |
| | | }else { |
| | | studentId = Integer.valueOf(map.get("studentIds").toString().split(",")[0]); |
| | | } |
| | | |
| | | TAppUser appUser = appuClient.queryAppUser1(appUserId); |
| | | map.put("userName", null != appUser ? appUser.getName() : ""); |
| | |
| | | map.put("studentName", null != student ? student.getName() : ""); |
| | | Integer integer = cpsMapper.selectCount(new QueryWrapper<CoursePackageStudent>().eq("appUserId", appUserId) |
| | | .eq("studentId", studentId).eq("coursePackagePaymentId", id).eq("signInOrNot", 2)); |
| | | |
| | | int count = coursePackageStudentService.count(new QueryWrapper<CoursePackageStudent>().eq("coursePackageId", coursePackageId).eq("studentId", studentId).eq("signInOrNot",2)); |
| | | |
| | | map.put("absencesNumber", count); |
| | | |
| | | map.put("already", integer); |
| | | // if (student != null && student.getName().equals("杨锴1")) { |
| | | // map.put("totalClassHours", "测试"); |
| | | // } |
| | | ; |
| | | } |
| | | return list; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 获取未预约排课学员列表 |
| | | * |
| | | * @param page |
| | | * @param queryWalkInStudentList |
| | | * @return |
| | |
| | | String userName = queryWalkInStudentList.getUserName(); |
| | | List<Integer> userIds = null; |
| | | List<Integer> studentIds = null; |
| | | if(ToolUtil.isNotEmpty(userName)){ |
| | | if (ToolUtil.isNotEmpty(userName)) { |
| | | List<AppUser> appUsers = appuClient.queryAppUserListByName(userName); |
| | | if(appUsers.size() > 0){ |
| | | if (appUsers.size() > 0) { |
| | | userIds = appUsers.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | String studentName = queryWalkInStudentList.getStudentName(); |
| | | if(ToolUtil.isNotEmpty(studentName)){ |
| | | if (ToolUtil.isNotEmpty(studentName)) { |
| | | List<Student> students = studentClient.queryStudentListByName(studentName); |
| | | if(students.size() > 0){ |
| | | if (students.size() > 0) { |
| | | studentIds = students.stream().map(Student::getId).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | List<Long> coursePackagePaymentId = null; |
| | | List<CoursePackageStudent> coursePackageStudents = cpsMapper.selectList(new QueryWrapper<CoursePackageStudent>().eq("coursePackageSchedulingId", coursePackageSchedulingId).eq("reservationStatus", 1)); |
| | | if(coursePackageStudents.size() > 0){ |
| | | if (coursePackageStudents.size() > 0) { |
| | | coursePackagePaymentId = coursePackageStudents.stream().map(CoursePackageStudent::getCoursePackagePaymentId).collect(Collectors.toList()); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<PayCourseRes> getMyCourseList(Integer storeId, Integer appUserId) { |
| | | // 找到购买的课包 |
| | | List<TCoursePackagePayment> tCoursePackagePayments = this.baseMapper.selectList(new LambdaQueryWrapper<TCoursePackagePayment>().eq(TCoursePackagePayment::getAppUserId, appUserId)); |
| | | List<CoursePackageOrderStudent> tCoursePackagePayments = coursePackageOrderStudentService.list(new LambdaQueryWrapper<CoursePackageOrderStudent>().eq(CoursePackageOrderStudent::getAppUserId, appUserId)); |
| | | ArrayList<PayCourseRes> payCourseRes = new ArrayList<>(); |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | for (CoursePackageOrderStudent tCoursePackagePayment : tCoursePackagePayments) { |
| | | TCoursePackage tCoursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); |
| | | if(tCoursePackage.getStoreId().equals(storeId)){ |
| | | if (tCoursePackage.getType() != 1) { |
| | | continue; |
| | | } |
| | | if (tCoursePackage.getStoreId().equals(storeId)) { |
| | | PayCourseRes payCourseRes1 = new PayCourseRes(); |
| | | payCourseRes1.setId(tCoursePackagePayment.getId()); |
| | | payCourseRes1.setName(tCoursePackage.getName()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PayCourseInfoReq payCourseInfo(Integer courseId){ |
| | | public PayCourseInfoReq payCourseInfo(Integer courseId) { |
| | | PayCourseInfoReq payCourseInfoReq = new PayCourseInfoReq(); |
| | | TCoursePackage tCoursePackage = tcpmapper.selectById(courseId); |
| | | payCourseInfoReq.setId(courseId); |
| | |
| | | List<Integer> week = week(tCoursePackage.getClassWeeks()); |
| | | |
| | | // 今天周几 |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date()) - 1; |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); |
| | | ArrayList<String> strings1 = new ArrayList<>(); |
| | | |
| | | for (Integer integer : week) { |
| | | if(integer<i){ |
| | | if (integer < i) { |
| | | // 找下一周的时间 |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7-(i-integer)); |
| | | instance.add(Calendar.DATE, 7 - (i - integer)); |
| | | Date time = instance.getTime(); |
| | | strings1.add(format.format(time)); |
| | | |
| | | }else if(integer>i) { |
| | | } else if (integer > i) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,integer-i); |
| | | instance.add(Calendar.DATE, integer - i); |
| | | Date time = instance.getTime(); |
| | | strings1.add(format.format(time)); |
| | | }else { |
| | | } else { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7); |
| | | instance.add(Calendar.DATE, 7); |
| | | Date time = instance.getTime(); |
| | | strings1.add(format.format(time)); |
| | | } |
| | |
| | | payCourseInfoReq.setDay(strings1); |
| | | return payCourseInfoReq; |
| | | } |
| | | private static List<Integer> week(String week){ |
| | | |
| | | private static List<Integer> week(String week) { |
| | | String[] split = week.split(";"); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | for (String s : split) { |
| | | switch (s){ |
| | | switch (s) { |
| | | case "周一": |
| | | integers.add(1); |
| | | break; |
| | |
| | | @Autowired |
| | | private CoursePackageStudentService coursePackageStudentService; |
| | | |
| | | @Autowired |
| | | private CourseCounsumService courseCounsumService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) |
| | | public ResultUtil payCourse(PayCourseReq req,Integer userId){ |
| | | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) |
| | | public ResultUtil payCourse(PayCourseReq req, Integer userId) throws ParseException { |
| | | // 扣除 原来的课时数 |
| | | // 添加购买课时 paytyoe为7 |
| | | // 排课可期 判断课程时间段 添加排课表 添加上课记录表 |
| | | // 找到原来的课包 扣课时 |
| | | TCoursePackagePayment tCoursePackagePayment = this.baseMapper.selectById(req.getOldCourseId()); |
| | | if(req.getNum()>tCoursePackagePayment.getLaveClassHours()){ |
| | | CoursePackageOrderStudent coursePackageOrderStudent = coursePackageOrderStudentService.getById(req.getOldCourseId()); |
| | | if (req.getNum() > coursePackageOrderStudent.getLaveClassHours()) { |
| | | return ResultUtil.error("当前课包课时数不足"); |
| | | } |
| | | tCoursePackagePayment.setLaveClassHours(tCoursePackagePayment.getLaveClassHours()-req.getNum()); |
| | | this.baseMapper.updateHoursById(tCoursePackagePayment.getId(),-req.getNum()); |
| | | TCoursePackage coursePackage = coursePackageService.getById(coursePackageOrderStudent.getCoursePackageId()); |
| | | TCoursePackage coursePackage1 = coursePackageService.getById(req.getCourseId()); |
| | | //判断剩余课时是否已经全部进行排课,如果排课需要删除已经排好的记录 |
| | | List<CoursePackageScheduling> list1 = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("studentId", coursePackageOrderStudent.getStudentId()).eq("status", 1) |
| | | .eq("type", 1).orderByDesc("classDate")); |
| | | //已经排课但没有使用的课时数量 |
| | | int number = list1.size() * coursePackage.getNeedNum(); |
| | | Integer laveClassHours1 = coursePackageOrderStudent.getLaveClassHours(); |
| | | laveClassHours1 -= number; |
| | | //需要购买使用的课时数 |
| | | Integer num = req.getNum(); |
| | | //需要删除多余的排课记录 |
| | | if(num.compareTo(laveClassHours1) > 0){ |
| | | //课时数差额 |
| | | int number1 = num - laveClassHours1; |
| | | double o = number1 % coursePackage.getNeedNum(); |
| | | int l = 0; |
| | | if(0 != o){ |
| | | l = 1; |
| | | } |
| | | int n = Double.valueOf(number1 / coursePackage.getNeedNum()).intValue() + l; |
| | | for (int i = 0; i < n; i++) { |
| | | CoursePackageScheduling coursePackageScheduling = list1.get(i); |
| | | coursePackageSchedulingService.getBaseMapper().deleteById(coursePackageScheduling.getId()); |
| | | |
| | | // |
| | | // List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", coursePackagePayment.getStudentId()).eq("coursePackageId", coursePackagePayment.getCoursePackageId())); |
| | | // List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | // coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id",collect)); |
| | | // coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", paymentDeductionClassHour.getId()).eq("coursePackageId", coursePackagePayment.getCoursePackageId())); |
| | | // |
| | | // TCoursePackage tCoursePackage = packageService.getById(tCoursePackagePayment.getCoursePackageId()); |
| | | // String classWeeks = tCoursePackage.getClassWeeks(); |
| | | // List<Integer> week = week(classWeeks); |
| | | // |
| | | // TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", tCoursePackagePayment.getCoursePackageId()).eq("studentId", tCoursePackagePayment.getStudentId())); |
| | | // |
| | | // |
| | | // Date today = new Date(); |
| | | // |
| | | // Integer laveClassHours = pay.getLaveClassHours(); |
| | | // Integer codeTime = tCoursePackage.getCodeTime(); |
| | | // Integer can = laveClassHours/codeTime; |
| | | // |
| | | // int count = 0; |
| | | // String[] split = tCoursePackage.getClassStartTime().split(","); |
| | | // String[] split1 = tCoursePackage.getClassEndTime().split(","); |
| | | // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | // |
| | | // Date[] dates = generateDateArray(14,today); |
| | | // for (Date date : dates) { |
| | | // if (count==can){ |
| | | // break; |
| | | // } |
| | | // int wei = cn.hutool.core.date.DateUtil.dayOfWeek(date); |
| | | // if (week.contains(wei)){ |
| | | // for (int i1 = 0; i1 < split.length; i1++) { |
| | | // if (count==can){ |
| | | // break; |
| | | // } |
| | | // CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | // coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | // Date parse = format1.parse(format.format(date) + " " + split[i1]); |
| | | // Date parse1 = format1.parse(format.format(date) + " " + split1[i1]); |
| | | // coursePackageScheduling.setClassDate(parse); |
| | | // coursePackageScheduling.setEndDate(parse1); |
| | | // coursePackageScheduling.setStatus(1); |
| | | // coursePackageSchedulingService.save(coursePackageScheduling); |
| | | // CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | // student1.setAppUserId(pay.getAppUserId()); |
| | | // student1.setStudentId(pay.getStudentId()); |
| | | // student1.setCoursePackageId(pay.getCoursePackageId()); |
| | | // student1.setCoursePackagePaymentId(pay.getId()); |
| | | // student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | // student1.setSignInOrNot(1); |
| | | // student1.setReservationStatus(1); |
| | | // student1.setInsertTime(new Date()); |
| | | // studentService.save(student1); |
| | | // count++; |
| | | // } |
| | | // } |
| | | // } |
| | | coursePackageStudentService.getBaseMapper().delete(new QueryWrapper<CoursePackageStudent>() |
| | | .eq("coursePackageSchedulingId", coursePackageScheduling.getId())); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | TCoursePackage tCoursePackage = tcpmapper.selectById(req.getCourseId()); |
| | | // 添加课包 |
| | | TCoursePackagePayment tCoursePackagePayment1 = new TCoursePackagePayment(); |
| | | // tCoursePackagePayment1.setAppUserId(userId); |
| | | // Student student = studentClient.queryDefaultStudent(userId); |
| | | // // student ID |
| | | // |
| | | // Integer sId=null; |
| | | // if(student!=null){ |
| | | // tCoursePackagePayment1.setStudentId(student.getId()); |
| | | // sId=student.getId(); |
| | | // } |
| | | tCoursePackagePayment1.setCoursePackageId(tCoursePackage.getId()); |
| | | tCoursePackagePayment1.setStudentId(req.getStuId()); |
| | | tCoursePackagePayment1.setPayType(7); |
| | | tCoursePackagePayment1.setClassHours(req.getNum()); |
| | | tCoursePackagePayment1.setOriginalPrice(0.0); |
| | | tCoursePackagePayment1.setTotalClassHours(req.getNum()); |
| | | tCoursePackagePayment1.setLaveClassHours(req.getNum()); |
| | | tCoursePackagePayment1.setAbsencesNumber(0); |
| | | tCoursePackagePayment1.setPayUserType(1); |
| | | tCoursePackagePayment1.setPayStatus(2); |
| | | tCoursePackagePayment1.setPayUserId(userId); |
| | | tCoursePackagePayment1.setStatus(1); |
| | | tCoursePackagePayment1.setAppUserId(userId); |
| | | tCoursePackagePayment1.setState(1); |
| | | tCoursePackagePayment1.setInsertTime(new Date()); |
| | | this.baseMapper.insert(tCoursePackagePayment1); |
| | | // 找出课包时间段 |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String classStartTime = tCoursePackage.getClassStartTime(); |
| | | String classEndTime = tCoursePackage.getClassEndTime(); |
| | | String[] split = classStartTime.split(","); |
| | | String[] split1 = classEndTime.split(","); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String classStartTime = coursePackage1.getClassStartTime(); |
| | | String classEndTime = coursePackage1.getClassEndTime(); |
| | | String[] split5 = classStartTime.split(","); |
| | | String[] split6 = classEndTime.split(","); |
| | | List<String> time = req.getTime(); |
| | | for (String s : time) { |
| | | for (int i = 0; i < split.length; i++) { |
| | | for (int i = 0; i < split5.length; i++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | coursePackageScheduling.setType(3); |
| | | coursePackageScheduling.setAppUserId(userId); |
| | | coursePackageScheduling.setStudentId(req.getStuId()); |
| | | coursePackageScheduling.setCoursePackageId(req.getCourseId()); |
| | | try { |
| | | Date parse = format.parse(s + " " + split[i]); |
| | | Date parse1 = format.parse(s + " " + split1[i]); |
| | | Date parse = format.parse(s + " " + split5[i]); |
| | | Date parse1 = format.parse(s + " " + split6[i]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(userId); |
| | | student1.setStudentId(req.getStuId()); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(tCoursePackagePayment1.getId()); |
| | | student1.setCoursePackageId(req.getCourseId()); |
| | | student1.setCoursePackagePaymentId(coursePackageOrderStudent.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 2.0 |
| | | TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); |
| | | tCourseInfoRecord.setUserId(userId); |
| | | tCourseInfoRecord.setCourseId(req.getCourseId()); |
| | | tCourseInfoRecord.setName("体验购课"); |
| | | tCourseInfoRecord.setNum(req.getNum()); |
| | | tCourseInfoRecord.setTime(new Date()); |
| | | tCourseInfoRecord.setType(2); |
| | | appuClient.addCourseInfoRecord(tCourseInfoRecord); |
| | | coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() - req.getNum()); |
| | | coursePackageOrderStudentService.updateById(coursePackageOrderStudent); |
| | | |
| | | |
| | | if(tCoursePackagePayment.getLaveClassHours()<=3){ |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackageOrderStudent.getId()); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setNum(req.getNum()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("体验购课"); |
| | | courseCounsum.setAppUserId(userId); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | |
| | | if (coursePackageOrderStudent.getLaveClassHours() <= 3) { |
| | | Integer appUserId = userId; |
| | | |
| | | //调用推送 |
| | |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | String s1 = appUserId + "_" + "Three"; |
| | | //定时修改排课状态 |
| | | String s = internalRestTemplate.getForObject("http://mb-cloud-gateway/netty/sendMsgToClient?id="+s1, String.class); |
| | | String s = internalRestTemplate.getForObject("http://mb-cloud-gateway/netty/sendMsgToClient?id=" + s1, String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | if (jsonObject1.getIntValue("code") != 200) { |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void updateUseTime(Long id, Date date) { |
| | | this.baseMapper.updateUseTime(id,date); |
| | | this.baseMapper.updateUseTime(id, date); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getStudentIds(Long payId, Integer classId, Integer appId) { |
| | | return this.baseMapper.getStudentIds(payId,classId,appId); |
| | | return this.baseMapper.getStudentIds(payId, classId, appId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateHoursById(TCoursePackagePayment byId, int i) { |
| | | return this.baseMapper.updateHoursById(byId.getId(),i); |
| | | return this.baseMapper.updateHoursById1(byId.getId(), i); |
| | | } |
| | | |
| | | |
| | | |
| | | public static Date[] generateDateArray(int numDays,Date date) { |
| | | public static Date[] generateDateArray(int numDays, Date date) { |
| | | // LocalDate tomorrow = LocalDate.now().plusDays(1); |
| | | LocalDate tomorrow = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(1); |
| | | |