| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.feignClient.AppUserCarClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserTagClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.account.api.model.TAppUserTag; |
| | | import com.ruoyi.chargingPile.api.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.api.dto.GetSiteListDTO; |
| | | import com.ruoyi.chargingPile.api.feignClient.*; |
| | |
| | | import com.ruoyi.order.vo.WatchChargingOrderVo; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserTagClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.domain.TCompany; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.payment.api.feignClient.AliPaymentClient; |
| | | import com.ruoyi.payment.api.feignClient.WxPaymentClient; |
| | | import com.ruoyi.payment.api.vo.IcbcPaymentResp; |
| | |
| | | private ChargingGunClient chargingGunClient; |
| | | @Resource |
| | | private AppUserCarClient appUserCarClient; |
| | | @Resource |
| | | private AppUserTagClient appUserTagClient; |
| | | @Resource |
| | | private UserTagClient userTagClient; |
| | | @Resource |
| | | private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService; |
| | | |
| | |
| | | } |
| | | |
| | | private List<Map<String, Object>> franchiseeUserTags(List<TChargingOrder> orders) { |
| | | Map<Long, Long> counts = orders.stream().filter(order -> order.getAppUserId() != null) |
| | | .collect(Collectors.groupingBy(TChargingOrder::getAppUserId, Collectors.counting())); |
| | | long active = counts.values().stream().filter(count -> count >= 5).count(); |
| | | long normal = counts.values().stream().filter(count -> count >= 2 && count < 5).count(); |
| | | long lowFrequency = counts.values().stream().filter(count -> count == 1).count(); |
| | | return namedCounts(new String[]{"活跃用户", "普通用户", "低频用户"}, new long[]{active, normal, lowFrequency}); |
| | | Set<Long> userIds = orders.stream() |
| | | .map(TChargingOrder::getAppUserId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | if (userIds.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | R<List<TUserTag>> tagResult = userTagClient.getAllUserTag(); |
| | | List<TUserTag> tags = tagResult == null || tagResult.getData() == null |
| | | ? Collections.emptyList() : tagResult.getData(); |
| | | Map<String, Long> counts = new LinkedHashMap<>(); |
| | | for (TUserTag tag : tags) { |
| | | if (tag == null || tag.getId() == null || StringUtils.isBlank(tag.getName())) { |
| | | continue; |
| | | } |
| | | long count = 0; |
| | | for (Long userId : userIds) { |
| | | TAppUserTag query = new TAppUserTag(); |
| | | query.setAppUserId(userId); |
| | | query.setUserTagId(tag.getId()); |
| | | R<TAppUserTag> userTagResult = appUserTagClient.getUserTag(query); |
| | | if (userTagResult != null && userTagResult.getData() != null) { |
| | | count++; |
| | | } |
| | | } |
| | | if (count > 0) { |
| | | counts.put(tag.getName(), count); |
| | | } |
| | | } |
| | | return counts.entrySet().stream() |
| | | .map(entry -> namedCount(entry.getKey(), entry.getValue())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private List<Map<String, Object>> franchiseeMemberTypes(List<TAppUser> users, Map<Integer, String> vipNames) { |