puzhibing
2023-07-31 c743f4413a00fc063bbbd9d851b6d0c3fff10581
cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
@@ -38,6 +38,10 @@
import com.dsh.account.util.*;
import com.dsh.account.util.akeylogin.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -149,29 +153,20 @@
                classInfoVo.setBodyStatus(BMIBodyUtil.getBodyStatus(tStudent.getBmi()));
                List<RegisteredCourse> courseList = new ArrayList<>();
//                总学时数
                int total = 0;
//                已扣数
                int deduct = 0;
//                剩余数
                int remain = 0;
                List<StuCourseResp> stuCoursePayment = paymentClient.getStuCoursePayment();
                List<StuCourseResp> stuCoursePayment = paymentClient.getStuCoursePayment(tStudent.getId());
                if (stuCoursePayment.size() > 0){
                    for (StuCourseResp tCoursePackagePayment : stuCoursePayment) {
                        RegisteredCourse course = new RegisteredCourse();
                        course.setCourseId(tCoursePackagePayment.getCourseId());
                        course.setCourseName(tCoursePackagePayment.getCourseName());
                        total = total + (ToolUtil.isEmpty(tCoursePackagePayment.getTotalCourseNums()) ? 0 : tCoursePackagePayment.getTotalCourseNums());
                        deduct = deduct + (ToolUtil.isEmpty(tCoursePackagePayment.getDeductionNums()) ? 0 : tCoursePackagePayment.getDeductionNums());
                        remain = remain + (ToolUtil.isEmpty(tCoursePackagePayment.getResidueNums())? 0 : tCoursePackagePayment.getResidueNums());
                        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);
                classInfoVo.setTotalNums(total);
                classInfoVo.setDeductedNums(deduct);
                classInfoVo.setRemainingNums(remain);
                List<ExerciseVideo> videos = new ArrayList<>();
@@ -494,9 +489,8 @@
    }
    @Override
    public BillingDetailsVo queryUserBillingDetails(String yearMonth, Integer recordId, Integer appUserId) {
        BillingDetailsVo vo = new BillingDetailsVo();
        List<BillingDetailsVo.ConsumeDetail> details = new ArrayList<>();
    public List<ConsumeDetail>  queryUserBillingDetails(String yearMonth, Integer recordId, Integer appUserId) {
        List<ConsumeDetail> details = new ArrayList<>();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm");
        Date monthStart = null;
@@ -512,7 +506,7 @@
        List<PaymentCompetition> allCompetitionPayRecord = deducClient.getAllCompetitionPayRecord(appUserId);
        if (allCompetitionPayRecord.size() > 0 ){
            for (PaymentCompetition paymentCompetition : allCompetitionPayRecord) {
                BillingDetailsVo.ConsumeDetail consumeDetail = new BillingDetailsVo.ConsumeDetail();
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.EVENT_REGISTRATION.getMsg());
                consumeDetail.setConsumeTime(simpleDateFormat.format(paymentCompetition.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + paymentCompetition.getAmount());
@@ -523,7 +517,7 @@
        List<PaymentCompetition> cancelOrderOfUserPayRecord = deducClient.getCancelOrderOfUserPayRecord(appUserId);
        if (cancelOrderOfUserPayRecord.size() > 0 ){
            for (PaymentCompetition paymentCompetition : cancelOrderOfUserPayRecord) {
                BillingDetailsVo.ConsumeDetail consumeDetail = new BillingDetailsVo.ConsumeDetail();
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.CANCEL_EVENT_REGISTRATION.getMsg());
                consumeDetail.setConsumeTime(simpleDateFormat.format(paymentCompetition.getInsertTime()));
                consumeDetail.setConsumeAmount("+" + paymentCompetition.getAmount());
@@ -534,7 +528,7 @@
        List<TCoursePackagePayment> amountPayRecord = paymentClient.getAmountPayRecord(appUserId);
        if (amountPayRecord.size() > 0 ){
            for (TCoursePackagePayment coursePackagePayment : amountPayRecord) {
                BillingDetailsVo.ConsumeDetail consumeDetail = new BillingDetailsVo.ConsumeDetail();
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg());
                consumeDetail.setConsumeTime(simpleDateFormat.format(coursePackagePayment.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + coursePackagePayment.getCashPayment());
@@ -545,7 +539,7 @@
        List<SiteBooking> allSiteBookingList = stClient.getAllSiteBookingList(appUserId);
        if (allSiteBookingList.size() >  0){
            for (SiteBooking booking : allSiteBookingList) {
                BillingDetailsVo.ConsumeDetail consumeDetail = new BillingDetailsVo.ConsumeDetail();
                ConsumeDetail consumeDetail = new ConsumeDetail();
                if (booking.getStatus() != 5){
                    consumeDetail.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.getMsg());
                    consumeDetail.setConsumeAmount("-" + booking.getPayMoney());
@@ -567,7 +561,7 @@
                .between("insertTime", monthStart, monthEnd));
        if (vipPayments.size() > 0) {
            for (VipPayment vipPayment : vipPayments) {
                BillingDetailsVo.ConsumeDetail consumeDetail = new BillingDetailsVo.ConsumeDetail();
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.ANNUAL_MEMBERSHIP.getMsg());
                consumeDetail.setConsumeTime(simpleDateFormat.format(vipPayment.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + vipPayment.getAmount());
@@ -581,7 +575,7 @@
                .between("insertTime", monthStart, monthEnd));
        if (rechargeRecords.size() > 0) {
            for (RechargeRecords rechargeRecord : rechargeRecords) {
                BillingDetailsVo.ConsumeDetail consumeDetail = new BillingDetailsVo.ConsumeDetail();
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.getMsg() + ":" + rechargeRecord.getPlayPaiCoins());
                consumeDetail.setConsumeTime(simpleDateFormat.format(rechargeRecord.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + rechargeRecord.getAmount());
@@ -589,9 +583,9 @@
            }
        }
        if (details.size() > 0 ){
            Collections.sort(details, new Comparator<BillingDetailsVo.ConsumeDetail>() {
            Collections.sort(details, new Comparator<ConsumeDetail>() {
                @Override
                public int compare(BillingDetailsVo.ConsumeDetail record1, BillingDetailsVo.ConsumeDetail record2) {
                public int compare(ConsumeDetail record1, ConsumeDetail record2) {
                    SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm");
                    Date date1 = null;
                    Date date2 = null;
@@ -606,8 +600,7 @@
                }
            });
        }
        vo.setDetails(details);
        return vo;
        return details;
    }
    @Override
@@ -627,11 +620,12 @@
        if (rechargeConfig.size() > 0 ){
            for (Map<String, Object> stringObjectMap : rechargeConfig) {
                RechargeCentVo vo = new RechargeCentVo();
                vo.setAmount("¥ "+stringObjectMap.get("money"));
                vo.setChargeId((Integer) stringObjectMap.get("money"));
                vo.setAmount(""+stringObjectMap.get("money"));
                if (tAppUser.getIsVip() == 1){
                    vo.setWpGold(stringObjectMap.get("MemberCoins")+"币");
                    vo.setWpGold(stringObjectMap.get("MemberCoins")+"");
                }else {
                    vo.setWpGold(stringObjectMap.get("usersCoins")+"币");
                    vo.setWpGold(stringObjectMap.get("usersCoins")+"");
                }
                centVos.add(vo);
            }
@@ -640,14 +634,8 @@
    }
    @Override
    public PointMallDetailsResponse queryAppUserIntegral(MallRequest request, Integer userIdFormRedis) {
        PointMallDetailsResponse detailsResponse = new PointMallDetailsResponse();
        List<PointMallDetailsResponse.Goods> goods = new ArrayList<>();
        TAppUser tAppUser = this.baseMapper.selectById(userIdFormRedis);
        detailsResponse.setName(tAppUser.getName());
        detailsResponse.setIntegral(tAppUser.getIntegral());
        detailsResponse.setHeadImg(tAppUser.getHeadImg());
    public List<Goods> queryAppUserIntegral(MallRequest request ) {
        List<Goods> goods = new ArrayList<>();
        CommodityRequest commodityRequest = new CommodityRequest();
        commodityRequest.setLon(request.getLon());
@@ -655,7 +643,7 @@
        List<PointsMerchandise> vicinityGoods = mcClient.getVicinityGoods(commodityRequest);
        if (vicinityGoods.size() > 0) {
            for (PointsMerchandise vicinityGood : vicinityGoods) {
                PointMallDetailsResponse.Goods commodity = new PointMallDetailsResponse.Goods();
                Goods commodity = new Goods();
                switch (vicinityGood.getType()) {
                    case 1:
                        commodity.setGoodId(vicinityGood.getId());
@@ -712,7 +700,7 @@
        List<Coupon> allCoupons = ucponClient.getAllCoupons(commodityRequest);
        if (allCoupons.size() > 0) {
            for (Coupon allCoupon : allCoupons) {
                PointMallDetailsResponse.Goods commodity = new PointMallDetailsResponse.Goods();
                Goods commodity = new Goods();
                commodity.setGoodId(allCoupon.getId());
                commodity.setGoodName(allCoupon.getName());
                commodity.setCondition(allCoupon.getRedemptionMethod());
@@ -738,17 +726,17 @@
            switch (request.getRank()){
                case 1:
                    goods = goods.stream()
                            .sorted(Comparator.comparing(PointMallDetailsResponse.Goods::getIntegral).reversed())
                            .sorted(Comparator.comparing(Goods::getIntegral).reversed())
                            .collect(Collectors.toList());
                    break;
                case 2:
                    goods = goods.stream()
                            .sorted(Comparator.comparing(PointMallDetailsResponse.Goods::getIntegral))
                            .sorted(Comparator.comparing(Goods::getIntegral))
                            .collect(Collectors.toList());
                    break;
                case 3:
                    goods = goods.stream()
                            .sorted(Comparator.comparing(PointMallDetailsResponse.Goods::getNums).reversed())
                            .sorted(Comparator.comparing(Goods::getNums).reversed())
                            .collect(Collectors.toList());
                    break;
                default:
@@ -761,8 +749,16 @@
                    .filter(merchandise -> merchandise.getGoodsType().equals(request.getGoodsType()))
                    .collect(Collectors.toList());
        }
        detailsResponse.setGoods(goods);
        return detailsResponse;
        Pageable pageable = PageRequest.of(request.getPageNum() - 1, request.getPageSize());
        Page<Goods> page = getPage(goods, pageable);
        return page.getContent();
    }
    // 对数据进行分页处理的方法
    private static Page<Goods> getPage(List<Goods> dataList, Pageable pageable) {
        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