| | |
| | | import com.dsh.course.feignclient.account.model.AppUser; |
| | | import com.dsh.course.feignclient.account.model.Student; |
| | | import com.dsh.course.feignclient.account.model.TCourseInfoRecord; |
| | | import com.dsh.course.feignclient.account.model.TStudent; |
| | | import com.dsh.course.feignclient.activity.CouponClient; |
| | | import com.dsh.course.feignclient.activity.model.Coupon; |
| | | import com.dsh.course.feignclient.model.*; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private CoursePackageSchedulingMapper coursePackageSchedulingMapper; |
| | | @Autowired |
| | | private ICoursePackageSchedulingService coursePackageSchedulingService; |
| | | @Autowired |
| | | private CoursePackageStudentService coursePackageStudentService; |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); |
| | | /** |
| | |
| | | packagePayment.setInsertTime(new Date()); |
| | | packagePayment.setInsertTime(new Date()); |
| | | Integer studentId = packagePayment.getStudentId(); |
| | | // 添加学员上课记录 |
| | | CoursePackageStudent coursePackageStudent = new CoursePackageStudent(); |
| | | TCoursePackagePayment one = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", packagePayment) |
| | | .orderByDesc("insertTime") |
| | | .last("LIMIT 1")); |
| | |
| | | Integer absencesNumber = one.getAbsencesNumber(); |
| | | // 没有过期 |
| | | if (one.getUseTime().after(new Date())){ |
| | | packagePayment.setTotalClassHours(packagePayment.getClassHours()+one.getTotalClassHours()); |
| | | packagePayment.setLaveClassHours(packagePayment.getClassHours()+one.getLaveClassHours()); |
| | | if (one.getLaveClassHours()-packagePayment.getClassHours()<0){ |
| | | return 5002; |
| | | } |
| | | packagePayment.setTotalClassHours(one.getTotalClassHours()); |
| | | packagePayment.setLaveClassHours(one.getLaveClassHours()-packagePayment.getClassHours()); |
| | | packagePayment.setAbsencesNumber(one.getAbsencesNumber()); |
| | | } |
| | | packagePayment.setTotalClassHours(packagePayment.getClassHours()); |
| | |
| | | coursePackageScheduling.setEndDate(endDate.getTime()); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | coursePackageStudent.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | |
| | | List<CoursePackageScheduling> list1 = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("coursePackageId", coursePackage.getId()) |
| | | .eq("classDate", classDate.getTime()) |
| | |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return packagePaymentService.save(packagePayment); |
| | | |
| | | coursePackageStudent.setStudentId(packagePayment.getStudentId()); |
| | | coursePackageStudent.setCoursePackageId(packagePayment.getCoursePackageId()); |
| | | |
| | | |
| | | coursePackageStudent.setSignInOrNot(0); |
| | | coursePackageStudent.setReservationStatus(1); |
| | | coursePackageStudent.setInsertTime(new Date()); |
| | | coursePackageStudent.setAppUserId(packagePayment.getAppUserId()); |
| | | packagePaymentService.save(packagePayment); |
| | | coursePackageStudent.setCoursePackagePaymentId(packagePayment.getId()); |
| | | return coursePackageStudentService.save(coursePackageStudent); |
| | | } |
| | | /** |
| | | * 手动支付 |
| | |
| | | List<AppUser> appUsers = appUserClient.queryAppUserListByName(query.getPayUser()); |
| | | for (AppUser user : appUsers) { |
| | | if (appUser.getName().equals(user.getName())){ |
| | | result.add(re); |
| | | if (query.getPayStudent()== null || query.getPayStudent().equals("")){ |
| | | }else{ |
| | | List<Student> students = studentClient.queryStudentListByName(query.getPayStudent()); |
| | | for (Student student1 : students) { |
| | | if (student.getName().equals(student1.getName())){ |
| | | result.add(re); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (query.getPayStudent()== null || query.getPayStudent().equals("")){ |
| | | }else{ |
| | | List<Student> students = studentClient.queryStudentListByName(query.getPayStudent()); |
| | | for (Student student1 : students) { |
| | | if (student.getName().equals(student1.getName())){ |
| | | result.add(re); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (re.getPayType()!=null){ |
| | | if (re.getPayType()==1){ |
| | | re.setBuyTypeName("微信支付"); |
| | |
| | | } |
| | | |
| | | // 如果支付用户类型为管理员 则购买方式则为1线下购买 |
| | | if (re.getPayUserType()!=null){ |
| | | if (re.getPayUserType()== 2){ |
| | | re.setBuyType(1); |
| | | }else{ |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (query.getPayStudent()== null || query.getPayStudent().equals("")){ |
| | | if (query.getPayUser()== null || query.getPayUser().equals("")){ |
| | | return res; |
| | |
| | | }else{ |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取报名订单记录列表 |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("/registerOrder/listAllRegister") |
| | | public List<RegisterOrderVO> listAllRegister(@RequestBody RegisterOrderQuery query){ |
| | | if (query.getStudentName()!=null){ |
| | | if (!query.getStudentName().equals("")){ |
| | | List<TStudent> students1 = studentClient.queryTStudentListByName(query.getStudentName()); |
| | | List<Integer> studentIds = students1.stream().map(TStudent::getId).collect(Collectors.toList()); |
| | | query.setStudentIds(studentIds); |
| | | if (students1.size()==0){ |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<RegisterOrderVO> res = packagePaymentService.listAllRegister(query); |
| | | // 该运营商下没有门店 |
| | | if (query.getStoresIds()!=null){ |
| | | if (query.getStoresIds().size()==0){ |
| | | List<RegisterOrderVO> registerOrderVOS = new ArrayList<>(); |
| | | return registerOrderVOS; |
| | | } |
| | | } |
| | | |
| | | List<RegisterOrderVO> result = new ArrayList<>(); |
| | | Iterator<RegisterOrderVO> iterator = res.iterator(); |
| | | while (iterator.hasNext()) { |
| | | RegisterOrderVO re = iterator.next(); |
| | | |
| | | if (re.getSalesName() == null) { |
| | | re.setSalesName("无"); |
| | | } |
| | | if (re.getPayType() != null) { |
| | | if (re.getPayType() == 3) { |
| | | re.setPayMoneyAndType(re.getPlayPaiCoin() + "玩湃币"); |
| | | } else { |
| | | re.setPayMoneyAndType("¥" + re.getMoney()); |
| | | } |
| | | } |
| | | Store store = storeClient.queryStoreById(re.getStoreId()); |
| | | TAppUser appUser = appUserClient.queryAppUser1(re.getAppUserId()); |
| | | Student student = studentClient.queryStudentById(re.getStudentId()); |
| | | re.setPayStudent(student.getName()); |
| | | re.setPayUser(appUser.getName()); |
| | | re.setPhone(appUser.getPhone()); |
| | | re.setStoreName(store.getName()); |
| | | // 在这里添加条件来删除不满足要求的元素 |
| | | if (appUser.getInsertType() != query.getInsertType()) { |
| | | iterator.remove(); // 使用迭代器的 remove 方法删除元素 |
| | | } |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | |
| | | return packagePaymentService.save(packagePayment); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePack/obtainStudentClassDetails") |
| | | public List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody WeeksOfCourseRest stuId){ |
| | | try { |
| | |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/editCoursePackagePayment") |
| | | public void editCoursePackagePayment(TCoursePackagePayment coursePackagePayment){ |
| | | coursePackagePayment.setCoursePackageId(null); |
| | | coursePackagePayment.setAppUserId(null); |
| | | packagePaymentService.updateById(coursePackagePayment); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 修改数据 |
| | | * @param coursePackagePayment |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/editCoursePackagePayment1") |
| | | public void editCoursePackagePayment1(@RequestBody TCoursePackagePayment coursePackagePayment){ |
| | | System.out.println("editCoursePackagePayment1====coursePackagePayment"+coursePackagePayment); |
| | | // coursePackagePayment.setCoursePackageId(null); |
| | | packagePaymentService.updateBytime(coursePackagePayment); |
| | | } |
| | | |
| | | |
| | |
| | | if (ToolUtil.isEmpty(packagePayment) || packagePayment.size()==0){ |
| | | return ResultUtil.error("该用户未购买该课包"); |
| | | } |
| | | List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingMapper.selectList(new LambdaQueryWrapper<CoursePackageScheduling>() |
| | | .eq(CoursePackageScheduling::getCoursePackageId, Integer.valueOf(courseID)) |
| | | .like(CoursePackageScheduling::getClassDate, time) |
| | | ); |
| | | |
| | | List<CoursePackageStudent> coursePackageStudent = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>() |
| | | .in(CoursePackageStudent::getCoursePackagePaymentId,packagePayment.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList())) |
| | | .in(CoursePackageStudent::getCoursePackageSchedulingId,coursePackageSchedulings.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList())) |
| | | .eq(CoursePackageStudent::getCoursePackageId,courseID) |
| | | .eq(CoursePackageStudent::getStudentId,stuId) |
| | | .eq(CoursePackageStudent::getAppUserId,appUserId) |
| | |
| | | } |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | |
| | | String time1 = courseDetailReq.getTime(); |
| | | |
| | | // 找出门店的所有课程 排出体验 |
| | | List<TCoursePackage> list = tcpService.list(new LambdaQueryWrapper<TCoursePackage>().eq(TCoursePackage::getStoreId, courseDetailReq.getStoreId()).ne(TCoursePackage::getType, 3).like(TCoursePackage::getClassWeeks,week)); |
| | | List<TCoursePackage> list = tcpService.list(new LambdaQueryWrapper<TCoursePackage>().eq(TCoursePackage::getStoreId, courseDetailReq.getStoreId()).ne(TCoursePackage::getType, 3).eq(TCoursePackage::getState,1).like(TCoursePackage::getClassWeeks,week)); |
| | | List<Integer> collect = list.stream().map(TCoursePackage::getId).collect(Collectors.toList()); |
| | | if(collect.size()==0){ |
| | | collect.add(-1); |
| | |
| | | String classEndTime = tCoursePackage.getClassEndTime(); |
| | | String[] split1 = classEndTime.split(","); |
| | | ArrayList<String> strings = new ArrayList<>(); |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | String s = split[i1] + "-" + split1[i1]; |
| | | strings.add(s); |
| | | if(ToolUtil.isNotEmpty(classStartTime)){ |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | String s = split[i1].substring(0,5) + "-" + split1[i1].substring(0,5); |
| | | strings.add(s); |
| | | } |
| | | } |
| | | |
| | | detailsListVo.setTime(strings); |
| | | List<CoursePackagePaymentConfig> list2 = icppcService.list(new LambdaQueryWrapper<CoursePackagePaymentConfig>().eq(CoursePackagePaymentConfig::getCoursePackageId, tCoursePackage.getId()).orderByAsc(CoursePackagePaymentConfig::getCashPayment)); |
| | | if (list2.size() > 0) { |
| | |
| | | .eq(CoursePackageScheduling::getCoursePackageId, tCoursePackage.getId()) |
| | | .like(CoursePackageScheduling::getClassDate, courseDetailReq.getTime()) |
| | | ); |
| | | if(list3.size()==0){ |
| | | break; |
| | | } |
| | | List<Long> collect2 = list3.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); |
| | | if(collect2.size()==0){ |
| | | collect2.add(-1l); |
| | |
| | | in(CoursePackageStudent::getCoursePackagePaymentId, ids) |
| | | ); |
| | | |
| | | detailsListVo.setType(1); |
| | | detailsListVo.setType(1); |
| | | if(list4.size()>0){ |
| | | Integer signInOrNot = list4.get(0).getSignInOrNot(); |
| | | if(signInOrNot==2){ |
| | | detailsListVo.setType(3); |
| | | } |
| | | detailsListVo.setIsType(list4.get(0).getType()); |
| | | } |
| | | |
| | | } else { |
| | |
| | | return a; |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/queryCourseData") |
| | | public List<Map<String,Object>> queryCourseData(@RequestBody List<Integer> ids){ |
| | | // 找出课程类型 找出剩余的课时数 |
| | | List<TCoursePackageType> list = coursePackageTypeService.list(); |
| | | if(ids.size()==0){ |
| | | ids.add(-1); |
| | | } |
| | | List<TCoursePackagePayment> list1 = packagePaymentService.listOne(ids); |
| | | List<Integer> collect = list1.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | if(collect.size()==0){ |
| | | collect.add(-1); |
| | | } |
| | | List<TCoursePackage> list2 = tcpService.list(new LambdaQueryWrapper<TCoursePackage>().in(TCoursePackage::getId, collect)); |
| | | for (TCoursePackagePayment tCoursePackagePayment : list1) { |
| | | for (TCoursePackage tCoursePackage : list2) { |
| | | if(tCoursePackagePayment.getCoursePackageId().equals(tCoursePackage.getId())){ |
| | | tCoursePackagePayment.setType(tCoursePackage.getType()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | List<Map<String,Object>> mapList = new ArrayList<>(); |
| | | for (TCoursePackageType tCoursePackageType : list) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("name",tCoursePackageType.getName()); |
| | | int a =0; |
| | | for (TCoursePackagePayment tCoursePackagePayment : list1) { |
| | | if(tCoursePackagePayment.getType().equals(tCoursePackageType.getId())){ |
| | | a += tCoursePackagePayment.getLaveClassHours(); |
| | | } |
| | | } |
| | | map.put("value",a); |
| | | mapList.add(map); |
| | | } |
| | | |
| | | |
| | | return mapList; |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/coursePt") |
| | | HashMap<String, Object> coursePt(@RequestBody List<Integer> userPt){ |
| | | if(userPt.size()==0){ |
| | | userPt.add(-1); |
| | | } |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.listOne(userPt); |
| | | int sum = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getTotalClassHours).sum(); |
| | | int sum1 = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getLaveClassHours).sum(); |
| | | map.put("allCourse",sum-sum1); |
| | | |
| | | //所有课包 |
| | | List<TCoursePackage> coursePackages = tcpService.list(); |
| | | |
| | | |
| | | // 年 |
| | | List<CoursePackageStudent> list = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>().in(CoursePackageStudent::getAppUserId, userPt)); |
| | | |
| | | |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | for (TCoursePackage coursePackage : coursePackages) { |
| | | if(coursePackageStudent.getCoursePackageId().equals(coursePackage.getId())){ |
| | | if(ToolUtil.isEmpty(coursePackage.getNeedNum())){ |
| | | coursePackageStudent.setNeedNum(0); |
| | | }else { |
| | | coursePackageStudent.setNeedNum(coursePackageStudent.getNeedNum()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | ArrayList<Object> integers = new ArrayList<>(); |
| | | int year = cn.hutool.core.date.DateUtil.year(new Date()); |
| | | for (int i = 0; i < 10; i++) { |
| | | integers.add(year-i); |
| | | } |
| | | List<Object> collect = integers.stream().sorted().collect(Collectors.toList()); |
| | | // 年 |
| | | ArrayList<Integer> years = new ArrayList<>(); |
| | | for (Object o : collect) { |
| | | String s = o.toString(); |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).collect(Collectors.toList()); |
| | | int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); |
| | | years.add(sum2); |
| | | } |
| | | |
| | | map.put("yearData",years); |
| | | |
| | | |
| | | |
| | | ArrayList<Integer> months = new ArrayList<>(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | |
| | | // 月 |
| | | for (int i = 1; i <= 12; i++) { |
| | | String m=i+""; |
| | | if(i<10){ |
| | | m="0"+i; |
| | | } |
| | | String s = year + "-" + m; |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).collect(Collectors.toList()); |
| | | int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); |
| | | months.add(sum2); |
| | | } |
| | | map.put("monthData",months); |
| | | |
| | | |
| | | |
| | | // 周 |
| | | // 获取最近四周 |
| | | LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); |
| | | LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); |
| | | // 周度数据 |
| | | String s1 = minNow.minusDays(6).toString(); |
| | | String s2 = maxNow.toString(); |
| | | |
| | | String s3 = minNow.minusDays(13).toString(); |
| | | String s4 = maxNow.minusDays(6).toString(); |
| | | |
| | | |
| | | String s5 = minNow.minusDays(20).toString(); |
| | | String s6 = maxNow.minusDays(13).toString(); |
| | | |
| | | String s7 = minNow.minusDays(27).toString(); |
| | | String s8 = maxNow.minusDays(20).toString(); |
| | | |
| | | // |
| | | // int count = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime, s7, s8)); |
| | | // |
| | | // int count1 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s5,s6)); |
| | | // |
| | | // int count2 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s3,s4)); |
| | | // |
| | | // int count3 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s1,s2)); |
| | | |
| | | // map.put("count",count); |
| | | // map.put("count1",count1); |
| | | // map.put("count2",count2); |
| | | // map.put("count3",count3); |
| | | return null; |
| | | |
| | | } |
| | | |
| | | } |