|  |  |  | 
|---|
|  |  |  | package com.dsh.course.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.dsh.course.entity.TCoursePackage; | 
|---|
|  |  |  | import com.dsh.course.entity.TCoursePackagePayment; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.dsh.course.entity.*; | 
|---|
|  |  |  | import com.dsh.course.entity.TAppUser; | 
|---|
|  |  |  | import com.dsh.course.feignclient.account.AppUserClient; | 
|---|
|  |  |  | import com.dsh.course.feignclient.account.StudentClient; | 
|---|
|  |  |  | import com.dsh.course.feignclient.account.model.AppUser; | 
|---|
|  |  |  | import com.dsh.course.feignclient.account.model.Student; | 
|---|
|  |  |  | import com.dsh.course.feignclient.account.model.TCourseInfoRecord; | 
|---|
|  |  |  | import com.dsh.course.feignclient.account.model.TStudent; | 
|---|
|  |  |  | import com.dsh.course.feignclient.activity.CouponClient; | 
|---|
|  |  |  | import com.dsh.course.feignclient.activity.model.Coupon; | 
|---|
|  |  |  | import com.dsh.course.feignclient.model.*; | 
|---|
|  |  |  | import com.dsh.course.service.TCoursePackagePaymentService; | 
|---|
|  |  |  | import com.dsh.course.service.TCoursePackageService; | 
|---|
|  |  |  | import com.dsh.course.util.DateUtil; | 
|---|
|  |  |  | import com.dsh.course.feignclient.other.StoreClient; | 
|---|
|  |  |  | import com.dsh.course.feignclient.other.model.Store; | 
|---|
|  |  |  | import com.dsh.course.mapper.CoursePackageSchedulingMapper; | 
|---|
|  |  |  | import com.dsh.course.model.*; | 
|---|
|  |  |  | import com.dsh.course.model.dto.DiscountJsonDto; | 
|---|
|  |  |  | import com.dsh.course.model.vo.CourseDetailRequest; | 
|---|
|  |  |  | import com.dsh.course.model.vo.RegisterCourseVo; | 
|---|
|  |  |  | import com.dsh.course.model.vo.request.*; | 
|---|
|  |  |  | import com.dsh.course.model.vo.response.*; | 
|---|
|  |  |  | import com.dsh.course.service.*; | 
|---|
|  |  |  | import com.dsh.course.util.*; | 
|---|
|  |  |  | import com.fasterxml.jackson.core.JsonProcessingException; | 
|---|
|  |  |  | import com.fasterxml.jackson.databind.ObjectMapper; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import net.bytebuddy.asm.Advice; | 
|---|
|  |  |  | import org.aspectj.weaver.ast.Var; | 
|---|
|  |  |  | import io.swagger.models.auth.In; | 
|---|
|  |  |  | import org.slf4j.Logger; | 
|---|
|  |  |  | import org.slf4j.LoggerFactory; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.http.HttpHeaders; | 
|---|
|  |  |  | import org.springframework.http.MediaType; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import org.springframework.web.client.RestTemplate; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.io.PrintWriter; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.text.ParseException; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.time.*; | 
|---|
|  |  |  | import java.time.temporal.ChronoUnit; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Api | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TCoursePackageService tcpService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TCoursePackageDiscountService tcpdService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ICoursePackagePaymentConfigService icppcService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserVideoDetailsService uvdsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TCourseService tcService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private StudentClient studentClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TCoursePackageTypeService coursePackageTypeService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TokenUtil tokenUtil; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CancelledClassesService cancelledClassesService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private CoursePackageStudentService cspsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PayMoneyUtil payMoneyUtil; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private AppUserClient auClitn; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private StoreClient sreClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private AppUserClient appUserClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RestTemplate internalRestTemplate; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CouponClient couponClient; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private StoreClient storeClient; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TCoursePackageDiscountService discountService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private CoursePackageSchedulingMapper coursePackageSchedulingMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ICoursePackageSchedulingService coursePackageSchedulingService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CoursePackageStudentService coursePackageStudentService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 添加购课记录-后台 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/base/coursePackagePayment/add") | 
|---|
|  |  |  | public Object addCoursePackagePayment(@RequestBody TCoursePackagePayment packagePayment){ | 
|---|
|  |  |  | packagePayment.setInsertTime(new Date()); | 
|---|
|  |  |  | packagePayment.setInsertTime(new Date()); | 
|---|
|  |  |  | Integer studentId = packagePayment.getStudentId(); | 
|---|
|  |  |  | // 添加学员上课记录 | 
|---|
|  |  |  | CoursePackageStudent coursePackageStudent = new CoursePackageStudent(); | 
|---|
|  |  |  | TCoursePackagePayment one = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", packagePayment.getStudentId()) | 
|---|
|  |  |  | .orderByDesc("insertTime") | 
|---|
|  |  |  | .last("LIMIT 1")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (one!=null){ | 
|---|
|  |  |  | Integer totalClassHours = one.getTotalClassHours(); | 
|---|
|  |  |  | Integer absencesNumber = one.getAbsencesNumber(); | 
|---|
|  |  |  | // 没有过期 | 
|---|
|  |  |  | if (one.getUseTime().after(new Date())){ | 
|---|
|  |  |  | if (one.getLaveClassHours()-packagePayment.getClassHours()<0){ | 
|---|
|  |  |  | return 5002; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | packagePayment.setTotalClassHours(one.getTotalClassHours()); | 
|---|
|  |  |  | packagePayment.setLaveClassHours(one.getLaveClassHours()-packagePayment.getClassHours()); | 
|---|
|  |  |  | packagePayment.setAbsencesNumber(one.getAbsencesNumber()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | packagePayment.setTotalClassHours(packagePayment.getClassHours()); | 
|---|
|  |  |  | packagePayment.setLaveClassHours(packagePayment.getClassHours()); | 
|---|
|  |  |  | packagePayment.setAbsencesNumber(one.getAbsencesNumber()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | packagePayment.setTotalClassHours(packagePayment.getClassHours()); | 
|---|
|  |  |  | packagePayment.setLaveClassHours(packagePayment.getClassHours()); | 
|---|
|  |  |  | packagePayment.setAbsencesNumber(0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 生成排课数据 | 
|---|
|  |  |  | TCoursePackage coursePackage = tcpService.getById(packagePayment.getCoursePackageId()); | 
|---|
|  |  |  | //生成排课数据 | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | 
|---|
|  |  |  | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
|---|
|  |  |  | Date date = sdf1.parse(sdf.format(new Date()) + " 00:00:00"); | 
|---|
|  |  |  | List<String> list = Arrays.asList(coursePackage.getClassWeeks().split(";")); | 
|---|
|  |  |  | String value = coursePackage.getClassStartTime(); | 
|---|
|  |  |  | String value1 = coursePackage.getClassEndTime(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String[] star = value.split(","); | 
|---|
|  |  |  | 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(":"); | 
|---|
|  |  |  | //            String value1 = en; | 
|---|
|  |  |  | int index1 = value1.indexOf(","); | 
|---|
|  |  |  | //                String result1 = value.substring(0, index1).trim(); | 
|---|
|  |  |  | String classEndTime = end[i]; | 
|---|
|  |  |  | String[] split1 = classEndTime.split(":"); | 
|---|
|  |  |  | Calendar s = Calendar.getInstance(); | 
|---|
|  |  |  | s.setTime(date); | 
|---|
|  |  |  | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); | 
|---|
|  |  |  | s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); | 
|---|
|  |  |  | s.set(Calendar.MINUTE, Integer.valueOf(split[1])); | 
|---|
|  |  |  | s.set(Calendar.SECOND, 0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Calendar e = Calendar.getInstance(); | 
|---|
|  |  |  | e.setTime(date); | 
|---|
|  |  |  | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 14); | 
|---|
|  |  |  | long timeInMillis = e.getTimeInMillis(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | while (true){ | 
|---|
|  |  |  | int w = s.get(Calendar.DAY_OF_WEEK); | 
|---|
|  |  |  | WeekEnum weekEnum = WeekEnum.getWeekEnum(w); | 
|---|
|  |  |  | if(list.contains(weekEnum.getChineseName())){ | 
|---|
|  |  |  | Calendar classDate = Calendar.getInstance(); | 
|---|
|  |  |  | classDate.setTime(s.getTime()); | 
|---|
|  |  |  | classDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); | 
|---|
|  |  |  | classDate.set(Calendar.MINUTE, Integer.valueOf(split[1])); | 
|---|
|  |  |  | classDate.set(Calendar.SECOND, 0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Calendar endDate = Calendar.getInstance(); | 
|---|
|  |  |  | endDate.setTime(s.getTime()); | 
|---|
|  |  |  | endDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split1[0])); | 
|---|
|  |  |  | endDate.set(Calendar.MINUTE, Integer.valueOf(split1[1])); | 
|---|
|  |  |  | endDate.set(Calendar.SECOND, 0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); | 
|---|
|  |  |  | coursePackageScheduling.setCoursePackageId(coursePackage.getId()); | 
|---|
|  |  |  | coursePackageScheduling.setClassDate(classDate.getTime()); | 
|---|
|  |  |  | coursePackageScheduling.setEndDate(endDate.getTime()); | 
|---|
|  |  |  | coursePackageScheduling.setStatus(1); | 
|---|
|  |  |  | coursePackageSchedulingService.save(coursePackageScheduling); | 
|---|
|  |  |  | coursePackageStudent.setCoursePackageSchedulingId(coursePackageScheduling.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CoursePackageScheduling> list1 = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>() | 
|---|
|  |  |  | .eq("coursePackageId", coursePackage.getId()) | 
|---|
|  |  |  | .eq("classDate", classDate.getTime()) | 
|---|
|  |  |  | .eq("endDate", endDate.getTime())); | 
|---|
|  |  |  | if (list1.size()+1>coursePackage.getMaxSubscribeNumber()){ | 
|---|
|  |  |  | // 当前课包预约人数已满 | 
|---|
|  |  |  | return 5001; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); | 
|---|
|  |  |  | if(s.getTimeInMillis() > timeInMillis){ | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (ParseException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | coursePackageStudent.setStudentId(packagePayment.getStudentId()); | 
|---|
|  |  |  | coursePackageStudent.setCoursePackageId(packagePayment.getCoursePackageId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | coursePackageStudent.setSignInOrNot(0); | 
|---|
|  |  |  | coursePackageStudent.setReservationStatus(1); | 
|---|
|  |  |  | coursePackageStudent.setInsertTime(new Date()); | 
|---|
|  |  |  | coursePackageStudent.setAppUserId(packagePayment.getAppUserId()); | 
|---|
|  |  |  | packagePaymentService.save(packagePayment); | 
|---|
|  |  |  | coursePackageStudent.setCoursePackagePaymentId(packagePayment.getId()); | 
|---|
|  |  |  | return coursePackageStudentService.save(coursePackageStudent); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 手动支付 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/base/coursePackagePayment/changeState") | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取购课记录 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @RequestMapping("/coursePackagePayment/listAll") | 
|---|
|  |  |  | public List<CoursePackagePaymentVO> listAll(@RequestBody CoursePackagePaymentQuery query){ | 
|---|
|  |  |  | List<CoursePackagePaymentVO> res = packagePaymentService.listAll(query); | 
|---|
|  |  |  | List<CoursePackagePaymentVO> result = new ArrayList<>(); | 
|---|
|  |  |  | for (CoursePackagePaymentVO re : res) { | 
|---|
|  |  |  | if (re.getCashPayment()==null){ | 
|---|
|  |  |  | if (re.getPlayPaiCoin()!=null){ | 
|---|
|  |  |  | String value = String.valueOf(re.getPlayPaiCoin()); | 
|---|
|  |  |  | re.setCashPayment(new BigDecimal(value)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Store store = storeClient.queryStoreById(re.getStoreId()); | 
|---|
|  |  |  | TAppUser appUser = appUserClient.queryAppUser1(re.getAppUserId()); | 
|---|
|  |  |  | Student student = studentClient.queryStudentById(re.getStudentId()); | 
|---|
|  |  |  | re.setPayStudent(student.getName()); | 
|---|
|  |  |  | re.setPayUser(appUser.getName()); | 
|---|
|  |  |  | re.setPhone(appUser.getPhone()); | 
|---|
|  |  |  | re.setStoreName(store.getName()); | 
|---|
|  |  |  | if (query.getPayUser()== null || query.getPayUser().equals("") ){ | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | List<AppUser> appUsers = appUserClient.queryAppUserListByName(query.getPayUser()); | 
|---|
|  |  |  | for (AppUser user : appUsers) { | 
|---|
|  |  |  | if (appUser.getName().equals(user.getName())){ | 
|---|
|  |  |  | if (query.getPayStudent()== null || query.getPayStudent().equals("")){ | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | List<Student> students = studentClient.queryStudentListByName(query.getPayStudent()); | 
|---|
|  |  |  | for (Student student1 : students) { | 
|---|
|  |  |  | if (student.getName().equals(student1.getName())){ | 
|---|
|  |  |  | result.add(re); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (re.getPayType()!=null){ | 
|---|
|  |  |  | if (re.getPayType()==1){ | 
|---|
|  |  |  | re.setBuyTypeName("微信支付"); | 
|---|
|  |  |  | }else if(re.getPayType()==2){ | 
|---|
|  |  |  | re.setBuyTypeName("支付宝支付"); | 
|---|
|  |  |  | }else if(re.getPayType()==3){ | 
|---|
|  |  |  | re.setBuyTypeName("玩湃币支付"); | 
|---|
|  |  |  | }else if(re.getPayType()==4){ | 
|---|
|  |  |  | re.setBuyTypeName("积分支付"); | 
|---|
|  |  |  | }else if(re.getPayType()==5){ | 
|---|
|  |  |  | re.setBuyTypeName("积分+微信支付"); | 
|---|
|  |  |  | }else if(re.getPayType()==6){ | 
|---|
|  |  |  | re.setBuyTypeName("积分+支付宝支付"); | 
|---|
|  |  |  | }else if(re.getPayType()==7){ | 
|---|
|  |  |  | re.setBuyTypeName("手动支付"+"-"+re.getBuyTypeName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BigDecimal subtract = re.getOriginalPrice().subtract(re.getCashPayment()); | 
|---|
|  |  |  | re.setDiscountAmount(subtract); | 
|---|
|  |  |  | // 如果支付用户类型为管理员 则购买方式则为1线下购买 | 
|---|
|  |  |  | if (re.getPayUserType()!=null){ | 
|---|
|  |  |  | if (re.getPayUserType()== 2){ | 
|---|
|  |  |  | re.setBuyType(1); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | // 如果当前课包有折扣 则为3折扣购买 | 
|---|
|  |  |  | if (discountService.list(new QueryWrapper<TCoursePackageDiscount>() | 
|---|
|  |  |  | .eq("coursePackageId",re.getCoursePackageId()).eq("auditStatus",2)).size()>0){ | 
|---|
|  |  |  | re.setBuyType(3); | 
|---|
|  |  |  | re.setDiscountAmount(re.getOriginalPrice().subtract(re.getPayMoney())); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | re.setBuyType(2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (query.getPayStudent()== null || query.getPayStudent().equals("")){ | 
|---|
|  |  |  | if (query.getPayUser()== null || query.getPayUser().equals("")){ | 
|---|
|  |  |  | return res; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取报名订单记录列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @RequestMapping("/registerOrder/listAllRegister") | 
|---|
|  |  |  | public List<RegisterOrderVO> listAllRegister(@RequestBody RegisterOrderQuery query){ | 
|---|
|  |  |  | if (query.getStudentName()!=null){ | 
|---|
|  |  |  | if (!query.getStudentName().equals("")){ | 
|---|
|  |  |  | List<TStudent> students1 = studentClient.queryTStudentListByName(query.getStudentName()); | 
|---|
|  |  |  | List<Integer> studentIds = students1.stream().map(TStudent::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | query.setStudentIds(studentIds); | 
|---|
|  |  |  | if (students1.size()==0){ | 
|---|
|  |  |  | return new ArrayList<>(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<RegisterOrderVO> res = packagePaymentService.listAllRegister(query); | 
|---|
|  |  |  | // 该运营商下没有门店 | 
|---|
|  |  |  | if (query.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<>(); | 
|---|
|  |  |  | 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.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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return res; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取 没有学员信息的图片配置 | 
|---|
|  |  |  | * @param stuId 学员id | 
|---|
|  |  |  | * @return  课包列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/coursePack/queryPayment") | 
|---|
|  |  |  | public List<StuCourseResp> getStuCoursePackagePayment(@RequestBody Integer stuId,@RequestBody Integer appUserId){ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/base/coursePack/queryPayment") | 
|---|
|  |  |  | public List<StuCourseResp> getStuCoursePackagePayment(@RequestBody Integer stuId){ | 
|---|
|  |  |  | List<StuCourseResp> resps = new ArrayList<>(); | 
|---|
|  |  |  | List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(null,null,stuId,appUserId); | 
|---|
|  |  |  | Student student = studentClient.queryStudentById(stuId); | 
|---|
|  |  |  | List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("appUserId",student.getAppUserId()) | 
|---|
|  |  |  | .eq("studentId",stuId)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.setCourseName(tCoursePackage.getName()); | 
|---|
|  |  |  | resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours()); | 
|---|
|  |  |  | resp.setResidueNums(tCoursePackagePayment.getLaveClassHours()); | 
|---|
|  |  |  | resp.setDeductionNums(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours()); | 
|---|
|  |  |  | if (tCoursePackage.getValidDays()!=null){ | 
|---|
|  |  |  | String afterDayDate = DateUtil.getAfterDayDate2(tCoursePackage.getInsertTime(),tCoursePackage.getValidDays() + ""); | 
|---|
|  |  |  | resp.setPeriodOfValidity(afterDayDate); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | resps.add(resp); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * 获取发布的 课包列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/coursePack/storeOfCourse") | 
|---|
|  |  |  | public List<CourseOfStoreVo> getStuCourseWithStores(){ | 
|---|
|  |  |  | List<CourseOfStoreVo> courseOfStoreVos = tcpService.queryStoreOfCourse(); | 
|---|
|  |  |  | if (courseOfStoreVos.size() > 0){ | 
|---|
|  |  |  | for (CourseOfStoreVo courseOfStoreVo : courseOfStoreVos) { | 
|---|
|  |  |  | String[] split = courseOfStoreVo.getClassWeeks().split(";"); | 
|---|
|  |  |  | List<Integer> integers = new ArrayList<>(); | 
|---|
|  |  |  | for (String s : split) { | 
|---|
|  |  |  | int num = Integer.parseInt(s); | 
|---|
|  |  |  | integers.add(num); | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/base/coursePack/storeOfCourse") | 
|---|
|  |  |  | public List<CourseOfStoreVo> getStuCourseWithStores(@RequestBody WeeksOfCourseRest courseRest){ | 
|---|
|  |  |  | List<CourseOfStoreVo> course = new ArrayList<>(); | 
|---|
|  |  |  | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Date parse = simpleDateFormat.parse(courseRest.getTime()); | 
|---|
|  |  |  | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("appUserId",courseRest.getAppUserId() ) | 
|---|
|  |  |  | .eq("studentId",courseRest.getStuId()) | 
|---|
|  |  |  | .eq("payStatus",2) | 
|---|
|  |  |  | .eq("status",1) | 
|---|
|  |  |  | .eq("state",1) | 
|---|
|  |  |  | .groupBy("coursePackageId")); | 
|---|
|  |  |  | if (list.size() >  0){ | 
|---|
|  |  |  | for (TCoursePackagePayment tCoursePackagePayment : list) { | 
|---|
|  |  |  | List<CoursePackageStudent> packageStudent = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>() | 
|---|
|  |  |  | .eq(CoursePackageStudent::getAppUserId, courseRest.getAppUserId()) | 
|---|
|  |  |  | .eq(CoursePackageStudent::getStudentId,courseRest.getStuId()) | 
|---|
|  |  |  | .eq(CoursePackageStudent::getCoursePackagePaymentId,tCoursePackagePayment.getId()) | 
|---|
|  |  |  | .eq(CoursePackageStudent::getCoursePackageId,tCoursePackagePayment.getCoursePackageId())); | 
|---|
|  |  |  | if (ToolUtil.isEmpty(packageStudent) || (ToolUtil.isNotEmpty(packageStudent) && packageStudent.get(0).getReservationStatus() == 1)){ | 
|---|
|  |  |  | //                        没有预约过的/已经取消了的 | 
|---|
|  |  |  | TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId()); | 
|---|
|  |  |  | CoursePackagePaymentConfig paymentConfig = icppcService.getOne(new QueryWrapper<CoursePackagePaymentConfig>() | 
|---|
|  |  |  | .eq("coursePackageId",tCoursePackage.getId() ) | 
|---|
|  |  |  | .eq("classHours",tCoursePackagePayment.getClassHours())); | 
|---|
|  |  |  | //                    获取课程有效结束时间,判断 查询的日期parse 是否在有效期范围内 | 
|---|
|  |  |  | Date expirationDate = DateTimeHelper.getExpirationDate(tCoursePackagePayment.getInsertTime(),tCoursePackage.getValidDays()); | 
|---|
|  |  |  | System.out.println(expirationDate.after(parse)); | 
|---|
|  |  |  | String classWeeks = tCoursePackage.getClassWeeks(); | 
|---|
|  |  |  | System.out.println(StrUtils.dealStrToList(classWeeks).contains(DateTimeHelper.getDayOfWeek(parse))); | 
|---|
|  |  |  | if (expirationDate.after(parse) && StrUtils.dealStrToList(classWeeks).contains(DateTimeHelper.getDayOfWeek(parse))){ | 
|---|
|  |  |  | CourseOfStoreVo storeVo = new CourseOfStoreVo(); | 
|---|
|  |  |  | storeVo.setCourseId(tCoursePackagePayment.getId()); | 
|---|
|  |  |  | storeVo.setCourseName(tCoursePackage.getName()); | 
|---|
|  |  |  | storeVo.setClassStartTime(tCoursePackage.getClassStartTime()); | 
|---|
|  |  |  | storeVo.setClassEndTime(tCoursePackage.getClassEndTime()); | 
|---|
|  |  |  | storeVo.setStoreId(tCoursePackage.getStoreId()); | 
|---|
|  |  |  | Store store = sreClient.queryStoreById(tCoursePackage.getStoreId()); | 
|---|
|  |  |  | storeVo.setStoreAddress(store.getAddress()); | 
|---|
|  |  |  | storeVo.setLat(store.getLat()); | 
|---|
|  |  |  | storeVo.setLon(store.getLon()); | 
|---|
|  |  |  | storeVo.setCoursePrice(ToolUtil.isEmpty(paymentConfig.getCashPayment()) ? (double) paymentConfig.getPlayPaiCoin():paymentConfig.getCashPayment()); | 
|---|
|  |  |  | storeVo.setStatus(1); | 
|---|
|  |  |  | // 2.0 | 
|---|
|  |  |  | storeVo.setAllNum(tCoursePackagePayment.getTotalClassHours()); | 
|---|
|  |  |  | storeVo.setLastNum(tCoursePackagePayment.getLaveClassHours()); | 
|---|
|  |  |  | storeVo.setUseNum(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | course.add(storeVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | courseOfStoreVo.setClassWeekList(integers); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | System.out.println(course); | 
|---|
|  |  |  | return course; | 
|---|
|  |  |  | } catch (ParseException e) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return tcpService.queryStoreOfCourse(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * 课程名称列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/coursePack/sessionNames") | 
|---|
|  |  |  | public List<StuSessionDetailsVo> getStuSessionList(@RequestBody Date startTime, @RequestBody Date  endTime, @RequestBody Integer stuId, @RequestBody Integer appUserId){ | 
|---|
|  |  |  | @PostMapping("/base/coursePack/sessionNames") | 
|---|
|  |  |  | public List<StuSessionDetailsVo> getStuSessionList(@RequestBody CourseDetailRequest request){ | 
|---|
|  |  |  | List<StuSessionDetailsVo> detailsVos = new ArrayList<>(); | 
|---|
|  |  |  | List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(startTime,endTime,stuId,appUserId); | 
|---|
|  |  |  | List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .between("insertTime", request.getStartTime(),request.getEndTime()) | 
|---|
|  |  |  | .eq("appUserId",request.getAppUserId()) | 
|---|
|  |  |  | .eq("studentId",request.getStuId())); | 
|---|
|  |  |  | if (byUserId.size() > 0){ | 
|---|
|  |  |  | List<Integer> collect = byUserId.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); | 
|---|
|  |  |  | List<TCoursePackage> list = tcpService.list(new QueryWrapper<TCoursePackage>() | 
|---|
|  |  |  | 
|---|
|  |  |  | return detailsVos; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/coursePack/paymentCourse") | 
|---|
|  |  |  | public List<PurchaseRecordVo> queryCourseDetails(@RequestBody Date startTime, @RequestBody Date  endTime,@RequestBody Integer stuId, @RequestBody Integer appUserId) { | 
|---|
|  |  |  | @PostMapping("/base/coursePack/paymentCourse") | 
|---|
|  |  |  | public List<PurchaseRecordVo> queryCourseDetails(@RequestBody GetStuSessionList sessionList) { | 
|---|
|  |  |  | List<PurchaseRecordVo> purchaseRecordVos = new ArrayList<>(); | 
|---|
|  |  |  | List<TCoursePackagePayment> coursePackage = packagePaymentService.queryAllCoursePackage(startTime,endTime,stuId, appUserId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<TCoursePackagePayment> coursePackage = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .between("insertTime", sessionList.getStartTime(),sessionList.getEndTime()) | 
|---|
|  |  |  | .eq("appUserId",sessionList.getAppUserId()) | 
|---|
|  |  |  | .eq("studentId",sessionList.getStuId())); | 
|---|
|  |  |  | if (coursePackage.size() > 0 ){ | 
|---|
|  |  |  | coursePackage.forEach( cspackage -> { | 
|---|
|  |  |  | PurchaseRecordVo recordVo = new PurchaseRecordVo(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/coursePack/stuOfCourses") | 
|---|
|  |  |  | public StuWithCoursesListVo getStuOfCoursesDetails(@RequestBody Integer stuId, @RequestBody Integer appUserId){ | 
|---|
|  |  |  | @PostMapping("/base/coursePack/stuOfCourses") | 
|---|
|  |  |  | public StuWithCoursesListVo getStuOfCoursesDetails(@RequestBody GetStuOfCoursesDetails getStuOfCoursesDetails){ | 
|---|
|  |  |  | StuWithCoursesListVo lisco = new StuWithCoursesListVo(); | 
|---|
|  |  |  | Integer totalNu = 0; | 
|---|
|  |  |  | Integer dedutNu = 0; | 
|---|
|  |  |  | Integer remainNu = 0; | 
|---|
|  |  |  | List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(null,null,stuId,appUserId); | 
|---|
|  |  |  | List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("appUserId",getStuOfCoursesDetails.getAppUserId()) | 
|---|
|  |  |  | .eq("studentId",getStuOfCoursesDetails.getStuId())); | 
|---|
|  |  |  | if (byUserId.size() > 0 ){ | 
|---|
|  |  |  | for (TCoursePackagePayment tCoursePackagePayment : byUserId) { | 
|---|
|  |  |  | StuWithCoursesListVo resp = new StuWithCoursesListVo(); | 
|---|
|  |  |  | totalNu = totalNu + tCoursePackagePayment.getTotalClassHours(); | 
|---|
|  |  |  | dedutNu = dedutNu + tCoursePackagePayment.getLaveClassHours(); | 
|---|
|  |  |  | remainNu = remainNu + (tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours()); | 
|---|
|  |  |  | 
|---|
|  |  |  | return lisco; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/continuingCourse") | 
|---|
|  |  |  | public StudentOfCourseVo getStudentCourse(@RequestBody GetStudentCourse getStudentCourse){ | 
|---|
|  |  |  | StudentOfCourseVo courseVo = new StudentOfCourseVo(); | 
|---|
|  |  |  | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("appUserId", getStudentCourse.getAppUserId()) | 
|---|
|  |  |  | .eq("coursePackageId", getStudentCourse.getCourseId()) | 
|---|
|  |  |  | .eq("studentId", getStudentCourse.getStuId())); | 
|---|
|  |  |  | if (tCoursePackagePayments.size() > 0 ){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CourseHoursType> typeList = new ArrayList<>(); | 
|---|
|  |  |  | tCoursePackagePayments.forEach(cou -> { | 
|---|
|  |  |  | CourseHoursType hoursType = new CourseHoursType(); | 
|---|
|  |  |  | hoursType.setCourseConfigId(cou.getId()); | 
|---|
|  |  |  | hoursType.setCourseHourNums(cou.getClassHours()); | 
|---|
|  |  |  | typeList.add(hoursType); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | TCoursePackagePayment tCoursePackagePayment = tCoursePackagePayments.get(0); | 
|---|
|  |  |  | courseVo.setCoursePackageId(tCoursePackagePayment.getCoursePackageId()); | 
|---|
|  |  |  | courseVo.setTypeList(typeList); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TCoursePackage coursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId()); | 
|---|
|  |  |  | courseVo.setPackageImg(coursePackage.getCoverDrawing()); | 
|---|
|  |  |  | courseVo.setCourseName(coursePackage.getName()); | 
|---|
|  |  |  | courseVo.setCoachId(coursePackage.getCoachId()); | 
|---|
|  |  |  | String classWeeks = coursePackage.getClassWeeks(); | 
|---|
|  |  |  | List<Integer> integers = StrUtils.dealStrToList(classWeeks); | 
|---|
|  |  |  | if (integers.size() > 0){ | 
|---|
|  |  |  | StringBuilder courWeeks = new StringBuilder("每"); | 
|---|
|  |  |  | for (Integer integer : integers) { | 
|---|
|  |  |  | courWeeks.append(integer).append("、"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (courWeeks.length() > 0 && courWeeks.charAt(courWeeks.length() - 1) == '、'){ | 
|---|
|  |  |  | courWeeks.deleteCharAt(courWeeks.length() - 1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | courseVo.setCourseWeek(courWeeks.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | courseVo.setCourseTime(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); | 
|---|
|  |  |  | Integer payType = tCoursePackagePayment.getPayType(); | 
|---|
|  |  |  | BigDecimal cashPayment = tCoursePackagePayment.getCashPayment(); | 
|---|
|  |  |  | double cashPaymentValue = cashPayment.doubleValue(); | 
|---|
|  |  |  | Integer playPaiCoin = tCoursePackagePayment.getPlayPaiCoin(); | 
|---|
|  |  |  | TCoursePackageDiscount coursePackageDiscount = tcpdService.getOne(new QueryWrapper<TCoursePackageDiscount>() | 
|---|
|  |  |  | .eq("coursePackageId",coursePackage.getId() ) | 
|---|
|  |  |  | .eq("type",1) | 
|---|
|  |  |  | .eq("auditStatus",2)); | 
|---|
|  |  |  | ObjectMapper objectMapper = new ObjectMapper(); | 
|---|
|  |  |  | String content = coursePackageDiscount.getContent(); | 
|---|
|  |  |  | double discountMember = 0.0; | 
|---|
|  |  |  | DiscountJsonDto discountJsonDto = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | discountJsonDto = objectMapper.readValue(content, DiscountJsonDto.class); | 
|---|
|  |  |  | discountMember = discountJsonDto.getDiscountMember(); | 
|---|
|  |  |  | } catch (JsonProcessingException e) { | 
|---|
|  |  |  | throw new RuntimeException(e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | switch (payType) { | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | courseVo.setAmount(cashPaymentValue); | 
|---|
|  |  |  | courseVo.setVipAmount(discountMember); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | courseVo.setWpGold(playPaiCoin); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | courseVo.setStoreId(coursePackage.getStoreId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return courseVo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/afterCourseTwos") | 
|---|
|  |  |  | public List<AfterVideoVo> getAfterCourseTwos(@RequestParam("appUserId") Integer appUserId){ | 
|---|
|  |  |  | List<AfterVideoVo> videoVos = new ArrayList<>(); | 
|---|
|  |  |  | List<UserVideoDetails> list = uvdsService.list(new QueryWrapper<UserVideoDetails>() | 
|---|
|  |  |  | .eq("appUserId",appUserId) | 
|---|
|  |  |  | .eq("state",1)); | 
|---|
|  |  |  | if (list.size() > 0 ){ | 
|---|
|  |  |  | List<Integer> courseIds = list.stream().map(UserVideoDetails::getCourseId).collect(Collectors.toList()); | 
|---|
|  |  |  | List<TCourse> courseList = tcService.list(new QueryWrapper<TCourse>() | 
|---|
|  |  |  | .in("id",courseIds) | 
|---|
|  |  |  | .eq("type",1) | 
|---|
|  |  |  | .eq("state",1) | 
|---|
|  |  |  | .last("ORDER BY insertTime desc LIMIT 2")); | 
|---|
|  |  |  | for (TCourse tCourse : courseList) { | 
|---|
|  |  |  | AfterVideoVo videoVo = new AfterVideoVo(); | 
|---|
|  |  |  | videoVo.setCourseId(tCourse.getId()); | 
|---|
|  |  |  | videoVo.setCourseUrl(tCourse.getCourseVideo()); | 
|---|
|  |  |  | videoVos.add(videoVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return videoVos; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/allPaymentCourseList") | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | public List<CouponPaymentVo> getAppuserCourseList(@RequestBody Integer appUserId){ | 
|---|
|  |  |  | List<CouponPaymentVo> paymentVos = new ArrayList<>(); | 
|---|
|  |  |  | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm"); | 
|---|
|  |  |  | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("appUserId", appUserId) | 
|---|
|  |  |  | .eq("payType", 3) | 
|---|
|  |  |  | .eq("payStatus", 2) | 
|---|
|  |  |  | .eq("state", 1)); | 
|---|
|  |  |  | if (list.size() > 0 ){ | 
|---|
|  |  |  | for (TCoursePackagePayment tCoursePackagePayment : list) { | 
|---|
|  |  |  | CouponPaymentVo couponPaymentVo = new CouponPaymentVo(); | 
|---|
|  |  |  | couponPaymentVo.setTime(simpleDateFormat.format(tCoursePackagePayment.getInsertTime())); | 
|---|
|  |  |  | couponPaymentVo.setAmount( tCoursePackagePayment.getPlayPaiCoin()); | 
|---|
|  |  |  | paymentVos.add(couponPaymentVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return paymentVos; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/base/coursePack/allAmountPayRecordOfUser") | 
|---|
|  |  |  | public BillingRequestVo getAmountPayRecord(@RequestBody BillingDataRequestVo billingDataRequestVo){ | 
|---|
|  |  |  | BillingRequestVo requestVo = new BillingRequestVo(); | 
|---|
|  |  |  | List<BillingRequest> billingRequests = packagePaymentService.queryAmountDatas(billingDataRequestVo.getAppUserId(), billingDataRequestVo.getMonthStart(), billingDataRequestVo.getMonthEnd()); | 
|---|
|  |  |  | if (billingRequests.size() >0){ | 
|---|
|  |  |  | requestVo.setRequests(billingRequests); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return requestVo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/course/queryArrangeCourseList") | 
|---|
|  |  |  | @ApiOperation(value = "课后练习-获取布置课程列表", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil<List<BaseVo>> queryArrangePackageType(){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer appUserId = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == appUserId){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("appUserId",appUserId)); | 
|---|
|  |  |  | List<BaseVo> list = new ArrayList<>(); | 
|---|
|  |  |  | tCoursePackagePayments.forEach(c -> { | 
|---|
|  |  |  | BaseVo baseVo = new BaseVo(); | 
|---|
|  |  |  | baseVo.setId(c.getCoursePackageId()); | 
|---|
|  |  |  | TCoursePackage coursePackage = tcpService.getById(c.getCoursePackageId()); | 
|---|
|  |  |  | baseVo.setName(coursePackage.getName()); | 
|---|
|  |  |  | list.add(baseVo); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | return ResultUtil.success(list); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 课后视频课表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/afterSourceList") | 
|---|
|  |  |  | @ApiOperation(value = "课后练习-课后视频列表", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | 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"); | 
|---|
|  |  |  | //            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("appUserId", appUserId); | 
|---|
|  |  |  | if (ToolUtil.isNotEmpty(search.getCourseTypeId())){ | 
|---|
|  |  |  | queryWrapper1.eq("coursePackageId",search.getCourseTypeId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CoursePackageStudent> list = coursePackageStudentService.list(queryWrapper1); | 
|---|
|  |  |  | List<Long> longs = new ArrayList<>(); | 
|---|
|  |  |  | for (CoursePackageStudent coursePackageStudent : list) { | 
|---|
|  |  |  | longs.add(coursePackageStudent.getCoursePackageSchedulingId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | System.out.println("======longs========"+longs); | 
|---|
|  |  |  | List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id",longs).isNotNull("courseId")); | 
|---|
|  |  |  | List<AppUserVideoResponse> coursePackageSchedulings1 = coursePackageSchedulingService.queryAll(longs); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ResultUtil.success(coursePackageSchedulings1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        }catch (Exception e){ | 
|---|
|  |  |  | //            return ResultUtil.runErr(); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 课后视频详情 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/afterSourceDetail") | 
|---|
|  |  |  | @ApiOperation(value = "课后练习-课后视频详情", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil<CourseOfVideoResponse> queryAfterSourceDetails( CourseWithDetailsRequest detailsRequest){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer appUserId = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == appUserId){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultUtil.success(packagePaymentService.queryVideoDetails(detailsRequest,appUserId)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/payCourseInfo") | 
|---|
|  |  |  | @ApiOperation(value = "课后练习-购课详情(用于购课)", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil<PayCourseInfoReq> payCourseInfo(Integer courseId){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | return ResultUtil.success(packagePaymentService.payCourseInfo(courseId)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/getMyCourseList") | 
|---|
|  |  |  | @ApiOperation(value = "课后练习-可支付课程列表(用于购课)", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil<List<PayCourseRes>> getMyCourseList(Integer storeId){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer appUserId = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == appUserId){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultUtil.success(packagePaymentService.getMyCourseList(storeId,appUserId)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 2.0 | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/payCourse") | 
|---|
|  |  |  | @ApiOperation(value = "课后练习-确认购课", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil<?> payCourse(PayCourseReq req){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer appUserId = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == appUserId){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return packagePaymentService.payCourse(req,appUserId); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新课后视频学习状态 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/updateVideoStatus") | 
|---|
|  |  |  | @ApiOperation(value = "更新课后视频学习状态", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil updateVideoStatus( UpdateCourseVideoStatusRequest detailsRequest){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer appUserId = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == appUserId){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultUtil.success(packagePaymentService.updateVideoStatus(detailsRequest,appUserId)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/course/getCourseAppUserDetails") | 
|---|
|  |  |  | @ApiOperation(value = "已报名课程-获取课程类型列表", tags = {"APP-课程列表"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil<List<BaseVo>> queryCoursePackageType(){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | List<TCoursePackageType> coursePackageTypes = coursePackageTypeService.list(new QueryWrapper<TCoursePackageType>().eq("state", 1)); | 
|---|
|  |  |  | List<BaseVo> list = new ArrayList<>(); | 
|---|
|  |  |  | coursePackageTypes.forEach(c -> { | 
|---|
|  |  |  | BaseVo baseVo = new BaseVo(); | 
|---|
|  |  |  | BeanUtils.copyProperties(c, baseVo); | 
|---|
|  |  |  | list.add(baseVo); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | return ResultUtil.success(list); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 已报名课程列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/registeredCourses") | 
|---|
|  |  |  | @ApiOperation(value = "已报名课程-课程列表", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil<List<RegisterCourseVo>> queryRegisteredCoursesDetails( CourseOfAfterRequest courseTypeId){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer appUserId = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == appUserId){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultUtil.success(packagePaymentService.queryRegisteredCourseList(courseTypeId,appUserId)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 已报名课程详情 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/RegisteredData") | 
|---|
|  |  |  | @ApiOperation(value = "已报名课程详情", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | @ApiImplicitParam(name = "coursePayId" ,value = "课包记录id",dataType = "long"), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil<CourseDetailsResponse> getRegisteredData(Long coursePayId){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer appUserId = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == appUserId){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultUtil.success(packagePaymentService.queryRegisteredCourseDetails(coursePayId,appUserId)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 已报名课程-支付 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/payment") | 
|---|
|  |  |  | @ApiOperation(value = "已报名课程-支付", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil continuationOperation(ClasspaymentRequest request){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == userIdFormRedis){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer couponId = request.getConponId(); | 
|---|
|  |  |  | if(couponId==null || couponId==0){ | 
|---|
|  |  |  | request.setConponId(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return packagePaymentService.ContinuationOrpaymentCourse(userIdFormRedis,request); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 课包续课支付宝支付回调接口 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @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){ | 
|---|
|  |  |  | String out_trade_no = map.get("out_trade_no"); | 
|---|
|  |  |  | String transaction_id = map.get("transaction_id"); | 
|---|
|  |  |  | ResultUtil resultUtil = packagePaymentService.insertVipPaymentCallback(out_trade_no, transaction_id); | 
|---|
|  |  |  | if(resultUtil.getCode() == 200){ | 
|---|
|  |  |  | PrintWriter out = response.getWriter(); | 
|---|
|  |  |  | out.write("success"); | 
|---|
|  |  |  | out.flush(); | 
|---|
|  |  |  | out.close(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 课包续课微信支付回调接口 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/base/coursePackage/wechatRegisteredCoursesCallback") | 
|---|
|  |  |  | public void weChatCallback(HttpServletRequest request, HttpServletResponse response){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); | 
|---|
|  |  |  | if(null != map){ | 
|---|
|  |  |  | String out_trade_no = map.get("out_trade_no"); | 
|---|
|  |  |  | String transaction_id = map.get("transaction_id"); | 
|---|
|  |  |  | String result = map.get("result"); | 
|---|
|  |  |  | ResultUtil resultUtil = packagePaymentService.insertVipPaymentCallback(out_trade_no, transaction_id); | 
|---|
|  |  |  | if(resultUtil.getCode() == 200){ | 
|---|
|  |  |  | PrintWriter out = response.getWriter(); | 
|---|
|  |  |  | out.write(result); | 
|---|
|  |  |  | out.flush(); | 
|---|
|  |  |  | out.close(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取学员剩余课时 | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/queryResidueClassHour") | 
|---|
|  |  |  | public Integer queryResidueClassHour(@RequestBody Integer id){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("studentId", id).eq("payStatus", 2) | 
|---|
|  |  |  | .eq("status", 1).eq("state", 1).gt("laveClassHours", 0)); | 
|---|
|  |  |  | Integer total = 0; | 
|---|
|  |  |  | for (TCoursePackagePayment coursePackagePayment : list) { | 
|---|
|  |  |  | total += coursePackagePayment.getLaveClassHours(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return total; | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取学员剩余课时 | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/queryResidueClassHourById") | 
|---|
|  |  |  | public Integer queryResidueClassHourById(@RequestBody Long id){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | TCoursePackagePayment list = packagePaymentService.getById(id); | 
|---|
|  |  |  | return list.getLaveClassHours(); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/paymentDeductionClassHour") | 
|---|
|  |  |  | public void paymentDeductionClassHour(@RequestBody PaymentDeductionClassHour paymentDeductionClassHour){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 2.0 用id进行查询 | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | coursePackagePayment.setLaveClassHours(coursePackagePayment.getLaveClassHours() - classHour); | 
|---|
|  |  |  | coursePackagePayment.setAppUserId(null); | 
|---|
|  |  |  | packagePaymentService.updateById(coursePackagePayment); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                    coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().eq("courseId", coursePackagePayment.getCoursePackageId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Student student = studentClient.queryStudentById(coursePackagePayment.getStudentId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TCoursePackage tCoursePackage = packageService.getById(coursePackagePayment.getCoursePackageId()); | 
|---|
|  |  |  | String classWeeks = tCoursePackage.getClassWeeks(); | 
|---|
|  |  |  | List<Integer> week = week(classWeeks); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<TCoursePackagePayment> pays = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", coursePackagePayment.getCoursePackageId()).eq("studentId", coursePackagePayment.getStudentId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (TCoursePackagePayment pay : pays) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CoursePackageStudent> studentCourse1 = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", pay.getStudentId()).eq("coursePackageId", pay.getCoursePackageId())); | 
|---|
|  |  |  | List<Long> collect1 = studentCourse1.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); | 
|---|
|  |  |  | //拿到最后一天的排课记录 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CoursePackageScheduling cs = null; | 
|---|
|  |  |  | if (collect1.size()>0) { | 
|---|
|  |  |  | cs = coursePackageSchedulingService.getOne(new QueryWrapper<CoursePackageScheduling>().in("id", collect1).orderByDesc("classDate").last("limit 1")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                        Calendar calendar = Calendar.getInstance(); | 
|---|
|  |  |  | //                        Date currentDate = calendar.getTime(); | 
|---|
|  |  |  | //                        calendar.add(Calendar.DAY_OF_MONTH, -1); | 
|---|
|  |  |  | //                        Date today = calendar.getTime(); | 
|---|
|  |  |  | Date today = new Date(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断最后一天是否超过当前日期 | 
|---|
|  |  |  | if (cs==null||cs.getClassDate().before(new Date())){ | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | today = cs.getClassDate(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                    // 本周周几 | 
|---|
|  |  |  | //                    int i = cn.hutool.core.date.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.save(coursePackageScheduling); | 
|---|
|  |  |  | //                                CoursePackageStudent student1 = new CoursePackageStudent(); | 
|---|
|  |  |  | //                                student1.setAppUserId(student.getAppUserId()); | 
|---|
|  |  |  | //                                student1.setStudentId(student.getId()); | 
|---|
|  |  |  | //                                student1.setCoursePackageId(tCoursePackage.getId()); | 
|---|
|  |  |  | //                                student1.setCoursePackagePaymentId(coursePackagePayment.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> list6 = new ArrayList<>(); | 
|---|
|  |  |  | //                            list6.add(time1); | 
|---|
|  |  |  | //                            instance.add(Calendar.DATE, 7); | 
|---|
|  |  |  | //                            Date time2 = instance.getTime(); | 
|---|
|  |  |  | //                            list6.add(time2); | 
|---|
|  |  |  | //                            for (Date time : list6) { | 
|---|
|  |  |  | //                                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.save(coursePackageScheduling); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                                    CoursePackageStudent student1 = new CoursePackageStudent(); | 
|---|
|  |  |  | //                                    student1.setAppUserId(student.getAppUserId()); | 
|---|
|  |  |  | //                                    student1.setStudentId(student.getId()); | 
|---|
|  |  |  | //                                    student1.setCoursePackageId(tCoursePackage.getId()); | 
|---|
|  |  |  | //                                    student1.setCoursePackagePaymentId(coursePackagePayment.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.save(coursePackageScheduling); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                                CoursePackageStudent student1 = new CoursePackageStudent(); | 
|---|
|  |  |  | //                                student1.setAppUserId(student.getAppUserId()); | 
|---|
|  |  |  | //                                student1.setStudentId(student.getId()); | 
|---|
|  |  |  | //                                student1.setCoursePackageId(tCoursePackage.getId()); | 
|---|
|  |  |  | //                                student1.setCoursePackagePaymentId(coursePackagePayment.getId()); | 
|---|
|  |  |  | //                                student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); | 
|---|
|  |  |  | //                                student1.setSignInOrNot(1); | 
|---|
|  |  |  | //                                student1.setReservationStatus(1); | 
|---|
|  |  |  | //                                student1.setInsertTime(new Date()); | 
|---|
|  |  |  | //                                studentService.save(student1); | 
|---|
|  |  |  | //                            } | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 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 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/rollbackPaymentDeductionClassHour") | 
|---|
|  |  |  | public void rollbackPaymentDeductionClassHour(@RequestBody PaymentDeductionClassHour paymentDeductionClassHour){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | List<CancelledClasses> voucher = cancelledClassesService.list(new QueryWrapper<CancelledClasses>().eq("voucher", paymentDeductionClassHour.getCode())); | 
|---|
|  |  |  | for (CancelledClasses cancelledClasses : voucher) { | 
|---|
|  |  |  | TCoursePackagePayment coursePackagePayment = packagePaymentService.getById(cancelledClasses.getCoursePackagePaymentId()); | 
|---|
|  |  |  | coursePackagePayment.setLaveClassHours(coursePackagePayment.getLaveClassHours() + cancelledClasses.getCancelledClassesNumber()); | 
|---|
|  |  |  | packagePaymentService.updateById(coursePackagePayment); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | cancelledClassesService.removeById(cancelledClasses.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 找出符合门店的课包 | 
|---|
|  |  |  | * @param s | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/paymentCompetitionCourseList") | 
|---|
|  |  |  | public List<PayCourseRes> paymentCompetitionCourseList(@RequestBody String s){ | 
|---|
|  |  |  | ArrayList<PayCourseRes> objects = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String[] split = s.split("_"); | 
|---|
|  |  |  | // 用户id | 
|---|
|  |  |  | Integer integer = Integer.valueOf(split[0]); | 
|---|
|  |  |  | String s1 = split[1]; | 
|---|
|  |  |  | // 门店id | 
|---|
|  |  |  | String[] split1 = s1.split(","); | 
|---|
|  |  |  | ArrayList<Integer> storeIds = new ArrayList<>(); | 
|---|
|  |  |  | for (String s2 : split1) { | 
|---|
|  |  |  | storeIds.add(Integer.valueOf(s2)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TCoursePackagePayment> list = packagePaymentService.list(new LambdaQueryWrapper<TCoursePackagePayment>().eq(TCoursePackagePayment::getAppUserId, integer).ge(TCoursePackagePayment::getLaveClassHours, 0).eq(TCoursePackagePayment::getStatus, 1).eq(TCoursePackagePayment::getState, 1)); | 
|---|
|  |  |  | for (TCoursePackagePayment tCoursePackagePayment : list) { | 
|---|
|  |  |  | Integer coursePackageId = tCoursePackagePayment.getCoursePackageId(); | 
|---|
|  |  |  | TCoursePackage byId = tcpService.getById(coursePackageId); | 
|---|
|  |  |  | if(storeIds.contains(byId.getStoreId())){ | 
|---|
|  |  |  | PayCourseRes payCourseRes = new PayCourseRes(); | 
|---|
|  |  |  | payCourseRes.setCourseNum(tCoursePackagePayment.getLaveClassHours()); | 
|---|
|  |  |  | payCourseRes.setId(tCoursePackagePayment.getId()); | 
|---|
|  |  |  | payCourseRes.setName(byId.getName()); | 
|---|
|  |  |  | objects.add(payCourseRes); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return objects; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 课包续费玩湃币支付 | 
|---|
|  |  |  | * @param | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/courseRenewPlayPaiPay") | 
|---|
|  |  |  | public int paymentWanpaiRenewCourse(@RequestBody PlayPaiGoldCoursePackage coursePackage){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if (null == userIdFormRedis){ | 
|---|
|  |  |  | return 2; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | CoursePackagePaymentConfig paymentConfig = icppcService.getById(coursePackage.getCoursePayConfigId()); | 
|---|
|  |  |  | AppUser appUser = auClitn.queryAppUser(userIdFormRedis); | 
|---|
|  |  |  | if (appUser.getPlayPaiCoins() < paymentConfig.getPlayPaiCoin()){ | 
|---|
|  |  |  | return 3; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | TCoursePackagePayment packagePayment = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("code",coursePackage.getCode() )); | 
|---|
|  |  |  | packagePayment.setPayStatus(2); | 
|---|
|  |  |  | packagePayment.setPayUserId(userIdFormRedis); | 
|---|
|  |  |  | packagePayment.setClassHours(paymentConfig.getClassHours()); | 
|---|
|  |  |  | packagePayment.setPlayPaiCoin(paymentConfig.getPlayPaiCoin()); | 
|---|
|  |  |  | packagePayment.setTotalClassHours(paymentConfig.getClassHours()); | 
|---|
|  |  |  | packagePayment.setLaveClassHours(paymentConfig.getClassHours()); | 
|---|
|  |  |  | packagePaymentService.updateById(packagePayment); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | appUser.setPlayPaiCoins(appUser.getPlayPaiCoins()-paymentConfig.getPlayPaiCoin()); | 
|---|
|  |  |  | auClitn.updateAppUser(appUser); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 2.0 | 
|---|
|  |  |  | TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); | 
|---|
|  |  |  | tCourseInfoRecord.setUserId(userIdFormRedis); | 
|---|
|  |  |  | tCourseInfoRecord.setCourseId(coursePackage.getCoursePackageId()); | 
|---|
|  |  |  | tCourseInfoRecord.setName("续课"); | 
|---|
|  |  |  | tCourseInfoRecord.setTime(new Date()); | 
|---|
|  |  |  | tCourseInfoRecord.setType(1); | 
|---|
|  |  |  | tCourseInfoRecord.setNum(paymentConfig.getClassHours()); | 
|---|
|  |  |  | auClitn.addCourseInfoRecord(tCourseInfoRecord); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | return 4; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/getPaymentCoursePackage") | 
|---|
|  |  |  | public TCoursePackagePayment getCoursePackagePaymentByCode(@RequestBody String code){ | 
|---|
|  |  |  | return packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("code",code)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/getCoursePackagePaymentById") | 
|---|
|  |  |  | public TCoursePackagePayment getCoursePackagePaymentById(@RequestBody Long id){ | 
|---|
|  |  |  | TCoursePackagePayment byId = packagePaymentService.getById(id); | 
|---|
|  |  |  | System.out.println("======byId=========="+byId); | 
|---|
|  |  |  | return byId; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/delPaymentCoursePackage") | 
|---|
|  |  |  | public boolean delPaymentCoursePackage(@RequestBody Integer payId){ | 
|---|
|  |  |  | return packagePaymentService.removeById(payId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @PostMapping("/base/coursePack/updatePaymentCoursePackage") | 
|---|
|  |  |  | public boolean updatePaymentCoursePackage(@RequestBody TCoursePackagePayment packagePayment){ | 
|---|
|  |  |  | boolean id = packagePaymentService.update(packagePayment, new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("id", packagePayment.getId())); | 
|---|
|  |  |  | if(id){ | 
|---|
|  |  |  | // 2.0 | 
|---|
|  |  |  | TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); | 
|---|
|  |  |  | tCourseInfoRecord.setNum(packagePayment.getTotalClassHours()); | 
|---|
|  |  |  | tCourseInfoRecord.setName("续课"); | 
|---|
|  |  |  | tCourseInfoRecord.setCourseId(packagePayment.getCoursePackageId()); | 
|---|
|  |  |  | tCourseInfoRecord.setUserId(packagePayment.getAppUserId()); | 
|---|
|  |  |  | tCourseInfoRecord.setType(1); | 
|---|
|  |  |  | tCourseInfoRecord.setTime(new Date()); | 
|---|
|  |  |  | id = appUserClient.addCourseInfoRecord(tCourseInfoRecord); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return id; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/savePaymentCoursePackage") | 
|---|
|  |  |  | public boolean savePaymentCoursePackage(@RequestBody TCoursePackagePayment packagePayment){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return packagePaymentService.save(packagePayment); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/base/coursePack/obtainStudentClassDetails") | 
|---|
|  |  |  | public List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody WeeksOfCourseRest stuId){ | 
|---|
|  |  |  | //        try { | 
|---|
|  |  |  | return packagePaymentService.obtainStuClassDetails(stuId.getStuId(),stuId.getAppUserId(),stuId.getPageNum()); | 
|---|
|  |  |  | //        }catch (Exception e){ | 
|---|
|  |  |  | //            e.printStackTrace(); | 
|---|
|  |  |  | //            throw new RuntimeException(); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/getCoursePackageConfig") | 
|---|
|  |  |  | public List<CoursePackagePaymentConfig> getCourseConfigList(@RequestBody Integer coursePackageId){ | 
|---|
|  |  |  | return icppcService.list(new QueryWrapper<CoursePackagePaymentConfig>() | 
|---|
|  |  |  | .eq("coursePackageId",coursePackageId)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/base/coursePack/getCoursePackagePaymentOfCode") | 
|---|
|  |  |  | public List<TCoursePackagePayment> getCoursePackagePaymentOfCode(@RequestBody String code){ | 
|---|
|  |  |  | return packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq("code",code)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 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])); | 
|---|
|  |  |  | if(b){ | 
|---|
|  |  |  | return 1; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询课时 | 
|---|
|  |  |  | * @param courseConfigId | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/base/coursePack/getClassHour") | 
|---|
|  |  |  | public Integer getClassHour(@RequestBody Integer courseConfigId){ | 
|---|
|  |  |  | CoursePackagePaymentConfig byId = icppcService.getById(courseConfigId); | 
|---|
|  |  |  | return byId.getClassHours(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取课包报名信息列表 | 
|---|
|  |  |  | * @param queryRegistrationRecord | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/queryRegistrationRecord") | 
|---|
|  |  |  | public Page<Map<String, Object>> queryRegistrationRecord(@RequestBody QueryRegistrationRecord queryRegistrationRecord){ | 
|---|
|  |  |  | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(queryRegistrationRecord.getLimit(), queryRegistrationRecord.getOffset(), queryRegistrationRecord.getSort(), queryRegistrationRecord.getOrder()); | 
|---|
|  |  |  | Page<Map<String, Object>> mapPage = page.setRecords(packagePaymentService.queryRegistrationRecord(page, queryRegistrationRecord)); | 
|---|
|  |  |  | return mapPage; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取未预约排课学员列表 | 
|---|
|  |  |  | * @param queryWalkInStudentList | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/queryWalkInStudentList") | 
|---|
|  |  |  | public Page<Map<String, Object>> queryWalkInStudentList(@RequestBody QueryWalkInStudentList queryWalkInStudentList){ | 
|---|
|  |  |  | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(queryWalkInStudentList.getLimit(), queryWalkInStudentList.getOffset(), queryWalkInStudentList.getSort(), queryWalkInStudentList.getOrder()); | 
|---|
|  |  |  | Page<Map<String, Object>> mapPage = page.setRecords(packagePaymentService.queryWalkInStudentList(page, queryWalkInStudentList)); | 
|---|
|  |  |  | return mapPage; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据id获取数据 | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/queryCoursePackagePaymentById") | 
|---|
|  |  |  | public TCoursePackagePayment queryCoursePackagePaymentById(@RequestParam("id")Long id){ | 
|---|
|  |  |  | return packagePaymentService.getById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/CountqueryByClassId") | 
|---|
|  |  |  | public   Integer  CountqueryByClassId(@RequestBody Integer id){ | 
|---|
|  |  |  | int coursePackageId = packagePaymentService.count(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", id)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return coursePackageId; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 修改数据 | 
|---|
|  |  |  | * @param coursePackagePayment | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/editCoursePackagePayment") | 
|---|
|  |  |  | public void editCoursePackagePayment(TCoursePackagePayment coursePackagePayment){ | 
|---|
|  |  |  | coursePackagePayment.setAppUserId(null); | 
|---|
|  |  |  | packagePaymentService.updateById(coursePackagePayment); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 修改数据 | 
|---|
|  |  |  | * @param coursePackagePayment | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/coursePackagePayment/editCoursePackagePayment1") | 
|---|
|  |  |  | public void editCoursePackagePayment1(@RequestBody TCoursePackagePayment coursePackagePayment){ | 
|---|
|  |  |  | System.out.println("editCoursePackagePayment1====coursePackagePayment"+coursePackagePayment); | 
|---|
|  |  |  | //        coursePackagePayment.setCoursePackageId(null); | 
|---|
|  |  |  | packagePaymentService.updateBytime(coursePackagePayment); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 上课主页-预约操作 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/api/startCource/reverse") | 
|---|
|  |  |  | @ApiOperation(value = "上课主页-预约操作--2.0改请假操作", tags = {"APP-开始上课"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), | 
|---|
|  |  |  | @ApiImplicitParam(value = "课包id", name = "courseID", required = true, dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(value = "时间 yyyy-MM-dd", name = "time", required = true, dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ResultUtil reverse(String courseID,String time,Integer stuId){ | 
|---|
|  |  |  | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer appUserId = tokenUtil.getUserIdFormRedis(); | 
|---|
|  |  |  | if(null == appUserId){ | 
|---|
|  |  |  | return ResultUtil.tokenErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TCoursePackagePayment> packagePayment = packagePaymentService.list(new LambdaQueryWrapper<TCoursePackagePayment>() | 
|---|
|  |  |  | .eq(TCoursePackagePayment::getCoursePackageId,courseID ) | 
|---|
|  |  |  | .eq(TCoursePackagePayment::getAppUserId,appUserId) | 
|---|
|  |  |  | .eq(TCoursePackagePayment::getStudentId,stuId) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ToolUtil.isEmpty(packagePayment) || packagePayment.size()==0){ | 
|---|
|  |  |  | return ResultUtil.error("该用户未购买该课包"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingMapper.selectList(new LambdaQueryWrapper<CoursePackageScheduling>() | 
|---|
|  |  |  | .eq(CoursePackageScheduling::getCoursePackageId, Integer.valueOf(courseID)) | 
|---|
|  |  |  | .like(CoursePackageScheduling::getClassDate, time) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CoursePackageStudent> coursePackageStudent = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>() | 
|---|
|  |  |  | .in(CoursePackageStudent::getCoursePackagePaymentId,packagePayment.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList())) | 
|---|
|  |  |  | .in(CoursePackageStudent::getCoursePackageSchedulingId,coursePackageSchedulings.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList())) | 
|---|
|  |  |  | .eq(CoursePackageStudent::getCoursePackageId,courseID) | 
|---|
|  |  |  | .eq(CoursePackageStudent::getStudentId,stuId) | 
|---|
|  |  |  | .eq(CoursePackageStudent::getAppUserId,appUserId) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ToolUtil.isNotEmpty(coursePackageStudent)){ | 
|---|
|  |  |  | for (CoursePackageStudent packageStudent : coursePackageStudent) { | 
|---|
|  |  |  | if(packageStudent.getReservationStatus()==1){ | 
|---|
|  |  |  | packageStudent.setSignInOrNot(2); | 
|---|
|  |  |  | cspsService.updateSignInOrNotById(packageStudent.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultUtil.success(); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return ResultUtil.runErr(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | @PostMapping("/base/coursePack/weeksOfCourseDetailsList") | 
|---|
|  |  |  | HashMap<String, Object> weeksOfCourseDetailsList(@RequestBody CourseDetailReq courseDetailReq){ | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | ArrayList<DetailsListVo> objects = new ArrayList<>(); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String time = courseDetailReq.getTime(); | 
|---|
|  |  |  | Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(time); | 
|---|
|  |  |  | int i = cn.hutool.core.date.DateUtil.dayOfWeek(parse)-1; | 
|---|
|  |  |  | String week = week(i); | 
|---|
|  |  |  | Store store = sreClient.queryStoreById(courseDetailReq.getStoreId()); | 
|---|
|  |  |  | String lat = store.getLat(); | 
|---|
|  |  |  | String lon = store.getLon(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Double> distance = GeodesyUtil.getDistance(courseDetailReq.getLon() + "," + courseDetailReq.getLat(), lon + "," + lat); | 
|---|
|  |  |  | double wgs84 = distance.get("WGS84") / 1000; | 
|---|
|  |  |  | map.put("distance",wgs84); | 
|---|
|  |  |  | map.put("name",store.getName()); | 
|---|
|  |  |  | map.put("lon",lon); | 
|---|
|  |  |  | map.put("lat",lat); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String time1 = courseDetailReq.getTime(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 找出门店的所有课程 排出体验 | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | String classStartTime = tCoursePackage.getClassStartTime(); | 
|---|
|  |  |  | String[] split = classStartTime.split(","); | 
|---|
|  |  |  | String classEndTime = tCoursePackage.getClassEndTime(); | 
|---|
|  |  |  | String[] split1 = classEndTime.split(","); | 
|---|
|  |  |  | ArrayList<String> strings = new ArrayList<>(); | 
|---|
|  |  |  | if(ToolUtil.isNotEmpty(classStartTime)){ | 
|---|
|  |  |  | for (int i1 = 0; i1 < split.length; i1++) { | 
|---|
|  |  |  | String s = split[i1].substring(0,5) + "-" + split1[i1].substring(0,5); | 
|---|
|  |  |  | strings.add(s); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | detailsListVo.setTime(strings); | 
|---|
|  |  |  | List<CoursePackagePaymentConfig> list2 = icppcService.list(new LambdaQueryWrapper<CoursePackagePaymentConfig>().eq(CoursePackagePaymentConfig::getCoursePackageId, tCoursePackage.getId()).orderByAsc(CoursePackagePaymentConfig::getCashPayment)); | 
|---|
|  |  |  | if (list2.size() > 0) { | 
|---|
|  |  |  | Double cashPayment = list2.get(0).getCashPayment(); | 
|---|
|  |  |  | detailsListVo.setMoney(cashPayment); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | detailsListVo.setNum(tCoursePackage.getNeedNum()); | 
|---|
|  |  |  | if (collect1.contains(tCoursePackage.getId())) { | 
|---|
|  |  |  | // 找出排课记录 | 
|---|
|  |  |  | List<CoursePackageScheduling> list3 = coursePackageSchedulingMapper.selectList(new LambdaQueryWrapper<CoursePackageScheduling>() | 
|---|
|  |  |  | .eq(CoursePackageScheduling::getCoursePackageId, tCoursePackage.getId()) | 
|---|
|  |  |  | .like(CoursePackageScheduling::getClassDate, courseDetailReq.getTime()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(list3.size()==0){ | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Long> collect2 = list3.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | if(collect2.size()==0){ | 
|---|
|  |  |  | collect2.add(-1l); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<CoursePackageStudent> list4 = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>() | 
|---|
|  |  |  | .eq(CoursePackageStudent::getAppUserId, courseDetailReq.getAppUserId()) | 
|---|
|  |  |  | .eq(CoursePackageStudent::getCoursePackageId, tCoursePackage.getId()) | 
|---|
|  |  |  | .in(CoursePackageStudent::getCoursePackageSchedulingId, collect2). | 
|---|
|  |  |  | in(CoursePackageStudent::getCoursePackagePaymentId, ids) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(list4.size()>0){ | 
|---|
|  |  |  | Integer signInOrNot = list4.get(0).getSignInOrNot(); | 
|---|
|  |  |  | detailsListVo.setType(1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(signInOrNot==2){ | 
|---|
|  |  |  | detailsListVo.setType(3); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | detailsListVo.setIsType(list4.get(0).getType()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | detailsListVo.setType(2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | detailsListVo.setType(2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | objects.add(detailsListVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | map.put("data",objects); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } catch (ParseException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String week(int i){ | 
|---|
|  |  |  | String a = ""; | 
|---|
|  |  |  | switch (i){ | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | a="周一"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | a="周二"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | a="周三"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 4: | 
|---|
|  |  |  | a="周四"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 5: | 
|---|
|  |  |  | a="周五"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 6: | 
|---|
|  |  |  | a="周六"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 7: | 
|---|
|  |  |  | a="周日"; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|