| | |
| | | import net.bytebuddy.asm.Advice; |
| | | import org.aspectj.weaver.ast.Var; |
| | | import io.swagger.models.auth.In; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private CoursePackageStudentService coursePackageStudentService; |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); |
| | | |
| | | /** |
| | | * 查询学员入学时间 根据第一次购买课包的时间 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/coursePackagePayment/getTime") |
| | | public String getTime(@RequestBody Integer studentId){ |
| | | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("studentId", studentId) |
| | | .orderByDesc("insertTime") |
| | | .last("LIMIT 1")); |
| | | if (list.size()>0){ |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date insertTime = list.get(0).getInsertTime(); |
| | | String format1 = format.format(list.get(0).getInsertTime()); |
| | | return format1; |
| | | } |
| | | return ""; |
| | | } |
| | | /** |
| | | * 添加购课记录-后台 |
| | | * @return |
| | |
| | | Integer studentId = packagePayment.getStudentId(); |
| | | // 添加学员上课记录 |
| | | CoursePackageStudent coursePackageStudent = new CoursePackageStudent(); |
| | | TCoursePackagePayment one = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", packagePayment) |
| | | TCoursePackagePayment one = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", packagePayment.getStudentId()) |
| | | .orderByDesc("insertTime") |
| | | .last("LIMIT 1")); |
| | | |
| | |
| | | Integer absencesNumber = one.getAbsencesNumber(); |
| | | // 没有过期 |
| | | if (one.getUseTime().after(new Date())){ |
| | | packagePayment.setTotalClassHours(packagePayment.getClassHours()+one.getTotalClassHours()); |
| | | if (one.getLaveClassHours()-packagePayment.getClassHours()<0){ |
| | | return 5002; |
| | | } |
| | | packagePayment.setTotalClassHours(one.getTotalClassHours()); |
| | | packagePayment.setLaveClassHours(one.getLaveClassHours()-packagePayment.getClassHours()); |
| | | packagePayment.setAbsencesNumber(one.getAbsencesNumber()); |
| | | } |
| | |
| | | String[] end = value1.split(","); |
| | | for (int i = 0; i < star.length; i++) { |
| | | // int index = star[i].indexOf(","); |
| | | // |
| | | // |
| | | // String result = value.substring(0, index).trim(); |
| | | String classStartTime = star[i]; |
| | | String[] split = classStartTime.split(":"); |
| | |
| | | |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 13); |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 14); |
| | | long timeInMillis = e.getTimeInMillis(); |
| | | |
| | | while (true){ |
| | |
| | | .eq("coursePackageId", coursePackage.getId()) |
| | | .eq("classDate", classDate.getTime()) |
| | | .eq("endDate", endDate.getTime())); |
| | | if (list.size()+1>coursePackage.getMaxSubscribeNumber()){ |
| | | if (list1.size()+1>coursePackage.getMaxSubscribeNumber()){ |
| | | // 当前课包预约人数已满 |
| | | return 5001; |
| | | } |
| | |
| | | public Object changeState(@RequestBody CoursePackagePayDTO dto){ |
| | | |
| | | return packagePaymentService.changeState(dto); |
| | | } |
| | | @GetMapping("/coursePackagePayment/courseStore/{appUserId}/{coursePackageId}") |
| | | public List<TCoursePackagePayment> getByUserIdAndCoursePackageId(@PathVariable("appUserId") Integer appUserId,@PathVariable("coursePackageId") Integer coursePackageId){ |
| | | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId", appUserId) |
| | | .eq("coursePackageId", coursePackageId)); |
| | | return list; |
| | | } |
| | | /** |
| | | * 获取购课记录 |
| | |
| | | } |
| | | } |
| | | } |
| | | if(re.getCashPayment()==null){ |
| | | BigDecimal bigDecimal = new BigDecimal("0.00"); |
| | | re.setDiscountAmount(bigDecimal); |
| | | continue; |
| | | } |
| | | BigDecimal subtract = re.getOriginalPrice().subtract(re.getCashPayment()); |
| | | re.setDiscountAmount(subtract); |
| | | } |
| | | if (query.getPayStudent()== null || query.getPayStudent().equals("")){ |
| | | if (query.getPayUser()== null || query.getPayUser().equals("")){ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<RegisterOrderVO> res = packagePaymentService.listAllRegister(query); |
| | | // 该运营商下没有门店 |
| | | if (query.getInsertType() == 2){ |
| | | if (query.getStoresIds()!=null){ |
| | | if (query.getStoresIds().size()==0){ |
| | | List<RegisterOrderVO> registerOrderVOS = new ArrayList<>(); |
| | | return registerOrderVOS; |
| | | } |
| | | }else{ |
| | | List<RegisterOrderVO> registerOrderVOS = new ArrayList<>(); |
| | | return registerOrderVOS; |
| | | } |
| | | } |
| | | |
| | | List<RegisterOrderVO> result = new ArrayList<>(); |
| | | for (RegisterOrderVO re : res) { |
| | | if(re.getSalesName()==null){ |
| | | 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()); |
| | | if (re.getPayType() != null) { |
| | | if (re.getPayType() == 3) { |
| | | re.setPayMoneyAndType(re.getPlayPaiCoin() + "玩湃币"); |
| | | } else { |
| | | re.setPayMoneyAndType("¥" + re.getMoney()); |
| | | } |
| | | } |
| | | Store store = storeClient.queryStoreById(re.getStoreId()); |
| | | if (re.getStoreId()!=null){ |
| | | Store store = storeClient.queryStoreById(re.getStoreId()); |
| | | if (store!=null){ |
| | | re.setStoreName(store.getName()); |
| | | } |
| | | } |
| | | 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()); |
| | | } |
| | | return res; |
| | | } |
| | |
| | | Student student = studentClient.queryStudentById(stuId); |
| | | List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",student.getAppUserId()) |
| | | .eq("studentId",stuId)); |
| | | .eq("studentId",stuId).eq("payStatus",2)); |
| | | |
| | | if (byUserId.size() > 0 ){ |
| | | for (TCoursePackagePayment tCoursePackagePayment : byUserId) { |
| | | TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId()); |
| | | if (tCoursePackage.getType()==3){ |
| | | continue; |
| | | } |
| | | StuCourseResp resp = new StuCourseResp(); |
| | | resp.setCourseId(tCoursePackage.getId()); |
| | | resp.setId(tCoursePackagePayment.getId()); |
| | |
| | | resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours()); |
| | | resp.setResidueNums(tCoursePackagePayment.getLaveClassHours()); |
| | | resp.setDeductionNums(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours()); |
| | | String afterDayDate = DateUtil.getAfterDayDate2(tCoursePackage.getInsertTime(),tCoursePackage.getValidDays() + ""); |
| | | resp.setPeriodOfValidity(afterDayDate); |
| | | resp.setCourseType(tCoursePackage.getType()); |
| | | if (tCoursePackage.getType()!=1||tCoursePackage.getState()==2||tCoursePackagePayment.getPayStatus()==1){ |
| | | resp.setIsAble(0); |
| | | }else { |
| | | resp.setIsAble(1); |
| | | } |
| | | if (tCoursePackagePayment.getUseTime()!=null){ |
| | | // String afterDayDate = DateUtil.getAfterDayDate2(tCoursePackage.getInsertTime(),tCoursePackage.getValidDays() + ""); |
| | | // resp.setPeriodOfValidity(afterDayDate); |
| | | |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String str = sdf.format(tCoursePackagePayment.getUseTime()); |
| | | resp.setPeriodOfValidity(str); |
| | | } |
| | | |
| | | |
| | | |
| | | resps.add(resp); |
| | | } |
| | | } |
| | |
| | | .in("id", collect)); |
| | | list.forEach(vo -> { |
| | | StuSessionDetailsVo detVo = new StuSessionDetailsVo(); |
| | | detVo.setSessionid(vo.getId()); |
| | | detVo.setSessionName(vo.getName()); |
| | | String afterDayDate = DateUtil.getAfterDayDate2(vo.getInsertTime(),vo.getValidDays() + ""); |
| | | detVo.setPeriodOfValidity(afterDayDate); |
| | | detailsVos.add(detVo); |
| | | if (vo.getType()!=2) { |
| | | detVo.setSessionid(vo.getId()); |
| | | detVo.setSessionName(vo.getName()); |
| | | String afterDayDate = DateUtil.getAfterDayDate2(vo.getInsertTime(), vo.getValidDays() + ""); |
| | | detVo.setPeriodOfValidity(afterDayDate); |
| | | detailsVos.add(detVo); |
| | | } |
| | | }); |
| | | } |
| | | return detailsVos; |
| | |
| | | }); |
| | | } |
| | | return purchaseRecordVos; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private CourseCounsumService courseCounsumService; |
| | | |
| | | @Autowired |
| | | private TCoursePackagePaymentService coursePackagePaymentService; |
| | | |
| | | @PostMapping("/base/coursePack/getRecord") |
| | | public List<PurchaseRecordVo> getRecord(@RequestBody RecordTimeRequest recordTimeRequest) { |
| | | List<TCoursePackagePayment> list = new ArrayList<>(); |
| | | Integer [] changes = {1,0}; |
| | | if (recordTimeRequest.getType()==null) { |
| | | list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("studentId", recordTimeRequest.getStuId()).eq("coursePackageId", recordTimeRequest.getLessionId()).orderByDesc("insertTime")); |
| | | }else { |
| | | |
| | | list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("studentId", recordTimeRequest.getStuId()).eq("coursePackageId", recordTimeRequest.getLessionId()).orderByDesc("insertTime")); |
| | | |
| | | } |
| | | List<Long> ids = new ArrayList<>(); |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | ids.add(coursePackagePayment.getId()); |
| | | } |
| | | |
| | | |
| | | |
| | | QueryWrapper<CourseCounsum> in = new QueryWrapper<CourseCounsum>().in("paymentId", ids).in("changeType", changes); |
| | | |
| | | if (recordTimeRequest.getType()!=null){ |
| | | if (recordTimeRequest.getType()==2){ |
| | | recordTimeRequest.setType(0); |
| | | } |
| | | in.eq("changeType",recordTimeRequest.getType()); |
| | | } |
| | | List<CourseCounsum> paymentId = courseCounsumService.list(in); |
| | | List<PurchaseRecordVo> recordVos =new ArrayList<>(); |
| | | for (CourseCounsum courseCounsum : paymentId) { |
| | | PurchaseRecordVo purchaseRecordVo = new PurchaseRecordVo(); |
| | | if (courseCounsum.getChangeType() == 0) { |
| | | purchaseRecordVo.setPurchaseAmount("-" + courseCounsum.getNum()); |
| | | purchaseRecordVo.setPurchaseType(courseCounsum.getReason()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm"); |
| | | String formattedDate = sdf.format(courseCounsum.getInsertTime()); |
| | | purchaseRecordVo.setPurchaseTime(formattedDate); |
| | | } else { |
| | | purchaseRecordVo.setPurchaseAmount("+" + courseCounsum.getNum()); |
| | | purchaseRecordVo.setPurchaseType(courseCounsum.getReason()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm"); |
| | | String formattedDate = sdf.format(courseCounsum.getInsertTime()); |
| | | purchaseRecordVo.setPurchaseTime(formattedDate); |
| | | } |
| | | recordVos.add(purchaseRecordVo); |
| | | } |
| | | |
| | | return recordVos; |
| | | } |
| | | |
| | | |
| | |
| | | @ResponseBody |
| | | public List<CouponPaymentVo> getAppuserCourseList(@RequestBody Integer appUserId){ |
| | | List<CouponPaymentVo> paymentVos = new ArrayList<>(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm"); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId", appUserId) |
| | | .eq("payType", 3) |
| | |
| | | baseVo.setName(coursePackage.getName()); |
| | | list.add(baseVo); |
| | | }); |
| | | return ResultUtil.success(list); |
| | | |
| | | Set<BaseVo> set = new HashSet<>(list); |
| | | List<BaseVo> back = new ArrayList<>(set); |
| | | |
| | | return ResultUtil.success(back); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<List<AppUserVideoResponse>> queryAfterSourceList( CourseOfAfterRequest search){ |
| | | try { |
| | | public ResultUtil<List<AppUserVideoResponse>> queryAfterSourceList( CourseOfAfterRequest search) throws Exception { |
| | | // try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<Integer> courseIds = new ArrayList<>(); |
| | | QueryWrapper<TCoursePackagePayment> queryWrapper = new QueryWrapper<TCoursePackagePayment>().eq("appUserId", appUserId) |
| | | .groupBy("coursePackageId"); |
| | | // |
| | | // List<Integer> courseIds = new ArrayList<>(); |
| | | // QueryWrapper<TCoursePackagePayment> queryWrapper = new QueryWrapper<TCoursePackagePayment>().eq("appUserId", appUserId) |
| | | // .groupBy("coursePackageId"); |
| | | // if (ToolUtil.isNotEmpty(search.getCourseTypeId())){ |
| | | // queryWrapper.eq("coursePackageId",search.getCourseTypeId()); |
| | | // } |
| | | // List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(queryWrapper); |
| | | // if (tCoursePackagePayments.size() > 0 ){ |
| | | // courseIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | |
| | | QueryWrapper<CoursePackageStudent> queryWrapper1 = new QueryWrapper<CoursePackageStudent>().eq("studentId", search.getStuId()); |
| | | if (ToolUtil.isNotEmpty(search.getCourseTypeId())){ |
| | | queryWrapper.eq("coursePackageId",search.getCourseTypeId()); |
| | | queryWrapper1.eq("coursePackageId",search.getCourseTypeId()); |
| | | } |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(queryWrapper); |
| | | if (tCoursePackagePayments.size() > 0 ){ |
| | | courseIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | |
| | | List<CoursePackageStudent> list = coursePackageStudentService.list(queryWrapper1); |
| | | List<Long> longs = new ArrayList<>(); |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | longs.add(coursePackageStudent.getCoursePackageSchedulingId()); |
| | | } |
| | | return ResultUtil.success(packagePaymentService.queryAfterVideo(search,courseIds)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | System.out.println("======longs========"+longs); |
| | | // List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id",longs).isNotNull("courseId")); |
| | | List<AppUserVideoResponse> coursePackageSchedulings1 = coursePackageSchedulingService.queryAll(longs); |
| | | |
| | | if (search.getSearch()!=null) { |
| | | List<AppUserVideoResponse> filteredList = new ArrayList<>(); |
| | | for (AppUserVideoResponse response : coursePackageSchedulings1) { |
| | | if (response.getVideoName().contains(search.getSearch())) { |
| | | filteredList.add(response); |
| | | } |
| | | } |
| | | return ResultUtil.success(filteredList); |
| | | |
| | | } |
| | | |
| | | return ResultUtil.success(coursePackageSchedulings1); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // }catch (Exception e){ |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | public ResultUtil<PayCourseInfoReq> payCourseInfo(Integer courseId){ |
| | | try { |
| | | return ResultUtil.success(packagePaymentService.payCourseInfo(courseId)); |
| | | PayCourseInfoReq payCourseInfoReq = packagePaymentService.payCourseInfo(courseId); |
| | | |
| | | // Arrays.sort(payCourseInfoReq.getDay(), (a, b) -> a.compareTo(b)); |
| | | |
| | | Collections.sort(payCourseInfoReq.getDay(), Comparator.comparing(String::toString)); |
| | | |
| | | |
| | | return ResultUtil.success(payCourseInfoReq); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | |
| | | @ApiOperation(value = "已报名课程详情", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "经度", name = "lon", dataType = "string", required = false), |
| | | @ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = false), |
| | | @ApiImplicitParam(name = "coursePayId" ,value = "课包记录id",dataType = "long"), |
| | | }) |
| | | public ResultUtil<CourseDetailsResponse> getRegisteredData(Long coursePayId){ |
| | | public ResultUtil<CourseDetailsResponse> getRegisteredData(Long coursePayId, String lon, String lat){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | |
| | | */ |
| | | @PostMapping("/base/coursePackage/alipayRegisteredCoursesCallback") |
| | | public void alipayCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | System.err.println("========支付宝支付回调========"); |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if(null != map){ |
| | |
| | | } |
| | | |
| | | |
| | | public static Date[] generateDateArray(int numDays,Date date) { |
| | | // LocalDate tomorrow = LocalDate.now().plusDays(1); |
| | | LocalDate tomorrow = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(1); |
| | | |
| | | Date[] dates = new Date[numDays]; |
| | | |
| | | for (int i = 0; i < numDays; i++) { |
| | | LocalDate currentDate = tomorrow.plusDays(i); |
| | | dates[i] = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | return dates; |
| | | } |
| | | |
| | | @Autowired |
| | | private TCoursePackageService packageService; |
| | | @Autowired |
| | | CoursePackageStudentService studentService ; |
| | | /** |
| | | * 课程用于支付进行扣减 |
| | | * @param paymentDeductionClassHour |
| | |
| | | public void paymentDeductionClassHour(@RequestBody PaymentDeductionClassHour paymentDeductionClassHour){ |
| | | try { |
| | | // 2.0 用id进行查询 |
| | | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("id", paymentDeductionClassHour.getCourseId()).eq("payStatus", 2) |
| | | TCoursePackagePayment coursePackagePayment= packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("id", paymentDeductionClassHour.getCourseId()).eq("payStatus", 2) |
| | | .eq("status", 1).eq("state", 1).gt("laveClassHours", 0)); |
| | | Integer classHour = paymentDeductionClassHour.getClassHour(); |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | if(coursePackagePayment.getLaveClassHours().compareTo(classHour) >= 0){ |
| | | // for (TCoursePackagePayment coursePackagePayment : list) { |
| | | if (coursePackagePayment.getLaveClassHours().compareTo(classHour) >= 0) { |
| | | coursePackagePayment.setLaveClassHours(coursePackagePayment.getLaveClassHours() - classHour); |
| | | coursePackagePayment.setAppUserId(null); |
| | | packagePaymentService.updateById(coursePackagePayment); |
| | | |
| | | // 2.0 少于3课时 推送 |
| | | if(coursePackagePayment.getLaveClassHours()<=3){ |
| | | Integer appUserId = coursePackagePayment.getAppUserId(); |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackagePayment.getId()); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setNum(classHour); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("报名赛事"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | //调用推送 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | String s1 = appUserId + "_" + "Three"; |
| | | //定时修改排课状态 |
| | | 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){ |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | 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(coursePackagePayment.getCoursePackageId()); |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | List<Integer> week = week(classWeeks); |
| | | |
| | | TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", coursePackagePayment.getCoursePackageId()).eq("studentId", coursePackagePayment.getStudentId())); |
| | | |
| | | Date today = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DATE, -1); |
| | | today = calendar.getTime(); |
| | | |
| | | |
| | | 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++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | CancelledClasses cancelledClasses = new CancelledClasses(); |
| | | cancelledClasses.setType(2); |
| | | cancelledClasses.setVoucher(paymentDeductionClassHour.getCode()); |
| | | cancelledClasses.setCoursePackageId(coursePackagePayment.getCoursePackageId()); |
| | | cancelledClasses.setCoursePackagePaymentId(coursePackagePayment.getId()); |
| | | cancelledClasses.setCancelledClassesNumber(classHour); |
| | | cancelledClasses.setInsertTime(new Date()); |
| | | cancelledClassesService.save(cancelledClasses); |
| | | break; |
| | | }else{ |
| | | CancelledClasses cancelledClasses = new CancelledClasses(); |
| | | cancelledClasses.setType(2); |
| | | cancelledClasses.setVoucher(paymentDeductionClassHour.getCode()); |
| | | cancelledClasses.setCoursePackageId(coursePackagePayment.getCoursePackageId()); |
| | | cancelledClasses.setCoursePackagePaymentId(coursePackagePayment.getId()); |
| | | cancelledClasses.setCancelledClassesNumber(coursePackagePayment.getLaveClassHours()); |
| | | cancelledClasses.setInsertTime(new Date()); |
| | | cancelledClassesService.save(cancelledClasses); |
| | | |
| | | coursePackagePayment.setLaveClassHours(0); |
| | | packagePaymentService.updateById(coursePackagePayment); |
| | | |
| | | classHour -= cancelledClasses.getCancelledClassesNumber(); |
| | | } |
| | | } |
| | | |
| | | // 2.0 少于3课时 推送 |
| | | if (coursePackagePayment.getLaveClassHours() <= 3) { |
| | | Integer appUserId = coursePackagePayment.getAppUserId(); |
| | | |
| | | //调用推送 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | String s1 = appUserId + "_" + "Three"; |
| | | //定时修改排课状态 |
| | | 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) { |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | } |
| | | } |
| | | |
| | | CancelledClasses cancelledClasses = new CancelledClasses(); |
| | | cancelledClasses.setType(2); |
| | | cancelledClasses.setVoucher(paymentDeductionClassHour.getCode()); |
| | | cancelledClasses.setCoursePackageId(coursePackagePayment.getCoursePackageId()); |
| | | cancelledClasses.setCoursePackagePaymentId(coursePackagePayment.getId()); |
| | | cancelledClasses.setCancelledClassesNumber(classHour); |
| | | cancelledClasses.setInsertTime(new Date()); |
| | | cancelledClassesService.save(cancelledClasses); |
| | | |
| | | }else{ |
| | | CancelledClasses cancelledClasses = new CancelledClasses(); |
| | | cancelledClasses.setType(2); |
| | | cancelledClasses.setVoucher(paymentDeductionClassHour.getCode()); |
| | | cancelledClasses.setCoursePackageId(coursePackagePayment.getCoursePackageId()); |
| | | cancelledClasses.setCoursePackagePaymentId(coursePackagePayment.getId()); |
| | | cancelledClasses.setCancelledClassesNumber(coursePackagePayment.getLaveClassHours()); |
| | | cancelledClasses.setInsertTime(new Date()); |
| | | cancelledClassesService.save(cancelledClasses); |
| | | |
| | | coursePackagePayment.setLaveClassHours(0); |
| | | packagePaymentService.updateById(coursePackagePayment); |
| | | |
| | | classHour -= cancelledClasses.getCancelledClassesNumber(); |
| | | } |
| | | // } |
| | | |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | private List<Integer> week(String week){ |
| | | String[] split = week.split(";"); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | for (String s : split) { |
| | | switch (s){ |
| | | case "周一": |
| | | integers.add(1); |
| | | break; |
| | | case "周二": |
| | | integers.add(2); |
| | | break; |
| | | case "周三": |
| | | integers.add(3); |
| | | break; |
| | | case "周四": |
| | | integers.add(4); |
| | | break; |
| | | case "周五": |
| | | integers.add(5); |
| | | break; |
| | | case "周六": |
| | | integers.add(6); |
| | | break; |
| | | case "周日": |
| | | integers.add(7); |
| | | break; |
| | | } |
| | | } |
| | | return integers; |
| | | } |
| | | /** |
| | | * 取消赛事回退支付课时 |
| | | * @param paymentDeductionClassHour |
| | |
| | | for (TCoursePackagePayment tCoursePackagePayment : list) { |
| | | Integer coursePackageId = tCoursePackagePayment.getCoursePackageId(); |
| | | TCoursePackage byId = tcpService.getById(coursePackageId); |
| | | if (byId.getType()==3){ |
| | | continue; |
| | | } |
| | | if(storeIds.contains(byId.getStoreId())){ |
| | | PayCourseRes payCourseRes = new PayCourseRes(); |
| | | payCourseRes.setCourseNum(tCoursePackagePayment.getLaveClassHours()); |
| | |
| | | } |
| | | } |
| | | return objects; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/isHave") |
| | | public Integer isHave(@RequestBody String ids){ |
| | | String[] split = ids.split(","); |
| | | return coursePackagePaymentService.count(new QueryWrapper<TCoursePackagePayment>().in("studentId",split)); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | tCourseInfoRecord.setType(1); |
| | | tCourseInfoRecord.setNum(paymentConfig.getClassHours()); |
| | | auClitn.addCourseInfoRecord(tCourseInfoRecord); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(packagePayment.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(packagePayment.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("购买课包"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | } catch (Exception e) { |
| | | return 4; |
| | | } |
| | |
| | | tCourseInfoRecord.setType(1); |
| | | tCourseInfoRecord.setTime(new Date()); |
| | | id = appUserClient.addCourseInfoRecord(tCourseInfoRecord); |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(packagePayment.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(packagePayment.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("续课"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | } |
| | | return id; |
| | | } |
| | |
| | | return packagePaymentService.save(packagePayment); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/coursePack/orderClass") |
| | | public void orderClass(@RequestBody OrderDto orderDto) throws ParseException { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | String[] split = orderDto.getStuIds().split(","); |
| | | for (String s : split) { |
| | | TCoursePackagePayment coursePackagePaymentServiceOne = coursePackagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", s).eq("coursePackageId",orderDto.getClassId())); |
| | | |
| | | |
| | | |
| | | if (coursePackagePaymentServiceOne==null) { |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | coursePackagePayment.setCode(code); |
| | | coursePackagePayment.setAppUserId(orderDto.getAppUserId()); |
| | | coursePackagePayment.setStudentId(Integer.valueOf(s)); |
| | | coursePackagePayment.setCoursePackageId(orderDto.getClassId()); |
| | | coursePackagePayment.setPayType(4); |
| | | coursePackagePayment.setClassHours(orderDto.getClassHours()); |
| | | coursePackagePayment.setTotalClassHours(orderDto.getClassHours()); |
| | | coursePackagePayment.setLaveClassHours(orderDto.getClassHours()); |
| | | coursePackagePayment.setAbsencesNumber(0); |
| | | coursePackagePayment.setPayUserType(1); |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setPayUserId(orderDto.getAppUserId()); |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setState(1); |
| | | coursePackagePayment.setInsertTime(new Date()); |
| | | coursePackagePaymentService.save(coursePackagePayment); |
| | | Integer sId = null; |
| | | Student student = studentClient.queryDefaultStudent(orderDto.getAppUserId()); |
| | | if (student != null) { |
| | | sId = student.getId(); |
| | | } |
| | | addPackageStudent(orderDto.getClassId(), orderDto.getAppUserId(), Integer.valueOf(s), coursePackagePayment.getId()); |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackagePayment.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(orderDto.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("积分兑换"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | }else { |
| | | coursePackagePaymentServiceOne.setClassHours(coursePackagePaymentServiceOne.getClassHours()+orderDto.getClassHours()); |
| | | coursePackagePaymentServiceOne.setTotalClassHours(coursePackagePaymentServiceOne.getTotalClassHours()+orderDto.getClassHours()); |
| | | coursePackagePaymentServiceOne.setLaveClassHours(coursePackagePaymentServiceOne.getLaveClassHours()+orderDto.getClassHours()); |
| | | coursePackagePaymentServiceOne.setAppUserId(null); |
| | | coursePackagePaymentService.updateById(coursePackagePaymentServiceOne); |
| | | |
| | | Integer sId = null; |
| | | Student student = studentClient.queryDefaultStudent(orderDto.getAppUserId()); |
| | | if (student != null) { |
| | | sId = student.getId(); |
| | | } |
| | | addPackageStudent(orderDto.getClassId(), orderDto.getAppUserId(), Integer.valueOf(s), coursePackagePaymentServiceOne.getId()); |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackagePaymentServiceOne.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(orderDto.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("积分兑换"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public static Date[] generateDateArray1(Date startDate, Date endDate) { |
| | | List<Date> dateList = new ArrayList<>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | |
| | | while (!calendar.getTime().after(endDate)) { |
| | | Date currentDate = calendar.getTime(); |
| | | dateList.add(currentDate); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | |
| | | return dateList.toArray(new Date[0]); |
| | | } |
| | | |
| | | @Autowired |
| | | private TCoursePackageService coursePackageService; |
| | | private void addPackageStudent(Integer courseId, Integer userId, Integer sId,Long paymentId) throws ParseException { |
| | | // 课包 |
| | | TCoursePackage tCoursePackage = coursePackageService.getById(courseId); |
| | | |
| | | if (tCoursePackage.getType()==1) { |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | |
| | | List<Integer> week = week(classWeeks); |
| | | |
| | | 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"); |
| | | |
| | | //查出当前用户当前学员当前课包最后一天的排课数据 |
| | | List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", sId).eq("coursePackageId", courseId)); |
| | | List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | //拿到最后一天的排课记录 |
| | | if (collect.size() > 0) { |
| | | coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id", collect)); |
| | | coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", sId).eq("coursePackageId", courseId)); |
| | | } |
| | | Date today = new Date(); |
| | | TCoursePackagePayment pay = coursePackagePaymentService.getById(paymentId); |
| | | Integer laveClassHours = pay.getLaveClassHours(); |
| | | Integer codeTime = tCoursePackage.getCodeTime(); |
| | | Integer can = 0; |
| | | int count = 0; |
| | | // 本周周几 |
| | | Date[] dates = generateDateArray(14, today); |
| | | if (tCoursePackage.getType() == 1) { |
| | | can = laveClassHours / codeTime; |
| | | } |
| | | if (tCoursePackage.getType() == 2) { |
| | | Date startDate = tCoursePackage.getStartTime(); |
| | | Date endDate = tCoursePackage.getEndTime(); |
| | | dates = generateDateArray1(startDate, endDate); |
| | | can = 999; |
| | | } |
| | | 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(userId); |
| | | student1.setStudentId(sId); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(paymentId); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | coursePackageStudentService.save(student1); |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | }else if (tCoursePackage.getType()==2){ |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | List<Integer> week = week(classWeeks); |
| | | |
| | | Date today = new Date(); |
| | | |
| | | Date startTime = tCoursePackage.getStartTime(); |
| | | Date endTime = tCoursePackage.getEndTime(); |
| | | LocalDate startDate = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | LocalDate endDate = endTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | Period period = Period.between(startDate, endDate); |
| | | int days = period.getDays() + 1; |
| | | Integer can =999; |
| | | 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"); |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | |
| | | TCoursePackagePayment pay = coursePackagePaymentService.getById(paymentId); |
| | | |
| | | |
| | | Date[] dates = generateDateArray(days,calendar.getTime()); |
| | | for (Date date : dates) { |
| | | if (count==can){ |
| | | break; |
| | | } |
| | | int wei = cn.hutool.core.date.DateUtil.dayOfWeek(date)-1; |
| | | if (wei == 0){ |
| | | wei =7; |
| | | } |
| | | 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(userId); |
| | | student1.setStudentId(sId); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(pay.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | coursePackageStudentService.save(student1); |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 2.0 |
| | | TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); |
| | | tCourseInfoRecord.setUserId(userId); |
| | | tCourseInfoRecord.setCourseId(courseId); |
| | | tCourseInfoRecord.setName("报名运动营"); |
| | | tCourseInfoRecord.setNum(tCoursePackage.getNeedNum()); |
| | | tCourseInfoRecord.setTime(new Date()); |
| | | tCourseInfoRecord.setType(2); |
| | | appUserClient.addCourseInfoRecord(tCourseInfoRecord); |
| | | |
| | | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePack/obtainStudentClassDetails") |
| | | public List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody WeeksOfCourseRest stuId){ |
| | | try { |
| | | return packagePaymentService.obtainStuClassDetails(stuId.getStuId(),stuId.getAppUserId()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(); |
| | | } |
| | | // try { |
| | | return packagePaymentService.obtainStuClassDetails(stuId.getStuId(),stuId.getAppUserId(),stuId.getPageNum()); |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // throw new RuntimeException(); |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 2.0 送课时 |
| | | @PostMapping("/base/coursePack/sendHours") |
| | | public Integer sendHours(@RequestBody String s){ |
| | | String[] split = s.split("_"); |
| | | TCoursePackagePayment byId = packagePaymentService.getById(Long.valueOf(split[0])); |
| | | byId.setTotalClassHours(byId.getTotalClassHours()+Integer.valueOf(split[2])); |
| | | boolean b = packagePaymentService.updateHoursById(byId,Integer.valueOf(split[2])); |
| | | public Integer sendHours(@RequestBody String s) throws ParseException { |
| | | String[] split2 = s.split("_"); |
| | | TCoursePackagePayment byId = packagePaymentService.getById(Long.valueOf(split2[0])); |
| | | byId.setTotalClassHours(byId.getTotalClassHours()+Integer.valueOf(split2[2])); |
| | | boolean b = packagePaymentService.updateHoursById(byId,Integer.valueOf(split2[2])); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(byId.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(Integer.valueOf(split2[2])); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("介绍有礼"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | |
| | | List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", byId.getStudentId()).eq("coursePackageId", byId.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", byId.getStudentId()).eq("coursePackageId", byId.getCoursePackageId())); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | TCoursePackage tCoursePackage = packageService.getById(byId.getCoursePackageId()); |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | List<Integer> week = week(classWeeks); |
| | | |
| | | TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", byId.getCoursePackageId()).eq("studentId", byId.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++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if(b){ |
| | | return 1; |
| | | }else { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePack/getConsumes") |
| | | List<CourseCounsum> getConsumes(@RequestBody BillingDataRequestVo requestVo) { |
| | | Integer[] integers = {2,3}; |
| | | QueryWrapper<CourseCounsum> courseCounsumQueryWrapper = new QueryWrapper<CourseCounsum>().in("changeType",integers).eq("appUserId",requestVo.getAppUserId()); |
| | | if (requestVo.getMonthEnd()!=null){ |
| | | courseCounsumQueryWrapper.ge("insertTime",requestVo.getMonthStart()); |
| | | courseCounsumQueryWrapper.le("insertTime",requestVo.getMonthEnd()); |
| | | } |
| | | return courseCounsumService.list(courseCounsumQueryWrapper); |
| | | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePack/weeksOfCourseDetailsList") |
| | | HashMap<String, Object> weeksOfCourseDetailsList(@RequestBody CourseDetailReq courseDetailReq){ |
| | |
| | | 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); |
| | |
| | | List<TCoursePackagePayment> list1 = packagePaymentService.list(new LambdaQueryWrapper<TCoursePackagePayment>().eq(TCoursePackagePayment::getAppUserId, courseDetailReq.getAppUserId()).eq(TCoursePackagePayment::getStudentId, courseDetailReq.getStuId()).in(TCoursePackagePayment::getCoursePackageId, collect)); |
| | | List<Integer> collect1 = list1.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | List<Long> ids = list1.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList()); |
| | | |
| | | |
| | | for (TCoursePackage tCoursePackage : list) { |
| | | DetailsListVo detailsListVo = new DetailsListVo(); |
| | | detailsListVo.setId(tCoursePackage.getId()); |
| | | detailsListVo.setName(tCoursePackage.getName()); |
| | | detailsListVo.setCourseType(tCoursePackage.getType()); |
| | | String classStartTime = tCoursePackage.getClassStartTime(); |
| | | String[] split = classStartTime.split(","); |
| | | String classEndTime = tCoursePackage.getClassEndTime(); |
| | |
| | | strings.add(s); |
| | | } |
| | | } |
| | | if (detailsListVo.getCourseType()==1) { |
| | | detailsListVo.setTime(strings); |
| | | }else { |
| | | Date startTime = tCoursePackage.getStartTime(); |
| | | Date endTime = tCoursePackage.getEndTime(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String formattedStartTime = sdf.format(startTime); |
| | | String formattedEndTime = sdf.format(endTime); |
| | | |
| | | detailsListVo.setTime(strings); |
| | | String result = formattedStartTime + "至" + formattedEndTime; |
| | | List<String> stringLists = new ArrayList<>(); |
| | | stringLists.add(result); |
| | | detailsListVo.setTime(stringLists); |
| | | |
| | | } |
| | | //价格 |
| | | List<CoursePackagePaymentConfig> list2 = icppcService.list(new LambdaQueryWrapper<CoursePackagePaymentConfig>().eq(CoursePackagePaymentConfig::getCoursePackageId, tCoursePackage.getId()).orderByAsc(CoursePackagePaymentConfig::getCashPayment)); |
| | | if (list2.size() > 0) { |
| | | Double cashPayment = list2.get(0).getCashPayment(); |
| | |
| | | .like(CoursePackageScheduling::getClassDate, courseDetailReq.getTime()) |
| | | ); |
| | | if(list3.size()==0){ |
| | | break; |
| | | detailsListVo.setType(2); |
| | | objects.add(detailsListVo); |
| | | continue; |
| | | } |
| | | //排课的ids |
| | | List<Long> collect2 = list3.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); |
| | | if(collect2.size()==0){ |
| | | collect2.add(-1l); |
| | | } |
| | | |
| | | |
| | | List<CoursePackageStudent> list4 = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>() |
| | | .eq(CoursePackageStudent::getAppUserId, courseDetailReq.getAppUserId()) |
| | | .eq(CoursePackageStudent::getCoursePackageId, tCoursePackage.getId()) |
| | |
| | | in(CoursePackageStudent::getCoursePackagePaymentId, ids) |
| | | ); |
| | | |
| | | detailsListVo.setType(1); |
| | | if(list4.size()>0){ |
| | | List<CoursePackageStudent> list5 = cspsService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", courseDetailReq.getStuId()).eq("coursePackageId",tCoursePackage.getId())); |
| | | |
| | | if(list5.size()>0&&list4.size()>0){ |
| | | Integer signInOrNot = list4.get(0).getSignInOrNot(); |
| | | detailsListVo.setType(1); |
| | | |
| | | if(signInOrNot==2){ |
| | | detailsListVo.setType(3); |
| | | } |
| | | detailsListVo.setIsType(list4.get(0).getType()); |
| | | |
| | | for (CoursePackageStudent coursePackageStudent : list4) { |
| | | Integer signInOrNot1 = coursePackageStudent.getSignInOrNot(); |
| | | detailsListVo.setType(1); |
| | | |
| | | if(signInOrNot1==2){ |
| | | detailsListVo.setType(3); |
| | | } |
| | | detailsListVo.setIsType(coursePackageStudent.getType()); |
| | | CoursePackageScheduling coursePackageScheduling = coursePackageSchedulingMapper.selectById(coursePackageStudent.getCoursePackageSchedulingId()); |
| | | Date classDate = coursePackageScheduling.getClassDate(); |
| | | Date endDate = coursePackageScheduling.getEndDate(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
| | | String formattedClassDate = sdf.format(classDate); |
| | | String formattedEndDate = sdf.format(endDate); |
| | | |
| | | String result = formattedClassDate + "-" + formattedEndDate; |
| | | List<String> strings1 =new ArrayList<>(); |
| | | strings1.add(result); |
| | | detailsListVo.setTime(strings1); |
| | | DetailsListVo detailsListVo1 = new DetailsListVo(); |
| | | |
| | | // detailsListVo1.setId(coursePackageStudent.getId()); |
| | | BeanUtils.copyProperties(detailsListVo,detailsListVo1); |
| | | objects.add(detailsListVo1); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | }else { |
| | | detailsListVo.setType(2); |
| | | objects.add(detailsListVo); |
| | | |
| | | } |
| | | |
| | | } else { |
| | | detailsListVo.setType(2); |
| | | objects.add(detailsListVo); |
| | | |
| | | } |
| | | objects.add(detailsListVo); |
| | | // objects.add(detailsListVo); |
| | | } |
| | | map.put("data",objects); |
| | | |
| | |
| | | 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(coursePackage.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)).filter(student -> student.getNeedNum() != null).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)).filter(student -> student.getNeedNum() != null).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); |
| | | // 周度数据 |
| | | LocalDateTime s1 = minNow.minusDays(6); |
| | | LocalDateTime s2 = maxNow; |
| | | |
| | | LocalDateTime s3 = minNow.minusDays(13); |
| | | LocalDateTime s4 = maxNow.minusDays(6); |
| | | |
| | | |
| | | LocalDateTime s5 = minNow.minusDays(20); |
| | | LocalDateTime s6 = maxNow.minusDays(13); |
| | | |
| | | LocalDateTime s7 = minNow.minusDays(27); |
| | | LocalDateTime s8 = maxNow.minusDays(20); |
| | | ArrayList<Object> weekData = new ArrayList<>(); |
| | | |
| | | int count = 0; |
| | | |
| | | int count1 = 0; |
| | | |
| | | int count2 = 0; |
| | | |
| | | int count3 = 0; |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | if (coursePackageStudent.getNeedNum()==null){ |
| | | continue; |
| | | } |
| | | // 如果到课状态为否 则不计算 |
| | | if (coursePackageStudent.getSignInOrNot() != 0) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | Instant instant = insertTime.toInstant(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); |
| | | if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ |
| | | |
| | | count+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ |
| | | count1+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ |
| | | count2+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ |
| | | count3+=coursePackageStudent.getNeedNum(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | weekData.add(count3); |
| | | weekData.add(count2); |
| | | weekData.add(count1); |
| | | weekData.add(count); |
| | | |
| | | map.put("weekData",weekData); |
| | | |
| | | |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | // 将 Date 转换为 LocalDateTime |
| | | LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); |
| | | // 计算日期与当前日期的差距 |
| | | long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); |
| | | // 如果日期在七天内,累加金额 |
| | | if (daysDifference >= 0 && daysDifference < 7) { |
| | | int index = (int) (6 - daysDifference); // 计算对应的索引位置 |
| | | Integer needNum = coursePackageStudent.getNeedNum(); |
| | | if (needNum!=null){ |
| | | int i = amountByDay.get(index) + needNum; |
| | | amountByDay.set(index, i); |
| | | } |
| | | |
| | | } |
| | | } |
| | | map.put("dayData", amountByDay); |
| | | |
| | | return map; |
| | | |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/courseYys") |
| | | HashMap<String, Object> courseYys(@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(coursePackage.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)).filter(student -> student.getNeedNum() != null).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)).filter(student -> student.getNeedNum() != null).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); |
| | | // 周度数据 |
| | | LocalDateTime s1 = minNow.minusDays(6); |
| | | LocalDateTime s2 = maxNow; |
| | | |
| | | LocalDateTime s3 = minNow.minusDays(13); |
| | | LocalDateTime s4 = maxNow.minusDays(6); |
| | | |
| | | |
| | | LocalDateTime s5 = minNow.minusDays(20); |
| | | LocalDateTime s6 = maxNow.minusDays(13); |
| | | |
| | | LocalDateTime s7 = minNow.minusDays(27); |
| | | LocalDateTime s8 = maxNow.minusDays(20); |
| | | ArrayList<Object> weekData = new ArrayList<>(); |
| | | |
| | | int count = 0; |
| | | |
| | | int count1 = 0; |
| | | |
| | | int count2 = 0; |
| | | |
| | | int count3 = 0; |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | if (coursePackageStudent.getNeedNum()==null){ |
| | | continue; |
| | | } |
| | | // 如果到课状态为否 则不计算 |
| | | if (coursePackageStudent.getSignInOrNot() != 0) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | Instant instant = insertTime.toInstant(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); |
| | | if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ |
| | | |
| | | count+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ |
| | | count1+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ |
| | | count2+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ |
| | | count3+=coursePackageStudent.getNeedNum(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | weekData.add(count3); |
| | | weekData.add(count2); |
| | | weekData.add(count1); |
| | | weekData.add(count); |
| | | |
| | | map.put("weekData",weekData); |
| | | |
| | | |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | // 将 Date 转换为 LocalDateTime |
| | | LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); |
| | | // 计算日期与当前日期的差距 |
| | | long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); |
| | | // 如果日期在七天内,累加金额 |
| | | if (daysDifference >= 0 && daysDifference < 7) { |
| | | int index = (int) (6 - daysDifference); // 计算对应的索引位置 |
| | | Integer needNum = coursePackageStudent.getNeedNum(); |
| | | if (needNum!=null){ |
| | | int i = amountByDay.get(index) + needNum; |
| | | amountByDay.set(index, i); |
| | | } |
| | | |
| | | } |
| | | } |
| | | map.put("dayData", amountByDay); |
| | | |
| | | return map; |
| | | |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/courseStore") |
| | | HashMap<String, Object> courseStore(@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(coursePackage.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)).filter(student -> student.getNeedNum() != null).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)).filter(student -> student.getNeedNum() != null).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); |
| | | // 周度数据 |
| | | LocalDateTime s1 = minNow.minusDays(6); |
| | | LocalDateTime s2 = maxNow; |
| | | |
| | | LocalDateTime s3 = minNow.minusDays(13); |
| | | LocalDateTime s4 = maxNow.minusDays(6); |
| | | |
| | | |
| | | LocalDateTime s5 = minNow.minusDays(20); |
| | | LocalDateTime s6 = maxNow.minusDays(13); |
| | | |
| | | LocalDateTime s7 = minNow.minusDays(27); |
| | | LocalDateTime s8 = maxNow.minusDays(20); |
| | | ArrayList<Object> weekData = new ArrayList<>(); |
| | | |
| | | int count = 0; |
| | | |
| | | int count1 = 0; |
| | | |
| | | int count2 = 0; |
| | | |
| | | int count3 = 0; |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | if (coursePackageStudent.getNeedNum()==null){ |
| | | continue; |
| | | } |
| | | // 如果到课状态为否 则不计算 |
| | | if (coursePackageStudent.getSignInOrNot() != 0) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | Instant instant = insertTime.toInstant(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); |
| | | if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ |
| | | |
| | | count+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ |
| | | count1+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ |
| | | count2+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ |
| | | count3+=coursePackageStudent.getNeedNum(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | weekData.add(count3); |
| | | weekData.add(count2); |
| | | weekData.add(count1); |
| | | weekData.add(count); |
| | | |
| | | map.put("weekData",weekData); |
| | | |
| | | |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | // 将 Date 转换为 LocalDateTime |
| | | LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); |
| | | // 计算日期与当前日期的差距 |
| | | long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); |
| | | // 如果日期在七天内,累加金额 |
| | | if (daysDifference >= 0 && daysDifference < 7) { |
| | | int index = (int) (6 - daysDifference); // 计算对应的索引位置 |
| | | Integer needNum = coursePackageStudent.getNeedNum(); |
| | | if (needNum!=null){ |
| | | int i = amountByDay.get(index) + needNum; |
| | | amountByDay.set(index, i); |
| | | } |
| | | |
| | | } |
| | | } |
| | | map.put("dayData", amountByDay); |
| | | |
| | | return map; |
| | | |
| | | } |
| | | } |