| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.domain.Person; |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.course.entity.*; |
| | |
| | | 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.ICoursePackageSchedulingService; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | 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.models.auth.In; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.persistence.criteria.CriteriaBuilder; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | List<Map<String, Object>> studentTotal = this.baseMapper.getStudentTotal(studentQeryDto); |
| | | |
| | | for (Map<String, Object> student : studentTotal) { |
| | | BigDecimal cashPayment = (BigDecimal) student.get("cashPayment"); |
| | | BigDecimal totalClassHours = (BigDecimal) student.get("totalClassHours"); |
| | | BigDecimal hasHours = (BigDecimal) student.get("hasHours"); |
| | | |
| | | BigDecimal hasPayment = cashPayment.divide(totalClassHours, 2, RoundingMode.HALF_UP) |
| | | .multiply(hasHours).setScale(2, RoundingMode.HALF_UP); |
| | | student.put("hasPayment", hasPayment); |
| | | |
| | | |
| | | Integer appUserId = (Integer) student.get("appUserId"); |
| | | AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | student.put("province", appUser.getProvince()); |
| | |
| | | |
| | | Student studentId = studentClient.queryStudentById((Integer) student.get("studentId")); |
| | | student.put("studentName", studentId.getName()); |
| | | |
| | | |
| | | BigDecimal cashPayment = (BigDecimal) student.get("cashPayment"); |
| | | BigDecimal totalClassHours = (BigDecimal) student.get("totalClassHours"); |
| | | BigDecimal hasHours = (BigDecimal) student.get("hasHours"); |
| | | if (cashPayment==null){ |
| | | continue; |
| | | } |
| | | if (totalClassHours.compareTo(BigDecimal.ZERO)==0){ |
| | | totalClassHours = totalClassHours.add(new BigDecimal("1")); |
| | | } |
| | | BigDecimal hasPayment = cashPayment.divide(totalClassHours, 2, RoundingMode.HALF_UP) |
| | | .multiply(hasHours).setScale(2, RoundingMode.HALF_UP); |
| | | student.put("hasPayment", hasPayment); |
| | | } |
| | | |
| | | if (studentQeryDto.getCityCode()!=null&&studentQeryDto.getCityCode()!="") { |
| | |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | @Autowired |
| | | private TCourseService courseService; |
| | | @Override |
| | | public CourseOfVideoResponse queryVideoDetails(CourseWithDetailsRequest detailsRequest,Integer appUserId) { |
| | | CourseOfVideoResponse response = new CourseOfVideoResponse(); |
| | | BenefitsVideos videosWithIds = bfvoClient.getVideosWithIds(detailsRequest.getVideoId()); |
| | | // BenefitsVideos videosWithIds = bfvoClient.getVideosWithIds(detailsRequest.getVideoId()); |
| | | TCourse byId = courseService.getById(detailsRequest.getVideoId()); |
| | | TCoursePackage coursePackage = tcpmapper.selectById(detailsRequest.getCoursePackageId()); |
| | | if (null != videosWithIds && null != coursePackage){ |
| | | CoursePackageScheduling byId1 = new CoursePackageScheduling(); |
| | | if (detailsRequest.getScId()!=null){ |
| | | byId1 = coursePackageSchedulingService.getById(detailsRequest.getScId()); |
| | | } |
| | | |
| | | if (null != coursePackage){ |
| | | response.setCoursePackageId(coursePackage.getId()); |
| | | response.setVideoId(videosWithIds.getId()); |
| | | response.setVideoURL(videosWithIds.getVideos()); |
| | | response.setVideoName(videosWithIds.getName()); |
| | | response.setIntegral(videosWithIds.getIntegral()); |
| | | response.setVideoId(byId.getId()); |
| | | response.setVideoURL(byId.getCourseVideo()); |
| | | response.setVideoName(coursePackage.getName()); |
| | | UserVideoDetails userVideoDetails = uvdmapper.selectOne(new QueryWrapper<UserVideoDetails>() |
| | | .eq("appUserId",appUserId ) |
| | | .eq("coursePackageId",coursePackage.getId()) |
| | | .eq("courseId",videosWithIds.getId())); |
| | | .eq("courseId",detailsRequest.getVideoId())); |
| | | |
| | | response.setStudyStatus(userVideoDetails.getState()); |
| | | if (userVideoDetails!=null) { |
| | | response.setStudyStatus(userVideoDetails.getState()); |
| | | }else { |
| | | response.setStudyStatus(1); |
| | | } |
| | | response.setPackageName(coursePackage.getName()); |
| | | response.setSynopsis(videosWithIds.getIntroduction()); |
| | | response.setDetailedDiagram(coursePackage.getIntroduceDrawing()); |
| | | response.setCover(videosWithIds.getCover()); |
| | | response.setSynopsis(byId.getIntroduce()); |
| | | response.setDetailedDiagram(byId.getIntroductionDrawing()); |
| | | response.setCover(byId.getCoverDrawing()); |
| | | if (byId1.getIntegral()!=null) { |
| | | response.setIntegral(String.valueOf(byId1.getIntegral())); |
| | | } |
| | | |
| | | } |
| | | |
| | | return response; |
| | |
| | | registerCourseVo.setCourseTime(new SimpleDateFormat("yyyy-MM-dd").format(tCoursePackagePayment.getInsertTime())); |
| | | Coach coach = coachClient.queryCoachById(coursePackage.getCoachId()); |
| | | registerCourseVo.setCourseTeacher(ToolUtil.isEmpty(coach) ? "" : coach.getName()); |
| | | if (coursePackage.getType()==2) { |
| | | registerCourseVo.setTime(new SimpleDateFormat("yyyy-MM-dd").format(coursePackage.getStartTime()) + "-" + new SimpleDateFormat("yyyy-MM-dd").format(coursePackage.getEndTime())); |
| | | } |
| | | List<CoursePackageStudent> coursePackageStudents = cpsMapper.selectList(new QueryWrapper<CoursePackageStudent>() |
| | | .eq("coursePackageId",coursePackage.getId()) |
| | | .eq("studentId",appUserId )); |
| | | .eq("appUserId",appUserId )); |
| | | |
| | | List<Long> ids = new ArrayList<>(); |
| | | for (CoursePackageStudent coursePackageStudent : coursePackageStudents) { |
| | | ids.add(coursePackageStudent.getCoursePackageSchedulingId()); |
| | | } |
| | | List<CoursePackageScheduling> cps =new ArrayList<>(); |
| | | |
| | | if (!ids.isEmpty()) { |
| | | cps = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id", ids)); |
| | | } |
| | | Integer counts = 0; |
| | | |
| | | for (CoursePackageScheduling cp : cps) { |
| | | if (cp.getDeductClassHour()!=null) { |
| | | counts = counts + cp.getDeductClassHour(); |
| | | } |
| | | } |
| | | |
| | | |
| | | // Integer counts = cpsMapper.selectCount(new QueryWrapper<CoursePackageStudent>() |
| | | // .eq("coursePackageId",coursePackage.getId()) |
| | | // .eq("appUserId",appUserId )); |
| | | |
| | | if (coursePackageStudents.size() > 0 ){ |
| | | registerCourseVo.setCourseNums(coursePackageStudents.size() * 2); |
| | | // registerCourseVo.setCourseNums(coursePackageStudents.size() * 2); |
| | | registerCourseVo.setCourseNums(counts); |
| | | } |
| | | registerCourseVo.setPayStatus(tCoursePackagePayment.getPayStatus()); |
| | | courseVos.add(registerCourseVo); |
| | |
| | | return courseVos; |
| | | } |
| | | |
| | | @Autowired |
| | | private ICoursePackagePaymentConfigService coursePackagePaymentConfigService; |
| | | |
| | | @Autowired |
| | | private TCoursePackageDiscountService coursePackageDiscountService; |
| | | |
| | | @Override |
| | | public CourseDetailsResponse queryRegisteredCourseDetails(Long coursePayId, Integer appUserId) { |
| | | AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | CourseDetailsResponse response = new CourseDetailsResponse(); |
| | | TCoursePackagePayment tCoursePackagePayment = this.baseMapper.selectById(coursePayId); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = this.baseMapper.selectList(new QueryWrapper<TCoursePackagePayment>().eq("appUserId", appUserId).eq("coursePackageId", tCoursePackagePayment.getCoursePackageId())); |
| | | List<Integer> stuIds = new ArrayList<>(); |
| | | for (TCoursePackagePayment coursePackagePayment : tCoursePackagePayments) { |
| | | stuIds.add(coursePackagePayment.getStudentId()); |
| | | } |
| | | response.setStuIds(stuIds); |
| | | response.setChooseHours(tCoursePackagePayment.getClassHours()); |
| | | |
| | | |
| | | if (null != tCoursePackagePayment){ |
| | | TCoursePackage coursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); |
| | | if (coursePackage.getType()==2) { |
| | | response.setTime(new SimpleDateFormat("yyyy.MM.dd").format(coursePackage.getStartTime()) + "-" + new SimpleDateFormat("yyyy.MM.dd").format(coursePackage.getEndTime())); |
| | | } |
| | | |
| | | // Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | // response.setStoreName(store.getName()); |
| | | // response.setStoreCoverDrawing(store.getCoverDrawing()); |
| | | // response.setStoreAddress(store.getAddress()); |
| | | // response.setLon(store.getLon()); |
| | | // response.setLat(store.getLat()); |
| | | // if(ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)){ |
| | | // Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); |
| | | // double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | // response.setDistance(wgs84); |
| | | // } |
| | | |
| | | |
| | | response.setCoursePackageId(tCoursePackagePayment.getCoursePackageId()); |
| | | response.setCoverDrawing(coursePackage.getCoverDrawing()); |
| | | response.setDetailDrawing(coursePackage.getDetailDrawing()); |
| | | response.setCoursePackageName(coursePackage.getName()); |
| | | response.setCoursePayId(tCoursePackagePayment.getId()); |
| | | response.setType(coursePackage.getType()); |
| | | List<Integer> integers = StrUtils.dealStrToList(coursePackage.getClassWeeks()); |
| | | String classWeeks = coursePackage.getClassWeeks(); |
| | | 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); |
| | | } |
| | | StringBuilder courWeeks = new StringBuilder("每"+classWeeks); |
| | | // for (Integer integer : integers) { |
| | | // courWeeks.append(integer).append("、"); |
| | | // } |
| | | // if (courWeeks.length() > 0 && courWeeks.charAt(courWeeks.length() - 1) == '、'){ |
| | | // courWeeks.deleteCharAt(courWeeks.length() - 1); |
| | | // } |
| | | response.setWeeks(courWeeks.toString()); |
| | | } |
| | | response.setCourseTimeFrame(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); |
| | | ArrayList<String> classTime = new ArrayList<>(); |
| | | String[] split4 = coursePackage.getClassStartTime().split(","); |
| | | String[] split3 = coursePackage.getClassEndTime().split(","); |
| | | if(ToolUtil.isNotEmpty(coursePackage.getClassStartTime())){ |
| | | for (int i = 0; i < split4.length; i++) { |
| | | String s = split4[i].substring(0,5) + "-" + split3[i].substring(0,5); |
| | | classTime.add(s); |
| | | } |
| | | } |
| | | |
| | | String joinedString = String.join("|", classTime); |
| | | |
| | | response.setCourseTimeFrame(joinedString); |
| | | |
| | | |
| | | // response.setCourseTimeFrame(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); |
| | | response.setIntroduceDrawing(coursePackage.getIntroduceDrawing()); |
| | | |
| | | Integer payType = tCoursePackagePayment.getPayType(); |
| | |
| | | response.setWpGold(playPaiCoin); |
| | | break; |
| | | } |
| | | |
| | | // coursePackage.get |
| | | |
| | | |
| | | response.setPayStatus(tCoursePackagePayment.getPayStatus()); |
| | | |
| | | |
| | | List<CoursePackagePaymentConfigVo> list = new ArrayList<>(); |
| | | List<CoursePackagePaymentConfig> list1 = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours")); |
| | | list1.forEach(coursePackagePaymentConfig -> { |
| | | CoursePackagePaymentConfigVo coursePackagePaymentConfigVo = new CoursePackagePaymentConfigVo(); |
| | | coursePackagePaymentConfigVo.setId(coursePackagePaymentConfig.getId()); |
| | | coursePackagePaymentConfigVo.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePaymentConfigVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | |
| | | if(ToolUtil.isNotEmpty(coursePackagePaymentConfig.getCashPayment()) && coursePackagePaymentConfig.getCashPayment()>0 && ToolUtil.isNotEmpty(coursePackagePaymentConfig.getPlayPaiCoin()) && coursePackagePaymentConfig.getPlayPaiCoin()>0 ){ |
| | | coursePackagePaymentConfigVo.setPayType(3); |
| | | }else if(ToolUtil.isNotEmpty(coursePackagePaymentConfig.getCashPayment()) && coursePackagePaymentConfig.getCashPayment()>0){ |
| | | coursePackagePaymentConfigVo.setPayType(1); |
| | | }else if( ToolUtil.isNotEmpty(coursePackagePaymentConfig.getPlayPaiCoin()) && coursePackagePaymentConfig.getPlayPaiCoin()>0 ){ |
| | | coursePackagePaymentConfigVo.setPayType(2); |
| | | } |
| | | |
| | | // coursePackagePaymentConfigVo.setPayType(coursePackage.getPayType()); |
| | | //会员显示原价和支付价(会员价)。非会员显示会员价和支付价(最低) |
| | | if(appUser.getIsVip() == 0){//非会员 |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount1 : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount1.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | | coursePackagePaymentConfigVo.setVipPrice(vipPrice); |
| | | Double paymentPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 3).eq("auditStatus", 2)); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (TCoursePackageDiscount coursePackageDiscount2 : list3) { |
| | | /** |
| | | * [{ |
| | | * "startDate": "2023-01-01 00:00:00", |
| | | * "endDate": "2023-12-31 23:59:59", |
| | | * "startTime": "02:00:00", |
| | | * "endTime": "23:00:00", |
| | | * "weeks": [1, 2, 7], |
| | | * "cashPayment": 100 |
| | | * }] |
| | | */ |
| | | JSONArray jsonArray = JSON.parseArray(coursePackageDiscount2.getContent()); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | try { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | String startDate = jsonObject.getString("startDate"); |
| | | String endDate = jsonObject.getString("endDate"); |
| | | String startTime = jsonObject.getString("startTime"); |
| | | String endTime = jsonObject.getString("endTime"); |
| | | List<Integer> weeks = jsonObject.getJSONArray("weeks").toJavaList(Integer.class); |
| | | Double cashPayment2 = jsonObject.getDouble("cashPayment"); |
| | | Date startDate_date = sdf.parse(startDate); |
| | | Date endDate_date = sdf.parse(endDate); |
| | | long timeMillis = System.currentTimeMillis(); |
| | | if(timeMillis >= startDate_date.getTime() && timeMillis < endDate_date.getTime()){ |
| | | Date date = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int week = calendar.get(Calendar.DAY_OF_WEEK); |
| | | boolean isFirstSunday = (calendar.getFirstDayOfWeek() == Calendar.SUNDAY); |
| | | if(isFirstSunday){ |
| | | week = week - 1; |
| | | if(week == 0){ |
| | | week = 7; |
| | | } |
| | | } |
| | | if(!weeks.contains(week)){ |
| | | continue; |
| | | } |
| | | |
| | | String[] split1 = startTime.split(":"); |
| | | Integer hour1 = Integer.valueOf(split1[0]); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, hour1); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(split1[1])); |
| | | s.set(Calendar.SECOND, Integer.valueOf(split1[2])); |
| | | |
| | | String[] split2 = endTime.split(":"); |
| | | Integer hour2 = Integer.valueOf(split2[0]); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, hour2); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(split2[1])); |
| | | e.set(Calendar.SECOND, Integer.valueOf(split2[2])); |
| | | |
| | | if(hour1 > hour2){ |
| | | if(s.getTimeInMillis() > date.getTime()){ |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) - 1); |
| | | }else{ |
| | | e.set(Calendar.DAY_OF_YEAR, e.get(Calendar.DAY_OF_YEAR) + 1); |
| | | } |
| | | } |
| | | if(timeMillis >= s.getTimeInMillis() && timeMillis < e.getTimeInMillis() && paymentPrice.compareTo(cashPayment2) > 0){ |
| | | paymentPrice = cashPayment2; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | coursePackagePaymentConfigVo.setPaymentPrice(paymentPrice); |
| | | |
| | | |
| | | TCoursePackageDiscount discount = coursePackageDiscountService.getOne(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 2).eq("auditStatus", 2)); |
| | | |
| | | Double continuingMember = JSON.parseObject(discount.getContent()).getDouble("continuingUser"); |
| | | Double vipcontinuingMember = JSON.parseObject(discount.getContent()).getDouble("continuingMember"); |
| | | |
| | | |
| | | if (coursePackagePaymentConfigVo.getPaymentPrice()>continuingMember){ |
| | | coursePackagePaymentConfigVo.setPaymentPrice(continuingMember); |
| | | } |
| | | if (coursePackagePaymentConfigVo.getVipPrice()>vipcontinuingMember){ |
| | | coursePackagePaymentConfigVo.setVipPrice(vipcontinuingMember); |
| | | } |
| | | |
| | | |
| | | if (coursePackagePaymentConfigVo.getPaymentPrice()<coursePackagePaymentConfigVo.getVipPrice()){ |
| | | coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | coursePackagePaymentConfigVo.setVipPrice(null); |
| | | } |
| | | |
| | | } |
| | | else{ |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount3 : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount3.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | | coursePackagePaymentConfigVo.setPaymentPrice(vipPrice); |
| | | coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | } |
| | | list.add(coursePackagePaymentConfigVo); |
| | | }); |
| | | response.setList(list); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | return response; |
| | | } |
| | |
| | | |
| | | public ResultUtil AlipayPayment(String code, BigDecimal request){ |
| | | TCoursePackagePaymentMapper baseMapper1 = this.baseMapper; |
| | | ResultUtil alipay = payMoneyUtil.alipay("课包购买", "", "", code, request.toString(), |
| | | ResultUtil alipay = payMoneyUtil.alipay("课包购买", "课包购买", "", code, request.toString(), |
| | | "/base/coursePackage/alipayRegisteredCoursesCallback"); |
| | | if(alipay.getCode() == 200){ |
| | | new Thread(new Runnable() { |
| | |
| | | if(coursePackagePayment.getPayStatus() == 2){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode() == 200 && coursePackagePayment.getPayStatus() == 1){ |
| | | AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(code); |
| | | |
| | | if(coursePackagePayment.getPayStatus() == 1){ |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("tradeStatus"); |
| | | String tradeNo = data1.get("tradeNo"); |
| | | // Map<String, String> data1 = resultUtil.getData(); |
| | | String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){ |
| | | coursePackagePayment.setState(3); |
| | | baseMapper1.deleteById(coursePackagePayment.getId()); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<RecordAppoint> obtainStuClassDetails(Integer stuId, Integer appUserId) { |
| | | public List<RecordAppoint> obtainStuClassDetails(Integer stuId, Integer appUserId,Integer pageNum) { |
| | | List<RecordAppoint> recordVoList = new ArrayList<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = this.baseMapper.selectList(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("studentId",stuId ) |
| | |
| | | .eq("payStatus",2 ) |
| | | .eq("status",1 ) |
| | | .orderByDesc("insertTime")); |
| | | |
| | | List<Integer> ids = new ArrayList<>(); |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | ids.add(tCoursePackagePayment.getCoursePackageId()); |
| | | } |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd"); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); |
| | | if (tCoursePackagePayments.size() > 0 ){ |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | |
| | | List<CoursePackageStudent> coursePackageStudent1 = cpsMapper.selectList(new QueryWrapper<CoursePackageStudent>() |
| | | .eq("coursePackageId",tCoursePackagePayment.getCoursePackageId() ) |
| | | .eq("studentId",stuId) |
| | | .eq("appUserId",appUserId) |
| | | .eq("reservationStatus",1)); |
| | | if (ToolUtil.isNotEmpty(coursePackageStudent1) && coursePackageStudent1.size() > 0){ |
| | | // int pageNum = 1; // 页码 |
| | | int pageSize = 10; // 每页记录数 |
| | | Page<CoursePackageStudent> page = new Page<>(pageNum, pageSize); |
| | | |
| | | // for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | // List<CoursePackageStudent> coursePackageStudent1 = cpsMapper.selectList(new QueryWrapper<CoursePackageStudent>() |
| | | // .in("coursePackageId",ids) |
| | | // .eq("studentId",stuId) |
| | | // .eq("appUserId",appUserId) |
| | | // .eq("reservationStatus",1)); |
| | | IPage<CoursePackageStudent> coursePackageStudentPage = cpsMapper.selectPage(page, new QueryWrapper<CoursePackageStudent>() |
| | | .in("coursePackageId", ids) |
| | | .eq("studentId", stuId) |
| | | .eq("appUserId", appUserId) |
| | | .eq("reservationStatus", 1)); |
| | | List<CoursePackageStudent> coursePackageStudent1 = coursePackageStudentPage.getRecords(); |
| | | |
| | | |
| | | if (ToolUtil.isNotEmpty(coursePackageStudent1) && coursePackageStudent1.size() > 0){ |
| | | TCoursePackage coursePackage = new TCoursePackage(); |
| | | Integer coursePackageId = -1; |
| | | for (CoursePackageStudent coursePackageStudent : coursePackageStudent1) { |
| | | RecordAppoint recordVo = new RecordAppoint(); |
| | | recordVo.setCoursePackageId(tCoursePackagePayment.getCoursePackageId()); |
| | | recordVo.setCoursePackageId(coursePackageStudent.getCoursePackageId()); |
| | | |
| | | TCoursePackage coursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); |
| | | if (!coursePackageStudent.getCoursePackageId().equals(coursePackageId)) { |
| | | coursePackage = tcpmapper.selectById(coursePackageStudent.getCoursePackageId()); |
| | | coursePackageId = coursePackageStudent.getCoursePackageId(); |
| | | } |
| | | |
| | | |
| | | recordVo.setSid(Arrays.asList(coursePackage.getStoreId())); |
| | | List<Integer> rid = stoClient.querySiteId(coursePackage.getStoreId()); |
| | | recordVo.setRid(rid); |
| | | recordVo.setUserId(appUserId); |
| | | recordVo.setSiteId(coursePackage.getSiteId()); |
| | | List<Integer> ids = getIds(coursePackage.getSiteId()); |
| | | recordVo.setIds(ids); |
| | | List<Integer> ids1 = getIds(coursePackage.getSiteId()); |
| | | recordVo.setIds(ids1); |
| | | |
| | | recordVo.setCoursePackageName(coursePackage.getName()); |
| | | recordVo.setCourseHours(tCoursePackagePayment.getClassHours()); |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | if (Objects.equals(coursePackageStudent.getCoursePackageId(), tCoursePackagePayment.getCoursePackageId())){ |
| | | recordVo.setCourseHours(tCoursePackagePayment.getClassHours()); |
| | | |
| | | } |
| | | } |
| | | |
| | | // recordVo.setCourseHours(tCoursePackagePayment.getClassHours()); |
| | | Date date = DateUtil.getDate(); |
| | | |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | recordVo.setTimeFrame(simpleDateFormat.format(date)+" "+classStartTime+"-"+classEndTime); |
| | | |
| | | CoursePackageScheduling byId = coursePackageSchedulingService.getById(coursePackageStudent.getCoursePackageSchedulingId()); |
| | | // String classStartTime = coursePackage.getClassStartTime(); |
| | | // String classEndTime = coursePackage.getClassEndTime(); |
| | | //这里是过滤今天之后的数据 |
| | | |
| | | // if (byId == null||byId.getClassDate().after(new Date())){ |
| | | // continue; |
| | | // } |
| | | |
| | | if (byId == null){ |
| | | continue; |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String dateString1 = sdf.format(byId.getClassDate()); |
| | | String dateString2 = sdf.format(byId.getEndDate()); |
| | | |
| | | |
| | | recordVo.setTimeFrame(dateString1 + "-" + dateString2.substring(11)); |
| | | |
| | | // recordVo.setTimeFrame(simpleDateFormat.format(date)+" "+classStartTime+"-"+classEndTime); |
| | | Store store = stoClient.queryStoreById(coursePackage.getStoreId()); |
| | | recordVo.setStoreNameAddr(store.getName()+store.getAddress()); |
| | | recordVo.setCourseStuRecordId(coursePackageStudent.getId()); |
| | |
| | | List<String> integerList = Arrays.asList(split); |
| | | String weekOfDate = DateTimeHelper.getWeekOfDate(new Date()); |
| | | if (integerList.contains(weekOfDate)){ |
| | | String dat = simpleDateFormat.format(date) +" "+ classStartTime; |
| | | String dat = simpleDateFormat.format(byId.getClassDate()) +" "+ dateString1.substring(11); |
| | | |
| | | Date start = null; |
| | | try { |
| | |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (start.after(new Date())){ |
| | | recordVo.setStatus(1); |
| | | }else if(coursePackageStudent.getSignInOrNot()==2){ |
| | | //已取消 |
| | | if (byId.getStatus()==4){ |
| | | recordVo.setStatus(4); |
| | | } else if(coursePackageStudent.getSignInOrNot()==2){ |
| | | //已请假 |
| | | recordVo.setStatus(5); |
| | | }else { |
| | | } |
| | | else if (start.after(new Date())){ |
| | | //待上课 |
| | | recordVo.setStatus(1); |
| | | } |
| | | // else if(coursePackageStudent.getSignInOrNot()==2){ |
| | | // recordVo.setStatus(5); |
| | | // } |
| | | else { |
| | | // CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | // .eq("coursePackageId",coursePackageStudent.getCoursePackageId())); |
| | | CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | .eq("coursePackageId",tCoursePackagePayment.getCoursePackageId() )); |
| | | .eq("coursePackageSchedulingId",byId.getId()).last("limit 1")); |
| | | if (ToolUtil.isNotEmpty(cancelledClasses)){ |
| | | recordVo.setStatus(3); |
| | | // 消课 到课状态0 旷课 |
| | |
| | | } |
| | | |
| | | }else { |
| | | recordVo.setStatus(2); |
| | | Date now = new Date(); |
| | | if (now.after(byId.getClassDate())&&now.before(byId.getEndDate())){ |
| | | recordVo.setStatus(2); |
| | | }else { |
| | | recordVo.setStatus(3); |
| | | |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | |
| | | return recordVoList; |
| | | } |
| | | public List<Integer> getIds(Integer siteId) { |
| | |
| | | ArrayList<PayCourseRes> payCourseRes = new ArrayList<>(); |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | TCoursePackage tCoursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); |
| | | if (tCoursePackage.getType()!=1){ |
| | | continue; |
| | | } |
| | | if(tCoursePackage.getStoreId().equals(storeId)){ |
| | | PayCourseRes payCourseRes1 = new PayCourseRes(); |
| | | payCourseRes1.setId(tCoursePackagePayment.getId()); |
| | |
| | | return integers; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | List<Integer> week = week("周一,周二"); |
| | | // 今天周几 |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | @Autowired |
| | | private TCoursePackageService packageService; |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("MM.dd"); |
| | | |
| | | ArrayList<String> strings = new ArrayList<>(); |
| | | for (Integer integer : week) { |
| | | if(integer<i){ |
| | | // 找下一周的时间 |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7-(i-integer)); |
| | | Date time = instance.getTime(); |
| | | strings.add(format.format(time)); |
| | | @Autowired |
| | | private TCoursePackagePaymentService packagePaymentService; |
| | | @Autowired |
| | | private CoursePackageStudentService coursePackageStudentService; |
| | | |
| | | }else if(integer>i) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,integer-i); |
| | | Date time = instance.getTime(); |
| | | strings.add(format.format(time)); |
| | | }else { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time = instance.getTime(); |
| | | strings.add(format.format(time)); |
| | | } |
| | | } |
| | | System.out.println(strings); |
| | | } |
| | | @Autowired |
| | | private CourseCounsumService courseCounsumService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) |
| | | public ResultUtil payCourse(PayCourseReq req,Integer userId){ |
| | | public ResultUtil payCourse(PayCourseReq req,Integer userId) throws ParseException { |
| | | // 扣除 原来的课时数 |
| | | // 添加购买课时 paytyoe为7 |
| | | // 排课可期 判断课程时间段 添加排课表 添加上课记录表 |
| | |
| | | this.baseMapper.updateHoursById(tCoursePackagePayment.getId(),-req.getNum()); |
| | | |
| | | |
| | | List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", tCoursePackagePayment.getStudentId()).eq("coursePackageId", tCoursePackagePayment.getCoursePackageId())); |
| | | List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | |
| | | List<CoursePackageScheduling> list = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id", collect).le("classDate", new Date())); |
| | | coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id",collect).le("classDate", new Date())); |
| | | List<Long> collect1 = list.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); |
| | | |
| | | |
| | | // coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id",collect)); |
| | | coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", tCoursePackagePayment.getStudentId()).eq("coursePackageId", tCoursePackagePayment.getCoursePackageId())); |
| | | |
| | | TCoursePackage tCoursePackage = tcpmapper.selectById(req.getCourseId()); |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | List<Integer> week = week(classWeeks); |
| | | |
| | | TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", tCoursePackagePayment.getCoursePackageId()).eq("studentId", tCoursePackagePayment.getStudentId())); |
| | | |
| | | |
| | | Date today = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DATE, -1); |
| | | today = calendar.getTime(); |
| | | |
| | | Integer laveClassHours = pay.getLaveClassHours(); |
| | | Integer codeTime = tCoursePackage.getCodeTime(); |
| | | Integer can = laveClassHours/codeTime; |
| | | |
| | | int count = 0; |
| | | String[] split = tCoursePackage.getClassStartTime().split(","); |
| | | String[] split1 = tCoursePackage.getClassEndTime().split(","); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | |
| | | Date[] dates = generateDateArray(14,today); |
| | | for (Date date : dates) { |
| | | if (count==can){ |
| | | break; |
| | | } |
| | | int wei = cn.hutool.core.date.DateUtil.dayOfWeek(date); |
| | | if (week.contains(wei)){ |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | if (count==can){ |
| | | break; |
| | | } |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(date) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(date) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(pay.getAppUserId()); |
| | | student1.setStudentId(pay.getStudentId()); |
| | | student1.setCoursePackageId(pay.getCoursePackageId()); |
| | | student1.setCoursePackagePaymentId(pay.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | coursePackageStudentService.save(student1); |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // TCoursePackage tCoursePackage = tcpmapper.selectById(req.getCourseId()); |
| | | // 添加课包 |
| | | TCoursePackagePayment tCoursePackagePayment1 = new TCoursePackagePayment(); |
| | | tCoursePackagePayment1.setAppUserId(userId); |
| | | Student student = studentClient.queryDefaultStudent(userId); |
| | | // student ID |
| | | Integer sId=null; |
| | | if(student!=null){ |
| | | tCoursePackagePayment1.setStudentId(student.getId()); |
| | | sId=student.getId(); |
| | | } |
| | | // tCoursePackagePayment1.setAppUserId(userId); |
| | | // Student student = studentClient.queryDefaultStudent(userId); |
| | | // // student ID |
| | | // |
| | | // Integer sId=null; |
| | | // if(student!=null){ |
| | | // tCoursePackagePayment1.setStudentId(student.getId()); |
| | | // sId=student.getId(); |
| | | // } |
| | | tCoursePackagePayment1.setCoursePackageId(tCoursePackage.getId()); |
| | | tCoursePackagePayment1.setStudentId(req.getStuId()); |
| | | tCoursePackagePayment1.setPayType(7); |
| | | tCoursePackagePayment1.setClassHours(req.getNum()); |
| | | tCoursePackagePayment1.setOriginalPrice(0.0); |
| | |
| | | tCoursePackagePayment1.setPayStatus(2); |
| | | tCoursePackagePayment1.setPayUserId(userId); |
| | | tCoursePackagePayment1.setStatus(1); |
| | | tCoursePackagePayment1.setAppUserId(userId); |
| | | tCoursePackagePayment1.setState(1); |
| | | tCoursePackagePayment1.setInsertTime(new Date()); |
| | | this.baseMapper.insert(tCoursePackagePayment1); |
| | | // 找出课包时间段 |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String classStartTime = tCoursePackage.getClassStartTime(); |
| | | String classEndTime = tCoursePackage.getClassEndTime(); |
| | | String[] split = classStartTime.split(","); |
| | | String[] split1 = classEndTime.split(","); |
| | | String[] split5 = classStartTime.split(","); |
| | | String[] split6 = classEndTime.split(","); |
| | | List<String> time = req.getTime(); |
| | | for (String s : time) { |
| | | for (int i = 0; i < split.length; i++) { |
| | | for (int i = 0; i < split5.length; i++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | try { |
| | | Date parse = format.parse(s + " " + split[i]); |
| | | Date parse1 = format.parse(s + " " + split1[i]); |
| | | Date parse = format.parse(s + " " + split5[i]); |
| | | Date parse1 = format.parse(s + " " + split6[i]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(userId); |
| | | student1.setStudentId(sId); |
| | | student1.setStudentId(req.getStuId()); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(tCoursePackagePayment1.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | |
| | | |
| | | |
| | | // 2.0 |
| | | TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); |
| | | tCourseInfoRecord.setUserId(userId); |
| | | tCourseInfoRecord.setCourseId(req.getCourseId()); |
| | | tCourseInfoRecord.setName("体验购课"); |
| | | tCourseInfoRecord.setNum(req.getNum()); |
| | | tCourseInfoRecord.setTime(new Date()); |
| | | tCourseInfoRecord.setType(2); |
| | | appuClient.addCourseInfoRecord(tCourseInfoRecord); |
| | | // TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); |
| | | // tCourseInfoRecord.setUserId(userId); |
| | | // tCourseInfoRecord.setCourseId(req.getCourseId()); |
| | | // tCourseInfoRecord.setName("体验购课"); |
| | | // tCourseInfoRecord.setNum(req.getNum()); |
| | | // tCourseInfoRecord.setTime(new Date()); |
| | | // tCourseInfoRecord.setType(2); |
| | | // appuClient.addCourseInfoRecord(tCourseInfoRecord); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(tCoursePackagePayment.getId()); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setNum(req.getNum()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("体验购课"); |
| | | courseCounsum.setAppUserId(userId); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | |
| | | |
| | | if(tCoursePackagePayment.getLaveClassHours()<=3){ |
| | |
| | | |
| | | @Override |
| | | public boolean updateHoursById(TCoursePackagePayment byId, int i) { |
| | | return this.baseMapper.updateHoursById(byId.getId(),i); |
| | | return this.baseMapper.updateHoursById1(byId.getId(),i); |
| | | } |
| | | |
| | | |
| | | |
| | | 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; |
| | | } |
| | | |
| | | } |