longz
2026-07-20 5af1194755100bd05556a3d7e8a1455c11986dd7
修复查询过慢的问题
11个文件已修改
606 ■■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/UserListQueryDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingRefundDto.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/PayOrderRefundDto.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 160 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml 233 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/UserListQueryDto.java
@@ -20,6 +20,8 @@
    Integer vipTypeId;
    @ApiModelProperty(value = "单位id")
    Integer companyId;
    @ApiModelProperty(value = "是否白名单:1=是,2=否")
    Integer whitelistFlag;
    @ApiModelProperty(value = "到期天数1")
    Integer vipEndTime1;
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -369,9 +369,29 @@
        //如果要筛选标签。用标签获取useids
        if (userListQueryDto.getUserTagId() != null){
            userIds = appUserTagService.lambdaQuery().eq(TAppUserTag::getUserTagId, userListQueryDto.getUserTagId()).list().stream().map(TAppUserTag::getAppUserId).collect(Collectors.toList());
            if (userIds.isEmpty()) {
                userIds.add(-1L);
            }
        }
        List<TAppUserWhitelist> whitelistList = new ArrayList<>();
        List<Long> whitelistUserIds = new ArrayList<>();
        List<String> whitelistPhones = new ArrayList<>();
        if (userListQueryDto.getWhitelistFlag() != null) {
            whitelistList = appUserWhitelistService.lambdaQuery()
                    .eq(TAppUserWhitelist::getStatus, 1)
                    .eq(TAppUserWhitelist::getDelFlag, false)
                    .list();
            whitelistUserIds = whitelistList.stream()
                    .map(TAppUserWhitelist::getAppUserId)
                    .filter(Objects::nonNull)
                    .collect(Collectors.toList());
            whitelistPhones = whitelistList.stream()
                    .map(TAppUserWhitelist::getPhone)
                    .filter(StringUtils::isNotBlank)
                    .collect(Collectors.toList());
        }
        //列表查询
        Page<TAppUser> page = appUserService.lambdaQuery()
        LambdaQueryChainWrapper<TAppUser> query = appUserService.lambdaQuery()
                .like(userListQueryDto.getUserPhone() != null && !"".equals(userListQueryDto.getUserPhone()), TAppUser::getPhone, userListQueryDto.getUserPhone())
                .eq(userListQueryDto.getCompanyId() != null, TAppUser::getCompanyId, userListQueryDto.getCompanyId())
                .eq(userListQueryDto.getProvinceCode() != null && !"".equals(userListQueryDto.getProvinceCode()), TAppUser::getProvinceCode, userListQueryDto.getProvinceCode())
@@ -379,12 +399,36 @@
                .eq(userListQueryDto.getStatus() != null, TAppUser::getStatus, userListQueryDto.getStatus())
                .eq(userListQueryDto.getVipTypeId() != null, TAppUser::getVipId, userListQueryDto.getVipTypeId())
                .in(!userIds.isEmpty(),TAppUser::getId,userIds)
                .orderByDesc(BasePojo::getCreateTime)
                .page(Page.of(userListQueryDto.getPageCurr(), userListQueryDto.getPageSize()));
                .orderByDesc(BasePojo::getCreateTime);
        if (Integer.valueOf(1).equals(userListQueryDto.getWhitelistFlag())) {
            if (whitelistUserIds.isEmpty() && whitelistPhones.isEmpty()) {
                query.eq(TAppUser::getId, -1L);
            } else {
                List<Long> finalWhitelistUserIds = whitelistUserIds;
                List<String> finalWhitelistPhones = whitelistPhones;
                query.and(wrapper -> {
                    if (!finalWhitelistUserIds.isEmpty()) {
                        wrapper.in(TAppUser::getId, finalWhitelistUserIds);
                    }
                    if (!finalWhitelistPhones.isEmpty()) {
                        if (!finalWhitelistUserIds.isEmpty()) {
                            wrapper.or();
                        }
                        wrapper.in(TAppUser::getPhone, finalWhitelistPhones);
                    }
                });
            }
        }
        if (Integer.valueOf(2).equals(userListQueryDto.getWhitelistFlag())) {
            query.notIn(!whitelistUserIds.isEmpty(), TAppUser::getId, whitelistUserIds)
                    .notIn(!whitelistPhones.isEmpty(), TAppUser::getPhone, whitelistPhones);
        }
        Page<TAppUser> page = query.page(Page.of(userListQueryDto.getPageCurr(), userListQueryDto.getPageSize()));
        if (page.getRecords().isEmpty()){
            return R.ok(page);
        }
        List<Long> pageUserIds = page.getRecords().stream().map(TAppUser::getId).collect(Collectors.toList());
        Map<Long, String> userTagNameMap = getUserTagNameMap(pageUserIds);
        Map<Long, BigDecimal> exchangeCodeBalanceMap = otherClient.getExchangeCodeBalanceMap(pageUserIds).getData();
        if (exchangeCodeBalanceMap == null) {
            exchangeCodeBalanceMap = new HashMap<>();
@@ -396,15 +440,7 @@
        //循环处理
        for (TAppUser appUser : page.getRecords()) {
            appUser.setExchangeCodeBalance(exchangeCodeBalanceMap.getOrDefault(appUser.getId(), BigDecimal.ZERO));
            //拿到最新的tagId
            TAppUserTag one = appUserTagService.lambdaQuery().eq(TAppUserTag::getAppUserId, appUser.getId()).orderByDesc(TAppUserTag::getCreateTime).last("limit 1").one();
            if (one!=null) {
                //设置最新的tagName
                R<TUserTag> byIdTag = otherClient.getByIdTag(one.getUserTagId());
                if (byIdTag.getData() != null) {
                    appUser.setTagName(byIdTag.getData().getName());
                }
            }
            appUser.setTagName(userTagNameMap.get(appUser.getId()));
            if (appUser.getVipEndTime()!=null&&appUser.getVipEndTime().isAfter(LocalDateTime.now())) {
                //匹配vipMap的值
                appUser.setVipName(vipMap.getData().get(appUser.getVipId()));
@@ -431,6 +467,37 @@
        }
        return R.ok(page);
    }
    private Map<Long, String> getUserTagNameMap(List<Long> userIds) {
        if (userIds == null || userIds.isEmpty()) {
            return new HashMap<>();
        }
        List<TAppUserTag> userTags = appUserTagService.lambdaQuery()
                .in(TAppUserTag::getAppUserId, userIds)
                .orderByDesc(TAppUserTag::getCreateTime)
                .list();
        if (userTags.isEmpty()) {
            return new HashMap<>();
        }
        List<Integer> tagIds = userTags.stream()
                .map(TAppUserTag::getUserTagId)
                .filter(Objects::nonNull)
                .distinct()
                .collect(Collectors.toList());
        R<Map<Integer, String>> tagMapResult = otherClient.getTagMap(tagIds);
        Map<Integer, String> tagMap = tagMapResult == null || tagMapResult.getData() == null ? new HashMap<>() : tagMapResult.getData();
        Map<Long, LinkedHashSet<String>> userTagNames = new HashMap<>();
        for (TAppUserTag userTag : userTags) {
            String tagName = tagMap.get(userTag.getUserTagId());
            if (StringUtils.isBlank(tagName)) {
                continue;
            }
            userTagNames.computeIfAbsent(userTag.getAppUserId(), key -> new LinkedHashSet<>()).add(tagName);
        }
        Map<Long, String> result = new HashMap<>();
        userTagNames.forEach((userId, names) -> result.put(userId, String.join(",", names)));
        return result;
    }
    
    
    @RequiresPermissions(value = {"/vipList"}, logical = Logical.OR)
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
@@ -967,8 +967,45 @@
        if (CollectionUtils.isEmpty(ids)) {
            return;
        }
        for (Integer id : ids) {
            setAccountingStrategy(id, accountingStrategyId);
        }
        this.lambdaUpdate()
                .in(Site::getId, ids)
                .set(Site::getAccountingStrategyId, accountingStrategyId)
                .update();
        chargingGunService.lambdaUpdate()
                .in(TChargingGun::getSiteId, ids)
                .eq(TChargingGun::getDelFlag, 0)
                .set(TChargingGun::getAccountingStrategyId, accountingStrategyId)
                .update();
        List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailService.list(new LambdaQueryWrapper<TAccountingStrategyDetail>().eq(TAccountingStrategyDetail::getAccountingStrategyId, accountingStrategyId));
        List<TChargingPile> chargingPiles = chargingPileService.lambdaQuery().in(TChargingPile::getSiteId, ids).eq(TChargingPile::getDelFlag, 0).list();
        List<Integer> syncSiteIds = this.lambdaQuery()
                .select(Site::getId, Site::getIsOpenSynchronization)
                .in(Site::getId, ids)
                .eq(Site::getIsOpenSynchronization, 1)
                .list()
                .stream()
                .map(Site::getId)
                .collect(Collectors.toList());
        new Thread(() -> {
            for (TChargingPile chargingPile : chargingPiles) {
                try {
                    integrationClient.setupBillingModel1(chargingPile.getCode(), JSON.toJSONString(accountingStrategyDetails));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                try {
                    chengDuJianGuanClient.notificationStationFee(chargingPile.getId());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (!CollectionUtils.isEmpty(syncSiteIds)) {
                try {
                    tcecClient.notificationStationChange(syncSiteIds);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -437,6 +437,20 @@
    public R refund(@RequestBody PayOrderRefundDto payOrderQueryDto) {
        return chargingOrderService.payRefund(payOrderQueryDto);
    }
    @ResponseBody
    @PostMapping(value = "/pay/order/special/refund/query")
    @ApiOperation(value = "特殊退款查询", tags = {"管理后台-支付订单-订单信息"})
    public R<PayOrderInfoDto> specialRefundQuery(@RequestBody PayOrderRefundDto payOrderQueryDto) {
        return chargingOrderService.getSpecialRefundOrder(payOrderQueryDto);
    }
    @ResponseBody
    @PostMapping(value = "/pay/order/special/refund")
    @ApiOperation(value = "特殊退款", tags = {"管理后台-支付订单-订单信息"})
    public R specialRefund(@RequestBody PayOrderRefundDto payOrderQueryDto) {
        return chargingOrderService.specialRefund(payOrderQueryDto);
    }
    
    
    @RequiresPermissions(value = {"/paymentOrder/order"}, logical = Logical.OR)
@@ -602,7 +616,7 @@
    
    
    
    @RequiresPermissions(value = {"/paymentOrder/refund"}, logical = Logical.OR)
    @RequiresPermissions(value = {"/paymentOrder/refund", "/paymentOrder/order"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/pay/order/refund/list")
    @ApiOperation(value = "列表", tags = {"管理后台-支付订单-退款订单"})
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingRefundDto.java
@@ -8,6 +8,10 @@
public class ChargingRefundDto extends BasePage {
    @ApiModelProperty("订单编号")
    private String code;
    @ApiModelProperty("支付流水号")
    private String serialNumber;
    @ApiModelProperty("平台退款编号")
    private String refundCode;
    @ApiModelProperty("是否特殊退款处理")
    private Boolean specialRefund;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/PayOrderRefundDto.java
@@ -12,7 +12,14 @@
    private Long orderId;
    @ApiModelProperty("1充电订单2购物订单3vip订单4停车订单")
    private Integer type;
    @ApiModelProperty("订单流水号")
    private String code;
    @ApiModelProperty("支付流水号")
    private String serialNumber;
    @ApiModelProperty("支付宝特殊退款方式:ALI=支付宝退款,ICBC=工商退款")
    private String refundChannel;
    private BigDecimal refundAmount;
    private String reason;
    private String remark;
    private String operationPassword;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java
@@ -206,6 +206,10 @@
    R payRefund(PayOrderRefundDto payOrderQueryDto);
    R<PayOrderInfoDto> getSpecialRefundOrder(PayOrderRefundDto payOrderQueryDto);
    R specialRefund(PayOrderRefundDto payOrderQueryDto);
    ChargingOrderListInfoVO chargingInfo(String uid);
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -131,6 +131,7 @@
    private static final int WHITELIST_BENEFIT_ELECTRIC_FREE = 2;
    private static final int WHITELIST_BENEFIT_SERVICE_FREE = 3;
    private static final String SHARE_AFTER_COMMIT_RESOURCE_PREFIX = "chargingOrderShareAfterCommit:";
    private static final String SPECIAL_REFUND_TITLE = "特殊退款处理";
    @Resource
    private ChargingGunClient chargingGunClient;
@@ -1571,9 +1572,8 @@
        }
        LocalTime start = LocalTime.parse(site.getReservationStartTime(), DateTimeFormatter.ofPattern("HH:mm"));
        LocalTime end = LocalTime.parse(site.getReservationEndTime(), DateTimeFormatter.ofPattern("HH:mm"));
        if (!isTimeInWindow(LocalTime.now(), start, end)
                || !isTimeInWindow(reservationTime.toLocalTime(), start, end)) {
            return AjaxResult.error("当前时间或预约时间不在允许预约时段内");
        if (!isTimeInWindow(reservationTime.toLocalTime(), start, end)) {
            return AjaxResult.error("预约时间不在允许预约时段内");
        }
        return null;
    }
@@ -4663,7 +4663,161 @@
    
    
    @Override
    public R<PayOrderInfoDto> getSpecialRefundOrder(PayOrderRefundDto payOrderQueryDto) {
        TChargingOrder order = getSpecialRefundChargingOrder(payOrderQueryDto);
        if (order == null) {
            return R.fail("未查询到支付成功的充电订单");
        }
        PayOrderInfoDto dto = new PayOrderInfoDto();
        dto.setOrderId(order.getId().toString());
        dto.setCode(order.getCode());
        dto.setTradeNo(order.getRechargeSerialNumber());
        dto.setPayType(order.getRechargePaymentType());
        dto.setPayAmount(money(order.getPaymentAmount()));
        dto.setPayTime(order.getPayTime());
        dto.setRefundAmount(money(order.getRefundAmount()));
        dto.setRechargeAmount(money(order.getRechargeAmount()));
        dto.setFinalAmount(money(order.getPaymentAmount()).subtract(money(order.getRefundAmount())).setScale(2, RoundingMode.HALF_UP));
        dto.setPayMethod(order.getPayMethod());
        dto.setBalancePayAmount(order.getBalancePayAmount());
        dto.setThirdPayAmount(order.getThirdPayAmount());
        dto.setBalanceRefundAmount(order.getBalanceRefundAmount());
        dto.setThirdRefundAmount(order.getThirdRefundAmount());
        return R.ok(dto);
    }
    @Override
    @Transactional
    public R specialRefund(PayOrderRefundDto payOrderQueryDto) {
        R passwordValid = validateOperationPassword(payOrderQueryDto);
        if (passwordValid.getCode() != 200) {
            return passwordValid;
        }
        if (payOrderQueryDto.getRefundAmount() == null || payOrderQueryDto.getRefundAmount().compareTo(BigDecimal.ZERO) <= 0) {
            return R.fail("请输入正确的退款金额");
        }
        TChargingOrder order = getSpecialRefundChargingOrder(payOrderQueryDto);
        if (order == null) {
            return R.fail("未查询到支付成功的充电订单");
        }
        BigDecimal refundAmount = money(payOrderQueryDto.getRefundAmount());
        BigDecimal refundableAmount = money(order.getPaymentAmount()).subtract(money(order.getRefundAmount())).setScale(2, RoundingMode.HALF_UP);
        if (refundAmount.compareTo(refundableAmount) > 0) {
            return R.fail("退款金额不能超过剩余可退金额");
        }
        BigDecimal refundedThirdAmount = money(order.getThirdRefundAmount());
        BigDecimal refundableThirdAmount = money(order.getThirdPayAmount()).subtract(refundedThirdAmount);
        if (refundableThirdAmount.compareTo(BigDecimal.ZERO) < 0) {
            refundableThirdAmount = BigDecimal.ZERO;
        }
        BigDecimal thirdRefundAmount = isBalancePayMode(order.getPayMethod())
                ? refundAmount.min(refundableThirdAmount).setScale(2, RoundingMode.HALF_UP)
                : refundAmount;
        BigDecimal balanceRefundAmount = refundAmount.subtract(thirdRefundAmount).setScale(2, RoundingMode.HALF_UP);
        if (balanceRefundAmount.compareTo(BigDecimal.ZERO) < 0) {
            balanceRefundAmount = BigDecimal.ZERO;
        }
        TChargingOrderRefund refund = buildSpecialChargingRefund(order, payOrderQueryDto, refundAmount, balanceRefundAmount, thirdRefundAmount);
        if (thirdRefundAmount.compareTo(BigDecimal.ZERO) == 0) {
            refund.setRefundSerialNumber("BALANCE");
            finishManualChargingRefund(order, refund, refundAmount, balanceRefundAmount, thirdRefundAmount);
            return R.ok();
        }
        Integer payType = order.getRechargePaymentType();
        boolean success = false;
        if (Integer.valueOf(1).equals(payType) || "ICBC".equalsIgnoreCase(payOrderQueryDto.getRefundChannel())) {
            success = refundByIcbcAndFinish(order, refund, thirdRefundAmount, SPECIAL_REFUND_TITLE, true, refundAmount, balanceRefundAmount);
        } else if (Integer.valueOf(2).equals(payType)) {
            RefundReq dto = new RefundReq();
            dto.setOutTradeNo(order.getCode());
            dto.setOutRequestNo(refund.getRefundCode());
            dto.setRefundAmount(thirdRefundAmount.toString());
            dto.setRefundReason(SPECIAL_REFUND_TITLE);
            RefundResp resp = aliPaymentClient.refund(dto).getData();
            if (resp != null) {
                refund.setRefundSerialNumber(resp.getTradeNo());
                refund.setRefundTime(LocalDateTime.now());
                finishManualChargingRefund(order, refund, refundAmount, balanceRefundAmount, thirdRefundAmount);
                success = true;
            }
        } else if (Integer.valueOf(3).equals(payType)) {
            RefundReq dto = new RefundReq();
            dto.setOutTradeNo(order.getRechargeSerialNumber());
            dto.setOutRequestNo(refund.getRefundCode());
            dto.setRefundAmount(thirdRefundAmount.toString());
            dto.setRefundReason(SPECIAL_REFUND_TITLE);
            RefundResp resp = h5AliPaymentClient.refund(dto).getData();
            if (resp != null && "10000".equals(resp.getCode())) {
                refund.setRefundSerialNumber(resp.getTradeNo());
                refund.setRefundTime(LocalDateTime.now());
                finishManualChargingRefund(order, refund, refundAmount, balanceRefundAmount, thirdRefundAmount);
                success = true;
            }
        }
        return success ? R.ok() : R.fail("退款失败,请检查支付渠道或稍后重试");
    }
    private R validateOperationPassword(PayOrderRefundDto payOrderQueryDto) {
        if (payOrderQueryDto == null || StringUtils.isEmpty(payOrderQueryDto.getOperationPassword())) {
            return R.fail("请输入操作密码");
        }
        SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
        if (sysUser == null || StringUtils.isEmpty(sysUser.getOperationPassword())) {
            return R.fail("当前账号未配置操作密码");
        }
        if (!SecurityUtils.matchesPassword(payOrderQueryDto.getOperationPassword(), sysUser.getOperationPassword())) {
            return R.fail("操作密码错误");
        }
        return R.ok();
    }
    private TChargingOrder getSpecialRefundChargingOrder(PayOrderRefundDto payOrderQueryDto) {
        if (payOrderQueryDto == null) {
            return null;
        }
        LambdaQueryWrapper<TChargingOrder> wrapper = new LambdaQueryWrapper<TChargingOrder>()
                .eq(TChargingOrder::getRechargePaymentStatus, 2)
                .eq(TChargingOrder::getDelFlag, false);
        if (payOrderQueryDto.getOrderId() != null) {
            wrapper.eq(TChargingOrder::getId, payOrderQueryDto.getOrderId());
        } else if (StringUtils.hasLength(payOrderQueryDto.getCode())) {
            wrapper.eq(TChargingOrder::getCode, payOrderQueryDto.getCode());
        } else if (StringUtils.hasLength(payOrderQueryDto.getSerialNumber())) {
            wrapper.eq(TChargingOrder::getRechargeSerialNumber, payOrderQueryDto.getSerialNumber());
        } else {
            return null;
        }
        return this.getOne(wrapper.last("limit 1"));
    }
    private TChargingOrderRefund buildSpecialChargingRefund(TChargingOrder order, PayOrderRefundDto dto, BigDecimal refundAmount,
                                                           BigDecimal balanceRefundAmount, BigDecimal thirdRefundAmount) {
        TChargingOrderRefund refund = new TChargingOrderRefund();
        refund.setChargingOrderId(order.getId());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        refund.setRefundCode("TSF" + sdf.format(new Date()) + (Double.valueOf(Math.random() * 1000).intValue()));
        refund.setRefundAmount(refundAmount);
        refund.setBalanceRefundAmount(balanceRefundAmount);
        refund.setThirdRefundAmount(thirdRefundAmount);
        refund.setRefundStatus(1);
        refund.setPayType(order.getRechargePaymentType());
        refund.setRefundTime(LocalDateTime.now());
        refund.setCode(order.getCode());
        refund.setRefundTitle(SPECIAL_REFUND_TITLE);
        refund.setRefundContent(SPECIAL_REFUND_TITLE);
        refund.setRefundReason(StringUtils.hasLength(dto.getReason()) ? dto.getReason() : SPECIAL_REFUND_TITLE);
        refund.setRefundRemark(dto.getRemark());
        refund.setRefundTotalAmount(money(order.getRefundAmount()).add(refundAmount));
        refund.setPayAmount(money(order.getPaymentAmount()));
        return refund;
    }
    @Override
    public R payRefund(PayOrderRefundDto payOrderQueryDto) {
        R passwordValid = validateOperationPassword(payOrderQueryDto);
        if (passwordValid.getCode() != 200) {
            return passwordValid;
        }
        if (payOrderQueryDto.getType() == 1) {
            TChargingOrder tChargingOrder = this.baseMapper.selectById(payOrderQueryDto.getOrderId());
            if (tChargingOrder.getPaymentAmount().compareTo(payOrderQueryDto.getRefundAmount()) == -1) {
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java
@@ -183,15 +183,11 @@
    @Override
    public PageInfo<TOrderEvaluateVO> getTagList(TOrderEvaluateQuery query) {
        PageInfo<TOrderEvaluateVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
        // 查询站点下的所有订单
        List<TChargingOrder> tChargingOrders = chargingOrderMapper.selectList(Wrappers.lambdaQuery(TChargingOrder.class)
                .eq(TChargingOrder::getSiteId, query.getSiteId()));
        if(CollectionUtils.isEmpty(tChargingOrders)){
            return new PageInfo<>();
        }
        List<Long> orderIds = tChargingOrders.stream().map(TChargingOrder::getId).collect(Collectors.toList());
        query.setOrderIds(orderIds);
        List<TOrderEvaluateVO> list = this.baseMapper.pageList(query,pageInfo);
        if (CollectionUtils.isEmpty(list)) {
            pageInfo.setRecords(list);
            return pageInfo;
        }
        // 查询用户信息
        List<TAppUser> appUsers = appUserClient.getUserByIds(list.stream().map(TOrderEvaluateVO::getAppUserId).collect(Collectors.toList())).getData();
        // 查询用户绑定车辆品牌
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -357,6 +357,12 @@
            <if test="data.refundCode != null and data.refundCode != ''">
                AND o.refund_code LIKE CONCAT('%',#{data.refundCode},'%')
            </if>
            <if test="data.serialNumber != null and data.serialNumber != ''">
                AND o.serail_number LIKE CONCAT('%',#{data.serialNumber},'%')
            </if>
            <if test="data.specialRefund != null and data.specialRefund">
                AND o.refund_title = '特殊退款处理'
            </if>
        </where>
        order by o.refund_time desc
@@ -1200,134 +1206,107 @@
    <select id="chargingList1" resultType="map">
        select
        aa.id,
        aa.`code`,
        aa.siteId,
        aa.siteName,
        aa.orderType,
        aa.terminalName,
        aa.electricity,
        aa.rechargeAmount,
        aa.rechargePaymentType,
        aa.payMethod,
        aa.isWhitelist,
        aa.whitelistRefundAmount,
        aa.whitelistElectricRefundAmount,
        aa.whitelistServiceRefundAmount,
        aa.paymentAmount,
        aa.thirdPayAmount,
        aa.balancePayAmount,
        aa.electrovalence,
        aa.serviceCharge,
        aa.orderSource,
        aa.tripartitePlatformName,
        aa.startTime,
        aa.endTime,
        aa.chargingSecond,
        aa.startSoc,
        aa.endSoc,
        aa.`status`,
        aa.endMode,
        aa.phone,
        aa.licensePlate,
        SUM(aa.period_electric_price) as periodElectricPrice,
        SUM(aa.period_service_price) as periodServicePrice,
        SUM(aa.jian) as jian,
        SUM(aa.feng) as feng,
        SUM(aa.ping) as ping,
        SUM(aa.gu) as gu
        from (
            select
            b.id,
            b.`code`,
            b.site_id as siteId,
            c.`name` as siteName,
            b.order_type as orderType,
            CONCAT(d.`name`, '-', e.`name`) as terminalName,
            b.electricity,
            b.recharge_amount as rechargeAmount,
            b.recharge_payment_type as rechargePaymentType,
            b.pay_method as payMethod,
            b.is_whitelist as isWhitelist,
            IFNULL(b.whitelist_electric_refund_amount, 0) + IFNULL(b.whitelist_service_refund_amount, 0) as whitelistRefundAmount,
            IFNULL(b.whitelist_electric_refund_amount, 0) as whitelistElectricRefundAmount,
            IFNULL(b.whitelist_service_refund_amount, 0) as whitelistServiceRefundAmount,
            b.payment_amount as paymentAmount,
            b.third_pay_amount as thirdPayAmount,
            b.balance_pay_amount as balancePayAmount,
            b.electrovalence,
            b.service_charge as serviceCharge,
            b.order_source as orderSource,
            b.tripartite_platform_name as tripartitePlatformName,
            DATE_FORMAT(b.start_time, '%Y-%m-%d %H:%i:%s') as startTime,
            DATE_FORMAT(b.end_time, '%Y-%m-%d %H:%i:%s') as endTime,
            (UNIX_TIMESTAMP(b.end_time) - UNIX_TIMESTAMP(b.start_time)) as chargingSecond,
            b.start_soc as startSoc,
            b.end_soc as endSoc,
            b.`status`,
            b.end_mode as endMode,
            f.phone,
            g.license_plate as licensePlate,
            a.period_electric_price,
            a.period_service_price,
            CASE WHEN a.type = 1 THEN a.charging_capacity ELSE 0 END as jian,
            CASE WHEN a.type = 2 THEN a.charging_capacity ELSE 0 END as feng,
            CASE WHEN a.type = 3 THEN a.charging_capacity ELSE 0 END as ping,
            CASE WHEN a.type = 4 THEN a.charging_capacity ELSE 0 END as gu
        b.id,
        b.`code`,
        b.site_id as siteId,
        c.`name` as siteName,
        b.order_type as orderType,
        CONCAT(d.`name`, '-', e.`name`) as terminalName,
        b.electricity,
        b.recharge_amount as rechargeAmount,
        b.recharge_payment_type as rechargePaymentType,
        b.pay_method as payMethod,
        b.is_whitelist as isWhitelist,
        IFNULL(b.whitelist_electric_refund_amount, 0) + IFNULL(b.whitelist_service_refund_amount, 0) as whitelistRefundAmount,
        IFNULL(b.whitelist_electric_refund_amount, 0) as whitelistElectricRefundAmount,
        IFNULL(b.whitelist_service_refund_amount, 0) as whitelistServiceRefundAmount,
        b.payment_amount as paymentAmount,
        b.third_pay_amount as thirdPayAmount,
        b.balance_pay_amount as balancePayAmount,
        b.electrovalence,
        b.service_charge as serviceCharge,
        b.order_source as orderSource,
        b.tripartite_platform_name as tripartitePlatformName,
        DATE_FORMAT(b.start_time, '%Y-%m-%d %H:%i:%s') as startTime,
        DATE_FORMAT(b.end_time, '%Y-%m-%d %H:%i:%s') as endTime,
        (UNIX_TIMESTAMP(b.end_time) - UNIX_TIMESTAMP(b.start_time)) as chargingSecond,
        b.start_soc as startSoc,
        b.end_soc as endSoc,
        b.`status`,
        b.end_mode as endMode,
        f.phone,
        g.license_plate as licensePlate,
        (select SUM(a.period_electric_price)
         from `charging_pile_order`.t_charging_order_accounting_strategy a
         where a.charging_order_id = b.id) as periodElectricPrice,
        (select SUM(a.period_service_price)
         from `charging_pile_order`.t_charging_order_accounting_strategy a
         where a.charging_order_id = b.id) as periodServicePrice,
        (select SUM(CASE WHEN a.type = 1 THEN a.charging_capacity ELSE 0 END)
         from `charging_pile_order`.t_charging_order_accounting_strategy a
         where a.charging_order_id = b.id) as jian,
        (select SUM(CASE WHEN a.type = 2 THEN a.charging_capacity ELSE 0 END)
         from `charging_pile_order`.t_charging_order_accounting_strategy a
         where a.charging_order_id = b.id) as feng,
        (select SUM(CASE WHEN a.type = 3 THEN a.charging_capacity ELSE 0 END)
         from `charging_pile_order`.t_charging_order_accounting_strategy a
         where a.charging_order_id = b.id) as ping,
        (select SUM(CASE WHEN a.type = 4 THEN a.charging_capacity ELSE 0 END)
         from `charging_pile_order`.t_charging_order_accounting_strategy a
         where a.charging_order_id = b.id) as gu
        from `charging_pile_order`.t_charging_order b
        left join `charging_pile_service`.t_site c on (b.site_id = c.id)
        left join `charging_pile_service`.t_charging_pile d on (b.charging_pile_id = d.id)
        left join `charging_pile_service`.t_charging_gun e on (b.charging_gun_id = e.id)
        left join `charging_pile_account`.t_app_user f on (b.app_user_id = f.id)
        left join `charging_pile_account`.t_app_user_car g on (b.app_user_car_id = g.id)
        where b.del_flag = 0 and b.recharge_payment_status = 2
        <if test="null != req.code and req.code!=''">
            and b.code LIKE CONCAT('%',#{req.code},'%')
        </if>
        <if test="null != req.carIds and req.carIds.size()>0">
            and b.app_user_car_id in
            <foreach collection="req.carIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.userIds and req.userIds.size()>0">
            and b.app_user_id in
            <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.siteIds and req.siteIds.size()>0">
            and b.site_id in
            <foreach collection="req.siteIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="req.orderType != null ">
            and b.order_type = #{req.orderType}
        </if>
        <if test="req.status != null ">
            and b.status = #{req.status}
        </if>
        <if test="req.isWhitelist != null">
            and b.is_whitelist = #{req.isWhitelist}
        </if>
        <if test="req.siteId != null ">
            and b.site_id = #{req.siteId}
        </if>
        <if test="startTime1 != null and startTime1!=''">
            and b.start_time between #{startTime1} and #{startTime2}
        </if>
        <if test="endTime1 != null and endTime2!=''">
            and b.end_time between #{endTime1} and #{endTime2}
        </if>
        and b.start_time IS NOT NULL and b.end_time is not null
        and exists (
            select 1
            from `charging_pile_order`.t_charging_order_accounting_strategy a
            left join `charging_pile_order`.t_charging_order b on (a.charging_order_id = b.id)
            left join `charging_pile_service`.t_site c on (b.site_id = c.id)
            left join `charging_pile_service`.t_charging_pile d on (b.charging_pile_id = d.id)
            left join `charging_pile_service`.t_charging_gun e on (b.charging_gun_id = e.id)
            left join `charging_pile_account`.t_app_user f on (b.app_user_id = f.id)
            left join `charging_pile_account`.t_app_user_car g on (b.app_user_car_id = g.id)
            where b.del_flag = 0 and b.recharge_payment_status = 2
            <if test="null != req.code and req.code!=''">
                and b.code LIKE CONCAT('%',#{req.code},'%')
            </if>
            <if test="null != req.carIds and req.carIds.size()>0">
                and b.app_user_car_id in
                <foreach collection="req.carIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="null != req.userIds and req.userIds.size()>0">
                and b.app_user_id in
                <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="null != req.siteIds and req.siteIds.size()>0">
                and b.site_id in
                <foreach collection="req.siteIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.orderType != null ">
                and b.order_type = #{req.orderType}
            </if>
            <if test="req.status != null ">
                and b.status = #{req.status}
            </if>
            <if test="req.status != null ">
                and b.status = #{req.status}
            </if>
            <if test="req.isWhitelist != null">
                and b.is_whitelist = #{req.isWhitelist}
            </if>
            <if test="req.siteId != null ">
                and b.site_id = #{req.siteId}
            </if>
            <if test="startTime1 != null and startTime1!=''">
                and b.start_time between #{startTime1} and #{startTime2}
            </if>
            <if test="endTime1 != null and endTime2!=''">
                and b.end_time between #{endTime1} and #{endTime2}
            </if>
            and b.start_time IS NOT NULL and b.end_time is not null
        ) as aa group by aa.id, aa.`code`, aa.siteId, aa.siteName, aa.orderType, aa.terminalName, aa.electricity, aa.rechargeAmount, aa.paymentAmount, aa.thirdPayAmount, aa.balancePayAmount, aa.electrovalence, aa.serviceCharge, aa.tripartitePlatformName,
        aa.startTime, aa.endTime, aa.chargingSecond, aa.startSoc, aa.endSoc, aa.`status`, aa.endMode, aa.phone, aa.licensePlate, aa.orderSource, aa.rechargePaymentType, aa.payMethod,
        aa.isWhitelist, aa.whitelistRefundAmount, aa.whitelistElectricRefundAmount, aa.whitelistServiceRefundAmount order by aa.startTime desc
            where a.charging_order_id = b.id
        )
        order by b.start_time desc
    </select>
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateMapper.xml
@@ -23,18 +23,14 @@
        id, order_type, order_id, app_user_id,app_user_car_id, mark, content, img_url, evaluation_response, create_time, response_time, del_flag
    </sql>
    <select id="pageList" resultType="com.ruoyi.order.api.vo.TOrderEvaluateVO">
        select id, order_type, order_id, app_user_id,app_user_car_id, mark, content, img_url, evaluation_response,
               create_time, response_time, del_flag
        from t_order_evaluate where id in
        (select toe.id
        select toe.id, toe.order_type, toe.order_id, toe.app_user_id, toe.app_user_car_id, toe.mark, toe.content,
               toe.img_url, toe.evaluation_response, toe.create_time, toe.response_time, toe.del_flag
        from t_order_evaluate toe
        left join t_order_evaluate_tag toet on toe.id = toet.order_evaluate_id
        inner join t_charging_order co on co.id = toe.order_id
            and co.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
        <where>
            <if test="query.orderIds != null and query.orderIds.size()>0">
                and toe.order_id in
                <foreach collection="query.orderIds" item="orderId" open="(" separator="," close=")">
                    #{orderId}
                </foreach>
            <if test="query.siteId != null">
                and co.site_id = #{query.siteId}
            </if>
            <if test="query.tagType != null">
                <choose>
@@ -49,35 +45,39 @@
                        AND toe.mark &lt;= 3
                    </when>
                    <when test="query.tagType == 5">
                        AND toet.evaluation_tag_id = #{query.tagId}
                        AND EXISTS (
                            SELECT 1
                            FROM t_order_evaluate_tag toet
                            WHERE toet.order_evaluate_id = toe.id
                            AND toet.evaluation_tag_id = #{query.tagId}
                        )
                    </when>
                </choose>
            </if>
            AND toe.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
        </where>
        GROUP BY toe.id)
        <if test="query.tagType != null">
            <choose>
                <when test="query.tagType == 1">
                    ORDER BY create_time DESC
                    ORDER BY toe.create_time DESC
                </when>
                <otherwise>
                    ORDER BY
                    CASE
                    WHEN img_url IS NOT NULL THEN 0
                    WHEN toe.img_url IS NOT NULL AND toe.img_url != '' THEN 0
                    ELSE 1
                    END ASC,
                    create_time DESC
                    toe.create_time DESC
                </otherwise>
            </choose>
        </if>
        <if test="query.tagType == null">
            ORDER BY
            CASE
            WHEN img_url IS NOT NULL THEN 0
            WHEN toe.img_url IS NOT NULL AND toe.img_url != '' THEN 0
            ELSE 1
            END ASC,
            create_time DESC
            toe.create_time DESC
        </if>
    </select>
    <select id="getOrderEvaluateBySiteId" resultType="com.ruoyi.order.api.vo.TOrderEvaluateVO">