| | |
| | | } |
| | | TAccountingStrategy accountingStrategy = accountingStrategyClient.getAccountingStrategyById(accountingStrategyId).getData(); |
| | | |
| | | //直营站点才可以享受会员折扣 |
| | | if (!whitelistMatched && !isBalancePayMode(payMethod) && null != appUser.getVipId() && 1 == site.getBusinessCategory()) { |
| | | //会员折扣支持直营网点和加盟商站点 |
| | | if (!whitelistMatched && !isBalancePayMode(payMethod) && null != appUser.getVipId()) { |
| | | TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | BigDecimal discount = null; |
| | | if (1 == vip.getType()) { |
| | | //普通会员折扣使用积分策略上的折扣,且有最高优惠金额 |
| | | discount = accountingStrategy.getDiscount(); |
| | | } else { |
| | | //内部会员使用会员信息设置的折扣,没有最高优惠金额 |
| | | discount = vip.getDiscount(); |
| | | } |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(appUser.getId()); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | TAppUserVipDetail vipDetail = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | if (null != vipDetail) { |
| | | Integer chargeNum = vipDetail.getChargeNum(); |
| | | if (0 < chargeNum) { |
| | | chargingOrder.setVipDiscount(discount); |
| | | if (null != vip) { |
| | | BigDecimal discount = null; |
| | | if (Integer.valueOf(1).equals(vip.getType())) { |
| | | //普通会员折扣使用积分策略上的折扣,且有最高优惠金额 |
| | | discount = accountingStrategy.getDiscount(); |
| | | } else { |
| | | //内部会员使用会员信息设置的折扣,没有最高优惠金额 |
| | | discount = vip.getDiscount(); |
| | | } |
| | | if (null != discount) { |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(appUser.getId()); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | TAppUserVipDetail vipDetail = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | if (null != vipDetail) { |
| | | Integer chargeNum = vipDetail.getChargeNum(); |
| | | if (null != chargeNum && 0 < chargeNum) { |
| | | chargingOrder.setVipDiscount(discount); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | pageInfo.setRecords(list); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Override |
| | | public R<PageInfo<EnterpriseChargingAnalysisVO>> enterpriseChargingAnalysis(EnterpriseChargingAnalysisQuery query) { |
| | | PageInfo<EnterpriseChargingAnalysisVO> pageInfo = new PageInfo<>(query.getPageCurr(), query.getPageSize()); |
| | | List<EnterpriseChargingAnalysisVO> list = this.baseMapper.enterpriseChargingAnalysis(pageInfo, query); |
| | | for (EnterpriseChargingAnalysisVO row : list) { |
| | | EnterpriseChargingAnalysisQuery rowQuery = buildEnterpriseRowQuery(query, row); |
| | | List<Map<String, Object>> topSites = this.baseMapper.enterpriseTopSites(rowQuery); |
| | | String topSiteNames = topSites.stream() |
| | | .map(item -> Objects.toString(item.get("siteName"), "")) |
| | | .filter(org.springframework.util.StringUtils::hasText) |
| | | .collect(Collectors.joining("、")); |
| | | row.setTopSiteNames(topSiteNames); |
| | | row.setAverageChargingInterval(calculateAverageChargingInterval(this.baseMapper.enterpriseChargingTimes(rowQuery))); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Override |
| | | public R<PageInfo<EnterpriseChargingDetailVO>> enterpriseChargingDetail(EnterpriseChargingAnalysisQuery query) { |
| | | PageInfo<EnterpriseChargingDetailVO> pageInfo = new PageInfo<>(query.getPageCurr(), query.getPageSize()); |
| | | List<EnterpriseChargingDetailVO> list = this.baseMapper.enterpriseChargingDetail(pageInfo, query); |
| | | pageInfo.setRecords(list); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnterpriseChargingDetailVO> enterpriseChargingDetailExport(EnterpriseChargingAnalysisQuery query) { |
| | | return this.baseMapper.enterpriseChargingDetailExport(query); |
| | | } |
| | | |
| | | private EnterpriseChargingAnalysisQuery buildEnterpriseRowQuery(EnterpriseChargingAnalysisQuery source, EnterpriseChargingAnalysisVO row) { |
| | | EnterpriseChargingAnalysisQuery rowQuery = new EnterpriseChargingAnalysisQuery(); |
| | | BeanUtils.copyProperties(source, rowQuery); |
| | | rowQuery.setCompanyName(null); |
| | | rowQuery.setExactCompanyName(row.getCompanyName()); |
| | | rowQuery.setSocialCreditCode(row.getSocialCreditCode()); |
| | | return rowQuery; |
| | | } |
| | | |
| | | private BigDecimal calculateAverageChargingInterval(List<LocalDateTime> times) { |
| | | if (times == null || times.size() < 2) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | long totalMinutes = 0L; |
| | | for (int i = 1; i < times.size(); i++) { |
| | | long minutes = ChronoUnit.MINUTES.between(times.get(i - 1), times.get(i)); |
| | | if (minutes > 0) { |
| | | totalMinutes += minutes; |
| | | } |
| | | } |
| | | return BigDecimal.valueOf(totalMinutes) |
| | | .divide(BigDecimal.valueOf(times.size() - 1L), 4, RoundingMode.HALF_UP) |
| | | .divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | @Override |
| | | public R<PageInfo<TChargingOrderRefund>> getRefundList(ChargingRefundDto chargingRefundDto) { |
| | | PageInfo<TChargingOrderRefund> pageInfo = new PageInfo<>(chargingRefundDto.getPageCurr(), chargingRefundDto.getPageSize()); |