Commit 5a4e4c3e authored by renjie's avatar renjie

企业认证照片正反面

parent 9ec882e0
......@@ -2,6 +2,9 @@ package com.edgec.browserbackend.account.controller;
import com.edgec.browserbackend.account.domain.*;
import com.edgec.browserbackend.account.dto.*;
import com.edgec.browserbackend.alipay.AlipayConfig;
import com.edgec.browserbackend.alipay.AlipaySubmit;
import com.edgec.browserbackend.alipay.VpsAlipayConfig;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.common.auth.Securitys;
import com.edgec.browserbackend.common.commons.error.ClientRequestException;
......@@ -405,12 +408,15 @@ public class AccountController {
@RequestParam(value = "type", defaultValue = "0") int type,
@RequestParam(value = "companyName") String companyName,
@RequestParam(value = "registerNumber") String registerNumber,
@RequestParam(value = "companyLicense") MultipartFile companyLicense,
@RequestParam(value = "companyLicense_front") MultipartFile companyLicense_front,
@RequestParam(value = "companyLicense_back") MultipartFile companyLicense_back,
@RequestParam(value = "coporationPlace") String coporationPlace,
@RequestParam(value = "coporationLicense") MultipartFile coporationLicense,
@RequestParam(value = "coporationLicense_front") MultipartFile coporationLicense_front,
@RequestParam(value = "coporationLicense_back") MultipartFile coporationLicense_back,
@RequestParam(value = "realController", defaultValue = "0") int realController,
@RequestParam(value = "writePerson", defaultValue = "0") int writePerson,
@RequestParam(value = "agency", required = false) MultipartFile agency) {
@RequestParam(value = "agency_front", required = false) MultipartFile agency_front,
@RequestParam(value = "agency_back", required = false) MultipartFile agency_back) {
ResultDto resultDto = new ResultDto();
try {
CompanyAuthorizeDto companyAuthorizeDto = new CompanyAuthorizeDto();
......@@ -418,19 +424,23 @@ public class AccountController {
companyAuthorizeDto.setType(type);
companyAuthorizeDto.setCompanyName(companyName);
companyAuthorizeDto.setRegisterNumber(registerNumber);
if (companyLicense == null)
if (companyLicense_front == null || companyLicense_back == null)
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
companyAuthorizeDto.setCompanyLicense(companyLicense);
companyAuthorizeDto.setCompanyLicense_front(companyLicense_front);
companyAuthorizeDto.setCompanyLicense_back(companyLicense_back);
companyAuthorizeDto.setCoporationPlace(coporationPlace);
if (coporationLicense == null)
if (coporationLicense_front == null || coporationLicense_back == null)
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
companyAuthorizeDto.setCoporationLicense(coporationLicense);
companyAuthorizeDto.setCoporationLicense_front(coporationLicense_front);
companyAuthorizeDto.setCoporationLicense_back(coporationLicense_back);
companyAuthorizeDto.setRealController(realController);
companyAuthorizeDto.setWritePerson(writePerson);
if (agency != null)
companyAuthorizeDto.setAgency(agency);
if (writePerson == 1 && agency == null)
if (writePerson == 1 && (agency_back == null || agency_back == null))
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
if (agency_front != null && agency_back != null) {
companyAuthorizeDto.setAgency_front(agency_front);
companyAuthorizeDto.setAgency_back(agency_back);
}
accountService.authorizeCompany(principal.getName(), companyAuthorizeDto);
resultDto.setStatus(0);
}catch (ClientRequestException e) {
......@@ -492,4 +502,37 @@ public class AccountController {
return resultDto;
}
@RequestMapping(path = "/alipay/login")
public String save(HttpServletRequest request,HttpServletResponse response) {
Map<String,String> maps = new HashMap<String ,String>();
//页面回调地址 必须与应用中的设置一样
String return_url = "http://localhost/alipay/withdraw";
//回调地址必须经encode
return_url = java.net.URLEncoder.encode(return_url);
//重定向到授权页面
AlipayConfig alipayConfig = new VpsAlipayConfig();
return "redirect:"+ VpsAlipayConfig.ALIPAY_AUTH_URL + "?app_id=" + alipayConfig.getAPPID() + "&scope=auth_user&redirect_uri=" + return_url;
}
@RequestMapping(path = "/alipay/withdraw")
public void alipayWithdraw(HttpServletRequest request, HttpServletResponse response) {
//获取支付宝GET过来反馈信息
Map<String,String> params = new HashMap<String,String>();
Map requestParams = request.getParameterMap();
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
String[] values = (String[]) requestParams.get(name);
String valueStr = "";
for (int i = 0; i < values.length; i++) {
valueStr = (i == (values.length-1)) ? valueStr + values[i]:valueStr + values[i] + ",";
}
params.put(name, valueStr);
}
String accessToken= AlipaySubmit.buildRequest(params);
if(accessToken!=null && accessToken!=""){
String imf = AlipaySubmit.get(accessToken);
System.out.println(imf);
}
}
}
......@@ -12,14 +12,17 @@ public class CompanyAuthorize {
private int type; //0 -- 企业, 1 -- 个体工商户
private String companyName;
private String registerNumber;
private String companyLicenseId;
private String companyLicenseFront;
private String companyLicenseBack;
private String coporationPlace;
private String coporationLicenseId;
private String coporationLicenseFront;
private String coporationLicenseBack;
private int realController;//0 -- 法定代表人, 1 -- 非法定代表人
private int writePerson; //0 -- 法定代表人, 1 -- 代理人
private String agencyId;
private String agencyFront;
private String agencyBack;
public CompanyAuthorize() {
......@@ -73,33 +76,15 @@ public class CompanyAuthorize {
return realController;
}
public void setAgencyId(String agencyId) {
this.agencyId = agencyId;
}
public int getWritePerson() {
return writePerson;
}
public void setCoporationLicenseId(String coporationLicenseId) {
this.coporationLicenseId = coporationLicenseId;
}
public String getAgencyId() {
return agencyId;
}
public void setCoporationPlace(String coporationPlace) {
this.coporationPlace = coporationPlace;
}
public String getCoporationLicenseId() {
return coporationLicenseId;
}
public String getCompanyLicenseId() {
return companyLicenseId;
}
public String getCoporationPlace() {
return coporationPlace;
......@@ -109,19 +94,64 @@ public class CompanyAuthorize {
this.realController = realController;
}
public void setCompanyLicenseId(String companyLicenseId) {
this.companyLicenseId = companyLicenseId;
public void setRegisterNumber(String registerNumber) {
this.registerNumber = registerNumber;
}
public void setWritePerson(int writePerson) {
this.writePerson = writePerson;
}
public String getRegisterNumber() {
return registerNumber;
}
public void setRegisterNumber(String registerNumber) {
this.registerNumber = registerNumber;
public String getAgencyBack() {
return agencyBack;
}
public void setWritePerson(int writePerson) {
this.writePerson = writePerson;
public void setAgencyBack(String agencyBack) {
this.agencyBack = agencyBack;
}
public String getAgencyFront() {
return agencyFront;
}
public void setAgencyFront(String agencyFront) {
this.agencyFront = agencyFront;
}
public String getCompanyLicenseBack() {
return companyLicenseBack;
}
public void setCompanyLicenseBack(String companyLicenseBack) {
this.companyLicenseBack = companyLicenseBack;
}
public String getCompanyLicenseFront() {
return companyLicenseFront;
}
public void setCompanyLicenseFront(String companyLicenseFront) {
this.companyLicenseFront = companyLicenseFront;
}
public String getCoporationLicenseBack() {
return coporationLicenseBack;
}
public void setCoporationLicenseBack(String coporationLicenseBack) {
this.coporationLicenseBack = coporationLicenseBack;
}
public String getCoporationLicenseFront() {
return coporationLicenseFront;
}
public void setCoporationLicenseFront(String coporationLicenseFront) {
this.coporationLicenseFront = coporationLicenseFront;
}
}
......@@ -11,14 +11,17 @@ public class CompanyAuthorizeDto {
private int type; //0 -- 企业, 1 -- 个体工商户
private String companyName;
private String registerNumber;
private MultipartFile companyLicense;
private MultipartFile companyLicense_front;
private MultipartFile companyLicense_back;
private String coporationPlace;
private MultipartFile coporationLicense;
private MultipartFile coporationLicense_front;
private MultipartFile coporationLicense_back;
private int realController;//0 -- 法定代表人, 1 -- 非法定代表人
private int writePerson; //0 -- 法定代表人, 1 -- 代理人
private MultipartFile agency;
private MultipartFile agency_front;
private MultipartFile agency_back;
public CompanyAuthorizeDto() {
......@@ -92,27 +95,51 @@ public class CompanyAuthorizeDto {
this.type = type;
}
public MultipartFile getAgency() {
return agency;
public MultipartFile getAgency_back() {
return agency_back;
}
public void setAgency(MultipartFile agency) {
this.agency = agency;
public void setAgency_back(MultipartFile agency_back) {
this.agency_back = agency_back;
}
public MultipartFile getCoporationLicense() {
return coporationLicense;
public MultipartFile getAgency_front() {
return agency_front;
}
public void setCoporationLicense(MultipartFile coporationLicense) {
this.coporationLicense = coporationLicense;
public void setAgency_front(MultipartFile agency_front) {
this.agency_front = agency_front;
}
public MultipartFile getCompanyLicense() {
return companyLicense;
public MultipartFile getCompanyLicense_back() {
return companyLicense_back;
}
public void setCompanyLicense(MultipartFile companyLicense) {
this.companyLicense = companyLicense;
public void setCompanyLicense_back(MultipartFile companyLicense_back) {
this.companyLicense_back = companyLicense_back;
}
public MultipartFile getCompanyLicense_front() {
return companyLicense_front;
}
public void setCompanyLicense_front(MultipartFile companyLicense_front) {
this.companyLicense_front = companyLicense_front;
}
public MultipartFile getCoporationLicense_front() {
return coporationLicense_front;
}
public void setCoporationLicense_front(MultipartFile coporationLicense_front) {
this.coporationLicense_front = coporationLicense_front;
}
public MultipartFile getCoporationLicense_back() {
return coporationLicense_back;
}
public void setCoporationLicense_back(MultipartFile coporationLicense_back) {
this.coporationLicense_back = coporationLicense_back;
}
}
......@@ -1047,9 +1047,12 @@ public class AccountServiceImpl implements AccountService {
@Override
public void authorizeCompany(String username, CompanyAuthorizeDto companyAuthorizeDto) {
String companyLicenseId = null;
String coporationLicenseId = null;
String agencyId = null;
String companyLicenseFront = null;
String companyLicenseBack = null;
String coporationLicenseFront = null;
String coporationLicenseBack = null;
String agencyFront = null;
String agencyBack = null;
CompanyAuthorize existing = companyAuthorizeRepository.findByUsername(username);
if (existing != null) {
throw new ClientRequestException(BrowserErrorCode.COMPANYAUTHORIZEEXIST);
......@@ -1058,29 +1061,41 @@ public class AccountServiceImpl implements AccountService {
Account account = repository.findByName(username);
if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
String companyLicenseName = "companyLicense-" + username;
companyLicenseId = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getCompanyLicense(), companyLicenseName);
String coporationLicenseName = "coporationLicense-" + username;
coporationLicenseId = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getCoporationLicense(), coporationLicenseName);
if (companyAuthorizeDto.getAgency() != null) {
String agencyName = "agencyLicense-" + username;
agencyId = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getAgency(), agencyName);
}
companyLicenseFront = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getCompanyLicense_front(), "companyLicense-front-" + username);
companyLicenseBack = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getCompanyLicense_back(), "companyLicense-back-" + username);
companyLicenseFront = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getCoporationLicense_front(), "coporationLicense-front-" + username);
companyLicenseBack = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getCoporationLicense_back(), "coporationLicense-back-" + username);
if (companyAuthorizeDto.getAgency_front() != null && companyAuthorizeDto.getAgency_back() != null) {
agencyFront = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getAgency_front(), "agency-front-" + username);
agencyBack = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getAgency_back(), "agency-back-" + username);
} else
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
CompanyAuthorize companyAuthorize = new CompanyAuthorize(companyAuthorizeDto);
companyAuthorize.setUsername(username);
companyAuthorize.setCompanyLicenseId(companyLicenseId);
companyAuthorize.setCoporationLicenseId(coporationLicenseId);
if (agencyId != null)
companyAuthorize.setAgencyId(agencyId);
companyAuthorize.setCompanyLicenseFront(companyLicenseFront);
companyAuthorize.setCompanyLicenseBack(companyLicenseBack);
companyAuthorize.setCoporationLicenseFront(coporationLicenseFront);
companyAuthorize.setCoporationLicenseBack(coporationLicenseBack);
if (agencyFront != null && agencyBack != null) {
companyAuthorize.setAgencyFront(agencyFront);
companyAuthorize.setAgencyBack(agencyBack);
}
companyAuthorizeRepository.save(companyAuthorize);
} catch (Exception e) {
if (agencyId != null)
companyAuthorizeRepository.deleteFile(agencyId);
if (coporationLicenseId != null)
companyAuthorizeRepository.deleteFile(coporationLicenseId);
if (companyLicenseId != null)
companyAuthorizeRepository.deleteFile(companyLicenseId);
if (agencyBack != null)
companyAuthorizeRepository.deleteFile(agencyBack);
if (agencyFront != null)
companyAuthorizeRepository.deleteFile(agencyFront);
if (coporationLicenseBack != null)
companyAuthorizeRepository.deleteFile(coporationLicenseBack);
if (coporationLicenseFront != null)
companyAuthorizeRepository.deleteFile(coporationLicenseFront);
if (companyLicenseBack != null)
companyAuthorizeRepository.deleteFile(companyLicenseBack);
if (companyLicenseFront != null)
companyAuthorizeRepository.deleteFile(companyLicenseFront);
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
}
......@@ -1100,17 +1115,24 @@ public class AccountServiceImpl implements AccountService {
CompanyAuthorize companyAuthorize = companyAuthorizeRepository.findByUsername(username);
if (companyAuthorize == null)
return null;
File companyLicense = companyAuthorizeRepository.getFile(companyAuthorize.getCompanyLicenseId());
File companyLicense_Front = companyAuthorizeRepository.getFile(companyAuthorize.getCompanyLicenseFront());
File companyLicense_Back = companyAuthorizeRepository.getFile(companyAuthorize.getCompanyLicenseBack());
log.error("3");
File coporationLicense = companyAuthorizeRepository.getFile(companyAuthorize.getCoporationLicenseId());
File agencyLicense = null;
if (companyAuthorize.getAgencyId() != null)
agencyLicense = companyAuthorizeRepository.getFile(companyAuthorize.getAgencyId());
File coporationLicense_Front = companyAuthorizeRepository.getFile(companyAuthorize.getCoporationLicenseFront());
File coporationLicense_Back = companyAuthorizeRepository.getFile(companyAuthorize.getCoporationLicenseBack());
File agencyLicense_Front = null;
File agencyLicense_Back = null;
if (companyAuthorize.getAgencyFront() != null)
agencyLicense_Front = companyAuthorizeRepository.getFile(companyAuthorize.getAgencyFront());
if (companyAuthorize.getAgencyBack() != null)
agencyLicense_Back = companyAuthorizeRepository.getFile(companyAuthorize.getAgencyBack());
try {
File tempFile = File.createTempFile("tempFile", "zip");
List<File> files = Arrays.asList(companyLicense, coporationLicense);
if (agencyLicense != null)
files.add(agencyLicense);
List<File> files = Arrays.asList(companyLicense_Front, companyLicense_Back, coporationLicense_Front, coporationLicense_Back);
if (agencyLicense_Front != null)
files.add(agencyLicense_Front);
if (agencyLicense_Back != null)
files.add(agencyLicense_Back);
tempFile = FileUtil.putBatchFilesInZip(files, tempFile);
return tempFile;
} catch (Exception e) {
......
......@@ -28,6 +28,8 @@ public abstract class AlipayConfig {
public static String RETURN_URL_BROWSER = "https://www.fangguanlian.cn/home/paySuccess.html?alipayreturn=";
public static String ALIPAY_AUTH_URL = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm";
public abstract String getSIGN_TYPE();
......
package com.edgec.browserbackend.alipay;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.request.AlipayUserInfoShareRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.alipay.api.response.AlipayUserInfoShareResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
public class AlipaySubmit {
private final static Logger logger = LoggerFactory.getLogger(AlipaySubmit.class);
/**
* 获取AccessToken
* @param sParaTemp
* @return
*/
public static String buildRequest(Map sParaTemp){
AlipayConfig alipayConfig = new VpsAlipayConfig();
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", alipayConfig.getAPPID(),
alipayConfig.getAPP_PRIVATE_KEY(), "json", alipayConfig.getCHARSET(), alipayConfig.getALIPAY_PUBLIC_KEY(), "RSA2");
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setCode((String)sParaTemp.get("auth_code"));
request.setGrantType("authorization_code");
try {
AlipaySystemOauthTokenResponse oauthTokenResponse = alipayClient.execute(request);
logger.error(oauthTokenResponse.getAccessToken());
return oauthTokenResponse.getAccessToken();
} catch (AlipayApiException e) {
//处理异常
e.printStackTrace();
}
return null;
}
/**
* 获取用户信息
* @param accessToken
* @return
*/
public static String get(String accessToken){
AlipayConfig alipayConfig = new VpsAlipayConfig();
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", alipayConfig.getAPPID(),
alipayConfig.getAPP_PRIVATE_KEY(), "json", alipayConfig.getCHARSET(), alipayConfig.getALIPAY_PUBLIC_KEY(), "RSA2");
AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();
try {
AlipayUserInfoShareResponse userinfoShareResponse = alipayClient.execute(request, accessToken);
return userinfoShareResponse.getBody();
} catch (AlipayApiException e) {
//处理异常
e.printStackTrace();
}
return null;
}
}
\ No newline at end of file
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