From b64d67ef01e81a857046f19dd556b4e4f0695e1c Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期三, 02 八月 2023 16:41:51 +0800 Subject: [PATCH] 后台代码 门店管理 --- cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java | 67 +++++++++++++++++++++++---------- 1 files changed, 47 insertions(+), 20 deletions(-) diff --git a/cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java b/cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java index deb3dc6..ebc7574 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java +++ b/cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java @@ -10,6 +10,7 @@ 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; @@ -38,6 +39,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; @@ -158,6 +163,7 @@ 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); } } @@ -478,7 +484,8 @@ }else { benefirVo.setIsMember("普通用户"); } - benefirVo.setCommodities(mcClient.getConvertibleGoods()); + List<IntegralCommodity> convertibleGoods = mcClient.getConvertibleGoods(); + benefirVo.setCommodities(convertibleGoods); benefirVo.setImage(icfgClient.getImageConfig()); return benefirVo; } @@ -497,8 +504,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(); @@ -506,32 +518,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(); @@ -539,10 +554,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); } @@ -560,6 +577,7 @@ consumeDetail.setConsumeName(RechargeRecordEnum.ANNUAL_MEMBERSHIP.getMsg()); consumeDetail.setConsumeTime(simpleDateFormat.format(vipPayment.getInsertTime())); consumeDetail.setConsumeAmount("-" + vipPayment.getAmount()); + consumeDetail.setType(2); details.add(consumeDetail); } } @@ -574,6 +592,7 @@ consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.getMsg() + ":" + rechargeRecord.getPlayPaiCoins()); consumeDetail.setConsumeTime(simpleDateFormat.format(rechargeRecord.getInsertTime())); consumeDetail.setConsumeAmount("-" + rechargeRecord.getAmount()); + consumeDetail.setType(2); details.add(consumeDetail); } } @@ -594,6 +613,12 @@ return date2.compareTo(date1); } }); + + if (ToolUtil.isNotEmpty(recordId)){ + details = details.stream() + .filter(response -> Objects.equals(response.getType(), recordId)) + .collect(Collectors.toList()); + } } return details; } @@ -629,14 +654,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()); @@ -644,7 +663,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()); @@ -701,7 +720,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()); @@ -727,17 +746,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: @@ -750,8 +769,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 -- Gitblit v1.7.1