| | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | 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.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.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api |
| | | @CrossOrigin |
| | |
| | | |
| | | // 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; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | //根据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") |
| | | ); |
| | | 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; |
| | | } |
| | | |
| | | @Autowired |
| | | private CourseCounsumService counsumService; |
| | | @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); |
| | | |
| | | } |
| | | |
| | | |
| | | @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("/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){ |
| | | o.setTotalClassHours(0); |
| | | o.setLaveClassHours(0); |
| | | 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(2); |
| | | 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.setAppUserId(null); |
| | | paymentService.updateById(orinPay); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | 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 { |
| | | |
| | | |
| | | |
| | | orinPay.setTotalClassHours(0); |
| | | orinPay.setLaveClassHours(0); |
| | | orinPay.setAppUserId(null); |
| | | 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); |
| | | |
| | | |
| | | |
| | | 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); |
| | | |
| | | |
| | | 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){ |
| | | |
| | | 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); |
| | | |
| | | 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()); |
| | | paymentService.save(holi); |
| | | |
| | | System.out.println("保存成功=============》="+holi); |
| | | |
| | | |
| | | |
| | | } |
| | | String[] stringArray = strings.toArray(new String[strings.size()]); |
| | | |
| | | String join = StringUtils.join(stringArray, ","); |
| | | System.out.println("==========join========"+join); |
| | | return join; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/toTrans",produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = "application/json;charset=UTF-8") |
| | | @ResponseBody |
| | | public String toTrans(@RequestBody ToHoliDto toHoliDto){ |
| | | |
| | | 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()); |
| | | paymentService.save(holi); |
| | | |
| | | System.out.println("保存成功=============》="+holi); |
| | | |
| | | |
| | | |
| | | } |
| | | String[] stringArray = strings.toArray(new String[strings.size()]); |
| | | |
| | | String join = StringUtils.join(stringArray, ","); |
| | | System.out.println("==========join========"+join); |
| | | return "转课成功"; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |