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/HardDeptTotalVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java index 2c9f88ec6..1337eca32 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java @@ -48,6 +48,12 @@ public class HardDeptTotalVo { @Schema(description = "退款次数") private Long orderRefundCont = 0L; + @Schema(description = "盈利金额") + private Long orderProfitPrice = 0L; + + @Schema(description = "盈利次数") + private Long orderProfitCont = 0L; + /** * 导出相关 */ 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/HardCarController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java index 841f2c9b5..1ad5dadcc 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java @@ -78,8 +78,11 @@ public class HardCarController { @GetMapping("/order-id") @Operation(summary = "根据订单id查询购物车") public R> orderId(@ParameterObject Page page, @RequestParam Long orderId) { + if (ObjectUtil.isEmpty(orderId)) { + R.ok(null); + } HardOrderEntity order = hardOrderService.getById(orderId); - if (ObjectUtil.isEmpty(order)) return null; + if (ObjectUtil.isEmpty(order) || ObjectUtil.isEmpty(order.getParentCarId())) return null; HardCarDto dto = new HardCarDto(); dto.setParentCarId(order.getParentCarId()); return R.ok(hardCarService.pageJoin(page, dto)); 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..6a6ff9e54 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 @@ -8,25 +8,21 @@ import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.fill.FillConfig; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import org.springdoc.core.annotations.ParameterObject; import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -53,16 +49,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 +83,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 +99,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 +157,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 +173,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); @@ -187,8 +244,12 @@ public class HardOrderTotalController { BigDecimal orderPayPriceSum = BigDecimal.ZERO; BigDecimal orderPayCountSum = BigDecimal.ZERO; + BigDecimal orderRefundPriceSum = BigDecimal.ZERO; BigDecimal orderRefundContSum = BigDecimal.ZERO; + // 盈利 + BigDecimal orderProfitPriceSum = BigDecimal.ZERO; + BigDecimal orderProfitContSum = BigDecimal.ZERO; Long lineNumber = 1L; for (HardDeptTotalVo v : list) { @@ -246,6 +307,14 @@ public class HardOrderTotalController { orderRefundContSum = orderRefundContSum.add(BigDecimal.valueOf(v.getOrderRefundCont())); v.setOrderRefundCont(BigDecimal.valueOf(v.getOrderRefundCont()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); } + if (ObjectUtil.isNotEmpty(v.getOrderProfitPrice())) { + orderProfitPriceSum = orderProfitPriceSum.add(BigDecimal.valueOf(v.getOrderProfitPrice())); + v.setOrderProfitPrice(BigDecimal.valueOf(v.getOrderProfitPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + } + if (ObjectUtil.isNotEmpty(v.getOrderProfitCont())) { + orderProfitContSum = orderProfitContSum.add(BigDecimal.valueOf(v.getOrderProfitCont())); + v.setOrderProfitCont(BigDecimal.valueOf(v.getOrderProfitCont()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue()); + } // 批量充值 map.put("walletPriceSum", walletPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); map.put("walletCountSum", walletCountSum.toString()); @@ -261,8 +330,12 @@ public class HardOrderTotalController { map.put("orderPayPriceSum", orderPayPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); map.put("orderPayCountSum", orderPayCountSum.toString()); + map.put("orderRefundPriceSum", orderRefundPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); map.put("orderRefundContSum", orderRefundContSum.toString()); + + map.put("orderProfitPriceSum", orderProfitPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("orderProfitContSum", orderProfitContSum.toString()); } } excelWriter.fill(map, 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/hard/HardThirdSelfZyServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/hard/HardThirdSelfZyServiceImpl.java index 63709cd1f..4488fb556 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/hard/HardThirdSelfZyServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/hard/HardThirdSelfZyServiceImpl.java @@ -119,9 +119,6 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService { try { // 校验订单是否可以退款 HardOrderVo order = hardAfterSaleService.validateOrderCanRefund(dto.getOrderId()); - if (!ObjectUtil.equals(dto.getSerialNum(), order.getOrderNo())) { - throw new RuntimeException("正元订单号不匹配"); - } // 用户 UserInfo user = remoteUserService.getByUserId(order.getUserId()).getData(); if (ObjectUtil.isEmpty(user)) throw new RuntimeException("用户不存在"); 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..a139bb132 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 @@ -238,7 +273,20 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { } return hardOrderMapper.sumAndCount(refundDto); }); - CompletableFuture allFutures = CompletableFuture.allOf(walletBatchFuture, walletReduceFuture, payFuture, refundFuture, walletOnceBatchFuture, walletOnceReduceFuture); + // 查看盈利流水 + CompletableFuture> profitFuture = CompletableFuture.supplyAsync(() -> { + HardOrderSumAndCountDto refundDto = new HardOrderSumAndCountDto(); + refundDto.setDeptIds(deptIds); + refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes()); + if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) { + refundDto.setCreateTimeList(dto.getCreateTimeList()); + } + if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) { + refundDto.setWalletTypeId(dto.getWalletTypeId()); + } + return hardOrderMapper.sumAndCount(refundDto); + }); + CompletableFuture allFutures = CompletableFuture.allOf(walletBatchFuture, walletReduceFuture, payFuture, refundFuture, walletOnceBatchFuture, walletOnceReduceFuture, profitFuture); allFutures.join(); List walletBatchList = walletBatchFuture.join(); List walletReduceList = walletReduceFuture.join(); @@ -246,6 +294,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { List walletOnceReduceList = walletOnceReduceFuture.join(); List payList = payFuture.join(); List refundList = refundFuture.join(); + List profitList = profitFuture.join(); // 聚合一下数据 for (HardDeptTotalVo v : resultList) { if (ObjectUtil.isNotEmpty(walletBatchList)) { @@ -284,6 +333,13 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { v.setOrderRefundCont(i.getCount()); }); } + // 查看盈利流水 + if (ObjectUtil.isNotEmpty(profitList)) { + profitList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { + v.setOrderProfitPrice(i.getSum()); + v.setOrderProfitCont(i.getCount()); + }); + } } return resultList; }); 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..26441d9e0 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-api/src/main/java/com/bsd/pjcloud/thirdparty/vo/zy/self/ZySelfPayVo.java b/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/vo/zy/self/ZySelfPayVo.java index 456d496af..be2f0fea3 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/vo/zy/self/ZySelfPayVo.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/vo/zy/self/ZySelfPayVo.java @@ -13,7 +13,7 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor -public class ZySelfPayVo extends ZyBaseVo { +public class ZySelfPayVo { /** * 帐号 @@ -31,7 +31,7 @@ public class ZySelfPayVo extends ZyBaseVo { private String perCode; /** - * 订单流水号,全局唯一,第三方流水号 + * 订单流水号,全局唯一,第三方流水号 */ private String platformSerialNum; 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..98161371f 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 @@ -103,8 +103,9 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { ThirdZyLogEntity entity = new ThirdZyLogEntity(); entity.setBizType(bizType.getType()); entity.setApiUrl(ZyApi.Self.CORRECT); + entity.setEncipherReq(JSONUtil.toJsonStr(params)); long startTime = System.currentTimeMillis(); - ZySelfCorrectVo result = new ZySelfCorrectVo(); + ZyBaseVo result = new ZyBaseVo(); try { result.setCode(ZyBaseVo.errorCode); boolean isToken = checkIsToken(accessToken); @@ -126,7 +127,7 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { result.setCode(ZyBaseVo.errorCode); result.setMsg(ZyBaseVo.defaultErrorMsg); ZySelfCorrectDto dto = JSONUtil.toBean(jsonRes, ZySelfCorrectDto.class); - entity.setEncipherReq(JSONUtil.toJsonStr(dto)); + entity.setOrgReq(JSONUtil.toJsonStr(dto)); // 获取参数 String correctSerialNum = dto.getCorrectSerialNum(); Long orderId = Long.parseLong(correctSerialNum); @@ -140,18 +141,25 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { case SUCCESS -> { ThirdZyIdDictEntity userIdDict = thirdZyIdDictMapper.getBySelfId(ThirdZyBizEnumType.SYNC_ACCOUNT_INFO, String.valueOf(refundRes.getUserId())); String userZyId = userIdDict.getZyId(); - result.setAccNum(userZyId); - result.setAccName(refundRes.getUsername()); - result.setPerCode(userZyId); - result.setPlatformSerialNum(String.valueOf(refundRes.getRefundId())); - result.setSerialNum(refundRes.getOrderNo()); - result.setRecDate(LocalDateTimeUtil.format(refundRes.getRefundTime(), DatePattern.NORM_DATETIME_PATTERN)); - result.setAmount(dto.getAmount()); + ZySelfPayVo success = new ZySelfPayVo(); + success.setAccNum(userZyId); + success.setAccName(refundRes.getUsername()); + success.setPerCode(userZyId); + success.setPlatformSerialNum(String.valueOf(refundRes.getRefundId())); + success.setSerialNum(refundRes.getOrderNo()); + success.setRecDate(LocalDateTimeUtil.format(refundRes.getRefundTime(), DatePattern.NORM_DATETIME_PATTERN)); + success.setAmount(dto.getAmount()); result.setMsg(ZyBaseVo.selfSuccessMsg); - entity.setOrgReq(JSONUtil.toJsonStr(result)); - Map encryptionRes = zyApiTool.getSelfEncryptionMap(BeanUtil.beanToMap(result)); - entity.setEncipherReq(JSONUtil.toJsonStr(encryptionRes)); - return encryptionRes; + Map resMap = BeanUtil.beanToMap(result); + Map dataMap = BeanUtil.beanToMap(success); + dataMap.put("sign", zyApiTool.generateSign(dataMap, false)); + resMap.put("data", Base64.encode(JSONUtil.toJsonStr(dataMap))); + entity.setOrgRes(JSONUtil.toJsonStr(success)); + entity.setEncipherRes(JSONUtil.toJsonStr(resMap)); + long elapsedTime = System.currentTimeMillis() - startTime; + entity.setTimeConsuming(Long.toString(elapsedTime)); + thirdZyLogService.save(entity); + return resMap; } default -> throw new RuntimeException(); } @@ -159,11 +167,10 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { String error = String.format("|%s||correct|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace())); log.error(error); entity.setError(error); - return result.getErrorMap(); - } finally { long elapsedTime = System.currentTimeMillis() - startTime; entity.setTimeConsuming(Long.toString(elapsedTime)); thirdZyLogService.save(entity); + return result.getErrorMap(); } } @@ -178,7 +185,7 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { entity.setBizType(bizType.getType()); entity.setEncipherReq(JSONUtil.toJsonStr(params)); long startTime = System.currentTimeMillis(); - ZySelfPayVo result = new ZySelfPayVo(); + ZyBaseVo result = new ZyBaseVo(); try { result.setCode(ZyBaseVo.errorCode); // 判断token @@ -200,7 +207,7 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { result.setCode(ZyBaseVo.errorCode); result.setMsg(ZyBaseVo.defaultErrorMsg); ZySelfPayDto dto = JSONUtil.toBean(jsonRes, ZySelfPayDto.class); - entity.setEncipherReq(JSONUtil.toJsonStr(dto)); + entity.setOrgReq(JSONUtil.toJsonStr(dto)); // 获取参数 String accNum = dto.getAccNum(); ThirdZyIdDictEntity userIdDict = thirdZyIdDictMapper.getByZyIds(ThirdZyBizEnumType.SYNC_ACCOUNT_INFO, accNum); @@ -224,18 +231,25 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { result.setCode(payRes.getCode().getType()); switch (payRes.getCode()) { case SUCCESS -> { - result.setAccNum(payRes.getUserId().toString()); - result.setAccName(payRes.getUsername()); - result.setPerCode(payRes.getUserId().toString()); - result.setPlatformSerialNum(dto.getSerialNum()); - result.setSerialNum(dto.getSerialNum()); - result.setAmount(amount); - result.setRecDate(LocalDateTimeUtil.format(payRes.getPayTime(), DatePattern.NORM_DATETIME_PATTERN)); + ZySelfPayVo success = new ZySelfPayVo(); + success.setAccNum(payRes.getUserId().toString()); + success.setAccName(payRes.getUsername()); + success.setPerCode(payRes.getUserId().toString()); + success.setPlatformSerialNum(payRes.getOrderId().toString()); + success.setSerialNum(dto.getSerialNum()); + success.setAmount(amount); + success.setRecDate(LocalDateTimeUtil.format(payRes.getPayTime(), DatePattern.NORM_DATETIME_PATTERN)); result.setMsg(ZyBaseVo.selfSuccessMsg); - entity.setOrgReq(JSONUtil.toJsonStr(result)); - Map encryptionRes = zyApiTool.getSelfEncryptionMap(BeanUtil.beanToMap(result)); - entity.setEncipherReq(JSONUtil.toJsonStr(encryptionRes)); - return encryptionRes; + Map resMap = BeanUtil.beanToMap(result); + Map dataMap = BeanUtil.beanToMap(success); + dataMap.put("sign", zyApiTool.generateSign(dataMap, false)); + resMap.put("data", Base64.encode(JSONUtil.toJsonStr(dataMap))); + entity.setOrgRes(JSONUtil.toJsonStr(success)); + entity.setEncipherRes(JSONUtil.toJsonStr(resMap)); + long elapsedTime = System.currentTimeMillis() - startTime; + entity.setTimeConsuming(Long.toString(elapsedTime)); + thirdZyLogService.save(entity); + return resMap; } default -> throw new RuntimeException(); } @@ -243,11 +257,10 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { String error = String.format("|%s||pay|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace())); log.error(error); entity.setError(error); - return result.getErrorMap(); - } finally { long elapsedTime = System.currentTimeMillis() - startTime; entity.setTimeConsuming(Long.toString(elapsedTime)); thirdZyLogService.save(entity); + return result.getErrorMap(); } } @@ -274,11 +287,11 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { result.setMsg(msg); throw new RuntimeException(msg); } - String redisKey = CacheConstants.THIRDPARTY_ZY_SELF_TOKEN + "*"; - Set keys = redisTemplate.keys(redisKey); - if (ObjectUtil.isNotEmpty(keys)) { - redisTemplate.delete(keys); - } + // String redisKey = CacheConstants.THIRDPARTY_ZY_SELF_TOKEN + "*"; + // Set keys = redisTemplate.keys(redisKey); + // if (ObjectUtil.isNotEmpty(keys)) { + // redisTemplate.delete(keys); + // } try { // 生成token String token = generateToken(params); @@ -345,14 +358,17 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService { } for (Map.Entry entry : paramsMap.entrySet()) { Object value = entry.getValue(); + if (ObjectUtil.isEmpty(value)) continue; if (value instanceof String) { - entry.setValue(Base64.decodeStr((String) value)); + String str = Base64.decodeStr((String) value); + entry.setValue(URLUtil.decode(str)); } else { - entry.setValue(Base64.decodeStr(value.toString())); + String str = Base64.decodeStr((String) value); + entry.setValue(URLUtil.decode(str)); } } String string = zyApiTool.generateSign(paramsMap, false); - if (ObjectUtil.equals(sign, string)) { + if (ObjectUtil.equals(sign.toLowerCase(), string)) { for (Map.Entry entry : paramsMap.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { @@ -393,6 +409,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..0ce58dbf5 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()); @@ -112,16 +116,19 @@ public class ZyApiTool { item.setZyId(zyId); list.add(item); result.put(v, zyId); + try { + Thread.sleep(100); + } catch (Exception e) { + log.error("{}generateZyId休眠失败", TAG, e); + } } List zyIds = list.stream().map(ThirdZyIdDictEntity::getZyId).toList(); if (zyIds.isEmpty()) { - hasDuplicate = true; break; } List repetitionList = thirdZyIdDictMapper.getByZyIds(type, zyIds); if (ObjectUtil.isNotEmpty(repetitionList)) { hasDuplicate = true; - break; } } while (hasDuplicate); if (ObjectUtil.isNotEmpty(list)) { @@ -170,7 +177,7 @@ public class ZyApiTool { return body; } - private void prePost(Map params, boolean isZy) { + public void prePost(Map params, boolean isZy) { for (Map.Entry entry : params.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { @@ -183,10 +190,12 @@ public class ZyApiTool { String sign = generateSign(params, isZy); for (Map.Entry entry : params.entrySet()) { Object value = entry.getValue(); - if (value instanceof String) { - entry.setValue(Base64.encode((String) value)); - } else { - entry.setValue(Base64.encode(value.toString())); + if (ObjectUtil.isNotEmpty(value)) { + if (value instanceof String) { + entry.setValue(Base64.encode((String) value)); + } else { + entry.setValue(Base64.encode(value.toString())); + } } } params.put("sign", sign); 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..d75b6bcc3 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml @@ -44,9 +44,20 @@ oauth2: # 正元智慧 # https://gwyc.zj.gov.cn/API/%E7%9C%81%E5%B9%B3%E5%8F%B0API%E5%AF%B9%E6%8E%A5%E6%8E%A5%E5%8F%A3.html zy: - base-url: http://60.191.37.212:18079 - app-id: 689C8D6F5059A6F85B8BE45A49001ACB - app-secret: BD21DA0DEB8F0FC43246B0BD2FCAE6FF + # base-url: http://60.191.37.212:18079 + # 测试1 + # app-id: 689C8D6F5059A6F85B8BE45A49001ACB + # app-secret: BD21DA0DEB8F0FC43246B0BD2FCAE6FF + + # 测试2 + # app-id: FC455B0A788E334AC08FB3E1D8385C75 + # app-secret: E9131D0BCC9054808675DA1E2E199023 + + # 正式 + base-url: https://gwycport.zj.gov.cn + app-id: 0BBF0D9A7F1B4BD5280E59197E259AC6 + app-secret: 434752786ACBB37214F6617CC37AD0E9 + self-base-url: http://60.191.37.212:18079 self-app-id: xA5jF2vX4zO5mQ8tR9yE7rC7iI0fK0kI diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/test/java/com/bsd/pjcloud/admin/ZyTest.java b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/test/java/com/bsd/pjcloud/admin/ZyTest.java index 0fe520c1e..c281b5329 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/test/java/com/bsd/pjcloud/admin/ZyTest.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/test/java/com/bsd/pjcloud/admin/ZyTest.java @@ -80,15 +80,26 @@ public class ZyTest { ZySelfGetTokenVo token = zySelfService.getToken(tokenParams); String accessToken = token.getAccess_token(); +// ZySelfPayDto params = ZySelfPayDto +// .builder() +// .accNum(dzcUserDict.getZyId()) +// .cardAccNum(dzcWalletId) +// .amount("10") +// .serialNum("01234567890123456789") +// .dealTime(date) +// .opId("0123456789") +// .build(); + ZySelfPayDto params = ZySelfPayDto .builder() - .accNum(dzcUserDict.getZyId()) - .cardAccNum(dzcWalletId) - .amount("10") - .serialNum("01234567890123456789") - .dealTime(date) - .opId("0123456789") + .accNum("1741232987425846") + .cardAccNum("1877309001545244673") + .amount("0.01") + .serialNum("763") + .dealTime("2025-03-06 17:34:11") + .opId("") .build(); + String testJson = "{\"accNum\":\"MTc0MTIzMjk4NzQyNTg0Ng==\",\"amount\":\"MC4wMQ==\",\"cardAccNum\":\"MTg3NzMwOTAwMTU0NTI0NDY3Mw==\",\"dealTime\":\"MjAyNS0wMy0wNiAxNjo0NTowMA==\",\"opId\":\"\",\"serialNum\":\"NzYx\",\"sign\":\"3EFD38EA76BDC32165841852F0EEFD5E\"}"; Map paramsMap = BeanUtil.beanToMap(params); Map body = zyApiTool.getSelfEncryptionMap(paramsMap, "accNum", "cardAccNum", "amount", "serialNum", "dealTime", "opId"); ZySelfPayDto bodyObj = JSONUtil.toBean(JSONUtil.toJsonStr(body), ZySelfPayDto.class); 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..864b4b636 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,9 @@ public interface WalletManageMapper extends PjcloudBaseMapper itemList = baseMapper.selectBalance(dto); if (ObjectUtil.isEmpty(itemList)) continue; for (WalletManageBalanceVo j : itemList) { - j.setWalletTypeName(i.getName()); + // j.setWalletTypeName(i.getName()); walletPage.getRecords().stream().filter(v -> ObjectUtil.equals(v.getUserId(), j.getUserId())).findFirst().ifPresent(v -> { if (ObjectUtil.isNotEmpty(j.getBalance())) { v.setBalance(j.getBalance()); diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/thrid/WalletThirdZyServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/thrid/WalletThirdZyServiceImpl.java index 830c0bad6..3818dc2a5 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/thrid/WalletThirdZyServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/thrid/WalletThirdZyServiceImpl.java @@ -157,14 +157,14 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService { log.info("|{}| syncAllRole 错误 List为空", TAG); return; } - // 查询商户信息 - List 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/file/个人钱包记录明细.xlsx b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/file/个人钱包记录明细.xlsx index 04782dec9..3c61b7884 100644 Binary files a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/file/个人钱包记录明细.xlsx and b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/file/个人钱包记录明细.xlsx differ 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}