From c743f4413a00fc063bbbd9d851b6d0c3fff10581 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期一, 31 七月 2023 10:04:02 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java | 68 ++++++++++++++++++--------------- 1 files changed, 37 insertions(+), 31 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 649cbd3..8cb1126 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 @@ -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; @@ -158,6 +162,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); } } @@ -484,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; @@ -502,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()); @@ -513,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()); @@ -524,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()); @@ -535,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()); @@ -557,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()); @@ -571,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()); @@ -579,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; @@ -596,8 +600,7 @@ } }); } - vo.setDetails(details); - return vo; + return details; } @Override @@ -617,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); } @@ -630,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()); @@ -645,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()); @@ -702,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()); @@ -728,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: @@ -751,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 -- Gitblit v1.7.1