feat:增加钱包统计纬度,正元对接修改

This commit is contained in:
dzc committed 2025-03-06 16:46:12 +08:00
1 parent de3e27d819
commit 35e0f6fad9
19 files changed
+248 -116

No files matched your search

+1 -1
View File
@@ -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 '创建人',
@@ -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;
/**
* 导出相关
*/
@@ -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;
/**
* 导出相关
*/
@@ -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<Page<HardOrderSbVo>> pageListSb(@ParameterObject Page page, @RequestBody HardOrderDto dto) {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
return R.ok(HardOrderTotalService.pageListSb(page, dto));
public R<List<HardOrderSbVo>> pageListSb(@RequestBody HardOrderDto dto) {
return R.ok(HardOrderTotalService.listSb(dto));
}
@PostMapping("/page-list-cs")
@Operation(summary = "商户交易记录")
public R<Page<HardOrderCsVo>> pageListCs(@ParameterObject Page page, @RequestBody HardOrderDto dto) {
public R<List<HardOrderCsVo>> 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);
@@ -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<HardOrderEntity> {
return selectListByScope(commonWrapper(dto), DataScope.of());
}
Page<HardOrderSbVo> pageListSb(Page page, @Param("dto") HardOrderDto dto);
Page<HardOrderSbVo> listSb(Page page, @Param("dto") HardOrderDto dto);
List<HardOrderSbVo> listSb(@Param("dto") HardOrderDto dto);
@@ -12,12 +12,8 @@ import java.util.List;
public interface HardOrderTotalService {
Page<HardOrderSbVo> pageListSb(Page page, HardOrderDto dto);
List<HardOrderSbVo> listSb(HardOrderDto dto);
Page<HardOrderCsVo> pageListCs(Page page, HardOrderDto dto);
List<HardOrderCsVo> listCs(HardOrderDto dto);
List<HardDeptTotalVo> pageListDept(HardDeptTotalDto dto);
@@ -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<HardOrderSbVo> pageListSb(Page page, HardOrderDto dto) {
Page<HardOrderSbVo> list = hardOrderMapper.pageListSb(page, dto);
if (ObjectUtil.isNotEmpty(list)) {
// 商户
List<Long> mchIds = list.getRecords().stream().map(HardOrderSbVo::getMerchantId).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> mchList = remoteMchService.getByIds(mchIds).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
WalletDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId));
}
}
// 设备
List<Long> hardIds = list.getRecords().stream().map(HardOrderSbVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
HardManagerDto hardManagerDto = new HardManagerDto();
hardManagerDto.setIds(hardIds);
List<HardManagerEntity> hardList = hardManagerMapper.list(hardManagerDto);
if (ObjectUtil.isNotEmpty(hardList)) {
HardUtil.convertHardList(list.getRecords(), CollectionUtils.convertMap(hardList, HardManagerEntity::getId));
}
}
}
return list;
}
@Override
public List<HardOrderSbVo> listSb(HardOrderDto dto) {
List<HardOrderSbVo> list = hardOrderMapper.listSb(dto);
if (ObjectUtil.isNotEmpty(list)) {
// 查询总流水
CompletableFuture<List<HardOrderSbVo>> totalListFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
return hardOrderMapper.listSb(totalDto);
});
// 扣款总流水
CompletableFuture<List<HardOrderSbVo>> refundListFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto refundDto = BeanUtil.toBean(dto, HardOrderDto.class);
refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes());
return hardOrderMapper.listSb(refundDto);
});
// 盈利
CompletableFuture<List<HardOrderSbVo>> profitListFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto profitDto = BeanUtil.toBean(dto, HardOrderDto.class);
profitDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
return hardOrderMapper.listSb(profitDto);
});
CompletableFuture<Void> allFutures = CompletableFuture.allOf(totalListFuture, refundListFuture, profitListFuture);
allFutures.join();
List<HardOrderSbVo> totalList = totalListFuture.join();
List<HardOrderSbVo> refundList = refundListFuture.join();
List<HardOrderSbVo> 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<Long> mchIds = list.stream().map(HardOrderSbVo::getMerchantId).distinct().toList();
List<Long> mchIds = totalList.stream().map(HardOrderSbVo::getMerchantId).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> 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<Long> hardIds = list.stream().map(HardOrderSbVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
List<Long> hardIds = totalList.stream().map(HardOrderSbVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
HardManagerDto hardManagerDto = new HardManagerDto();
hardManagerDto.setIds(hardIds);
List<HardManagerEntity> 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<HardOrderCsVo> pageListCs(Page page, HardOrderDto dto) {
Page<HardOrderCsVo> list = hardOrderMapper.pageListCs(page, dto);
if (ObjectUtil.isNotEmpty(list)) {
// 商户
List<Long> mchIds = list.getRecords().stream().map(HardOrderCsVo::getMerchantId).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> 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<HardOrderCsVo> listCs(HardOrderDto dto) {
List<HardOrderCsVo> list = hardOrderMapper.listCs(dto);
if (ObjectUtil.isNotEmpty(list)) {
// 查询总流水
CompletableFuture<List<HardOrderCsVo>> totalListFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
return hardOrderMapper.listCs(totalDto);
});
// 扣款总流水
CompletableFuture<List<HardOrderCsVo>> refundListFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto refundDto = BeanUtil.toBean(dto, HardOrderDto.class);
refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes());
return hardOrderMapper.listCs(refundDto);
});
// 盈利
CompletableFuture<List<HardOrderCsVo>> profitListFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto profitDto = BeanUtil.toBean(dto, HardOrderDto.class);
profitDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
return hardOrderMapper.listCs(profitDto);
});
CompletableFuture<Void> allFutures = CompletableFuture.allOf(totalListFuture, refundListFuture, profitListFuture);
allFutures.join();
List<HardOrderCsVo> totalList = totalListFuture.join();
List<HardOrderCsVo> refundList = refundListFuture.join();
List<HardOrderCsVo> 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<Long> mchIds = list.stream().map(HardOrderCsVo::getMerchantId).distinct().toList();
List<Long> mchIds = totalList.stream().map(HardOrderCsVo::getMerchantId).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> 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
@@ -112,7 +112,7 @@
</if>
</sql>
<select id="pageListSb" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo">
<select id="listSb" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo">
select
a.hard_id,
a.merchant_id,
@@ -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<String, Object> 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);
}
@@ -155,7 +155,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
Map<String, String> userIdDict = zyApiTool.generateZyId(bizType, userList);
// 转换身份编号
List<String> roleList = dto.stream().map(ZyMerSyncAccountInfoDto::getAccClassID).distinct().toList();
Map<String, String> roleIdDict = zyApiTool.generateZyId(bizType, roleList);
Map<String, String> 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<String> roleList = dto.stream().map(ZyMerSyncAccClassInfoDto::getEPID).distinct().toList();
Map<String, String> roleIdDict = zyApiTool.generateZyId(bizType, roleList);
List<String> deptList = dto.stream().map(ZyMerSyncAccClassInfoDto::getEPID).distinct().toList();
Map<String, String> deptIdDict = zyApiTool.generateZyId(ThirdZyBizEnumType.SYNC_ENTERPRISE_INFO, deptList);
// 转换身份id
List<String> roleList = dto.stream().map(ZyMerSyncAccClassInfoDto::getAccClassID).distinct().toList();
Map<String, String> 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<String, Object> encryptionBody = new HashMap<>();
@@ -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);
}
}
@@ -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<ThirdZyIdDictEntity> 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());
@@ -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
@@ -36,7 +36,8 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
)
.orderByDesc(WalletManageEntity::getCreateTime);
.orderByDesc(WalletManageEntity::getCreateTime)
.orderByDesc(WalletManageEntity::getWalletTypeId);
if (ObjectUtil.isNotEmpty(dto.getIsInclude())) {
if (dto.getIsInclude()) {
wrapper.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletManageEntity::getDeptId, dto.getDeptIds());
@@ -157,14 +157,14 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService {
log.info("|{}| syncAllRole 错误 List为空", TAG);
return;
}
// 查询商户信息
List<MchManageVo> mchList = mchManageService.list(new MchManageDto());
if (ObjectUtil.isEmpty(mchList)) {
log.info("|{}| syncAllRole 错误 mchList为空", TAG);
// 查询部门信息
List<SysDept> deptList = remoteDeptService.getAllDept(null).getData();
if (ObjectUtil.isEmpty(deptList)) {
log.info("|{}| syncAllRole 错误 deptList为空", TAG);
return;
}
for (MchManageVo i : mchList) {
List<ZyMerSyncAccClassInfoDto> syncList = new ArrayList<>();
List<ZyMerSyncAccClassInfoDto> 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<WalletManageVo> userPage = walletManageService.scopePageList(page, query, dataScope);
if (ObjectUtil.isEmpty(userPage.getRecords())) return false;
if (ObjectUtil.isEmpty(userPage.getRecords())) return 0;
List<ZyMerSyncAccountInfoDto> 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;
@@ -59,7 +59,7 @@
a.del_flag = 0
<if test="dto.walletRecordMonth != null">
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') &lt;= #{dto.walletRecordMonth})
</if>
<if test="dto.userId != null">
AND a.user_id = #{dto.userId}