liujie
2023-08-08 fece6af66e0cfaf95896227a791810c79bafd2e8
cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
@@ -10,10 +10,12 @@
import com.dsh.account.feignclient.activity.UserConponClient;
import com.dsh.account.feignclient.activity.model.*;
import com.dsh.account.feignclient.competition.DeductionCompetitionsClient;
import com.dsh.account.feignclient.competition.model.BillingDataRequestVo;
import com.dsh.account.feignclient.competition.model.PaymentCompetition;
import com.dsh.account.feignclient.course.CoursePackageClient;
import com.dsh.account.feignclient.course.CoursePackageConfigClient;
import com.dsh.account.feignclient.course.CoursePaymentClient;
import com.dsh.account.feignclient.course.VideoOfCourseListClient;
import com.dsh.account.feignclient.course.model.*;
import com.dsh.account.feignclient.other.ImgConfigClient;
import com.dsh.account.feignclient.other.RechargeConfigClient;
@@ -97,6 +99,10 @@
    @Resource
    private ImgConfigClient icfgClient;
    @Resource
    private VideoOfCourseListClient voclClient;
    @Resource
    private VipPaymentMapper vipPaymentMapper;
@@ -154,7 +160,9 @@
                List<RegisteredCourse> courseList = new ArrayList<>();
                List<StuCourseResp> stuCoursePayment = paymentClient.getStuCoursePayment(tStudent.getId());
                List<Integer> coursePackIds = new ArrayList<>();
                if (stuCoursePayment.size() > 0){
                    coursePackIds = stuCoursePayment.stream().map(StuCourseResp::getCourseId).collect(Collectors.toList());
                    for (StuCourseResp tCoursePackagePayment : stuCoursePayment) {
                        RegisteredCourse course = new RegisteredCourse();
                        course.setCourseId(tCoursePackagePayment.getCourseId());
@@ -162,14 +170,14 @@
                        course.setTotalNums(ToolUtil.isEmpty(tCoursePackagePayment.getTotalCourseNums()) ? 0 : tCoursePackagePayment.getTotalCourseNums());
                        course.setDeductedNums(ToolUtil.isEmpty(tCoursePackagePayment.getDeductionNums()) ? 0 : tCoursePackagePayment.getDeductionNums());
                        course.setRemainingNums(ToolUtil.isEmpty(tCoursePackagePayment.getResidueNums())? 0 : tCoursePackagePayment.getResidueNums());
                        course.setPeriodOfValidity(tCoursePackagePayment.getPeriodOfValidity());
                        courseList.add(course);
                    }
                }
                classInfoVo.setCourseList(courseList);
                List<ExerciseVideo> videos = new ArrayList<>();
                classInfoVo.setExerciseVideoList(videos);
                List<ExerciseVideo> stuCourseOfVideoList = voclClient.getStuCourseOfVideoList(coursePackIds);
                System.out.println(stuCourseOfVideoList);
                classInfoVo.setExerciseVideoList(stuCourseOfVideoList);
            }else {
                classInfoVo.setIsThere(2);
                List<TImgConfig> tImgConfigs = configClient.getNoneStuImgs();
@@ -197,9 +205,12 @@
            CourseVenue courseVenue = new CourseVenue();
            courseVenue.setStoreId(storeId);
            courseVenue.setAreaName(value.get(0).getCourseName());
            courseVenue.setSiteDistance(LonlatUtils.distance(Double.parseDouble(longitude), Double.parseDouble(latitude),
                    Double.parseDouble(value.get(0).getLon()), Double.parseDouble(value.get(0).getLat())) + "");
            if (ToolUtil.isEmpty(longitude) && ToolUtil.isEmpty(latitude)){
                courseVenue.setSiteDistance(0+"");
            }else {
                courseVenue.setSiteDistance(LonlatUtils.distance(Double.parseDouble(longitude), Double.parseDouble(latitude),
                        Double.parseDouble(value.get(0).getLon()), Double.parseDouble(value.get(0).getLat())) + "");
            }
            List<CourseVenue.CouList> courses = new ArrayList<>();
            for (CourseOfStoreVo courseOfStoreVo : value) {
                CourseVenue.CouList couList = new CourseVenue.CouList();
@@ -207,6 +218,7 @@
                couList.setCourseName(courseOfStoreVo.getCourseName());
                couList.setTimeStr(courseOfStoreVo.getClassStartTime() + "-" + courseOfStoreVo.getClassEndTime());
                couList.setDetail("¥" + courseOfStoreVo.getCoursePrice() + "/会员扣2学时");
                couList.setStatus(courseOfStoreVo.getStatus());
                courses.add(couList);
            }
            courseVenue.setCourses(courses);
@@ -477,12 +489,15 @@
        TAppUser appUser = this.getById(appUserId);
        benefirVo.setUserHeadImg(appUser.getHeadImg());
        benefirVo.setUserName(appUser.getName());
        benefirVo.setWpCoin(ToolUtil.isEmpty(appUser.getPlayPaiCoins()) ? 0 : appUser.getPlayPaiCoins());
        benefirVo.setUserIntegral(ToolUtil.isEmpty(appUser.getIntegral()) ? 0 : appUser.getIntegral());
        if (appUser.getIsVip() == 1){
            benefirVo.setIsMember("年度会员");
        }else {
            benefirVo.setIsMember("普通用户");
        }
        benefirVo.setCommodities(mcClient.getConvertibleGoods());
        List<IntegralCommodity> convertibleGoods = mcClient.getConvertibleGoods();
        benefirVo.setCommodities(convertibleGoods);
        benefirVo.setImage(icfgClient.getImageConfig());
        return benefirVo;
    }
@@ -501,8 +516,13 @@
            monthStart = DateTimeHelper.getCurrentMouthStart();
            monthEnd = DateTimeHelper.getCurrentMouthEnd();
        }
        BillingDataRequestVo requestVo = new BillingDataRequestVo();
        requestVo.setMonthStart(monthStart);
        requestVo.setMonthEnd(monthEnd);
        requestVo.setAppUserId(appUserId);
//            1.赛事报名
        List<PaymentCompetition> allCompetitionPayRecord = deducClient.getAllCompetitionPayRecord(appUserId);
        List<PaymentCompetition> allCompetitionPayRecord = deducClient.getAllCompetitionPayRecord(requestVo);
        if (allCompetitionPayRecord.size() > 0 ){
            for (PaymentCompetition paymentCompetition : allCompetitionPayRecord) {
                ConsumeDetail consumeDetail = new ConsumeDetail();
@@ -510,32 +530,35 @@
                consumeDetail.setConsumeTime(simpleDateFormat.format(paymentCompetition.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + paymentCompetition.getAmount());
                details.add(consumeDetail);
                consumeDetail.setType(1);
            }
        }
//            2.取消赛事报名
        List<PaymentCompetition> cancelOrderOfUserPayRecord = deducClient.getCancelOrderOfUserPayRecord(appUserId);
        List<PaymentCompetition> cancelOrderOfUserPayRecord = deducClient.getCancelOrderOfUserPayRecord(requestVo);
        if (cancelOrderOfUserPayRecord.size() > 0 ){
            for (PaymentCompetition paymentCompetition : cancelOrderOfUserPayRecord) {
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.CANCEL_EVENT_REGISTRATION.getMsg());
                consumeDetail.setConsumeTime(simpleDateFormat.format(paymentCompetition.getInsertTime()));
                consumeDetail.setConsumeAmount("+" + paymentCompetition.getAmount());
                consumeDetail.setType(1);
                details.add(consumeDetail);
            }
        }
//            3.课包购买
        List<TCoursePackagePayment> amountPayRecord = paymentClient.getAmountPayRecord(appUserId);
        List<TCoursePackagePayment> amountPayRecord = paymentClient.getAmountPayRecord(requestVo);
        if (amountPayRecord.size() > 0 ){
            for (TCoursePackagePayment coursePackagePayment : amountPayRecord) {
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg());
                consumeDetail.setConsumeTime(simpleDateFormat.format(coursePackagePayment.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + coursePackagePayment.getCashPayment());
                consumeDetail.setType(2);
                details.add(consumeDetail);
            }
        }
//            4.场地预约
        List<SiteBooking> allSiteBookingList = stClient.getAllSiteBookingList(appUserId);
        List<SiteBooking> allSiteBookingList = stClient.getAllSiteBookingList(requestVo);
        if (allSiteBookingList.size() >  0){
            for (SiteBooking booking : allSiteBookingList) {
                ConsumeDetail consumeDetail = new ConsumeDetail();
@@ -543,10 +566,12 @@
                    consumeDetail.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.getMsg());
                    consumeDetail.setConsumeAmount("-" + booking.getPayMoney());
                    consumeDetail.setConsumeTime(simpleDateFormat.format(booking.getPayTime()));
                    consumeDetail.setType(2);
                }else {
                    consumeDetail.setConsumeName(RechargeRecordEnum.CANCEL_VENUE_RESERVATION.getMsg());
                    consumeDetail.setConsumeAmount("+" + booking.getPayMoney());
                    consumeDetail.setConsumeTime(simpleDateFormat.format(booking.getCancelTime()));
                    consumeDetail.setType(1);
                }
                details.add(consumeDetail);
            }
@@ -564,6 +589,7 @@
                consumeDetail.setConsumeName(RechargeRecordEnum.ANNUAL_MEMBERSHIP.getMsg());
                consumeDetail.setConsumeTime(simpleDateFormat.format(vipPayment.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + vipPayment.getAmount());
                consumeDetail.setType(2);
                details.add(consumeDetail);
            }
        }
@@ -578,6 +604,7 @@
                consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.getMsg() + ":" + rechargeRecord.getPlayPaiCoins());
                consumeDetail.setConsumeTime(simpleDateFormat.format(rechargeRecord.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + rechargeRecord.getAmount());
                consumeDetail.setType(2);
                details.add(consumeDetail);
            }
        }
@@ -598,6 +625,12 @@
                    return date2.compareTo(date1);
                }
            });
            if (ToolUtil.isNotEmpty(recordId)){
                details = details.stream()
                        .filter(response -> Objects.equals(response.getType(), recordId))
                        .collect(Collectors.toList());
            }
        }
        return details;
    }
@@ -616,15 +649,16 @@
        List<RechargeCentVo> centVos = new ArrayList<>();
        TAppUser tAppUser = this.baseMapper.selectById(appUserId);
        List<Map<String, Object>> rechargeConfig = reconMapper.getRechargeConfig();
        System.out.println(rechargeConfig);
        if (rechargeConfig.size() > 0 ){
            for (Map<String, Object> stringObjectMap : rechargeConfig) {
                RechargeCentVo vo = new RechargeCentVo();
                vo.setChargeId((Integer) stringObjectMap.get("money"));
                vo.setAmount(""+stringObjectMap.get("money"));
                Double money = (Double) stringObjectMap.get("money");
                vo.setAmount(BigDecimal.valueOf(money) );
                if (tAppUser.getIsVip() == 1){
                    vo.setWpGold(stringObjectMap.get("MemberCoins")+"");
                    vo.setWpGold((Integer) stringObjectMap.get("MemberCoins"));
                }else {
                    vo.setWpGold(stringObjectMap.get("usersCoins")+"");
                    vo.setWpGold((Integer) stringObjectMap.get("usersCoins"));
                }
                centVos.add(vo);
            }
@@ -717,26 +751,34 @@
            }
        }
        if (StringUtils.hasText(request.getSearch())){
            goods = goods.stream()
                    .filter(merchandise -> merchandise.getGoodName().contains(request.getSearch()))
                    .collect(Collectors.toList());
            if (goods.size() > 0 ){
                goods = goods.stream()
                        .filter(merchandise -> merchandise.getGoodName().contains(request.getSearch()))
                        .collect(Collectors.toList());
            }
        }
        if (null != request.getRank()){
            switch (request.getRank()){
                case 1:
                    goods = goods.stream()
                            .sorted(Comparator.comparing(Goods::getIntegral).reversed())
                            .collect(Collectors.toList());
                    if (goods.size() > 0 ){
                        goods = goods.stream()
                                .sorted(Comparator.comparing(Goods::getIntegral).reversed())
                                .collect(Collectors.toList());
                    }
                    break;
                case 2:
                    goods = goods.stream()
                            .sorted(Comparator.comparing(Goods::getIntegral))
                            .collect(Collectors.toList());
                    if (goods.size() > 0 ){
                        goods = goods.stream()
                                .sorted(Comparator.comparing(Goods::getIntegral))
                                .collect(Collectors.toList());
                    }
                    break;
                case 3:
                    goods = goods.stream()
                            .sorted(Comparator.comparing(Goods::getNums).reversed())
                            .collect(Collectors.toList());
                    if (goods.size() > 0 ){
                        goods = goods.stream()
                                .sorted(Comparator.comparing(Goods::getNums).reversed())
                                .collect(Collectors.toList());
                    }
                    break;
                default:
                    break;
@@ -744,13 +786,22 @@
        }
        if (null != request.getGoodsType()){
            goods = goods.stream()
                    .filter(merchandise -> merchandise.getGoodsType().equals(request.getGoodsType()))
                    .collect(Collectors.toList());
            if (goods.size() > 0 ){
                goods = goods.stream()
                        .filter(merchandise -> merchandise.getGoodsType().equals(request.getGoodsType()))
                        .collect(Collectors.toList());
            }
        }
        Pageable pageable = PageRequest.of(request.getPageNum() - 1, request.getPageSize());
        Page<Goods> page = getPage(goods, pageable);
        return page.getContent();
        //当前第几页
        int pageNo = request.getPageNum();
        //一页五条
        int size = request.getPageSize();
        //分页
        goods = goods.stream().skip((pageNo - 1) * size).limit(size).
                collect(Collectors.toList());
        return goods;
    }
    // 对数据进行分页处理的方法
@@ -758,20 +809,6 @@
        int start = (int) pageable.getOffset();
        int end = Math.min((start + pageable.getPageSize()), dataList.size());
        return new PageImpl<>(dataList.subList(start, end), pageable, dataList.size());
    }
    @Override
    public ResultUtil uploadAppUserHeadImg(Integer appUserId, MultipartFile file, HttpServletRequest request) {
        try {
            String filePath = OssUploadUtil.ossUpload(request,file);
            TAppUser tAppUser = this.baseMapper.selectById(appUserId);
            tAppUser.setHeadImg(filePath);
            this.baseMapper.updateById(tAppUser);
        } catch (IOException e) {
            ResultUtil.error("头像上传失败!");
        }
        return ResultUtil.success();
    }
    @Override
@@ -1144,6 +1181,7 @@
        weeksOfCourseRest.setStuId(stuId);
        weeksOfCourseRest.setAppUserId(appUserId);
        List<CourseOfStoreVo> storeOfCourses = paymentClient.getStoreOfCourses(weeksOfCourseRest);
        System.out.println(storeOfCourses);
        if (storeOfCourses.size() > 0 ){
            courseVenues = dealDatas(storeOfCourses,longitude,latitude);
        }