新增了获取企业的授权地址

This commit is contained in:
wucongxing8150 2025-07-01 15:22:13 +08:00
parent 96588b4379
commit 405fe91c65
7 changed files with 142 additions and 1 deletions

View File

@ -45,7 +45,7 @@ public class Base {
public String postJson(String url, String jsonData, Map<String, String> headers) {
// 获取token
String tokenKey = "fangxinqian:" + clientId;
redisTemplate.delete(tokenKey);
// redisTemplate.delete(tokenKey);
String token = redisTemplate.opsForValue().get(tokenKey);
if (token == null) {
token = getAccessToken();

View File

@ -0,0 +1,43 @@
package net.lab1024.sa.admin.extend.fangxinqian.auth;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.extend.fangxinqian.Base;
import net.lab1024.sa.admin.extend.fangxinqian.company.RegisterPResponse;
import net.lab1024.sa.common.common.exception.BusinessException;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Component
public class Auth extends Base {
/**
* 获取静默签署的授权
*/
public GetAuthorizeResponse getAuthorize(String unionId){
// 处理参数
Map<String, Object> requestData = new HashMap<>();
requestData.put("signerUnionId", unionId); // 个人/企业主体在放心签平台与接入方关联的唯一性标识
requestData.put("notifyUrl", "www.baidu.com"); // 授权结果通知地址
requestData.put("notifyWay", "2");
String url = getClientUrl() + "authorize/silent/sign";
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
String response = postJson(url,jsonBody,null);
GetAuthorizeResponse result = JSONUtil.toBean(response, GetAuthorizeResponse.class);
if (result.getCode() != 10000){
if (!Objects.equals(result.getMessage(), "")){
throw new BusinessException(result.getMessage());
}else{
throw new BusinessException("失败");
}
}
return result;
}
}

View File

@ -0,0 +1,28 @@
package net.lab1024.sa.admin.extend.fangxinqian.auth;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class GetAuthorizeResponse {
private int code;
private String message;
private GetAuthorizeData data;
private String requestId;
/**
* 根据统一标签列表 - 详细数据
*/
@Data
public static class GetAuthorizeData {
private String unionId;
private String pcUrl;
private String h5Url;
}
}

View File

@ -9,6 +9,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
import net.lab1024.sa.admin.extend.fangxinqian.auth.GetAuthorizeResponse;
import net.lab1024.sa.admin.extend.fangxinqian.task.GetTaskLinkResponse;
import net.lab1024.sa.admin.module.app.expert.admin.*;
import net.lab1024.sa.admin.module.app.expert.dao.ExpertDao;
@ -159,4 +160,20 @@ public class ExpertFxqController {
return ResponseDTO.app_ok(g);
}
/**
* 获取企业授权地址
*/
@ApiOperation(value = "获取企业授权地址")
@GetMapping("/expert/auth")
public ResponseDTO<String> getCompanyAuth() {
return ResponseDTO.app_ok();
// 以下暂不开放过期时解开授权
// // 获取静默签署的授权
// GetAuthorizeResponse.GetAuthorizeData auth = expertFxqService.getAuthorize("56447a9865aa488caf6036fd00ddcbed");
//
// return ResponseDTO.app_ok(auth.getH5Url());
}
}

View File

@ -38,6 +38,18 @@ public class FxqCompanyEntity {
@TableField("union_id")
private String unionId;
/**
* 授权状态1:已授权 2:未授权
*/
@TableField("auth_status")
private Integer authStatus;
/**
* 授权过期日期
*/
@TableField("auth_expire_date")
private LocalDateTime authExpireDate;
/**
* 创建时间
*/

View File

@ -1,5 +1,6 @@
package net.lab1024.sa.admin.module.app.expert.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -23,6 +24,13 @@ public class FxqCompanyVo {
@ApiModelProperty(value = "企业主体在放心签平台与接入方关联的唯一性标识")
private String unionId;
@ApiModelProperty(value = "授权状态1:已授权 2:未授权)")
private Integer authStatus;
@ApiModelProperty(value = "授权过期日期")
private LocalDateTime authExpireDate;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;

View File

@ -1,6 +1,8 @@
package net.lab1024.sa.admin.module.app.expert.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import net.lab1024.sa.admin.extend.fangxinqian.auth.Auth;
import net.lab1024.sa.admin.extend.fangxinqian.auth.GetAuthorizeResponse;
import net.lab1024.sa.admin.extend.fangxinqian.company.Company;
import net.lab1024.sa.admin.extend.fangxinqian.company.RegisterPResponse;
import net.lab1024.sa.admin.extend.fangxinqian.personal.Personal;
@ -51,6 +53,9 @@ public class ExpertFxqService {
@Resource
private FxqTask fxqTask;
@Resource
private Auth auth;
@Resource
private FxqExpertTaskDao fxqExpertTaskDao;
@ -342,6 +347,17 @@ public class ExpertFxqService {
throw new BusinessException("操作失败");
}
// 授权处理
if (company.getAuthStatus() == 1){
if (company.getAuthExpireDate() != null && company.getAuthExpireDate().isBefore(LocalDateTime.now())) {
// 已授权但已过期
throw new BusinessException("操作失败:请联系客服人员更换授权");
}
}else{
// 未授权
throw new BusinessException("操作失败:请联系客服人员更换授权");
}
// 获取签署链接
GetTaskLinkResponse.taskDetailsData fxqLink = getTaskLink(templateTask.getData().getTaskNo(),fxqUser.getUnionId());
if (fxqLink == null) {
@ -473,4 +489,21 @@ public class ExpertFxqService {
throw new BusinessException(e.getMessage());
}
}
/**
* 获取静默签署的授权
*/
public GetAuthorizeResponse.GetAuthorizeData getAuthorize(String unionId){
GetAuthorizeResponse result = auth.getAuthorize(unionId);
if (result.getData() == null) {
throw new BusinessException("操作失败");
}
if (result.getData().getH5Url() == null || result.getData().getH5Url().isEmpty()) {
throw new BusinessException("操作失败");
}
return result.getData();
}
}