| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.feignclient.account.AppUserClient; |
| | |
| | | import com.dsh.course.feignclient.model.*; |
| | | import com.dsh.course.feignclient.other.StoreClient; |
| | | import com.dsh.course.feignclient.other.model.Store; |
| | | import com.dsh.course.model.BaseVo; |
| | | import com.dsh.course.model.QueryRegistrationRecord; |
| | | import com.dsh.course.model.QueryWalkInStudentList; |
| | | import com.dsh.course.model.BillingRequest; |
| | | import com.dsh.course.model.BillingRequestVo; |
| | | 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 io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api |
| | |
| | | @Autowired |
| | | private RestTemplate internalRestTemplate; |
| | | |
| | | @Resource |
| | | private CoursePackageSchedulingMapper coursePackageSchedulingMapper; |
| | | |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); |
| | | |
| | |
| | | TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId()); |
| | | StuCourseResp resp = new StuCourseResp(); |
| | | resp.setCourseId(tCoursePackage.getId()); |
| | | resp.setId(tCoursePackagePayment.getId()); |
| | | resp.setCourseName(tCoursePackage.getName()); |
| | | resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours()); |
| | | resp.setResidueNums(tCoursePackagePayment.getLaveClassHours()); |
| | |
| | | .groupBy("coursePackageId")); |
| | | if (list.size() > 0){ |
| | | for (TCoursePackagePayment tCoursePackagePayment : list) { |
| | | CoursePackageStudent packageStudent = cspsService.getOne(new LambdaQueryWrapper<CoursePackageStudent>() |
| | | 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.getReservationStatus() != 1)){ |
| | | 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>() |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课后视频课表 |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/payCourseInfo") |
| | | @ApiOperation(value = "课后练习-购课详情(用于购课)", tags = {"APP-开始上课"}) |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/getMyCourseList") |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<?> payCourse(@RequestBody PayCourseReq req){ |
| | | public ResultUtil<?> payCourse(PayCourseReq req){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新课后视频学习状态 |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | 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){ |
| | |
| | | .eq("code",code)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/coursePack/getCoursePackagePaymentById") |
| | | public TCoursePackagePayment getCoursePackagePaymentById(@RequestBody Integer id){ |
| | | return packagePaymentService.getById(id); |
| | | } |
| | | @PostMapping("/base/coursePack/delPaymentCoursePackage") |
| | | public boolean delPaymentCoursePackage(@RequestBody Integer payId){ |
| | | return packagePaymentService.removeById(payId); |
| | |
| | | |
| | | // 2.0 送课时 |
| | | @PostMapping("/base/coursePack/sendHours") |
| | | public Boolean sendHours(@RequestBody String s){ |
| | | public Integer sendHours(@RequestBody String s){ |
| | | String[] split = s.split("_"); |
| | | TCoursePackagePayment byId = packagePaymentService.getById(Integer.valueOf(split[0])); |
| | | TCoursePackagePayment byId = packagePaymentService.getById(Long.valueOf(split[0])); |
| | | byId.setTotalClassHours(byId.getTotalClassHours()+Integer.valueOf(split[2])); |
| | | return packagePaymentService.updateById(byId); |
| | | boolean b = packagePaymentService.updateHoursById(byId,Integer.valueOf(split[2])); |
| | | if(b){ |
| | | return 1; |
| | | }else { |
| | | |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/CountqueryByClassId") |
| | | public Integer CountqueryByClassId(@RequestBody Integer id){ |
| | | int coursePackageId = packagePaymentService.count(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", id)); |
| | | |
| | | |
| | | return coursePackageId; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改数据 |
| | | * @param coursePackagePayment |
| | |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | TCoursePackagePayment packagePayment = packagePaymentService.getOne(new LambdaQueryWrapper<TCoursePackagePayment>() |
| | | List<TCoursePackagePayment> packagePayment = packagePaymentService.list(new LambdaQueryWrapper<TCoursePackagePayment>() |
| | | .eq(TCoursePackagePayment::getCoursePackageId,courseID ) |
| | | .eq(TCoursePackagePayment::getAppUserId,appUserId) |
| | | .eq(TCoursePackagePayment::getStudentId,stuId) |
| | | ); |
| | | |
| | | if (ToolUtil.isEmpty(packagePayment)){ |
| | | if (ToolUtil.isEmpty(packagePayment) || packagePayment.size()==0){ |
| | | return ResultUtil.error("该用户未购买该课包"); |
| | | } |
| | | CoursePackageStudent coursePackageStudent = cspsService.getOne(new LambdaQueryWrapper<CoursePackageStudent>() |
| | | .eq(CoursePackageStudent::getCoursePackageId,packagePayment.getCoursePackageId()) |
| | | .eq(CoursePackageStudent::getCoursePackagePaymentId,courseID) |
| | | List<CoursePackageStudent> coursePackageStudent = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>() |
| | | .in(CoursePackageStudent::getCoursePackagePaymentId,packagePayment.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList())) |
| | | .eq(CoursePackageStudent::getCoursePackageId,courseID) |
| | | .eq(CoursePackageStudent::getStudentId,stuId) |
| | | .eq(CoursePackageStudent::getAppUserId,appUserId) |
| | | ); |
| | | |
| | | if (ToolUtil.isNotEmpty(coursePackageStudent) && coursePackageStudent.getReservationStatus() == 0){ |
| | | coursePackageStudent.setSignInOrNot(2); |
| | | coursePackageStudent.setInsertTime(simpleDateFormat.parse(time)); |
| | | cspsService.updateById(coursePackageStudent); |
| | | if (ToolUtil.isNotEmpty(coursePackageStudent)){ |
| | | for (CoursePackageStudent packageStudent : coursePackageStudent) { |
| | | if(packageStudent.getReservationStatus()==1){ |
| | | packageStudent.setSignInOrNot(2); |
| | | cspsService.updateSignInOrNotById(packageStudent.getId()); |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | coursePackageStudent = new CoursePackageStudent(); |
| | | coursePackageStudent.setAppUserId(appUserId); |
| | | coursePackageStudent.setStudentId(stuId); |
| | | coursePackageStudent.setCoursePackageId(packagePayment.getCoursePackageId()); |
| | | coursePackageStudent.setCoursePackagePaymentId(Long.parseLong(courseID)); |
| | | coursePackageStudent.setSignInOrNot(2); |
| | | coursePackageStudent.setInsertTime(simpleDateFormat.parse(time)); |
| | | cspsService.save(coursePackageStudent); |
| | | } |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | |
| | | } |
| | | } |
| | | |
| | | @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).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<>(); |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | String s = split[i1] + "-" + split1[i1]; |
| | | 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()) |
| | | ); |
| | | 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) |
| | | ); |
| | | |
| | | detailsListVo.setType(1); |
| | | if(list4.size()>0){ |
| | | Integer signInOrNot = list4.get(0).getSignInOrNot(); |
| | | if(signInOrNot==2){ |
| | | detailsListVo.setType(3); |
| | | } |
| | | } |
| | | |
| | | } 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; |
| | | } |
| | | |
| | | } |