feat:第三方密钥管理
This commit is contained in:
1 parent
3c20ebf10a
commit
970bae2ddb
19 files changed
+554
-49
No files matched your search
@@ -85,6 +85,32 @@ CREATE TABLE `third_pay_log`
|
||||
COLLATE = utf8mb4_general_ci
|
||||
ROW_FORMAT = DYNAMIC COMMENT ='第三方支付日志';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for third_key_manage
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `third_key_manage`;
|
||||
CREATE TABLE `third_key_manage`
|
||||
(
|
||||
`id` bigint NOT NULL COMMENT '主键',
|
||||
`name` varchar(32) NOT NULL COMMENT '第三方名字',
|
||||
`biz_type` varchar(32) NOT NULL COMMENT '第三方类型id(常量)',
|
||||
`app_key` varchar(256) DEFAULT NULL COMMENT 'appKey',
|
||||
`app_secret` varchar(256) DEFAULT NULL COMMENT 'appSecret',
|
||||
`field_key` varchar(256) DEFAULT NULL COMMENT '字段加密key',
|
||||
`status` varchar(32) DEFAULT '1' COMMENT '状态',
|
||||
`remark` varchar(1024) DEFAULT 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 '创建人',
|
||||
`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 ='第三方密钥管理';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for third_zy_id_dict
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.bsd.pjcloud.thirdparty.constant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayApiBizTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 第三方key类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ThirdKeyTypeEnum {
|
||||
|
||||
LB("10", "宁波银行"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static ThirdKeyTypeEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.bsd.pjcloud.thirdparty.constant.pay;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 第三方统一支付api类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ThirdPayApiBizTypeEnum {
|
||||
|
||||
PAY("10", "支付"),
|
||||
REFUND("20", "退款"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static ThirdPayApiBizTypeEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+4
-5
@@ -2,25 +2,24 @@ package com.bsd.pjcloud.thirdparty.constant.pay;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 第三方统一支付类型
|
||||
* 第三方统一支付来源类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ThirdPayBizTypeEnum {
|
||||
public enum ThirdPaySoureBizTypeEnum {
|
||||
|
||||
LB_PAY("10", "宁波银行支付"),
|
||||
LB("10", "宁波银行"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static ThirdPayBizTypeEnum valueOfByType(String type) {
|
||||
public static ThirdPaySoureBizTypeEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.bsd.pjcloud.thirdparty.dto.pay;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPaySoureBizTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@@ -19,7 +19,7 @@ public class PayDto {
|
||||
/**
|
||||
* 第三方统一支付类型
|
||||
*/
|
||||
private ThirdPayBizTypeEnum bizType;
|
||||
private ThirdPaySoureBizTypeEnum bizType;
|
||||
|
||||
/**
|
||||
* 扣款金额(分)
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package com.bsd.pjcloud.thirdparty.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 第三方密钥管理
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-04-30 15:18:13
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("third_key_manage")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "第三方密钥管理")
|
||||
public class ThirdKeyManageEntity extends Model<ThirdKeyManageEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 第三方名字
|
||||
*/
|
||||
@Schema(description="第三方名字")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 第三方类型id(常量)
|
||||
*/
|
||||
@Schema(description="第三方类型id(常量)")
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* appKey
|
||||
*/
|
||||
@Schema(description="appKey")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* appSecret
|
||||
*/
|
||||
@Schema(description="appSecret")
|
||||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 字段加密key
|
||||
*/
|
||||
@Schema(description="字段加密key")
|
||||
private String fieldKey;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description="状态")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description="备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
+4
-2
@@ -3,14 +3,16 @@ package com.bsd.pjcloud.thirdparty.entity.api;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 第三方支付日志
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("third_pay_log")
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.bsd.pjcloud.thirdparty.vo.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PayGetWalletInfoVo {
|
||||
|
||||
|
||||
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.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.ThirdKeyManageEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdKeyManageService;
|
||||
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;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 第三方密钥管理
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/third-key-manage")
|
||||
@Tag(description = "third-key-manage", name = "第三方密钥管理管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdKeyManageController {
|
||||
|
||||
private final ThirdKeyManageService thirdKeyManageService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdKeyManage_view')")
|
||||
public R getThirdKeyManagePage(@ParameterObject Page page, @ParameterObject ThirdKeyManageEntity dto) {
|
||||
LambdaQueryWrapper<ThirdKeyManageEntity> wrapper = new LambdaQueryWrapper<ThirdKeyManageEntity>()
|
||||
.like(ObjectUtil.isNotEmpty(dto.getName()), ThirdKeyManageEntity::getName, dto.getName())
|
||||
.orderByDesc(ThirdKeyManageEntity::getCreateTime)
|
||||
.orderByDesc(ThirdKeyManageEntity::getId);
|
||||
return R.ok(thirdKeyManageService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdKeyManage_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(thirdKeyManageService.getById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "新增第三方密钥管理", description = "新增第三方密钥管理")
|
||||
@SysLog("新增第三方密钥管理")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdKeyManage_add')")
|
||||
public R save(@RequestBody ThirdKeyManageEntity dto) {
|
||||
return R.ok(thirdKeyManageService.create(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改第三方密钥管理", description = "修改第三方密钥管理")
|
||||
@SysLog("修改第三方密钥管理")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdKeyManage_edit')")
|
||||
public R updateById(@RequestBody ThirdKeyManageEntity dto) {
|
||||
return R.ok(thirdKeyManageService.edit(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id删除第三方密钥管理", description = "通过id删除第三方密钥管理")
|
||||
@SysLog("通过id删除第三方密钥管理")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdKeyManage_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(thirdKeyManageService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller.pay;
|
||||
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayApiService;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayLogService;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 第三方支付日志
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/third-pay-api")
|
||||
@Tag(description = "third-pay-api", name = "地上方支付")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdPayApiController {
|
||||
|
||||
private final ThirdPayApiService thirdPayApiService;
|
||||
|
||||
@Operation(summary = "通过手机号查询用户钱包信息", description = "通过手机号查询用户钱包信息")
|
||||
@GetMapping("/{signPhone}")
|
||||
public R getWalletInfo(@PathVariable("signPhone") String signPhone) {
|
||||
return R.ok(thirdPayApiService.getWalletInfo(signPhone));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+9
-3
@@ -11,6 +11,7 @@ import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.ThirdPayLogDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayLogService;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -29,8 +30,8 @@ import java.util.Objects;
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/thirdPayLog")
|
||||
@Tag(description = "thirdPayLog", name = "第三方支付日志管理")
|
||||
@RequestMapping("/third-pay-log")
|
||||
@Tag(description = "third-pay-log", name = "第三方支付日志管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdPayLogController {
|
||||
|
||||
@@ -43,7 +44,12 @@ public class ThirdPayLogController {
|
||||
LambdaQueryWrapper<ThirdPayLogEntity> wrapper = new LambdaQueryWrapper<ThirdPayLogEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getPaySourceType()), ThirdPayLogEntity::getPaySourceType, dto.getPaySourceType())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), ThirdPayLogEntity::getBizType, dto.getBizType())
|
||||
.between(ObjectUtil.isNotEmpty(dto.getCreateTimeList()), ThirdPayLogEntity::getCreateTime, dto.getCreateTimeList()[0], dto.getCreateTimeList()[1])
|
||||
.between(
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
|
||||
ThirdPayLogEntity::getCreateTime,
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
|
||||
)
|
||||
.orderByDesc(ThirdPayLogEntity::getCreateTime)
|
||||
.orderByDesc(ThirdPayLogEntity::getId);
|
||||
return R.ok(thirdPayLogService.page(page, wrapper));
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.bsd.pjcloud.thirdparty.mapper;
|
||||
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.thirdparty.entity.ThirdKeyManageEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ThirdKeyManageMapper extends PjcloudBaseMapper<ThirdKeyManageEntity> {
|
||||
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.bsd.pjcloud.thirdparty.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.thirdparty.constant.ThirdKeyTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.entity.ThirdKeyManageEntity;
|
||||
|
||||
public interface ThirdKeyManageService extends IService<ThirdKeyManageEntity> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
Long create(ThirdKeyManageEntity dto);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
Long edit(ThirdKeyManageEntity dto);
|
||||
|
||||
/**
|
||||
* 获取第三方key配置
|
||||
*/
|
||||
ThirdKeyManageEntity get(ThirdKeyTypeEnum type);
|
||||
}
|
||||
+5
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.thirdparty.service;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.PayGetWalletInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.PayVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.RefundVo;
|
||||
|
||||
@@ -18,4 +19,8 @@ public interface ThirdPayApiService {
|
||||
*/
|
||||
RefundVo refund(RefundDto dto);
|
||||
|
||||
/**
|
||||
* 根据加密的手机号查询用户钱包信息
|
||||
*/
|
||||
PayGetWalletInfoVo getWalletInfo(String phone);
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.bsd.pjcloud.thirdparty.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.thirdparty.constant.ThirdKeyTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.entity.ThirdKeyManageEntity;
|
||||
import com.bsd.pjcloud.thirdparty.mapper.ThirdKeyManageMapper;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdKeyManageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* 第三方密钥管理
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ThirdKeyManageServiceImpl extends ServiceImpl<ThirdKeyManageMapper, ThirdKeyManageEntity> implements ThirdKeyManageService {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@Override
|
||||
public Long create(ThirdKeyManageEntity dto) {
|
||||
if (existBizType(dto)) throw new RuntimeException("第三方key类型不能重复");
|
||||
if (existName(dto)) throw new RuntimeException("第三方key名称不能重复");
|
||||
baseMapper.insert(dto);
|
||||
return dto.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@Override
|
||||
public Long edit(ThirdKeyManageEntity dto) {
|
||||
if (existBizType(dto)) throw new RuntimeException("第三方key类型不能重复");
|
||||
if (existName(dto)) throw new RuntimeException("第三方key名称不能重复");
|
||||
baseMapper.updateById(dto);
|
||||
return dto.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第三方key配置
|
||||
*/
|
||||
@Override
|
||||
public ThirdKeyManageEntity get(ThirdKeyTypeEnum type) {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<ThirdKeyManageEntity>().eq(ThirdKeyManageEntity::getBizType, type.getType()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方类型不能重复
|
||||
*/
|
||||
private boolean existBizType(ThirdKeyManageEntity dto) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<ThirdKeyManageEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), ThirdKeyManageEntity::getBizType, dto.getBizType())
|
||||
.ne(ObjectUtil.isNotEmpty(dto.getId()), ThirdKeyManageEntity::getId, dto.getId())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dto.getId())) {
|
||||
return count >= 1;
|
||||
}
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 名字不能重复
|
||||
*/
|
||||
private boolean existName(ThirdKeyManageEntity dto) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<ThirdKeyManageEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getName()), ThirdKeyManageEntity::getName, dto.getName())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), ThirdKeyManageEntity::getBizType, dto.getBizType())
|
||||
.ne(ObjectUtil.isNotEmpty(dto.getId()), ThirdKeyManageEntity::getId, dto.getId())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dto.getId())) {
|
||||
return count >= 1;
|
||||
}
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-4
@@ -36,10 +36,10 @@ public class ThirdLbApiServiceImpl implements ThirdLbApiService {
|
||||
LbH5LoginVo ksBaseVo = new LbH5LoginVo();
|
||||
String phone = dto.getPhone();
|
||||
String signPhone = LbRetailSignUtils.sm4Encrypt(phone, lbConfig.getSm4Key());
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
long timeMillis = System.currentTimeMillis() / 1000;
|
||||
String signature = apiCountersign(dto.getPhone(), timeMillis);
|
||||
Map<String, String> queryMap = new HashMap<>();
|
||||
queryMap.put("companyNumber", lbConfig.getCompanyNumber());
|
||||
// queryMap.put("companyNumber", lbConfig.getCompanyNumber());
|
||||
queryMap.put("appId", lbConfig.getAppId());
|
||||
queryMap.put("phone", signPhone);
|
||||
queryMap.put("timestamp", String.valueOf(timeMillis));
|
||||
@@ -60,8 +60,10 @@ public class ThirdLbApiServiceImpl implements ThirdLbApiService {
|
||||
|
||||
// 加签
|
||||
public String apiCountersign(String phone, Long timestamp) {
|
||||
String str = "companyNumber=%s&appId=%s&phone=%s×tamp=%s&secret=%s";
|
||||
str = String.format(str, lbConfig.getCompanyNumber(), lbConfig.getAppId(), phone, timestamp, lbConfig.getAppSecret());
|
||||
// String str = "companyNumber=%s&appId=%s&phone=%s×tamp=%s&secret=%s";
|
||||
// str = String.format(str, lbConfig.getCompanyNumber(), lbConfig.getAppId(), phone, timestamp, lbConfig.getAppSecret());
|
||||
String str = "phone=%s&appKey=%s×tamp=%s&secret=%s";
|
||||
str = String.format(str, phone, lbConfig.getAppId(), timestamp, lbConfig.getAppSecret());
|
||||
// 使用 SHA-256 进行哈希计算,并返回十六进制字符串。
|
||||
String sha256 = DigestUtils.sha256Hex(str);
|
||||
return sha256;
|
||||
|
||||
+35
-5
@@ -1,8 +1,14 @@
|
||||
package com.bsd.pjcloud.thirdparty.service.impl.pay;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayApiBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayApiService;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayLogService;
|
||||
import com.bsd.pjcloud.thirdparty.utils.lb.tool.LbRetailSignUtils;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.PayGetWalletInfoVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.PayVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.RefundVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -10,6 +16,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 第三方支付
|
||||
*/
|
||||
@@ -19,20 +27,27 @@ import org.springframework.validation.annotation.Validated;
|
||||
@RequiredArgsConstructor
|
||||
public class ThirdPayApiServiceImpl implements ThirdPayApiService {
|
||||
|
||||
private final String TAG = "第三方支付";
|
||||
private final String TAG = "第三方支付";
|
||||
|
||||
private final ThirdPayLogService thirdPayLogService;
|
||||
|
||||
/**
|
||||
* 扣款
|
||||
*/
|
||||
@Override
|
||||
public PayVo pay(PayDto dto) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
ThirdPayLogEntity logObj = ThirdPayLogEntity.builder().apiUrl("/pay").bizType(ThirdPayApiBizTypeEnum.PAY.getType()).req(JSONUtil.toJsonStr(dto)).build();
|
||||
PayVo vo = new PayVo();
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
String error = String.format("|%s||pay|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
logObj.setError(error);
|
||||
} finally {
|
||||
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
thirdPayLogService.save(logObj);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
@@ -42,14 +57,29 @@ public class ThirdPayApiServiceImpl implements ThirdPayApiService {
|
||||
*/
|
||||
@Override
|
||||
public RefundVo refund(RefundDto dto) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
ThirdPayLogEntity logObj = ThirdPayLogEntity.builder().apiUrl("/refund").bizType(ThirdPayApiBizTypeEnum.REFUND.getType()).req(JSONUtil.toJsonStr(dto)).build();
|
||||
RefundVo vo = new RefundVo();
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
String error = String.format("|%s||refund|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
logObj.setError(error);
|
||||
} finally {
|
||||
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
thirdPayLogService.save(logObj);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据加密的手机号查询用户钱包信息
|
||||
*/
|
||||
@Override
|
||||
public PayGetWalletInfoVo getWalletInfo(String signPhone) {
|
||||
// 手机号解密
|
||||
String phone = LbRetailSignUtils.sm4Decrypt(signPhone, "");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+28
-28
@@ -44,31 +44,31 @@ oauth2:
|
||||
# 正元智慧
|
||||
# https://gwyc.zj.gov.cn/API/%E7%9C%81%E5%B9%B3%E5%8F%B0API%E5%AF%B9%E6%8E%A5%E6%8E%A5%E5%8F%A3.html
|
||||
zy:
|
||||
# 测试1
|
||||
# base-url: http://60.191.37.212:18079
|
||||
# app-id: 689C8D6F5059A6F85B8BE45A49001ACB
|
||||
# app-secret: BD21DA0DEB8F0FC43246B0BD2FCAE6FF
|
||||
# 测试1
|
||||
# base-url: http://60.191.37.212:18079
|
||||
# app-id: 689C8D6F5059A6F85B8BE45A49001ACB
|
||||
# app-secret: BD21DA0DEB8F0FC43246B0BD2FCAE6FF
|
||||
|
||||
# 测试2
|
||||
# base-url: http://60.191.37.212:18079
|
||||
# app-id: FC455B0A788E334AC08FB3E1D8385C75
|
||||
# app-secret: E9131D0BCC9054808675DA1E2E199023
|
||||
# 测试2
|
||||
# base-url: http://60.191.37.212:18079
|
||||
# app-id: FC455B0A788E334AC08FB3E1D8385C75
|
||||
# app-secret: E9131D0BCC9054808675DA1E2E199023
|
||||
|
||||
# 正式
|
||||
# base-url: https://gwycport.zj.gov.cn
|
||||
# app-id: 0BBF0D9A7F1B4BD5280E59197E259AC6
|
||||
# app-secret: 434752786ACBB37214F6617CC37AD0E9
|
||||
# 正式
|
||||
# base-url: https://gwycport.zj.gov.cn
|
||||
# app-id: 0BBF0D9A7F1B4BD5280E59197E259AC6
|
||||
# app-secret: 434752786ACBB37214F6617CC37AD0E9
|
||||
|
||||
|
||||
# self-base-url: http://60.191.37.212:18079
|
||||
# self-app-id: xA5jF2vX4zO5mQ8tR9yE7rC7iI0fK0kI
|
||||
# self-app-secret: kE3hH5gF7zN0nH1yI5yX3vP0oP1hU0jE
|
||||
# 失效时间单位秒
|
||||
# self-expires-in: 7200
|
||||
# token key
|
||||
# self_token_key: zy_token
|
||||
# token
|
||||
# self_token_secret: eV3dT0oD7iX8rK4eC3jS6fU8cU5cS6mJ
|
||||
# self-base-url: http://60.191.37.212:18079
|
||||
# self-app-id: xA5jF2vX4zO5mQ8tR9yE7rC7iI0fK0kI
|
||||
# self-app-secret: kE3hH5gF7zN0nH1yI5yX3vP0oP1hU0jE
|
||||
# 失效时间单位秒
|
||||
# self-expires-in: 7200
|
||||
# token key
|
||||
# self_token_key: zy_token
|
||||
# token
|
||||
# self_token_secret: eV3dT0oD7iX8rK4eC3jS6fU8cU5cS6mJ
|
||||
|
||||
# 智能柜
|
||||
# door:
|
||||
@@ -90,11 +90,11 @@ zy:
|
||||
# callback-sku-url: /third/third-ks/callback/sku
|
||||
lb:
|
||||
# base-url: https://elss-sit.nbcb.com.cn
|
||||
base-url: https://elss-uat.nbcb.com.cn
|
||||
app-id: c4b0a38e9ba5419eab9b651dd23db462
|
||||
app-secret: iW9H6BT2AMXg2XnN2Eq+r6ISossJNNh97nyLwrrOrDY=
|
||||
company-number: p6VQYhHZ
|
||||
sm4-key: 1234567812345678
|
||||
base-url: https://elss-sit.nbcb.com.cn/h5/thirdApp
|
||||
app-id: 7da62b1a9ade473c917f573c5748081e
|
||||
app-secret: 8ffl6b+OKTmdVAt9Qo+2F/HQQMdt/d8GFia0zUOt9l=
|
||||
company-number: 202504673472
|
||||
sm4-key: 567157e8aQs2tF5X
|
||||
|
||||
|
||||
sms:
|
||||
@@ -109,10 +109,10 @@ sms:
|
||||
templates:
|
||||
20657: # 验证码模板
|
||||
content: "您好,您的验证码是{code},有效时间{date}分钟,请勿转发!"
|
||||
params: ["code", "date"]
|
||||
params: [ "code", "date" ]
|
||||
20658:
|
||||
content: "您的访客预约申请已通过,请通过地址{url}查看详情!"
|
||||
params: ["url"]
|
||||
params: [ "url" ]
|
||||
settings:
|
||||
default-ext-code: "123"
|
||||
timeout-seconds: 300
|
||||
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
<?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.ThirdKeyManageMapper">
|
||||
|
||||
<resultMap id="thirdKeyManageMap" type="com.bsd.pjcloud.thirdparty.entity.ThirdKeyManageEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="bizType" column="biz_type"/>
|
||||
<result property="appKey" column="app_key"/>
|
||||
<result property="appSecret" column="app_secret"/>
|
||||
<result property="fieldKey" column="field_key"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<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>
|
||||
Reference in new issue
Block a user