nickchange
2023-11-24 18b58aaf9bd99cadd0e7f80fe5d80586f2f4831a
cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java
@@ -377,11 +377,36 @@
        return "ERROR";
    }
    @Autowired
    private TOrderService orderService;
    @Override
    public List<RegisterCourseVo> queryRegisteredCourseList(CourseOfAfterRequest courseTypeId, Integer appUserId) {
        List<RegisterCourseVo> courseVos = new ArrayList<>();
        List<TCoursePackagePayment> tCoursePackagePayments = this.list(new QueryWrapper<TCoursePackagePayment>()
                .eq("appUserId",appUserId ));
        List<TOrder> orders = orderService.list(new QueryWrapper<TOrder>().eq("appUserId", appUserId));
        List<String> paysId = new ArrayList<>();
        List<TCoursePackagePayment> tCoursePackagePayments = new ArrayList<>();
        for (TOrder order : orders) {
            String[] split = order.getPaysId().split(",");
//            paysId.add(split[0]);
            TCoursePackagePayment byId = this.getById(split[0]);
            byId.setPayStatus(order.getIsPay());
            byId.setOrderId(order.getId());
            tCoursePackagePayments.add(byId);
        }
//        List<TCoursePackagePayment> tCoursePackagePayments = this.list(new QueryWrapper<TCoursePackagePayment>()
//                .eq("appUserId",appUserId ));
//        List<TCoursePackagePayment> tCoursePackagePayments = this.list(new QueryWrapper<TCoursePackagePayment>()
//                .in("id",paysId ));
        System.out.println(tCoursePackagePayments);
        if (tCoursePackagePayments.size() > 0){
            try {
@@ -392,6 +417,7 @@
                    // 2.0
                    registerCourseVo.setType(coursePackage.getType());
                    registerCourseVo.setOrderId(tCoursePackagePayment.getOrderId());
                    registerCourseVo.setCoursePayId(tCoursePackagePayment.getId());
                    registerCourseVo.setCoursePackageId(tCoursePackagePayment.getCoursePackageId());
                    registerCourseVo.setCoursePackTypeId(coursePackage.getCoursePackageTypeId());
@@ -436,7 +462,9 @@
//                        registerCourseVo.setCourseNums(coursePackageStudents.size() * 2);
                        registerCourseVo.setCourseNums(counts);
                    }
//                    registerCourseVo.setPayStatus(tCoursePackagePayment.getPayStatus());
                    registerCourseVo.setPayStatus(tCoursePackagePayment.getPayStatus());
                    courseVos.add(registerCourseVo);
                }
            }catch (Exception e){
@@ -470,17 +498,19 @@
    @Autowired
    private  TCoursePackageDiscountService coursePackageDiscountService;
    @Resource StoreClient storeClient;
    @Override
    public CourseDetailsResponse queryRegisteredCourseDetails(Long coursePayId, Integer appUserId) {
    public CourseDetailsResponse queryRegisteredCourseDetails(Long coursePayId, Integer appUserId,String lon,String lat) {
        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);
//        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());
@@ -490,17 +520,17 @@
                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);
//            }
            Store store = storeClient.queryStoreById(coursePackage.getStoreId());
            response.setStoreName(store.getName());
            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());