diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardOrderMapper.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardOrderMapper.java index 52f05e49b..c2def6879 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardOrderMapper.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardOrderMapper.java @@ -71,6 +71,8 @@ public interface HardOrderMapper extends PjcloudBaseMapper { .in(ObjectUtil.isNotEmpty(dto.getUserIds()), HardOrderEntity::getUserId, dto.getUserIds()) .in(ObjectUtil.isNotEmpty(dto.getMchIds()), HardOrderEntity::getMerchantId, dto.getMchIds()) .in(ObjectUtil.isNotEmpty(dto.getMchTypeCodes()), HardOrderEntity::getMerchantType, dto.getMchTypeCodes()) + .in(ObjectUtil.isNotEmpty(dto.getOrderStatusCodes()), HardOrderEntity::getOrderStatus, dto.getOrderStatusCodes()) + .in(ObjectUtil.isNotEmpty(dto.getRefundStatusCodes()), HardOrderEntity::getRefundStatus, dto.getRefundStatusCodes()) .between( ObjectUtil.isNotEmpty(dto.getCreateTimeList()), HardOrderEntity::getCreateTime, diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java index 0ffccd67d..8904847cc 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java @@ -169,7 +169,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl afterList = baseMapper.selectList(new LambdaQueryWrapper() .eq(HardAfterSaleEntity::getOrderId, order.getId()) @@ -493,7 +498,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.set(HardOrderEntity::getApplyCancelTime, null) .set(HardOrderEntity::getOrderStatus, HardOrderStatusEnum.REFUND.getType()) - .set(HardOrderEntity::getRefundStatus, HardRefundStatusEnum.NONE.getStatus()) + .set(HardOrderEntity::getRefundStatus, HardRefundStatusEnum.APPLY.getStatus()) .eq(HardOrderEntity::getId, order.getId()); hardOrderService.update(updateWrapper); return saveObj; @@ -709,4 +714,4 @@ public class HardAfterSaleServiceImpl extends ServiceImpl mchIds = totalList.stream().map(HardOrderSbVo::getMerchantId).distinct().toList(); if (ObjectUtil.isNotEmpty(mchIds)) { - List mchList = remoteMchService.getByIds(mchIds).getData(); + List mchList = getMchListByIds(mchIds); if (ObjectUtil.isNotEmpty(mchList)) { WalletDataUtil.convertMchList(totalList, CollectionUtils.convertMap(mchList, MchManageVo::getId)); } @@ -220,7 +221,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { // 商户 List mchIds = totalList.stream().map(HardOrderCsVo::getMerchantId).distinct().toList(); if (ObjectUtil.isNotEmpty(mchIds)) { - List mchList = remoteMchService.getByIds(mchIds).getData(); + List mchList = getMchListByIds(mchIds); if (ObjectUtil.isNotEmpty(mchList)) { WalletDataUtil.convertMchList(totalList, CollectionUtils.convertMap(mchList, MchManageVo::getId)); } @@ -228,7 +229,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { // 商户部门 List mchDeptIds = totalList.stream().map(HardOrderCsVo::getMerchantDeptId).distinct().toList(); if (ObjectUtil.isNotEmpty(mchDeptIds)) { - Map deptMap = remoteDeptService.getDeptByDeptIds(mchDeptIds).getData(); + Map deptMap = getDeptMapByIds(mchDeptIds); if (ObjectUtil.isNotEmpty(deptMap)) { for (HardOrderCsVo v : totalList) { if (ObjectUtil.isEmpty(v.getMerchantDeptId())) continue; @@ -319,7 +320,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { // 商户 List mchIds = totalList.stream().map(HardOrderCsVo::getMerchantId).distinct().toList(); if (ObjectUtil.isNotEmpty(mchIds)) { - List mchList = remoteMchService.getByIds(mchIds).getData(); + List mchList = getMchListByIds(mchIds); if (ObjectUtil.isNotEmpty(mchList)) { WalletDataUtil.convertMchList(totalList, CollectionUtils.convertMap(mchList, MchManageVo::getId)); } @@ -327,7 +328,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { // 商户部门 List mchDeptIds = totalList.stream().map(HardOrderCsVo::getMerchantDeptId).distinct().toList(); if (ObjectUtil.isNotEmpty(mchDeptIds)) { - Map deptMap = remoteDeptService.getDeptByDeptIds(mchDeptIds).getData(); + Map deptMap = getDeptMapByIds(mchDeptIds); if (ObjectUtil.isNotEmpty(deptMap)) { for (HardOrderCsVo v : totalList) { if (ObjectUtil.isEmpty(v.getMerchantDeptId())) continue; @@ -388,7 +389,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { // 商户 List mchIds = totalList.stream().map(HardOrderCsVo::getMerchantId).distinct().toList(); if (ObjectUtil.isNotEmpty(mchIds)) { - List mchList = remoteMchService.getByIds(mchIds).getData(); + List mchList = getMchListByIds(mchIds); if (ObjectUtil.isNotEmpty(mchList)) { WalletDataUtil.convertMchList(totalList, CollectionUtils.convertMap(mchList, MchManageVo::getId)); } @@ -816,7 +817,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { } List> chuckMchIds = ListUtil.split(mchIds, 5); - List mchList = remoteMchService.getByIds(mchIds).getData(); + List mchList = getMchListByIds(mchIds); Map map = new HashMap(); @@ -962,4 +963,12 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { return listMap; } + + private List getMchListByIds(List mchIds) { + return RemoteBatchQueryUtil.queryByIds(mchIds, ids -> remoteMchService.getByIds(ids).getData()); + } + + private Map getDeptMapByIds(List deptIds) { + return RemoteBatchQueryUtil.queryMapByIds(deptIds, ids -> remoteDeptService.getDeptByDeptIds(ids).getData()); + } } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/utils/RemoteBatchQueryUtil.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/utils/RemoteBatchQueryUtil.java new file mode 100644 index 000000000..282a1c6a5 --- /dev/null +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/utils/RemoteBatchQueryUtil.java @@ -0,0 +1,113 @@ +package com.bsd.pjcloud.hard.utils; + +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.ObjectUtil; +import lombok.experimental.UtilityClass; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +/** + * 远程批量查询工具。 + *

+ * 用于处理 ids 数量过多时,直接调用其他服务的批量查询接口可能导致请求参数过长的问题。 + */ +@UtilityClass +public class RemoteBatchQueryUtil { + + /** + * 默认每批查询 200 个 id。 + */ + public static final int DEFAULT_BATCH_SIZE = 200; + + /** + * 按默认批量大小分组查询。 + * + * @param ids 查询 id 集合 + * @param queryFunction 实际远程查询方法 + * @param id 类型 + * @param 返回数据类型 + * @return 合并后的查询结果 + */ + public static List queryByIds(List ids, Function, List> queryFunction) { + return queryByIds(ids, DEFAULT_BATCH_SIZE, queryFunction); + } + + /** + * 按指定批量大小分组查询,并合并每批查询结果。 + * + * @param ids 查询 id 集合 + * @param batchSize 每批 id 数量 + * @param queryFunction 实际远程查询方法 + * @param id 类型 + * @param 返回数据类型 + * @return 合并后的查询结果 + */ + public static List queryByIds(List ids, int batchSize, Function, List> queryFunction) { + if (ObjectUtil.isEmpty(ids)) return List.of(); + if (ObjectUtil.isEmpty(queryFunction)) return List.of(); + + List distinctIds = ids.stream() + .filter(ObjectUtil::isNotEmpty) + .distinct() + .toList(); + if (ObjectUtil.isEmpty(distinctIds)) return List.of(); + + List resultList = new ArrayList<>(); + for (List batchIds : ListUtil.split(distinctIds, batchSize)) { + List batchList = queryFunction.apply(batchIds); + if (ObjectUtil.isNotEmpty(batchList)) { + resultList.addAll(batchList); + } + } + return resultList; + } + + /** + * 按默认批量大小分组查询,并合并每批 Map 查询结果。 + * + * @param ids 查询 id 集合 + * @param queryFunction 实际远程查询方法 + * @param id 类型 + * @param 返回 Map 的 key 类型 + * @param 返回 Map 的 value 类型 + * @return 合并后的查询结果 + */ + public static Map queryMapByIds(List ids, Function, Map> queryFunction) { + return queryMapByIds(ids, DEFAULT_BATCH_SIZE, queryFunction); + } + + /** + * 按指定批量大小分组查询,并合并每批 Map 查询结果。 + * + * @param ids 查询 id 集合 + * @param batchSize 每批 id 数量 + * @param queryFunction 实际远程查询方法 + * @param id 类型 + * @param 返回 Map 的 key 类型 + * @param 返回 Map 的 value 类型 + * @return 合并后的查询结果 + */ + public static Map queryMapByIds(List ids, int batchSize, Function, Map> queryFunction) { + if (ObjectUtil.isEmpty(ids)) return Map.of(); + if (ObjectUtil.isEmpty(queryFunction)) return Map.of(); + + List distinctIds = ids.stream() + .filter(ObjectUtil::isNotEmpty) + .distinct() + .toList(); + if (ObjectUtil.isEmpty(distinctIds)) return Map.of(); + + Map resultMap = new LinkedHashMap<>(); + for (List batchIds : ListUtil.split(distinctIds, batchSize)) { + Map batchMap = queryFunction.apply(batchIds); + if (ObjectUtil.isNotEmpty(batchMap)) { + resultMap.putAll(batchMap); + } + } + return resultMap; + } +} diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeInvoiceServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeInvoiceServiceImpl.java index 15f637bd9..77811a011 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeInvoiceServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeInvoiceServiceImpl.java @@ -86,6 +86,9 @@ import java.util.Map; public class WalletRechargeInvoiceServiceImpl extends ServiceImpl implements WalletRechargeInvoiceService { static private final String TAG = "充值/扣款发票"; + private static final double INVOICE_STAMP_WIDTH_RATIO = 500D / (661.5D * 3D); + private static final double INVOICE_STAMP_X_RATIO = (500D + 661.5D * 3D * 0.15D + 80D) / (661.5D * 3D); + private static final double INVOICE_STAMP_BOTTOM_MARGIN_RATIO = 50D / (359.1D * 3D); private final FlowUtil flowUtil; @@ -428,7 +431,6 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl baseMapWidth || stampHeight > baseMapHeight) { + double scale = Math.min(baseMapWidth / (double) stampWidth, baseMapHeight / (double) stampHeight); + stampWidth = Math.max(1, (int) Math.floor(stampWidth * scale)); + stampHeight = Math.max(1, (int) Math.floor(stampHeight * scale)); + } BufferedImage scaledStamp = new BufferedImage(stampWidth, stampHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D stampG2d = scaledStamp.createGraphics(); stampG2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); @@ -464,12 +475,10 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl