| | |
| | | package com.dsh.course.controller; |
| | | |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.dsh.course.entity.StudentClassInfo; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.entity.dto.ClassListDto; |
| | | import com.dsh.course.entity.dto.SelectDto; |
| | | import com.dsh.course.entity.dto.updateTimeDto; |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.entity.dto.*; |
| | | import com.dsh.course.feignclient.account.AppUserClient; |
| | | import com.dsh.course.service.CoursePackageStudentService; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | import com.dsh.course.feignclient.account.StudentClient; |
| | | import com.dsh.course.feignclient.account.model.Student; |
| | | import com.dsh.course.mapper.CoursePackageSchedulingMapper; |
| | | import com.dsh.course.model.dto.ToClassDto; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.UUIDUtil; |
| | | import io.swagger.annotations.Api; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.swing.text.html.parser.Entity; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api |
| | | @CrossOrigin |
| | |
| | | CoursePackageStudentService studentService ; |
| | | @Autowired |
| | | TCoursePackagePaymentService paymentService; |
| | | @Autowired |
| | | private CourseCounsumService counsumService; |
| | | @Autowired |
| | | private TCoursePackageService coursePackageService; |
| | | //获取退费记录 |
| | | @RequestMapping("/getRefund") |
| | | @ResponseBody |
| | | public List<MoneyBack> getRefund() { |
| | | // 查询已通过申请的退费记录 |
| | | return counsumService.getRefund(); |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private CoursePackageSchedulingMapper coursePackageSchedulingService; |
| | | |
| | | |
| | | |
| | | |
| | | @RequestMapping("/getStudentTotal") |
| | | @ResponseBody |
| | | public List<Map<String, Object>> get(@RequestBody StudentQeryDto studentQeryDto) { |
| | | System.out.println("-====studentQeryDto========="+studentQeryDto); |
| | | List<Map<String, Object>> pays = paymentService.getStudentTotal(studentQeryDto); |
| | | System.out.println("=========pays======"+pays); |
| | | |
| | | return pays; |
| | | |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/bypac") |
| | | @ResponseBody |
| | | public List<Map<String, Object>> bypac(@RequestBody PacQueryDto pacQueryDto) { |
| | | System.out.println("-====studentQeryDto========="+pacQueryDto); |
| | | if (pacQueryDto.getStoreIds()!=null && pacQueryDto.getStoreIds().size()!=0){ |
| | | // 根据门店id 查询课包ids |
| | | List<Integer> coursePackageIds = coursePackageService.list(new QueryWrapper<TCoursePackage>() |
| | | .in("storeId", pacQueryDto.getStoreIds())).stream() |
| | | .map(TCoursePackage::getId).collect(Collectors.toList()); |
| | | pacQueryDto.setStoreIds(coursePackageIds); |
| | | } |
| | | List<Map<String, Object>> pays = paymentService.bypac(pacQueryDto); |
| | | |
| | | System.out.println("=========pays======"+pays); |
| | | |
| | | return pays; |
| | | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/queryIdsByStore") |
| | | public List<Integer> queryIdsByStore(@RequestBody Integer objectId){ |
| | | List<TCoursePackage> list = packageService.list(new LambdaQueryWrapper<TCoursePackage>().eq(TCoursePackage::getStoreId, objectId)); |
| | | List<Integer> collect = list.stream().map(TCoursePackage::getId).collect(Collectors.toList()); |
| | | if(collect.size()==0){ |
| | | collect.add(-1); |
| | | } |
| | | return collect; |
| | | } |
| | | |
| | | |
| | | //获取学员课时数信息 |
| | | @RequestMapping("/getInfo") |
| | | @ResponseBody |
| | |
| | | |
| | | // Date maxDate = studentService.getMaxDate(tStudentId); |
| | | Date minDate = studentService.getMinDate(tStudentId); |
| | | System.out.println("===========>"+studentClassInfo); |
| | | Integer totalHours = studentClassInfo.getTotalHours(); |
| | | Integer hasHours = studentClassInfo.getRestHours(); |
| | | Integer restHours = totalHours-hasHours; |
| | | studentClassInfo.setHasHours(restHours); |
| | | studentClassInfo.setInDate(minDate); |
| | | System.out.println("===========>"+studentClassInfo); |
| | | |
| | | return studentClassInfo; |
| | | } |
| | | //获取学员课程列表 |
| | |
| | | public List<ClassListDto> listClass(@RequestParam("tStudentId")Integer tStudentId) { |
| | | System.out.println("==========getClassList===tStudentId===="+tStudentId); |
| | | List<ClassListDto> listDtos = studentService.getClassList(tStudentId); |
| | | for (ClassListDto dto : listDtos){ |
| | | dto.setHasClassHours(dto.getTotalClassHours()-dto.getLaveClassHours()); |
| | | } |
| | | System.out.println("======listDtos======"+listDtos); |
| | | return listDtos; |
| | | |
| | |
| | | //获取可转移学员 |
| | | @RequestMapping("/getSelect") |
| | | @ResponseBody |
| | | public List<SelectDto> getSelect(@RequestParam("payId")Integer payId){ |
| | | public List<SelectDto> getSelect(@RequestParam("payId")Long payId){ |
| | | |
| | | List<Integer> studentIds = paymentService.getStudentIds(payId); |
| | | TCoursePackagePayment byId = paymentService.getById(payId); |
| | | |
| | | List<Integer> studentIds = paymentService.getStudentIds(payId,byId.getCoursePackageId(),byId.getAppUserId()); |
| | | System.out.println("=========studentIds=================>"+studentIds); |
| | | |
| | | if (studentIds.size()>0){ |
| | | List<SelectDto> selectDtos = appUserClient.getSelects(studentIds); |
| | | |
| | | return selectDtos;} |
| | | else return null; |
| | | } |
| | | |
| | | |
| | | |
| | | //根据payid获取对应门店的常规课程 |
| | | |
| | | @Autowired |
| | | private TCoursePackageService packageService; |
| | | @RequestMapping("/holiSelect") |
| | | @ResponseBody |
| | | public List<SelectDto> getHoliSelect(@RequestParam("courseId")Integer id){ |
| | | |
| | | TCoursePackage byId = packageService.getById(id); |
| | | Integer storeId = byId.getStoreId(); |
| | | List<TCoursePackage> list = packageService.list(new QueryWrapper<TCoursePackage>() |
| | | .select("id", "name") |
| | | .eq("storeId", storeId) |
| | | .eq("type","2") |
| | | ); |
| | | List<SelectDto> selectDtos = new ArrayList<>(); |
| | | for (TCoursePackage t :list){ |
| | | SelectDto selectDto = new SelectDto(); |
| | | selectDto.setId(t.getId()); |
| | | selectDto.setValue(t.getName()); |
| | | selectDtos.add(selectDto); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | return selectDtos; |
| | | } |
| | | |
| | | @RequestMapping("/transSelect") |
| | | @ResponseBody |
| | | public List<SelectDto> getTransSelect(@RequestParam("courseId")Integer id){ |
| | | |
| | | TCoursePackage byId = packageService.getById(id); |
| | | Integer storeId = byId.getStoreId(); |
| | | List<TCoursePackage> list = packageService.list(new QueryWrapper<TCoursePackage>() |
| | | .select("id", "name") |
| | | .eq("storeId", storeId) |
| | | .eq("type","1").ne("id",id) |
| | | ); |
| | | List<SelectDto> selectDtos = new ArrayList<>(); |
| | | for (TCoursePackage t :list){ |
| | | SelectDto selectDto = new SelectDto(); |
| | | selectDto.setId(t.getId()); |
| | | selectDto.setValue(t.getName()); |
| | | selectDtos.add(selectDto); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | return selectDtos; |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/queryCounsum") |
| | | @ResponseBody |
| | | public List<CourseCounsum> queryCounsum(@RequestBody ConsumeQuery consumeQuery){ |
| | | System.out.println("======queryCounsum==========="+consumeQuery); |
| | | |
| | | QueryWrapper<CourseCounsum> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("paymentId",consumeQuery.getPayId()); |
| | | |
| | | |
| | | if (consumeQuery.getChangeType()!=null){ |
| | | queryWrapper.eq("changeType", consumeQuery.getChangeType()); |
| | | } |
| | | if (consumeQuery.getStart()!=null){ |
| | | queryWrapper.between("insertTime", consumeQuery.getStart(), consumeQuery.getEnd()); |
| | | } |
| | | if (consumeQuery.getReason()!=null&&consumeQuery.getReason()!=""){ |
| | | queryWrapper.like("reason", consumeQuery.getReason()); |
| | | |
| | | } |
| | | |
| | | List<CourseCounsum> list = counsumService.list(queryWrapper); |
| | | |
| | | |
| | | |
| | | |
| | | // List<CourseCounsum> list = counsumService.list(new QueryWrapper<CourseCounsum>().eq("paymentId", consumeQuery.getPayId()).eq("changeType", consumeQuery.getChangeType()).between("insertTime", consumeQuery.getStart(), consumeQuery.getEnd()).like("reason", consumeQuery.getReason())); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/insertBack") |
| | | @ResponseBody |
| | | public void insertBack(@RequestBody InsertBackDto insertBackDto){ |
| | | |
| | | MoneyBack moneyBack = new MoneyBack(); |
| | | moneyBack.setStudentId(insertBackDto.getId()); |
| | | moneyBack.setStatus(0); |
| | | moneyBack.setInsertTime(new Date()); |
| | | moneyBack.setIds(insertBackDto.getIds()); |
| | | moneyBackService.save(moneyBack); |
| | | |
| | | List<TCoursePackagePayment> pays = paymentService.list(new QueryWrapper<TCoursePackagePayment>().in("id", insertBackDto.getIds())); |
| | | for (TCoursePackagePayment o :pays){ |
| | | o.setStatus(4); |
| | | o.setAppUserId(null); |
| | | } |
| | | |
| | | |
| | | |
| | | paymentService.updateBatchById(pays); |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/queryByIds") |
| | | @ResponseBody |
| | | public List<TCoursePackagePayment> queryByIds(@RequestParam("ids")String ids){ |
| | | List<TCoursePackagePayment> paymentList = paymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .in("id", Arrays.asList(ids.split(",")))); |
| | | |
| | | System.out.println("========client==>"+paymentList); |
| | | return paymentList; |
| | | } |
| | | |
| | | @RequestMapping("/changeStatus") |
| | | @ResponseBody |
| | | public void changeStatus(@RequestParam("id")Integer id){ |
| | | MoneyBack byId = moneyBackService.getById(id); |
| | | byId.setStatus(1); |
| | | moneyBackService.updateById(byId); |
| | | |
| | | } |
| | | |
| | | @RequestMapping("/noStatus") |
| | | @ResponseBody |
| | | public void noStatus(@RequestParam("id")Integer id){ |
| | | MoneyBack byId = moneyBackService.getById(id); |
| | | byId.setStatus(2); |
| | | moneyBackService.updateById(byId); |
| | | |
| | | } |
| | | |
| | | @RequestMapping("/zeroClass") |
| | | @ResponseBody |
| | | public void zeroClass(@RequestParam("id")Integer id){ |
| | | MoneyBack byId = moneyBackService.getById(id); |
| | | String[] split = byId.getIds().split(","); |
| | | System.out.println("========split===>"+split); |
| | | List<TCoursePackagePayment> id1 = paymentService.list(new QueryWrapper<TCoursePackagePayment>().in("id", split)); |
| | | for (TCoursePackagePayment o :id1){ |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setNum(o.getLaveClassHours()); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setReason("退费"); |
| | | courseCounsum.setPaymentId(o.getId()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | counsumService.save(courseCounsum); |
| | | |
| | | o.setTotalClassHours(0); |
| | | o.setLaveClassHours(0); |
| | | o.setStatus(2); |
| | | o.setAppUserId(null); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | paymentService.updateBatchById(id1); |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/backStausClass") |
| | | @ResponseBody |
| | | public void backStausClass(@RequestParam("id")Integer id){ |
| | | MoneyBack byId = moneyBackService.getById(id); |
| | | String[] split = byId.getIds().split(","); |
| | | System.out.println("========split===>"+split); |
| | | List<TCoursePackagePayment> id1 = paymentService.list(new QueryWrapper<TCoursePackagePayment>().in("id", split)); |
| | | for (TCoursePackagePayment o :id1){ |
| | | o.setStatus(1); |
| | | o.setAppUserId(null); |
| | | } |
| | | paymentService.updateBatchById(id1); |
| | | } |
| | | @RequestMapping("/cancel") |
| | | @ResponseBody |
| | | public void cancel(@RequestParam("ids")String ids){ |
| | | String[] split = ids.split(","); |
| | | List<CoursePackageStudent> coursePackagePaymentId = studentService.list(new QueryWrapper<CoursePackageStudent>().in("coursePackagePaymentId", split)); |
| | | for (CoursePackageStudent student :coursePackagePaymentId){ |
| | | student.setReservationStatus(3); |
| | | student.setAppUserId(null); |
| | | } |
| | | studentService.updateBatchById(coursePackagePaymentId); |
| | | |
| | | |
| | | } |
| | | |
| | | @Autowired |
| | | private MoneyBackService moneyBackService; |
| | | @RequestMapping("/getMoneyBack") |
| | | @ResponseBody |
| | | public List<MoneyBack> getMoneyBack(@RequestParam("tStudentId")Integer tStudentId){ |
| | | |
| | | List<MoneyBack> moneyBacksck = moneyBackService.list(new QueryWrapper<MoneyBack>().eq("studentId", tStudentId)); |
| | | return moneyBacksck; |
| | | } |
| | | |
| | | //课程转移 |
| | | @RequestMapping("/toClass") |
| | | @ResponseBody |
| | | public void toClass(@RequestBody ToClassDto toClassDto){ |
| | | System.out.println("===========到达getSelect======="+toClassDto); |
| | | TCoursePackagePayment orinPay = paymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("id", toClassDto.getId())); |
| | | TCoursePackagePayment studentPay = paymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", toClassDto.getToStudentId()).eq("coursePackageId",orinPay.getCoursePackageId())); |
| | | if (studentPay!=null) { |
| | | System.out.println("======orinPay=====>" + orinPay); |
| | | System.out.println("======studentPay=====>" + studentPay); |
| | | Integer laveClassHours = orinPay.getLaveClassHours(); |
| | | Integer totalClassHours = orinPay.getTotalClassHours(); |
| | | |
| | | orinPay.setTotalClassHours(0); |
| | | orinPay.setLaveClassHours(0); |
| | | orinPay.setStatus(5); |
| | | orinPay.setAppUserId(null); |
| | | paymentService.updateById(orinPay); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | if (orinPay.getAppUserId()!=studentPay.getAppUserId()){ |
| | | courseCounsum.setReason("赠课"); |
| | | }else { courseCounsum.setReason("转课"); |
| | | } |
| | | courseCounsum.setNum(laveClassHours); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setPaymentId(orinPay.getId()); |
| | | counsumService.save(courseCounsum); |
| | | |
| | | Integer laveClassHours1 = studentPay.getLaveClassHours(); |
| | | Integer totalClassHours1 = studentPay.getTotalClassHours(); |
| | | int total = totalClassHours + totalClassHours1; |
| | | int lave = laveClassHours + laveClassHours1; |
| | | |
| | | studentPay.setAppUserId(null); |
| | | studentPay.setLaveClassHours(lave); |
| | | studentPay.setTotalClassHours(total); |
| | | paymentService.updateById(studentPay); |
| | | |
| | | CourseCounsum courseCounsum1 = new CourseCounsum(); |
| | | courseCounsum1.setInsertTime(new Date()); |
| | | courseCounsum1.setReason("转课"); |
| | | courseCounsum1.setNum(laveClassHours); |
| | | courseCounsum1.setChangeType(1); |
| | | courseCounsum1.setPaymentId(studentPay.getId()); |
| | | counsumService.save(courseCounsum1); |
| | | |
| | | }else { |
| | | |
| | | |
| | | |
| | | Student student = studentClient.queryStudentById(toClassDto.getToStudentId()); |
| | | TCoursePackagePayment to = new TCoursePackagePayment(); |
| | | to.setStudentId(toClassDto.getToStudentId()); |
| | | to.setTotalClassHours(orinPay.getTotalClassHours()); |
| | | to.setLaveClassHours(orinPay.getLaveClassHours()); |
| | | to.setCoursePackageId(orinPay.getCoursePackageId()); |
| | | to.setState(1); |
| | | to.setAppUserId(student.getAppUserId()); |
| | | to.setPayStatus(2); |
| | | to.setStatus(1); |
| | | to.setInsertTime(new Date()); |
| | | paymentService.save(to); |
| | | |
| | | |
| | | |
| | | orinPay.setTotalClassHours(0); |
| | | orinPay.setLaveClassHours(0); |
| | | orinPay.setAppUserId(null); |
| | | orinPay.setStatus(6); |
| | | paymentService.updateById(orinPay); |
| | | |
| | | |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("赠课"); |
| | | courseCounsum.setNum(orinPay.getLaveClassHours()); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setPaymentId(orinPay.getId()); |
| | | counsumService.save(courseCounsum); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | CourseCounsum courseCounsum1 = new CourseCounsum(); |
| | | courseCounsum1.setInsertTime(new Date()); |
| | | courseCounsum1.setReason("赠课"); |
| | | courseCounsum1.setNum(orinPay.getLaveClassHours()); |
| | | courseCounsum1.setChangeType(1); |
| | | courseCounsum1.setPaymentId(to.getId()); |
| | | counsumService.save(courseCounsum); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | @RequestMapping(value = "/toHoli",produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = "application/json;charset=UTF-8") |
| | | @ResponseBody |
| | | public String toHoli(@RequestBody ToHoliDto toHoliDto) throws ParseException { |
| | | |
| | | String [] ids = toHoliDto.getIds(); |
| | | List<String> strings = new ArrayList<>(); |
| | | |
| | | |
| | | for (String id : ids){ |
| | | //扣除课时 |
| | | TCoursePackagePayment payment = paymentService.getById(id); |
| | | System.out.println("=====byId========="+payment); |
| | | |
| | | |
| | | Integer laveClassHours = payment.getLaveClassHours(); |
| | | |
| | | Integer classNum = toHoliDto.getClassNum(); |
| | | Integer totalClassHours = payment.getTotalClassHours(); |
| | | Student student = studentClient.queryStudentById(payment.getStudentId()); |
| | | |
| | | if (laveClassHours < classNum){ |
| | | strings.add(student.getName()); continue; |
| | | } |
| | | |
| | | Integer laveClassHoursnew = laveClassHours - classNum; |
| | | Integer totalClassHoursnew = totalClassHours - classNum; |
| | | payment.setLaveClassHours(laveClassHoursnew); |
| | | payment.setTotalClassHours(totalClassHoursnew); |
| | | payment.setAppUserId(null); |
| | | payment.setStatus(3); |
| | | |
| | | paymentService.updateById(payment); |
| | | |
| | | //获取student信息 |
| | | |
| | | //新增课时 |
| | | |
| | | TCoursePackagePayment holi = new TCoursePackagePayment(); |
| | | holi.setAppUserId(student.getAppUserId()); |
| | | holi.setStudentId(student.getId()); |
| | | holi.setCoursePackageId(toHoliDto.getClassId()); |
| | | holi.setTotalClassHours(toHoliDto.getClassNum()); |
| | | holi.setLaveClassHours(toHoliDto.getClassNum()); |
| | | holi.setState(1); |
| | | holi.setInsertTime(new Date()); |
| | | holi.setPayStatus(2); |
| | | paymentService.save(holi); |
| | | |
| | | TCoursePackage tCoursePackage = packageService.getById(toHoliDto.getClassId()); |
| | | 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"); |
| | | // 本周周几 |
| | | int i = DateUtil.dayOfWeek(new Date())-1; |
| | | for (Integer integer : week) { |
| | | if(integer<i){ |
| | | // 找下一周的时间 |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7-(i-integer)); |
| | | Date time = instance.getTime(); |
| | | |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.insert(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(student.getAppUserId()); |
| | | student1.setStudentId(student.getId()); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(holi.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | studentService.save(student1); |
| | | |
| | | } |
| | | |
| | | }else if(integer>i) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,integer-i); |
| | | Date time1 = instance.getTime(); |
| | | List<Date> list = new ArrayList<>(); |
| | | list.add(time1); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time2 = instance.getTime(); |
| | | list.add(time2); |
| | | for (Date time : list) { |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.insert(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(student.getAppUserId()); |
| | | student1.setStudentId(student.getId()); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(holi.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | studentService.save(student1); |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time = instance.getTime(); |
| | | |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.insert(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(student.getAppUserId()); |
| | | student1.setStudentId(student.getId()); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(holi.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | studentService.save(student1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | System.out.println("保存成功=============》="+holi); |
| | | |
| | | |
| | | |
| | | } |
| | | String[] stringArray = strings.toArray(new String[strings.size()]); |
| | | |
| | | String join = StringUtils.join(stringArray, ","); |
| | | System.out.println("==========join========"+join); |
| | | return join; |
| | | |
| | | |
| | | |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | @RequestMapping(value = "/toTrans",produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = "application/json;charset=UTF-8") |
| | | @ResponseBody |
| | | public String toTrans(@RequestBody ToHoliDto toHoliDto) throws ParseException { |
| | | |
| | | String [] ids = toHoliDto.getIds(); |
| | | List<String> strings = new ArrayList<>(); |
| | | |
| | | |
| | | for (String id : ids){ |
| | | //扣除课时 |
| | | TCoursePackagePayment payment = paymentService.getById(id); |
| | | System.out.println("=====byId========="+payment); |
| | | |
| | | |
| | | Integer laveClassHours = payment.getLaveClassHours(); |
| | | |
| | | Integer classNum = toHoliDto.getClassNum(); |
| | | Integer totalClassHours = payment.getTotalClassHours(); |
| | | Student student = studentClient.queryStudentById(payment.getStudentId()); |
| | | |
| | | // if (laveClassHours < classNum){ |
| | | // strings.add(student.getName()); continue; |
| | | // } |
| | | // |
| | | // Integer laveClassHoursnew = laveClassHours - classNum; |
| | | // Integer totalClassHoursnew = totalClassHours - classNum; |
| | | payment.setLaveClassHours(0); |
| | | payment.setTotalClassHours(0); |
| | | payment.setAppUserId(null); |
| | | |
| | | paymentService.updateById(payment); |
| | | |
| | | //获取student信息 |
| | | |
| | | //新增课时 |
| | | |
| | | TCoursePackagePayment holi = new TCoursePackagePayment(); |
| | | holi.setAppUserId(student.getAppUserId()); |
| | | holi.setStudentId(student.getId()); |
| | | holi.setCoursePackageId(toHoliDto.getClassId()); |
| | | holi.setTotalClassHours(laveClassHours); |
| | | holi.setLaveClassHours(laveClassHours); |
| | | holi.setState(1); |
| | | holi.setInsertTime(new Date()); |
| | | holi.setPayStatus(2); |
| | | paymentService.save(holi); |
| | | |
| | | System.out.println("保存成功=============》="+holi); |
| | | |
| | | |
| | | |
| | | TCoursePackage tCoursePackage = packageService.getById(toHoliDto.getClassId()); |
| | | 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"); |
| | | // 本周周几 |
| | | int i = DateUtil.dayOfWeek(new Date())-1; |
| | | for (Integer integer : week) { |
| | | if(integer<i){ |
| | | // 找下一周的时间 |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7-(i-integer)); |
| | | Date time = instance.getTime(); |
| | | |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.insert(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(student.getAppUserId()); |
| | | student1.setStudentId(student.getId()); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(holi.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | studentService.save(student1); |
| | | |
| | | } |
| | | |
| | | }else if(integer>i) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,integer-i); |
| | | Date time1 = instance.getTime(); |
| | | List<Date> list = new ArrayList<>(); |
| | | list.add(time1); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time2 = instance.getTime(); |
| | | list.add(time2); |
| | | for (Date time : list) { |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.insert(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(student.getAppUserId()); |
| | | student1.setStudentId(student.getId()); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(holi.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | studentService.save(student1); |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time = instance.getTime(); |
| | | |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.insert(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(student.getAppUserId()); |
| | | student1.setStudentId(student.getId()); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(holi.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | studentService.save(student1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | String[] stringArray = strings.toArray(new String[strings.size()]); |
| | | |
| | | String join = StringUtils.join(stringArray, ","); |
| | | System.out.println("==========join========"+join); |
| | | return "转课成功"; |
| | | } |
| | | |
| | | |
| | | |
| | | } |