|
@@ -25,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.alibaba.dashscope.utils.JsonUtils.gson;
|
|
|
import static org.jeecg.modules.app.esign.auth.ESignAuth.*;
|
|
@@ -51,7 +50,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
private FamilyMembersMapper familyMembersMapper;
|
|
|
@Resource
|
|
|
private AppSiteMapper appSiteMapper;
|
|
|
- private static final String NOTIFY_URL = "";
|
|
|
+ private static final String NOTIFY_URL = "http://o3878n6548.wicp.vip/jeecg-boot/app/esign/signCallback";
|
|
|
private static final String REDIRECT_URL = "";
|
|
|
private static final String NAME_MAIN_ORGANIZATION = "中数未来(海南)系统集成有限公司";
|
|
|
private static final String MAIN_CARD_NUM = "91460105MAA9A6L75X";
|
|
@@ -61,26 +60,30 @@ public class ESignServiceImpl implements IESignService {
|
|
|
private static final String[] ORG_AUTH_MODES = {"ORG_ALIPAY_CREDIT", "ORG_LEGALREP"};
|
|
|
private static final int DEFAULT_EXPIRE_TIME = 86400000;
|
|
|
@Override
|
|
|
- public boolean getUserIdentityInfo(String phoneNumber) throws EsignDemoException {
|
|
|
- EsignHttpResponse getPsnIdentityInfo = getPsnIdentityInfo(phoneNumber);
|
|
|
+ public boolean getUserIdentityInfo(String familyId) throws EsignDemoException {
|
|
|
+ FamilyMembers familyMembers = familyMembersMapper.selectById(familyId);
|
|
|
+ EsignHttpResponse getPsnIdentityInfo = getPsnIdentityInfo(familyMembers.getPhone());
|
|
|
JsonObject getPsnIdentityInfoObject = gson.fromJson(getPsnIdentityInfo.getBody(), JsonObject.class);
|
|
|
+ if(getPsnIdentityInfoObject.get("code").getAsString().equals("1435203")) return false;
|
|
|
String realnameStatus =getPsnIdentityInfoObject.getAsJsonObject("data").get("realnameStatus").getAsString();//授权状态authorizeUserInfo
|
|
|
String psnId =getPsnIdentityInfoObject.getAsJsonObject("data").get("psnId").getAsString();
|
|
|
- FamilyMembers familyMembers = familyMembersMapper.selectOne(Wrappers.<FamilyMembers>lambdaQuery().eq(FamilyMembers::getPhone, phoneNumber));
|
|
|
familyMembers.setPsnId(psnId);
|
|
|
familyMembersMapper.updateById(familyMembers);
|
|
|
return realnameStatus.equals("1");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getAuthUrl(String phoneNumber) throws EsignDemoException {
|
|
|
+ public String getAuthUrl(String familyId) throws EsignDemoException {
|
|
|
+// FamilyMembers familyMembers = familyMembersMapper.selectById(familyId);
|
|
|
GetPsnAuthUrlDTO getPsnAuthUrlDTO = new GetPsnAuthUrlDTO();
|
|
|
- GetPsnAuthUrlDTO.PsnAuthConfig pncAuthConfig = new GetPsnAuthUrlDTO.PsnAuthConfig().setPsnAccount(phoneNumber);
|
|
|
+// GetPsnAuthUrlDTO.PsnAuthConfig pncAuthConfig = new GetPsnAuthUrlDTO.PsnAuthConfig().setPsnAccount(familyMembers.getPhone());
|
|
|
+ GetPsnAuthUrlDTO.PsnAuthConfig pncAuthConfig = new GetPsnAuthUrlDTO.PsnAuthConfig().setPsnAccount("17885674919");
|
|
|
getPsnAuthUrlDTO.setPsnAuthConfig(pncAuthConfig);
|
|
|
EsignHttpResponse getPsnAuthUrl = getPsnAuthUrl(getPsnAuthUrlDTO);
|
|
|
JsonObject getPsnAuthUrlObject = gson.fromJson(getPsnAuthUrl.getBody(), JsonObject.class);
|
|
|
+ if(getPsnAuthUrlObject.get("code").getAsString().equals("1450005")) throw new JeecgBootException("当前用户已实名");
|
|
|
JsonObject data = getPsnAuthUrlObject.getAsJsonObject("data");
|
|
|
- return data.get("authUrl").getAsString();
|
|
|
+ return data.get("authShortUrl").getAsString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -159,40 +162,30 @@ public class ESignServiceImpl implements IESignService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public List<String> createSign(String orderCode){
|
|
|
- List<String> signFlowIds = new ArrayList<>();
|
|
|
+ public String createSign(String orderCode, String familyId){
|
|
|
AppOrder appOrder = orderMapper.selectOne(Wrappers.<AppOrder>lambdaQuery()
|
|
|
.eq(AppOrder::getOrderCode, orderCode));
|
|
|
|
|
|
- List<String> familyIds = Arrays.asList(appOrder.getFamilyIds().split(","));
|
|
|
AppContractInfo contractInfo = appAccountMapper.selectById(appOrder.getContractNo());
|
|
|
SysDepart sysDepart = sysDepartMapper.selectOne(Wrappers.<SysDepart>lambdaQuery()
|
|
|
.eq(SysDepart::getOrgCode, appOrder.getOrgCode()));
|
|
|
|
|
|
- // 预加载家庭成员信息
|
|
|
- Map<String, FamilyMembers> familyMemberMap = familyIds.stream()
|
|
|
- .map(familyMembersMapper::selectById)
|
|
|
- .collect(Collectors.toMap(FamilyMembers::getId, fm -> fm));
|
|
|
|
|
|
- // 构建签署流程
|
|
|
- familyIds.forEach(familyId -> {
|
|
|
- try {
|
|
|
- FamilyMembers familyMembers = familyMemberMap.get(familyId);
|
|
|
- JsonObject dto = buildSignFlowDto(contractInfo, sysDepart, familyMembers);
|
|
|
-
|
|
|
- EsignHttpResponse response = createByFile(dto.toString());
|
|
|
- String signFlowId = extractSignFlowId(response);
|
|
|
-
|
|
|
- log.info("生成签署流程ID: {}", signFlowId);
|
|
|
- signFlowIds.add(signFlowId);
|
|
|
- saveSignFlowRecord(signFlowId, appOrder, familyId);
|
|
|
- } catch (EsignDemoException e) {
|
|
|
- log.error("签署流程创建失败,订单号: {}", orderCode, e);
|
|
|
- throw new JeecgBootException(e.getMessage());
|
|
|
- }
|
|
|
- });
|
|
|
+ try {
|
|
|
+ FamilyMembers familyMembers = familyMembersMapper.selectById(familyId);
|
|
|
+ JsonObject dto = buildSignFlowDto(contractInfo, sysDepart, familyMembers);
|
|
|
+
|
|
|
+ EsignHttpResponse response = createByFile(dto.toString());
|
|
|
+ String signFlowId = extractSignFlowId(response);
|
|
|
+
|
|
|
+ log.info("生成签署流程ID: {}", signFlowId);
|
|
|
+ saveSignFlowRecord(signFlowId, appOrder, familyId);
|
|
|
+ return signFlowId;
|
|
|
+ } catch (EsignDemoException e) {
|
|
|
+ log.error("签署流程创建失败,订单号: {}", orderCode, e);
|
|
|
+ throw new JeecgBootException(e.getMessage());
|
|
|
+ }
|
|
|
|
|
|
- return signFlowIds;
|
|
|
}
|
|
|
/**
|
|
|
* 构建签署流程请求体
|
|
@@ -251,6 +244,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
|
|
|
JsonObject transactor = new JsonObject();
|
|
|
transactor.addProperty("psnId", familyMembers.getPsnId());
|
|
|
+// transactor.addProperty("psnId", "630548cc4f954e7fad05210af02cee35");
|
|
|
orgInitiator.add("transactor", transactor);
|
|
|
|
|
|
signFlowInitiator.add("orgInitiator", orgInitiator);
|
|
@@ -410,6 +404,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
*/
|
|
|
private String extractSignFlowId(EsignHttpResponse response) {
|
|
|
JSONObject result = JSONObject.parseObject(response.getBody());
|
|
|
+ if (result.getString("code").equals("1435002")) throw new JeecgBootException("该使用人未授权");
|
|
|
return result.getJSONObject("data").getString("signFlowId");
|
|
|
}
|
|
|
|
|
@@ -417,16 +412,11 @@ public class ESignServiceImpl implements IESignService {
|
|
|
* 保存签署流程记录
|
|
|
*/
|
|
|
private void saveSignFlowRecord(String signFlowId, AppOrder appOrder, String familyId) {
|
|
|
- String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
- AppContractSign record = new AppContractSign()
|
|
|
- .setId(id)
|
|
|
- .setSignFlowId(signFlowId)
|
|
|
- .setOrderId(appOrder.getId())
|
|
|
- .setFamilyId(familyId)
|
|
|
- .setOrgCode(appOrder.getOrgCode())
|
|
|
- .setCreateTime(new Date())
|
|
|
- .setUpdateTime(new Date());
|
|
|
- appContractSignMapper.insert(record);
|
|
|
+ AppContractSign appContractSign = appContractSignMapper.selectOne(Wrappers.<AppContractSign>lambdaQuery()
|
|
|
+ .eq(AppContractSign::getOrderId, appOrder.getId())
|
|
|
+ .eq(AppContractSign::getFamilyId, familyId));
|
|
|
+ appContractSign.setSignFlowId(signFlowId);
|
|
|
+ appContractSignMapper.updateById(appContractSign);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -653,6 +643,36 @@ public class ESignServiceImpl implements IESignService {
|
|
|
return previewUrl;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean signCallback(JsonObject jsonObject) {
|
|
|
+ try {
|
|
|
+ // 提取字段并验证
|
|
|
+ String action = jsonObject.get("action").getAsString();
|
|
|
+ String statusDesc = jsonObject.get("statusDescription").getAsString();
|
|
|
+ if("SIGN_FLOW_COMPLETE".equals(action) && "完成".equals(statusDesc)){
|
|
|
+ String signFlowId = jsonObject.get("signFlowId").getAsString();
|
|
|
+ AppContractSign appContractSign = appContractSignMapper.selectOne(Wrappers.<AppContractSign>lambdaQuery()
|
|
|
+ .eq(AppContractSign::getSignFlowId, signFlowId));
|
|
|
+ appContractSign.setIsSign(1).setSignTime(new Date());
|
|
|
+ return appContractSignMapper.updateById(appContractSign) > 0;
|
|
|
+ }else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error( e.getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AppContractSign> queryWaitSignList(String orderId) {
|
|
|
+ List<AppContractSign> appContractSigns = appContractSignMapper.selectList(Wrappers.<AppContractSign>lambdaQuery().eq(AppContractSign::getOrderId, orderId));
|
|
|
+ appContractSigns.forEach(a -> {
|
|
|
+ a.setFullName(familyMembersMapper.selectById(a.getFamilyId()).getFullName());
|
|
|
+ });
|
|
|
+ return appContractSigns;
|
|
|
+ }
|
|
|
+
|
|
|
public String orgAuthorizedSeal(String orgId) throws EsignDemoException {
|
|
|
// 使用传入的 orgId
|
|
|
EsignHttpResponse orgAuthorizedSealList = orgAuthorizedSealList("585f3eabc65b42b1ad5ae56f4e2bdde6");
|