| | |
| | | import com.dsh.account.feignclient.competition.DeductionCompetitionsClient; |
| | | import com.dsh.account.feignclient.competition.model.PaymentCompetition; |
| | | import com.dsh.account.feignclient.course.CoursePaymentClient; |
| | | import com.dsh.account.feignclient.course.model.CouponPaymentVo; |
| | | import com.dsh.account.feignclient.course.model.TCoursePackagePayment; |
| | | import com.dsh.account.feignclient.other.RechargeConfigClient; |
| | | import com.dsh.account.feignclient.other.SiteClient; |
| | |
| | | import com.dsh.account.model.vo.userBenefitDetail.RechargePayRequest; |
| | | import com.dsh.account.model.vo.userBenefitDetail.RechargesDetail; |
| | | import com.dsh.account.service.RechargeRecordsService; |
| | | import com.dsh.account.util.DateTimeHelper; |
| | | import com.dsh.account.util.PayMoneyUtil; |
| | | import com.dsh.account.util.ResultUtil; |
| | | import com.dsh.account.util.UUIDUtil; |
| | | import com.dsh.account.util.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.PageImpl; |
| | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.EVENT_REGISTRATION.getMsg() ); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(competition.getInsertTime())); |
| | | consumeDetail.setConsumeAmount("-" + competition.getAmount()); |
| | | consumeDetail.setRecordId(2); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | | // 2.课包购买 |
| | | List<TCoursePackagePayment> appuserCourseList = cpClient.getAppuserCourseList(appUserId); |
| | | List<CouponPaymentVo> appuserCourseList = cpClient.getAppuserCourseList(appUserId); |
| | | if (appuserCourseList.size() > 0){ |
| | | for (TCoursePackagePayment tCoursePackagePayment : appuserCourseList) { |
| | | for (CouponPaymentVo tCoursePackagePayment : appuserCourseList) { |
| | | RechargesDetail consumeDetail = new RechargesDetail(); |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg() ); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(tCoursePackagePayment.getInsertTime())); |
| | | consumeDetail.setConsumeAmount("-" + tCoursePackagePayment.getPlayPaiCoin()); |
| | | consumeDetail.setConsumeTime(tCoursePackagePayment.getTime()); |
| | | consumeDetail.setConsumeAmount("-" + tCoursePackagePayment.getAmount()); |
| | | consumeDetail.setRecordId(2); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.name()); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(booking.getInsertTime())); |
| | | consumeDetail.setConsumeAmount("-" + booking.getPayMoney()); |
| | | consumeDetail.setRecordId(2); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.name() + ":" + rechargeRecord.getPlayPaiCoins()); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(rechargeRecord.getInsertTime())); |
| | | consumeDetail.setConsumeAmount("+" + rechargeRecord.getAmount()); |
| | | consumeDetail.setRecordId(1); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | | if (ToolUtil.isNotEmpty(recordId)){ |
| | | details = details.stream() |
| | | .filter(record -> record.getRecordId().equals(recordId)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | if (details.size() > 0 ){ |
| | | Collections.sort(details, new Comparator<RechargesDetail>() { |
| | |
| | | } |
| | | }); |
| | | } |
| | | Pageable pageable = PageRequest.of(pageNum - 1, pageSize); |
| | | Page<RechargesDetail> page = getPage(details, pageable); |
| | | return page.getContent(); |
| | | //当前第几页 |
| | | int pageNo = pageNum; |
| | | //一页五条 |
| | | int size = pageSize; |
| | | |
| | | //分页 |
| | | details = details.stream().skip((pageNo - 1) * size).limit(size). |
| | | collect(Collectors.toList()); |
| | | |
| | | return details; |
| | | } |
| | | |
| | | @Override |
| | |
| | | BigDecimal amount = BigDecimal.ZERO; |
| | | if (rechargeConfig.size() > 0){ |
| | | for (Map<String, Object> stringObjectMap : rechargeConfig) { |
| | | Integer chargeId = (Integer) stringObjectMap.get("chargeId"); |
| | | if (chargeId.equals(request.getChargeId())) { |
| | | Long o = (Long) stringObjectMap.get("money"); |
| | | double o = (double) stringObjectMap.get("money"); |
| | | if (BigDecimal.valueOf(o).compareTo(request.getAmount()) == 0) { |
| | | amount = BigDecimal.valueOf(o); |
| | | rechargeRecords.setAmount(BigDecimal.valueOf(o)); |
| | | if (tAppUser.getIsVip() == 1) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | // 对数据进行分页处理的方法 |
| | | private static Page<RechargesDetail> getPage(List<RechargesDetail> 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()); |
| | | public static <T> List<T> pageList(List<T> list, int pageNum, int pageSize) { |
| | | //计算总页数 |
| | | int page = list.size() % pageSize == 0 ? list.size() / pageSize : list.size() / pageSize + 1; |
| | | //兼容性分页参数错误 |
| | | pageNum = pageNum <= 0 ? 1 : pageNum; |
| | | pageNum = pageNum >= page ? page : pageNum; |
| | | // 开始索引 |
| | | int begin = 0; |
| | | // 结束索引 |
| | | int end = 0; |
| | | if (pageNum != page) { |
| | | begin = (pageNum - 1) * pageSize; |
| | | end = begin + pageSize; |
| | | } else { |
| | | begin = (pageNum - 1) * pageSize; |
| | | end = list.size(); |
| | | } |
| | | return list.subList(begin, end); |
| | | } |
| | | |
| | | } |