Commit 45854c17 authored by 5359's avatar 5359

代码提交git

parent 9a33e9a9
Pipeline #5222 canceled with stages
package com.hand.app.esignHclc.controllers;
import org.springframework.stereotype.Controller;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.dto.ResponseData;
import com.hand.app.esignHclc.dto.SignFlowsInfoHclc;
import com.hand.app.esignHclc.service.ISignFlowsInfoHclcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import org.springframework.validation.BindingResult;
import java.util.List;
@Controller
public class SignFlowsInfoHclcController extends BaseController {
@Autowired
private ISignFlowsInfoHclcService service;
@RequestMapping(value = "/sign/flows/info/hclc/query")
@ResponseBody
public ResponseData query(SignFlowsInfoHclc dto, @RequestParam(defaultValue = DEFAULT_PAGE) int page,
@RequestParam(defaultValue = DEFAULT_PAGE_SIZE) int pageSize, HttpServletRequest request) {
IRequest requestContext = createRequestContext(request);
return new ResponseData(service.select(requestContext, dto, page, pageSize));
}
@RequestMapping(value = "/sign/flows/info/hclc/submit")
@ResponseBody
public ResponseData update(@RequestBody List<SignFlowsInfoHclc> dto, BindingResult result, HttpServletRequest request) {
getValidator().validate(dto, result);
if (result.hasErrors()) {
ResponseData responseData = new ResponseData(false);
responseData.setMessage(getErrorMessage(result, request));
return responseData;
}
IRequest requestCtx = createRequestContext(request);
return new ResponseData(service.batchUpdate(requestCtx, dto));
}
@RequestMapping(value = "/sign/flows/info/hclc/remove")
@ResponseBody
public ResponseData delete(HttpServletRequest request, @RequestBody List<SignFlowsInfoHclc> dto) {
service.batchDelete(dto);
return new ResponseData();
}
}
\ No newline at end of file
package com.hand.app.esignHclc.controllers;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esignHclc.dto.SignUserAttachInfo;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.hand.app.esignHclc.dto.SignUserFaceHclc;
import com.hand.app.esignHclc.dto.SignUserInfoHclcHis;
import com.hand.app.esignHclc.service.*;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.controllers.BaseController;
import hls.support.core.wechat.formbean.AttachmentInfo;
import com.hand.hap.system.dto.ResponseData;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Controller
@RequestMapping(value = {"/r/api", "/"})
public class SignHclcController extends BaseController {
@Autowired
private ISignInfoHclcService signHclcService;
@Autowired
private IOrganSignInfoHclcService organSignHclcService;
@Autowired
private ISignInfoHclcFaceService signInfoHclcFaceService;
@Autowired
private ISignUserInfoHclcHisService signUserInfoHclcHisService;
@Autowired
private ISignUserAttachInfoService iSignUserAttachInfoService;
/**
* 根据openid获取用户信息
*
* @param request
* @param dto 根据openid获取用户信息
* @return responseData
*/
@ResponseBody
@RequestMapping(value = "/sign/info/hclc/query/by/openid")
public ResponseData query(HttpServletRequest request, SignUserInfoHclc dto) {
IRequest requestContext = createRequestContext(request);
List<SignUserInfoHclc> signInfoHclcs = new ArrayList<>();
SignUserInfoHclc signInfoHclc = signHclcService.selectByPrimaryKey(requestContext, dto);
if (Objects.nonNull(signInfoHclc)) {
//获取人脸核验状态
if (Objects.nonNull(signInfoHclc.getFaceAuthId())) {
SignUserFaceHclc signInfoHclcFace = new SignUserFaceHclc();
signInfoHclcFace.setAuthId(signInfoHclc.getFaceAuthId());
signInfoHclcFace = signInfoHclcFaceService.selectByPrimaryKey(requestContext, signInfoHclcFace);
signInfoHclc.setFaceAuthStatus(signInfoHclcFace.getAuthStatus());
}
//获取机构对公打款状态
if (Objects.nonNull(signInfoHclc.getOrgAuthId())) {
SignUserFaceHclc signInfoHclcFace = new SignUserFaceHclc();
signInfoHclcFace.setAuthId(signInfoHclc.getOrgAuthId());
signInfoHclcFace = signInfoHclcFaceService.selectByPrimaryKey(requestContext, signInfoHclcFace);
signInfoHclc.setOrgAuthStatus(signInfoHclcFace.getAuthStatus());
}
SignUserAttachInfo signUserAttachInfo = new SignUserAttachInfo();
signUserAttachInfo.setOpenId(signInfoHclc.getOpenId());
List<SignUserAttachInfo> signUserAttachInfos = new ArrayList<>();
//身份证附件Id
{
signUserAttachInfo.setAttachmentType("app_file_id_card");
signUserAttachInfos = iSignUserAttachInfoService.select(requestContext, signUserAttachInfo, 1, 1);
if (signUserAttachInfos.size() > 0 && Objects.nonNull(signUserAttachInfos.get(0).getAttachmentIdHclc())) {
signInfoHclc.setAttachmentId(signUserAttachInfos.get(0).getAttachmentIdHclc().toString());
}
}
//营业执照附件Id
{
signUserAttachInfo.setAttachmentType("app_file_bus_lic");
signUserAttachInfos = iSignUserAttachInfoService.select(requestContext, signUserAttachInfo, 1, 1);
if (signUserAttachInfos.size() > 0 && Objects.nonNull(signUserAttachInfos.get(0).getAttachmentIdHclc())) {
signInfoHclc.setOrgAttachmentId(signUserAttachInfos.get(0).getAttachmentIdHclc().toString());
}
}
}
if (signInfoHclc != null) {
signInfoHclcs.add(signInfoHclc);
}
return new ResponseData(signInfoHclcs);
}
/**
* 创建个人用户
*
* @param request
* @param dto 创建个人用户
* @return Map
*/
@ResponseBody
@RequestMapping("/accounts/outerAccounts/create")
public Map<String, Object> addPersonAccount(HttpServletRequest request,
@RequestBody SignUserInfoHclc dto) {
Map<String, Object> map = new HashMap<>();
IRequest iRequest = createRequestContext(request);
map = signHclcService.addPersonAccount(dto);
if ("0".equalsIgnoreCase(map.get("code").toString())) {
dto = signHclcService.selectByPrimaryKey(iRequest, dto);
dto.setAccountId(map.get("accountId").toString());
signHclcService.updateByPrimaryKey(createRequestContext(request), dto);
}
return map;
}
/**
* 注销个人用户
*
* @param request
* @param dto 注销个人用户
* @return Map
*/
@ResponseBody
@RequestMapping("/accounts/outerAccounts/delete")
public Map<String, Object> deletePersonAccount(HttpServletRequest request,
@RequestBody SignUserInfoHclc dto) {
IRequest iRequest = createRequestContext(request);
Map<String, Object> map = new HashMap<>();
if (Objects.isNull(dto.getOpenId())) {
map.put("code", "000005");
map.put("message", "关键参数openId不存在,调用失败!");
return map;
}
map = signHclcService.deletePersonAccount(iRequest, dto);
if ("0".equalsIgnoreCase(map.get("code").toString()) || "40051667".equalsIgnoreCase(map.get("code").toString()) || "000003".equalsIgnoreCase(map.get("code").toString())) {
dto = signHclcService.selectByPrimaryKey(iRequest, dto);
SignUserInfoHclcHis signUserInfoHclcHis = new SignUserInfoHclcHis();
BeanUtils.copyProperties(dto, signUserInfoHclcHis);
signUserInfoHclcHisService.insert(iRequest, signUserInfoHclcHis);
signHclcService.deleteByPrimaryKey(dto);
}
return map;
}
/**
* 创建机构用户
*
* @param request
* @param dto 创建机构用户
* @return Map
*/
@ResponseBody
@RequestMapping("/organizations/outerOrgans/create")
public Map<String, Object> addOrgansAccount(HttpServletRequest request,
@RequestBody SignUserInfoHclc dto) {
Map<String, Object> map = new HashMap<>();
IRequest iRequest = createRequestContext(request);
map = organSignHclcService.addOrgansAccount(dto);
if ("0".equalsIgnoreCase(map.get("code").toString())) {
dto = signHclcService.selectByPrimaryKey(iRequest, dto);
dto.setAccountId(map.get("organizeId").toString());
signHclcService.updateByPrimaryKey(createRequestContext(request), dto);
}
return map;
}
/**
* 注销机构用户
*
* @param request
* @param dto 注销机构用户
* @return Map
*/
@ResponseBody
@RequestMapping("/organizations/outerOrgans/delete")
public Map<String, Object> deleteOrgansAccount(HttpServletRequest request,
@RequestBody SignUserInfoHclc dto) {
Map<String, Object> map = new HashMap<>();
IRequest iRequest = createRequestContext(request);
if (Objects.isNull(dto.getOpenId())) {
map.put("code", "000005");
map.put("message", "关键参数openId不存在,调用失败!");
}
//注销机构账户
map = organSignHclcService.deleteOrgansAccount(iRequest, dto);
if ("0".equalsIgnoreCase(map.get("code").toString()) || "40051667".equalsIgnoreCase(map.get("code").toString())) {
dto = signHclcService.selectByPrimaryKey(iRequest, dto);
//复制用户信息到历史表
SignUserInfoHclcHis signUserInfoHclcHis = new SignUserInfoHclcHis();
BeanUtils.copyProperties(dto, signUserInfoHclcHis);
signUserInfoHclcHisService.insert(iRequest, signUserInfoHclcHis);
//重置结构用户信息为空
dto.setAccountId("");
dto.setAuthAccountId("");
dto.setOrgAuthId(null);
dto.setAuthFlag("N");
dto.setCreateCode("");
dto.setCreateMessage("");
//注销经办人用户
map = signHclcService.deletePersonAccount(iRequest, dto);
if ("0".equalsIgnoreCase(map.get("code").toString()) || "40051667".equalsIgnoreCase(map.get("code").toString()) || "000003".equalsIgnoreCase(map.get("code").toString())) {
signHclcService.deleteByPrimaryKey(dto);
} else {
signHclcService.updateByPrimaryKey(iRequest, dto);
}
//机构已注销,ccountaId为空的情况
} else if ("000012".equalsIgnoreCase(map.get("code").toString())) {
//注销经办人用户
map = signHclcService.deletePersonAccount(iRequest, dto);
if ("0".equalsIgnoreCase(map.get("code").toString()) || "40051667".equalsIgnoreCase(map.get("code").toString()) || "000003".equalsIgnoreCase(map.get("code").toString())) {
signHclcService.deleteByPrimaryKey(dto);
}
}
return map;
}
/**
* 获取人身核验地址
*
* @param request
* @param dto 获取人身核验地址
* @return Map
*/
@ResponseBody
@RequestMapping("/auth/api/individual/face")
public Map<String, Object> getIndividualFaceUrl(HttpServletRequest request,
@RequestBody SignUserInfoHclc dto) {
return signHclcService.getIndividualFaceUrl(createRequestContext(request), dto);
}
/**
* 获取机构核验地址
*
* @param request
* @param dto 获取机构核验地址
* @return Map
*/
@ResponseBody
@RequestMapping("/auth/api/individual/face/Organ")
public Map<String, Object> getOrganIndividualFaceUrl(HttpServletRequest request,
@RequestBody SignUserInfoHclc dto) {
return organSignHclcService.getOrganIndividualFaceUrl(createRequestContext(request), dto);
}
/**
* 下载微信图片资源上传业务系统
*
* @param request
* @param dto 下载微信图片资源上传业务系统
*/
@RequestMapping(value = "/auth/upload/image/hls/from/wx", method = RequestMethod.POST)
@ResponseBody
public JSONObject uploadHlsFromWx(HttpServletRequest request, @RequestBody AttachmentInfo dto) {
return signHclcService.uploadHlsFromWx(createRequestContext(request), dto);
}
/**
* 文件直传
*
* @param request
* @param dto 文件直传
* @return Map
*/
@ResponseBody
@RequestMapping("/sign/files/upload")
public Map<String, Object> signFileUpload(HttpServletRequest request,
@RequestBody AttachmentInfo dto) {
return signHclcService.signFileUpload(createRequestContext(request), dto);
}
/**
* 创建签署流程
*
* @param request
* @param params 创建签署流程
* @return Map
*/
@ResponseBody
@RequestMapping(value = "/sign/flows/create", method = RequestMethod.POST)
public JSONObject createSignFlows(HttpServletRequest request,
@RequestBody(required = true) JSONObject params) {
return signHclcService.createSignFlows(createRequestContext(request), params);
}
}
package com.hand.app.esignHclc.controllers;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.system.dto.ResponseData;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/25
* Time: 21:32
*/
@Controller
public class SignHclcListenController extends BaseController {
@Autowired
private ISignInfoHclcFaceService iSignInfoHclcFaceService;
@Autowired
private ISignInfoHclcService iSignInfoHclcService;
@ResponseBody
@RequestMapping(value = "/api/public/listen/auth/result", method = RequestMethod.POST)
public ResponseData postAuthResult(HttpServletRequest request,
@RequestBody(required = false) JSONObject params) {
ResponseData responseData = new ResponseData(false);
iSignInfoHclcFaceService.postAuthResult(createRequestContext(request), params);
responseData.setCode("200");
responseData.setSuccess(true);
responseData.setMessage("接收成功!");
return responseData;
}
@ResponseBody
@RequestMapping(value = "/api/public/listen/sign/flow", method = RequestMethod.POST)
public ResponseData postSignFlowsResult(HttpServletRequest request,
@RequestBody(required = false) JSONObject params) {
ResponseData responseData = new ResponseData(false);
iSignInfoHclcService.postSignFlowsResult(createRequestContext(request), params);
responseData.setCode("200");
responseData.setSuccess(true);
responseData.setMessage("接收成功!");
return responseData;
}
}
package com.hand.app.esignHclc.controllers;
import org.springframework.stereotype.Controller;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.dto.ResponseData;
import com.hand.app.esignHclc.dto.SignUserAttachInfo;
import com.hand.app.esignHclc.service.ISignUserAttachInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import org.springframework.validation.BindingResult;
import java.util.List;
@Controller
public class SignUserAttachInfoController extends BaseController {
@Autowired
private ISignUserAttachInfoService service;
@RequestMapping(value = "/sign/user/attach/info/query")
@ResponseBody
public ResponseData query(SignUserAttachInfo dto, @RequestParam(defaultValue = DEFAULT_PAGE) int page,
@RequestParam(defaultValue = DEFAULT_PAGE_SIZE) int pageSize, HttpServletRequest request) {
IRequest requestContext = createRequestContext(request);
return new ResponseData(service.select(requestContext, dto, page, pageSize));
}
@RequestMapping(value = "/sign/user/attach/info/submit")
@ResponseBody
public ResponseData update(@RequestBody List<SignUserAttachInfo> dto, BindingResult result, HttpServletRequest request) {
getValidator().validate(dto, result);
if (result.hasErrors()) {
ResponseData responseData = new ResponseData(false);
responseData.setMessage(getErrorMessage(result, request));
return responseData;
}
IRequest requestCtx = createRequestContext(request);
return new ResponseData(service.batchUpdate(requestCtx, dto));
}
@RequestMapping(value = "/sign/user/attach/info/remove")
@ResponseBody
public ResponseData delete(HttpServletRequest request, @RequestBody List<SignUserAttachInfo> dto) {
service.batchDelete(dto);
return new ResponseData();
}
}
\ No newline at end of file
package com.hand.app.esignHclc.controllers;
import org.springframework.stereotype.Controller;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.dto.ResponseData;
import com.hand.app.esignHclc.dto.SignUserInfoHclcHis;
import com.hand.app.esignHclc.service.ISignUserInfoHclcHisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import org.springframework.validation.BindingResult;
import java.util.List;
@Controller
public class SignUserInfoHclcHisController extends BaseController {
@Autowired
private ISignUserInfoHclcHisService service;
@RequestMapping(value = "/sign/user/info/hclc/his/query")
@ResponseBody
public ResponseData query(SignUserInfoHclcHis dto, @RequestParam(defaultValue = DEFAULT_PAGE) int page,
@RequestParam(defaultValue = DEFAULT_PAGE_SIZE) int pageSize, HttpServletRequest request) {
IRequest requestContext = createRequestContext(request);
return new ResponseData(service.select(requestContext, dto, page, pageSize));
}
@RequestMapping(value = "/sign/user/info/hclc/his/submit")
@ResponseBody
public ResponseData update(@RequestBody List<SignUserInfoHclcHis> dto, BindingResult result, HttpServletRequest request) {
getValidator().validate(dto, result);
if (result.hasErrors()) {
ResponseData responseData = new ResponseData(false);
responseData.setMessage(getErrorMessage(result, request));
return responseData;
}
IRequest requestCtx = createRequestContext(request);
return new ResponseData(service.batchUpdate(requestCtx, dto));
}
@RequestMapping(value = "/sign/user/info/hclc/his/remove")
@ResponseBody
public ResponseData delete(HttpServletRequest request, @RequestBody List<SignUserInfoHclcHis> dto) {
service.batchDelete(dto);
return new ResponseData();
}
}
\ No newline at end of file
package com.hand.app.esignHclc.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/27
* Time: 10:27
*/
@Table(name = "lm005_hclc")
@ExtensionAttribute(disable = true)
public class Lm005Hclc extends BaseDTO {
@Id
private String webcustomercd;
private String ctino;//身份证件号(组织机构号)
private String openId;
public String getWebcustomercd() {
return webcustomercd;
}
public void setWebcustomercd(String webcustomercd) {
this.webcustomercd = webcustomercd;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getCtino() {
return ctino;
}
public void setCtino(String ctino) {
this.ctino = ctino;
}
}
package com.hand.app.esignHclc.dto;
/**
* Auto Generated By Hap Code Generator
**/
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import org.hibernate.validator.constraints.Length;
import javax.persistence.Table;
import com.hand.hap.system.dto.BaseDTO;
@ExtensionAttribute(disable = true)
@Table(name = "SIGN_FLOWS_INFO_HCLC")
public class SignFlowsInfoHclc extends BaseDTO {
public static final String FIELD_INFO_ID = "infoId";
public static final String FIELD_CONTRACT_NO = "contractNo";
public static final String FIELD_SIGN_FLOW_ID = "signFlowId";
public static final String FIELD_SIGN_ACTION = "signAction";
public static final String FIELD_STATUS = "status";
public static final String FIELD_REQUEST_CLOB = "requestClob";
public static final String FIELD_RESPONSE_CLOB = "responseClob";
public static final String FIELD_RETURN_CODE = "returnCode";
public static final String FIELD_RETURN_MSG = "returnMsg";
@Id
@GeneratedValue
private Long infoId;
@Length(max = 30)
private String contractNo;
private String signFlowId;
@Length(max = 50)
private String signAction;
@Length(max = 50)
private String status;
@Length(max = 4000)
private String requestClob;
@Length(max = 4000)
private String responseClob;
@Length(max = 50)
private String returnCode;
@Length(max = 2000)
private String returnMsg;
private String sendFlag;
public void setInfoId(Long infoId) {
this.infoId = infoId;
}
public Long getInfoId() {
return infoId;
}
public void setContractNo(String contractNo) {
this.contractNo = contractNo;
}
public String getContractNo() {
return contractNo;
}
public void setSignFlowId(String signFlowId) {
this.signFlowId = signFlowId;
}
public String getSignFlowId() {
return signFlowId;
}
public void setSignAction(String signAction) {
this.signAction = signAction;
}
public String getSignAction() {
return signAction;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
public void setRequestClob(String requestClob) {
this.requestClob = requestClob;
}
public String getRequestClob() {
return requestClob;
}
public void setResponseClob(String responseClob) {
this.responseClob = responseClob;
}
public String getResponseClob() {
return responseClob;
}
public void setReturnCode(String returnCode) {
this.returnCode = returnCode;
}
public String getReturnCode() {
return returnCode;
}
public void setReturnMsg(String returnMsg) {
this.returnMsg = returnMsg;
}
public String getReturnMsg() {
return returnMsg;
}
public void setSendFlag(String sendFlag) {
this.sendFlag = sendFlag;
}
public String getSendFlag() {
return sendFlag;
}
}
package com.hand.app.esignHclc.dto;
/**
* Auto Generated By Hap Code Generator
**/
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import org.hibernate.validator.constraints.Length;
import javax.persistence.Table;
import com.hand.hap.system.dto.BaseDTO;
@ExtensionAttribute(disable = true)
@Table(name = "SIGN_USER_ATTACH_INFO")
public class SignUserAttachInfo extends BaseDTO {
@Id
@GeneratedValue
private Long attachmentId;
@Length(max = 30)
private String openId;
@Length(max = 50)
private String attachmentType;
@Length(max = 200)
private String mediaId;
private Long attachmentIdHclc;
public void setAttachmentId(Long attachmentId) {
this.attachmentId = attachmentId;
}
public Long getAttachmentId() {
return attachmentId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getOpenId() {
return openId;
}
public void setAttachmentType(String attachmentType) {
this.attachmentType = attachmentType;
}
public String getAttachmentType() {
return attachmentType;
}
public void setMediaId(String mediaId) {
this.mediaId = mediaId;
}
public String getMediaId() {
return mediaId;
}
public void setAttachmentIdHclc(Long attachmentIdHclc) {
this.attachmentIdHclc = attachmentIdHclc;
}
public Long getAttachmentIdHclc() {
return attachmentIdHclc;
}
}
package com.hand.app.esignHclc.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Table(name = "sign_user_face_hclc")
@ExtensionAttribute(disable = true)
public class SignUserFaceHclc extends BaseDTO {
@Id
@GeneratedValue
private Long authId;
private String openId;
private String authStatus;
private String url;
private String shortLink;
private String returnCode;
private String returnMessage;
private String flowId;
private String authType;
private String verifyCode;
private String enableFlag;
public Long getAuthId() {
return authId;
}
public void setAuthId(Long authId) {
this.authId = authId;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getShortLink() {
return shortLink;
}
public void setShortLink(String shortLink) {
this.shortLink = shortLink;
}
public String getReturnCode() {
return returnCode;
}
public void setReturnCode(String returnCode) {
this.returnCode = returnCode;
}
public String getReturnMessage() {
return returnMessage;
}
public void setReturnMessage(String returnMessage) {
this.returnMessage = returnMessage;
}
public String getAuthStatus() {
return authStatus;
}
public void setAuthStatus(String authStatus) {
this.authStatus = authStatus;
}
public String getFlowId() {
return flowId;
}
public void setFlowId(String flowId) {
this.flowId = flowId;
}
public String getAuthType() {
return authType;
}
public void setAuthType(String authType) {
this.authType = authType;
}
public String getVerifyCode() {
return verifyCode;
}
public void setVerifyCode(String verifyCode) {
this.verifyCode = verifyCode;
}
public String getEnableFlag() {
return enableFlag;
}
public void setEnableFlag(String enableFlag) {
this.enableFlag = enableFlag;
}
}
package com.hand.app.esignHclc.dto;
import com.hand.app.esign.bean.AttachmentInfo;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Table(name = "sign_user_info_hclc")
@ExtensionAttribute(disable = true)
public class SignUserInfoHclc extends BaseDTO {
@Id
private String openId;
private String idNo;//身份证件号(组织机构号)
private String name;//用户名称(组织机构名称)
private String mobile;
private String email;
private String title;
private String address;
private String legalName;//法定代表人姓名
private Long ctitype;//用户类型(1-个人,2-法人)
private Long agentType;//经办人类型(1-法定代表人,2-组织其他员工)
private String agentIdNo;//经办人身份证号码
private String agentName;//经办人姓名
private String legalIdNo;//法定代表人身份证号码
private String accountId; // 用户e签宝账户
private String agentAccountId; // 经办人e签宝账户
private String createCode; // e签宝用户创建返回code
private String createMessage; // e签宝用户创建返回描述
private Long faceAuthId;//人脸识别流程id
private Long orgAuthId;//企业识别流程id
private String authAccountId; // 用户e签宝账户
private String authAgentAccountId; // 经办人e签宝账户
private String authFlag; // 用户通过认证状态
@Transient
private String attachmentId;//身份证附件id
@Transient
private String orgAttachmentId;//机构营业执照附件id
@Transient
private AttachmentInfo attachmentInfo; // 附件信息
@Transient
private String apiUrl; // e签宝接口url
@Transient
private String appId; // e签宝人脸接口用户id
@Transient
private String secret; // e签宝人脸接口密钥
@Transient
private String redirectUrl; // e签宝返回企业认证url
@Transient
private String notifyUrl; // e签宝返回企业认证url
@Transient
private String faceAuthStatus;//人脸识别流程id
@Transient
private String orgAuthStatus;//企业识别流程id
@Transient
private String mediaId;//微信图片资源id
public AttachmentInfo getAttachmentInfo() {
return attachmentInfo;
}
public void setAttachmentInfo(AttachmentInfo attachmentInfo) {
this.attachmentInfo = attachmentInfo;
}
public String getApiUrl() {
return apiUrl;
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Long getAgentType() {
return agentType;
}
public void setAgentType(Long agentType) {
this.agentType = agentType;
}
public Long getCtitype() {
return ctitype;
}
public void setCtitype(Long ctitype) {
this.ctitype = ctitype;
}
public String getAgentAccountId() {
return agentAccountId;
}
public void setAgentAccountId(String agentAccountId) {
this.agentAccountId = agentAccountId;
}
public String getAgentIdNo() {
return agentIdNo;
}
public void setAgentIdNo(String agentIdNo) {
this.agentIdNo = agentIdNo;
}
public String getAgentName() {
return agentName;
}
public void setAgentName(String agentName) {
this.agentName = agentName;
}
public String getLegalIdNo() {
return legalIdNo;
}
public void setLegalIdNo(String legalIdNo) {
this.legalIdNo = legalIdNo;
}
public String getLegalName() {
return legalName;
}
public void setLegalName(String legalName) {
this.legalName = legalName;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getRedirectUrl() {
return redirectUrl;
}
public void setRedirectUrl(String redirectUrl) {
this.redirectUrl = redirectUrl;
}
public String getNotifyUrl() {
return notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public String getAttachmentId() {
return attachmentId;
}
public void setAttachmentId(String attachmentId) {
this.attachmentId = attachmentId;
}
public String getOrgAttachmentId() {
return orgAttachmentId;
}
public void setOrgAttachmentId(String orgAttachmentId) {
this.orgAttachmentId = orgAttachmentId;
}
public String getMediaId() {
return mediaId;
}
public void setMediaId(String mediaId) {
this.mediaId = mediaId;
}
public String getCreateCode() {
return createCode;
}
public void setCreateCode(String createCode) {
this.createCode = createCode;
}
public String getCreateMessage() {
return createMessage;
}
public void setCreateMessage(String createMessage) {
this.createMessage = createMessage;
}
public Long getFaceAuthId() {
return faceAuthId;
}
public void setFaceAuthId(Long faceAuthId) {
this.faceAuthId = faceAuthId;
}
public Long getOrgAuthId() {
return orgAuthId;
}
public void setOrgAuthId(Long orgAuthId) {
this.orgAuthId = orgAuthId;
}
public String getAuthAccountId() {
return authAccountId;
}
public void setAuthAccountId(String authAccountId) {
this.authAccountId = authAccountId;
}
public String getAuthAgentAccountId() {
return authAgentAccountId;
}
public void setAuthAgentAccountId(String authAgentAccountId) {
this.authAgentAccountId = authAgentAccountId;
}
public String getFaceAuthStatus() {
return faceAuthStatus;
}
public void setFaceAuthStatus(String faceAuthStatus) {
this.faceAuthStatus = faceAuthStatus;
}
public String getOrgAuthStatus() {
return orgAuthStatus;
}
public void setOrgAuthStatus(String orgAuthStatus) {
this.orgAuthStatus = orgAuthStatus;
}
public String getAuthFlag() {
return authFlag;
}
public void setAuthFlag(String authFlag) {
this.authFlag = authFlag;
}
}
package com.hand.app.esignHclc.dto;
/**
* Auto Generated By Hap Code Generator
**/
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import org.hibernate.validator.constraints.Length;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.hand.hap.system.dto.BaseDTO;
@ExtensionAttribute(disable = true)
@Table(name = "SIGN_USER_INFO_HCLC_HIS")
public class SignUserInfoHclcHis extends BaseDTO {
public static final String FIELD_HIS_ID = "hisId";
public static final String FIELD_OPEN_ID = "openId";
public static final String FIELD_ID_NO = "idNo";
public static final String FIELD_NAME = "name";
public static final String FIELD_MOBILE = "mobile";
public static final String FIELD_EMAIL = "email";
public static final String FIELD_TITLE = "title";
public static final String FIELD_ADDRESS = "address";
public static final String FIELD_ACCOUNT_ID = "accountId";
public static final String FIELD_CTITYPE = "ctitype";
public static final String FIELD_AGENT_TYPE = "agentType";
public static final String FIELD_AGENT_ID_NO = "agentIdNo";
public static final String FIELD_AGENT_NAME = "agentName";
public static final String FIELD_LEGAL_ID_NO = "legalIdNo";
public static final String FIELD_LEGAL_NAME = "legalName";
public static final String FIELD_CREATE_CODE = "createCode";
public static final String FIELD_CREATE_MESSAGE = "createMessage";
public static final String FIELD_AGENT_ACCOUNT_ID = "agentAccountId";
public static final String FIELD_FACE_AUTH_ID = "faceAuthId";
public static final String FIELD_ORG_AUTH_ID = "orgAuthId";
public static final String FIELD_AUTH_ACCOUNT_ID = "authAccountId";
public static final String FIELD_AUTH_AGENT_ACCOUNT_ID = "authAgentAccountId";
public static final String FIELD_AUTH_FLAG = "authFlag";
@Id
@GeneratedValue
private Long hisId;
@Length(max = 30)
private String openId;
@Length(max = 30)
private String idNo;
@Length(max = 200)
private String name;
@Length(max = 30)
private String mobile;
@Length(max = 30)
private String email;
@Length(max = 200)
private String title;
@Length(max = 300)
private String address;
@Length(max = 200)
private String accountId;
private Long ctitype;
private Long agentType;
@Length(max = 30)
private String agentIdNo;
@Length(max = 200)
private String agentName;
@Length(max = 30)
private String legalIdNo;
@Length(max = 200)
private String legalName;
@Transient
private Long attachmentId;
@Transient
private String mediaId;
@Length(max = 200)
private String createCode;
@Length(max = 2000)
private String createMessage;
@Length(max = 200)
private String agentAccountId;
private Long faceAuthId;
private Long orgAuthId;
@Length(max = 200)
private String authAccountId;
@Length(max = 200)
private String authAgentAccountId;
@Length(max = 1)
private String authFlag;
@Transient
private Long orgAttachmentId;
public void setHisId(Long hisId) {
this.hisId = hisId;
}
public Long getHisId() {
return hisId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getOpenId() {
return openId;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getIdNo() {
return idNo;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getMobile() {
return mobile;
}
public void setEmail(String email) {
this.email = email;
}
public String getEmail() {
return email;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setAddress(String address) {
this.address = address;
}
public String getAddress() {
return address;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccountId() {
return accountId;
}
public void setCtitype(Long ctitype) {
this.ctitype = ctitype;
}
public Long getCtitype() {
return ctitype;
}
public void setAgentType(Long agentType) {
this.agentType = agentType;
}
public Long getAgentType() {
return agentType;
}
public void setAgentIdNo(String agentIdNo) {
this.agentIdNo = agentIdNo;
}
public String getAgentIdNo() {
return agentIdNo;
}
public void setAgentName(String agentName) {
this.agentName = agentName;
}
public String getAgentName() {
return agentName;
}
public void setLegalIdNo(String legalIdNo) {
this.legalIdNo = legalIdNo;
}
public String getLegalIdNo() {
return legalIdNo;
}
public void setLegalName(String legalName) {
this.legalName = legalName;
}
public String getLegalName() {
return legalName;
}
public void setAttachmentId(Long attachmentId) {
this.attachmentId = attachmentId;
}
public Long getAttachmentId() {
return attachmentId;
}
public void setMediaId(String mediaId) {
this.mediaId = mediaId;
}
public String getMediaId() {
return mediaId;
}
public void setCreateCode(String createCode) {
this.createCode = createCode;
}
public String getCreateCode() {
return createCode;
}
public void setCreateMessage(String createMessage) {
this.createMessage = createMessage;
}
public String getCreateMessage() {
return createMessage;
}
public void setAgentAccountId(String agentAccountId) {
this.agentAccountId = agentAccountId;
}
public String getAgentAccountId() {
return agentAccountId;
}
public void setFaceAuthId(Long faceAuthId) {
this.faceAuthId = faceAuthId;
}
public Long getFaceAuthId() {
return faceAuthId;
}
public void setOrgAuthId(Long orgAuthId) {
this.orgAuthId = orgAuthId;
}
public Long getOrgAuthId() {
return orgAuthId;
}
public void setAuthAccountId(String authAccountId) {
this.authAccountId = authAccountId;
}
public String getAuthAccountId() {
return authAccountId;
}
public void setAuthAgentAccountId(String authAgentAccountId) {
this.authAgentAccountId = authAgentAccountId;
}
public String getAuthAgentAccountId() {
return authAgentAccountId;
}
public void setOrgAttachmentId(Long orgAttachmentId) {
this.orgAttachmentId = orgAttachmentId;
}
public Long getOrgAttachmentId() {
return orgAttachmentId;
}
public void setAuthFlag(String authFlag) {
this.authFlag = authFlag;
}
public String getAuthFlag() {
return authFlag;
}
}
package com.hand.app.esignHclc.mapper;
import com.hand.app.esignHclc.dto.Lm005Hclc;
import com.hand.hap.mybatis.common.Mapper;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface Lm005HclcMapper extends Mapper<Lm005Hclc> {
}
package com.hand.app.esignHclc.mapper;
import com.hand.hap.mybatis.common.Mapper;
import com.hand.app.esignHclc.dto.SignFlowsInfoHclc;
public interface SignFlowsInfoHclcMapper extends Mapper<SignFlowsInfoHclc>{
}
\ No newline at end of file
package com.hand.app.esignHclc.mapper;
import com.hand.app.esignHclc.dto.SignUserFaceHclc;
import com.hand.hap.mybatis.common.Mapper;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface SignInfoHclcFaceMapper extends Mapper<SignUserFaceHclc> {
SignUserFaceHclc getSignFaceAuthStatus(Long authId);
}
package com.hand.app.esignHclc.mapper;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.hand.hap.mybatis.common.Mapper;
import java.util.List;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface SignInfoHclcMapper extends Mapper<SignUserInfoHclc> {
List<SignUserInfoHclc> queryUserInfo(SignUserInfoHclc dto);
}
package com.hand.app.esignHclc.mapper;
import com.hand.hap.mybatis.common.Mapper;
import com.hand.app.esignHclc.dto.SignUserAttachInfo;
public interface SignUserAttachInfoMapper extends Mapper<SignUserAttachInfo>{
}
\ No newline at end of file
package com.hand.app.esignHclc.mapper;
import com.hand.hap.mybatis.common.Mapper;
import com.hand.app.esignHclc.dto.SignUserInfoHclcHis;
public interface SignUserInfoHclcHisMapper extends Mapper<SignUserInfoHclcHis>{
}
\ No newline at end of file
package com.hand.app.esignHclc.service;
import com.hand.app.esignHclc.dto.Lm005Hclc;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/27
* Time: 11:34
*/
public interface ILm005HclcService extends IBaseService<Lm005Hclc>, ProxySelf<ILm005HclcService> {
}
package com.hand.app.esignHclc.service;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import java.util.Map;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface IOrganSignInfoHclcService extends IBaseService<SignUserInfoHclc>, ProxySelf<IOrganSignInfoHclcService> {
Map<String,Object> getOrganIndividualFaceUrl(IRequest iRequest, SignUserInfoHclc info);
Map<String, Object> addOrgansAccount(SignUserInfoHclc info);
Map<String, Object> deleteOrgansAccount(IRequest iRequest,SignUserInfoHclc signInfoHclc);
}
package com.hand.app.esignHclc.service;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import com.hand.app.esignHclc.dto.SignFlowsInfoHclc;
public interface ISignFlowsInfoHclcService extends IBaseService<SignFlowsInfoHclc>, ProxySelf<ISignFlowsInfoHclcService>{
}
\ No newline at end of file
package com.hand.app.esignHclc.service;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esignHclc.dto.SignUserFaceHclc;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface ISignInfoHclcFaceService extends IBaseService<SignUserFaceHclc>, ProxySelf<ISignInfoHclcFaceService> {
void postAuthResult(IRequest iRequest, JSONObject params);
}
package com.hand.app.esignHclc.service;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import hls.support.core.wechat.formbean.AttachmentInfo;
import java.util.Map;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface ISignInfoHclcService extends IBaseService<SignUserInfoHclc>, ProxySelf<ISignInfoHclcService> {
Map<String, Object> getIndividualFaceUrl(IRequest iRequest, SignUserInfoHclc info);
Map<String, Object> getFaceUrlHttp(IRequest iRequest, SignUserInfoHclc info, String token);
Map<String, Object> getByThirdId(SignUserInfoHclc info, String token);
JSONObject uploadHlsFromWx(IRequest iRequest, AttachmentInfo attachmentInfo);
String getApiUrl(String sysName, String apiName);
Map<String, Object> addPersonAccount(SignUserInfoHclc signInfoHclc);
Map<String, Object> deletePersonAccount(IRequest iRequest, SignUserInfoHclc signInfoHclc);
Map<String, Object> signFileUpload(IRequest requestContext, AttachmentInfo dto);
JSONObject createSignFlows(IRequest requestContext, JSONObject params);
void postSignFlowsResult(IRequest iRequest, JSONObject params);
}
package com.hand.app.esignHclc.service;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import com.hand.app.esignHclc.dto.SignUserAttachInfo;
public interface ISignUserAttachInfoService extends IBaseService<SignUserAttachInfo>, ProxySelf<ISignUserAttachInfoService>{
}
\ No newline at end of file
package com.hand.app.esignHclc.service;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import com.hand.app.esignHclc.dto.SignUserInfoHclcHis;
public interface ISignUserInfoHclcHisService extends IBaseService<SignUserInfoHclcHis>, ProxySelf<ISignUserInfoHclcHisService>{
}
\ No newline at end of file
package com.hand.app.esignHclc.service.impl;
import com.hand.app.esignHclc.dto.Lm005Hclc;
import com.hand.app.esignHclc.service.ILm005HclcService;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/27
* Time: 11:34
*/
@Service
public class Lm005HclcServiceImpl extends BaseServiceImpl<Lm005Hclc> implements ILm005HclcService {
}
package com.hand.app.esignHclc.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esign.utils.AlgorithmHelper;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.hand.app.esignHclc.dto.SignUserFaceHclc;
import com.hand.app.esignHclc.service.IOrganSignInfoHclcService;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.app.esignHclc.utils.SignHclcUtils;
import com.hand.hap.core.IRequest;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.intergration.utils.HttpUtil;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.apache.http.HttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Service
public class OrganSignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> implements IOrganSignInfoHclcService {
@Value("${tsign.project.id}")
private String projectId;
@Value("${tsign.project.secret}")
private String projectSecret;
@Value("${tsign.api.notifyUrl}")
private String notifyUrl;
@Value("${tsign.face.api.appId}")
private String appId;
@Value("${tsign.face.api.secret}")
private String secret;
@Autowired
private ISignInfoHclcFaceService signInfoHclcFaceService;
@Autowired
private ISignInfoHclcService iSignInfoHclcService;
//用户认证接口信息
public static final String indivSysName = "HCLC_FACE_API";
public static final String tokenApiName = "getToken";
public static final String orgApiName = "orgAuthUrl";
public static final String getOrgIdApiName = "getOrgByThirdId";
//电子签章接口信息
public static final String signatureSysName = "HCLC_ELECTRONIC_SIGNATURE";
public static final String organsApiName = "outerOrgans";
public static final String deleteApiName = "organizationsDelete";
private static final String HASH_ALGORITHM = "HmacSHA256";
private final static int HTTP_OK = 200;
@Autowired
IHapInterfaceHeaderService headerService;
private Logger logger = LoggerFactory.getLogger(getClass());
public Map<String, Object> getOrganIndividualFaceUrl(IRequest iRequest, SignUserInfoHclc info) {
Map<String, Object> mapOrgan = new HashMap<>();
if (Objects.isNull(info.getOpenId())) {
logger.error("关键参数openId不存在,调用失败!");
mapOrgan.put("code", "1");
mapOrgan.put("message", "关键参数openId不存在,调用失败!");
return mapOrgan;
}
//查询用户信息
SignUserInfoHclc signInfoHclc = mapper.selectByPrimaryKey(info);
//初始化创建用户判断
String accountStatus = null;
String getUrlType = null;
//用户信息不存在,新增用户信息,创建e签宝经办人账户,获取经办人人脸核验url
if (Objects.isNull(signInfoHclc)) {
info.setCtitype(2L);
info.setAuthFlag("N");
signInfoHclc = this.insertSelective(iRequest, info);
accountStatus = "AGENT_ADD";
getUrlType = "AGENT";
} else {
if ("Y".equalsIgnoreCase(signInfoHclc.getAuthFlag())) {
mapOrgan.put("code", "2");
mapOrgan.put("message", "机构认证已完成,无需重复验证!");
return mapOrgan;
}
//移动端用户信息发生变更,需要注销e签宝账户,重新创建,并获取核验url
if (!signInfoHclc.getAgentIdNo().equalsIgnoreCase(info.getAgentIdNo()) || !signInfoHclc.getAgentName().equalsIgnoreCase(info.getAgentName()) || !signInfoHclc.getMobile().equalsIgnoreCase(info.getMobile())) {
//e签宝账户不存在,需要创建e签宝账户
if (Objects.isNull(signInfoHclc.getAgentAccountId())) {
accountStatus = "AGENT_ADD";
getUrlType = "AGENT";
}
//e签宝账户已存在,注销e签宝账户重新创建
else {
accountStatus = "AGENT_MODIFY";
getUrlType = "AGENT";
}
}
//移动端用户信息未发生变更
else {
SignUserFaceHclc signInfoHclcFace = new SignUserFaceHclc();
//存在人脸核验记录,获取原核验信息判断是否核验完成
if (Objects.nonNull(signInfoHclc.getFaceAuthId())) {
//查询经办人e签宝人脸核验信息
signInfoHclcFace.setAuthId(signInfoHclc.getFaceAuthId());
signInfoHclcFace = signInfoHclcFaceService.selectByPrimaryKey(iRequest, signInfoHclcFace);
//判断人脸核身认证状态,核验完成直接获取机构核验url
if ("SUCCESS".equalsIgnoreCase(signInfoHclcFace.getAuthStatus())) {
getUrlType = "ORG";
} else if ("FAIL".equalsIgnoreCase(signInfoHclcFace.getAuthStatus())) {
accountStatus = "AGENT_EXISTS";
getUrlType = "AGENT";
} else {
//返回原核验url
mapOrgan.put("code", "0");
mapOrgan.put("url", signInfoHclcFace.getUrl());
mapOrgan.put("message", "获取url成功!");
return mapOrgan;
}
} //不存在人脸核验记录,判断是否存在e签宝用户创建记录
else {
//e签宝账户不存在,需要新增
if (Objects.isNull(signInfoHclc.getAgentAccountId())) {
accountStatus = "AGENT_ADD";
getUrlType = "AGENT";
}
//e签宝账户已存在,不需要新增,直接获取人脸核验url
else {
accountStatus = "AGENT_EXISTS";
getUrlType = "AGENT";
}
}
}
}
//经办人人脸识别url
if ("AGENT".equalsIgnoreCase(getUrlType)) {
//初始化经办人人脸识别信息
SignUserInfoHclc agentSignInfo = new SignUserInfoHclc();
agentSignInfo.setOpenId(signInfoHclc.getOpenId());
agentSignInfo.setIdNo(signInfoHclc.getAgentIdNo());
agentSignInfo.setMobile(signInfoHclc.getMobile());
agentSignInfo.setName(signInfoHclc.getAgentName());
if (!"AGENT_EXISTS".equalsIgnoreCase(accountStatus)) {
//移动端用户信息发生变更,先注销e签宝用户
if ("AGENT_MODIFY".equalsIgnoreCase(accountStatus)) {
agentSignInfo.setAccountId(signInfoHclc.getAgentAccountId());
mapOrgan = iSignInfoHclcService.deletePersonAccount(iRequest, agentSignInfo);
//注销成功
if ("0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
agentSignInfo.setAccountId("");
signInfoHclc.setAgentAccountId("");
signInfoHclc.setAuthAgentAccountId("");
//重新设置经办人信息
signInfoHclc.setAgentIdNo(info.getAgentIdNo());
signInfoHclc.setAgentName(info.getAgentName());
signInfoHclc.setMobile(info.getMobile());
signInfoHclc.setAgentType(info.getAgentType());
signInfoHclc.setFaceAuthId(null);
}
}
//注销e签宝用户或者只创建e签宝账户
if (mapOrgan.size() == 0 || "0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
//创建e签宝账户
mapOrgan = iSignInfoHclcService.addPersonAccount(agentSignInfo);
//创建成功
if ("0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
signInfoHclc.setAgentAccountId(mapOrgan.get("accountId").toString());
if ("AGENT_ADD".equalsIgnoreCase(accountStatus)) {
//重新设置经办人信息
signInfoHclc.setAgentIdNo(info.getAgentIdNo());
signInfoHclc.setAgentName(info.getAgentName());
signInfoHclc.setMobile(info.getMobile());
signInfoHclc.setAgentType(info.getAgentType());
}
}
signInfoHclc.setCreateCode(mapOrgan.get("code").toString());
signInfoHclc.setCreateMessage(mapOrgan.get("message").toString());
}
}
if (mapOrgan.size() == 0 || "0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
//初始化接口密钥参数信息
SignHclcUtils signHclcUtils = new SignHclcUtils();
agentSignInfo = signHclcUtils.initProject(agentSignInfo, appId, secret, notifyUrl);
//获取鉴权Token
String tokenApiUrl = iSignInfoHclcService.getApiUrl(indivSysName, tokenApiName);
logger.debug("upload url: {}", tokenApiUrl);
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, agentSignInfo.getAppId(), agentSignInfo.getSecret());
//获取鉴权Token接口结果返回成功
if (Objects.nonNull(token)) {
agentSignInfo.setAccountId(signInfoHclc.getAgentAccountId());
//获取身份验证公有云账户id
if (signInfoHclc.getAuthAgentAccountId() == null || "".equalsIgnoreCase(signInfoHclc.getAuthAgentAccountId())) {
mapOrgan = iSignInfoHclcService.getByThirdId(agentSignInfo, token);
if ("0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
signInfoHclc.setAuthAgentAccountId(mapOrgan.get("authAccountId").toString());
}
}
if (signInfoHclc.getAuthAgentAccountId() == null || "".equalsIgnoreCase(signInfoHclc.getAuthAgentAccountId())) {
mapOrgan.put("code", "10");
mapOrgan.put("message", "获取验证公有云accountId失败,请检查!");
} else {
agentSignInfo.setAuthAccountId(signInfoHclc.getAuthAgentAccountId());
//设置经办人人脸验证成功跳转地址
agentSignInfo.setRedirectUrl(info.getRedirectUrl());
//获取个人核身认证地址
mapOrgan = iSignInfoHclcService.getFaceUrlHttp(iRequest, agentSignInfo, token);
//接口结果返回成功
if ("0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
signInfoHclc.setFaceAuthId(Long.valueOf(mapOrgan.get("faceAuthId").toString()));
}
}
}
//获取鉴权Token接口结果返回失败
else {
mapOrgan.put("code", "2");
mapOrgan.put("message", "获取鉴权Token失败,请检查!");
}
}
} else {
//查询e签宝机构打款核验状态
SignUserFaceHclc signInfoHclcOrg = new SignUserFaceHclc();
if (Objects.nonNull(signInfoHclc.getOrgAuthId())) {
signInfoHclcOrg.setAuthId(signInfoHclc.getOrgAuthId());
signInfoHclcOrg = signInfoHclcFaceService.selectByPrimaryKey(iRequest, signInfoHclcOrg);
}
//移动端用户信息发生变更,需要注销e签宝账户,重新创建,并获取企业核验url
if (!info.getIdNo().equalsIgnoreCase(signInfoHclc.getIdNo()) || !info.getName().equalsIgnoreCase(signInfoHclc.getName()) || !info.getLegalIdNo().equalsIgnoreCase(signInfoHclc.getLegalIdNo()) || !info.getLegalName().equalsIgnoreCase(signInfoHclc.getLegalName())) {
//判断人脸核身认证状态,核验完成直接结束任务
if (Objects.nonNull(signInfoHclcOrg)) {
if ("SUCCESS".equalsIgnoreCase(signInfoHclcOrg.getAuthStatus())) {
mapOrgan.put("code", "10");
mapOrgan.put("message", "企业对公打款认证已完成,无需重复验证!");
return mapOrgan;
} else if ("AUTHING".equalsIgnoreCase(signInfoHclcOrg.getAuthStatus())) {
mapOrgan.put("code", "11");
mapOrgan.put("message", "企业对公打款认证中,请耐心等待认证结果!");
return mapOrgan;
}
}
//e签宝账户不存在,需要新增
if (Objects.isNull(signInfoHclc.getAccountId())) {
accountStatus = "ORG_ADD";
}
//e签宝账户已存在,需要注销,重新创建e签宝账户
else {
accountStatus = "ORG_MODIFY";
}
}//移动端用户信息未发生变更
else {
//存在对应核验url信息
if (Objects.nonNull(signInfoHclcOrg.getAuthId())) {
//判断对公打款认证状态,核验完成直接结束任务
if ("SUCCESS".equalsIgnoreCase(signInfoHclcOrg.getAuthStatus())) {
mapOrgan.put("code", "10");
mapOrgan.put("message", "企业对公打款认证已完成,无需重复验证!");
return mapOrgan;
} else if ("FAIL".equalsIgnoreCase(signInfoHclcOrg.getAuthStatus())) {
accountStatus = "ORG_EXISTS";
} else {
//返回原核验url
mapOrgan.put("code", "0");
mapOrgan.put("url", signInfoHclcOrg.getUrl());
mapOrgan.put("message", "获取url成功!");
return mapOrgan;
}
}
//不存在对应核验完成url,重新获取url
else {
//e签宝账户不存在,需要新增企业账户
if (Objects.isNull(signInfoHclc.getAccountId())) {
accountStatus = "ORG_ADD";
}
//e签宝账户已存在,不需要新增,直接获取企业核验url
else {
accountStatus = "ORG_EXISTS";
}
}
}
if (!"ORG_EXISTS".equalsIgnoreCase(accountStatus)) {
//移动端用户信息发生变更,先注销e签宝用户
if ("ORG_MODIFY".equalsIgnoreCase(accountStatus)) {
mapOrgan = deleteOrgansAccount(iRequest, signInfoHclc);
//注销成功
if ("0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
signInfoHclc.setAccountId("");
signInfoHclc.setAuthAccountId("");
//重新设置机构用户信息
signInfoHclc.setIdNo(info.getIdNo());
signInfoHclc.setName(info.getName());
signInfoHclc.setLegalIdNo(info.getLegalIdNo());
signInfoHclc.setLegalName(info.getLegalName());
signInfoHclc.setOrgAuthId(null);
}
}
//创建e签宝账户
if (mapOrgan.size() == 0 || "0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
//初始化经办人人脸识别信息
SignUserInfoHclc ogrSignInfo = new SignUserInfoHclc();
ogrSignInfo.setAgentAccountId(signInfoHclc.getAgentAccountId());
ogrSignInfo.setAgentIdNo(signInfoHclc.getAgentIdNo());
ogrSignInfo.setLegalIdNo(info.getLegalIdNo());
ogrSignInfo.setLegalName(info.getLegalName());
ogrSignInfo.setIdNo(info.getIdNo());
ogrSignInfo.setName(info.getName());
ogrSignInfo.setOpenId(signInfoHclc.getOpenId());
mapOrgan = addOrgansAccount(ogrSignInfo);
//创建成功
if ("0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
signInfoHclc.setAccountId(mapOrgan.get("organizeId").toString());
if ("ORG_ADD".equalsIgnoreCase(accountStatus)) {
//重新设置机构用户信息
signInfoHclc.setIdNo(info.getIdNo());
signInfoHclc.setName(info.getName());
signInfoHclc.setLegalIdNo(info.getLegalIdNo());
signInfoHclc.setLegalName(info.getLegalName());
}
}
signInfoHclc.setCreateCode(mapOrgan.get("code").toString());
signInfoHclc.setCreateMessage(mapOrgan.get("message").toString());
}
}
//用户创建成功
if (mapOrgan.size() == 0 || "0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
//初始化接口密钥参数信息
SignHclcUtils signHclcUtils = new SignHclcUtils();
signInfoHclc = signHclcUtils.initProject(signInfoHclc, appId, secret, notifyUrl);
//获取鉴权Token
String tokenApiUrl = iSignInfoHclcService.getApiUrl(indivSysName, tokenApiName);
logger.debug("upload url: {}", tokenApiUrl);
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, signInfoHclc.getAppId(), signInfoHclc.getSecret());
if (Objects.nonNull(token)) {
//获取身份验证公有云账户id
if (signInfoHclc.getAuthAccountId() == null || "".equalsIgnoreCase(signInfoHclc.getAuthAccountId())) {
mapOrgan = getByThirdId(signInfoHclc, token);
if ("0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
signInfoHclc.setAuthAccountId(mapOrgan.get("authOrgAccountId").toString());
}
}
if (signInfoHclc.getAuthAccountId() == null || "".equalsIgnoreCase(signInfoHclc.getAuthAccountId())) {
mapOrgan.put("code", "10");
mapOrgan.put("message", "获取验证公有云accountId失败,请检查!");
} else {
signInfoHclc.setRedirectUrl(info.getRedirectUrl());
//获取组织机构核身地址
mapOrgan = this.getOrgAuthUrlHttp(iRequest, signInfoHclc, token);
if ("0".equalsIgnoreCase(mapOrgan.get("code").toString())) {
signInfoHclc.setOrgAuthId(Long.valueOf(mapOrgan.get("orgAuthId").toString()));
}
}
} else {
mapOrgan.put("code", "2");
mapOrgan.put("message", "获取鉴权Token失败,请检查!");
}
}
}
this.updateByPrimaryKey(iRequest, signInfoHclc);
return mapOrgan;
}
public Map<String, Object> getOrgAuthUrlHttp(IRequest iRequest, SignUserInfoHclc info, String token) {
//初始化人脸核验流程初始化数据
SignUserFaceHclc signInfoHclcFace = new SignUserFaceHclc();
signInfoHclcFace.setOpenId(info.getOpenId());
signInfoHclcFace.setAuthStatus("NEW");
signInfoHclcFace.setAuthType("2");
signInfoHclcFace = signInfoHclcFaceService.insertSelective(iRequest, signInfoHclcFace);
//业务方交互上下文信息
JSONObject json1 = new JSONObject();
json1.put("contextId", signInfoHclcFace.getAuthId());
json1.put("notifyUrl", info.getNotifyUrl());
json1.put("redirectUrl", info.getRedirectUrl());
//个人认证基本信息
JSONObject json2 = new JSONObject();
//组织机构名称
json2.put("name", info.getName());
//组织机构证件号
json2.put("certNo", info.getIdNo());
//组织机构证件类型-统一社会信用代码
json2.put("certType", "ORGANIZATION_USC_CODE");
//法定代表人证件号
json2.put("legalRepCertNo", info.getLegalIdNo());
//法定代表人证件类型-中国大陆身份证
json2.put("egalRepCertType", "INDIVIDUAL_CH_IDCARD");
//法定代表人姓名
json2.put("legalRepName", info.getLegalName());
//法定代表人地区/国籍
json2.put("legalRepNationality", "");
//经办人身份1 企业法定代表人;2 企业授权代理人
json2.put("operatorType", info.getAgentType());
//组织核验类型,“1”:三要素核验;“2”:四要素核验;不填为不指定核验类型
json2.put("verifyType", "2");
JSONObject result = new JSONObject();
result.put("agentAccountId", info.getAuthAgentAccountId());
result.put("authType", "ORG_BANK_TRANSFER");//组织机构对公账户打款认证
result.put("contextInfo", json1);
result.put("orgEntity", json2);
result.put("repeatIdentity", false);
JSONObject json = new JSONObject(result);
String param = json.toString();
//设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>();
headInfo.put("X-Tsign-Open-App-Id", info.getAppId());
headInfo.put("X-Tsign-Open-Token", token);
Map<String, Object> map = new HashMap<>();
try {
//初始化接口信息
String orgApiurl = iSignInfoHclcService.getApiUrl(indivSysName, orgApiName);
orgApiurl = orgApiurl.replace("{accountId}", info.getAuthAccountId());
logger.debug("upload url: {}", orgApiurl);
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
//发送http请求
String stringResult = signHclcUtils1.postString(orgApiurl, param, headInfo);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("code"))) {
JSONObject data = jsonResult.getJSONObject("data");
signInfoHclcFace.setFlowId(data.getString("flowId"));
signInfoHclcFace.setUrl(data.getString("url"));
signInfoHclcFace.setShortLink(data.getString("shortLink"));
signInfoHclcFace.setAuthStatus("AUTHING");
map.put("code", "0");
map.put("orgAuthId", signInfoHclcFace.getAuthId());
map.put("url", data.getString("url"));
map.put("message", "获取url成功!");
} else {
map.put("code", jsonResult.getString("code"));
map.put("message", "获取组织机构实名认证地址失败," + jsonResult.getString("message"));
}
signInfoHclcFace.setReturnCode(jsonResult.getString("code"));
signInfoHclcFace.setReturnMessage(jsonResult.getString("message"));
signInfoHclcFaceService.updateByPrimaryKey(iRequest, signInfoHclcFace);
} catch (Exception e) {
map.put("code", "17");
map.put("message", "访问e签宝组织机构实名认证地址失败," + e.getMessage());
signInfoHclcFace.setReturnCode("3");
signInfoHclcFace.setReturnMessage(e.getMessage());
signInfoHclcFaceService.updateByPrimaryKey(iRequest, signInfoHclcFace);
}
return map;
}
public Map<String, Object> addOrgansAccount(SignUserInfoHclc signInfoHclc) {
Map<String, Object> map = new HashMap<>();
//业务方交互上下文信息
JSONObject result = new JSONObject();
//默认经办人id agentUniqueId和agentUniqueId都不为空的情况,以accountId为准
result.put("agentAccountId", signInfoHclc.getAgentAccountId());
//默认经办人唯一标识
result.put("agentUniqueId", signInfoHclc.getOpenId());
//银行卡号
result.put("cardNo", "");
//当前机构联系邮箱
result.put("email", "");
//法定代表人证件号码
result.put("legalLicenseNumber", signInfoHclc.getLegalIdNo());
//法定代表人证件类型:IDCard-身份证号码,Passport-中国护照,HMPass-港澳居民来往内地通行证,MTP-台胞证,Other-其它
result.put("legalLicenseType", "IDCard");
//法定代表人手机号
result.put("legalMobile", "");
//法定代表人姓名
result.put("legalName", signInfoHclc.getLegalName());
//证照号码
result.put("licenseNumber", signInfoHclc.getIdNo());
//证照类型 :ORANO-机构代码证,SOCNO-社会信用代码,BUSNO-工商注册号
result.put("licenseType", "SOCNO");
//机构名称
result.put("organizeName", signInfoHclc.getName());
//机构唯一标识
result.put("organizeNo", signInfoHclc.getOpenId() + "-ORG");
JSONObject json = new JSONObject(result);
String param = json.toString();
//获取HMAC加密后的X-timevale-signature签名信息
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = algorithmHelper.getXtimevaleSignature(param, projectSecret, HASH_ALGORITHM, "UTF-8");
//设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>();
headInfo.put("x-timevale-project-id", projectId);
headInfo.put("x-timevale-signature", EncryptedString);
try {
//初始化接口信息
String url = iSignInfoHclcService.getApiUrl(signatureSysName, organsApiName);
logger.debug("create organs account url: {}", url);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("errCode"))) {
JSONObject data = jsonResult.getJSONObject("data");
map.put("organizeId", data.getString("organizeId"));
map.put("code", "0");
map.put("message", "机构e签宝账户创建成功!");
} else {
logger.error("create organs account failed, errCode:{} ,msg:{}", jsonResult.getString("errCode"), jsonResult.getString("msg"));
map.put("code", jsonResult.getString("errCode"));
map.put("message", "机构e签宝账户创建失败," + jsonResult.getString("msg"));
}
} catch (Exception e) {
logger.error("create organs account failed, msg:{}", e.getMessage());
map.put("code", "000015");
map.put("message", "机构e签宝账户创建失败," + e.getMessage());
}
return map;
}
public Map<String, Object> deleteOrgansAccount(IRequest iRequest, SignUserInfoHclc signInfoHclc) {
Map<String, Object> map = new HashMap<>();
signInfoHclc = iSignInfoHclcService.selectByPrimaryKey(iRequest, signInfoHclc);
if (Objects.isNull(signInfoHclc)) {
logger.debug("未找到对应e签宝机构用户信息,请检查!");
map.put("code", "000002");
map.put("message", "未找到对应e签宝机构用户信息,请检查!");
return map;
}
if (Objects.isNull(signInfoHclc.getAccountId()) || "".equalsIgnoreCase(signInfoHclc.getAccountId())) {
logger.debug("e签宝机构账户 accountId: {} 不存在,无需注销!", signInfoHclc.getAccountId());
map.put("code", "000012");
map.put("message", "e签宝机构账户不存在,无需注销!");
return map;
}
//业务方交互上下文信息
JSONObject result = new JSONObject();
//机构名称
result.put("organizeId", signInfoHclc.getAccountId());
//机构唯一标识
result.put("organizeNo", signInfoHclc.getOpenId() + "-ORG");
JSONObject json = new JSONObject(result);
String param = json.toString();
//获取HMAC加密后的X-timevale-signature签名信息
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = algorithmHelper.getXtimevaleSignature(param, projectSecret, HASH_ALGORITHM, "UTF-8");
//设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>();
headInfo.put("x-timevale-project-id", projectId);
headInfo.put("x-timevale-signature", EncryptedString);
try {
//初始化接口信息
String url = iSignInfoHclcService.getApiUrl(signatureSysName, deleteApiName);
logger.debug("upload url: {}", url);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("errCode")) || "40051667".equalsIgnoreCase(map.get("code").toString())) {
map.put("code", "0");
map.put("message", "e签宝机构用户注销成功!");
} else {
logger.error("delete organs account failed, errCode:{} ,msg:{}", jsonResult.getString("errCode"), jsonResult.getString("msg"));
map.put("code", jsonResult.getString("errCode"));
map.put("message", "e签宝机构用户注销失败," + jsonResult.getString("msg"));
}
} catch (Exception e) {
logger.error("delete organs account failed, msg:{}", e.getMessage());
map.put("code", "000013");
map.put("message", "e签宝机构用户注销失败," + e.getMessage());
}
return map;
}
/***
* 查询机构账户(按照第三方用户ID查询);
* @param info
* @param token
***/
public Map<String, Object> getByThirdId(SignUserInfoHclc info, String token) {
Map<String, Object> map = new HashMap<>();
//设置http请求head信息
JSONObject headInfo = new JSONObject();
headInfo.put("X-Tsign-Open-App-Id", info.getAppId());
headInfo.put("X-Tsign-Open-Token", token);
String param = "thirdPartyUserId=" + info.getIdNo();
try {
//初始化接口url信息
String orgApiurl = iSignInfoHclcService.getApiUrl(indivSysName, getOrgIdApiName) + "?" + param;
logger.debug("upload url: {}", orgApiurl);
//发送http请求
HttpResponse execute = HttpUtil.getJson(orgApiurl, headInfo);
int httpReponseCode;
String stringResult = null;
JSONObject responseBody = new JSONObject();
if (execute != null) {
httpReponseCode = execute.getStatusLine().getStatusCode();
if (httpReponseCode != HTTP_OK) {
responseBody.put("code", httpReponseCode);
responseBody.put("message", execute.getStatusLine().getReasonPhrase());
stringResult = responseBody.toString();
} else {
stringResult = HttpUtil.HttpResponseParseJson(execute);
}
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("code"))) {
JSONObject data = jsonResult.getJSONObject("data");
map.put("code", "0");
map.put("authOrgAccountId", data.getString("orgId"));
map.put("message", "获取身份认证账户成功!");
} else {
map.put("code", jsonResult.getString("code"));
map.put("message", "获取身份认证账户失败," + jsonResult.getString("message"));
}
} else {
map.put("code", "10");
map.put("message", "获取身份认证账户发送网络请求失败,请检查身份认证地址信息!");
}
} catch (Exception e) {
map.put("code", "9");
map.put("message", e.getMessage());
}
return map;
}
}
package com.hand.app.esignHclc.service.impl;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.hand.app.esignHclc.dto.SignFlowsInfoHclc;
import com.hand.app.esignHclc.service.ISignFlowsInfoHclcService;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(rollbackFor = Exception.class)
public class SignFlowsInfoHclcServiceImpl extends BaseServiceImpl<SignFlowsInfoHclc> implements ISignFlowsInfoHclcService{
}
\ No newline at end of file
package com.hand.app.esignHclc.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.hand.app.esignHclc.dto.SignUserFaceHclc;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Service
public class SignInfoHclcFaceServiceImpl extends BaseServiceImpl<SignUserFaceHclc> implements ISignInfoHclcFaceService {
private final Object lock = new Object();
@Autowired
private ISignInfoHclcService iSignInfoHclcService;
public void postAuthResult(IRequest iRequest, JSONObject params) {
synchronized (lock) {
if (Objects.isNull(params.get("contextId"))) {
return;
}
SignUserFaceHclc signInfoHclcFace = new SignUserFaceHclc();
signInfoHclcFace.setAuthId(Long.valueOf(params.get("contextId").toString()));
signInfoHclcFace = this.selectByPrimaryKey(iRequest, signInfoHclcFace);
//判断认证识别流程是否存在
if (Objects.nonNull(signInfoHclcFace) && !"SUCCESS".equalsIgnoreCase(signInfoHclcFace.getAuthStatus())) {
//判断认证返回结果成功
if ("true".equalsIgnoreCase(params.get("success").toString())) {
//更新认证明细表状态
signInfoHclcFace.setAuthStatus("SUCCESS");
signInfoHclcFace.setVerifyCode(params.get("verifycode").toString());
SignUserInfoHclc signInfoHclc = new SignUserInfoHclc();
signInfoHclc.setOpenId(signInfoHclcFace.getOpenId());
signInfoHclc = iSignInfoHclcService.selectByPrimaryKey(iRequest, signInfoHclc);
//更新用户认证状态为Y
if (signInfoHclc.getCtitype().compareTo(1L) == 0 || (signInfoHclc.getCtitype().compareTo(2L) == 0 && "2".equalsIgnoreCase(signInfoHclcFace.getAuthType()))) {
signInfoHclc.setAuthFlag("Y");
iSignInfoHclcService.updateByPrimaryKeySelective(iRequest, signInfoHclc);
}
} else {
//更新认证明细表状态
signInfoHclcFace.setAuthStatus("FAIL");
signInfoHclcFace.setVerifyCode(params.get("verifycode").toString());
}
this.updateByPrimaryKey(iRequest, signInfoHclcFace);
}
}
}
}
package com.hand.app.esignHclc.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esign.service.ISignInfoService;
import com.hand.app.esign.utils.AlgorithmHelper;
import com.hand.app.esignHclc.dto.SignFlowsInfoHclc;
import com.hand.app.esignHclc.dto.SignUserAttachInfo;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.hand.app.esignHclc.dto.SignUserFaceHclc;
import com.hand.app.esignHclc.mapper.SignInfoHclcMapper;
import com.hand.app.esignHclc.service.ISignFlowsInfoHclcService;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.app.esignHclc.service.ISignUserAttachInfoService;
import com.hand.app.esignHclc.utils.SignHclcUtils;
import com.hand.hap.core.IRequest;
import com.hand.hap.intergration.dto.HapInterfaceHeader;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.intergration.utils.HttpUtil;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import hls.support.core.wechat.formbean.AttachmentInfo;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.CharsetUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Service
public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> implements ISignInfoHclcService {
@Value("${tsign.project.id}")
private String projectId;
@Value("${tsign.project.secret}")
private String projectSecret;
@Value("${tsign.api.notifyUrl}")
private String notifyUrl;
@Value("${tsign.face.api.appId}")
private String appId;
@Value("${tsign.face.api.secret}")
private String secret;
@Value("${wx.apiKey}")
private String apiKey;
@Value("${wx.image.path}")
private String imagePath;
private CloseableHttpClient httpClient;
public static final String RESULT_ERROR = "-1";
//用户认证接口信息
public static final String indivSysName = "HCLC_FACE_API";
public static final String tokenApiName = "getToken";
public static final String indivApiName = "indivAuthUrl";
public static final String getAccIdApiName = "getAccByThirdId";
//公众号接口信息
public static final String wxSysName = "wxgzh_hitachics";
public static final String wxDownLoadApiName = "media_download";
//业务系统接口信息
public static final String hclcSysName = "HCL_UPLOAD_FILE";
public static final String hclcUpLoadApiName = "upload";
public static final String hclcDownloadApiName = "download";
//电子签章接口信息
public static final String signatureSysName = "HCLC_ELECTRONIC_SIGNATURE";
public static final String accountsApiName = "outerAccounts";
public static final String deleteApiName = "accountsDelete";
public static final String signatureUpLoadApiName = "fileUpload";
public static final String signFlowsApiName = "signFlows";
public static final String getUrlsApiName = "getSignFlowDocUrls";
private static final String HASH_ALGORITHM = "HmacSHA256";
private final static int HTTP_OK = 200;
@Autowired
IHapInterfaceHeaderService headerService;
@Autowired
private ISignInfoHclcFaceService signInfoHclcFaceService;
@Autowired
private SignInfoHclcMapper signInfoHclcMapper;
@Autowired
private ISignFlowsInfoHclcService iSignFlowsInfoHclcService;
@Autowired
private ISignUserAttachInfoService iSignUserAttachInfoService;
private Logger logger = LoggerFactory.getLogger(getClass());
public SignInfoHclcServiceImpl() {
// ensure e-sign SDK will be init only once
RequestConfig config = RequestConfig.custom().setConnectTimeout(60 * 1000).setSocketTimeout(15000).build();
httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
}
public Map<String, Object> getIndividualFaceUrl(IRequest iRequest, SignUserInfoHclc info) {
Map<String, Object> map = new HashMap<>();
if (Objects.isNull(info.getOpenId())) {
logger.error("关键参数openId不存在,调用失败!");
map.put("code", "000001");
map.put("message", "关键参数openId不存在,调用失败!");
return map;
}
//查询用户信息
SignUserInfoHclc signInfoHclc = mapper.selectByPrimaryKey(info);
//初始化创建用户判断
String accountStatus = null;
//判断用户信息是否存在,当新增用户时需要创建e签宝账户
if (Objects.isNull(signInfoHclc)) {
info.setCtitype(1L);
info.setAuthFlag("N");
signInfoHclc = this.insertSelective(iRequest, info);
accountStatus = "ADD";
} else {
if ("Y".equalsIgnoreCase(signInfoHclc.getAuthFlag())) {
map.put("code", "000002");
map.put("message", "人脸核身认证已完成,无需重复验证!");
return map;
}
//移动端用户信息发生变更,需要注销e签宝账户,重新创建,并获取人脸核验url
if (!info.getIdNo().equalsIgnoreCase(signInfoHclc.getIdNo()) || !info.getName().equalsIgnoreCase(signInfoHclc.getName()) || !info.getMobile().equalsIgnoreCase(signInfoHclc.getMobile())) {
//e签宝账户不存在,需要新增
if (Objects.isNull(signInfoHclc.getAccountId())) {
accountStatus = "ADD";
}
//e签宝账户已存在,注销e签宝账户,重新新增,获取人脸核验url
else {
accountStatus = "MODIFY";
}
}
//移动端用户信息未发生变更
else {
SignUserFaceHclc signInfoHclcFace = new SignUserFaceHclc();
//存在对应核验url信息
if (Objects.nonNull(signInfoHclc.getFaceAuthId())) {
//查询e签宝人脸核验信息
signInfoHclcFace.setAuthId(signInfoHclc.getFaceAuthId());
signInfoHclcFace = signInfoHclcFaceService.selectByPrimaryKey(iRequest, signInfoHclcFace);
//判断人脸核身认证状态,核验完成直接结束任务
if ("SUCCESS".equalsIgnoreCase(signInfoHclcFace.getAuthStatus())) {
map.put("code", "000002");
map.put("message", "人脸核身认证已完成,无需重复验证!");
return map;
} else if ("FAIL".equalsIgnoreCase(signInfoHclcFace.getAuthStatus())) {
accountStatus = "EXISTS";
} else {
//返回原核验url
map.put("code", "0");
map.put("url", signInfoHclcFace.getUrl());
map.put("message", "获取url成功!");
return map;
}
}
//不存在对应核验完成url,重新获取url
else {
//e签宝账户不存在,需要新增
if (Objects.isNull(signInfoHclc.getAccountId())) {
accountStatus = "ADD";
}
//e签宝账户已存在,不需要新增,直接获取人脸核验url
else {
accountStatus = "EXISTS";
}
}
}
}
if (!"EXISTS".equalsIgnoreCase(accountStatus)) {
//移动端用户信息发生变更,先注销e签宝用户
if ("MODIFY".equalsIgnoreCase(accountStatus)) {
map = deletePersonAccount(iRequest, signInfoHclc);
//注销成功
if ("0".equalsIgnoreCase(map.get("code").toString()) || "40051667".equalsIgnoreCase(map.get("code").toString())) {
signInfoHclc.setAccountId("");
signInfoHclc.setAuthAccountId("");
//重新设置个人用户信息
signInfoHclc.setIdNo(info.getIdNo());
signInfoHclc.setName(info.getName());
signInfoHclc.setMobile(info.getMobile());
signInfoHclc.setFaceAuthId(null);
}
}
//创建e签宝账户
if (map.size() == 0 || "0".equalsIgnoreCase(map.get("code").toString()) || "40051667".equalsIgnoreCase(map.get("code").toString())) {
map = addPersonAccount(signInfoHclc);
//创建成功
if ("0".equalsIgnoreCase(map.get("code").toString())) {
signInfoHclc.setAccountId(map.get("accountId").toString());
if ("ADD".equalsIgnoreCase(accountStatus)) {
//重新设置个人用户信息
signInfoHclc.setIdNo(info.getIdNo());
signInfoHclc.setName(info.getName());
signInfoHclc.setMobile(info.getMobile());
}
}
signInfoHclc.setCreateCode(map.get("code").toString());
signInfoHclc.setCreateMessage(map.get("message").toString());
}
}
//用户创建成功
if (map.size() == 0 || "0".equalsIgnoreCase(map.get("code").toString())) {
//初始化接口密钥参数信息
SignHclcUtils signHclcUtils = new SignHclcUtils();
signInfoHclc = signHclcUtils.initProject(signInfoHclc, appId, secret, notifyUrl);
//获取鉴权Token
String tokenApiUrl = getApiUrl(indivSysName, tokenApiName);
logger.debug("token url: {}", tokenApiUrl);
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, signInfoHclc.getAppId(), signInfoHclc.getSecret());
if (Objects.nonNull(token)) {
//获取身份验证公有云账户id
if (signInfoHclc.getAuthAccountId() == null || "".equalsIgnoreCase(signInfoHclc.getAuthAccountId())) {
map = getByThirdId(signInfoHclc, token);
if ("0".equalsIgnoreCase(map.get("code").toString())) {
signInfoHclc.setAuthAccountId(map.get("authAccountId").toString());
}
}
if (signInfoHclc.getAuthAccountId() == null || "".equalsIgnoreCase(signInfoHclc.getAuthAccountId())) {
map.put("code", "000010");
map.put("message", "获取验证公有云accountId失败,请检查!");
} else {
signInfoHclc.setRedirectUrl(info.getRedirectUrl());
//获取个人核身认证地址
map = getFaceUrlHttp(iRequest, signInfoHclc, token);
if ("0".equalsIgnoreCase(map.get("code").toString())) {
signInfoHclc.setFaceAuthId(Long.valueOf(map.get("faceAuthId").toString()));
}
}
} else {
map.put("code", "000007");
map.put("message", "获取鉴权Token失败,请检查!");
}
}
this.updateByPrimaryKey(iRequest, signInfoHclc);
return map;
}
/***
* 获取中台接口定义url;
* @param sysName
* @param apiName
***/
public String getApiUrl(String sysName, String apiName) {
//初始化接口密钥参数信息
HapInterfaceHeader headerAndLineDTO = headerService.getHeaderAndLine(sysName, apiName);
if (headerAndLineDTO == null) {
logger.debug("headerAndLineDTO is null, apiName:{}, sysName:{}", apiName, sysName);
return null;
}
return headerAndLineDTO.getDomainUrl() + headerAndLineDTO.getIftUrl();
}
/***
* 获取人脸识别url;
* @param iRequest
* @param info
* @param token
***/
public Map<String, Object> getFaceUrlHttp(IRequest iRequest, SignUserInfoHclc info, String token) {
Map<String, Object> map = new HashMap<>();
//初始化人脸核验流程初始化数据
SignUserFaceHclc signInfoHclcFace = new SignUserFaceHclc();
signInfoHclcFace.setOpenId(info.getOpenId());
signInfoHclcFace.setAuthStatus("NEW");
signInfoHclcFace.setAuthType("1");
signInfoHclcFace = signInfoHclcFaceService.insertSelective(iRequest, signInfoHclcFace);
//业务方交互上下文信息
JSONObject json1 = new JSONObject();
//传入上下文id用于接口回传更新
json1.put("contextId", signInfoHclcFace.getAuthId());
json1.put("notifyUrl", info.getNotifyUrl());
json1.put("redirectUrl", info.getRedirectUrl());
//个人认证基本信息
JSONObject json2 = new JSONObject();
json2.put("name", info.getName());
json2.put("certType", "INDIVIDUAL_CH_IDCARD");
json2.put("certNo", info.getIdNo());
json2.put("mobileNo", info.getMobile());
//认证配置信息
JSONObject json3 = new JSONObject();
String[] str = new String[]{"name", "certNo", "mobileNo", "bankCardNo"};
json3.put("indivUneditableInfo", str);
JSONObject result = new JSONObject();
//个人刷脸认证
result.put("authType", "PSN_FACEAUTH_BYURL");
result.put("contextInfo", json1);
result.put("indivInfo", json2);
result.put("configParams", json3);
result.put("repeatIdentity", true);
JSONObject json = new JSONObject(result);
String param = json.toString();
//设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>();
headInfo.put("X-Tsign-Open-App-Id", info.getAppId());
headInfo.put("X-Tsign-Open-Token", token);
try {
//初始化接口url信息
String faceApiurl = getApiUrl(indivSysName, indivApiName).replace("{accountId}", info.getAuthAccountId());
logger.debug("upload url: {}", faceApiurl);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(faceApiurl, param, headInfo);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("code"))) {
JSONObject data = jsonResult.getJSONObject("data");
signInfoHclcFace.setFlowId(data.getString("flowId") == null ? "" : data.getString("flowId"));
signInfoHclcFace.setUrl(data.getString("url") == null ? "" : data.getString("url"));
signInfoHclcFace.setShortLink(data.getString("shortLink") == null ? "" : data.getString("shortLink"));
signInfoHclcFace.setAuthStatus("AUTHING");
map.put("code", "0");
map.put("faceAuthId", signInfoHclcFace.getAuthId());
map.put("url", data.getString("url"));
map.put("message", "获取url成功!");
} else {
map.put("code", "8");
map.put("message", "获取人脸核身认证url失败," + jsonResult.getString("message"));
}
signInfoHclcFace.setReturnCode(jsonResult.getString("code"));
signInfoHclcFace.setReturnMessage(jsonResult.getString("message"));
} catch (Exception e) {
map.put("code", "9");
map.put("message", "访问e签宝人脸核身地址失败,请检查!");
signInfoHclcFace.setReturnCode("3");
signInfoHclcFace.setReturnMessage(e.getMessage());
}
signInfoHclcFaceService.updateByPrimaryKey(iRequest, signInfoHclcFace);
return map;
}
/***
* 查询个人账户(按照第三方用户ID查询);
* @param info
* @param token
***/
public Map<String, Object> getByThirdId(SignUserInfoHclc info, String token) {
Map<String, Object> map = new HashMap<>();
//设置http请求head信息
JSONObject headInfo = new JSONObject();
headInfo.put("X-Tsign-Open-App-Id", info.getAppId());
headInfo.put("X-Tsign-Open-Token", token);
String param = "thirdPartyUserId=" + info.getAccountId();
try {
//初始化接口url信息
String faceApiurl = getApiUrl(indivSysName, getAccIdApiName) + "?" + param;
logger.debug("get face api url: {}", faceApiurl);
//发送http请求
HttpResponse execute = HttpUtil.getJson(faceApiurl, headInfo);
int httpReponseCode;
String stringResult = null;
JSONObject responseBody = new JSONObject();
if (execute != null) {
httpReponseCode = execute.getStatusLine().getStatusCode();
if (httpReponseCode != HTTP_OK) {
responseBody.put("code", httpReponseCode);
responseBody.put("message", execute.getStatusLine().getReasonPhrase());
stringResult = responseBody.toString();
} else {
stringResult = HttpUtil.HttpResponseParseJson(execute);
}
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("code"))) {
JSONObject data = jsonResult.getJSONObject("data");
map.put("code", "0");
map.put("authAccountId", data.getString("accountId"));
map.put("message", "获取个人云账户成功!");
} else {
map.put("code", "8");
map.put("message", "获取个人云账户失败," + jsonResult.getString("message"));
}
} else {
map.put("code", "10");
map.put("message", "获取个人云账户发送网络请求失败,请检查个人云地址信息!");
}
} catch (Exception e) {
map.put("code", "9");
map.put("message", e.getMessage());
}
return map;
}
// public JSONObject uploadHlsFromWx(IRequest iRequest, AttachmentInfo attachmentInfo) {
//
//
// JSONObject json = null;
// if (Objects.isNull(attachmentInfo.getMediaId())) {
// logger.error("upload attachment failed, attachmentInfo:{} 关键参数mediaId不存在,调用失败!", JSON.toJSONString(attachmentInfo));
// json.put("code", "3");
// json.put("message", "关键参数mediaId不存在,调用失败");
// return json;
// }
//
// //更新用户信息表mediaId信息
// SignInfoHclc signInfoHclc = new SignInfoHclc();
// signInfoHclc.setOpenId(attachmentInfo.getOpenId());
// signInfoHclc.setMediaId(attachmentInfo.getMediaId());
// signInfoHclc = updateByPrimaryKeySelective(iRequest, signInfoHclc);
//
// try {
//
// //下载微信服务器媒体文件
// //设置文件目录
// String tomcatPath = imagePath;
// AttachmentInfo downloadInfo = new AttachmentInfo();
// downloadInfo.setUploadSysName(wxSysName);
// downloadInfo.setUploadApiName(wxDownLoadApiName);
// downloadInfo.setMediaId(attachmentInfo.getMediaId());
// tomcatPath = downloadFileFromWx(downloadInfo, tomcatPath);
//
// //判断文件下载成功
// if (!tomcatPath.equalsIgnoreCase("-1")) {
// //身份证ocr认证
// SignHclcUtils signHclcUtils = new SignHclcUtils();
// json = signHclcUtils.idcard(tomcatPath);
// json.put("code", "0");
//
// //上传微信服务器媒体文件到社内服务器
// attachmentInfo.setUserId("admin");
// attachmentInfo.setUploadSysName(hclcSysName);
// attachmentInfo.setUploadApiName(hclcUpLoadApiName);
// attachmentInfo.setPkValue(attachmentInfo.getOpenId());
// String attchmentId = uploadFileToHclc(tomcatPath, attachmentInfo);
//
// //判断文件下载是否成功
// if (Objects.nonNull(attchmentId)) {
// //设置用户信息表附件信息
// signInfoHclc.setAttachmentId(attchmentId);
// updateByPrimaryKeySelective(iRequest, signInfoHclc);
// }
//
// json.put("attchmentId", attchmentId);
// } else {
// json.put("code", "1");
// json.put("message", "获取服务器图片失败,OCR识别失败");
// }
//
// return json;
//
// } catch (Exception e) {
// logger.error("upload attachment failed, attachmentInfo:{}", JSON.toJSONString(attachmentInfo), e);
// json.put("code", "2");
// json.put("message", e.getMessage());
// return json;
// }
//
// }
/***
* 下载微信图片资源上传至业务系统;
* @param iRequest
* @param attachmentInfo
***/
public JSONObject uploadHlsFromWx(IRequest iRequest, AttachmentInfo attachmentInfo) {
JSONObject json = new JSONObject();
if (Objects.isNull(attachmentInfo.getMediaId())) {
logger.error("upload attachment failed, attachmentInfo:{} 关键参数mediaId不存在,调用失败!", JSON.toJSONString(attachmentInfo));
json.put("code", "000003");
json.put("message", "关键参数mediaId不存在,调用失败");
return json;
}
//更新用户信息表mediaId信息
SignUserAttachInfo signUserAttachInfo = new SignUserAttachInfo();
signUserAttachInfo.setOpenId(attachmentInfo.getOpenId());
signUserAttachInfo.setAttachmentType(attachmentInfo.getSourceType());
List<SignUserAttachInfo> signUserAttachInfos = new ArrayList<>();
signUserAttachInfos = iSignUserAttachInfoService.select(iRequest, signUserAttachInfo, 1, 1);
if (signUserAttachInfos.size() > 0) {
signUserAttachInfo = signUserAttachInfos.get(0);
} else {
signUserAttachInfo = iSignUserAttachInfoService.insertSelective(iRequest, signUserAttachInfo);
}
signUserAttachInfo.setMediaId(attachmentInfo.getMediaId());
try {
byte[] bytes;
//下载微信服务器媒体文件
//设置文件目录
AttachmentInfo downloadInfo = new AttachmentInfo();
downloadInfo.setUploadSysName(wxSysName);
downloadInfo.setUploadApiName(wxDownLoadApiName);
downloadInfo.setMediaId(attachmentInfo.getMediaId());
InputStream inputStream = downloadFileFromWx(downloadInfo);
bytes = IOUtils.toByteArray(inputStream);
//判断文件下载成功
if (!ArrayUtils.isEmpty(bytes)) {
//身份证ocr认证
SignHclcUtils signHclcUtils = new SignHclcUtils();
if ("app_file_id_card".equalsIgnoreCase(attachmentInfo.getSourceType())) {
json = signHclcUtils.idcard(bytes);
} else {
//营业执照
json = signHclcUtils.businessLicense(bytes);
}
json.put("code", "0");
//上传微信服务器媒体文件到社内服务器
attachmentInfo.setUserId("admin");
attachmentInfo.setUploadSysName(hclcSysName);
attachmentInfo.setUploadApiName(hclcUpLoadApiName);
attachmentInfo.setPkValue(attachmentInfo.getOpenId());
String attchmentId = uploadFileToHclc(bytes, attachmentInfo);
//判断文件下载是否成功
if (Objects.nonNull(attchmentId)) {
//设置用户信息表附件信息--身份证
signUserAttachInfo.setAttachmentIdHclc(Long.valueOf(attchmentId));
iSignUserAttachInfoService.updateByPrimaryKey(iRequest, signUserAttachInfo);
json.put("attchmentId", attchmentId);
} else {
json.put("code", "000005");
json.put("message", "上传业务系统图片失败,OCR识别失败");
}
} else {
json.put("code", "000001");
json.put("message", "下载服务器图片失败,OCR识别失败");
}
return json;
} catch (Exception e) {
logger.error("upload attachment failed, attachmentInfo:{}", JSON.toJSONString(attachmentInfo), e);
json.put("code", "000002");
json.put("message", e.getMessage());
return json;
}
}
// public String downloadFileFromWx(AttachmentInfo info, String filePath) throws IOException {
// //设置接口参数
// JSONObject parameters = new JSONObject();
// parameters.put("apiKey", apiKey);
// parameters.put("mediaId", info.getMediaId());
//
// //初始化接口信息
// String url = getApiUrl(info.getUploadSysName(), info.getUploadApiName());
// logger.debug("upload url: {}", url);
//
// //发起http请求下载文件
// HttpPost httpPost = new HttpPost(url);
// httpPost.addHeader(HTTP.CONTENT_TYPE, "application/json");
// httpPost.setHeader("Accept", "application/json");
// StringEntity se = new StringEntity(parameters.toString(), "utf-8");
// se.setContentType("text/json");
// httpPost.setEntity(se);
//
// try {
// //获取微信服务器媒体文件
// CloseableHttpResponse response = httpClient.execute(httpPost);
// InputStream inputStream = response.getEntity().getContent();
//
// File file = new File(filePath);
// if (!file.exists()) {
// file.mkdirs();
// }
// filePath += File.separator + info.getFileName();
// OutputStream outputStream = new FileOutputStream(filePath);
// int len = -1;
// byte[] bytes = new byte[1024];
// while ((len = inputStream.read(bytes)) != -1) {
// outputStream.write(bytes, 0, len);//写入
// }
// outputStream.flush();
// outputStream.close();
// inputStream.close();
//
// return filePath;
// } catch (IOException e) {
// logger.error("获取服务器图片失败,msg:{}", e.getMessage());
// e.printStackTrace();
// return "-1";
// }
// }
/***
* 下载微信图片;
* @param info
***/
public InputStream downloadFileFromWx(AttachmentInfo info) throws IOException {
//设置接口参数
JSONObject parameters = new JSONObject();
parameters.put("apiKey", apiKey);
parameters.put("mediaId", info.getMediaId());
//初始化接口信息
String url = getApiUrl(info.getUploadSysName(), info.getUploadApiName());
logger.debug("upload url: {}", url);
//发起http请求下载文件
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader(HTTP.CONTENT_TYPE, "application/json");
httpPost.setHeader("Accept", "application/json");
StringEntity se = new StringEntity(parameters.toString(), "utf-8");
se.setContentType("text/json");
httpPost.setEntity(se);
//获取微信服务器媒体文件
CloseableHttpResponse response = httpClient.execute(httpPost);
InputStream inputStream = response.getEntity().getContent();
return inputStream;
}
// public String uploadFileToHclc(String filePath, AttachmentInfo info) {
// //todo upload file
// logger.debug("params,filePath:{}, attachmentInfo:{}", filePath, JSON.toJSONString(info));
// if (filePath == null || info == null || StringUtils.isBlank(info.getPkValue()) || StringUtils.isBlank(info.getSourceType())) {
// return null;
// }
//
// String url = getApiUrl(info.getUploadSysName(), info.getUploadApiName());
// logger.debug("upload url: {}", url);
// HttpPost httpPost = new HttpPost(url);
//
// //prepare params
// StringBody pkValue = new StringBody(info.getPkValue(), ContentType.MULTIPART_FORM_DATA);
// StringBody userId = new StringBody(info.getUserId(), ContentType.MULTIPART_FORM_DATA);
// StringBody sourceType = new StringBody(info.getSourceType(), ContentType.MULTIPART_FORM_DATA);
//
// ContentType pdfType = ContentType.create("image/jpeg", Consts.UTF_8);
//
// try {
// File file = new File(filePath);
//
// HttpEntity entity = MultipartEntityBuilder.create()
// .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
// .addPart("pkvalue", pkValue)
// .addPart("user_id", userId)
// .addPart("source_type", sourceType)
// .addBinaryBody("file", file, pdfType, info.getFileName())
// .setCharset(CharsetUtils.get("utf-8"))
// .build();
// httpPost.setEntity(entity);
// CloseableHttpResponse response = httpClient.execute(httpPost);
// InputStream content = response.getEntity().getContent();
// String result = IOUtils.toString(content);
// if (StringUtils.equals(RESULT_ERROR, result)) {
// return null;
// }
// return result;
// } catch (IOException e) {
// logger.error("upload attachment failed, attachmentInfo:{}", JSON.toJSONString(info), e);
// }
// return null;
// }
/***
* 上传微信图片至业务系统;
* @param bytes
* @param info
***/
public String uploadFileToHclc(byte[] bytes, AttachmentInfo info) {
//todo upload file
logger.debug("params,bytes:{}, attachmentInfo:{}", bytes, JSON.toJSONString(info));
if (ArrayUtils.isEmpty(bytes) || info == null || StringUtils.isBlank(info.getPkValue()) || StringUtils.isBlank(info.getSourceType())) {
return null;
}
String url = getApiUrl(info.getUploadSysName(), info.getUploadApiName());
logger.debug("upload url: {}", url);
HttpPost httpPost = new HttpPost(url);
//prepare params
StringBody pkValue = new StringBody(info.getPkValue(), ContentType.MULTIPART_FORM_DATA);
StringBody userId = new StringBody(info.getUserId(), ContentType.MULTIPART_FORM_DATA);
StringBody sourceType = new StringBody(info.getSourceType(), ContentType.MULTIPART_FORM_DATA);
ContentType pdfType = ContentType.create("image/jpeg", Consts.UTF_8);
try {
HttpEntity entity = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.addPart("pkvalue", pkValue)
.addPart("user_id", userId)
.addPart("source_type", sourceType)
.addBinaryBody("file", bytes, pdfType, info.getFileName())
.setCharset(CharsetUtils.get("utf-8"))
.build();
httpPost.setEntity(entity);
CloseableHttpResponse response = httpClient.execute(httpPost);
InputStream content = response.getEntity().getContent();
String result = IOUtils.toString(content);
if (StringUtils.equals(RESULT_ERROR, result)) {
return null;
}
return result;
} catch (IOException e) {
logger.error("upload attachment failed, attachmentInfo:{}", JSON.toJSONString(info), e);
}
return null;
}
/**
* e签宝文件直传
*
* @param iRequest
* @param dto 附件信息
* @return
*/
public Map<String, Object> signFileUpload(IRequest iRequest, AttachmentInfo dto) {
Map<String, Object> map = new HashMap<>();
if (Objects.isNull(dto.getAttachmentId())) {
logger.error("关键参数AttachmentId不存在,调用失败!");
map.put("success", "false");
map.put("message", "关键参数AttachmentId不存在,调用失败!");
return map;
}
String downloadUrl = getApiUrl(hclcSysName, hclcDownloadApiName);
byte[] bytes;
bytes = downloadFileFromHclc(dto.getAttachmentId(), downloadUrl);
//判断文件下载成功
if (!ArrayUtils.isEmpty(bytes)) {
String uploadUrl = getApiUrl(signatureSysName, signatureUpLoadApiName);
String fileKey = fileUpload(bytes, uploadUrl, dto.getFileName());
if (fileKey == null) {
map.put("success", "true");
map.put("message", "上传e签宝文件失败请检查e签宝服务器!");
} else {
map.put("success", "true");
map.put("fileKey", fileKey);
map.put("message", "上传成功");
}
} else {
logger.error("业务系统文件下载失败请检查文件下载路径!");
map.put("success", "false");
map.put("message", "业务系统文件下载失败请检查文件下载路径!");
}
return map;
}
/**
* hclc的文件下载
*
* @param attachmentId
* @param downloadUrl
*/
public byte[] downloadFileFromHclc(String attachmentId, String downloadUrl) {
String url = downloadUrl;
try {
url = url + (url.indexOf("?") > 0 ? "&attachment_id=" : "?attachment_id=") + attachmentId;
HttpGet httpGet = new HttpGet(url);
CloseableHttpResponse response = httpClient.execute(httpGet);
if (HttpStatus.SC_OK != response.getStatusLine().getStatusCode()) {
logger.error("request target attachment({}) failed,sysName:{}, apiName:{}", attachmentId, hclcSysName, hclcDownloadApiName);
return null;
}
InputStream content = response.getEntity().getContent();
return IOUtils.toByteArray(content);
} catch (Exception e) {
logger.error("request target attachment({}) failed,sysName:{}, apiName:{}", attachmentId, hclcSysName, hclcDownloadApiName);
return null;
}
}
/**
* e签宝文件直传
*
* @param bytes 文件输入流
* @param uploadUrl 接口地址
* @param fileName 文件名
* @return
*/
private String fileUpload(byte[] bytes, String uploadUrl, String fileName) {
String res = "";
//初始化接口url信息
logger.debug("upload url: {}", uploadUrl);
try {
HttpPost httpPost = new HttpPost(uploadUrl);
//获取HMAC加密后的X-timevale-signature签名信息
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = algorithmHelper.getXtimevaleSignature("", projectSecret, HASH_ALGORITHM, "UTF-8");
//设置http请求head信息
httpPost.addHeader("x-timevale-project-id", projectId);
httpPost.addHeader("x-timevale-signature", EncryptedString);
HttpEntity entity = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.addBinaryBody("file", bytes, ContentType.MULTIPART_FORM_DATA, fileName)
.setCharset(CharsetUtils.get("utf-8"))
.build();
httpPost.setEntity(entity);
CloseableHttpResponse response = httpClient.execute(httpPost);
InputStream content = response.getEntity().getContent();
res = IOUtils.toString(content);
if (StringUtils.equals(RESULT_ERROR, res)) {
return null;
}
String fileKey = null;
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(res);
if (!"".equalsIgnoreCase(jsonResult.getString("data")) && jsonResult.getString("data") != null) {
fileKey = jsonResult.getJSONObject("data").getString("fileKey");
}
return fileKey;
} catch (Exception e) {
this.logger.info("文件上传,发送POST请求出错==>" + uploadUrl);
this.logger.info("文件上传,异常信息==>" + e.getMessage());
return null;
}
}
public Map<String, Object> addPersonAccount(SignUserInfoHclc signInfoHclc) {
Map<String, Object> map = new HashMap<>();
//业务方交互上下文信息
JSONObject result = new JSONObject();
//银行卡号
result.put("cardNo", "");
//联系人邮箱
result.put("contactsEmail", "");
//联系人手机号
result.put("contactsMobile", signInfoHclc.getMobile());
//证件号码
result.put("licenseNumber", signInfoHclc.getIdNo());
//证件类型,个人证件类型(Other-其他,IDCard-身份证 号码,Passport-中国护照,HMPass-港澳居民来往内地通行证,MTP-台胞证)
result.put("licenseType", "IDCard");
//登录手机号/登录邮箱必填其一
//登录邮箱
result.put("loginEmail", "");
//登录手机号/
result.put("loginMobile", signInfoHclc.getMobile());
//用户名称
result.put("name", signInfoHclc.getName());
//用户的唯一标识可以为客户业务系统内唯一标识
result.put("uniqueId", signInfoHclc.getOpenId());
JSONObject json = new JSONObject(result);
String param = json.toString();
//获取HMAC加密后的X-timevale-signature签名信息
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = algorithmHelper.getXtimevaleSignature(param, projectSecret, HASH_ALGORITHM, "UTF-8");
//设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>();
headInfo.put("x-timevale-project-id", projectId);
headInfo.put("x-timevale-signature", EncryptedString);
try {
//初始化接口信息
String url = getApiUrl(signatureSysName, accountsApiName);
logger.debug("add person account url: {}", url);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("errCode"))) {
JSONObject data = jsonResult.getJSONObject("data");
//设置返回accountId
map.put("accountId", data.getString("accountId"));
map.put("code", "0");
map.put("message", "个人e签宝账户创建成功!");
} else {
logger.error("create person account failed, errCode:{} ,msg:{}", jsonResult.getString("errCode"), jsonResult.getString("msg"));
map.put("code", jsonResult.getString("errCode"));
map.put("message", "个人e签宝账户创建失败," + jsonResult.getString("msg"));
}
} catch (Exception e) {
logger.error("create person account failed, msg:{}", e.getMessage());
map.put("code", "000006");
map.put("message", "个人e签宝账户创建成功失败," + e.getMessage());
}
return map;
}
public Map<String, Object> deletePersonAccount(IRequest iRequest, SignUserInfoHclc signInfoHclc) {
Map<String, Object> map = new HashMap<>();
signInfoHclc = this.selectByPrimaryKey(iRequest, signInfoHclc);
if (Objects.isNull(signInfoHclc)) {
logger.debug("未找到对应e签宝个人用户信息,请检查!");
map.put("code", "000002");
map.put("message", "未找到对应e签宝个人用户信息,请检查!");
return map;
}
if (Objects.isNull(signInfoHclc.getAccountId())) {
logger.debug("e签宝个人账户不存在,无需注销!");
map.put("code", "000003");
map.put("message", "e签宝个人账户不存在,无需注销!");
return map;
}
String accountId = "";
//判断个人用户还是法人经办人
if (signInfoHclc.getCtitype().compareTo(1L) == 0) {
accountId = signInfoHclc.getAccountId();
} else {
accountId = signInfoHclc.getAgentAccountId();
}
//业务方交互上下文信息
JSONObject result = new JSONObject();
//创建内部用户返回的天印签章系统的用户id
result.put("accountId", accountId);
//用户的唯一标识可以为客户业务系统内唯一标识
result.put("uniqueId", signInfoHclc.getOpenId());
JSONObject json = new JSONObject(result);
String param = json.toString();
//获取HMAC加密后的X-timevale-signature签名信息
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = algorithmHelper.getXtimevaleSignature(param, projectSecret, HASH_ALGORITHM, "UTF-8");
//设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>();
headInfo.put("x-timevale-project-id", projectId);
headInfo.put("x-timevale-signature", EncryptedString);
try {
//初始化接口信息
String url = getApiUrl(signatureSysName, deleteApiName);
logger.debug("delete person account url: {}", url);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("errCode")) || "40051667".equalsIgnoreCase(map.get("code").toString())) {
map.put("code", "0");
map.put("message", "e签宝个人用户注销成功!");
} else {
logger.error("delete person account failed, errCode:{} ,msg:{}", jsonResult.getString("errCode"), jsonResult.getString("msg"));
map.put("code", jsonResult.getString("errCode"));
map.put("message", "e签宝个人用户注销失败," + jsonResult.getString("msg"));
}
} catch (Exception e) {
logger.error("delete person account failed, msg:{}", e.getMessage());
map.put("code", "000004");
map.put("message", "e签宝个人用户注销失败," + e.getMessage());
}
return map;
}
public JSONObject createSignFlows(IRequest requestContext, JSONObject params) {
JSONObject jsonResult = new JSONObject();
//解析签署人信息集合,替换用户信息为accountId
JSONArray signers = params.getJSONArray("signers");
JSONArray signersNew = new JSONArray();
String initiatorAccountId = "";
for (int i = 0; i < signers.size(); i++) {
JSONObject json1 = signers.getJSONObject(i);
String idNo = json1.getString("idNo");
String name = json1.getString("name");
String role = json1.getString("role");
SignUserInfoHclc signInfoHclc = new SignUserInfoHclc();
signInfoHclc.setAuthFlag("Y");
//代理店匹配用户名称
if ("AGENT".equalsIgnoreCase(role)) {
signInfoHclc.setName(name);
} else {
signInfoHclc.setIdNo(idNo);
signInfoHclc.setName(name);
}
List<SignUserInfoHclc> signInfoHclcs = signInfoHclcMapper.queryUserInfo(signInfoHclc);
if (signInfoHclcs.size() == 0) {
logger.error("create sign flows failed, account:{} is not defined in wx", name + idNo);
jsonResult.put("code", "2");
jsonResult.put("message", "创建签署流程失败,用户" + name + idNo + "在移动端未成功注册,请先注册!");
return jsonResult;
} else {
signInfoHclc = signInfoHclcs.get(0);
json1.put("accountType", signInfoHclc.getCtitype());
json1.put("uniqueId", signInfoHclc.getOpenId());
//用户类型是个人时
if (signInfoHclc.getCtitype().compareTo(1L) == 0) {
json1.put("accountId", signInfoHclc.getAccountId());
//用户类型是机构时
} else {
json1.put("accountId", signInfoHclc.getAgentAccountId());
json1.put("authorizationOrganizeId", signInfoHclc.getAccountId());
}
//代理店设置发起人
if ("AGENT".equalsIgnoreCase(role)) {
initiatorAccountId = signInfoHclc.getAccountId();
}
}
json1.remove("idNo");
json1.remove("name");
json1.remove("role");
signersNew.add(json1);
}
JSONObject result = new JSONObject();
//附件信息集合
result.put("attachments", params.get("attachments"));
//第三方业务码
result.put("bizNo", params.get("bizNo"));
//签署回调通知地址
result.put("callbackUrl", params.get("callbackUrl"));
//流程备注
result.put("comments", params.get("comments"));
// //抄送人信息集合签署成功后通知抄送人
// result.put("copyViewers", params.get("copyViewers"));
//发起人用户id
result.put("initiatorAccountId", initiatorAccountId);
//流程文档信息集合
result.put("signDocs", params.get("signDocs"));
//签署人信息集合
result.put("signers", signersNew);
//流程主题
result.put("subject", params.get("subject"));
JSONObject json = new JSONObject(result);
String param = json.toString();
//获取HMAC加密后的X-timevale-signature签名信息
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = algorithmHelper.getXtimevaleSignature(param, projectSecret, HASH_ALGORITHM, "UTF-8");
//设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>();
headInfo.put("x-timevale-project-id", projectId);
headInfo.put("x-timevale-signature", EncryptedString);
SignFlowsInfoHclc signFlowsInfoHclc = new SignFlowsInfoHclc();
try {
//初始化接口信息
String url = getApiUrl(signatureSysName, signFlowsApiName);
logger.debug("upload url: {}", url);
signFlowsInfoHclc.setContractNo(params.getString("bizNo"));
signFlowsInfoHclc.setSignAction("SIGN_CREATE");
signFlowsInfoHclc.setStatus("0");
signFlowsInfoHclc.setRequestClob(param);
signFlowsInfoHclc = iSignFlowsInfoHclcService.insertSelective(requestContext, signFlowsInfoHclc);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
//解析返回结果
jsonResult = JSONObject.parseObject(stringResult);
signFlowsInfoHclc.setResponseClob(stringResult);
if (!"0".equalsIgnoreCase(jsonResult.getString("errCode"))) {
logger.error("create sign flows failed, errCode:{} ,msg:{}", jsonResult.getString("errCode"), jsonResult.getString("msg"));
} else {
JSONObject data = jsonResult.getJSONObject("data");
signFlowsInfoHclc.setSignFlowId(data.getString("signFlowId"));
signFlowsInfoHclc.setReturnCode(jsonResult.getString("errCode"));
signFlowsInfoHclc.setReturnMsg(jsonResult.getString("msg"));
//解析返回签署信息集合,替换accountId为用户信息
JSONArray signUrls = data.getJSONArray("signUrls");
JSONArray signUrlsNew = new JSONArray();
for (int i = 0; i < signUrls.size(); i++) {
JSONObject signUrl = signUrls.getJSONObject(i);
//根据uniqueId获取用户信息
SignUserInfoHclc signInfoHclc = new SignUserInfoHclc();
signInfoHclc.setOpenId(signUrl.getString("uniqueId"));
signInfoHclc = this.selectByPrimaryKey(requestContext, signInfoHclc);
signUrl.put("idNo", signInfoHclc.getIdNo());
signUrl.put("name", signInfoHclc.getName());
signUrl.remove("accountId");
signUrl.remove("accountName");
signUrlsNew.add(signUrl);
}
jsonResult.remove("signUrls");
jsonResult.put("signUrls", signUrlsNew);
}
} catch (Exception e) {
logger.error("create sign flows failed, msg:{}", e.getMessage());
jsonResult.put("code", "4");
jsonResult.put("message", "创建签署流程失败," + e.getMessage());
}
if (Objects.nonNull(signFlowsInfoHclc)) {
iSignFlowsInfoHclcService.updateByPrimaryKey(requestContext, signFlowsInfoHclc);
}
return jsonResult;
}
public void postSignFlowsResult(IRequest iRequest, JSONObject params) {
//签署流程id不存在直接返回
if (Objects.isNull(params.get("flowId"))) {
return;
}
SignFlowsInfoHclc signFlowsInfoHclc = new SignFlowsInfoHclc();
signFlowsInfoHclc.setSignAction(params.getString("action"));
signFlowsInfoHclc.setSignFlowId(params.getString("flowId"));
signFlowsInfoHclc.setResponseClob(params.toString());
signFlowsInfoHclc.setStatus(params.getString("status"));
signFlowsInfoHclc.setContractNo(params.getString("bizNo"));
signFlowsInfoHclc.setSendFlag("N");
signFlowsInfoHclc = iSignFlowsInfoHclcService.insertSelective(iRequest, signFlowsInfoHclc);
//签署终结状态回调,获取所有签署流程文档下载地址
if ("SIGN_FLOW_FINISH".equalsIgnoreCase(params.getString("action"))) {
Map<String, Object> map = new HashMap<>();
map = getSignFlowDocUrls(signFlowsInfoHclc.getSignFlowId());
params.remove("finishDocUrlBeans");
params.put("finishDocUrlBeans", map.get("signDocUrlList"));
}
try {
//初始化接口信息
String url = getApiUrl(hclcSysName, getUrlsApiName);
logger.debug("upload url: {}", url);
String param = params.toString();
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, null);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("code"))) {
signFlowsInfoHclc.setSendFlag("Y");
iSignFlowsInfoHclcService.updateByPrimaryKey(iRequest, signFlowsInfoHclc);
} else {
logger.error("get sign flow doc urls failed, errCode:{} ,msg:{}", jsonResult.getString("errCode"), jsonResult.getString("msg"));
}
} catch (Exception e) {
logger.error("get sign flow doc urls failed ,msg:{}", e.getMessage());
}
}
public Map<String, Object> getSignFlowDocUrls(String signFlowId) {
Map<String, Object> map = new HashMap<>();
//业务方交互上下文信息
JSONObject result = new JSONObject();
//银行卡号
result.put("signFlowId", signFlowId);
JSONObject json = new JSONObject(result);
String param = json.toString();
//获取HMAC加密后的X-timevale-signature签名信息
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = algorithmHelper.getXtimevaleSignature(param, projectSecret, HASH_ALGORITHM, "UTF-8");
//设置http请求head信息
Map<String, String> headInfo = new HashMap<String, String>();
headInfo.put("x-timevale-project-id", projectId);
headInfo.put("x-timevale-signature", EncryptedString);
try {
//初始化接口信息
String url = getApiUrl(signatureSysName, getUrlsApiName);
logger.debug("upload url: {}", url);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(jsonResult.getString("errCode"))) {
JSONObject data = jsonResult.getJSONObject("data");
//设置返回accountId
map.put("signDocUrlList", data.getJSONArray("signDocUrlList"));
map.put("code", "0");
map.put("message", "获取签署流程文档下载地址成功!");
} else {
logger.error("get sign flow doc urls failed, errCode:{} ,msg:{}", jsonResult.getString("errCode"), jsonResult.getString("msg"));
map.put("code", jsonResult.getString("errCode"));
map.put("message", "获取签署流程文档下载地址失败," + jsonResult.getString("msg"));
}
} catch (Exception e) {
logger.error("create person account failed, msg:{}", e.getMessage());
map.put("code", "1");
map.put("message", "获取签署流程文档下载地址失败,请检查!" + e.getMessage());
}
return map;
}
}
package com.hand.app.esignHclc.service.impl;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.hand.app.esignHclc.dto.SignUserAttachInfo;
import com.hand.app.esignHclc.service.ISignUserAttachInfoService;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(rollbackFor = Exception.class)
public class SignUserAttachInfoServiceImpl extends BaseServiceImpl<SignUserAttachInfo> implements ISignUserAttachInfoService{
}
\ No newline at end of file
package com.hand.app.esignHclc.service.impl;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.hand.app.esignHclc.dto.SignUserInfoHclcHis;
import com.hand.app.esignHclc.service.ISignUserInfoHclcHisService;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(rollbackFor = Exception.class)
public class SignUserInfoHclcHisServiceImpl extends BaseServiceImpl<SignUserInfoHclcHis> implements ISignUserInfoHclcHisService{
}
\ No newline at end of file
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.utils;
import com.baidu.aip.ocr.AipOcr;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHeader;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.security.SecureRandom;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public class SignHclcUtils {
//设置百度图片识别APPID/AK/SK
public static final String APP_ID = "18653557";
public static final String API_KEY = "VD5jNFLsuBQE4vvjTtQoKQtt";
public static final String SECRET_KEY = "Bx1O0kQ7W9YDprTOaLr2MPcPupsn7w7z";
public SignHclcUtils() {
}
/***
* 项目初始化 使用到的接口;
* @param info
* @param appId
* @param secret
*/
public static SignUserInfoHclc initProject(SignUserInfoHclc info, String appId, String secret, String notifyUrl) {
info.setAppId(appId);
info.setSecret(secret);
info.setNotifyUrl(notifyUrl);
return info;
}
/**
* 向指定URL发送POST方法的请求
*
* @param urls 发送请求的URL
* @param json 请求参数,请求参数应该是 JSON 的形式。
* @return URL 所代表远程资源的响应结果
*/
public String postString(String urls, String json, Map<String, String> headInfo) {
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(urls);
post.setHeader("Content-Type", "application/json");
String result = "";
try {
StringEntity s = new StringEntity(json, "utf-8");
s.setContentEncoding(new BasicHeader("Content-Type", "application/json"));
if (Objects.nonNull(headInfo)) {
for (Map.Entry<String, String> entry : headInfo.entrySet()) {
post.setHeader(entry.getKey(), entry.getValue());
}
}
post.setEntity(s);
HttpResponse httpResponse = client.execute(post);
InputStream inStream = httpResponse.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "utf-8"));
StringBuilder strber = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
strber.append(line + "\n");
}
inStream.close();
result = strber.toString();
if (httpResponse.getStatusLine().getStatusCode() == 200) {
System.out.println("请求服务器成功");
} else {
System.out.println("请求服务端失败");
}
return result;
} catch (Exception var12) {
var12.printStackTrace();
throw new RuntimeException(var12);
}
}
public String getJSON(String url) {
try {
URL thisurl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) thisurl.openConnection();
connection.connect();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
connection.disconnect();
return sb.toString();
} catch (Exception var7) {
var7.printStackTrace();
return null;
}
}
public String aes(String key, String res) {
try {
KeyGenerator kg = KeyGenerator.getInstance("AES");
byte[] keyBytes = key.getBytes("utf-8");
kg.init(128, new SecureRandom(keyBytes));
SecretKey sk = kg.generateKey();
SecretKeySpec sks = new SecretKeySpec(sk.getEncoded(), "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(1, sks);
byte[] resBytes = res.getBytes("utf-8");
String data = this.parseByte2HexStr(cipher.doFinal(resBytes));
return data;
} catch (Exception var10) {
var10.printStackTrace();
throw new RuntimeException(var10);
}
}
private String parseByte2HexStr(byte[] buf) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < buf.length; ++i) {
String hex = Integer.toHexString(buf[i] & 255);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
return sb.toString();
}
public String signString(String secKey, String data) {
try {
String srcStr = "secKey=" + secKey + "&data=" + data;
SecretKeySpec keySpec = new SecretKeySpec(secKey.getBytes("UTF-8"), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(keySpec);
byte[] signBytes = mac.doFinal(srcStr.getBytes("UTF-8"));
String appSec = Base64.encodeBase64String(signBytes);
return appSec;
} catch (Exception var8) {
var8.printStackTrace();
throw new RuntimeException(var8);
}
}
/**
* 向指定URL发送GET方法的请求
*
* @param url 发送请求的URL
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return URL 所代表远程资源的响应结果
*/
public static String getStr(String url, String param) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
// for (String key : map.keySet()) {
// System.out.println(key + "--->" + map.get(key));
// }
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送GET请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
/***
* 获取鉴权Token;
* @param faceApiUrl
*/
public String getFaceApiToken(String faceApiUrl, String appId, String secret) {
String token = null;
try {
SignHclcUtils signHclcUtils = new SignHclcUtils();
String param = "appId=" + appId + "&secret=" + secret + "&grantType=client_credentials";
String stringResult = signHclcUtils.getStr(faceApiUrl, param);
JSONObject json2 = JSONObject.parseObject(stringResult);
if ("0".equalsIgnoreCase(json2.getString("code"))) {
JSONObject data = json2.getJSONObject("data");
token = data.getString("token");
}
return token;
} catch (Exception var8) {
var8.printStackTrace();
return token;
}
}
/***
* orc身份证识别;
* @param image
*/
public JSONObject idcard(byte[] image) {
// 传入可选参数调用接口
AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
HashMap<String, String> options = new HashMap<String, String>();
//是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:- true:检测朝向;- false:不检测朝向。
options.put("detect_direction", "true");
//是否开启身份证风险类型(身份证复印件、临时身份证、身份证翻拍、修改过的身份证)功能,默认不开启,即:false。可选值:true-开启;false-不开启
options.put("detect_risk", "false");
//front:身份证含照片的一面;back:身份证带国徽的一面
String idCardSide = "front";
// 参数为本地图片路径
org.json.JSONObject res = client.idcard(image, idCardSide, options);
JSONObject jsonObject = new JSONObject();
if (Objects.nonNull(res.get("words_result").toString())) {
jsonObject = getJsonResult(res);
}
return jsonObject;
}
/***
* 营业执照识别;
* @param image
*/
public JSONObject businessLicense(byte[] image) {
// 传入可选参数调用接口
AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
HashMap<String, String> options = new HashMap<String, String>();
// 参数为本地图片路径
org.json.JSONObject res = client.businessLicense(image, options);
JSONObject jsonObject = new JSONObject();
if (Objects.nonNull(res.get("words_result").toString())) {
jsonObject = getJsonResult(res);
}
return jsonObject;
}
private JSONObject getJsonResult(org.json.JSONObject res) {
JSONObject jsonObject = new JSONObject();
JSONObject jsonObjectRes = JSONObject.parseObject(res.get("words_result").toString());
for (String str : jsonObjectRes.keySet()) {
String value = "";
if (!"".equalsIgnoreCase(jsonObjectRes.getString(str)) && Objects.nonNull(jsonObjectRes.getString(str))) {
value = jsonObjectRes.getJSONObject(str).getString("words");
jsonObject.put(str, value);
}
}
return jsonObject;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.controllers;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esignHclc.dto.SignInfoHclc;
import com.hand.app.esignHclc.service.IOrganSignInfoHclcService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.system.dto.ResponseData;
import hls.support.core.wechat.formbean.AttachmentInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/r/api", "/"})
public class SignHclcController extends BaseController {
@Autowired
private ISignInfoHclcService signHclcService;
@Autowired
private IOrganSignInfoHclcService organSignHclcService;
public SignHclcController() {
}
@ResponseBody
@RequestMapping({"/sign/info/hclc/query/by/openid"})
public ResponseData query(HttpServletRequest request, SignInfoHclc dto) {
IRequest requestContext = this.createRequestContext(request);
List<SignInfoHclc> signInfoHclcs = new ArrayList();
SignInfoHclc signInfoHclc = (SignInfoHclc)this.signHclcService.selectByPrimaryKey(requestContext, dto);
if (signInfoHclc != null) {
signInfoHclcs.add(signInfoHclc);
}
return new ResponseData(signInfoHclcs);
}
@ResponseBody
@RequestMapping({"/auth/api/individual/face"})
public Map<String, Object> getIndividualFaceUrl(HttpServletRequest request, @RequestBody SignInfoHclc dto) {
return this.signHclcService.getIndividualFaceUrl(this.createRequestContext(request), dto);
}
@ResponseBody
@RequestMapping({"/auth/api/individual/face/Organ"})
public Map<String, Object> getOrganIndividualFaceUrl(HttpServletRequest request, @RequestBody SignInfoHclc dto) {
return this.organSignHclcService.getOrganIndividualFaceUrl(this.createRequestContext(request), dto);
}
@RequestMapping(
value = {"/auth/upload/image/hls/from/wx"},
method = {RequestMethod.POST}
)
@ResponseBody
public JSONObject uploadHlsFromWx(HttpServletRequest request, @RequestBody AttachmentInfo dto) {
return this.signHclcService.uploadHlsFromWx(this.createRequestContext(request), dto);
}
@ResponseBody
@RequestMapping({"/accounts/outerAccounts/create"})
public Map<String, Object> addPersonAccount(HttpServletRequest request, @RequestBody SignInfoHclc dto) {
return this.signHclcService.addPersonAccount(this.createRequestContext(request), dto.getOpenId());
}
@ResponseBody
@RequestMapping({"/organizations/outerOrgans/create"})
public Map<String, Object> addOrgansAccount(HttpServletRequest request, @RequestBody SignInfoHclc dto) {
return this.organSignHclcService.addOrgansAccount(this.createRequestContext(request), dto.getOpenId());
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.controllers;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.system.dto.ResponseData;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class SignHclcListenController extends BaseController {
@Autowired
private ISignInfoHclcFaceService iSignInfoHclcFaceService;
public SignHclcListenController() {
}
@ResponseBody
@RequestMapping(
value = {"/api/public/listen/auth/result"},
method = {RequestMethod.POST}
)
public ResponseData postAuthResult(HttpServletRequest request, @RequestBody(required = false) JSONObject params) {
ResponseData responseData = new ResponseData(false);
this.iSignInfoHclcFaceService.postAuthResult(this.createRequestContext(request), params);
responseData.setCode("200");
responseData.setSuccess(true);
responseData.setMessage("接收成功!");
return responseData;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(
name = "lm005_hclc"
)
@ExtensionAttribute(
disable = true
)
public class Lm005Hclc extends BaseDTO {
@Id
private String webcustomercd;
private String ctino;
private String openId;
public Lm005Hclc() {
}
public String getWebcustomercd() {
return this.webcustomercd;
}
public void setWebcustomercd(String webcustomercd) {
this.webcustomercd = webcustomercd;
}
public String getOpenId() {
return this.openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getCtino() {
return this.ctino;
}
public void setCtino(String ctino) {
this.ctino = ctino;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.dto;
import com.hand.app.esign.bean.AttachmentInfo;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
@Table(
name = "sign_info_hclc"
)
@ExtensionAttribute(
disable = true
)
public class SignInfoHclc extends BaseDTO {
@Id
private String openId;
private String idNo;
private String name;
private String mobile;
private String email;
private String title;
private String address;
private String faceauthStatus;
private String orgauthStatus;
private String legalName;
private Long ctitype;
private Long agentType;
private String agentIdNo;
private String agentName;
private String legalIdNo;
private String attachmentId;
private String mediaId;
private String bindFlag;
private String accountId;
private String createCode;
private String createMessage;
@Transient
private AttachmentInfo attachmentInfo;
@Transient
private String apiUrl;
@Transient
private String appId;
@Transient
private String secret;
@Transient
private String redirectUrl;
@Transient
private String notifyUrl;
public SignInfoHclc() {
}
public AttachmentInfo getAttachmentInfo() {
return this.attachmentInfo;
}
public void setAttachmentInfo(AttachmentInfo attachmentInfo) {
this.attachmentInfo = attachmentInfo;
}
public String getApiUrl() {
return this.apiUrl;
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getAppId() {
return this.appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getSecret() {
return this.secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getOpenId() {
return this.openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getIdNo() {
return this.idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getMobile() {
return this.mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public Long getAgentType() {
return this.agentType;
}
public void setAgentType(Long agentType) {
this.agentType = agentType;
}
public Long getCtitype() {
return this.ctitype;
}
public void setCtitype(Long ctitype) {
this.ctitype = ctitype;
}
public String getFaceauthStatus() {
return this.faceauthStatus;
}
public void setFaceauthStatus(String faceauthStatus) {
this.faceauthStatus = faceauthStatus;
}
public String getOrgauthStatus() {
return this.orgauthStatus;
}
public void setOrgauthStatus(String orgauthStatus) {
this.orgauthStatus = orgauthStatus;
}
public String getAgentIdNo() {
return this.agentIdNo;
}
public void setAgentIdNo(String agentIdNo) {
this.agentIdNo = agentIdNo;
}
public String getAgentName() {
return this.agentName;
}
public void setAgentName(String agentName) {
this.agentName = agentName;
}
public String getLegalIdNo() {
return this.legalIdNo;
}
public void setLegalIdNo(String legalIdNo) {
this.legalIdNo = legalIdNo;
}
public String getLegalName() {
return this.legalName;
}
public void setLegalName(String legalName) {
this.legalName = legalName;
}
public String getAccountId() {
return this.accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getRedirectUrl() {
return this.redirectUrl;
}
public void setRedirectUrl(String redirectUrl) {
this.redirectUrl = redirectUrl;
}
public String getNotifyUrl() {
return this.notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public String getAttachmentId() {
return this.attachmentId;
}
public void setAttachmentId(String attachmentId) {
this.attachmentId = attachmentId;
}
public String getMediaId() {
return this.mediaId;
}
public void setMediaId(String mediaId) {
this.mediaId = mediaId;
}
public String getBindFlag() {
return this.bindFlag;
}
public void setBindFlag(String bindFlag) {
this.bindFlag = bindFlag;
}
public String getCreateCode() {
return this.createCode;
}
public void setCreateCode(String createCode) {
this.createCode = createCode;
}
public String getCreateMessage() {
return this.createMessage;
}
public void setCreateMessage(String createMessage) {
this.createMessage = createMessage;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(
name = "sign_info_hclc_face"
)
@ExtensionAttribute(
disable = true
)
public class SignInfoHclcFace extends BaseDTO {
@Id
@GeneratedValue
private Long faceauthId;
private String openId;
private String authStatus;
private String url;
private String shortLink;
private String returnCode;
private String returnMessage;
private String flowId;
private String authType;
private String verifyCode;
public SignInfoHclcFace() {
}
public Long getFaceauthId() {
return this.faceauthId;
}
public void setFaceauthId(Long faceauthId) {
this.faceauthId = faceauthId;
}
public String getOpenId() {
return this.openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getShortLink() {
return this.shortLink;
}
public void setShortLink(String shortLink) {
this.shortLink = shortLink;
}
public String getReturnCode() {
return this.returnCode;
}
public void setReturnCode(String returnCode) {
this.returnCode = returnCode;
}
public String getReturnMessage() {
return this.returnMessage;
}
public void setReturnMessage(String returnMessage) {
this.returnMessage = returnMessage;
}
public String getAuthStatus() {
return this.authStatus;
}
public void setAuthStatus(String authStatus) {
this.authStatus = authStatus;
}
public String getFlowId() {
return this.flowId;
}
public void setFlowId(String flowId) {
this.flowId = flowId;
}
public String getAuthType() {
return this.authType;
}
public void setAuthType(String authType) {
this.authType = authType;
}
public String getVerifyCode() {
return this.verifyCode;
}
public void setVerifyCode(String verifyCode) {
this.verifyCode = verifyCode;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.mapper;
import com.hand.app.esignHclc.dto.Lm005Hclc;
import com.hand.hap.mybatis.common.Mapper;
public interface Lm005HclcMapper extends Mapper<Lm005Hclc> {
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.mapper;
import com.hand.app.esignHclc.dto.SignInfoHclcFace;
import com.hand.hap.mybatis.common.Mapper;
public interface SignInfoHclcFaceMapper extends Mapper<SignInfoHclcFace> {
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.mapper;
import com.hand.app.esignHclc.dto.SignInfoHclc;
import com.hand.hap.mybatis.common.Mapper;
public interface SignInfoHclcMapper extends Mapper<SignInfoHclc> {
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.service;
import com.hand.app.esignHclc.dto.Lm005Hclc;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
public interface ILm005HclcService extends IBaseService<Lm005Hclc>, ProxySelf<ILm005HclcService> {
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.service;
import com.hand.app.esignHclc.dto.SignInfoHclc;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import java.util.Map;
public interface IOrganSignInfoHclcService extends IBaseService<SignInfoHclc>, ProxySelf<IOrganSignInfoHclcService> {
Map<String, Object> getOrganIndividualFaceUrl(IRequest var1, SignInfoHclc var2);
Map<String, Object> addOrgansAccount(IRequest var1, String var2);
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.service;
import com.hand.app.esignHclc.dto.SignInfoHclcFace;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import net.sf.json.JSONObject;
public interface ISignInfoHclcFaceService extends IBaseService<SignInfoHclcFace>, ProxySelf<ISignInfoHclcFaceService> {
void postAuthResult(IRequest var1, JSONObject var2);
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.service;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esignHclc.dto.SignInfoHclc;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import hls.support.core.wechat.formbean.AttachmentInfo;
import java.util.Map;
public interface ISignInfoHclcService extends IBaseService<SignInfoHclc>, ProxySelf<ISignInfoHclcService> {
Map<String, Object> getIndividualFaceUrl(IRequest var1, SignInfoHclc var2);
Map<String, Object> getFaceUrlHttp(IRequest var1, SignInfoHclc var2, String var3);
JSONObject uploadHlsFromWx(IRequest var1, AttachmentInfo var2);
String getApiUrl(String var1, String var2);
Map<String, Object> addPersonAccount(IRequest var1, String var2);
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.service.impl;
import com.hand.app.esignHclc.dto.Lm005Hclc;
import com.hand.app.esignHclc.service.ILm005HclcService;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
@Service
public class Lm005HclcServiceImpl extends BaseServiceImpl<Lm005Hclc> implements ILm005HclcService {
public Lm005HclcServiceImpl() {
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esign.utils.AlgorithmHelper;
import com.hand.app.esignHclc.dto.SignInfoHclc;
import com.hand.app.esignHclc.dto.SignInfoHclcFace;
import com.hand.app.esignHclc.service.IOrganSignInfoHclcService;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.app.esignHclc.utils.SignHclcUtils;
import com.hand.hap.core.IRequest;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Service
public class OrganSignInfoHclcServiceImpl extends BaseServiceImpl<SignInfoHclc> implements IOrganSignInfoHclcService {
@Value("${tsign.project.id}")
private String projectId;
@Value("${tsign.project.secret}")
private String projectSecret;
@Value("${tsign.api.notifyUrl}")
private String notifyUrl;
@Value("${tsign.face.api.appId}")
private String appId;
@Value("${tsign.face.api.secret}")
private String secret;
@Autowired
private ISignInfoHclcFaceService signInfoHclcFaceService;
@Autowired
private ISignInfoHclcService iSignInfoHclcService;
public static final String indivSysName = "HCLC_FACE_API";
public static final String tokenApiName = "getToken";
public static final String orgApiName = "orgAuthUrl";
public static final String signatureSysName = "HCLC_ELECTRONIC_SIGNATURE";
public static final String organsApiName = "outerAccounts";
private static final String HASH_ALGORITHM = "HmacSHA256";
@Autowired
IHapInterfaceHeaderService headerService;
private Logger logger = LoggerFactory.getLogger(this.getClass());
public OrganSignInfoHclcServiceImpl() {
}
public Map<String, Object> getOrganIndividualFaceUrl(IRequest iRequest, SignInfoHclc info) {
Map<String, Object> mapOrgan = new HashMap();
if (Objects.isNull(info.getOpenId())) {
this.logger.error("关键参数openid不存在,调用失败!");
((Map)mapOrgan).put("success", "false");
((Map)mapOrgan).put("message", "关键参数openid不存在,调用失败!");
return (Map)mapOrgan;
} else {
SignInfoHclc signInfoHclc = (SignInfoHclc)this.mapper.selectByPrimaryKey(info);
if (Objects.isNull(signInfoHclc)) {
info.setFaceauthStatus("NEW");
info.setOrgauthStatus("NEW");
info.setCtitype(2L);
info.setBindFlag("0");
signInfoHclc = (SignInfoHclc)this.insertSelective(iRequest, info);
} else {
if (signInfoHclc.getFaceauthStatus().equalsIgnoreCase("SUCCESS") && signInfoHclc.getOrgauthStatus().equalsIgnoreCase("SUCCESS")) {
((Map)mapOrgan).put("success", "false");
((Map)mapOrgan).put("message", "企业认证已完成,无需重复验证!");
return (Map)mapOrgan;
}
signInfoHclc.setIdNo(info.getIdNo());
signInfoHclc.setName(info.getName());
signInfoHclc.setLegalIdNo(info.getLegalIdNo());
signInfoHclc.setLegalName(info.getLegalName());
signInfoHclc.setAgentType(info.getAgentType());
signInfoHclc.setRedirectUrl(info.getRedirectUrl());
signInfoHclc = (SignInfoHclc)this.updateByPrimaryKey(iRequest, signInfoHclc);
}
String tokenApiUrl = this.iSignInfoHclcService.getApiUrl("HCLC_FACE_API", "getToken");
this.logger.debug("upload url: {}", tokenApiUrl);
SignHclcUtils signHclcUtils = new SignHclcUtils();
signInfoHclc = SignHclcUtils.initProject(signInfoHclc, this.appId, this.secret, this.notifyUrl);
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, signInfoHclc.getAppId(), signInfoHclc.getSecret());
if (Objects.nonNull(token)) {
mapOrgan = this.getOrgAuthUrlHttp(iRequest, signInfoHclc, token);
if (((Map)mapOrgan).get("code").toString().equalsIgnoreCase("0") && !signInfoHclc.getFaceauthStatus().equalsIgnoreCase("SUCCESS")) {
new HashMap();
SignInfoHclc signInfo = new SignInfoHclc();
signInfo = SignHclcUtils.initProject(signInfo, this.appId, this.secret, this.notifyUrl);
signInfo.setOpenId(signInfoHclc.getOpenId());
signInfo.setIdNo(signInfoHclc.getLegalIdNo());
signInfo.setName(signInfoHclc.getLegalName());
signInfo.setRedirectUrl(((Map)mapOrgan).get("url").toString());
Map<String, Object> mapFace = this.iSignInfoHclcService.getFaceUrlHttp(iRequest, signInfo, token);
if (!mapFace.get("code").toString().equalsIgnoreCase("0")) {
return mapFace;
}
((Map)mapOrgan).put("url", mapFace.get("url"));
}
} else {
((Map)mapOrgan).put("code", "1");
((Map)mapOrgan).put("message", "获取鉴权Token失败,请检查!");
}
return (Map)mapOrgan;
}
}
public Map<String, Object> getOrgAuthUrlHttp(IRequest iRequest, SignInfoHclc info, String token) {
SignInfoHclcFace signInfoHclcFace = new SignInfoHclcFace();
signInfoHclcFace.setOpenId(info.getOpenId());
signInfoHclcFace.setAuthStatus("NEW");
signInfoHclcFace.setAuthType("2");
signInfoHclcFace = (SignInfoHclcFace)this.signInfoHclcFaceService.insertSelective(iRequest, signInfoHclcFace);
JSONObject json1 = new JSONObject();
json1.put("contextId", signInfoHclcFace.getFaceauthId());
json1.put("notifyUrl", info.getNotifyUrl());
json1.put("redirectUrl", info.getRedirectUrl());
JSONObject json2 = new JSONObject();
json2.put("name", info.getName());
json2.put("certNo", info.getIdNo());
json2.put("certType", "ORGANIZATION_USC_CODE");
json2.put("legalRepCertNo", info.getLegalIdNo());
json2.put("egalRepCertType", "INDIVIDUAL_CH_IDCARD");
json2.put("legalRepName", info.getLegalName());
json2.put("legalRepNationality", "");
json2.put("operatorType", info.getAgentType());
json2.put("verifyType", "2");
JSONObject result = new JSONObject();
result.put("authType", "ORG_BANK_TRANSFER");
result.put("contextInfo", json1);
result.put("orgEntity", json2);
JSONObject json = new JSONObject(result);
String param = json.toString();
Map<String, String> headInfo = new HashMap();
headInfo.put("X-Tsign-Open-App-Id", info.getAppId());
headInfo.put("X-Tsign-Open-Token", token);
HashMap map = new HashMap();
try {
String url = this.iSignInfoHclcService.getApiUrl("HCLC_FACE_API", "orgAuthUrl");
this.logger.debug("upload url: {}", url);
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
net.sf.json.JSONObject jsonResult = net.sf.json.JSONObject.fromObject(stringResult);
if (jsonResult.get("code").toString().equalsIgnoreCase("0")) {
net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(jsonResult.get("data"));
signInfoHclcFace.setFlowId(data.getString("flowId"));
signInfoHclcFace.setUrl(data.getString("url"));
signInfoHclcFace.setShortLink(data.getString("shortLink"));
map.put("code", "0");
map.put("url", data.getString("url"));
map.put("message", "获取url成功!");
} else {
map.put("code", "2");
map.put("message", "获取组织机构实名认证地址失败,请检查!");
}
signInfoHclcFace.setReturnCode(jsonResult.get("code").toString());
signInfoHclcFace.setReturnMessage(jsonResult.get("message").toString());
this.signInfoHclcFaceService.updateByPrimaryKey(iRequest, signInfoHclcFace);
return map;
} catch (Exception var17) {
map.put("code", "3");
map.put("message", "访问e签宝组织机构实名认证地址失败,请检查!");
signInfoHclcFace.setReturnCode("3");
signInfoHclcFace.setReturnMessage(var17.getMessage());
this.signInfoHclcFaceService.updateByPrimaryKey(iRequest, signInfoHclcFace);
return map;
}
}
public Map<String, Object> addOrgansAccount(IRequest iRequest, String openId) {
Map<String, Object> map = new HashMap();
SignInfoHclc signInfoHclc = new SignInfoHclc();
signInfoHclc.setOpenId(openId);
signInfoHclc = (SignInfoHclc)this.mapper.selectByPrimaryKey(signInfoHclc);
if (Objects.nonNull(signInfoHclc.getAccountId())) {
this.logger.debug("e签宝用户 accountId: {} 已创建,无需重复创建!", signInfoHclc.getAccountId());
map.put("code", "1");
map.put("message", "e签宝用户已创建,无需重复创建!");
return map;
} else {
JSONObject result = new JSONObject();
result.put("agentAccountId", "");
result.put("agentUniqueId", signInfoHclc.getAgentIdNo());
result.put("cardNo", "");
result.put("email", "");
result.put("legalLicenseNumber", signInfoHclc.getLegalIdNo());
result.put("legalLicenseType", "IDCard");
result.put("legalMobile", "");
result.put("legalName", signInfoHclc.getLegalName());
result.put("licenseNumber", signInfoHclc.getIdNo());
result.put("licenseType", "SOCNO");
result.put("organizeName", signInfoHclc.getName());
result.put("organizeNo", signInfoHclc.getOpenId());
JSONObject json = new JSONObject(result);
String param = json.toString();
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = AlgorithmHelper.getXtimevaleSignature(param, this.projectSecret, "HmacSHA256", "UTF-8");
Map<String, String> headInfo = new HashMap();
headInfo.put("x-timevale-project-id", this.projectId);
headInfo.put("x-timevale-signature", EncryptedString);
try {
String url = this.iSignInfoHclcService.getApiUrl("HCLC_ELECTRONIC_SIGNATURE", "outerAccounts");
this.logger.debug("upload url: {}", url);
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
net.sf.json.JSONObject jsonResult = net.sf.json.JSONObject.fromObject(stringResult);
if (jsonResult.get("errCode").toString().equalsIgnoreCase("0")) {
net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(jsonResult.get("data"));
signInfoHclc.setAccountId(data.getString("organizeId"));
map.put("code", "0");
map.put("message", "用户创建成功!");
} else {
this.logger.error("create organs account failed, errCode:{} ,msg:{}", jsonResult.get("errCode").toString(), jsonResult.get("msg").toString());
map.put("code", jsonResult.get("errCode").toString());
map.put("message", jsonResult.get("msg").toString());
}
signInfoHclc.setCreateCode(jsonResult.get("code").toString());
signInfoHclc.setCreateMessage(jsonResult.get("message").toString());
} catch (Exception var16) {
this.logger.error("create organs account failed, msg:{}", var16.getMessage());
map.put("code", "2");
map.put("message", "用户创建成功失败,请检查!" + var16.getMessage());
signInfoHclc.setCreateCode("2");
signInfoHclc.setCreateMessage(var16.getMessage());
}
this.updateByPrimaryKey(iRequest, signInfoHclc);
return map;
}
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.service.impl;
import com.hand.app.esignHclc.dto.Lm005Hclc;
import com.hand.app.esignHclc.dto.SignInfoHclc;
import com.hand.app.esignHclc.dto.SignInfoHclcFace;
import com.hand.app.esignHclc.mapper.Lm005HclcMapper;
import com.hand.app.esignHclc.service.IOrganSignInfoHclcService;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SignInfoHclcFaceServiceImpl extends BaseServiceImpl<SignInfoHclcFace> implements ISignInfoHclcFaceService {
@Autowired
private ISignInfoHclcService signInfoHclcService;
@Autowired
private IOrganSignInfoHclcService organSignInfoHclcService;
@Autowired
private Lm005HclcMapper lm005HclcMapper;
private final Object lock = new Object();
public SignInfoHclcFaceServiceImpl() {
}
public void postAuthResult(IRequest iRequest, JSONObject params) {
Object var3 = this.lock;
synchronized(this.lock) {
SignInfoHclcFace signInfoHclcFace = new SignInfoHclcFace();
signInfoHclcFace.setFaceauthId(Long.valueOf(params.get("contextId").toString()));
signInfoHclcFace = (SignInfoHclcFace)this.selectByPrimaryKey(iRequest, signInfoHclcFace);
if (Objects.nonNull(signInfoHclcFace) && !signInfoHclcFace.getAuthStatus().equalsIgnoreCase("SUCCESS")) {
SignInfoHclc signInfoHclc = new SignInfoHclc();
signInfoHclc.setOpenId(signInfoHclcFace.getOpenId());
signInfoHclc = (SignInfoHclc)this.signInfoHclcService.selectByPrimaryKey(iRequest, signInfoHclc);
if (params.get("success").toString().equalsIgnoreCase("true")) {
signInfoHclcFace.setAuthStatus("SUCCESS");
signInfoHclcFace.setVerifyCode(params.get("success").toString());
signInfoHclcFace = (SignInfoHclcFace)this.updateByPrimaryKey(iRequest, signInfoHclcFace);
if (!signInfoHclc.getFaceauthStatus().equalsIgnoreCase("SUCCESS")) {
signInfoHclc.setFaceauthStatus("SUCCESS");
}
if (signInfoHclcFace.getAuthType().equalsIgnoreCase("2") && !signInfoHclc.getOrgauthStatus().equalsIgnoreCase("SUCCESS")) {
signInfoHclc.setOrgauthStatus("SUCCESS");
}
if (signInfoHclc.getCtitype().compareTo(1L) == 0 || signInfoHclcFace.getAuthType().equalsIgnoreCase("2")) {
Lm005Hclc lm005Hclc = new Lm005Hclc();
lm005Hclc.setCtino(signInfoHclc.getIdNo());
List<Lm005Hclc> lm005Hclcs = this.lm005HclcMapper.select(lm005Hclc);
Iterator var8 = lm005Hclcs.iterator();
while(var8.hasNext()) {
Lm005Hclc hclc = (Lm005Hclc)var8.next();
hclc.setOpenId(signInfoHclc.getOpenId());
this.lm005HclcMapper.updateByPrimaryKey(hclc);
}
if (lm005Hclcs.size() > 0) {
signInfoHclc.setBindFlag("1");
}
}
signInfoHclc = (SignInfoHclc)this.signInfoHclcService.updateByPrimaryKey(iRequest, signInfoHclc);
if (signInfoHclc.getBindFlag().equalsIgnoreCase("Y") && Objects.isNull(signInfoHclc.getAccountId())) {
if (signInfoHclc.getCtitype().compareTo(1L) == 0) {
this.signInfoHclcService.addPersonAccount(iRequest, signInfoHclc.getOpenId());
} else {
this.organSignInfoHclcService.addOrgansAccount(iRequest, signInfoHclc.getOpenId());
}
}
}
}
}
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esign.service.ISignInfoService;
import com.hand.app.esign.utils.AlgorithmHelper;
import com.hand.app.esignHclc.dto.SignInfoHclc;
import com.hand.app.esignHclc.dto.SignInfoHclcFace;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.app.esignHclc.utils.SignHclcUtils;
import com.hand.hap.core.IRequest;
import com.hand.hap.intergration.dto.HapInterfaceHeader;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import hls.support.core.wechat.formbean.AttachmentInfo;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.CharsetUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Service
public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignInfoHclc> implements ISignInfoHclcService {
@Value("${tsign.project.id}")
private String projectId;
@Value("${tsign.project.secret}")
private String projectSecret;
@Value("${tsign.api.notifyUrl}")
private String notifyUrl;
@Value("${tsign.face.api.appId}")
private String appId;
@Value("${tsign.face.api.secret}")
private String secret;
@Value("${wx.apiKey}")
private String apiKey;
@Value("${wx.image.path}")
private String imagePath;
private CloseableHttpClient httpClient;
public static final String RESULT_ERROR = "-1";
public static final String indivSysName = "HCLC_FACE_API";
public static final String tokenApiName = "getToken";
public static final String indivApiName = "indivAuthUrl";
public static final String downLoadSysName = "wxgzh_hitachics";
public static final String downLoadApiName = "media_download";
public static final String upLoadSysName = "HCL_UPLOAD_FILE";
public static final String upLoadApiName = "upload";
public static final String signatureSysName = "HCLC_ELECTRONIC_SIGNATURE";
public static final String accountsApiName = "outerAccounts";
private static final String HASH_ALGORITHM = "HmacSHA256";
@Autowired
IHapInterfaceHeaderService headerService;
@Autowired
private ISignInfoHclcFaceService signInfoHclcFaceService;
@Autowired
private ISignInfoService ISignInfoService;
private Logger logger = LoggerFactory.getLogger(this.getClass());
public SignInfoHclcServiceImpl() {
RequestConfig config = RequestConfig.custom().setConnectTimeout(60000).setSocketTimeout(15000).build();
this.httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
}
public Map<String, Object> getIndividualFaceUrl(IRequest iRequest, SignInfoHclc info) {
Map<String, Object> map = new HashMap();
if (Objects.isNull(info.getOpenId())) {
this.logger.error("关键参数openid不存在,调用失败!");
((Map)map).put("success", "false");
((Map)map).put("message", "关键参数openid不存在,调用失败!");
return (Map)map;
} else {
SignInfoHclc signInfoHclc = (SignInfoHclc)this.mapper.selectByPrimaryKey(info);
if (Objects.isNull(signInfoHclc)) {
info.setFaceauthStatus("NEW");
info.setCtitype(1L);
info.setBindFlag("0");
signInfoHclc = (SignInfoHclc)this.insertSelective(iRequest, info);
} else {
if (signInfoHclc.getFaceauthStatus().equalsIgnoreCase("SUCCESS")) {
((Map)map).put("success", "false");
((Map)map).put("message", "人脸核身认证已完成,无需重复验证!");
return (Map)map;
}
signInfoHclc.setIdNo(info.getIdNo());
signInfoHclc.setName(info.getName());
signInfoHclc.setRedirectUrl(info.getRedirectUrl());
signInfoHclc = (SignInfoHclc)this.updateByPrimaryKey(iRequest, signInfoHclc);
}
String tokenApiUrl = this.getApiUrl("HCLC_FACE_API", "getToken");
this.logger.debug("upload url: {}", tokenApiUrl);
SignHclcUtils signHclcUtils = new SignHclcUtils();
signInfoHclc = SignHclcUtils.initProject(signInfoHclc, this.appId, this.secret, this.notifyUrl);
String token = signHclcUtils.getFaceApiToken(tokenApiUrl, signInfoHclc.getAppId(), signInfoHclc.getSecret());
if (Objects.nonNull(token)) {
map = this.getFaceUrlHttp(iRequest, signInfoHclc, token);
} else {
((Map)map).put("code", "1");
((Map)map).put("message", "获取鉴权Token失败,请检查!");
}
return (Map)map;
}
}
public String getApiUrl(String sysName, String apiName) {
HapInterfaceHeader headerAndLineDTO = this.headerService.getHeaderAndLine(sysName, apiName);
if (headerAndLineDTO == null) {
this.logger.debug("headerAndLineDTO is null, apiName:{}, sysName:{}", apiName, sysName);
return null;
} else {
return headerAndLineDTO.getDomainUrl() + headerAndLineDTO.getIftUrl();
}
}
public Map<String, Object> getFaceUrlHttp(IRequest iRequest, SignInfoHclc info, String token) {
Map<String, Object> map = new HashMap();
String faceApiurl = this.getApiUrl("HCLC_FACE_API", "indivAuthUrl");
this.logger.debug("upload url: {}", faceApiurl);
SignInfoHclcFace signInfoHclcFace = new SignInfoHclcFace();
signInfoHclcFace.setOpenId(info.getOpenId());
signInfoHclcFace.setAuthStatus("NEW");
signInfoHclcFace.setAuthType("1");
signInfoHclcFace = (SignInfoHclcFace)this.signInfoHclcFaceService.insertSelective(iRequest, signInfoHclcFace);
JSONObject json1 = new JSONObject();
json1.put("contextId", signInfoHclcFace.getFaceauthId());
json1.put("notifyUrl", info.getNotifyUrl());
json1.put("redirectUrl", info.getRedirectUrl());
JSONObject json2 = new JSONObject();
json2.put("name", info.getName());
json2.put("certNo", info.getIdNo());
json2.put("mobileNo", info.getMobile());
JSONObject result = new JSONObject();
result.put("authType", "PSN_FACEAUTH_BYURL");
result.put("contextInfo", json1);
result.put("indivInfo", json2);
JSONObject json = new JSONObject(result);
String param = json.toString();
Map<String, String> headInfo = new HashMap();
headInfo.put("X-Tsign-Open-App-Id", info.getAppId());
headInfo.put("X-Tsign-Open-Token", token);
try {
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(faceApiurl, param, headInfo);
net.sf.json.JSONObject jsonResult = net.sf.json.JSONObject.fromObject(stringResult);
if (jsonResult.get("code").toString().equalsIgnoreCase("0")) {
net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(jsonResult.get("data"));
signInfoHclcFace.setFlowId(data.getString("flowId"));
signInfoHclcFace.setUrl(data.getString("url"));
signInfoHclcFace.setShortLink(data.getString("shortLink"));
map.put("code", "0");
map.put("url", data.getString("url"));
map.put("message", "获取url成功!");
} else {
map.put("code", "2");
map.put("message", "获取人脸核身认证地址失败,请检查!");
}
signInfoHclcFace.setReturnCode(jsonResult.get("code").toString());
signInfoHclcFace.setReturnMessage(jsonResult.get("message").toString());
} catch (Exception var17) {
map.put("code", "3");
map.put("message", "访问e签宝人脸核身地址失败,请检查!");
signInfoHclcFace.setReturnCode("3");
signInfoHclcFace.setReturnMessage(var17.getMessage());
}
this.signInfoHclcFaceService.updateByPrimaryKey(iRequest, signInfoHclcFace);
return map;
}
public JSONObject uploadHlsFromWx(IRequest iRequest, AttachmentInfo attachmentInfo) {
JSONObject json = null;
if (Objects.isNull(attachmentInfo.getMediaId())) {
this.logger.error("upload attachment failed, attachmentInfo:{} 关键参数mediaId不存在,调用失败!", JSON.toJSONString(attachmentInfo));
json.put("code", "3");
json.put("message", "关键参数mediaId不存在,调用失败");
return json;
} else {
SignInfoHclc signInfoHclc = new SignInfoHclc();
signInfoHclc.setOpenId(attachmentInfo.getOpenId());
signInfoHclc.setMediaId(attachmentInfo.getMediaId());
signInfoHclc = (SignInfoHclc)this.updateByPrimaryKeySelective(iRequest, signInfoHclc);
try {
String tomcatPath = this.imagePath;
AttachmentInfo downloadInfo = new AttachmentInfo();
downloadInfo.setUploadSysName("wxgzh_hitachics");
downloadInfo.setUploadApiName("media_download");
downloadInfo.setMediaId(attachmentInfo.getMediaId());
tomcatPath = this.downloadFile(downloadInfo, tomcatPath);
if (!tomcatPath.equalsIgnoreCase("-1")) {
SignHclcUtils signHclcUtils = new SignHclcUtils();
json = signHclcUtils.idcard(tomcatPath);
json.put("code", "0");
attachmentInfo.setUserId("admin");
attachmentInfo.setUploadSysName("HCL_UPLOAD_FILE");
attachmentInfo.setUploadApiName("upload");
attachmentInfo.setPkValue(attachmentInfo.getOpenId());
String attchmentId = this.uploadFile(tomcatPath, attachmentInfo);
if (Objects.nonNull(attchmentId)) {
signInfoHclc.setAttachmentId(attchmentId);
this.updateByPrimaryKeySelective(iRequest, signInfoHclc);
}
json.put("attchmentId", attchmentId);
} else {
json.put("code", "1");
json.put("message", "获取服务器图片失败,OCR识别失败");
}
return json;
} catch (Exception var9) {
this.logger.error("upload attachment failed, attachmentInfo:{}", JSON.toJSONString(attachmentInfo), var9);
json.put("code", "2");
json.put("message", var9.getMessage());
return json;
}
}
}
public String downloadFile(AttachmentInfo info, String filePath) throws IOException {
JSONObject parameters = new JSONObject();
parameters.put("apiKey", this.apiKey);
parameters.put("mediaId", info.getMediaId());
String url = this.getApiUrl(info.getUploadSysName(), info.getUploadApiName());
this.logger.debug("upload url: {}", url);
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json");
httpPost.setHeader("Accept", "application/json");
StringEntity se = new StringEntity(parameters.toString(), "utf-8");
se.setContentType("text/json");
httpPost.setEntity(se);
try {
CloseableHttpResponse response = this.httpClient.execute(httpPost);
InputStream inputStream = response.getEntity().getContent();
File file = new File(filePath);
if (!file.exists()) {
file.mkdirs();
}
filePath = filePath + File.separator + info.getFileName();
OutputStream outputStream = new FileOutputStream(filePath);
int len = true;
byte[] bytes = new byte[1024];
int len;
while((len = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, len);
}
outputStream.flush();
outputStream.close();
inputStream.close();
return filePath;
} catch (IOException var13) {
this.logger.error("获取服务器图片失败,msg:{}", var13.getMessage());
var13.printStackTrace();
return "-1";
}
}
public String uploadFile(String filePath, AttachmentInfo info) {
this.logger.debug("params,filePath:{}, attachmentInfo:{}", filePath, JSON.toJSONString(info));
if (filePath != null && info != null && !StringUtils.isBlank(info.getPkValue()) && !StringUtils.isBlank(info.getSourceType())) {
String url = this.getApiUrl(info.getUploadSysName(), info.getUploadApiName());
this.logger.debug("upload url: {}", url);
HttpPost httpPost = new HttpPost(url);
StringBody pkValue = new StringBody(info.getPkValue(), ContentType.MULTIPART_FORM_DATA);
StringBody userId = new StringBody(info.getUserId(), ContentType.MULTIPART_FORM_DATA);
StringBody sourceType = new StringBody(info.getSourceType(), ContentType.MULTIPART_FORM_DATA);
ContentType pdfType = ContentType.create("image/jpeg", Consts.UTF_8);
try {
File file = new File(filePath);
HttpEntity entity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE).addPart("pkvalue", pkValue).addPart("user_id", userId).addPart("source_type", sourceType).addBinaryBody("file", file, pdfType, info.getFileName()).setCharset(CharsetUtils.get("utf-8")).build();
httpPost.setEntity(entity);
CloseableHttpResponse response = this.httpClient.execute(httpPost);
InputStream content = response.getEntity().getContent();
String result = IOUtils.toString(content);
return StringUtils.equals("-1", result) ? null : result;
} catch (IOException var14) {
this.logger.error("upload attachment failed, attachmentInfo:{}", JSON.toJSONString(info), var14);
return null;
}
} else {
return null;
}
}
public Map<String, Object> addPersonAccount(IRequest iRequest, String openId) {
Map<String, Object> map = new HashMap();
SignInfoHclc signInfoHclc = new SignInfoHclc();
signInfoHclc.setOpenId(openId);
signInfoHclc = (SignInfoHclc)this.mapper.selectByPrimaryKey(signInfoHclc);
if (Objects.nonNull(signInfoHclc.getAccountId())) {
this.logger.debug("e签宝用户 accountId: {} 已创建,无需重复创建!", signInfoHclc.getAccountId());
map.put("code", "1");
map.put("message", "e签宝用户已创建,无需重复创建!");
return map;
} else {
JSONObject result = new JSONObject();
result.put("cardNo", "");
result.put("contactsEmail", "");
result.put("contactsMobile", signInfoHclc.getMobile());
result.put("licenseNumber", signInfoHclc.getIdNo());
result.put("licenseType", "IDCard");
result.put("loginEmail", "");
result.put("loginMobile", signInfoHclc.getMobile());
result.put("name", signInfoHclc.getName());
result.put("uniqueId", signInfoHclc.getOpenId());
JSONObject json = new JSONObject(result);
String param = json.toString();
AlgorithmHelper algorithmHelper = new AlgorithmHelper();
String EncryptedString = AlgorithmHelper.getXtimevaleSignature(param, this.projectSecret, "HmacSHA256", "UTF-8");
Map<String, String> headInfo = new HashMap();
headInfo.put("x-timevale-project-id", this.projectId);
headInfo.put("x-timevale-signature", EncryptedString);
try {
String url = this.getApiUrl("HCLC_ELECTRONIC_SIGNATURE", "outerAccounts");
this.logger.debug("upload url: {}", url);
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, param, headInfo);
net.sf.json.JSONObject jsonResult = net.sf.json.JSONObject.fromObject(stringResult);
if (jsonResult.get("errCode").toString().equalsIgnoreCase("0")) {
net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(jsonResult.get("data"));
signInfoHclc.setAccountId(data.getString("accountId"));
map.put("code", "0");
map.put("message", "用户创建成功!");
} else {
this.logger.error("create person account failed, errCode:{} ,msg:{}", jsonResult.get("errCode").toString(), jsonResult.get("msg").toString());
map.put("code", jsonResult.get("errCode").toString());
map.put("message", jsonResult.get("msg").toString());
}
signInfoHclc.setCreateCode(jsonResult.get("code").toString());
signInfoHclc.setCreateMessage(jsonResult.get("message").toString());
} catch (Exception var16) {
this.logger.error("create person account failed, msg:{}", var16.getMessage());
map.put("code", "2");
map.put("message", "用户创建成功失败,请检查!" + var16.getMessage());
signInfoHclc.setCreateCode("2");
signInfoHclc.setCreateMessage(var16.getMessage());
}
this.updateByPrimaryKey(iRequest, signInfoHclc);
return map;
}
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.hand.app.esignHclc.utils;
import com.baidu.aip.ocr.AipOcr;
import com.hand.app.esignHclc.dto.SignInfoHclc;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Map.Entry;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import net.sf.json.JSONObject;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHeader;
public class SignHclcUtils {
public static final String APP_ID = "18653557";
public static final String API_KEY = "VD5jNFLsuBQE4vvjTtQoKQtt";
public static final String SECRET_KEY = "Bx1O0kQ7W9YDprTOaLr2MPcPupsn7w7z";
public SignHclcUtils() {
}
public static SignInfoHclc initProject(SignInfoHclc info, String appId, String secret, String notifyUrl) {
info.setAppId(appId);
info.setSecret(secret);
info.setNotifyUrl(notifyUrl);
return info;
}
public String postString(String urls, String json, Map<String, String> headInfo) {
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(urls);
post.setHeader("Content-Type", "application/json");
String result = "";
try {
StringEntity s = new StringEntity(json, "utf-8");
s.setContentEncoding(new BasicHeader("Content-Type", "application/json"));
if (Objects.nonNull(headInfo)) {
Iterator var8 = headInfo.entrySet().iterator();
while(var8.hasNext()) {
Entry<String, String> entry = (Entry)var8.next();
post.setHeader((String)entry.getKey(), (String)entry.getValue());
}
}
post.setEntity(s);
HttpResponse httpResponse = client.execute(post);
InputStream inStream = httpResponse.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "utf-8"));
StringBuilder strber = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null) {
strber.append(line + "\n");
}
inStream.close();
result = strber.toString();
if (httpResponse.getStatusLine().getStatusCode() == 200) {
System.out.println("请求服务器成功");
} else {
System.out.println("请求服务端失败");
}
return result;
} catch (Exception var13) {
var13.printStackTrace();
throw new RuntimeException(var13);
}
}
public String getJSON(String url) {
try {
URL thisurl = new URL(url);
HttpURLConnection connection = (HttpURLConnection)thisurl.openConnection();
connection.connect();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
StringBuilder sb = new StringBuilder();
String line;
while((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
connection.disconnect();
return sb.toString();
} catch (Exception var7) {
var7.printStackTrace();
return null;
}
}
public String aes(String key, String res) {
try {
KeyGenerator kg = KeyGenerator.getInstance("AES");
byte[] keyBytes = key.getBytes("utf-8");
kg.init(128, new SecureRandom(keyBytes));
SecretKey sk = kg.generateKey();
SecretKeySpec sks = new SecretKeySpec(sk.getEncoded(), "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(1, sks);
byte[] resBytes = res.getBytes("utf-8");
String data = this.parseByte2HexStr(cipher.doFinal(resBytes));
return data;
} catch (Exception var10) {
var10.printStackTrace();
throw new RuntimeException(var10);
}
}
private String parseByte2HexStr(byte[] buf) {
StringBuffer sb = new StringBuffer();
for(int i = 0; i < buf.length; ++i) {
String hex = Integer.toHexString(buf[i] & 255);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
return sb.toString();
}
public String signString(String secKey, String data) {
try {
String srcStr = "secKey=" + secKey + "&data=" + data;
SecretKeySpec keySpec = new SecretKeySpec(secKey.getBytes("UTF-8"), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(keySpec);
byte[] signBytes = mac.doFinal(srcStr.getBytes("UTF-8"));
String appSec = Base64.encodeBase64String(signBytes);
return appSec;
} catch (Exception var8) {
var8.printStackTrace();
throw new RuntimeException(var8);
}
}
public static String getStr(String url, String param) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection();
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.connect();
Map<String, List<String>> map = connection.getHeaderFields();
String line;
for(in = new BufferedReader(new InputStreamReader(connection.getInputStream())); (line = in.readLine()) != null; result = result + line) {
;
}
} catch (Exception var17) {
System.out.println("发送GET请求出现异常!" + var17);
var17.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception var16) {
var16.printStackTrace();
}
}
return result;
}
public String getFaceApiToken(String faceApiUrl, String appId, String secret) {
String token = null;
try {
SignHclcUtils signHclcUtils = new SignHclcUtils();
String param = "appId=" + appId + "&secret=" + secret + "&grantType=client_credentials";
String stringResult = getStr(faceApiUrl, param);
JSONObject json2 = JSONObject.fromObject(stringResult);
if (json2.get("code").toString().equalsIgnoreCase("0")) {
JSONObject data = JSONObject.fromObject(json2.get("data"));
token = data.getString("token");
}
return token;
} catch (Exception var10) {
var10.printStackTrace();
return token;
}
}
public com.alibaba.fastjson.JSONObject idcard(String filePath) {
AipOcr client = new AipOcr("18653557", "VD5jNFLsuBQE4vvjTtQoKQtt", "Bx1O0kQ7W9YDprTOaLr2MPcPupsn7w7z");
HashMap<String, String> options = new HashMap();
options.put("detect_direction", "true");
options.put("detect_risk", "false");
String idCardSide = "front";
org.json.JSONObject res = client.idcard(filePath, idCardSide, options);
System.out.println(res);
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
if (Objects.nonNull(res.get("words_result").toString())) {
com.alibaba.fastjson.JSONObject jsonObjectRes = com.alibaba.fastjson.JSONObject.parseObject(res.get("words_result").toString());
Iterator var8 = jsonObjectRes.keySet().iterator();
while(var8.hasNext()) {
String str = (String)var8.next();
String value = "";
if (!jsonObjectRes.get(str).toString().equalsIgnoreCase("") && Objects.nonNull(jsonObjectRes.get(str).toString())) {
value = com.alibaba.fastjson.JSONObject.parseObject(jsonObjectRes.get(str).toString()).get("words").toString();
jsonObject.put(str, value);
}
}
}
return jsonObject;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package hls.support.core.wechat.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.validator.constraints.Length;
@ExtensionAttribute(
disable = true
)
@Table(
name = "SUN_UPLOAD_RECORD"
)
public class SunUploadRecord extends BaseDTO {
@Id
@GeneratedValue
private Float uploadRecordId;
@Length(
max = 500
)
private String localPath;
@Length(
max = 100
)
private String busiSerialNo;
@Length(
max = 100
)
private String busiStartDate;
@Length(
max = 100
)
private String contentId;
public SunUploadRecord() {
}
public void setUploadRecordId(Float uploadRecordId) {
this.uploadRecordId = uploadRecordId;
}
public Float getUploadRecordId() {
return this.uploadRecordId;
}
public void setLocalPath(String localPath) {
this.localPath = localPath;
}
public String getLocalPath() {
return this.localPath;
}
public void setBusiSerialNo(String busiSerialNo) {
this.busiSerialNo = busiSerialNo;
}
public String getBusiSerialNo() {
return this.busiSerialNo;
}
public void setBusiStartDate(String busiStartDate) {
this.busiStartDate = busiStartDate;
}
public String getBusiStartDate() {
return this.busiStartDate;
}
public void setContentId(String contentId) {
this.contentId = contentId;
}
public String getContentId() {
return this.contentId;
}
}
...@@ -17,6 +17,8 @@ public class AttachmentInfo { ...@@ -17,6 +17,8 @@ public class AttachmentInfo {
private String message; private String message;
private String openId;
public String getWechatCode() { public String getWechatCode() {
return wechatCode; return wechatCode;
} }
...@@ -104,4 +106,12 @@ public class AttachmentInfo { ...@@ -104,4 +106,12 @@ public class AttachmentInfo {
this.message = message; this.message = message;
} }
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
} }
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package hls.support.core.wechat.mapper;
import com.hand.hap.mybatis.common.Mapper;
import hls.support.core.wechat.dto.SunUploadRecord;
public interface SunUploadRecordMapper extends Mapper<SunUploadRecord> {
}
<?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.hand.app.esignHclc.mapper.SignInfoHclcFaceMapper">
<resultMap id="BaseResultMap" type="com.hand.app.esignHclc.dto.SignUserFaceHclc">
<result column="AUTH_ID" property="authId" jdbcType="DECIMAL"/>
<result column="OPEN_ID" property="openId" jdbcType="VARCHAR"/>
<result column="AUTH_STATUS" property="authStatus" jdbcType="VARCHAR"/>
<result column="URL" property="url" jdbcType="VARCHAR"/>
<result column="SHORT_LINK" property="shortLink" jdbcType="VARCHAR"/>
<result column="RETURN_CODE" property="returnCode" jdbcType="VARCHAR"/>
<result column="RETURN_MESSAGE" property="returnMessage" jdbcType="VARCHAR"/>
<result column="FLOW_ID" property="flowId" jdbcType="VARCHAR"/>
<result column="AUTH_TYPE" property="authType" jdbcType="VARCHAR"/>
<result column="VERIFY_CODE" property="verifyCode" jdbcType="VARCHAR"/>
<result column="ENABLE_FLAG" property="enableFlag" jdbcType="VARCHAR"/>
</resultMap>
</mapper>
\ No newline at end of file
<?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.hand.app.esignHclc.mapper.SignInfoHclcMapper">
<resultMap id="BaseResultMap" type="com.hand.app.esignHclc.dto.SignUserInfoHclc">
<result column="OPEN_ID" property="openId" jdbcType="VARCHAR"/>
<result column="ID_NO" property="idNo" jdbcType="VARCHAR"/>
<result column="NAME" property="name" jdbcType="VARCHAR"/>
<result column="MOBILE" property="mobile" jdbcType="VARCHAR"/>
<result column="EMAIL" property="email" jdbcType="VARCHAR"/>
<result column="ACCOUNT_ID" property="accountId" jdbcType="VARCHAR"/>
<result column="CTITYPE" property="ctitype" jdbcType="DECIMAL"/>
<result column="AGENT_TYPE" property="agentType" jdbcType="DECIMAL"/>
<result column="AGENT_ID_NO" property="agentIdNo" jdbcType="VARCHAR"/>
<result column="AGENT_NAME" property="agentName" jdbcType="VARCHAR"/>
<result column="LEGAL_ID_NO" property="legalIdNo" jdbcType="VARCHAR"/>
<result column="LEGAL_NAME" property="legalName" jdbcType="VARCHAR"/>
<result column="ATTACHMENT_ID" property="attachmentId" jdbcType="VARCHAR"/>
<result column="MEDIA_ID" property="mediaId" jdbcType="VARCHAR"/>
<result column="CREATE_CODE" property="createCode" jdbcType="VARCHAR"/>
<result column="CREATE_MESSAGE" property="createMessage" jdbcType="VARCHAR"/>
<result column="AGENT_ACCOUNT_ID" property="agentAccountId" jdbcType="VARCHAR"/>
<result column="FACE_AUTH_ID" property="faceAuthId" jdbcType="DECIMAL"/>
<result column="ORG_AUTH_ID" property="orgAuthId" jdbcType="DECIMAL"/>
<result column="AUTH_ACCOUNT_ID" property="authAccountId" jdbcType="VARCHAR"/>
<result column="AUTH_AGENT_ACCOUNT_ID" property="authAgentAccountId" jdbcType="VARCHAR"/>
<result column="ORG_ATTACHMENT_ID" property="orgAttachmentId" jdbcType="VARCHAR"/>
<result column="AUTH_FLAG" property="authFlag" jdbcType="VARCHAR"/>
</resultMap>
<select id="queryUserInfo" resultMap="BaseResultMap" parameterType="com.hand.app.esignHclc.dto.SignUserInfoHclc">
select *
from SIGN_USER_INFO_HCLC
<where>
<if test="openId != null">
and OPEN_ID = #{openId,jdbcType=DECIMAL}
</if>
<if test="idNo != null">
and ID_NO = #{idNo,jdbcType=VARCHAR}
</if>
<if test="name != null">
and name = #{NAME,jdbcType=VARCHAR}
</if>
<if test="accountId != null">
and nvl(ACCOUNT_ID,'N') = #{accountId,jdbcType=VARCHAR}
</if>
<if test="authFlag != null">
and nvl(AUTH_FLAG,'N') = #{authFlag,jdbcType=VARCHAR}
</if>
</where>
order by account_id
</select>
</mapper>
\ No newline at end of file
<?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.hand.app.esignHclc.mapper.SignUserAttachInfoMapper">
<resultMap id="BaseResultMap" type="com.hand.app.esignHclc.dto.SignUserAttachInfo">
<result column="ATTACHMENT_ID" property="attachmentId" jdbcType="DECIMAL"/>
<result column="OPEN_ID" property="openId" jdbcType="VARCHAR"/>
<result column="ATTACHMENT_TYPE" property="attachmentType" jdbcType="VARCHAR"/>
<result column="MEDIA_ID" property="mediaId" jdbcType="VARCHAR"/>
</resultMap>
</mapper>
\ No newline at end of file
<?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.hand.app.esignHclc.mapper.SignUserInfoHclcHisMapper">
<resultMap id="BaseResultMap" type="com.hand.app.esignHclc.dto.SignUserInfoHclcHis">
<result column="HIS_ID" property="hisId" jdbcType="DECIMAL"/>
<result column="OPEN_ID" property="openId" jdbcType="VARCHAR"/>
<result column="ID_NO" property="idNo" jdbcType="VARCHAR"/>
<result column="NAME" property="name" jdbcType="VARCHAR"/>
<result column="MOBILE" property="mobile" jdbcType="VARCHAR"/>
<result column="EMAIL" property="email" jdbcType="VARCHAR"/>
<result column="TITLE" property="title" jdbcType="VARCHAR"/>
<result column="ADDRESS" property="address" jdbcType="VARCHAR"/>
<result column="ACCOUNT_ID" property="accountId" jdbcType="VARCHAR"/>
<result column="CTITYPE" property="ctitype" jdbcType="DECIMAL"/>
<result column="AGENT_TYPE" property="agentType" jdbcType="DECIMAL"/>
<result column="AGENT_ID_NO" property="agentIdNo" jdbcType="VARCHAR"/>
<result column="AGENT_NAME" property="agentName" jdbcType="VARCHAR"/>
<result column="LEGAL_ID_NO" property="legalIdNo" jdbcType="VARCHAR"/>
<result column="LEGAL_NAME" property="legalName" jdbcType="VARCHAR"/>
<result column="ATTACHMENT_ID" property="attachmentId" jdbcType="DECIMAL"/>
<result column="MEDIA_ID" property="mediaId" jdbcType="VARCHAR"/>
<result column="CREATE_CODE" property="createCode" jdbcType="VARCHAR"/>
<result column="CREATE_MESSAGE" property="createMessage" jdbcType="VARCHAR"/>
<result column="AGENT_ACCOUNT_ID" property="agentAccountId" jdbcType="VARCHAR"/>
<result column="FACE_AUTH_ID" property="faceAuthId" jdbcType="DECIMAL"/>
<result column="ORG_AUTH_ID" property="orgAuthId" jdbcType="DECIMAL"/>
<result column="AUTH_ACCOUNT_ID" property="authAccountId" jdbcType="VARCHAR"/>
<result column="AUTH_AGENT_ACCOUNT_ID" property="authAgentAccountId" jdbcType="VARCHAR"/>
<result column="ORG_ATTACHMENT_ID" property="orgAttachmentId" jdbcType="DECIMAL"/>
<result column="AUTH_FLAG" property="authFlag" jdbcType="VARCHAR"/>
</resultMap>
</mapper>
\ No newline at end of file
...@@ -10,19 +10,19 @@ redis.useSentinel=false ...@@ -10,19 +10,19 @@ redis.useSentinel=false
redis.ip=localhost redis.ip=localhost
redis.port=6379 redis.port=6379
redis.db=10 redis.db=7
#redis.password=123456
db.jndiName=java:comp/env/jdbc/hls_support
db.jndiName=java:comp/env/jdbc/dr_app_dev
# db.type property is used for activiti # db.type property is used for activiti
db.type=mysql #db.type=mysql
#db.type=oracle db.type=oracle
#db.type=mssql
#db.type=hana #db.type=hana
mybatis.identity=JDBC #mybatis.identity=JDBC
#mybatis.identity=SEQUENCE mybatis.identity=SEQUENCE
# environment # environment
env.code=SIT env.code=SIT
...@@ -97,11 +97,10 @@ ureport.fileStoreDir= ...@@ -97,11 +97,10 @@ ureport.fileStoreDir=
wx.token=fdbiabwehuiv wx.token=fdbiabwehuiv
#企业号 #企业号
qy.wx.token=YDQFbrP4wAdA5TTSBxSCKk qy.wx.token=cjndksabebubcjd
qy.wx.encodingAESKey=RuGAoQ7DHt0GdV9OkCLqYbzNBhDbiuuUiUskeltdcYK qy.wx.encodingAESKey=z2W9lyOAR1XjY8mopEmiSqib0TlBZzCFiCLp6IdS2Iv
qy.wx.corpId=ww77bcfe6939a185fe qy.wx.corpId=ww4ca7a88ea2843535
qy.wx.corpSecret=pj0kw409qsMX6DnWF6iUYwhCQOom5oE7B7sAgHazHX4 qy.wx.corpSecret=tE3QJtYf89IsdlF99wZyo_QKEbb7lRFsJuIiuk8YOJ8
## end ## end
...@@ -110,24 +109,29 @@ domain=http://localhost:8070/core/ ...@@ -110,24 +109,29 @@ domain=http://localhost:8070/core/
#set task size #set task size
thread.taskSize = 5 thread.taskSize = 5
markImgPath = C:/Users/����/Desktop/test9.png #esignHclc
tsign.project.id=1000029
#esign dev tsign.project.secret=2e66a86bbc6fa9000d4a5f272cbc70e1
tsign.project.id=1111563517 #e签宝地址
tsign.project.secret=95439b0863c241c63a861b87d1e647b7 tsign.api.url=http://139.196.17.22:8035
tsign.api.url=http://121.40.164.61:8080/tgmonitor/rest/app!getAPIInfo2 #用户认证地址
tsign.face.api.url=https://smlopenapi.esign.cn
#用户认证用户
tsign.face.api.appId=4438798562
#用户认证密码
tsign.face.api.secret=4024c2b5e503a84da6d126fdc6f0da81
#认证结果通知地址
tsign.api.notifyUrl=http://101.133.225.167/core/api/public/listen/auth/result
#微信公众号apiKey
wx.apiKey=handexinxi
#微信公众号接口地址
wx.apiHttpUrl=https://wxgzh.hitachics.com/hcs-public-server/internal/third/
#微信服务器图片保存中台路径
wx.image.path = D:\\app_dev\\apache-tomcat-app\\app_file
#esign
#tsign.project.id=1111565057
#tsign.project.secret=cf74f42ab268ae0b31ba2ee98e84bab5
#tsign.api.url=http://openapi.tsign.cn:8080/tgmonitor/rest/app!getAPIInfo2
#aliyun
aliyun.accessKeyId=LTAI4BKXkUQW1jVY
aliyun.accessKeySecret=TlaBwgHASAshVfPX6jMWgQahx9epse
face.check.enable=false face.check.enable=false
#金格电子合同配置文件地址 #金格电子合同配置文件地址
electronic.signature.path=/Volumes/work/idea/APIconfig electronic.signature.path=/Volumes/work/idea/APIconfig
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<result column="UPLOAD_RECORD_ID" property="uploadRecordId" jdbcType="DECIMAL" /> <result column="UPLOAD_RECORD_ID" property="uploadRecordId" jdbcType="DECIMAL" />
<result column="LOCAL_PATH" property="localPath" jdbcType="VARCHAR" /> <result column="LOCAL_PATH" property="localPath" jdbcType="VARCHAR" />
<result column="BUSI_SERIAL_NO" property="busiSerialNo" jdbcType="VARCHAR" /> <result column="BUSI_SERIAL_NO" property="busiSerialNo" jdbcType="VARCHAR" />
<result column="busi_start_date)" property="busiStartDate)" jdbcType="VARCHAR" /> <result column="busi_start_date" property="busiStartDate" jdbcType="VARCHAR" />
<result column="content_id)" property="contentId)" jdbcType="VARCHAR" /> <result column="content_id" property="contentId" jdbcType="VARCHAR" />
</resultMap> </resultMap>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</appender> --> </appender> -->
<root level="INFO"> <root level="ERROR">
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
<!-- <appender-ref ref="stash" /> --> <!-- <appender-ref ref="stash" /> -->
</root> </root>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment