Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
558ba6229b
41 files changed
+1312
-185
No files matched your search
@@ -0,0 +1,30 @@
|
||||
create database `pjcloudx_thirdparty` default character set utf8mb4 collate utf8mb4_general_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for third_zy_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `third_zy_log`;
|
||||
CREATE TABLE `third_zy_log`
|
||||
(
|
||||
`id` bigint NOT NULL COMMENT '主键',
|
||||
`biz_type` tinytext NOT NULL COMMENT '同步类型',
|
||||
`biz_id` varchar(2048) DEFAULT NULL COMMENT '同步类型id',
|
||||
`api_url` text DEFAULT NULL COMMENT 'api url',
|
||||
`org_res` text DEFAULT NULL COMMENT '原始res',
|
||||
`encipher_res` text DEFAULT NULL COMMENT '加密res',
|
||||
`org_req` text DEFAULT NULL COMMENT '原始req',
|
||||
`encipher_req` text DEFAULT NULL COMMENT '加密req',
|
||||
`error` text DEFAULT NULL COMMENT '调用错误',
|
||||
`version` char(64) DEFAULT NULL COMMENT '同步版本格式化为14位字符串,如果是数字不足14位的,前面补0',
|
||||
`time_consuming` char(64) DEFAULT NULL COMMENT '同步版本格式化为14位字符串,如果是数字不足14位的,前面补0',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`create_by` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
`update_by` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除时间',
|
||||
`tenant_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
ROW_FORMAT = DYNAMIC COMMENT ='正元日志表';
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.bsd.pjcloud.thirdparty.api.feign;
|
||||
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncEnterpriseInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideAuthenticationDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideConsumptionDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideCorrectDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignSyncNativeCardTradeInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccClassInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccountInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncDealerInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncEnterpriseInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideAuthenticationVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideConsumptionVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideCorrectVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(contextId = "remoterThirdZyService", value = ServiceNameConstants.THIRDPARTY_SERVICE)
|
||||
public interface RemoterThirdZyService {
|
||||
|
||||
/* ************************************* start 正元本地一卡通交易数据同步 start ************************************* */
|
||||
|
||||
/**
|
||||
* 本地一卡通交易数据同步
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/third-zy-foreign/sync-native-card")
|
||||
R<ZyForeignSyncNativeCardTradeInfoVo> syncNativeCardTradeInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
|
||||
|
||||
/* ************************************* end 正元本地一卡通交易数据同步 end ************************************* */
|
||||
|
||||
|
||||
/* ************************************* start 数据同步 start ************************************* */
|
||||
|
||||
/**
|
||||
* 商户信息同步
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/third-zy-mer/sync-dealer-info")
|
||||
R<ZyMerSyncDealerInfoVo> syncDealerInfo(@RequestBody List<ZyMerSyncDealerInfoDto> dto);
|
||||
|
||||
/**
|
||||
* 记账单位同步
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/third-zy-mer/sync-enterprise-info")
|
||||
R<ZyMerSyncEnterpriseInfoVo> syncEnterpriseInfoApi(@RequestBody List<ZyMerSyncEnterpriseInfoDto> dto);
|
||||
|
||||
/**
|
||||
* 账户信息同步
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/third-zy-mer/sync-account-info")
|
||||
R<ZyMerSyncAccountInfoVo> syncAccountInfoApi(@RequestBody List<ZyMerSyncAccountInfoDto> dto);
|
||||
|
||||
/**
|
||||
* 身份信息同步
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/third-zy-mer/sync-acc-class-info")
|
||||
R<ZyMerSyncAccClassInfoVo> syncAccClassInfoApi(@RequestBody List<ZyMerSyncAccClassInfoDto> dto);
|
||||
|
||||
/* ************************************* end 数据同步 end ************************************* */
|
||||
|
||||
/* ************************************* start 数据同步 start ************************************* */
|
||||
|
||||
/**
|
||||
* 统一身份验证功能
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/third-zy-stride/authentication")
|
||||
R<ZyStrideAuthenticationVo> authenticationApi(@RequestBody ZyStrideAuthenticationDto dto);
|
||||
|
||||
/**
|
||||
* 智慧园区通刷平台提供消费接口
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/third-zy-stride/consumption")
|
||||
R<ZyStrideConsumptionVo> consumptionApi(@RequestBody ZyStrideConsumptionDto dto);
|
||||
|
||||
/**
|
||||
* 智慧园区通刷平台提供冲正接口
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/third-zy-stride/correct")
|
||||
R<ZyStrideCorrectVo> correctApi(@RequestBody ZyStrideCorrectDto dto);
|
||||
|
||||
/* ************************************* end 数据同步 end ************************************* */
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.bsd.pjcloud.thirdparty.constant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 打印状态
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ThirdZyBizEnumType {
|
||||
|
||||
// 数据同步
|
||||
SYNC_DEALER_INFO("10", "商户信息同步"),
|
||||
SYNC_ENTERPRISE_INFO("20", "记账单位同步"),
|
||||
SYNC_ACCOUNT_INFO("30", "账户信息同步"),
|
||||
SYNC_ACC_CLASS_INFO("40", "身份信息同步"),
|
||||
|
||||
// 跨单位交易
|
||||
AUTHENTICATION("50", "统一身份验证功能"),
|
||||
CONSUMPTION("60", "智慧园区通刷平台提供消费接口"),
|
||||
CORRECT("70", "智慧园区通刷平台提供冲正接口"),
|
||||
|
||||
// 本地一卡通交易数据同步
|
||||
SYNC_NATIVE_CARD_INFO("80", "本地一卡通交易数据同步"),
|
||||
GET_REGION_ID_BY_TOKEN("90", "获取区域编码"),
|
||||
|
||||
// 第三方需提供的接口
|
||||
SELF_CHECK_SYSTEM_STATUS("100", "第三方url健康探测"),
|
||||
SELF_CORRECT("110", "第三方一卡通系统提供冲正接口"),
|
||||
SELF_PAY("120", "第三方一卡通系统提供扣费接口"),
|
||||
SELF_GET_TOKEN("130", "第三方提供获取token"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static ThirdZyBizEnumType valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class ZyMerSyncAccountInfoDto {
|
||||
/**
|
||||
* 卡片状态,0销卡;1有效;2挂失;3冻结;4预销卡;5锁卡,默认1
|
||||
*/
|
||||
private String CardStatus;
|
||||
private Integer CardStatus;
|
||||
|
||||
/**
|
||||
* 该卡在所属接入系统中的所属单位编号
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public class ZyMerSyncEnterpriseInfoDto {
|
||||
/**
|
||||
* 记账单位是否有效0:禁用 1:有效
|
||||
*/
|
||||
private String IsValid;
|
||||
private Integer IsValid;
|
||||
|
||||
/**
|
||||
* 每次推送版本号,格式化为14位字符串,如果是数字不足14位的,前面补0。
|
||||
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
package com.bsd.pjcloud.thirdparty.entity.zy;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 正元日志表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-03-04 09:05:56
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TenantTable
|
||||
@TableName("third_zy_log")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "正元日志表")
|
||||
public class ThirdZyLogEntity extends Model<ThirdZyLogEntity> {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 同步类型
|
||||
*/
|
||||
@Schema(description = "同步类型")
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* api url
|
||||
*/
|
||||
@Schema(description = "apiUrl")
|
||||
private String apiUrl;
|
||||
|
||||
/**
|
||||
* 同步类型id
|
||||
*/
|
||||
@Schema(description = "同步类型id")
|
||||
private String bizId;
|
||||
|
||||
/**
|
||||
* 原始res
|
||||
*/
|
||||
@Schema(description = "原始res")
|
||||
private String orgRes;
|
||||
|
||||
/**
|
||||
* 加密res
|
||||
*/
|
||||
@Schema(description = "加密res")
|
||||
private String encipherRes;
|
||||
|
||||
/**
|
||||
* 原始req
|
||||
*/
|
||||
@Schema(description = "原始req")
|
||||
private String orgReq;
|
||||
|
||||
/**
|
||||
* 加密req
|
||||
*/
|
||||
@Schema(description = "加密req")
|
||||
private String encipherReq;
|
||||
|
||||
/**
|
||||
* 调用错误
|
||||
*/
|
||||
@Schema(description = "调用错误")
|
||||
private String error;
|
||||
|
||||
/**
|
||||
* 同步版本格式化为14位字符串,如果是数字不足14位的,前面补0
|
||||
*/
|
||||
@Schema(description = "同步版本格式化为14位字符串,如果是数字不足14位的,前面补0")
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 同步版本格式化为14位字符串,如果是数字不足14位的,前面补0
|
||||
*/
|
||||
@Schema(description = "同步版本格式化为14位字符串,如果是数字不足14位的,前面补0")
|
||||
private String timeConsuming;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "更新人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除时间")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* tenantId
|
||||
*/
|
||||
@Schema(description = "tenantId")
|
||||
private Long tenantId;
|
||||
}
|
||||
+1
@@ -1 +1,2 @@
|
||||
com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdPartyAuthService
|
||||
com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdZyService
|
||||
@@ -115,6 +115,10 @@
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-common-idempotent</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller.zy;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyForeignService;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignSyncNativeCardTradeInfoVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/third-zy-foreign")
|
||||
@Tag(description = "third-zy-foreign", name = "正元本地一卡通交易数据同步")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdZyForeignController {
|
||||
|
||||
private final ThirdZyForeignService zyForeignService;
|
||||
|
||||
/* ************************************* start 原创调用 start ************************************* */
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "本地一卡通交易数据同步")
|
||||
@GetMapping("/sync-native-card")
|
||||
public R<ZyForeignSyncNativeCardTradeInfoVo> syncNativeCardTradeInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto) {
|
||||
return R.ok(zyForeignService.syncNativeCardTradeInfoApi(dto));
|
||||
}
|
||||
|
||||
/* ************************************* end 原创调用 end ************************************* */
|
||||
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller.zy;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
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.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdZyLogService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 正元日志表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-03-04 09:05:56
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/third-zy-log")
|
||||
@Tag(description = "third-zy-log", name = "正元日志表管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdZyLogController {
|
||||
|
||||
private final ThirdZyLogService thirdZyLogService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdZyLog_view')")
|
||||
public R getThirdZyLogPage(@ParameterObject Page page, @ParameterObject ThirdZyLogEntity thirdZyLog) {
|
||||
LambdaQueryWrapper<ThirdZyLogEntity> wrapper = Wrappers.lambdaQuery();
|
||||
return R.ok(thirdZyLogService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdZyLog_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(thirdZyLogService.getById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "新增正元日志表", description = "新增正元日志表")
|
||||
@SysLog("新增正元日志表")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdZyLog_add')")
|
||||
public R save(@RequestBody ThirdZyLogEntity thirdZyLog) {
|
||||
return R.ok(thirdZyLogService.save(thirdZyLog));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改正元日志表", description = "修改正元日志表")
|
||||
@SysLog("修改正元日志表")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdZyLog_edit')")
|
||||
public R updateById(@RequestBody ThirdZyLogEntity thirdZyLog) {
|
||||
return R.ok(thirdZyLogService.updateById(thirdZyLog));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id删除正元日志表", description = "通过id删除正元日志表")
|
||||
@SysLog("通过id删除正元日志表")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdZyLog_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(thirdZyLogService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdZyLog_export')")
|
||||
public List<ThirdZyLogEntity> export(ThirdZyLogEntity thirdZyLog, Long[] ids) {
|
||||
return thirdZyLogService.list(Wrappers.lambdaQuery(thirdZyLog).in(ArrayUtil.isNotEmpty(ids), ThirdZyLogEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller.zy;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncEnterpriseInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyMerService;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignSyncNativeCardTradeInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccClassInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccountInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncDealerInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncEnterpriseInfoVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/third-zy-mer")
|
||||
@Tag(description = "third-zy-mer", name = "数据同步")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdZyMerController {
|
||||
|
||||
private final ThirdZyMerService thirdZyMerService;
|
||||
|
||||
/* ************************************* start 原创调用 start ************************************* */
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "商户信息同步")
|
||||
@GetMapping("/sync-dealer-info")
|
||||
public R<ZyMerSyncDealerInfoVo> syncDealerInfo(@RequestBody List<ZyMerSyncDealerInfoDto> dto) {
|
||||
return R.ok(thirdZyMerService.syncDealerInfoApi(dto));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "记账单位同步")
|
||||
@GetMapping("/sync-enterprise-info")
|
||||
public R<ZyMerSyncEnterpriseInfoVo> syncEnterpriseInfoApi(@RequestBody List<ZyMerSyncEnterpriseInfoDto> dto) {
|
||||
return R.ok(thirdZyMerService.syncEnterpriseInfoApi(dto));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "账户信息同步")
|
||||
@GetMapping("/sync-account-info")
|
||||
public R<ZyMerSyncAccountInfoVo> syncAccountInfoApi(@RequestBody List<ZyMerSyncAccountInfoDto> dto) {
|
||||
return R.ok(thirdZyMerService.syncAccountInfoApi(dto));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "身份信息同步")
|
||||
@GetMapping("/sync-acc-class-info")
|
||||
public R<ZyMerSyncAccClassInfoVo> syncAccClassInfoApi(@RequestBody List<ZyMerSyncAccClassInfoDto> dto) {
|
||||
return R.ok(thirdZyMerService.syncAccClassInfoApi(dto));
|
||||
}
|
||||
|
||||
/* ************************************* end 原创调用 end ************************************* */
|
||||
|
||||
}
|
||||
+8
-6
@@ -1,9 +1,10 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller.zy;
|
||||
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfCorrectDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfGetTokenDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfPayDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ZySelfService;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZySelfService;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfCorrectVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfGetTokenVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfPayVo;
|
||||
@@ -14,20 +15,20 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/third/zy")
|
||||
@Tag(description = "thirdPartyDept", name = "正元接口对接")
|
||||
@RequestMapping("/third-zy-self")
|
||||
@Tag(description = "/third-zy-self", name = "正元接口对接")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ZySelfController {
|
||||
public class ThirdZySelfController {
|
||||
|
||||
private final ZySelfService zySelfService;
|
||||
private final ThirdZySelfService zySelfService;
|
||||
|
||||
@GetMapping("/checkSystemStatus")
|
||||
@Operation(summary = "第三方url健康探测", description = "第三方url健康探测")
|
||||
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
||||
public Map<String, Object> checkSystemStatus() {
|
||||
return zySelfService.checkSystemStatus();
|
||||
}
|
||||
@@ -47,6 +48,7 @@ public class ZySelfController {
|
||||
|
||||
@PostMapping("/getToken")
|
||||
@Operation(summary = "第三方一卡通系统提供扣费接口", description = "第三方一卡通系统提供扣费接口")
|
||||
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
||||
public ZySelfPayVo pay(@RequestBody ZySelfPayDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
||||
return zySelfService.pay(params, accessToken);
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller.zy;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideAuthenticationDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideConsumptionDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideCorrectDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyStrideService;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideAuthenticationVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideConsumptionVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideCorrectVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/third-zy-stride")
|
||||
@Tag(description = "third/zy/stride", name = "跨单位交易")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdZyStrideController {
|
||||
|
||||
private final ThirdZyStrideService thirdZyStrideService;
|
||||
|
||||
/* ************************************* start 原创调用 start ************************************* */
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "统一身份验证功能")
|
||||
@GetMapping("/authentication")
|
||||
public R<ZyStrideAuthenticationVo> authenticationApi(@RequestBody ZyStrideAuthenticationDto dto) {
|
||||
return R.ok(thirdZyStrideService.authenticationApi(dto));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "智慧园区通刷平台提供消费接口")
|
||||
@GetMapping("/consumption")
|
||||
public R<ZyStrideConsumptionVo> syncDealerInfo(@RequestBody ZyStrideConsumptionDto dto) {
|
||||
return R.ok(thirdZyStrideService.consumptionApi(dto));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "智慧园区通刷平台提供冲正接口")
|
||||
@GetMapping("/correct")
|
||||
public R<ZyStrideCorrectVo> correctApi(@RequestBody ZyStrideCorrectDto dto) {
|
||||
return R.ok(thirdZyStrideService.correctApi(dto));
|
||||
}
|
||||
|
||||
/* ************************************* end 原创调用 end ************************************* */
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.bsd.pjcloud.thirdparty.mapper.zy;
|
||||
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ThirdZyLogMapper extends PjcloudBaseMapper<ThirdZyLogEntity> {
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.bsd.pjcloud.thirdparty.service;
|
||||
|
||||
public interface ZyDoForeignService {
|
||||
public interface ThirdZyDoForeignService {
|
||||
|
||||
// 本地一卡通交易数据同步
|
||||
void syncNativeCardTradeInfo();
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.bsd.pjcloud.thirdparty.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
|
||||
public interface ThirdZyLogService extends IService<ThirdZyLogEntity> {
|
||||
|
||||
}
|
||||
+1
-2
@@ -1,11 +1,10 @@
|
||||
package com.bsd.pjcloud.thirdparty.service.impl;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignGetRegionIdByTokenDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignGetRegionIdByTokenVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignSyncNativeCardTradeInfoVo;
|
||||
|
||||
public interface ZyForeignService {
|
||||
public interface ThirdZyForeignService {
|
||||
|
||||
/**
|
||||
* 本地一卡通交易数据同步
|
||||
+4
-4
@@ -8,7 +8,7 @@ import com.bsd.pjcloud.thirdparty.vo.zy.mer.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ZyMerService {
|
||||
public interface ThirdZyMerService {
|
||||
|
||||
/**
|
||||
* 商户信息同步
|
||||
@@ -18,16 +18,16 @@ public interface ZyMerService {
|
||||
/**
|
||||
* 记账单位同步
|
||||
*/
|
||||
ZyMerSyncEnterpriseInfoVo syncEnterpriseInfoApi(ZyMerSyncEnterpriseInfoDto dto);
|
||||
ZyMerSyncEnterpriseInfoVo syncEnterpriseInfoApi(List<ZyMerSyncEnterpriseInfoDto> dto);
|
||||
|
||||
/**
|
||||
* 账户信息同步
|
||||
*/
|
||||
ZyMerSyncAccountInfoVo syncAccountInfoApi(ZyMerSyncAccountInfoDto dto);
|
||||
ZyMerSyncAccountInfoVo syncAccountInfoApi(List<ZyMerSyncAccountInfoDto> dto);
|
||||
|
||||
/**
|
||||
* 身份信息同步
|
||||
*/
|
||||
ZyMerSyncAccClassInfoVo syncAccClassInfoApi(ZyMerSyncAccClassInfoDto dto);
|
||||
ZyMerSyncAccClassInfoVo syncAccClassInfoApi(List<ZyMerSyncAccClassInfoDto> dto);
|
||||
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfPayVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ZySelfService {
|
||||
public interface ThirdZySelfService {
|
||||
|
||||
/**
|
||||
* 第三方url健康探测
|
||||
+1
-1
@@ -7,7 +7,7 @@ import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideAuthenticationVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideConsumptionVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideCorrectVo;
|
||||
|
||||
public interface ZyStrideService {
|
||||
public interface ThirdZyStrideService {
|
||||
|
||||
/**
|
||||
* 统一身份验证功能
|
||||
+3
-3
@@ -2,7 +2,7 @@ package com.bsd.pjcloud.thirdparty.service.impl.zy;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.ZyDoForeignService;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdZyDoForeignService;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignGetRegionIdByTokenVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignSyncNativeCardTradeInfoVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -14,9 +14,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ZyDoForeignServiceImpl implements ZyDoForeignService {
|
||||
public class ThirdZyDoForeignServiceImpl implements ThirdZyDoForeignService {
|
||||
|
||||
private final ZyForeignServiceImpl zyForeignServiceImpl;
|
||||
private final ThirdZyForeignServiceImpl zyForeignServiceImpl;
|
||||
|
||||
@Override
|
||||
public void syncNativeCardTradeInfo() {
|
||||
+33
-6
@@ -5,9 +5,9 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignGetRegionIdByTokenDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ZyForeignService;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyForeignService;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApi;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApiTool;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.ZyBaseEncryptVo;
|
||||
@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,7 +26,7 @@ import java.util.Map;
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ZyForeignServiceImpl implements ZyForeignService {
|
||||
public class ThirdZyForeignServiceImpl implements ThirdZyForeignService {
|
||||
|
||||
private final String TAG = "正元跨部门api";
|
||||
|
||||
@@ -33,31 +34,46 @@ public class ZyForeignServiceImpl implements ZyForeignService {
|
||||
|
||||
private final ZyApiTool zyApiTool;
|
||||
|
||||
private final ThirdZyLogServiceImpl thirdZyLogService;
|
||||
|
||||
/**
|
||||
* 本地一卡通交易数据同步
|
||||
*/
|
||||
@Override
|
||||
public ZyForeignSyncNativeCardTradeInfoVo syncNativeCardTradeInfoApi(ZyForeignSyncNativeCardTradeInfoDto dto) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Foreign.SYNC_NATIVE_CARD_TRADE_INFO;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("regionCode", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||
entity.setEncipherReq(body);
|
||||
String res = HttpRequest.post(url)
|
||||
.body(body)
|
||||
.form(body)
|
||||
.execute()
|
||||
.body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyForeignSyncNativeCardTradeInfoVo vo = JSONUtil.toBean(res, ZyForeignSyncNativeCardTradeInfoVo.class);
|
||||
if (!vo.isSuccess()) {
|
||||
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
|
||||
}
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||syncNativeCardTradeInfoApi|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||syncNativeCardTradeInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -67,13 +83,17 @@ public class ZyForeignServiceImpl implements ZyForeignService {
|
||||
*/
|
||||
@Override
|
||||
public ZyForeignGetRegionIdByTokenVo.VoData getRegionIdByToken() {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Foreign.GET_REGION_ID_BY_TOKEN;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
entity.setApiUrl(url);
|
||||
String res = HttpRequest.get(url).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyBaseEncryptVo baseEncryptVo = JSONUtil.toBean(res, ZyBaseEncryptVo.class);
|
||||
if (ObjectUtil.isEmpty(baseEncryptVo)) {
|
||||
throw new RuntimeException(String.format("解密错误res|%s|url|%s|res|%s|", res, url, baseEncryptVo));
|
||||
@@ -83,9 +103,16 @@ public class ZyForeignServiceImpl implements ZyForeignService {
|
||||
}
|
||||
String json = Base64.decodeStr(baseEncryptVo.getData());
|
||||
ZyForeignGetRegionIdByTokenVo.VoData vo = JSONUtil.toBean(json, ZyForeignGetRegionIdByTokenVo.VoData.class);
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||getRegionIdByToken|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||getRegionIdByToken|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.bsd.pjcloud.thirdparty.service.impl.zy;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.mapper.zy.ThirdZyLogMapper;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdZyLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
/**
|
||||
* 正元日志表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-03-04 09:05:56
|
||||
*/
|
||||
@Service
|
||||
public class ThirdZyLogServiceImpl extends ServiceImpl<ThirdZyLogMapper, ThirdZyLogEntity> implements ThirdZyLogService {
|
||||
}
|
||||
+71
-19
@@ -5,11 +5,13 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
||||
import com.bsd.pjcloud.thirdparty.constant.ThirdZyBizEnumType;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncEnterpriseInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ZyMerService;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyMerService;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApi;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApiTool;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.*;
|
||||
@@ -18,16 +20,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ZyMerServiceImpl implements ZyMerService {
|
||||
public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
||||
|
||||
private final String TAG = "正元商户api";
|
||||
|
||||
@@ -35,11 +34,16 @@ public class ZyMerServiceImpl implements ZyMerService {
|
||||
|
||||
private final ZyApiTool zyApiTool;
|
||||
|
||||
private final ThirdZyLogServiceImpl thirdZyLogService;
|
||||
|
||||
/**
|
||||
* 商户信息同步
|
||||
*/
|
||||
@Override
|
||||
public ZyMerSyncDealerInfoVo syncDealerInfoApi(List<ZyMerSyncDealerInfoDto> dto) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
entity.setBizType(ThirdZyBizEnumType.SYNC_DEALER_INFO.getType());
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (ObjectUtil.isEmpty(dto)) {
|
||||
return null;
|
||||
}
|
||||
@@ -53,22 +57,29 @@ public class ZyMerServiceImpl implements ZyMerService {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("dealers", listMap);
|
||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||
String res = HttpRequest.post(url)
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.body(body)
|
||||
.execute()
|
||||
.body();
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyMerSyncDealerInfoVo vo = JSONUtil.toBean(res, ZyMerSyncDealerInfoVo.class);
|
||||
if (!vo.isSuccess()) {
|
||||
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
|
||||
}
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||syncDealerInfoApi|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||syncNativeCardTradeInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -77,27 +88,42 @@ public class ZyMerServiceImpl implements ZyMerService {
|
||||
* 记账单位同步
|
||||
*/
|
||||
@Override
|
||||
public ZyMerSyncEnterpriseInfoVo syncEnterpriseInfoApi(ZyMerSyncEnterpriseInfoDto dto) {
|
||||
public ZyMerSyncEnterpriseInfoVo syncEnterpriseInfoApi(List<ZyMerSyncEnterpriseInfoDto> dto) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
entity.setBizType(ThirdZyBizEnumType.SYNC_ENTERPRISE_INFO.getType());
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ENTERPRISE_INFO;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("enterprises", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||
entity.setEncipherReq(body);
|
||||
String res = HttpRequest.post(url)
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.body(body)
|
||||
.execute()
|
||||
.body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyMerSyncEnterpriseInfoVo vo = JSONUtil.toBean(res, ZyMerSyncEnterpriseInfoVo.class);
|
||||
if (!vo.isSuccess()) {
|
||||
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
|
||||
}
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||syncEnterpriseInfoApi|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||syncEnterpriseInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -106,13 +132,18 @@ public class ZyMerServiceImpl implements ZyMerService {
|
||||
* 账户信息同步
|
||||
*/
|
||||
@Override
|
||||
public ZyMerSyncAccountInfoVo syncAccountInfoApi(ZyMerSyncAccountInfoDto dto) {
|
||||
public ZyMerSyncAccountInfoVo syncAccountInfoApi(List<ZyMerSyncAccountInfoDto> dto) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ACCOUNT_INFO;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("accounts", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||
entity.setEncipherReq(body);
|
||||
String res = HttpRequest.post(url)
|
||||
.body(body)
|
||||
.execute()
|
||||
@@ -120,13 +151,21 @@ public class ZyMerServiceImpl implements ZyMerService {
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyMerSyncAccountInfoVo vo = JSONUtil.toBean(res, ZyMerSyncAccountInfoVo.class);
|
||||
if (!vo.isSuccess()) {
|
||||
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
|
||||
}
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||syncAccountInfoApi|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||syncAccountInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -135,13 +174,18 @@ public class ZyMerServiceImpl implements ZyMerService {
|
||||
* 身份信息同步
|
||||
*/
|
||||
@Override
|
||||
public ZyMerSyncAccClassInfoVo syncAccClassInfoApi(ZyMerSyncAccClassInfoDto dto) {
|
||||
public ZyMerSyncAccClassInfoVo syncAccClassInfoApi(List<ZyMerSyncAccClassInfoDto> dto) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ACC_CLASS_INFO;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("accClasses", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||
entity.setEncipherReq(body);
|
||||
String res = HttpRequest.post(url)
|
||||
.body(body)
|
||||
.execute()
|
||||
@@ -149,13 +193,21 @@ public class ZyMerServiceImpl implements ZyMerService {
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyMerSyncAccClassInfoVo vo = JSONUtil.toBean(res, ZyMerSyncAccClassInfoVo.class);
|
||||
if (!vo.isSuccess()) {
|
||||
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
|
||||
}
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||syncAccClassInfoApi|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||syncAccClassInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
+35
-7
@@ -10,7 +10,9 @@ import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfCorrectDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfGetTokenDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfPayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfTokenDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ZySelfService;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZySelfService;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApi;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.ZyBaseVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfCorrectVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfGetTokenVo;
|
||||
@@ -24,6 +26,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -33,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ZySelfServiceImpl implements ZySelfService {
|
||||
public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
|
||||
private final String TAG = "第三方需提供的接口api";
|
||||
|
||||
@@ -41,15 +44,31 @@ public class ZySelfServiceImpl implements ZySelfService {
|
||||
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
|
||||
private final ThirdZyLogServiceImpl thirdZyLogService;
|
||||
|
||||
/**
|
||||
* 第三方url健康探测
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> checkSystemStatus() {
|
||||
String systemTime = DateUtil.formatDateTime(new Date());
|
||||
Map<String, Object> result = Map.of("systemTime", systemTime);
|
||||
log.info("|{}|checkSystemStatus res|{}|", TAG, JSONUtil.toJsonStr(result));
|
||||
return result;
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
entity.setApiUrl(ZyApi.Self.CHECK_SYSTEM_STATUS);
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
String systemTime = DateUtil.formatDateTime(new Date());
|
||||
Map<String, Object> result = Map.of("systemTime", systemTime);
|
||||
log.info("|{}|checkSystemStatus res|{}|", TAG, JSONUtil.toJsonStr(result));
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
String error = String.format("|%s||checkSystemStatus|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
return null;
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +109,9 @@ public class ZySelfServiceImpl implements ZySelfService {
|
||||
*/
|
||||
@Override
|
||||
public ZySelfGetTokenVo getToken(ZySelfGetTokenDto params) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
entity.setApiUrl(ZyApi.Self.GET_TOKEN);
|
||||
long startTime = System.currentTimeMillis();
|
||||
ZySelfGetTokenVo result = new ZySelfGetTokenVo();
|
||||
result.setCode(ZyBaseVo.errorCode);
|
||||
if (ObjectUtil.isEmpty(params.getAppid()) || ObjectUtil.equals(params.getAppid(), zyConfig.getSelfAppId())) {
|
||||
@@ -110,9 +132,15 @@ public class ZySelfServiceImpl implements ZySelfService {
|
||||
result.setExpires_in(zyConfig.getSelfExpiresIn().toString());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|getToken意外的错误dto|{}|error|{}|stack|{}|", TAG, JSONUtil.toJsonStr(params), e.getMessage(), e.getStackTrace());
|
||||
String error = String.format("|%s||getToken|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
result.setMsg(ZyBaseVo.defaultErrorMsg);
|
||||
return result;
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
+48
-6
@@ -7,10 +7,10 @@ import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideAuthenticationDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideConsumptionDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideCorrectDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ZyStrideService;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyStrideService;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApi;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApiTool;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncDealerInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideAuthenticationVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideConsumptionVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideCorrectVo;
|
||||
@@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ZyStrideServiceImpl implements ZyStrideService {
|
||||
public class ThirdZyStrideServiceImpl implements ThirdZyStrideService {
|
||||
|
||||
private final String TAG = "正元外来人员api";
|
||||
|
||||
@@ -34,17 +35,24 @@ public class ZyStrideServiceImpl implements ZyStrideService {
|
||||
|
||||
private final ZyApiTool zyApiTool;
|
||||
|
||||
private final ThirdZyLogServiceImpl thirdZyLogService;
|
||||
|
||||
/**
|
||||
* 统一身份验证功能
|
||||
*/
|
||||
@Override
|
||||
public ZyStrideAuthenticationVo authenticationApi(ZyStrideAuthenticationDto dto) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Stride.AUTHENTICATION;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("dealers", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||
entity.setEncipherReq(body);
|
||||
String res = HttpRequest.post(url)
|
||||
.body(body)
|
||||
.execute()
|
||||
@@ -52,13 +60,21 @@ public class ZyStrideServiceImpl implements ZyStrideService {
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyStrideAuthenticationVo vo = JSONUtil.toBean(res, ZyStrideAuthenticationVo.class);
|
||||
if (!vo.isSuccess()) {
|
||||
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
|
||||
}
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||authenticationApi|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||authenticationApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -68,12 +84,17 @@ public class ZyStrideServiceImpl implements ZyStrideService {
|
||||
*/
|
||||
@Override
|
||||
public ZyStrideConsumptionVo consumptionApi(ZyStrideConsumptionDto dto) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Stride.CONSUMPTION;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("dealers", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||
entity.setEncipherReq(body);
|
||||
String res = HttpRequest.post(url)
|
||||
.body(body)
|
||||
.execute()
|
||||
@@ -81,13 +102,21 @@ public class ZyStrideServiceImpl implements ZyStrideService {
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyStrideConsumptionVo vo = JSONUtil.toBean(res, ZyStrideConsumptionVo.class);
|
||||
if (!vo.isSuccess()) {
|
||||
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
|
||||
}
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||consumptionApi|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||syncNativeCardTradeInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -97,12 +126,17 @@ public class ZyStrideServiceImpl implements ZyStrideService {
|
||||
*/
|
||||
@Override
|
||||
public ZyStrideCorrectVo correctApi(ZyStrideCorrectDto dto) {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Stride.CORRECT;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("dealers", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||
entity.setEncipherReq(body);
|
||||
String res = HttpRequest.post(url)
|
||||
.body(body)
|
||||
.execute()
|
||||
@@ -110,13 +144,21 @@ public class ZyStrideServiceImpl implements ZyStrideService {
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
throw new RuntimeException("response is empty");
|
||||
}
|
||||
entity.setEncipherRes(res);
|
||||
ZyStrideCorrectVo vo = JSONUtil.toBean(res, ZyStrideCorrectVo.class);
|
||||
if (!vo.isSuccess()) {
|
||||
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
|
||||
}
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(vo));
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}||correctApi|意外的错误error|{}|", TAG, e.getMessage());
|
||||
String error = String.format("|%s||correctApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
+13
-2
@@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerGetTokenVo;
|
||||
@@ -89,7 +91,16 @@ public class ZyApiTool {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("data", params);
|
||||
prePost(body);
|
||||
return JSONUtil.toJsonStr(body);
|
||||
String jsonString = JSON.toJSONString(body, SerializerFeature.DisableCircularReferenceDetect);
|
||||
log.error(jsonString);
|
||||
return jsonString;
|
||||
}
|
||||
|
||||
public Map<String, Object> getEncryptionMap(Map<String, Object> params) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("data", params);
|
||||
prePost(body);
|
||||
return body;
|
||||
}
|
||||
|
||||
public Map<String, Object> removeEmptyMap(Map<String, Object> params) {
|
||||
@@ -116,7 +127,7 @@ public class ZyApiTool {
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
entry.setValue(Base64.encode((String) value));
|
||||
entry.setValue(Base64.encode((String) value).replaceAll("\\s+", ""));
|
||||
} else {
|
||||
entry.setValue(Base64.encode(value.toString()));
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.thirdparty.mapper.zy.ThirdZyLogMapper">
|
||||
|
||||
<resultMap id="thirdZyLogMap" type="com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="bizType" column="biz_type"/>
|
||||
<result property="bizId" column="biz_id"/>
|
||||
<result property="orgRes" column="org_res"/>
|
||||
<result property="encipherRes" column="encipher_res"/>
|
||||
<result property="orgReq" column="org_req"/>
|
||||
<result property="encipherReq" column="encipher_req"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="timeConsuming" column="time_consuming"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
+16
-14
@@ -1,9 +1,7 @@
|
||||
package com.bsd.pjcloud.admin;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.thirdparty.ThirdPartyApp;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignGetRegionIdByTokenDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||
@@ -12,9 +10,9 @@ import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncEnterpriseInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideAuthenticationDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideConsumptionDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideCorrectDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ZyForeignService;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ZyMerService;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ZyStrideService;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyForeignService;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyMerService;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyStrideService;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApiTool;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignGetRegionIdByTokenVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.foreign.ZyForeignSyncNativeCardTradeInfoVo;
|
||||
@@ -22,7 +20,6 @@ import com.bsd.pjcloud.thirdparty.vo.zy.mer.*;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideAuthenticationVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideConsumptionVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.stride.ZyStrideCorrectVo;
|
||||
import io.undertow.security.idm.DigestAlgorithm;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -30,9 +27,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootTest(classes = ThirdPartyApp.class)
|
||||
public class ZyTest {
|
||||
@@ -41,11 +36,11 @@ public class ZyTest {
|
||||
private ZyApiTool zyApiTool;
|
||||
|
||||
@Resource
|
||||
private ZyMerService zyMerService;
|
||||
private ThirdZyMerService zyMerService;
|
||||
@Resource
|
||||
private ZyForeignService zyForeignService;
|
||||
private ThirdZyForeignService zyForeignService;
|
||||
@Resource
|
||||
private ZyStrideService zyStrideService;
|
||||
private ThirdZyStrideService zyStrideService;
|
||||
|
||||
/************************** start mer start **************************/
|
||||
|
||||
@@ -83,7 +78,11 @@ public class ZyTest {
|
||||
@Test
|
||||
public void merSyncEnterpriseInfo() {
|
||||
ZyMerSyncEnterpriseInfoDto dto = new ZyMerSyncEnterpriseInfoDto();
|
||||
ZyMerSyncEnterpriseInfoVo vo = zyMerService.syncEnterpriseInfoApi(dto);
|
||||
dto.setEPID("1");
|
||||
dto.setEPName("测试部门");
|
||||
dto.setIsValid(1);
|
||||
dto.setFixId("20190920100101");
|
||||
ZyMerSyncEnterpriseInfoVo vo = zyMerService.syncEnterpriseInfoApi(List.of(dto));
|
||||
System.out.println(vo);
|
||||
}
|
||||
|
||||
@@ -93,7 +92,10 @@ public class ZyTest {
|
||||
@Test
|
||||
public void merSyncAccountInfoApi() {
|
||||
ZyMerSyncAccountInfoDto dto = new ZyMerSyncAccountInfoDto();
|
||||
ZyMerSyncAccountInfoVo vo = zyMerService.syncAccountInfoApi(dto);
|
||||
dto.setEPID("1");
|
||||
dto.setAccName("测试部门");
|
||||
dto.setEPID("1");
|
||||
ZyMerSyncAccountInfoVo vo = zyMerService.syncAccountInfoApi(List.of(dto));
|
||||
System.out.println(vo);
|
||||
}
|
||||
|
||||
@@ -103,7 +105,7 @@ public class ZyTest {
|
||||
@Test
|
||||
public void merSyncAccClassInfo() {
|
||||
ZyMerSyncAccClassInfoDto dto = new ZyMerSyncAccClassInfoDto();
|
||||
ZyMerSyncAccClassInfoVo vo = zyMerService.syncAccClassInfoApi(dto);
|
||||
ZyMerSyncAccClassInfoVo vo = zyMerService.syncAccClassInfoApi(List.of(dto));
|
||||
System.out.println(vo);
|
||||
}
|
||||
|
||||
|
||||
+14
-6
@@ -24,6 +24,7 @@ import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,11 +35,18 @@ import java.util.List;
|
||||
@FeignClient(contextId = "remoteRoleService", value = ServiceNameConstants.UPMS_SERVICE)
|
||||
public interface RemoteRoleService {
|
||||
|
||||
/**
|
||||
* 获取所有部门接口
|
||||
* @return R 返回结果对象,包含所有部门信息列表
|
||||
*/
|
||||
@GetMapping("/role/list")
|
||||
R<List<SysRole>> getAllRole();
|
||||
/**
|
||||
* 获取所有部门接口
|
||||
*
|
||||
* @return R 返回结果对象,包含所有部门信息列表
|
||||
*/
|
||||
@GetMapping("/role/list")
|
||||
R<List<SysRole>> getAllRole();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@GetMapping("/role/by-codes")
|
||||
R<List<SysRole>> findRolesByCodes(@RequestBody List<String> codes);
|
||||
|
||||
}
|
||||
@@ -210,6 +210,12 @@
|
||||
<version>5.7.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-thirdparty-api</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
+7
@@ -33,6 +33,7 @@ import com.bsd.pjcloud.common.excel.annotation.RequestExcel;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -58,6 +59,12 @@ public class SysRoleController {
|
||||
|
||||
private final SysRoleService sysRoleService;
|
||||
|
||||
@Inner
|
||||
@PostMapping("/by-codes")
|
||||
public R<List<SysRole>> findRolesByCodes(@RequestBody List<String> codes) {
|
||||
return R.ok(sysRoleService.findRolesByCodes(codes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ID查询角色信息
|
||||
* @param id ID
|
||||
|
||||
+7
@@ -53,6 +53,13 @@ public interface SysRoleService extends IService<SysRole> {
|
||||
*/
|
||||
List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key);
|
||||
|
||||
/**
|
||||
* 根据角色标识 查询角色列表
|
||||
* @param codes 角色标识
|
||||
* @return
|
||||
*/
|
||||
List<SysRole> findRolesByCodes(List<String> codes);
|
||||
|
||||
/**
|
||||
* 通过角色ID,删除角色
|
||||
* @param ids
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package com.bsd.pjcloud.admin.service;
|
||||
|
||||
public interface SysThirdZyService {
|
||||
|
||||
|
||||
}
|
||||
+119
-104
@@ -22,6 +22,8 @@ package com.bsd.pjcloud.admin.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
||||
@@ -59,120 +61,133 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||
|
||||
private SysRoleMenuService roleMenuService;
|
||||
private SysRoleMenuService roleMenuService;
|
||||
|
||||
/**
|
||||
* 通过用户ID,查询角色信息
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List findRolesByUserId(Long userId) {
|
||||
return baseMapper.listRolesByUserId(userId);
|
||||
}
|
||||
/**
|
||||
* 通过用户ID,查询角色信息
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List findRolesByUserId(Long userId) {
|
||||
return baseMapper.listRolesByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID 查询角色列表,注意缓存删除
|
||||
* @param roleIdList 角色ID列表
|
||||
* @param key 缓存key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key", unless = "#result.isEmpty()")
|
||||
public List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key) {
|
||||
return baseMapper.selectBatchIds(roleIdList);
|
||||
}
|
||||
/**
|
||||
* 根据角色ID 查询角色列表,注意缓存删除
|
||||
*
|
||||
* @param roleIdList 角色ID列表
|
||||
* @param key 缓存key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key", unless = "#result.isEmpty()")
|
||||
public List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key) {
|
||||
return baseMapper.selectBatchIds(roleIdList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID,删除角色,并清空角色菜单缓存
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean removeRoleByIds(Long[] ids) {
|
||||
roleMenuService
|
||||
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
|
||||
return this.removeBatchByIds(CollUtil.toList(ids));
|
||||
}
|
||||
@Override
|
||||
public List<SysRole> findRolesByCodes(List<String> codes) {
|
||||
if (ObjectUtil.isEmpty(codes)) return null;
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysRole>()
|
||||
.in(SysRole::getRoleCode, codes)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色菜单列表
|
||||
* @param roleVo 角色&菜单列表
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateRoleMenus(RoleMenuVO roleVo) {
|
||||
return roleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds());
|
||||
}
|
||||
/**
|
||||
* 通过角色ID,删除角色,并清空角色菜单缓存
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean removeRoleByIds(Long[] ids) {
|
||||
roleMenuService
|
||||
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
|
||||
return this.removeBatchByIds(CollUtil.toList(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入角色
|
||||
* @param excelVOList 角色列表
|
||||
* @param bindingResult 错误信息列表
|
||||
* @return ok fail
|
||||
*/
|
||||
@Override
|
||||
public R importRole(List<RoleExcelVO> excelVOList, BindingResult bindingResult) {
|
||||
// 通用校验获取失败的数据
|
||||
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
||||
/**
|
||||
* 根据角色菜单列表
|
||||
*
|
||||
* @param roleVo 角色&菜单列表
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateRoleMenus(RoleMenuVO roleVo) {
|
||||
return roleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds());
|
||||
}
|
||||
|
||||
// 个性化校验逻辑
|
||||
List<SysRole> roleList = this.list();
|
||||
/**
|
||||
* 导入角色
|
||||
*
|
||||
* @param excelVOList 角色列表
|
||||
* @param bindingResult 错误信息列表
|
||||
* @return ok fail
|
||||
*/
|
||||
@Override
|
||||
public R importRole(List<RoleExcelVO> excelVOList, BindingResult bindingResult) {
|
||||
// 通用校验获取失败的数据
|
||||
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
||||
|
||||
// 执行数据插入操作 组装 RoleDto
|
||||
for (RoleExcelVO excel : excelVOList) {
|
||||
Set<String> errorMsg = new HashSet<>();
|
||||
// 检验角色名称或者角色编码是否存在
|
||||
boolean existRole = roleList.stream()
|
||||
.anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName())
|
||||
|| excel.getRoleCode().equals(sysRole.getRoleCode()));
|
||||
// 个性化校验逻辑
|
||||
List<SysRole> roleList = this.list();
|
||||
|
||||
if (existRole) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
|
||||
excel.getRoleCode()));
|
||||
}
|
||||
// 执行数据插入操作 组装 RoleDto
|
||||
for (RoleExcelVO excel : excelVOList) {
|
||||
Set<String> errorMsg = new HashSet<>();
|
||||
// 检验角色名称或者角色编码是否存在
|
||||
boolean existRole = roleList.stream()
|
||||
.anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName())
|
||||
|| excel.getRoleCode().equals(sysRole.getRoleCode()));
|
||||
|
||||
// 数据合法情况
|
||||
if (CollUtil.isEmpty(errorMsg)) {
|
||||
insertExcelRole(excel);
|
||||
}
|
||||
else {
|
||||
// 数据不合法情况
|
||||
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(errorMessageList)) {
|
||||
return R.failed(errorMessageList);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
if (existRole) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
|
||||
excel.getRoleCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部的角色
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<RoleExcelVO> listRole(SysRole sysRole, Long[] ids) {
|
||||
List<SysRole> roleList = this
|
||||
.list(Wrappers.lambdaQuery(sysRole).in(ArrayUtil.isNotEmpty(ids), SysRole::getRoleId, ids));
|
||||
// 转换成execl 对象输出
|
||||
return roleList.stream().map(role -> {
|
||||
RoleExcelVO roleExcelVO = new RoleExcelVO();
|
||||
BeanUtil.copyProperties(role, roleExcelVO);
|
||||
return roleExcelVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
// 数据合法情况
|
||||
if (CollUtil.isEmpty(errorMsg)) {
|
||||
insertExcelRole(excel);
|
||||
} else {
|
||||
// 数据不合法情况
|
||||
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(errorMessageList)) {
|
||||
return R.failed(errorMessageList);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入excel Role
|
||||
*/
|
||||
private void insertExcelRole(RoleExcelVO excel) {
|
||||
SysRole sysRole = new SysRole();
|
||||
sysRole.setRoleName(excel.getRoleName());
|
||||
sysRole.setRoleDesc(excel.getRoleDesc());
|
||||
sysRole.setRoleCode(excel.getRoleCode());
|
||||
this.save(sysRole);
|
||||
}
|
||||
/**
|
||||
* 查询全部的角色
|
||||
*
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<RoleExcelVO> listRole(SysRole sysRole, Long[] ids) {
|
||||
List<SysRole> roleList = this
|
||||
.list(Wrappers.lambdaQuery(sysRole).in(ArrayUtil.isNotEmpty(ids), SysRole::getRoleId, ids));
|
||||
// 转换成execl 对象输出
|
||||
return roleList.stream().map(role -> {
|
||||
RoleExcelVO roleExcelVO = new RoleExcelVO();
|
||||
BeanUtil.copyProperties(role, roleExcelVO);
|
||||
return roleExcelVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入excel Role
|
||||
*/
|
||||
private void insertExcelRole(RoleExcelVO excel) {
|
||||
SysRole sysRole = new SysRole();
|
||||
sysRole.setRoleName(excel.getRoleName());
|
||||
sysRole.setRoleDesc(excel.getRoleDesc());
|
||||
sysRole.setRoleCode(excel.getRoleCode());
|
||||
this.save(sysRole);
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.bsd.pjcloud.admin.service.impl.third;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.service.SysRoleService;
|
||||
import com.bsd.pjcloud.admin.service.SysThirdZyService;
|
||||
import com.bsd.pjcloud.admin.service.SysUserService;
|
||||
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdZyService;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccClassInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccountInfoVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysThirdZyServiceImpl implements SysThirdZyService {
|
||||
|
||||
private static final String TAG = "用户模块同步到正元信息";
|
||||
|
||||
private final SysRoleService roleService;
|
||||
private final SysUserService userService;
|
||||
|
||||
private final RemoterThirdZyService thirdZyService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -112,6 +112,12 @@
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-flow-task-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-thirdparty-api</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.bsd.pjcloud.wallet.controller.third;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import com.bsd.pjcloud.wallet.service.MchThirdZyService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/mch-third-zy")
|
||||
@Tag(description = "wallet-active", name = "钱包开卡管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
@Validated
|
||||
public class MchThirdZyController {
|
||||
|
||||
private final MchThirdZyService mchThirdZyService;
|
||||
|
||||
@GetMapping("/sync-all-mch")
|
||||
@Operation(summary = "同步全部商户")
|
||||
public R<MchManageVo> syncAllMch(@RequestParam Long id) {
|
||||
mchThirdZyService.syncAllMch();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/sync-all-dept")
|
||||
@Operation(summary = "同步全部商户部门")
|
||||
public R<MchManageVo> syncAllDept() {
|
||||
mchThirdZyService.syncAllDept();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.bsd.pjcloud.wallet.service;
|
||||
|
||||
public interface MchThirdZyService {
|
||||
|
||||
/**
|
||||
* 同步全部商户
|
||||
*/
|
||||
void syncAllMch();
|
||||
|
||||
/**
|
||||
* 同步全部商户部门
|
||||
*/
|
||||
void syncAllDept();
|
||||
|
||||
/**
|
||||
* 同步到正元全部身份信息
|
||||
*/
|
||||
void syncAllUser();
|
||||
|
||||
/**
|
||||
* 同步到正元全部身份信息
|
||||
*/
|
||||
void syncAllRole();
|
||||
|
||||
}
|
||||
+11
-1
@@ -164,7 +164,17 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
|
||||
@Override
|
||||
public List<MchManageVo> list(MchManageDto dto) {
|
||||
return baseMapper.list(dto);
|
||||
List<MchManageVo> list = baseMapper.list(dto);
|
||||
if (ObjectUtil.isEmpty(list)) return null;
|
||||
// 部门
|
||||
List<Long> deptIds = list.stream().map(MchManageVo::getDeptId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
R<Map<Long, SysDept>> deptList = remoteDeptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(list, deptList.getData());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl.thrid;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteRoleService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScopeFuncEnum;
|
||||
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdZyService;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncEnterpriseInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccClassInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccountInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncDealerInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncEnterpriseInfoVo;
|
||||
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.service.MchManageService;
|
||||
import com.bsd.pjcloud.wallet.service.MchThirdZyService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class MchThirdZyServiceImpl implements MchThirdZyService {
|
||||
|
||||
private static final String TAG = "用户模块同步到正元信息";
|
||||
|
||||
private final RemoterThirdZyService thirdZyService;
|
||||
private final RemoteDeptService remoteDeptService;
|
||||
private final RemoteRoleService remoteRoleService;
|
||||
|
||||
private final MchManageService mchManageService;
|
||||
private final WalletManageService walletManageService;
|
||||
|
||||
@Override
|
||||
public void syncAllMch() {
|
||||
List<MchManageEntity> mchList = mchManageService.list();
|
||||
if (ObjectUtil.isEmpty(mchList)) {
|
||||
log.info("|{}|同步到正元全部商户信息错误mchList为空", TAG);
|
||||
return;
|
||||
}
|
||||
List<ZyMerSyncDealerInfoDto> syncList = new ArrayList<>();
|
||||
for (MchManageEntity v : mchList) {
|
||||
ZyMerSyncDealerInfoDto entity = new ZyMerSyncDealerInfoDto();
|
||||
entity.setDealerKeyObj(v.getId().toString());
|
||||
entity.setDealerName(v.getName());
|
||||
entity.setIsValid(1);
|
||||
entity.setEPID("");
|
||||
entity.setFixId(getSyncAllMchVersion());
|
||||
syncList.add(entity);
|
||||
}
|
||||
ZyMerSyncDealerInfoVo res = thirdZyService.syncDealerInfo(syncList).getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAllDept() {
|
||||
List<SysDept> mchList = remoteDeptService.getAllDept(null).getData();
|
||||
if (ObjectUtil.isEmpty(mchList)) {
|
||||
log.info("|{}|同步到正元全部商户部门信息错误mchList为空", TAG);
|
||||
return;
|
||||
}
|
||||
List<ZyMerSyncEnterpriseInfoDto> syncList = new ArrayList<>();
|
||||
for (SysDept v : mchList) {
|
||||
ZyMerSyncEnterpriseInfoDto entity = new ZyMerSyncEnterpriseInfoDto();
|
||||
entity.setEPID(v.getDeptId().toString());
|
||||
entity.setEPName(v.getName());
|
||||
entity.setIsValid(1);
|
||||
entity.setFixId(getSyncAllMchVersion());
|
||||
syncList.add(entity);
|
||||
}
|
||||
ZyMerSyncEnterpriseInfoVo res = thirdZyService.syncEnterpriseInfoApi(syncList).getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAllUser() {
|
||||
Page page = new Page();
|
||||
page.setCurrent(1);
|
||||
page.setSize(500);
|
||||
boolean isResidue = true;
|
||||
while (isResidue) {
|
||||
isResidue = syncAllUserGroup(page);
|
||||
if (!isResidue) break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步到正元全部身份信息
|
||||
*/
|
||||
@Override
|
||||
public void syncAllRole() {
|
||||
// 查询需要同步的身份信息
|
||||
List<SysRole> roleList = remoteRoleService.findRolesByCodes(List.of("GENERAL_USER")).getData();
|
||||
if (ObjectUtil.isEmpty(roleList)) {
|
||||
log.info("|{}|同步到正元全部身份信息错误roleList为空", TAG);
|
||||
return;
|
||||
}
|
||||
List<ZyMerSyncAccClassInfoDto> syncList = new ArrayList<>();
|
||||
for (SysRole v : roleList) {
|
||||
ZyMerSyncAccClassInfoDto entity = new ZyMerSyncAccClassInfoDto();
|
||||
entity.setAccClassID(v.getRoleId().toString());
|
||||
entity.setAccClassName(v.getRoleName());
|
||||
entity.setEPID("1");
|
||||
entity.setFixId(getSyncAllRoleVersion());
|
||||
syncList.add(entity);
|
||||
}
|
||||
ZyMerSyncAccClassInfoVo res = thirdZyService.syncAccClassInfoApi(syncList).getData();
|
||||
}
|
||||
|
||||
private boolean syncAllUserGroup(Page page) {
|
||||
WalletManageDto query = new WalletManageDto();
|
||||
DataScope dataScope = DataScope.of();
|
||||
dataScope.func(DataScopeFuncEnum.ALL);
|
||||
Page<WalletManageVo> userPage = walletManageService.scopePageList(page, query, dataScope);
|
||||
if (ObjectUtil.isEmpty(userPage.getRecords())) return false;
|
||||
List<ZyMerSyncAccountInfoDto> syncList = new ArrayList<>();
|
||||
for (WalletManageVo v : userPage.getRecords()) {
|
||||
ZyMerSyncAccountInfoDto item = new ZyMerSyncAccountInfoDto();
|
||||
item.setAccName(v.getUsername());
|
||||
item.setAccNum(v.getUserId().toString());
|
||||
item.setCardAccNum(v.getId());
|
||||
item.setCardSID(v.getCardNumber());
|
||||
item.setCardStatus(getCardStatus(v.getCardNumber()));
|
||||
item.setEPID("");
|
||||
item.setAccClassID("");
|
||||
item.setPhoneNo(v.getUserMobile());
|
||||
item.setFixId(getSyncAllUserVersion());
|
||||
syncList.add(item);
|
||||
}
|
||||
ZyMerSyncAccountInfoVo res = thirdZyService.syncAccountInfoApi(syncList).getData();
|
||||
|
||||
return userPage.getTotal() > 0;
|
||||
}
|
||||
|
||||
|
||||
/* ************************************* start 版本号 start ************************************* */
|
||||
|
||||
private String getSyncAllMchVersion() {
|
||||
return String.format("%014d", 2);
|
||||
}
|
||||
|
||||
private String getSyncAllDeptVersion() {
|
||||
return String.format("%014d", 2);
|
||||
}
|
||||
|
||||
private String getSyncAllUserVersion() {
|
||||
return String.format("%014d", 1);
|
||||
}
|
||||
|
||||
private String getSyncAllRoleVersion() {
|
||||
return String.format("%014d", 1);
|
||||
}
|
||||
|
||||
/* ************************************* end 版本号 end ************************************* */
|
||||
|
||||
// 卡片状态,0销卡;1有效;2挂失;3冻结;4预销卡;5锁卡,默认1
|
||||
private Integer getCardStatus(String cardNumber) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user