# Conflicts: # hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java # hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.javamaster
parent
37f768ac18
commit
54e0b04eb6
@ -0,0 +1,279 @@ |
||||
package com.bweb.controller.Etc; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.config.EtcService; |
||||
import com.hai.entity.*; |
||||
import com.hai.etc.EtcCarMsgService; |
||||
import com.hai.etc.EtcCustMsgService; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@RestController |
||||
@RequestMapping(value="/etcCustomer") |
||||
@Api(value="etc客户信息") |
||||
public class EtcCustomerController { |
||||
|
||||
Logger log = LoggerFactory.getLogger(EtcCustomerController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private EtcCustMsgService etcCustMsgService; |
||||
|
||||
@Resource |
||||
private EtcCarMsgService etcCarMsgService; |
||||
|
||||
@RequestMapping(value = "/getEtcCustList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询用户列表") |
||||
public ResponseData getEtcCustList( |
||||
@RequestParam(value = "custName", required = false) String custName, |
||||
@RequestParam(value = "phone", required = false) String phone, HttpServletRequest request |
||||
) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
Map<String, Object> map = new HashMap<>(5); |
||||
|
||||
map.put("userId", userInfoModel.getSecUser().getId()); |
||||
map.put("custName", custName); |
||||
map.put("phone", phone); |
||||
|
||||
return ResponseMsgUtil.success(etcCustMsgService.getEtcCustList(map)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsMsgController --> getMsgByList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@RequestMapping(value = "insertCustomer" , method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "新增客户基本信息") |
||||
public ResponseData insertCustomer(@RequestBody EtcCustMsg etcCustMsg , HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
if (etcCustMsg == null |
||||
|| etcCustMsg.getPhone() == null |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
etcCustMsg.setUserId(userInfoModel.getSecUser().getId()); |
||||
etcCustMsg.setUserName(userInfoModel.getSecUser().getUserName()); |
||||
etcCustMsg.setCreateTime(new Date()); |
||||
etcCustMsg.setUpdateTime(new Date()); |
||||
etcCustMsg.setStatus(0); |
||||
|
||||
etcCustMsgService.insertEtcCust(etcCustMsg); |
||||
return ResponseMsgUtil.success("成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsMsgController --> insertMsg() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/findByCustomer", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询详情") |
||||
public ResponseData findByCustomer(@RequestParam(value = "id", required = true) Long id) { |
||||
try { |
||||
return ResponseMsgUtil.success(etcCustMsgService.findEtcCustById(id)); |
||||
} catch (Exception e) { |
||||
log.error("HighUserController --> findByUserId() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@RequestMapping(value = "editCustomer" , method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "编辑客户基本信息") |
||||
public ResponseData editCustomer(@RequestBody EtcCustMsg etcCustMsg , HttpServletRequest request) { |
||||
try { |
||||
|
||||
if (etcCustMsg == null |
||||
|| etcCustMsg.getBankPhone() == null |
||||
|| etcCustMsg.getAccountNo() == null |
||||
|| etcCustMsg.getAddress() == null |
||||
|| etcCustMsg.getCustAgentIdBront() == null |
||||
|| etcCustMsg.getCustAgentIdFront() == null |
||||
|| etcCustMsg.getBankCard() == null |
||||
|| etcCustMsg.getBankName() == null |
||||
|| etcCustMsg.getCustIdNo() == null |
||||
|| etcCustMsg.getCustName() == null |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
etcCustMsg.setUpdateTime(new Date()); |
||||
|
||||
etcCustMsgService.updateEtcCust(etcCustMsg); |
||||
return ResponseMsgUtil.success("成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsMsgController --> insertMsg() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "editCarMsg" , method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "编辑基本信息") |
||||
public ResponseData editCarMsg(@RequestBody EtcCarMsg etcCarMsg , HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
if (etcCarMsg == null |
||||
|| etcCarMsg.getCustId() == null |
||||
|| etcCarMsg.getProductId() == null |
||||
|| etcCarMsg.getCardVarietyId() == null |
||||
|| etcCarMsg.getVehPlateNo() == null |
||||
|| etcCarMsg.getVehPlateColor() == null |
||||
|| etcCarMsg.getVehType() == null |
||||
|| etcCarMsg.getAxlesNum() == null |
||||
|| etcCarMsg.getWheelsNum() == null |
||||
|| etcCarMsg.getDrivlicMainFro() == null |
||||
|| etcCarMsg.getDrivlicSubFro() == null |
||||
|| etcCarMsg.getHeadStockPhoto() == null |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
etcCarMsg.setUserId(userInfoModel.getSecUser().getId()); |
||||
etcCarMsg.setUserName(userInfoModel.getSecUser().getUserName()); |
||||
|
||||
etcCarMsg.setUpdateTime(new Date()); |
||||
etcCarMsg.setVehStatus(11); |
||||
|
||||
etcCarMsgService.insertEtcCar(etcCarMsg); |
||||
return ResponseMsgUtil.success("成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsMsgController --> insertMsg() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getEtcCarMsgList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询车辆列表") |
||||
public ResponseData getEtcCarMsgList( |
||||
@RequestParam(value = "vehPlateNo", required = false) String vehPlateNo, HttpServletRequest request |
||||
) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
Map<String, Object> map = new HashMap<>(5); |
||||
|
||||
map.put("userId", userInfoModel.getSecUser().getId()); |
||||
map.put("vehPlateNo", vehPlateNo); |
||||
|
||||
return ResponseMsgUtil.success(etcCarMsgService.getEtcCarList(map)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsMsgController --> getMsgByList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/sendRealNameCode", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "请求实名认证") |
||||
public ResponseData sendRealNameCode(@RequestParam(value = "id", required = true) Long id) { |
||||
try { |
||||
|
||||
EtcCustMsg etcCustMsg = etcCustMsgService.findEtcCustById(id); |
||||
|
||||
if (etcCustMsg == null || etcCustMsg.getCustId() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "状态错误!"); |
||||
} |
||||
|
||||
JSONObject object = EtcService.sendRealNameCode(etcCustMsg.getCustId()); |
||||
|
||||
if (object.getString("errCode").equals("0")) { |
||||
return ResponseMsgUtil.success("请求成功!"); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(object.getString("errMsg")); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighUserController --> findByUserId() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/checkRealNameCode", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "验证实名认证编码") |
||||
public ResponseData checkRealNameCode(@RequestParam(value = "id", required = true) Long id , |
||||
@RequestParam(value = "verifyCode", required = true) String verifyCode ) { |
||||
try { |
||||
|
||||
EtcCustMsg etcCustMsg = etcCustMsgService.findEtcCustById(id); |
||||
|
||||
if (etcCustMsg == null || etcCustMsg.getCustId() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "状态错误!"); |
||||
} |
||||
|
||||
JSONObject object = EtcService.checkRealNameCode(etcCustMsg.getCustId() , verifyCode); |
||||
|
||||
if (object.getString("errCode").equals("0")) { |
||||
return ResponseMsgUtil.success("请求成功!"); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(object.getString("errMsg")); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighUserController --> findByUserId() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/findByCarMsg", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询详情") |
||||
public ResponseData findByCarMsg(@RequestParam(value = "id", required = true) Long id) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(etcCarMsgService.findEtcCarById(id)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighUserController --> findByUserId() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,78 @@ |
||||
package com.bweb.controller.Etc; |
||||
|
||||
|
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.config.CommonSysConst; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.ocr.AliYunOcrService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/ocr") |
||||
@Api(value = "ocr识别") |
||||
public class OcrController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(OcrController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@RequestMapping(value="/recognizeIdCard",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "身份证识别") |
||||
public ResponseData recognizeIdCard(@RequestParam(name = "url", required = true) String url) { |
||||
try { |
||||
return ResponseMsgUtil.success(AliYunOcrService.recognizeIdCard(CommonSysConst.getSysConfig().getFilesystem()+ url)); |
||||
} catch (Exception e) { |
||||
log.error("recognizeIdCard error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/recognizeBankCard",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "银行卡识别") |
||||
public ResponseData recognizeBankCard(@RequestParam(name = "url", required = true) String url) { |
||||
try { |
||||
return ResponseMsgUtil.success(AliYunOcrService.recognizeBankCard(CommonSysConst.getSysConfig().getFilesystem()+ url)); |
||||
} catch (Exception e) { |
||||
log.error("recognizeBankCard error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/recognizeBankAccount",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "银行开户许可证识别") |
||||
public ResponseData recognizeBankAccount(@RequestParam(name = "url", required = true) String url) { |
||||
try { |
||||
return ResponseMsgUtil.success(AliYunOcrService.recognizeBankAccount(CommonSysConst.getSysConfig().getFilesystem()+ url)); |
||||
} catch (Exception e) { |
||||
log.error("recognizeBankCard error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/recognizeBusinessLicense",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "营业执照识别") |
||||
public ResponseData recognizeBusinessLicense(@RequestParam(name = "url", required = true) String url) { |
||||
try { |
||||
return ResponseMsgUtil.success(AliYunOcrService.recognizeBusinessLicense(CommonSysConst.getSysConfig().getFilesystem()+ url)); |
||||
} catch (Exception e) { |
||||
log.error("recognizeBusinessLicense error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,462 @@ |
||||
package com.hai.common.utils; |
||||
|
||||
import org.apache.commons.lang3.ArrayUtils; |
||||
import sun.misc.BASE64Decoder; |
||||
import sun.misc.BASE64Encoder; |
||||
|
||||
import javax.crypto.Cipher; |
||||
import java.security.*; |
||||
import java.security.interfaces.RSAPrivateKey; |
||||
import java.security.spec.PKCS8EncodedKeySpec; |
||||
import java.security.spec.X509EncodedKeySpec; |
||||
|
||||
|
||||
/** |
||||
* @Description RSAUtil |
||||
* @Author aili |
||||
**/ |
||||
public class RSAUtil { |
||||
|
||||
public static final String KEY_ALGORTHM = "RSA"; |
||||
public static final String SIGNATURE_ALGORITHM = "MD5withRSA"; |
||||
private static final int MAX_ENCRYPT_BLOCK = 117; |
||||
/** |
||||
* 用公钥加密 |
||||
* |
||||
* @param data 加密数据 |
||||
* @param key 密钥 |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static byte[] encryptByPublicKey(byte[] data, String key) throws Exception { |
||||
//对公钥解密
|
||||
byte[] keyBytes = decryptBASE64(key); |
||||
//取公钥
|
||||
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(keyBytes); |
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORTHM); |
||||
Key publicKey = keyFactory.generatePublic(x509EncodedKeySpec); |
||||
|
||||
//对数据解密
|
||||
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm()); |
||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey); |
||||
//return cipher.doFinal(data);
|
||||
|
||||
byte[] enBytes = null; |
||||
for (int i = 0; i < data.length; i += MAX_ENCRYPT_BLOCK) { |
||||
// 注意要使用2的倍数,否则会出现加密后的内容再解密时为乱码
|
||||
byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(data, i, i + MAX_ENCRYPT_BLOCK)); |
||||
enBytes = ArrayUtils.addAll(enBytes, doFinal); |
||||
} |
||||
return enBytes; |
||||
} |
||||
|
||||
/** |
||||
* 用私钥对信息生成数字签名 |
||||
* |
||||
* @param data //加密数据
|
||||
* @param privateKey //私钥
|
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String sign(byte[] data, String privateKey) throws Exception { |
||||
//解密私钥
|
||||
byte[] keyBytes = decryptBASE64(privateKey); |
||||
//构造PKCS8EncodedKeySpec对象
|
||||
PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(keyBytes); |
||||
//指定加密算法
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORTHM); |
||||
//取私钥匙对象
|
||||
PrivateKey privateKey2 = keyFactory.generatePrivate(pkcs8EncodedKeySpec); |
||||
//用私钥对信息生成数字签名
|
||||
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM); |
||||
signature.initSign(privateKey2); |
||||
signature.update(data); |
||||
|
||||
return encryptBASE64(signature.sign()); |
||||
} |
||||
|
||||
/** |
||||
* 私钥解密 |
||||
* @param str |
||||
* @param key |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String decryptByPrivate(String str, String key) throws Exception{ |
||||
//64位解码加密后的字符串
|
||||
byte[] inputByte = decryptBASE64(str); |
||||
//base64编码的私钥
|
||||
byte[] decoded = decryptBASE64(key); |
||||
RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded)); |
||||
//RSA解密
|
||||
Cipher cipher = Cipher.getInstance("RSA"); |
||||
cipher.init(Cipher.DECRYPT_MODE, priKey); |
||||
String outStr = new String(cipher.doFinal(inputByte)); |
||||
return outStr; |
||||
} |
||||
|
||||
/** |
||||
* BASE64解密 |
||||
* |
||||
* @param key |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static byte[] decryptBASE64(String key) throws Exception { |
||||
return (new BASE64Decoder()).decodeBuffer(key); |
||||
} |
||||
|
||||
/** |
||||
* BASE64加密 |
||||
* |
||||
* @param key |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String encryptBASE64(byte[] key) throws Exception { |
||||
return (new BASE64Encoder()).encodeBuffer(key); |
||||
} |
||||
|
||||
/** |
||||
* 解密动态核销码 dynamicCode |
||||
* @param data |
||||
* @param key |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String decryptByPrivateKey(String data, String key) throws Exception { |
||||
//对私钥解密
|
||||
byte[] keyBytes = decryptBASE64(key); |
||||
//64位解码加密后的字符串
|
||||
byte[] inputByte = decryptBASE64(data); |
||||
PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(keyBytes); |
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORTHM); |
||||
Key privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec); |
||||
//对数据解密
|
||||
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm()); |
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey); |
||||
int decryptBlock = 1024 / 8; |
||||
byte[] deBytes = null; |
||||
for (int i = 0; i < inputByte.length; i += decryptBlock) { |
||||
byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(inputByte, i, i + decryptBlock)); |
||||
deBytes = ArrayUtils.addAll(deBytes, doFinal); |
||||
} |
||||
return new String(deBytes); |
||||
} |
||||
/** |
||||
* 校验数字签名 |
||||
* |
||||
* @param data 加密数据 |
||||
* @param publicKey 公钥 |
||||
* @param sign 数字签名 |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static boolean verify(byte[] data, String publicKey, String sign) throws Exception { |
||||
//解密公钥
|
||||
byte[] keyBytes = decryptBASE64(publicKey); |
||||
//构造PKCS8EncodedKeySpec对象
|
||||
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(keyBytes); |
||||
//指定加密算法
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORTHM); |
||||
//取公钥匙对象
|
||||
PublicKey publicKey2 = keyFactory.generatePublic(x509EncodedKeySpec); |
||||
|
||||
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM); |
||||
signature.initVerify(publicKey2); |
||||
signature.update(data); |
||||
//验证签名是否正常
|
||||
return signature.verify(decryptBASE64(sign)); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Base64 编码和解码 |
||||
*/ |
||||
static class Base64 { |
||||
|
||||
static private final int BASELENGTH = 128; |
||||
static private final int LOOKUPLENGTH = 64; |
||||
static private final int TWENTYFOURBITGROUP = 24; |
||||
static private final int EIGHTBIT = 8; |
||||
static private final int SIXTEENBIT = 16; |
||||
static private final int FOURBYTE = 4; |
||||
static private final int SIGN = -128; |
||||
static private final char PAD = '='; |
||||
static private final boolean fDebug = false; |
||||
static final private byte[] base64Alphabet = new byte[BASELENGTH]; |
||||
static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH]; |
||||
|
||||
static { |
||||
for (int i = 0; i < BASELENGTH; ++i) { |
||||
base64Alphabet[i] = -1; |
||||
} |
||||
for (int i = 'Z'; i >= 'A'; i--) { |
||||
base64Alphabet[i] = (byte) (i - 'A'); |
||||
} |
||||
for (int i = 'z'; i >= 'a'; i--) { |
||||
base64Alphabet[i] = (byte) (i - 'a' + 26); |
||||
} |
||||
|
||||
for (int i = '9'; i >= '0'; i--) { |
||||
base64Alphabet[i] = (byte) (i - '0' + 52); |
||||
} |
||||
|
||||
base64Alphabet['+'] = 62; |
||||
base64Alphabet['/'] = 63; |
||||
|
||||
for (int i = 0; i <= 25; i++) { |
||||
lookUpBase64Alphabet[i] = (char) ('A' + i); |
||||
} |
||||
|
||||
for (int i = 26, j = 0; i <= 51; i++, j++) { |
||||
lookUpBase64Alphabet[i] = (char) ('a' + j); |
||||
} |
||||
|
||||
for (int i = 52, j = 0; i <= 61; i++, j++) { |
||||
lookUpBase64Alphabet[i] = (char) ('0' + j); |
||||
} |
||||
lookUpBase64Alphabet[62] = (char) '+'; |
||||
lookUpBase64Alphabet[63] = (char) '/'; |
||||
|
||||
} |
||||
|
||||
private static boolean isWhiteSpace(char octect) { |
||||
return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9); |
||||
} |
||||
|
||||
private static boolean isPad(char octect) { |
||||
return (octect == PAD); |
||||
} |
||||
|
||||
private static boolean isData(char octect) { |
||||
return (octect < BASELENGTH && base64Alphabet[octect] != -1); |
||||
} |
||||
|
||||
/** |
||||
* Encodes hex octects into Base64 |
||||
* |
||||
* @param binaryData Array containing binaryData |
||||
* @return Encoded Base64 array |
||||
*/ |
||||
public static String encode(byte[] binaryData) { |
||||
|
||||
if (binaryData == null) { |
||||
return null; |
||||
} |
||||
|
||||
int lengthDataBits = binaryData.length * EIGHTBIT; |
||||
if (lengthDataBits == 0) { |
||||
return ""; |
||||
} |
||||
|
||||
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; |
||||
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP; |
||||
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets; |
||||
char encodedData[] = null; |
||||
|
||||
encodedData = new char[numberQuartet * 4]; |
||||
|
||||
byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0; |
||||
|
||||
int encodedIndex = 0; |
||||
int dataIndex = 0; |
||||
if (fDebug) { |
||||
System.out.println("number of triplets = " + numberTriplets); |
||||
} |
||||
|
||||
for (int i = 0; i < numberTriplets; i++) { |
||||
b1 = binaryData[dataIndex++]; |
||||
b2 = binaryData[dataIndex++]; |
||||
b3 = binaryData[dataIndex++]; |
||||
|
||||
if (fDebug) { |
||||
System.out.println("b1= " + b1 + ", b2= " + b2 + ", b3= " + b3); |
||||
} |
||||
|
||||
l = (byte) (b2 & 0x0f); |
||||
k = (byte) (b1 & 0x03); |
||||
|
||||
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); |
||||
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); |
||||
byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc); |
||||
|
||||
if (fDebug) { |
||||
System.out.println("val2 = " + val2); |
||||
System.out.println("k4 = " + (k << 4)); |
||||
System.out.println("vak = " + (val2 | (k << 4))); |
||||
} |
||||
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; |
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)]; |
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3]; |
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f]; |
||||
} |
||||
|
||||
// form integral number of 6-bit groups
|
||||
if (fewerThan24bits == EIGHTBIT) { |
||||
b1 = binaryData[dataIndex]; |
||||
k = (byte) (b1 & 0x03); |
||||
if (fDebug) { |
||||
System.out.println("b1=" + b1); |
||||
System.out.println("b1<<2 = " + (b1 >> 2)); |
||||
} |
||||
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); |
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; |
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4]; |
||||
encodedData[encodedIndex++] = PAD; |
||||
encodedData[encodedIndex++] = PAD; |
||||
} else if (fewerThan24bits == SIXTEENBIT) { |
||||
b1 = binaryData[dataIndex]; |
||||
b2 = binaryData[dataIndex + 1]; |
||||
l = (byte) (b2 & 0x0f); |
||||
k = (byte) (b1 & 0x03); |
||||
|
||||
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); |
||||
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); |
||||
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; |
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)]; |
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2]; |
||||
encodedData[encodedIndex++] = PAD; |
||||
} |
||||
|
||||
return new String(encodedData); |
||||
} |
||||
|
||||
/** |
||||
* Decodes Base64 data into octects |
||||
* |
||||
* @param encoded string containing Base64 data |
||||
* @return Array containind decoded data. |
||||
*/ |
||||
public static byte[] decode(String encoded) { |
||||
|
||||
if (encoded == null) { |
||||
return null; |
||||
} |
||||
|
||||
char[] base64Data = encoded.toCharArray(); |
||||
// remove white spaces
|
||||
int len = removeWhiteSpace(base64Data); |
||||
|
||||
if (len % FOURBYTE != 0) { |
||||
return null;//should be divisible by four
|
||||
} |
||||
|
||||
int numberQuadruple = (len / FOURBYTE); |
||||
|
||||
if (numberQuadruple == 0) { |
||||
return new byte[0]; |
||||
} |
||||
|
||||
byte decodedData[] = null; |
||||
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0; |
||||
char d1 = 0, d2 = 0, d3 = 0, d4 = 0; |
||||
|
||||
int i = 0; |
||||
int encodedIndex = 0; |
||||
int dataIndex = 0; |
||||
decodedData = new byte[(numberQuadruple) * 3]; |
||||
|
||||
for (; i < numberQuadruple - 1; i++) { |
||||
|
||||
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])) |
||||
|| !isData((d3 = base64Data[dataIndex++])) |
||||
|| !isData((d4 = base64Data[dataIndex++]))) { |
||||
return null; |
||||
}//if found "no data" just return null
|
||||
|
||||
b1 = base64Alphabet[d1]; |
||||
b2 = base64Alphabet[d2]; |
||||
b3 = base64Alphabet[d3]; |
||||
b4 = base64Alphabet[d4]; |
||||
|
||||
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); |
||||
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); |
||||
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); |
||||
} |
||||
|
||||
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) { |
||||
return null;//if found "no data" just return null
|
||||
} |
||||
|
||||
b1 = base64Alphabet[d1]; |
||||
b2 = base64Alphabet[d2]; |
||||
|
||||
d3 = base64Data[dataIndex++]; |
||||
d4 = base64Data[dataIndex++]; |
||||
if (!isData((d3)) || !isData((d4))) {//Check if they are PAD characters
|
||||
if (isPad(d3) && isPad(d4)) { |
||||
if ((b2 & 0xf) != 0)//last 4 bits should be zero
|
||||
{ |
||||
return null; |
||||
} |
||||
byte[] tmp = new byte[i * 3 + 1]; |
||||
System.arraycopy(decodedData, 0, tmp, 0, i * 3); |
||||
tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4); |
||||
return tmp; |
||||
} else if (!isPad(d3) && isPad(d4)) { |
||||
b3 = base64Alphabet[d3]; |
||||
if ((b3 & 0x3) != 0)//last 2 bits should be zero
|
||||
{ |
||||
return null; |
||||
} |
||||
byte[] tmp = new byte[i * 3 + 2]; |
||||
System.arraycopy(decodedData, 0, tmp, 0, i * 3); |
||||
tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); |
||||
tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); |
||||
return tmp; |
||||
} else { |
||||
return null; |
||||
} |
||||
} else { //No PAD e.g 3cQl
|
||||
b3 = base64Alphabet[d3]; |
||||
b4 = base64Alphabet[d4]; |
||||
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); |
||||
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); |
||||
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); |
||||
|
||||
} |
||||
|
||||
return decodedData; |
||||
} |
||||
|
||||
/** |
||||
* remove WhiteSpace from MIME containing encoded Base64 data. |
||||
* |
||||
* @param data the byte array of base64 data (with WS) |
||||
* @return the new length |
||||
*/ |
||||
private static int removeWhiteSpace(char[] data) { |
||||
if (data == null) { |
||||
return 0; |
||||
} |
||||
|
||||
// count characters that's not whitespace
|
||||
int newSize = 0; |
||||
int len = data.length; |
||||
for (int i = 0; i < len; i++) { |
||||
if (!isWhiteSpace(data[i])) { |
||||
data[newSize++] = data[i]; |
||||
} |
||||
} |
||||
return newSize; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,236 @@ |
||||
package com.hai.config; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.common.utils.HttpsUtils; |
||||
import com.hai.common.utils.WxUtils; |
||||
import com.hai.entity.EtcCarMsg; |
||||
import com.hai.entity.EtcCustMsg; |
||||
import org.apache.commons.codec.digest.DigestUtils; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import java.nio.file.Files; |
||||
import java.nio.file.Path; |
||||
import java.nio.file.Paths; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @serviceName QrCodeUtilsConfig.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // Etc申请管理
|
||||
* @createTime 09:54 2022/4/13 |
||||
**/ |
||||
@Configuration |
||||
public class EtcService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name submitCustInfo |
||||
* @Description // 客户信息提交
|
||||
* @Date 16:31 2024/3/25 |
||||
* @Param etcCustMsg |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject submitCustInfo(EtcCustMsg etcCustMsg) throws Exception { |
||||
// 组装数据
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("orgCode" , CommonSysConst.getSysConfig().getNdOrgCode()); |
||||
map.put("timestamps", System.currentTimeMillis()); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("custName" , etcCustMsg.getCustName()); |
||||
jsonObject.put("custIdNo" , etcCustMsg.getCustIdNo()); |
||||
jsonObject.put("accountNo" , etcCustMsg.getAccountNo()); |
||||
jsonObject.put("bankName" , etcCustMsg.getBankName()); |
||||
jsonObject.put("address" , etcCustMsg.getAddress()); |
||||
jsonObject.put("phone" , etcCustMsg.getPhone()); |
||||
jsonObject.put("custAgentIdFront" , convertToBase64(etcCustMsg.getCustAgentIdFront())); |
||||
jsonObject.put("custAgentIdBack" , convertToBase64(etcCustMsg.getCustAgentIdBront())); |
||||
jsonObject.put("bankCard" , convertToBase64(etcCustMsg.getCustAgentIdBront())); |
||||
if (etcCustMsg.getCustId() != null) { |
||||
jsonObject.put("custId" , etcCustMsg.getCustId()); |
||||
} |
||||
String sign = WxUtils.generateSignKytc(jsonObject , CommonSysConst.getSysConfig().getNdKey()); |
||||
|
||||
map.put("body" , jsonObject); |
||||
map.put("sign" , DigestUtils.md5Hex((sign).getBytes())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/api/v1/submitCustInfo" , map); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name submitVehInfo |
||||
* @Description // 车辆信息提交接口
|
||||
* @Date 11:28 2024/3/26 |
||||
* @Param etcCustMsg |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject submitVehInfo(EtcCarMsg etcCarMsg) throws Exception { |
||||
// 组装数据
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("orgCode" , CommonSysConst.getSysConfig().getNdOrgCode()); |
||||
map.put("timestamps", System.currentTimeMillis()); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("productId" , etcCarMsg.getProductId()); |
||||
jsonObject.put("custId" , etcCarMsg.getCustId()); |
||||
jsonObject.put("cardVarietyId" , etcCarMsg.getCardVarietyId()); |
||||
|
||||
List<JSONObject> vehInfoList = new ArrayList<>(); |
||||
JSONObject vehInfoListObject = new JSONObject(); |
||||
vehInfoListObject.put("vehPlateNo" , etcCarMsg.getVehPlateNo()); |
||||
vehInfoListObject.put("vehPlateColor" , etcCarMsg.getVehPlateColor()); |
||||
vehInfoListObject.put("vehType" , etcCarMsg.getVehType()); |
||||
vehInfoListObject.put("wheelsNum" , etcCarMsg.getWheelsNum()); |
||||
jsonObject.put("drivLicMainFro" , convertToBase64(etcCarMsg.getDrivlicMainFro())); |
||||
jsonObject.put("drivLicSubFro" , convertToBase64(etcCarMsg.getDrivlicSubFro())); |
||||
jsonObject.put("headStockPhoto" , convertToBase64(etcCarMsg.getHeadStockPhoto())); |
||||
|
||||
if (etcCarMsg.getVehId() != null) { |
||||
jsonObject.put("vehId" , etcCarMsg.getVehId()); |
||||
} |
||||
String sign = WxUtils.generateSignKytc(jsonObject , CommonSysConst.getSysConfig().getNdKey()); |
||||
|
||||
map.put("body" , jsonObject); |
||||
map.put("sign" , DigestUtils.md5Hex((sign).getBytes())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/api/v1/submitVehInfo" , map); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getVehStatus |
||||
* @Description // 查询车辆状态
|
||||
* @Date 13:54 2024/3/26 |
||||
* @Param etcCarMsg |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject getVehStatus(EtcCarMsg etcCarMsg) throws Exception { |
||||
// 组装数据
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("orgCode" , CommonSysConst.getSysConfig().getNdOrgCode()); |
||||
map.put("timestamps", System.currentTimeMillis()); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("custId" , etcCarMsg.getCustId()); |
||||
jsonObject.put("vehId" , etcCarMsg.getVehId()); |
||||
|
||||
String sign = WxUtils.generateSignKytc(jsonObject , CommonSysConst.getSysConfig().getNdKey()); |
||||
|
||||
map.put("body" , jsonObject); |
||||
map.put("sign" , DigestUtils.md5Hex((sign).getBytes())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/api/v1/getVehStatus" , map); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name sendRealNameCode |
||||
* @Description // 实名认证发送认证码接口
|
||||
* @Date 14:14 2024/3/26 |
||||
* @Param JSONObject |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject sendRealNameCode(String custId) throws Exception { |
||||
// 组装数据
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("orgCode" , CommonSysConst.getSysConfig().getNdOrgCode()); |
||||
map.put("timestamps", System.currentTimeMillis()); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("custId" , custId); |
||||
|
||||
String sign = WxUtils.generateSignKytc(jsonObject , CommonSysConst.getSysConfig().getNdKey()); |
||||
|
||||
map.put("body" , jsonObject); |
||||
map.put("sign" , DigestUtils.md5Hex((sign).getBytes())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/api/v1/sendRealNameCode" , map); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name checkRealNameCode |
||||
* @Description // 实名认证核验验证码接口
|
||||
* @Date 14:16 2024/3/26 |
||||
* @Param object |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject checkRealNameCode(String custId , String verifyCode) throws Exception { |
||||
// 组装数据
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("orgCode" , CommonSysConst.getSysConfig().getNdOrgCode()); |
||||
map.put("timestamps", System.currentTimeMillis()); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("custId" , custId); |
||||
jsonObject.put("verifyCode" , verifyCode); |
||||
|
||||
String sign = WxUtils.generateSignKytc(jsonObject , CommonSysConst.getSysConfig().getNdKey()); |
||||
|
||||
map.put("body" , jsonObject); |
||||
map.put("sign" , DigestUtils.md5Hex((sign).getBytes())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/api/v1/checkRealNameCode" , map); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name sendSignVerifyCode |
||||
* @Description // 签约验证码发送接口
|
||||
* @Date 14:37 2024/3/26 |
||||
* @Param custId |
||||
* @Param verifyCode |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject sendSignVerifyCode(String custId) throws Exception { |
||||
// 组装数据
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("orgCode" , CommonSysConst.getSysConfig().getNdOrgCode()); |
||||
map.put("timestamps", System.currentTimeMillis()); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("custId" , custId); |
||||
|
||||
String sign = WxUtils.generateSignKytc(jsonObject , CommonSysConst.getSysConfig().getNdKey()); |
||||
|
||||
map.put("body" , jsonObject); |
||||
map.put("sign" , DigestUtils.md5Hex((sign).getBytes())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/api/v1/sendSignVerifyCode" , map); |
||||
} |
||||
|
||||
|
||||
public static JSONObject checkSignVerifyCode(String custId , String verifyCode) throws Exception { |
||||
// 组装数据
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("orgCode" , CommonSysConst.getSysConfig().getNdOrgCode()); |
||||
map.put("timestamps", System.currentTimeMillis()); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("custId" , custId); |
||||
jsonObject.put("verifyCode" , verifyCode); |
||||
|
||||
String sign = WxUtils.generateSignKytc(jsonObject , CommonSysConst.getSysConfig().getNdKey()); |
||||
|
||||
map.put("body" , jsonObject); |
||||
map.put("sign" , DigestUtils.md5Hex((sign).getBytes())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/api/v1/checkSignVerifyCode" , map); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name convertToBase64 |
||||
* @Description // 转换base64
|
||||
* @Date 16:32 2024/3/25 |
||||
* @Param imagePath |
||||
* @return java.lang.String |
||||
*/ |
||||
public static String convertToBase64(String imagePath) { |
||||
String base64Image = ""; |
||||
try { |
||||
Path path = Paths.get( CommonSysConst.getSysConfig().getFileUrl() + imagePath); |
||||
byte[] imageBytes = Files.readAllBytes(path); |
||||
base64Image = Base64.getEncoder().encodeToString(imageBytes); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return base64Image; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,72 @@ |
||||
package com.hai.etc; |
||||
|
||||
import com.hai.entity.BlxCarInfo; |
||||
import com.hai.entity.EtcCarMsg; |
||||
import com.hai.entity.EtcCustMsg; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName .java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // etc业务
|
||||
* @createTime 15:15 2024/3/22 |
||||
**/ |
||||
public interface EtcCarMsgService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name insertCar |
||||
* @Description // 新增车辆信息
|
||||
* @Date 11:29 2023/9/5 |
||||
* @Param carInfo |
||||
* @return void |
||||
*/ |
||||
void insertEtcCar(EtcCarMsg etcCarMsg) throws Exception; |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name updateCar |
||||
* @Description // 更新车辆信息
|
||||
* @Date 11:29 2023/9/5 |
||||
* @Param carInfo |
||||
* @return void |
||||
*/ |
||||
void updateEtcCar(EtcCarMsg etcCarMsg); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getCarInfoList |
||||
* @Description // 查询车辆信息列表
|
||||
* @Date 11:30 2023/9/5 |
||||
* @Param map |
||||
* @return java.util.List<com.hai.entity.BlxCarInfo> |
||||
*/ |
||||
List<EtcCarMsg> getEtcCarList(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findCarInfoByMap |
||||
* @Description //TODO
|
||||
* @Date 14:14 2023/9/5 |
||||
* @Param map |
||||
* @return com.hai.entity.BlxCarInfo |
||||
*/ |
||||
EtcCarMsg findEtcCarByMap(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findCarInfoById |
||||
* @Description // 根据ID查询详情
|
||||
* @Date 15:13 2023/9/5 |
||||
* @Param id |
||||
* @return com.hai.entity.BlxCarInfo |
||||
*/ |
||||
EtcCarMsg findEtcCarById(Long id); |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,68 @@ |
||||
package com.hai.etc; |
||||
|
||||
import com.hai.entity.EtcCustMsg; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName .java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // etc客户信息
|
||||
* @createTime 16:03 2024/3/22 |
||||
**/ |
||||
public interface EtcCustMsgService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name insertCust |
||||
* @Description // 新增客户信息
|
||||
* @Date 11:29 2023/9/5 |
||||
* @Param CustInfo |
||||
* @return void |
||||
*/ |
||||
void insertEtcCust(EtcCustMsg etcCustMsg); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name updateCust |
||||
* @Description // 更新客户信息
|
||||
* @Date 11:29 2023/9/5 |
||||
* @Param CustInfo |
||||
* @return void |
||||
*/ |
||||
void updateEtcCust(EtcCustMsg etcCustMsg) throws Exception; |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getCustInfoList |
||||
* @Description // 查询客户信息列表
|
||||
* @Date 11:30 2023/9/5 |
||||
* @Param map |
||||
* @return java.util.List<com.hai.entity.BlxCustInfo> |
||||
*/ |
||||
List<EtcCustMsg> getEtcCustList(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findCustInfoByMap |
||||
* @Description //TODO
|
||||
* @Date 14:14 2023/9/5 |
||||
* @Param map |
||||
* @return com.hai.entity.BlxCustInfo |
||||
*/ |
||||
EtcCustMsg findEtcCustByMap(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findCustInfoById |
||||
* @Description // 根据ID查询详情
|
||||
* @Date 15:13 2023/9/5 |
||||
* @Param id |
||||
* @return com.hai.entity.BlxCustInfo |
||||
*/ |
||||
EtcCustMsg findEtcCustById(Long id); |
||||
|
||||
|
||||
} |
@ -0,0 +1,81 @@ |
||||
package com.hai.etc.impl; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.config.EtcService; |
||||
import com.hai.dao.EtcCarMsgMapper; |
||||
import com.hai.entity.EtcCarMsg; |
||||
import com.hai.entity.EtcCarMsgExample; |
||||
import com.hai.entity.EtcCustMsg; |
||||
import com.hai.entity.EtcCustMsgExample; |
||||
import com.hai.etc.EtcCarMsgService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("etcCarMsgService") |
||||
public class EtcCarMsgServiceImpl implements EtcCarMsgService { |
||||
|
||||
@Resource |
||||
private EtcCarMsgMapper etcCarMsgMapper; |
||||
|
||||
@Override |
||||
public void insertEtcCar(EtcCarMsg etcCarMsg) throws Exception { |
||||
// 提交车辆审核
|
||||
JSONObject jsonObject = EtcService.submitVehInfo(etcCarMsg); |
||||
if (jsonObject.getString("errCode").equals("0")) { |
||||
JSONObject object = (JSONObject) jsonObject.getJSONArray("result").get(0); |
||||
etcCarMsg.setVehId(object.getString("custId")); |
||||
|
||||
JSONObject car = EtcService.getVehStatus(etcCarMsg); |
||||
if (car.getString("errCode").equals("0")) { |
||||
etcCarMsg.setVehStatus(car.getJSONObject("result").getInteger("vehStatus")); |
||||
etcCarMsg.setPayStatus(car.getJSONObject("result").getInteger("payStatus")); |
||||
etcCarMsg.setSignStatus(car.getJSONObject("result").getInteger("signStatus")); |
||||
etcCarMsg.setExt2(car.getJSONObject("result").getString("docException")); |
||||
} |
||||
etcCarMsg.setExt3(car.getString("errMsg")); |
||||
|
||||
} |
||||
etcCarMsg.setExt1(jsonObject.getString("errMsg")); |
||||
etcCarMsgMapper.insert(etcCarMsg); |
||||
} |
||||
|
||||
@Override |
||||
public void updateEtcCar(EtcCarMsg etcCarMsg) { |
||||
etcCarMsgMapper.updateByPrimaryKey(etcCarMsg); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public List<EtcCarMsg> getEtcCarList(Map<String, Object> map) { |
||||
EtcCarMsgExample example = new EtcCarMsgExample(); |
||||
EtcCarMsgExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getLong(map , "userId") != null) { |
||||
criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId")); |
||||
} |
||||
if (MapUtils.getString(map , "vehPlateNo") != null) { |
||||
criteria.andVehPlateNoEqualTo(MapUtils.getString(map , "vehPlateNo")); |
||||
} |
||||
|
||||
return etcCarMsgMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public EtcCarMsg findEtcCarByMap(Map<String, Object> map) { |
||||
|
||||
EtcCustMsgExample example = new EtcCustMsgExample(); |
||||
EtcCustMsgExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public EtcCarMsg findEtcCarById(Long id) { |
||||
return etcCarMsgMapper.selectByPrimaryKey(id); |
||||
} |
||||
} |
@ -0,0 +1,72 @@ |
||||
package com.hai.etc.impl; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.config.EtcService; |
||||
import com.hai.dao.EtcCustMsgMapper; |
||||
import com.hai.entity.BsMsgExample; |
||||
import com.hai.entity.EtcCustMsg; |
||||
import com.hai.entity.EtcCustMsgExample; |
||||
import com.hai.etc.EtcCustMsgService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("etcCustMsgService") |
||||
public class EtcCustMsgServiceImpl implements EtcCustMsgService { |
||||
|
||||
@Resource |
||||
private EtcCustMsgMapper etcCustMsgMapper; |
||||
|
||||
@Override |
||||
public void insertEtcCust(EtcCustMsg etcCustMsg) { |
||||
etcCustMsgMapper.insert(etcCustMsg); |
||||
} |
||||
|
||||
@Override |
||||
public void updateEtcCust(EtcCustMsg etcCustMsg) throws Exception { |
||||
// 提交实名认证
|
||||
JSONObject jsonObject = EtcService.submitCustInfo(etcCustMsg); |
||||
if (jsonObject.getString("errCode").equals("0")) { |
||||
etcCustMsg.setCustId(jsonObject.getJSONObject("result").getString("custId")); |
||||
etcCustMsg.setCustIdNo(jsonObject.getJSONObject("result").getString("custIdNo")); |
||||
etcCustMsg.setStatus(jsonObject.getJSONObject("result").getInteger("realStatus")); |
||||
} |
||||
etcCustMsg.setExt1(jsonObject.getString("errMsg")); |
||||
|
||||
etcCustMsgMapper.updateByPrimaryKey(etcCustMsg); |
||||
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public List<EtcCustMsg> getEtcCustList(Map<String, Object> map) { |
||||
|
||||
EtcCustMsgExample example = new EtcCustMsgExample(); |
||||
EtcCustMsgExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getLong(map , "userId") != null) { |
||||
criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId")); |
||||
} |
||||
if (MapUtils.getString(map , "custName") != null) { |
||||
criteria.andCustNameEqualTo(MapUtils.getString(map , "custName")); |
||||
} |
||||
if (MapUtils.getString(map , "phone") != null) { |
||||
criteria.andPhoneEqualTo(MapUtils.getString(map , "phone")); |
||||
} |
||||
|
||||
return etcCustMsgMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public EtcCustMsg findEtcCustByMap(Map<String, Object> map) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public EtcCustMsg findEtcCustById(Long id) { |
||||
return etcCustMsgMapper.selectByPrimaryKey(id); |
||||
} |
||||
} |
@ -0,0 +1,97 @@ |
||||
package com.hai.ocr; |
||||
|
||||
import com.aliyun.ocr_api20210707.Client; |
||||
import com.aliyun.ocr_api20210707.models.*; |
||||
import com.aliyun.teaopenapi.models.Config; |
||||
|
||||
/** |
||||
* 阿里云识别 |
||||
* @author hurui |
||||
*/ |
||||
public class AliYunOcrService { |
||||
|
||||
/** |
||||
* 创建请求 |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private static Client createClient() throws Exception { |
||||
Config config = new Config() |
||||
// 您的AccessKey ID
|
||||
.setAccessKeyId("LTAI5tAu96cTs6b87vdfZivT") |
||||
// 您的AccessKey Secret
|
||||
.setAccessKeySecret("67SmjGewt0zKGrhQeDKGbbk5lE3tAi"); |
||||
// 访问的域名
|
||||
config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com"; |
||||
return new Client(config); |
||||
} |
||||
|
||||
/** |
||||
* 身份证识别 |
||||
* @param url 访问地址 |
||||
* @return |
||||
*/ |
||||
public static RecognizeIdcardResponseBody recognizeIdCard(String url) { |
||||
try { |
||||
Client client = createClient(); |
||||
RecognizeIdcardRequest recognizeIdcardRequest = new RecognizeIdcardRequest().setUrl(url); |
||||
RecognizeIdcardResponse response = client.recognizeIdcard(recognizeIdcardRequest); |
||||
return response.getBody(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 银行卡识别 |
||||
* @param url 访问地址 |
||||
* @return |
||||
*/ |
||||
public static RecognizeBankCardResponseBody recognizeBankCard(String url) { |
||||
try { |
||||
Client client = createClient(); |
||||
RecognizeBankCardRequest recognizeBankCardRequest = new RecognizeBankCardRequest().setUrl(url); |
||||
RecognizeBankCardResponse response = client.recognizeBankCard(recognizeBankCardRequest); |
||||
return response.getBody(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 银行开户许可证识别 |
||||
* @param url 访问地址 |
||||
* @return |
||||
*/ |
||||
public static RecognizeBankAccountLicenseResponseBody recognizeBankAccount(String url) { |
||||
try { |
||||
Client client = createClient(); |
||||
RecognizeBankAccountLicenseRequest recognizeBankAccountLicenseRequest = new RecognizeBankAccountLicenseRequest().setUrl(url); |
||||
RecognizeBankAccountLicenseResponse response = client.recognizeBankAccountLicense(recognizeBankAccountLicenseRequest); |
||||
return response.getBody(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 营业执照识别 |
||||
* @param url 访问地址 |
||||
* @return |
||||
*/ |
||||
public static RecognizeBusinessLicenseResponseBody recognizeBusinessLicense(String url) { |
||||
try { |
||||
Client client = createClient(); |
||||
RecognizeBusinessLicenseRequest request = new RecognizeBusinessLicenseRequest().setUrl(url); |
||||
RecognizeBusinessLicenseResponse response = client.recognizeBusinessLicense(request); |
||||
return response.getBody(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
} |
Loading…
Reference in new issue