diff --git a/db/1000pjcloudx_thirdparty.sql b/db/1000pjcloudx_thirdparty.sql index a22f984e7..93fbde67b 100644 --- a/db/1000pjcloudx_thirdparty.sql +++ b/db/1000pjcloudx_thirdparty.sql @@ -39,7 +39,7 @@ CREATE TABLE `third_zy_id_dict` `id` bigint NOT NULL COMMENT '主键', `self_id` varchar(64) NOT NULL COMMENT '自己这边的id映射', `zy_id` varchar(64) NOT NULL COMMENT '正元id映射', - `biz_type` tinytext(16) NOT NULL COMMENT '同步类型', + `biz_type` tinytext NOT NULL COMMENT '同步类型', `create_time` datetime DEFAULT NULL COMMENT '创建时间', `update_time` datetime DEFAULT NULL COMMENT '更新时间', `create_by` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderCsVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderCsVo.java index f611cabec..b0c40293b 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderCsVo.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderCsVo.java @@ -39,6 +39,18 @@ public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface { @Schema(description = "总消费次数") private BigDecimal totalPayCount; + @Schema(description = "总退款金额(元)") + private BigDecimal totalRefundPrice; + + @Schema(description = "总退款次数") + private BigDecimal totalRefundCount; + + @Schema(description = "总盈利金额(元)") + private BigDecimal totalProfitPrice; + + @Schema(description = "总盈利次数") + private BigDecimal totalProfitCount; + /** * 导出相关 */ diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderSbVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderSbVo.java index 2d6c1a0a1..f6b825e8e 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderSbVo.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderSbVo.java @@ -38,7 +38,19 @@ public class HardOrderSbVo implements BaseMchInterface, BaseHardInterface { @Schema(description = "总消费次数") private BigDecimal totalPayCount; - + + @Schema(description = "总退款金额(元)") + private BigDecimal totalRefundPrice; + + @Schema(description = "总退款次数") + private BigDecimal totalRefundCount; + + @Schema(description = "总盈利金额(元)") + private BigDecimal totalProfitPrice; + + @Schema(description = "总盈利次数") + private BigDecimal totalProfitCount; + /** * 导出相关 */ diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java index 4902b4f02..13a25897f 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java @@ -13,13 +13,11 @@ import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; import com.bsd.pjcloud.hard.api.constant.HardTypeEnum; import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum; -import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum; import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto; import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto; import com.bsd.pjcloud.hard.api.vo.order.HardDeptTotalVo; import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo; import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo; -import com.bsd.pjcloud.hard.api.vo.order.HardZyCardSyncVo; import com.bsd.pjcloud.hard.service.HardOrderTotalService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -53,16 +51,15 @@ public class HardOrderTotalController { @PostMapping("/page-list-sb") @Operation(summary = "设备交易记录") - public R> pageListSb(@ParameterObject Page page, @RequestBody HardOrderDto dto) { - dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes()); - return R.ok(HardOrderTotalService.pageListSb(page, dto)); + public R> pageListSb(@RequestBody HardOrderDto dto) { + return R.ok(HardOrderTotalService.listSb(dto)); } @PostMapping("/page-list-cs") @Operation(summary = "商户交易记录") - public R> pageListCs(@ParameterObject Page page, @RequestBody HardOrderDto dto) { + public R> pageListCs(@RequestBody HardOrderDto dto) { dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes()); - return R.ok(HardOrderTotalService.pageListCs(page, dto)); + return R.ok(HardOrderTotalService.listCs(dto)); } @PostMapping("/page-list-dept") @@ -88,8 +85,15 @@ public class HardOrderTotalController { map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[1], DatePattern.NORM_DATETIME_PATTERN)); } if (ObjectUtil.isNotEmpty(list)) { - BigDecimal priceTotal = BigDecimal.ZERO; - BigDecimal countTotal = BigDecimal.ZERO; + // 总消费 + BigDecimal totalPayPrice = BigDecimal.ZERO; + BigDecimal totalPayCount = BigDecimal.ZERO; + // 总退款 + BigDecimal totalRefundPrice = BigDecimal.ZERO; + BigDecimal totalRefundCount = BigDecimal.ZERO; + // 总盈利 + BigDecimal totalProfitPrice = BigDecimal.ZERO; + BigDecimal totalProfitCount = BigDecimal.ZERO; Long lineNumber = 1L; for (HardOrderSbVo v : list) { v.setLineNumber(lineNumber); @@ -97,16 +101,40 @@ public class HardOrderTotalController { if (ObjectUtil.isNotEmpty(v.getHardType())) { v.setHardType(HardTypeEnum.valueOfByType(v.getHardType()).getDescription()); } + // 总消费 if (ObjectUtil.isNotEmpty(v.getTotalPayPrice())) { - priceTotal = priceTotal.add(v.getTotalPayPrice()); + totalPayPrice = totalPayPrice.add(v.getTotalPayPrice()); v.setTotalPayPrice(v.getTotalPayPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } if (ObjectUtil.isNotEmpty(v.getTotalPayCount())) { - countTotal = countTotal.add(v.getTotalPayCount()); + totalPayCount = totalPayCount.add(v.getTotalPayCount()); + } + // 总退款 + if (ObjectUtil.isNotEmpty(v.getTotalRefundPrice())) { + totalRefundPrice = totalRefundPrice.add(v.getTotalRefundPrice()); + v.setTotalRefundPrice(v.getTotalRefundPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); + } + if (ObjectUtil.isNotEmpty(v.getTotalRefundCount())) { + totalRefundCount = totalRefundCount.add(v.getTotalRefundCount()); + } + // 总盈利 + if (ObjectUtil.isNotEmpty(v.getTotalProfitPrice())) { + totalProfitPrice = totalProfitPrice.add(v.getTotalProfitPrice()); + v.setTotalProfitPrice(v.getTotalProfitPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); + } + if (ObjectUtil.isNotEmpty(v.getTotalProfitCount())) { + totalProfitCount = totalProfitCount.add(v.getTotalProfitCount()); } } - map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); - map.put("computeTotalPayCount", countTotal.toString()); + // 总消费 + map.put("computeTotalPayPrice", totalPayPrice.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("computeTotalPayCount", totalPayCount.toString()); + // 总退款 + map.put("computeTotalRefundPrice", totalRefundPrice.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("computeTotalRefundCount", totalRefundCount.toString()); + // 总盈利 + map.put("computeTotalProfitPrice", totalProfitPrice.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("computeTotalProfitCount", totalProfitCount.toString()); } excelWriter.fill(map, writeSheet); excelWriter.fill(list, fillConfig, writeSheet); @@ -131,8 +159,15 @@ public class HardOrderTotalController { map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[1], DatePattern.NORM_DATETIME_PATTERN)); } if (ObjectUtil.isNotEmpty(list)) { - BigDecimal priceTotal = BigDecimal.ZERO; - BigDecimal countTotal = BigDecimal.ZERO; + // 总消费 + BigDecimal totalPayPrice = BigDecimal.ZERO; + BigDecimal totalPayCount = BigDecimal.ZERO; + // 总退款 + BigDecimal totalRefundPrice = BigDecimal.ZERO; + BigDecimal totalRefundCount = BigDecimal.ZERO; + // 总盈利 + BigDecimal totalProfitPrice = BigDecimal.ZERO; + BigDecimal totalProfitCount = BigDecimal.ZERO; Long lineNumber = 1L; for (HardOrderCsVo v : list) { v.setLineNumber(lineNumber); @@ -140,16 +175,40 @@ public class HardOrderTotalController { if (ObjectUtil.isNotEmpty(v.getHardType())) { v.setHardType(HardTypeEnum.valueOfByType(v.getHardType()).getDescription()); } + // 总消费 if (ObjectUtil.isNotEmpty(v.getTotalPayPrice())) { - priceTotal = priceTotal.add(v.getTotalPayPrice()); + totalPayPrice = totalPayPrice.add(v.getTotalPayPrice()); v.setTotalPayPrice(v.getTotalPayPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); } if (ObjectUtil.isNotEmpty(v.getTotalPayCount())) { - countTotal = countTotal.add(v.getTotalPayCount()); + totalPayCount = totalPayCount.add(v.getTotalPayCount()); + } + // 总退款 + if (ObjectUtil.isNotEmpty(v.getTotalRefundPrice())) { + totalRefundPrice = totalRefundPrice.add(v.getTotalRefundPrice()); + v.setTotalRefundPrice(v.getTotalRefundPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); + } + if (ObjectUtil.isNotEmpty(v.getTotalRefundCount())) { + totalRefundCount = totalRefundCount.add(v.getTotalRefundCount()); + } + // 总盈利 + if (ObjectUtil.isNotEmpty(v.getTotalProfitPrice())) { + totalProfitPrice = totalProfitPrice.add(v.getTotalProfitPrice()); + v.setTotalProfitPrice(v.getTotalProfitPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); + } + if (ObjectUtil.isNotEmpty(v.getTotalProfitCount())) { + totalProfitCount = totalProfitCount.add(v.getTotalProfitCount()); } } - map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); - map.put("computeTotalPayCount", countTotal.toString()); + // 总消费 + map.put("computeTotalPayPrice", totalPayPrice.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("computeTotalPayCount", totalPayCount.toString()); + // 总退款 + map.put("computeTotalRefundPrice", totalRefundPrice.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("computeTotalRefundCount", totalRefundCount.toString()); + // 总盈利 + map.put("computeTotalProfitPrice", totalProfitPrice.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("computeTotalProfitCount", totalProfitCount.toString()); } excelWriter.fill(map, writeSheet); excelWriter.fill(list, fillConfig, writeSheet); 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 fc2ca74f9..7f07035f9 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 @@ -9,7 +9,6 @@ import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto; import com.bsd.pjcloud.hard.api.dto.order.HardOrderSumAndCountDto; import com.bsd.pjcloud.hard.api.entity.HardManagerEntity; -import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity; import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; import com.bsd.pjcloud.hard.api.vo.order.*; import com.github.yulichang.wrapper.MPJLambdaWrapper; @@ -86,7 +85,7 @@ public interface HardOrderMapper extends PjcloudBaseMapper { return selectListByScope(commonWrapper(dto), DataScope.of()); } - Page pageListSb(Page page, @Param("dto") HardOrderDto dto); + Page listSb(Page page, @Param("dto") HardOrderDto dto); List listSb(@Param("dto") HardOrderDto dto); diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderTotalService.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderTotalService.java index 8ec4f0f38..9c4c00d04 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderTotalService.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderTotalService.java @@ -12,12 +12,8 @@ import java.util.List; public interface HardOrderTotalService { - Page pageListSb(Page page, HardOrderDto dto); - List listSb(HardOrderDto dto); - Page pageListCs(Page page, HardOrderDto dto); - List listCs(HardOrderDto dto); List pageListDept(HardDeptTotalDto dto); diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java index 26442ff10..ecb2799c2 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java @@ -1,6 +1,7 @@ package com.bsd.pjcloud.hard.service.impl.order; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bsd.pjcloud.admin.api.dto.DeptAllListDto; @@ -8,7 +9,6 @@ import com.bsd.pjcloud.admin.api.entity.SysDept; import com.bsd.pjcloud.admin.api.feign.RemoteDeptService; import com.bsd.pjcloud.common.core.util.CollectionUtils; import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum; -import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum; import com.bsd.pjcloud.hard.api.dto.HardManagerDto; import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto; import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto; @@ -33,7 +33,6 @@ import org.springframework.validation.annotation.Validated; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; @Validated @Slf4j @@ -48,88 +47,124 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { private final RemoteWalletTransactionService remoteWalletTransactionService; private final RemoteDeptService remoteDeptService; - @Override - public Page pageListSb(Page page, HardOrderDto dto) { - Page list = hardOrderMapper.pageListSb(page, dto); - if (ObjectUtil.isNotEmpty(list)) { - // 商户 - List mchIds = list.getRecords().stream().map(HardOrderSbVo::getMerchantId).distinct().toList(); - if (ObjectUtil.isNotEmpty(mchIds)) { - List mchList = remoteMchService.getByIds(mchIds).getData(); - if (ObjectUtil.isNotEmpty(mchList)) { - WalletDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId)); - } - } - // 设备 - List hardIds = list.getRecords().stream().map(HardOrderSbVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList(); - if (ObjectUtil.isNotEmpty(mchIds)) { - HardManagerDto hardManagerDto = new HardManagerDto(); - hardManagerDto.setIds(hardIds); - List hardList = hardManagerMapper.list(hardManagerDto); - if (ObjectUtil.isNotEmpty(hardList)) { - HardUtil.convertHardList(list.getRecords(), CollectionUtils.convertMap(hardList, HardManagerEntity::getId)); - } - } - } - return list; - } - @Override public List listSb(HardOrderDto dto) { - List list = hardOrderMapper.listSb(dto); - if (ObjectUtil.isNotEmpty(list)) { + // 查询总流水 + CompletableFuture> totalListFuture = CompletableFuture.supplyAsync(() -> { + HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class); + totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice()); + return hardOrderMapper.listSb(totalDto); + }); + // 扣款总流水 + CompletableFuture> refundListFuture = CompletableFuture.supplyAsync(() -> { + HardOrderDto refundDto = BeanUtil.toBean(dto, HardOrderDto.class); + refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes()); + return hardOrderMapper.listSb(refundDto); + }); + // 盈利 + CompletableFuture> profitListFuture = CompletableFuture.supplyAsync(() -> { + HardOrderDto profitDto = BeanUtil.toBean(dto, HardOrderDto.class); + profitDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes()); + return hardOrderMapper.listSb(profitDto); + }); + CompletableFuture allFutures = CompletableFuture.allOf(totalListFuture, refundListFuture, profitListFuture); + allFutures.join(); + List totalList = totalListFuture.join(); + List refundList = refundListFuture.join(); + List profitList = profitListFuture.join(); + // 聚合一下数据 + for (HardOrderSbVo v : totalList) { + // 退款 + if (ObjectUtil.isNotEmpty(refundList)) { + refundList.stream().filter(i -> ObjectUtil.equals(i.getHardId(), v.getHardId())).findFirst().ifPresent(i -> { + v.setTotalRefundPrice(i.getTotalPayPrice()); + v.setTotalRefundCount(i.getTotalPayCount()); + }); + } + // 盈利 + if (ObjectUtil.isNotEmpty(profitList)) { + profitList.stream().filter(i -> ObjectUtil.equals(i.getHardId(), v.getHardId())).findFirst().ifPresent(i -> { + v.setTotalProfitPrice(i.getTotalPayPrice()); + v.setTotalProfitCount(i.getTotalPayCount()); + }); + } + } + if (ObjectUtil.isNotEmpty(totalList)) { // 商户 - List mchIds = list.stream().map(HardOrderSbVo::getMerchantId).distinct().toList(); + List mchIds = totalList.stream().map(HardOrderSbVo::getMerchantId).distinct().toList(); if (ObjectUtil.isNotEmpty(mchIds)) { List mchList = remoteMchService.getByIds(mchIds).getData(); if (ObjectUtil.isNotEmpty(mchList)) { - WalletDataUtil.convertMchList(list, CollectionUtils.convertMap(mchList, MchManageVo::getId)); + WalletDataUtil.convertMchList(totalList, CollectionUtils.convertMap(mchList, MchManageVo::getId)); } } // 设备 - List hardIds = list.stream().map(HardOrderSbVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList(); + List hardIds = totalList.stream().map(HardOrderSbVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList(); if (ObjectUtil.isNotEmpty(mchIds)) { HardManagerDto hardManagerDto = new HardManagerDto(); hardManagerDto.setIds(hardIds); List hardList = hardManagerMapper.list(hardManagerDto); if (ObjectUtil.isNotEmpty(hardList)) { - HardUtil.convertHardList(list, CollectionUtils.convertMap(hardList, HardManagerEntity::getId)); + HardUtil.convertHardList(totalList, CollectionUtils.convertMap(hardList, HardManagerEntity::getId)); } } } - return list; - } - - @Override - public Page pageListCs(Page page, HardOrderDto dto) { - Page list = hardOrderMapper.pageListCs(page, dto); - if (ObjectUtil.isNotEmpty(list)) { - // 商户 - List mchIds = list.getRecords().stream().map(HardOrderCsVo::getMerchantId).distinct().toList(); - if (ObjectUtil.isNotEmpty(mchIds)) { - List mchList = remoteMchService.getByIds(mchIds).getData(); - if (ObjectUtil.isNotEmpty(mchList)) { - WalletDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId)); - } - } - } - return list; + return totalList; } @Override public List listCs(HardOrderDto dto) { - List list = hardOrderMapper.listCs(dto); - if (ObjectUtil.isNotEmpty(list)) { + // 查询总流水 + CompletableFuture> totalListFuture = CompletableFuture.supplyAsync(() -> { + HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class); + totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice()); + return hardOrderMapper.listCs(totalDto); + }); + // 扣款总流水 + CompletableFuture> refundListFuture = CompletableFuture.supplyAsync(() -> { + HardOrderDto refundDto = BeanUtil.toBean(dto, HardOrderDto.class); + refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes()); + return hardOrderMapper.listCs(refundDto); + }); + // 盈利 + CompletableFuture> profitListFuture = CompletableFuture.supplyAsync(() -> { + HardOrderDto profitDto = BeanUtil.toBean(dto, HardOrderDto.class); + profitDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes()); + return hardOrderMapper.listCs(profitDto); + }); + CompletableFuture allFutures = CompletableFuture.allOf(totalListFuture, refundListFuture, profitListFuture); + allFutures.join(); + List totalList = totalListFuture.join(); + List refundList = refundListFuture.join(); + List profitList = profitListFuture.join(); + for (HardOrderCsVo v : totalList) { + // 退款 + if (ObjectUtil.isNotEmpty(refundList)) { + refundList.stream().filter(i -> ObjectUtil.equals(i.getMerchantId(), v.getMerchantId())).findFirst().ifPresent(i -> { + v.setTotalRefundPrice(i.getTotalPayPrice()); + v.setTotalRefundCount(i.getTotalPayCount()); + }); + } + // 盈利 + if (ObjectUtil.isNotEmpty(profitList)) { + profitList.stream().filter(i -> ObjectUtil.equals(i.getMerchantId(), v.getMerchantId())).findFirst().ifPresent(i -> { + v.setTotalProfitPrice(i.getTotalPayPrice()); + v.setTotalProfitCount(i.getTotalPayCount()); + }); + } + } + // 聚合一下数据 + if (ObjectUtil.isNotEmpty(totalList)) { // 商户 - List mchIds = list.stream().map(HardOrderCsVo::getMerchantId).distinct().toList(); + List mchIds = totalList.stream().map(HardOrderCsVo::getMerchantId).distinct().toList(); if (ObjectUtil.isNotEmpty(mchIds)) { List mchList = remoteMchService.getByIds(mchIds).getData(); if (ObjectUtil.isNotEmpty(mchList)) { - WalletDataUtil.convertMchList(list, CollectionUtils.convertMap(mchList, MchManageVo::getId)); + WalletDataUtil.convertMchList(totalList, CollectionUtils.convertMap(mchList, MchManageVo::getId)); } } } - return list; + return totalList; } @Override diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/商户交易金额汇总.xlsx b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/商户交易金额汇总.xlsx index aedbeea5f..831e78567 100644 Binary files a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/商户交易金额汇总.xlsx and b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/商户交易金额汇总.xlsx differ diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/设备交易金额汇总.xlsx b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/设备交易金额汇总.xlsx index 62911f18d..7a334018a 100644 Binary files a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/设备交易金额汇总.xlsx and b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/设备交易金额汇总.xlsx differ diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx index 3a1e3203b..51d149779 100644 Binary files a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx and b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx differ diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml index 33aebe982..a0ed3ddd6 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml @@ -112,7 +112,7 @@ - select a.hard_id, a.merchant_id, diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/zy/ThirdZySelfController.java b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/zy/ThirdZySelfController.java index 1e7b4393f..eb5fd2cf8 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/zy/ThirdZySelfController.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/zy/ThirdZySelfController.java @@ -27,7 +27,7 @@ public class ThirdZySelfController { @Inner(value = false) @GetMapping("/checkSystemStatus") @Operation(summary = "第三方url健康探测", description = "第三方url健康探测") - @Idempotent(expireTime = 3, info = "请勿重复调用") + // @Idempotent(expireTime = 3, info = "请勿重复调用") public Map checkSystemStatus() { return zySelfService.checkSystemStatus(); } @@ -35,7 +35,7 @@ public class ThirdZySelfController { @Inner(value = false) @GetMapping("/getToken") @Operation(summary = "第三方提供获取token", description = "第三方提供获取token") - @Idempotent(expireTime = 3, info = "请勿重复调用") + // @Idempotent(expireTime = 3, info = "请勿重复调用") public ZySelfGetTokenVo getToken(ZySelfGetTokenDto params) { return zySelfService.getToken(params); } diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/service/impl/zy/ThirdZyMerServiceImpl.java b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/service/impl/zy/ThirdZyMerServiceImpl.java index 972170600..ed30f5c19 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/service/impl/zy/ThirdZyMerServiceImpl.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/service/impl/zy/ThirdZyMerServiceImpl.java @@ -155,7 +155,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService { Map userIdDict = zyApiTool.generateZyId(bizType, userList); // 转换身份编号 List roleList = dto.stream().map(ZyMerSyncAccountInfoDto::getAccClassID).distinct().toList(); - Map roleIdDict = zyApiTool.generateZyId(bizType, roleList); + Map roleIdDict = zyApiTool.generateZyId(ThirdZyBizEnumType.SYNC_ACC_CLASS_INFO, roleList); for (ZyMerSyncAccountInfoDto v : dto) { v.setEPID(deptIdDict.get(v.getEPID())); v.setPerCode(userIdDict.get(v.getPerCode())); @@ -215,10 +215,14 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService { String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ACC_CLASS_INFO; try { // 转换zyId - List roleList = dto.stream().map(ZyMerSyncAccClassInfoDto::getEPID).distinct().toList(); - Map roleIdDict = zyApiTool.generateZyId(bizType, roleList); + List deptList = dto.stream().map(ZyMerSyncAccClassInfoDto::getEPID).distinct().toList(); + Map deptIdDict = zyApiTool.generateZyId(ThirdZyBizEnumType.SYNC_ENTERPRISE_INFO, deptList); + // 转换身份id + List roleList = dto.stream().map(ZyMerSyncAccClassInfoDto::getAccClassID).distinct().toList(); + Map roleIdDict = zyApiTool.generateZyId(ThirdZyBizEnumType.SYNC_ACC_CLASS_INFO, roleList); for (ZyMerSyncAccClassInfoDto v : dto) { - v.setEPID(roleIdDict.get(v.getEPID())); + v.setEPID(deptIdDict.get(v.getEPID())); + v.setAccClassID(roleIdDict.get(v.getAccClassID())); } url = String.format(url, zyApiTool.getToken()); Map encryptionBody = new HashMap<>(); diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/service/impl/zy/ThirdZySelfServiceImpl.java b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/service/impl/zy/ThirdZySelfServiceImpl.java index 9ecb7b4cf..bc44d2101 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/service/impl/zy/ThirdZySelfServiceImpl.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/service/impl/zy/ThirdZySelfServiceImpl.java @@ -393,6 +393,6 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { dto.setLoginTime(System.currentTimeMillis()); dto.setExpireTime(dto.getLoginTime() + zyConfig.getSelfExpiresIn() + 100); String redisKey = CacheConstants.THIRDPARTY_ZY_SELF_TOKEN + dto.getToken(); - redisTemplate.opsForValue().set(redisKey, JSONUtil.toJsonStr(dto), zyConfig.getSelfExpiresIn(), TimeUnit.MINUTES); + redisTemplate.opsForValue().set(redisKey, JSONUtil.toJsonStr(dto), zyConfig.getSelfExpiresIn(), TimeUnit.SECONDS); } } diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/utils/zy/api/ZyApiTool.java b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/utils/zy/api/ZyApiTool.java index 934a0afb4..f79351e53 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/utils/zy/api/ZyApiTool.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/utils/zy/api/ZyApiTool.java @@ -98,6 +98,10 @@ public class ZyApiTool { list.clear(); result.clear(); for (String v : selfIds) { + if (v.length() <= 16) { + result.put(v, v); + continue; + } Optional first = bySelfIdList.stream().filter(i -> ObjectUtil.equals(v, i.getSelfId()) && ObjectUtil.equals(type.getType(), i.getBizType())).findFirst(); if (first.isPresent()) { result.put(v, first.get().getZyId()); diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml index 53d9fde2b..5a0463b26 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml @@ -47,6 +47,9 @@ zy: base-url: http://60.191.37.212:18079 app-id: 689C8D6F5059A6F85B8BE45A49001ACB app-secret: BD21DA0DEB8F0FC43246B0BD2FCAE6FF + # app-id: FC455B0A788E334AC08FB3E1D8385C75 + # app-secret: E9131D0BCC9054808675DA1E2E199023 + self-base-url: http://60.191.37.212:18079 self-app-id: xA5jF2vX4zO5mQ8tR9yE7rC7iI0fK0kI diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java index 6f7afb967..d988e1bf5 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java @@ -36,7 +36,8 @@ public interface WalletManageMapper extends PjcloudBaseMapper mchList = mchManageService.list(new MchManageDto()); - if (ObjectUtil.isEmpty(mchList)) { - log.info("|{}| syncAllRole 错误 mchList为空", TAG); + // 查询部门信息 + List deptList = remoteDeptService.getAllDept(null).getData(); + if (ObjectUtil.isEmpty(deptList)) { + log.info("|{}| syncAllRole 错误 deptList为空", TAG); return; } - for (MchManageVo i : mchList) { - List syncList = new ArrayList<>(); + List syncList = new ArrayList<>(); + for (SysDept i : deptList) { String syncAllMchVersion = getSyncAllMchVersion(); for (SysRole j : roleList) { ZyMerSyncAccClassInfoDto entity = new ZyMerSyncAccClassInfoDto(); @@ -174,14 +174,14 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService { entity.setFixId(syncAllMchVersion); syncList.add(entity); } - try { - if (ObjectUtil.isNotEmpty(syncList)) { - ZyMerSyncAccClassInfoVo res = thirdZyService.syncAccClassInfoApi(syncList).getData(); - if (ObjectUtil.isEmpty(res)) return; - } - } catch (Exception e) { - log.error("|{}syncAllRole 调用第三方接口错误|", TAG); + } + try { + if (ObjectUtil.isNotEmpty(syncList)) { + ZyMerSyncAccClassInfoVo res = thirdZyService.syncAccClassInfoApi(syncList).getData(); + if (ObjectUtil.isEmpty(res)) return; } + } catch (Exception e) { + log.error("|{}syncAllRole 调用第三方接口错误|", TAG); } } @@ -208,22 +208,27 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService { log.error("|{}|syncAllUser 同步到正元全部身份信息错误walletType为空", TAG); return; } + int total = 0; while (true) { - boolean isNotEmpty = syncAllUserGroup(page, userId, defaultUserRole.get().getRoleId(), walletType.getId()); - if (!isNotEmpty) break; + int syncCount = syncAllUserGroup(page, userId, defaultUserRole.get().getRoleId(), walletType.getId()); + if (syncCount > 0) { + total += syncCount; + } + if (syncCount <= 0) break; page.setCurrent(page.getCurrent() + 1); } + log.info("|{}|总共同步|{}|条数据", TAG, total); } - private boolean syncAllUserGroup(Page page, Long userId, Long roleId, Long walletTypeId) { + private int syncAllUserGroup(Page page, Long userId, Long roleId, Long walletTypeId) { WalletManageDto query = new WalletManageDto(); query.setWalletTypeId(walletTypeId); if (ObjectUtil.isNotEmpty(userId)) query.setUserId(userId); DataScope dataScope = DataScope.of(); dataScope.func(DataScopeFuncEnum.ALL); Page userPage = walletManageService.scopePageList(page, query, dataScope); - if (ObjectUtil.isEmpty(userPage.getRecords())) return false; + if (ObjectUtil.isEmpty(userPage.getRecords())) return 0; List syncList = new ArrayList<>(); String syncAllMchVersion = getSyncAllMchVersion(); for (WalletManageVo v : userPage.getRecords()) { @@ -241,8 +246,10 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService { if (ObjectUtil.isEmpty(v.getCardNumber())) { walletManageService.createWallet(v.getUserId()); WalletManageEntity wallet = walletManageService.getWallet(v.getId()); - if (ObjectUtil.isNotEmpty(wallet)) { + if (ObjectUtil.isNotEmpty(wallet) && ObjectUtil.isNotEmpty(wallet.getCardNumber())) { v.setCardNumber(wallet.getCardNumber()); + } else { + continue; } } ZyMerSyncAccountInfoDto item = new ZyMerSyncAccountInfoDto(); @@ -261,13 +268,13 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService { try { if (ObjectUtil.isNotEmpty(syncList)) { ZyMerSyncAccountInfoVo.DataVo res = thirdZyService.syncAccountInfoApi(syncList).getData(); - if (ObjectUtil.isEmpty(res)) return false; + if (ObjectUtil.isEmpty(res)) return 0; } } catch (Exception e) { log.error("|{}syncAllUserGroup 调用第三方接口错误|", TAG); - return false; + return 0; } - return userPage.getTotal() > 0; + return syncList.size(); } @@ -291,8 +298,8 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService { try { WalleCardStatusEnum walleCardStatusEnum = WalleCardStatusEnum.valueOfByType(cardStatus); return switch (walleCardStatusEnum) { - case NONE_ACTIVE, LOCK -> 5; - case ACTIVE -> 1; + case LOCK -> 5; + case ACTIVE, NONE_ACTIVE -> 1; case REPORT -> 2; case FREEZE -> 3; case CANCEL -> 0; diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletManageMapper.xml b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletManageMapper.xml index 7fd723753..102d93f19 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletManageMapper.xml +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletManageMapper.xml @@ -59,7 +59,7 @@ a.del_flag = 0 AND a.create_time = (SELECT MAX(sub.create_time) FROM wallet_transaction sub WHERE sub.user_id = a.user_id AND - DATE_FORMAT(sub.create_time, '%Y-%m') = #{dto.walletRecordMonth}) + DATE_FORMAT(sub.create_time, '%Y-%m') <= #{dto.walletRecordMonth}) AND a.user_id = #{dto.userId}