后台进件迁移

This commit is contained in:
liuyingfang 2023-09-21 14:21:31 +08:00
parent 8122314ba4
commit 80af3303b7
52 changed files with 2573 additions and 850 deletions

Binary file not shown.

View File

@ -23,6 +23,11 @@
<artifactId>dao-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.chaozhanggui.system</groupId>
<artifactId>merchant-service-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.chaozhanggui.system</groupId>
<artifactId>common-api</artifactId>

View File

@ -4,6 +4,7 @@ import com.chaozhanggui.common.system.CommonConfig;
import com.chaozhanggui.common.system.util.ExceptionUtil;
import com.chaozhanggui.common.system.util.SpringContextHolder;
import com.chaozhanggui.dao.system.DaoConfig;
import com.chaozhanggui.merchant.MerchantConfig;
import com.chaozhanggui.system.AliPayServiceConfig;
import com.chaozhanggui.system.config.AliPayConfig;
import com.dianguang.cloud.ossservice.OssServiceConfig;
@ -30,9 +31,9 @@ import org.springframework.web.client.RestTemplate;
*/
@SpringBootApplication
@EnableScheduling
@EntityScan(basePackageClasses = {Shell.class, DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class})
@MapperScan(basePackageClasses ={Shell.class,DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class} )
@ComponentScan(basePackageClasses ={ Shell.class, DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class})
@EntityScan(basePackageClasses = {Shell.class, DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class, MerchantConfig.class})
@MapperScan(basePackageClasses ={Shell.class,DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class,MerchantConfig.class} )
@ComponentScan(basePackageClasses ={ Shell.class, DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class,MerchantConfig.class})
@Slf4j
@Transactional
public class Shell {
@ -56,4 +57,8 @@ public class Shell {
propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
return propertySourcesPlaceholderConfigurer;
}
@Bean
RestTemplate restTemplate(){
return new RestTemplate();
}
}

View File

@ -55,6 +55,19 @@ public class AgencyController {
}
return new RespBody("999997");
}
// @OpLog(opName = "更改机构", opDetail = "更改机构", opCode = "AGENCY_UPDATE")
// @GetMapping("updateAgency")
// public RespBody updateAgencyInfo(){
// agencyService.updateAgency()
// }
@GetMapping("AgencyInfo")
public RespBody getAgencyInfo(@RequestParam("userId") Integer userId){
return agencyService.getAgencyInfo(userId);
}
/**
* 机构列表

View File

@ -2,6 +2,7 @@ package com.chaozhanggui.admin.system.controller;
import com.chaozhanggui.admin.system.service.MerchantChannelStatusService;
import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.merchant.service.MerchantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@ -18,6 +19,8 @@ import javax.annotation.Resource;
public class MerchantChannelStatusController {
@Resource
private MerchantChannelStatusService merchantChannelStatusService;
@Resource
private MerchantService merchantService;
// @GetMapping(value = "/queryUserAppByPage")
// public Map<String, Object> queryUserAppByPage(@RequestParam(defaultValue = "1") Integer currPage, Integer size,
@ -132,8 +135,18 @@ public class MerchantChannelStatusController {
* @return
*/
@GetMapping(value = "/manualMerchantIncom/{userId}/{channelId}/{merchantCode}")
public RespBody manualMerchantIncome(@PathVariable("userId") Integer userId, @PathVariable("channelId") String channelId, @PathVariable("merchantCode") String merchantCode){
return new RespBody (merchantChannelStatusService.manualMerchantIncome(userId,channelId,merchantCode));
public RespBody manualMerchantIncome(@PathVariable("userId") String userId, @PathVariable("channelId") String channelId, @PathVariable("merchantCode") String merchantCode){
merchantService.merchantAudit(userId,channelId);
return new RespBody ();
}
/**
* 通道进件信息
* @return
*/
@GetMapping("/messageChannel/{userId}")
public RespBody messageChannel(@PathVariable("userId") Integer userId){
return merchantChannelStatusService.messageChannel(userId);
}
}

View File

@ -1,30 +1,21 @@
package com.chaozhanggui.admin.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chaozhanggui.admin.system.annotation.OpLog;
import com.chaozhanggui.admin.system.service.AccountService;
import com.chaozhanggui.admin.system.service.MerchantInfoService;
import com.chaozhanggui.admin.system.service.SxfMccInfoService;
import com.chaozhanggui.merchant.service.sxf.SxfMccInfoService;
import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.dao.system.dao.TbPlussBankCodeSxfMapper;
import com.chaozhanggui.dao.system.entity.*;
import com.chaozhanggui.dao.system.entity.DTO.AccountDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author lyf
@ -173,108 +164,4 @@ public class MerchantInfoController {
public RespBody connectInfo(@PathVariable("userId") Integer userId) {
return merchantInfoService.connectInfo(userId);
}
// /**
// * 通道进件信息
// * @param userId
// * @return
// */
// @GetMapping("/detail/channelAuditInfo/{userId}")
// public RespBody channelAuditInfo(@PathVariable("userId") Integer userId) {
// merchantInfoService.channelAuditInfo(userId);
//
// }
// @PostMapping("/updateMerchantSettlement2")
// public RespBody updateMerchantSettlement2(@RequestBody AccountDTO accountDTO) {
// if (accountDTO != null && accountDTO.getUserid() != null) {
// accountService.saveV4(accountDTO, false);
// }
// System.out.println(JSON.toJSONString(accountDTO));
// BankCard editBankCard = accountDTO.getBankCard();
// if (editBankCard != null) {
// MsgException.checkNull(editBankCard.getId(), "无结算银行卡信息请先从通过app填写结算信息!");
//
// LambdaQueryWrapper<BankCodeSxf> qWrapper = new LambdaQueryWrapper<BankCodeSxf>()
// .eq(BankCodeSxf::getCnapsCode, editBankCard.getContactLine());
// BankCodeSxf bankCodeSxf = bankCodeSxfMapper.selectOne(qWrapper);
// editBankCard.setBranchName(bankCodeSxf.getCnapsName());
//
// bankCardService.updateById(editBankCard);
// }
//
// IdCard editIdCard = accountDTO.getIdcard();
// if (editIdCard != null) {
// MsgException.checkNull(editBankCard.getId(), "无结算身份证信息请先从通过app填写结算信息!");
//
// idCardService.updateById(editIdCard);
// }
//
// if (merchantImage.getMerchantCode() != null) {
// //修改结算人与收银台合照
// if (!StringUtils.isEmpty(merchantImage.getPicUrl999())) {
// merchantImage.setPicUrl(merchantImage.getPicUrl999());
// merchantImage.setPhotoType(MerchantImage.ImageType.CASH_DESK_WITH_PERSON);
//
// UpdateWrapper<MerchantImage> merchantImageUpdateWrapper = new UpdateWrapper<MerchantImage>()
// .eq("merchantCode", merchantImage.getMerchantCode()).eq("photoType", merchantImage.getPhotoType());
// boolean update = merchantImageService.update(merchantImage, merchantImageUpdateWrapper);
// if (!update) {
// merchantImage.setMerchantCode(merchantImage.getMerchantCode());
// merchantImageService.save(merchantImage);
// }
// }
// //修改结算人手持身份证照
// if (!StringUtils.isEmpty(merchantImage.getPicUrl11())) {
// merchantImage.setPicUrl(merchantImage.getPicUrl11());
// merchantImage.setPhotoType(MerchantImage.ImageType.HAND_IDCARD_PHOTO);
//
// UpdateWrapper<MerchantImage> merchantImageUpdateWrapper = new UpdateWrapper<MerchantImage>()
// .eq("merchantCode", merchantImage.getMerchantCode()).eq("photoType", merchantImage.getPhotoType());
// boolean update = merchantImageService.update(merchantImage, merchantImageUpdateWrapper);
// if (!update) {
// merchantImage.setMerchantCode(merchantImage.getMerchantCode());
// merchantImageService.save(merchantImage);
// }
// }
// }
//
// // throw new MsgException("终止操作");
// return ResultGenerator.genSuccessResult("保存成功!", null);
// }
// /**
// * 进件相关信息
// * @param userId
// * @return
// */
// @GetMapping("/detail/channelAuditInfo/{userId}")
// public RespBody channelAuditInfo(@PathVariable("userId") Long userId) {
//
// }
// private void getProvince() {
// QueryWrapper<TbPlussAreaCity> queryWrapper = new QueryWrapper<TbPlussAreaCity>().eq("type", "1");
// List<TbPlussAreaCity> areaCitiesList = TbPlussAreaCityMapper.selectList(queryWrapper);
// for (AreaCity areaCity : areaCitiesList) {
// switch (areaCity.getAreaName()) {
// case "北京":
// areaCity.setAreaName("北京市");
// break;
// case "天津":
// areaCity.setAreaName("天津市");
// break;
// case "重庆":
// areaCity.setAreaName("重庆市");
// break;
// case "上海":
// areaCity.setAreaName("上海市");
// break;
// default:
// break;
// }
// }
//
// request.setAttribute("areaCitiesList", areaCitiesList);
// }
}

View File

@ -1,12 +1,9 @@
package com.chaozhanggui.admin.system.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.admin.system.model.CommonError;
import com.chaozhanggui.admin.system.util.Converter;
import com.chaozhanggui.merchant.service.sxf.model.Converter;
import com.chaozhanggui.common.system.config.MsgException;
import com.chaozhanggui.dao.system.dao.*;
import com.chaozhanggui.dao.system.entity.*;

View File

@ -3,7 +3,7 @@ package com.chaozhanggui.admin.system.service;
import cn.hutool.core.util.ObjectUtil;
import com.chaozhanggui.admin.system.model.CreateAgencyReq;
import com.chaozhanggui.admin.system.util.MD5Util;
import com.chaozhanggui.admin.system.util.StringUtil;
import com.chaozhanggui.common.system.util.StringUtil;
import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.dao.system.dao.*;
import com.chaozhanggui.dao.system.entity.*;
@ -12,18 +12,15 @@ import com.chaozhanggui.dao.system.model.ProfitPO;
import com.chaozhanggui.dao.system.util.N;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.cache.CacheStats;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
@ -51,6 +48,10 @@ public class AgencyService {
TbPlussMerchantBaseInfoMapper tbPlussMerchantBaseInfoMapper;
@Resource
private TbPlussUserMarkerMapper userMarkerMapper;
@Resource
private TbPlussCashAccountMapper cashAccountMapper;
@Resource
private TbPlussIdCardMapper idCardMapper;
@ -160,6 +161,27 @@ public class AgencyService {
}
public RespBody getAgencyInfo(Integer userId){
//首先判断是不是大小机构
TbPlussUserPromotion userPromotion = userPromotionMapper.selectByPrimaryKey(userId);
if (userPromotion == null ||"FO".equals(userPromotion.getTypeCode()) || "SO".equals(userPromotion.getTypeCode())){
return new RespBody("000086");
}
//查找大小机构的详情信息
//支付宝
TbPlussCashAccount tbPlussCashAccount = cashAccountMapper.selectByUserId(String.valueOf(userId));
//实名信息
TbPlussIdCard tbPlussIdCard = idCardMapper.selectCertByUserId(userId, TbPlussIdCard.TYPE_CERT);
//登录手机号
TbPlussUserApp tbPlussUserApp = userAppMapper.selectByUserId(userId);
HashMap<Object, Object> map = new HashMap<>();
map.put("zfb", tbPlussCashAccount);
map.put("idCard", tbPlussIdCard);
map.put("phone", tbPlussUserApp == null? null:tbPlussUserApp.getLoginname());
return new RespBody(map);
}
public RespBody queryCustormFlow(String userId,String userType,String agencyCode,String isExtend,
String merchantCode,String status,String merchantType,String reqUserId,

View File

@ -1,15 +1,23 @@
package com.chaozhanggui.admin.system.service;
import cn.hutool.core.util.ObjectUtil;
import com.chaozhanggui.common.system.config.MsgException;
import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.dao.system.dao.TbPlussAccountMapper;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantChannelMapper;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantChannelStatusMapper;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantRejectDescMapper;
import com.chaozhanggui.dao.system.entity.TbPlussAccount;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantChannel;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantChannelStatus;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantRejectDesc;
import com.chaozhanggui.merchant.service.sxf.SxfMerchantAuditService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
/**
@ -91,6 +99,12 @@ public class MerchantChannelStatusService {
private TbPlussMerchantChannelStatusMapper merchantChannelStatusMapper;
@Resource
private SxfMerchantAuditService sxfMerchantAuditService;
@Resource
private TbPlussMerchantRejectDescMapper merchantRejectDescMapper;
@Resource
private TbPlussMerchantChannelMapper merchantChannelMapper;
@Resource
private TbPlussAccountMapper accountMapper;
/**
* 后台进件
@ -176,4 +190,19 @@ public class MerchantChannelStatusService {
return merchantChannelStatusMapper.getIncomingInfoAnother(merchantCode);
}
public RespBody messageChannel(Integer userId){
HashMap<String, List<Object>> map = new HashMap<>();
//获取审核备注组
List<TbPlussMerchantRejectDesc> merchantRejectDescs = merchantRejectDescMapper.selectRejectList();
//通道选择
List<TbPlussMerchantChannel> merchantChannels = merchantChannelMapper.selectAll();
//默认结算方式
TbPlussAccount account = accountMapper.selectDefault(userId);
//TODO
return new RespBody();
}
}

View File

@ -5,11 +5,10 @@ import cn.hutool.crypto.digest.MD5;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
import com.chaozhanggui.admin.system.util.RedisCst;
import com.chaozhanggui.admin.system.util.RedisUtil;
import com.chaozhanggui.admin.system.util.StringUtil;
import com.chaozhanggui.common.system.util.StringUtil;
import com.chaozhanggui.admin.system.util.TokenUtil;
import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.dao.system.dao.*;

View File

@ -1,214 +0,0 @@
package com.chaozhanggui.admin.system.util;
import com.aliyun.oss.ServiceException;
import com.chaozhanggui.common.system.config.MsgException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
/**
* @author rsa加密解密签名验签工具类
*/
public class RSAUtils {
private RSAUtils() {}
public static final String RSA = "RSA";
public static final String CIPHERALGORITHM = "RSA/ECB/PKCS1Padding";
public static String sign(String privateKey, String src) throws Exception {
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) getPrivateKey(privateKey);
return sign(rsaPrivateKey, src);
}
public static boolean checkSign(String publicKey, String src, String sign) throws Exception {
RSAPublicKey rsaPublicKey = (RSAPublicKey) getPublicKey(publicKey);
return checkSign(rsaPublicKey, src, sign);
}
public static String signSHA256(String privateKey, String src) throws Exception {
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) getPrivateKey(privateKey);
return signSHA256WithRSA(rsaPrivateKey, src);
}
public static boolean checkSignSHA256(String publicKey, String src, String sign) throws Exception {
RSAPublicKey rsaPublicKey = (RSAPublicKey) getPublicKey(publicKey);
return checkSignSHA256WithRSA(rsaPublicKey, src, sign);
}
/**
* 私钥签名过程
*
* @param rsaPrivateKey 私钥
* @param plainTextData 明文数据
* @return
* @throws Exception 加密过程中的异常信息
*/
public static String sign(RSAPrivateKey rsaPrivateKey, String plainTextData) throws Exception {
if (rsaPrivateKey == null) {
throw new MsgException("签名私钥为空, 请设置");
}
Signature signature = Signature.getInstance("SHA1withRSA");
signature.initSign(rsaPrivateKey);
signature.update(plainTextData.getBytes());
byte[] result = signature.sign();
return Base64.getEncoder().encodeToString(result);
}
/**
* 私钥签名过程
*
* @param rsaPrivateKey 私钥
* @param plainTextData 明文数据
* @return
* @throws Exception 加密过程中的异常信息
*/
public static String signSHA256WithRSA(RSAPrivateKey rsaPrivateKey, String plainTextData) throws Exception {
if (rsaPrivateKey == null) {
throw new MsgException("签名私钥为空, 请设置");
}
Signature signature = Signature.getInstance("SHA256withRSA");
signature.initSign(rsaPrivateKey);
signature.update(plainTextData.getBytes());
byte[] result = signature.sign();
return Base64.getEncoder().encodeToString(result);
}
public static boolean checkSign(RSAPublicKey rsaPublicKey, String src, String sign) throws Exception {
Signature signature = Signature.getInstance("SHA1withRSA");
signature.initVerify(rsaPublicKey);
signature.update(src.getBytes(StandardCharsets.UTF_8));
return signature.verify(Base64.getDecoder().decode(sign));
}
public static boolean checkSignSHA256WithRSA(RSAPublicKey rsaPublicKey, String src, String sign) throws Exception {
Signature signature = Signature.getInstance("SHA256withRSA");
signature.initVerify(rsaPublicKey);
signature.update(src.getBytes(StandardCharsets.UTF_8));
return signature.verify(Base64.getDecoder().decode(sign));
}
public static PublicKey getPublicKey(String key) throws Exception {
byte[] keyBytes;
keyBytes = Base64.getDecoder().decode(key);
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(RSA);
return keyFactory.generatePublic(keySpec);
}
public static PrivateKey getPrivateKey(String key) throws Exception {
byte[] keyBytes;
keyBytes = Base64.getMimeDecoder().decode(key);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(RSA);
return keyFactory.generatePrivate(keySpec);
}
/**
* 公钥加密过程
*
* @param rsaPublicKey 公钥
* @param plainTextData 明文数据
* @return
* @throws Exception 加密过程中的异常信息
*/
public static String encrypt(RSAPublicKey rsaPublicKey, String plainTextData) throws Exception {
if (rsaPublicKey == null) {
throw new MsgException("加密公钥为空, 请设置");
}
Base64.Encoder encoder = Base64.getEncoder();
Cipher cipher = Cipher.getInstance(RSA);
cipher.init(Cipher.ENCRYPT_MODE, rsaPublicKey);
byte[] output = cipher.doFinal(plainTextData.getBytes(StandardCharsets.UTF_8));
return encoder.encodeToString(output);
}
/**
* 使用私钥解密
* @param rsaPrivateKey 私钥
* @param encryptParam 公钥加密的字符串
* @return 解密后的字符串
* */
public static String decrypt(RSAPrivateKey rsaPrivateKey,String encryptParam) throws Exception {
Base64.Decoder decoder = Base64.getDecoder();
Base64.Encoder encoder = Base64.getEncoder();
Cipher cipher;
try {
cipher = Cipher.getInstance(RSA);
cipher.init(Cipher.DECRYPT_MODE, rsaPrivateKey);
byte[] output = cipher.doFinal(decoder.decode(encryptParam));
return new String(output, StandardCharsets.UTF_8);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* Ecb解密
* @param encryptedBytes
* @param privateKey
* @param keyLength
* @param reserveSize
* @return
*/
public static byte[] decryptEcb(byte[] encryptedBytes, PrivateKey privateKey, int keyLength, int reserveSize) throws ServiceException {
int keyByteSize = keyLength / 8; // 密钥字节数
int decryptBlockSize = keyByteSize - reserveSize; // 解密块大小=密钥字节数-padding填充字节数
int nBlock = encryptedBytes.length / keyByteSize;// 计算分段解密的block数理论上能整除
try {
Cipher cipher = Cipher.getInstance(CIPHERALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, privateKey);
// 输出buffer大小为nBlock个decryptBlockSize
ByteArrayOutputStream outbuf = new ByteArrayOutputStream(nBlock * decryptBlockSize);
// 分段解密
for (int offset = 0; offset < encryptedBytes.length; offset += keyByteSize) {
// block大小: decryptBlock 剩余字节数
int inputLen = encryptedBytes.length - offset;
if (inputLen > keyByteSize) {
inputLen = keyByteSize;
}
// 得到分段解密结果
byte[] decryptedBlock = cipher.doFinal(encryptedBytes, offset, inputLen);
// 追加结果到输出buffer中
outbuf.write(decryptedBlock);
}
outbuf.flush();
outbuf.close();
return outbuf.toByteArray();
} catch (NoSuchAlgorithmException e) {
throw new ServiceException(String.format("没有[%s]此类解密算法", CIPHERALGORITHM));
} catch (NoSuchPaddingException e) {
throw new ServiceException(String.format("没有[%s]此类填充模式", CIPHERALGORITHM));
} catch (InvalidKeyException e) {
throw new ServiceException("无效密钥");
} catch (IllegalBlockSizeException e) {
throw new ServiceException("解密块大小不合法");
} catch (BadPaddingException e) {
throw new ServiceException("错误填充模式");
} catch (IOException e) {
throw new ServiceException("字节输出流异常");
}
}
}

View File

@ -1,6 +1,7 @@
package com.chaozhanggui.admin.system.util;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.common.system.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;

View File

@ -23,7 +23,16 @@
<artifactId>commons-lang3</artifactId>
<version>3.8</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.chaozhanggui.system</groupId>-->
<!-- <artifactId>dao-api</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.chaozhanggui.system</groupId>-->
<!-- <artifactId>oss-service</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>

View File

@ -84,6 +84,7 @@ public class ExceptionUtil {
map.put("000083","已在【随行付】进件的商户禁止在【瑞银信】通道进件");
map.put("000084","商户未提交进件请求");
map.put("000085","当前通道下已进件,请选择别的进件通道");
map.put("000086","不是目标用户");

View File

@ -1,483 +1,214 @@
//package com.chaozhanggui.common.system.util;
package com.chaozhanggui.common.system.util;
import com.chaozhanggui.common.system.config.MsgException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
/**
* @author rsa加密解密签名验签工具类
*/
public class RSAUtils {
private RSAUtils() {}
public static final String RSA = "RSA";
public static final String CIPHERALGORITHM = "RSA/ECB/PKCS1Padding";
public static String sign(String privateKey, String src) throws Exception {
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) getPrivateKey(privateKey);
return sign(rsaPrivateKey, src);
}
public static boolean checkSign(String publicKey, String src, String sign) throws Exception {
RSAPublicKey rsaPublicKey = (RSAPublicKey) getPublicKey(publicKey);
return checkSign(rsaPublicKey, src, sign);
}
public static String signSHA256(String privateKey, String src) throws Exception {
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) getPrivateKey(privateKey);
return signSHA256WithRSA(rsaPrivateKey, src);
}
public static boolean checkSignSHA256(String publicKey, String src, String sign) throws Exception {
RSAPublicKey rsaPublicKey = (RSAPublicKey) getPublicKey(publicKey);
return checkSignSHA256WithRSA(rsaPublicKey, src, sign);
}
/**
* 私钥签名过程
*
* @param rsaPrivateKey 私钥
* @param plainTextData 明文数据
* @return
* @throws Exception 加密过程中的异常信息
*/
public static String sign(RSAPrivateKey rsaPrivateKey, String plainTextData) throws Exception {
if (rsaPrivateKey == null) {
throw new MsgException("签名私钥为空, 请设置");
}
Signature signature = Signature.getInstance("SHA1withRSA");
signature.initSign(rsaPrivateKey);
signature.update(plainTextData.getBytes());
byte[] result = signature.sign();
return Base64.getEncoder().encodeToString(result);
}
/**
* 私钥签名过程
*
* @param rsaPrivateKey 私钥
* @param plainTextData 明文数据
* @return
* @throws Exception 加密过程中的异常信息
*/
public static String signSHA256WithRSA(RSAPrivateKey rsaPrivateKey, String plainTextData) throws Exception {
if (rsaPrivateKey == null) {
throw new MsgException("签名私钥为空, 请设置");
}
Signature signature = Signature.getInstance("SHA256withRSA");
signature.initSign(rsaPrivateKey);
signature.update(plainTextData.getBytes());
byte[] result = signature.sign();
return Base64.getEncoder().encodeToString(result);
}
public static boolean checkSign(RSAPublicKey rsaPublicKey, String src, String sign) throws Exception {
Signature signature = Signature.getInstance("SHA1withRSA");
signature.initVerify(rsaPublicKey);
signature.update(src.getBytes(StandardCharsets.UTF_8));
return signature.verify(Base64.getDecoder().decode(sign));
}
public static boolean checkSignSHA256WithRSA(RSAPublicKey rsaPublicKey, String src, String sign) throws Exception {
Signature signature = Signature.getInstance("SHA256withRSA");
signature.initVerify(rsaPublicKey);
signature.update(src.getBytes(StandardCharsets.UTF_8));
return signature.verify(Base64.getDecoder().decode(sign));
}
public static PublicKey getPublicKey(String key) throws Exception {
byte[] keyBytes;
keyBytes = Base64.getDecoder().decode(key);
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(RSA);
return keyFactory.generatePublic(keySpec);
}
public static PrivateKey getPrivateKey(String key) throws Exception {
byte[] keyBytes;
keyBytes = Base64.getMimeDecoder().decode(key);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(RSA);
return keyFactory.generatePrivate(keySpec);
}
/**
* 公钥加密过程
*
* @param rsaPublicKey 公钥
* @param plainTextData 明文数据
* @return
* @throws Exception 加密过程中的异常信息
*/
public static String encrypt(RSAPublicKey rsaPublicKey, String plainTextData) throws Exception {
if (rsaPublicKey == null) {
throw new MsgException("加密公钥为空, 请设置");
}
Base64.Encoder encoder = Base64.getEncoder();
Cipher cipher = Cipher.getInstance(RSA);
cipher.init(Cipher.ENCRYPT_MODE, rsaPublicKey);
byte[] output = cipher.doFinal(plainTextData.getBytes(StandardCharsets.UTF_8));
return encoder.encodeToString(output);
}
/**
* 使用私钥解密
* @param rsaPrivateKey 私钥
* @param encryptParam 公钥加密的字符串
* @return 解密后的字符串
* */
public static String decrypt(RSAPrivateKey rsaPrivateKey,String encryptParam) throws Exception {
Base64.Decoder decoder = Base64.getDecoder();
Base64.Encoder encoder = Base64.getEncoder();
Cipher cipher;
try {
cipher = Cipher.getInstance(RSA);
cipher.init(Cipher.DECRYPT_MODE, rsaPrivateKey);
byte[] output = cipher.doFinal(decoder.decode(encryptParam));
return new String(output, StandardCharsets.UTF_8);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* Ecb解密
* @param encryptedBytes
* @param privateKey
* @param keyLength
* @param reserveSize
* @return
*/
// public static byte[] decryptEcb(byte[] encryptedBytes, PrivateKey privateKey, int keyLength, int reserveSize) throws ServiceException {
// int keyByteSize = keyLength / 8; // 密钥字节数
// int decryptBlockSize = keyByteSize - reserveSize; // 解密块大小=密钥字节数-padding填充字节数
// int nBlock = encryptedBytes.length / keyByteSize;// 计算分段解密的block数理论上能整除
//
//import java.math.BigInteger;
//import java.security.Key;
//import java.security.KeyFactory;
//import java.security.KeyPair;
//import java.security.KeyPairGenerator;
//import java.security.NoSuchAlgorithmException;
//import java.security.PrivateKey;
//import java.security.PublicKey;
//import java.security.interfaces.RSAPrivateKey;
//import java.security.interfaces.RSAPublicKey;
//import java.security.spec.PKCS8EncodedKeySpec;
//import java.security.spec.RSAPrivateKeySpec;
//import java.security.spec.RSAPublicKeySpec;
//import java.security.spec.X509EncodedKeySpec;
//import java.util.*;
//
//import javax.crypto.Cipher;
//
//import org.apache.commons.codec.binary.Base64;
//import sun.misc.BASE64Decoder;
//import sun.misc.BASE64Encoder;
//
///**
// * RSA私钥公钥字符串对象生成工具
// *
// * 本工具类提供以下几种方法
// *
// * 1生成基于PublicKey 和PrivateKey对象的方法 initRSAKeys()
// * 2将PrivateKey对象转为私钥字符串
// * 3将PublicKey对象转为公钥字符串
// * 4将私钥字符串转为PrivateKey对象
// * 5将公钥字符串转为PublicKey对象
// * 6将公钥和私钥以文件形式保存
// * 7公钥加密私钥解密
// * 8私钥加密公钥解密
// *
// * @author Guo pengFei
// *
// * @date 2017-7-27
// *
// * @version V1.0
// *
// * @compeny 深证风轮科技有限公司
// *
// * @site https://www.blog-china.cn
// *
// */
//public class RSAUtils {
// /** 指定加密算法为RSA */
// private static final String ALGORITHM = "RSA";
//// /** 指定公钥存放文件 */
//// private static String PUBLIC_KEY_FILE = "D://key/PublicKey.txt";
//// /** 指定私钥存放文件 */
//// private static String PRIVATE_KEY_FILE = "D://key/PrivateKey.txt";
////
//// /**
//// * 以文件形式生成公钥和私钥并保存
//// *
//// * @return
//// * @throws Exception
//// */
//// public static boolean writeKeyFile() throws Exception {
//// Map<String, Object> map = initRSAKeys();
//// Key publicKey = (Key) map.get("pubKey");
//// Key privateKey = (Key) map.get("priKey");
////
//// String pubKeyString = RSAUtils.getKeyString(publicKey);
////
//// String priKeyString = RSAUtils.getKeyString(privateKey);
//// System.out.println(pubKeyString);
//// System.out.println();
//// System.out.println(priKeyString);
////
//// /** 用对象流将生成的密钥写入文件 */
//// FileOutputStream oos1 = new FileOutputStream(PUBLIC_KEY_FILE);
//// oos1.write(pubKeyString.getBytes("UTF-8")); // 可以指定编码
////
//// FileOutputStream oos2 = new FileOutputStream(PRIVATE_KEY_FILE);
//// oos2.write(priKeyString.getBytes("UTF-8")); // 可以指定编码
////
//// /** 清空缓存,关闭文件输出流 */
//// if (oos1 != null) {
//// oos1.close();
//// }
//// if (oos2 != null) {
//// oos2.close();
//// }
//// return true;
//// }
//
// /**
// * 生产RSA的私钥和公钥
// *
// * @return
// * @throws NoSuchAlgorithmException
// */
// public static Map<String, Object> initRSAKeys()
// throws NoSuchAlgorithmException {
// // TODO Auto-generated method stub
// Map<String, Object> map = getKeys();
// // 生成公钥和私钥
// RSAPublicKey publicKey = (RSAPublicKey) map.get("public");
// RSAPrivateKey privateKey = (RSAPrivateKey) map.get("private");
//
// //
// String modulus = publicKey.getModulus().toString();
// // 公钥指数
// String public_exponent = publicKey.getPublicExponent().toString();
// // 私钥指数
// String private_exponent = privateKey.getPrivateExponent().toString();
// // 使用模和指数生成公钥和私钥
// RSAPublicKey pubKey = RSAUtils.getPublicKey(modulus, public_exponent);
// RSAPrivateKey priKey = RSAUtils
// .getPrivateKey(modulus, private_exponent);
//
// map.put("pubKey", Base64.encodeBase64String(pubKey.getEncoded()));
// map.put("priKey",Base64.encodeBase64String(priKey.getEncoded()) );
//
// return map;
// }
//
// /**
// * 把公钥字符串转为对象
// *
// * @param key
// * @return
// * @throws Exception
// */
// public static PublicKey getPublicKey(String key) throws Exception {
// byte[] keyBytes;
// keyBytes = (new BASE64Decoder()).decodeBuffer(key);
// X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
// KeyFactory keyFactory = KeyFactory.getInstance("RSA");
// PublicKey publicKey = keyFactory.generatePublic(keySpec);
// return publicKey;
// }
//
// /**
// * 把私钥字符串转为对象
// *
// * @param key
// * @return
// * @throws Exception
// */
// public static PrivateKey getPrivateKey(String key) throws Exception {
// byte[] keyBytes;
// keyBytes = (new BASE64Decoder()).decodeBuffer(key);
// PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
// KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
// PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
// return privateKey;
// }
//
// /**
// * 得到密钥字符串经过base64编码
// *
// * @return
// */
// public static String getKeyString(Key key) throws Exception {
// byte[] keyBytes = key.getEncoded();
// String s = (new BASE64Encoder()).encode(keyBytes);
// return s;
// }
//
// /**
// * 生成公钥和私钥
// *
// * @throws NoSuchAlgorithmException
// *
// */
// private static HashMap<String, Object> getKeys()
// throws NoSuchAlgorithmException {
// HashMap<String, Object> map = new HashMap<String, Object>();
// KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(ALGORITHM);
// keyPairGen.initialize(1024);
// KeyPair keyPair = keyPairGen.generateKeyPair();
// RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
// RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
// map.put("public", publicKey);
// map.put("private", privateKey);
// return map;
// }
//
// /**
// * 使用模和指数生成RSA公钥
// * 注意此代码用了默认补位方式为RSA/None/PKCS1Padding不同JDK默认的补位方式可能不同如Android默认是RSA
// * /None/NoPadding
// *
// * @param modulus
// *
// * @param exponent
// * 指数
// * @return
// */
// private static RSAPublicKey getPublicKey(String modulus, String exponent) {
// try {
// BigInteger b1 = new BigInteger(modulus);
// BigInteger b2 = new BigInteger(exponent);
// KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
// RSAPublicKeySpec keySpec = new RSAPublicKeySpec(b1, b2);
// return (RSAPublicKey) keyFactory.generatePublic(keySpec);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
// Cipher cipher = Cipher.getInstance(CIPHERALGORITHM);
// cipher.init(Cipher.DECRYPT_MODE, privateKey);
//
// /**
// * 使用模和指数生成RSA私钥
// * 注意此代码用了默认补位方式为RSA/None/PKCS1Padding不同JDK默认的补位方式可能不同如Android默认是RSA
// * /None/NoPadding
// *
// * @param modulus
// *
// * @param exponent
// * 指数
// * @return
// */
// private static RSAPrivateKey getPrivateKey(String modulus, String exponent) {
// try {
// BigInteger b1 = new BigInteger(modulus);
// BigInteger b2 = new BigInteger(exponent);
// KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
// RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(b1, b2);
// return (RSAPrivateKey) keyFactory.generatePrivate(keySpec);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
// /**
// * 公钥加密
// *
// * @param data
// * @param publicKey
// * @return
// * @throws Exception
// */
// public static String encryptByPublicKey(Map<String, String> data, RSAPublicKey publicKey)
// throws Exception {
// if(data == null)
// return null;
// StringBuffer buffer = new StringBuffer();
// buffer.append("{");
// Iterator<String> iterator = data.keySet().iterator();
// while (iterator.hasNext()) {
// String key = iterator.next();
// String value = data.get(key);
// buffer.append("'").append(key).append("':'").append(value).append("',");
// }
// String result = buffer.substring(0,buffer.length()-1)+"}";
// System.out.println(result);
//
// Cipher cipher = Cipher.getInstance(ALGORITHM);
// cipher.init(Cipher.ENCRYPT_MODE, publicKey);
// // 模长
// int key_len = publicKey.getModulus().bitLength() / 8;
// // 加密数据长度 <= 模长-11
// String[] datas = splitString(result, key_len - 11);
// String mi = "";
// // 如果明文长度大于模长-11则要分组加密
// for (String s : datas) {
// mi += bcd2Str(cipher.doFinal(s.getBytes()));
// }
// return mi;
// }
//
//
//
//
// /**
// * 公钥加密
// *
// * @param data
// * @return
// * @throws Exception
// */
// public static String encryptByPublicKey(String data, String publicKeys)
// throws Exception {
// RSAPublicKey publicKey= (RSAPublicKey) getPublicKey(publicKeys);
// Cipher cipher = Cipher.getInstance(ALGORITHM);
// cipher.init(Cipher.ENCRYPT_MODE, publicKey);
// // 模长
// int key_len = publicKey.getModulus().bitLength() / 8;
// // 加密数据长度 <= 模长-11
// String[] datas = splitString(data, key_len - 11);
// String mi = "";
// // 如果明文长度大于模长-11则要分组加密
// for (String s : datas) {
// mi += bcd2Str(cipher.doFinal(s.getBytes()));
// }
// return mi;
// }
//
//
// /**
// * 私钥加密过程
// *
// * @param privateKey
// * 私钥
// * 明文数据
// * @return
// * @throws Exception
// * 加密过程中的异常信息
// */
// public static String encryptByPrivateKey1(RSAPrivateKey privateKey,
// String data) throws Exception {
// Cipher cipher = Cipher.getInstance(ALGORITHM);
// cipher.init(Cipher.ENCRYPT_MODE, privateKey);
// // 模长
// int key_len = privateKey.getModulus().bitLength() / 8;
// // 加密数据长度 <= 模长-11
// String[] datas = splitString(data, key_len - 11);
// String mi = "";
// // 如果明文长度大于模长-11则要分组加密
// for (String s : datas) {
// mi += bcd2Str(cipher.doFinal(s.getBytes()));
// }
// return mi;
//
// }
//
// /**
// * 公钥解密过程
// *
// * @param publicKey
// * 公钥
// * 密文数据
// * @return 明文
// * @throws Exception
// * 解密过程中的异常信息
// */
// public static String decryptByPublicKey(RSAPublicKey publicKey, String data)
// throws Exception {
// Cipher cipher = Cipher.getInstance(ALGORITHM);
// cipher.init(Cipher.DECRYPT_MODE, publicKey);
// // 模长
// int key_len = publicKey.getModulus().bitLength() / 8;
// byte[] bytes = data.getBytes();
// byte[] bcd = ASCII_To_BCD(bytes, bytes.length);
// System.err.println(bcd.length);
// // 如果密文长度大于模长则要分组解密
// String ming = "";
// byte[][] arrays = splitArray(bcd, key_len);
// for (byte[] arr : arrays) {
// ming += new String(cipher.doFinal(arr));
// }
// return ming;
// }
//
//
// /**
// * 私钥解密
// *
// * @param data
// * @param privateKey
// * @return
// * @throws Exception
// */
// public static String decryptByPrivateKey(String data,
// String privateKey) throws Exception {
// RSAPrivateKey publicKey= (RSAPrivateKey) getPrivateKey(privateKey);
// Cipher cipher = Cipher.getInstance(ALGORITHM);
// cipher.init(Cipher.DECRYPT_MODE, publicKey);
// // 模长
// int key_len = publicKey.getModulus().bitLength() / 8;
// byte[] bytes = data.getBytes();
// byte[] bcd = ASCII_To_BCD(bytes, bytes.length);
// // 如果密文长度大于模长则要分组解密
// String ming = "";
// byte[][] arrays = splitArray(bcd, key_len);
// for (byte[] arr : arrays) {
// ming += new String(cipher.doFinal(arr));
// }
// return ming;
// }
//
// /**
// * ASCII码转BCD码
// *
// */
// private static byte[] ASCII_To_BCD(byte[] ascii, int asc_len) {
// byte[] bcd = new byte[asc_len / 2];
// int j = 0;
// for (int i = 0; i < (asc_len + 1) / 2; i++) {
// bcd[i] = asc_to_bcd(ascii[j++]);
// bcd[i] = (byte) (((j >= asc_len) ? 0x00 : asc_to_bcd(ascii[j++])) + (bcd[i] << 4));
// }
// return bcd;
// }
//
// private static byte asc_to_bcd(byte asc) {
// byte bcd;
//
// if ((asc >= '0') && (asc <= '9'))
// bcd = (byte) (asc - '0');
// else if ((asc >= 'A') && (asc <= 'F'))
// bcd = (byte) (asc - 'A' + 10);
// else if ((asc >= 'a') && (asc <= 'f'))
// bcd = (byte) (asc - 'a' + 10);
// else
// bcd = (byte) (asc - 48);
// return bcd;
// }
//
// /**
// * BCD转字符串
// */
// private static String bcd2Str(byte[] bytes) {
// char temp[] = new char[bytes.length * 2], val;
//
// for (int i = 0; i < bytes.length; i++) {
// val = (char) (((bytes[i] & 0xf0) >> 4) & 0x0f);
// temp[i * 2] = (char) (val > 9 ? val + 'A' - 10 : val + '0');
//
// val = (char) (bytes[i] & 0x0f);
// temp[i * 2 + 1] = (char) (val > 9 ? val + 'A' - 10 : val + '0');
// }
// return new String(temp);
// }
//
// /**
// * 拆分字符串
// */
// private static String[] splitString(String string, int len) {
// int x = string.length() / len;
// int y = string.length() % len;
// int z = 0;
// if (y != 0) {
// z = 1;
// }
// String[] strings = new String[x + z];
// String str = "";
// for (int i = 0; i < x + z; i++) {
// if (i == x + z - 1 && y != 0) {
// str = string.substring(i * len, i * len + y);
// } else {
// str = string.substring(i * len, i * len + len);
// // 输出buffer大小为nBlock个decryptBlockSize
// ByteArrayOutputStream outbuf = new ByteArrayOutputStream(nBlock * decryptBlockSize);
// // 分段解密
// for (int offset = 0; offset < encryptedBytes.length; offset += keyByteSize) {
// // block大小: decryptBlock 剩余字节数
// int inputLen = encryptedBytes.length - offset;
// if (inputLen > keyByteSize) {
// inputLen = keyByteSize;
// }
// // 得到分段解密结果
// byte[] decryptedBlock = cipher.doFinal(encryptedBytes, offset, inputLen);
// // 追加结果到输出buffer中
// outbuf.write(decryptedBlock);
// }
// strings[i] = str;
// outbuf.flush();
// outbuf.close();
// return outbuf.toByteArray();
// } catch (NoSuchAlgorithmException e) {
// throw new ServiceException(String.format("没有[%s]此类解密算法", CIPHERALGORITHM));
// } catch (NoSuchPaddingException e) {
// throw new ServiceException(String.format("没有[%s]此类填充模式", CIPHERALGORITHM));
// } catch (InvalidKeyException e) {
// throw new ServiceException("无效密钥");
// } catch (IllegalBlockSizeException e) {
// throw new ServiceException("解密块大小不合法");
// } catch (BadPaddingException e) {
// throw new ServiceException("错误填充模式");
// } catch (IOException e) {
// throw new ServiceException("字节输出流异常");
// }
// return strings;
// }
//
// /**
// * 拆分数组
// */
// private static byte[][] splitArray(byte[] data, int len) {
// int x = data.length / len;
// int y = data.length % len;
// int z = 0;
// if (y != 0) {
// z = 1;
// }
// byte[][] arrays = new byte[x + z][];
// byte[] arr;
// for (int i = 0; i < x + z; i++) {
// arr = new byte[len];
// if (i == x + z - 1 && y != 0) {
// System.arraycopy(data, i * len, arr, 0, y);
// } else {
// System.arraycopy(data, i * len, arr, 0, len);
// }
// arrays[i] = arr;
// }
// return arrays;
// }
//
//
// public static void main(String[] args) throws Exception {
// Map<String, Object> map=initRSAKeys();
// System.out.println("publickey:"+map.get("pubKey"));
// System.out.println("privatekey:"+map.get("priKey"));
//
// String code=encryptByPublicKey("16232c1f0459856a11d0d735d5ab7c632a82a2a625c67392ae00048b17075a03","MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDG0BwuxagDwPcWdeDn+tM/lxAICVpoj4fhKnlNYnZFN7HMjrgNjvN3Hf1yrVvnwb/4P04PP/Ck8KLBQJASGWVnSBNqbF2C03XsaEBDYUdaumBED9hxN1tWZs/vDAZB3CQwafPce4XsjffjZFx3K2t7MO4kBc8iB5AU2w96Jmjf/QIDAQAB");
////
// System.out.println("加密数据:"+code);
////
//// System.out.println(decryptByPrivateKey(code,"MIIBNwIBADANBgkqhkiG9w0BAQEFAASCASEwggEdAgEAAoGBAO6kUESLQMrDdnDbIqKikzpw94f1WKF5MWMWhNJDYaqHV99hW1YJMiKpqVxaEzNlNKiOI3VISEXSnK2LTfbBGNFOFtxjcy3WlJ0nVoAXMzvyebIX/1cr2nCnN9F73jjB3kxsOV5OCurPb+MJy3q4KAh1IMb/Pq6+oomhRSg2F9RPAgEAAoGBAKRyNCHXt9FBuldwmkBqOXxXJivZRLcY1ZCLjwF5j068ry/uXcs+0P6T3XIXXA3Zmtzf/c0u/yamSHNKgHIehCM6tlXWtuiDA4Ko5i8e2fQPLQgQ3EBJS51AxCW4H6AOnu9Usu27uC6ZA/C9p/TPGFtoLV+9/98JkpHDx6Xzc+SRAgEAAgEAAgEAAgEAAgEA"));
// }
//}
}

View File

@ -1,4 +1,4 @@
package com.chaozhanggui.admin.system.util;
package com.chaozhanggui.common.system.util;
import cn.hutool.crypto.digest.MD5;
import org.apache.commons.lang3.StringUtils;

View File

@ -1,2 +1,5 @@
parameter:
ZY_ALI_APP_ID: 2021003175619219
ZY_ALI_APP_ID: 2021003175619219
domain: https://ky.sxczgkj.cn
#随行付相关
alipayChannel: 2088441721243954

View File

@ -19,6 +19,8 @@ public interface TbPlussAccountMapper {
TbPlussAccount selectByUser(@Param("userId") Integer userId, @Param("channelType")String channelType);
TbPlussAccount selectByAccount(TbPlussAccount record);
TbPlussAccount selectByAccountD1(@Param("userId") String userId,@Param("channelType") String channelType);
//默认结算方式
TbPlussAccount selectDefault(@Param("userId") Integer userId);
int updateByPrimaryKeySelective(TbPlussAccount record);
int updateByPrimaryKeyWithBLOBs(TbPlussAccount record);
@ -30,4 +32,5 @@ public interface TbPlussAccountMapper {
Integer selectCountBankCard(@Param("bankCardId")String bankCardId, @Param("userId")String userId);
Integer selectMicroMbiAccountNum(@Param("certNo") String certNo);
Integer selectYSAuditSmallCount(@Param("userId") String userId);
}

View File

@ -30,9 +30,12 @@ public interface TbPlussMerchantChannelStatusMapper {
TbPlussMerchantChannelStatus getByMerchantCodeAndChannelType(String merchantCode, String virChannelFlag);
Map<String,Object> selectByUserId(@Param("userId") String userId, @Param("channel") String channel);
TbPlussMerchantChannelStatus getByCodeAndChannelFlag(@Param("merchantCode") String merchantCode, @Param("virChannelFlag") String virChannelFlag);
TbPlussMerchantChannelStatus getByCodeNullChannel(@Param("merchantCode") String merchantCode);
TbPlussMerchantChannelStatus getByMerchantCode(@Param("merchantCode") String merchantCode,@Param("channel") String channel );
TbPlussMerchantChannelStatus getByIdLock(@Param("id") Integer id);
List<TbPlussMerchantChannelStatus> getByMerchantCodeList(@Param("merchantCode") String merchantCode);

View File

@ -5,6 +5,8 @@ import com.chaozhanggui.dao.system.entity.TbPlussMerchantRejectDesc;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface TbPlussMerchantRejectDescMapper {
@ -15,6 +17,7 @@ public interface TbPlussMerchantRejectDescMapper {
int insertSelective(TbPlussMerchantRejectDesc record);
TbPlussMerchantRejectDesc selectByPrimaryKey(Integer id);
List<TbPlussMerchantRejectDesc> selectRejectList();
int updateByPrimaryKeySelective(TbPlussMerchantRejectDesc record);

View File

@ -3,6 +3,7 @@ package com.chaozhanggui.dao.system.dao;
import com.chaozhanggui.dao.system.entity.TbPlussRegionCodeYs;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@Component
@ -19,4 +20,6 @@ public interface TbPlussRegionCodeYsMapper {
int updateByPrimaryKeySelective(TbPlussRegionCodeYs record);
int updateByPrimaryKey(TbPlussRegionCodeYs record);
TbPlussRegionCodeYs selectRegionCode(@Param("province") String province, @Param("city") String city, @Param("area") String area);
}

View File

@ -6,6 +6,26 @@ import java.io.Serializable;
import java.util.Date;
public class TbPlussMerchantBaseInfo implements Serializable {
/** 商户类型-小微 */
public static final String MERCH_TYPE_MICRO = "1";
/** 商户类型-个体户 */
public static final String MERCH_TYPE_INDIVIDUAL = "2";
/** 商户类型-企业 */
public static final String MERCH_TYPE_COMPANY = "3";
/** 不支持信用卡交易 **/
public static final String LIMIT_PAY_TYPE_NO_CREDIT = "1";
/** 不限制信用卡交易 **/
public static final String LIMIT_PAY_TYPE_ALL = "0";
/** 不分账 **/
public static final Integer SPLIT_FLAG_NO = 1;
/** 分账 **/
public static final Integer SPLIT_FLAG_YES = 2;
private Integer id;
private String bindingcode;

View File

@ -119,7 +119,27 @@
AND mcs.`status` IN (3)
AND ic.certNo = #{certNo}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<select id="selectDefault" resultType="com.chaozhanggui.dao.system.entity.TbPlussAccount">
SELECT *
FROM tb_pluss_account
WHERE userId = #{userId}
AND valid = 1
</select>
<select id="selectYSAuditSmallCount" resultType="java.lang.Integer">
SELECT count(DISTINCT a.userId) FROM tb_pluss_account a
LEFT JOIN tb_pluss_merchant_base_info mbi ON a.userId = mbi.userId
LEFT JOIN tb_pluss_merchant_channel_status mcs ON mbi.merchantCode = mcs.merchantCode
LEFT JOIN tb_pluss_id_card ic ON ic.id = a.idcardId
WHERE mcs.`status` IN (3, 7) AND mbi.merchantType = 1 AND mcs.channel = 4
AND ic.certNo = (
SELECT DISTINCT ic.certNo FROM tb_pluss_account a
LEFT JOIN tb_pluss_merchant_base_info mbi ON a.userId = mbi.userId
LEFT JOIN tb_pluss_merchant_channel_status mcs ON mbi.merchantCode = mcs.merchantCode
LEFT JOIN tb_pluss_id_card ic ON ic.id = a.idcardId
WHERE mbi.userId = #{userId}
)
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_pluss_account
where id = #{id,jdbcType=INTEGER}
</delete>

View File

@ -438,4 +438,20 @@
ORDER BY valid DESC, id ASC
LIMIT 1;
</select>
<select id="getByCodeAndChannelFlag"
resultType="com.chaozhanggui.dao.system.entity.TbPlussMerchantChannelStatus">
SELECT * FROM tb_pluss_merchant_channel_status
WHERE merchantCode=#{merchantCode}
AND virChannelFlag=#{virChannelFlag}
</select>
<select id="getByCodeNullChannel"
resultType="com.chaozhanggui.dao.system.entity.TbPlussMerchantChannelStatus">
SELECT * FROM tb_pluss_merchant_channel_status
WHERE merchantCode=#{merchantCode}
AND channel IS NULL LIMIT 1
</select>
<select id="getByIdLock" resultType="com.chaozhanggui.dao.system.entity.TbPlussMerchantChannelStatus">
SELECT * FROM tb_pluss_merchant_channel_status
WHERE id = #{id} FOR UPDATE;
</select>
</mapper>

View File

@ -17,7 +17,11 @@
from tb_pluss_merchant_reject_desc
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<select id="selectRejectList" resultType="com.chaozhanggui.dao.system.entity.TbPlussMerchantRejectDesc">
select rejectName
from tb_pluss_merchant_reject_desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_pluss_merchant_reject_desc
where id = #{id,jdbcType=INTEGER}
</delete>

View File

@ -19,7 +19,17 @@
from tb_pluss_region_code_ys
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<select id="selectRegionCode" resultType="com.chaozhanggui.dao.system.entity.TbPlussRegionCodeYs">
SELECT sxf.id, sxf.province, sxf.provinceCode, sxf.city, sxf.cityCode, sxf.area, sxf.areaCode
FROM tb_pluss_region_code_ys sxf
LEFT JOIN tb_pluss_region_reflect rr ON sxf.id = rr.regionDes
LEFT JOIN tb_pluss_region_code_ls ls ON ls.id = rr.regionSrc
WHERE rr.channel = 4
AND ls.province LIKE CONCAT(#{province}, "%")
AND ls.city = #{city}
AND ls.area = #{area}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_pluss_region_code_ys
where id = #{id,jdbcType=INTEGER}
</delete>

View File

@ -28,6 +28,11 @@
<artifactId>dao-api</artifactId>
<version>1.0.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.chaozhanggui.system</groupId>-->
<!-- <artifactId>admin</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -0,0 +1,11 @@
package com.chaozhanggui.merchant;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@EntityScan(basePackageClasses = MerchantConfig.class)
@ComponentScan(basePackageClasses = MerchantConfig.class)
public class MerchantConfig {
}

View File

@ -0,0 +1,136 @@
package com.chaozhanggui.merchant.entity.ys;
/**
* 经营信息详情
*/
public class BusInfo {
/**
* 营业执照号,非小微必填
*/
private String busNo;
/**
* 营业执照名称,非小微必填
*/
private String busNm;
/**
* 营业执照有效开始日期,非小微必填 格式为yyyyMMdd
*/
private String busCertBgn;
/**
* 营业执照有效期,非小微必填 格式为yyyyMMdd
*/
private String busCertExpire;
/**
* 营业归属省代码,通过"地区信息查询"接口获取cityCd
*/
private String busProviceCode;
/**
* 营业归属市代码,通过"地区信息查询"接口获取cityCd
*/
private String busCityCode;
/**
* 营业归属区()代码,通过"地区信息查询"接口获取cityCd城市下有区(县必填)城市下无区()则不上送如广东省中山市广东省东莞市
*/
private String busAreaCode;
/**
* 营业执照证件类型,默认 19 社会统一信用代码
*/
private String busCertType;
/**
* 营业详细地址,需包含省市区示例广东省深圳市龙华新区大道513号远景大厦
*/
private String busAddr;
/**
* 注册地址,默认 营业地址一致
*/
private String regAddr;
public String getBusNo() {
return busNo;
}
public void setBusNo(String busNo) {
this.busNo = busNo;
}
public String getBusNm() {
return busNm;
}
public void setBusNm(String busNm) {
this.busNm = busNm;
}
public String getBusCertBgn() {
return busCertBgn;
}
public void setBusCertBgn(String busCertBgn) {
this.busCertBgn = busCertBgn;
}
public String getBusCertExpire() {
return busCertExpire;
}
public void setBusCertExpire(String busCertExpire) {
this.busCertExpire = busCertExpire;
}
public String getBusProviceCode() {
return busProviceCode;
}
public void setBusProviceCode(String busProviceCode) {
this.busProviceCode = busProviceCode;
}
public String getBusCityCode() {
return busCityCode;
}
public void setBusCityCode(String busCityCode) {
this.busCityCode = busCityCode;
}
public String getBusAreaCode() {
return busAreaCode;
}
public void setBusAreaCode(String busAreaCode) {
this.busAreaCode = busAreaCode;
}
public String getBusCertType() {
return busCertType;
}
public void setBusCertType(String busCertType) {
this.busCertType = busCertType;
}
public String getBusAddr() {
return busAddr;
}
public void setBusAddr(String busAddr) {
this.busAddr = busAddr;
}
public String getRegAddr() {
return regAddr;
}
public void setRegAddr(String regAddr) {
this.regAddr = regAddr;
}
}

View File

@ -0,0 +1,50 @@
package com.chaozhanggui.merchant.entity.ys;
import com.chaozhanggui.dao.system.entity.TbPlussBankCard;
import com.chaozhanggui.dao.system.entity.TbPlussIdCard;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantBaseInfo;
/**
* @author lyf
*/
public class CombineMercInfo {
private TbPlussMerchantBaseInfo mbi;
private TbPlussIdCard legalIdCard;
private TbPlussIdCard settleIdCard;
private TbPlussBankCard bankCard;
public TbPlussMerchantBaseInfo getMbi() {
return mbi;
}
public void setMbi(TbPlussMerchantBaseInfo mbi) {
this.mbi = mbi;
}
public TbPlussIdCard getLegalIdCard() {
return legalIdCard;
}
public void setLegalIdCard(TbPlussIdCard legalIdCard) {
this.legalIdCard = legalIdCard;
}
public TbPlussIdCard getSettleIdCard() {
return settleIdCard;
}
public void setSettleIdCard(TbPlussIdCard settleIdCard) {
this.settleIdCard = settleIdCard;
}
public TbPlussBankCard getBankCard() {
return bankCard;
}
public void setBankCard(TbPlussBankCard bankCard) {
this.bankCard = bankCard;
}
}

View File

@ -0,0 +1,143 @@
package com.chaozhanggui.merchant.entity.ys;
import java.util.List;
/**
* 法人信息
* @author lyf
*/
public class CrpInfo {
/**
* 法人证件号
*/
private String crpCertNo;
/**
* 法人证件类型,暂时只支持 00 身份证
*/
private String crpCertType = "00";
/**
* 证件开始日期,证件开始日期yyyyMMdd
*/
private String certBgn;
/**
* 证件有效期,日期格式yyyyMMdd 如果为长期或者永久请填值29991231
*/
private String certExpire;
/**
* 法人国籍,法人国籍(默认中国(249))
*/
private String crpNati;
/**
* 法人姓名
*/
private String crpNm;
/**
* 法人手机号
*/
private String crpPhone;
/**
* crpAddr 法人地址
*/
private String crpAddr;
/**
* 可不填
*/
private PersonInfo actContrInfo;
private PersonInfo authInfo;
private List<PersonInfo> bnfList;
public String getCrpCertNo() {
return crpCertNo;
}
public void setCrpCertNo(String crpCertNo) {
this.crpCertNo = crpCertNo;
}
public String getCrpCertType() {
return crpCertType;
}
public void setCrpCertType(String crpCertType) {
this.crpCertType = crpCertType;
}
public String getCertBgn() {
return certBgn;
}
public void setCertBgn(String certBgn) {
this.certBgn = certBgn;
}
public String getCertExpire() {
return certExpire;
}
public void setCertExpire(String certExpire) {
this.certExpire = certExpire;
}
public String getCrpNati() {
return crpNati;
}
public void setCrpNati(String crpNati) {
this.crpNati = crpNati;
}
public String getCrpNm() {
return crpNm;
}
public void setCrpNm(String crpNm) {
this.crpNm = crpNm;
}
public String getCrpPhone() {
return crpPhone;
}
public void setCrpPhone(String crpPhone) {
this.crpPhone = crpPhone;
}
public String getCrpAddr() {
return crpAddr;
}
public void setCrpAddr(String crpAddr) {
this.crpAddr = crpAddr;
}
public PersonInfo getActContrInfo() {
return actContrInfo;
}
public void setActContrInfo(PersonInfo actContrInfo) {
this.actContrInfo = actContrInfo;
}
public PersonInfo getAuthInfo() {
return authInfo;
}
public void setAuthInfo(PersonInfo authInfo) {
this.authInfo = authInfo;
}
public List<PersonInfo> getBnfList() {
return bnfList;
}
public void setBnfList(List<PersonInfo> bnfList) {
this.bnfList = bnfList;
}
}

View File

@ -0,0 +1,143 @@
package com.chaozhanggui.merchant.entity.ys;
/**
*银盛基本信息
*/
public class CustInfo {
/**
* 代理商编号,默认同发起方代理商编号不是必填
*/
private String agtMercId;
/**
* 商户名称必填
*/
private String mercName;
/**
* 商户简称,默认为商户名称若商户名称长度超过20,商户简称必传
*/
private String mercShortName;
/**
* 商户类型,2 小微 3个体 4企业
*/
private String mercType;
/**
* mcc码,通过"查询MCC码"接口获取mccCd
*/
private String mccCd;
/**
* 联系人邮箱
*/
private String contactMail;
/**
* 联系人电话, 默认同法人电话号码
*/
private String contactMan;
/**
* 客户经理
*/
private String cusMgrNm;
/**
* 是否开通营销,Y开通N不开通,默认不开通
*/
private String isOpenMarket;
/**
* 异步通知地址,银盛通过商户提供的地址下发通知商户可根据异步通知业务参数bizContent中的notifyType确定通知类型具体通知内容场景以及接口要求详见如下
*/
private String notifyUrl;
private String remark;
public String getAgtMercId() {
return agtMercId;
}
public void setAgtMercId(String agtMercId) {
this.agtMercId = agtMercId;
}
public String getMercName() {
return mercName;
}
public void setMercName(String mercName) {
this.mercName = mercName;
}
public String getMercShortName() {
return mercShortName;
}
public void setMercShortName(String mercShortName) {
this.mercShortName = mercShortName;
}
public String getMercType() {
return mercType;
}
public void setMercType(String mercType) {
this.mercType = mercType;
}
public String getMccCd() {
return mccCd;
}
public void setMccCd(String mccCd) {
this.mccCd = mccCd;
}
public String getContactMail() {
return contactMail;
}
public void setContactMail(String contactMail) {
this.contactMail = contactMail;
}
public String getContactMan() {
return contactMan;
}
public void setContactMan(String contactMan) {
this.contactMan = contactMan;
}
public String getCusMgrNm() {
return cusMgrNm;
}
public void setCusMgrNm(String cusMgrNm) {
this.cusMgrNm = cusMgrNm;
}
public String getIsOpenMarket() {
return isOpenMarket;
}
public void setIsOpenMarket(String isOpenMarket) {
this.isOpenMarket = isOpenMarket;
}
public String getNotifyUrl() {
return notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

View File

@ -0,0 +1,46 @@
package com.chaozhanggui.merchant.entity.ys;
/**
* @author lyf
*/
public class MercInfo {
private CustInfo custInfo;
private CrpInfo crpInfo;
private StlAccInfo stlAccInfo;
private BusInfo busInfo;
public CustInfo getCustInfo() {
return custInfo;
}
public void setCustInfo(CustInfo custInfo) {
this.custInfo = custInfo;
}
public CrpInfo getCrpInfo() {
return crpInfo;
}
public void setCrpInfo(CrpInfo crpInfo) {
this.crpInfo = crpInfo;
}
public StlAccInfo getStlAccInfo() {
return stlAccInfo;
}
public void setStlAccInfo(StlAccInfo stlAccInfo) {
this.stlAccInfo = stlAccInfo;
}
public BusInfo getBusInfo() {
return busInfo;
}
public void setBusInfo(BusInfo busInfo) {
this.busInfo = busInfo;
}
}

View File

@ -0,0 +1,90 @@
package com.chaozhanggui.merchant.entity.ys;
/**
* @author lyf
*/
public class PersonInfo extends com.alipay.api.domain.PersonInfo{
/**
* 实际控制人姓名
*/
private String name;
/**
* 实际控制人证件类型
*/
private String certType;
/**
* 实际控制人证件号
*/
private String certNo;
/**
* 实际控制人证件起始日期,格式YYYYMMDD
*/
private String certBgn;
/**
* 实际控制人证件有效期,格式YYYYMMDD
*/
private String certExpire;
/**
* 实际控制人证件地址
*/
private String addr;
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getCertType() {
return certType;
}
@Override
public void setCertType(String certType) {
this.certType = certType;
}
@Override
public String getCertNo() {
return certNo;
}
@Override
public void setCertNo(String certNo) {
this.certNo = certNo;
}
public String getCertBgn() {
return certBgn;
}
public void setCertBgn(String certBgn) {
this.certBgn = certBgn;
}
public String getCertExpire() {
return certExpire;
}
public void setCertExpire(String certExpire) {
this.certExpire = certExpire;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
}

View File

@ -0,0 +1,7 @@
package com.chaozhanggui.merchant.entity.ys;
public class Req {
public static class Url {
public static final String PREFIX = "https://ysgate.ysepay.com/openapi/";
}
}

View File

@ -0,0 +1,123 @@
package com.chaozhanggui.merchant.entity.ys;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.util.Date;
@Getter
public class ReqEntity {
private String timeStamp;
private String method;
private String charset = "utf-8";
private String sign;
private String check;
private String bizContent;
private String reqId;
private String certId = "826521773920170";
private String version = "1.0";
public static ReqEntity get(ReqMethods reqMethod) {
Date date = new Date();
ReqEntity entity = new ReqEntity();
entity.timeStamp = DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
entity.method = reqMethod.getMethod();
entity.reqId = "SYB_" + RandomUtil.randomString(4) + DateUtil.format(date, "yyMMddHHmmss");
return entity;
}
public static ReqEntity get(ReqMethod reqMethod) {
Date date = new Date();
ReqEntity entity = new ReqEntity();
entity.timeStamp = DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
entity.method = reqMethod.getMethod();
entity.reqId = "SYB_" + RandomUtil.randomString(4) + DateUtil.format(date, "yyMMddHHmmss");
return entity;
}
public String getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(String timeStamp) {
this.timeStamp = timeStamp;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getCharset() {
return charset;
}
public void setCharset(String charset) {
this.charset = charset;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getCheck() {
return check;
}
public void setCheck(String check) {
this.check = check;
}
public String getBizContent() {
return bizContent;
}
public void setBizContent(String bizContent) {
this.bizContent = bizContent;
}
public String getReqId() {
return reqId;
}
public void setReqId(String reqId) {
this.reqId = reqId;
}
public String getCertId() {
return certId;
}
public void setCertId(String certId) {
this.certId = certId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}

View File

@ -0,0 +1,58 @@
package com.chaozhanggui.merchant.entity.ys;
import lombok.Getter;
/**
* 银盛常用的url
*/
@Getter
public enum ReqMethod {
addCustInfoApply(Req.Url.PREFIX + "t1/smsc/addCustInfoApply"),
modifyCustInfoApply(Req.Url.PREFIX + "smsc/modifyCustInfoApply"),
upload(Req.Url.PREFIX + "file/smsc/upload"),
auditCustInfoApply(Req.Url.PREFIX + "t1/smsc/auditCustInfoApply"),
queryCustApply(Req.Url.PREFIX + "smsc/queryCustApply"),
sign(Req.Url.PREFIX + "t1/smsc/sign"),
sendSmsOrEmailMsg(Req.Url.PREFIX + "smsc/sign/sendSmsOrEmailMsg"),
queryAuthInfo(Req.Url.PREFIX + "smsc/saas/constract/queryAuthInfo"),
queryContract(Req.Url.PREFIX + "smsc/sign/queryContract"),
sweepReport(Req.Url.PREFIX + "smsc/saas/sweep/sweepreport"),
reportAgain(Req.Url.PREFIX + "smsc/saas/sweep/reportAgain"),
changeMercBaseInfo(Req.Url.PREFIX + "smsc/changeMercBaseInfo"),
uploadChangePic(Req.Url.PREFIX + "file/smsc/uploadChangePic"),
queryCustChange(Req.Url.PREFIX + "smsc/queryCustChange"),
changeMercStlAccInfo(Req.Url.PREFIX + "t1/smsc/changeMercStlAccInfo"),
changeRate(Req.Url.PREFIX + "smsc/changeRate"),
openOnlinePay(Req.Url.PREFIX + "smsc/saas/authority/online"),
regionList(Req.Url.PREFIX + "pregate/trade/findCmmtAreaInfoList"),
repAndAppIdQry(Req.Url.PREFIX + "report/scan/union/repAndAppIdQry"),
/**
* 支付宝实名认证状态查询
*/
aliAuthStatus(Req.Url.PREFIX + "pregate/alipay/getAuthState"),
/**
* 新增报备
*/
Reporting(Req.Url.PREFIX+"report/scan/union/reportAdd"),
/**
* 新增/修改appid
*/
appIdAddOrUpdate(Req.Url.PREFIX+"report/scan/union/appIdAddOrUpdate")
;
private final String url;
private final String method;
ReqMethod(String url, String method) {
this.url = url;
this.method = method;
}
ReqMethod(String url) {
this(url, url.replace(Req.Url.PREFIX, "").replace('/', '.'));
}
}

View File

@ -0,0 +1,34 @@
package com.chaozhanggui.merchant.entity.ys;
import lombok.Getter;
/**
* 银盛进件接口部分参数常量
*/
@Getter
public enum ReqMethods {
MERCHANT_ADD("Merchant", "addScanMerchant"),
MERCHANT_EDIT("Merchant", "updateScanMerchant"),
MERCHANT_APPLY("Merchant", "autoAuditTerm"),
MERCHANT_QUERY("Merchant", "queryMerchant"),
MERCHANT_PROTOCOL_STATUS("Merchant", "querySignSts"),
MERCHANT_SEND_MSG("Merchant", "sendScanSmsCode"),
MERCHANT_ONLINE_TRADING("Merchant", "onlineTrading"),
MERCHANT_OPT_ONLINE_D0("Merchant", "optOnlineD0"),
MERCHANT_BASE_INFO_CHANGE("Merchant", "changeMerInfo"),
MERCHANT_ACCOUNT_CHANGE("Merchant", "changeMerAccInfo"),
MERCHANT_EDIT_RESULT("Merchant", "queryModifyStatus"),
MERCHANT_CHANGE_ONLINE_FEE("Merchant", "changeMerOnlineFee");
@Getter
private final String msgCode;
@Getter
private final String method;
ReqMethods(String msgCode, String method) {
this.msgCode = msgCode;
this.method = method;
}
}

View File

@ -0,0 +1,108 @@
package com.chaozhanggui.merchant.entity.ys;
public class RespEntity {
/**
* 网关响应码
*/
private String code;
/**
* 网关响应码描述
*/
private String msg;
/**
* 业务响应码
*/
private String subCode;
/**
* 业务响应描述
*/
private String subMsg;
/**
* yyyy-MM-dd HH:mm:ss
*/
private String timeStamp;
/**
* 随机参数
*/
private String norce;
/**
* 签名串
*/
private String sign;
/**
* 业务响应参数集合
* 加密后的数据
*/
private String businessData;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getSubCode() {
return subCode;
}
public void setSubCode(String subCode) {
this.subCode = subCode;
}
public String getSubMsg() {
return subMsg;
}
public void setSubMsg(String subMsg) {
this.subMsg = subMsg;
}
public String getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(String timeStamp) {
this.timeStamp = timeStamp;
}
public String getNorce() {
return norce;
}
public void setNorce(String norce) {
this.norce = norce;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getBusinessData() {
return businessData;
}
public void setBusinessData(String businessData) {
this.businessData = businessData;
}
}

View File

@ -0,0 +1,134 @@
package com.chaozhanggui.merchant.entity.ys;
public class StlAccInfo {
/**
* 是否平台内账户,Y是 N否默认否
*/
private String isSettInPlatAcc;
/**
* 是否非法人结算,Y是 N否默认否
*/
private String isUncrpSett;
/**
* 结算户名,默认法人姓名, 非法人结算必填
*/
private String stlAccNm;
/**
* 结算账号
*/
private String stlAccNo;
/**
* 开户支行联行号,通过"行名行号查询"获取bankCode
*/
private String bankSubCode;
/**
* 结算账户类型,11 对私 21 对公 23 对公存折 24 单位结算卡
*/
private String stlAccType;
/**
* 银行预留手机号,非法人结算必填
*/
private String bankMobile;
/**
* 开开户证件号,默认法人证件号,非法人结算必填
*/
private String openCertNo;
/**
* 银行开户行所属省代码,银行开户行所属市代码都填或都不填
*/
private String bankProince;
/**
* 银行开户行所属市代码,银行开户行所属省代码都填或都不填
*/
private String bankCity;
public String getIsSettInPlatAcc() {
return isSettInPlatAcc;
}
public void setIsSettInPlatAcc(String isSettInPlatAcc) {
this.isSettInPlatAcc = isSettInPlatAcc;
}
public String getIsUncrpSett() {
return isUncrpSett;
}
public void setIsUncrpSett(String isUncrpSett) {
this.isUncrpSett = isUncrpSett;
}
public String getStlAccNm() {
return stlAccNm;
}
public void setStlAccNm(String stlAccNm) {
this.stlAccNm = stlAccNm;
}
public String getStlAccNo() {
return stlAccNo;
}
public void setStlAccNo(String stlAccNo) {
this.stlAccNo = stlAccNo;
}
public String getBankSubCode() {
return bankSubCode;
}
public void setBankSubCode(String bankSubCode) {
this.bankSubCode = bankSubCode;
}
public String getStlAccType() {
return stlAccType;
}
public void setStlAccType(String stlAccType) {
this.stlAccType = stlAccType;
}
public String getBankMobile() {
return bankMobile;
}
public void setBankMobile(String bankMobile) {
this.bankMobile = bankMobile;
}
public String getOpenCertNo() {
return openCertNo;
}
public void setOpenCertNo(String openCertNo) {
this.openCertNo = openCertNo;
}
public String getBankProince() {
return bankProince;
}
public void setBankProince(String bankProince) {
this.bankProince = bankProince;
}
public String getBankCity() {
return bankCity;
}
public void setBankCity(String bankCity) {
this.bankCity = bankCity;
}
}

View File

@ -0,0 +1,231 @@
package com.chaozhanggui.merchant.entity.ys;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Data
@Component
@ConfigurationProperties(prefix = "ys")
public class YsConfig {
private String auditDomain;
private String payDomain;
private String searchDomain;
private String commonDomain;
private String otherDomain;
private String settleDomain;
private String agentNo;
private String srcMerchantNo;
private String pubKey;
private String priKey;
private String oldPubKey;
/**
* 进件图片上传的接口链接
*/
public static String IMG_UPLOAD;
/**
* 进件接口
*/
public static String MER_AUDIT;
/**
* 进件结果查询接口
*/
public static String MER_RESULT;
/**
* 微信认证
*/
public static String WX_AUTH;
/**
* 微信认证取消
*/
public static String WX_AUTH_CANCEL;
/**
* 微信认证状态查询
*/
public static String WX_AUTH_STATUS;
/**
* 微信认证授权状态查询
*/
public static String WX_AUTHORIZE_STATUS;
/**
* 微信反扫接口地址
*/
public static String WX_BARCODE_PAY;
/**
* 微信公众号支付接口地址
*/
public static String WX_JSAPI_PAY;
/**
* 微信小程序支付
*/
public static String WX_APPLETS_PAY;
/**
* 支付宝反扫接口地址
*/
public static String ALI_BARCODE_PAY;
/**
* 支付宝服务窗支付接口地址
*/
public static String ALI_JSAPI_PAY;
/**
* 银联反扫接口地址
*/
public static String UNI_BARCODE_PAY;
/**
* 银联服务窗支付接口地址
*/
public static String UNI_JSAPI_PAY;
/**
* 退款请求地址
*/
public static String REFUND_PAY;
/**
* 退款查询请求地址
*/
public static String REFUND_QUERY;
/**
* 支付订单查询请求地址
*/
public static String PAY_ORDER_QUERY;
/**
* 支付订单详情请求地址
*/
public static String PAY_ORDER_DETAIL_QUERY;
/**
* 获取银联用户标识
*/
public static String GET_UNION_USER_ID;
/**
* 结算提现接口地址
*/
public static String SETTLE_TRADE;
/**
* 提现接口查询地址
*/
public static String SETTLE_TRADE_QUERY;
/**
* 响应状态成功
*/
public static final String RESULT_SUCCESS_CODE = "success";
/**
* 响应状态失败
*/
public static final String YS_RESULT_FAIL_CODE = "fail";
public static final String YS_RESULT_PAY_SUCCESS_CODE = "success";
public static final String YS_RESULT_PAY_FAIL_CODE = "fail";
public static final String YS_RESULT_WAITPAY_CODE = "waitpay";
public static final String YS_RESULT_UNKNOW_CODE = "unknow";
public static final String YS_RESULT_ACCEPT_CODE = "accept";
public static final String YS_RESULT_DFREVERSE_CODE = "dfreverse";
@PostConstruct
public void init() {
IMG_UPLOAD = auditDomain + "/gateway/file/merchantPic";
MER_AUDIT = auditDomain + "/gateway/merchant/add";
MER_RESULT = auditDomain + "/gateway/merchant/query";
WX_AUTH = auditDomain + "/gateway/merchant/wxAuthSubmitApply";
WX_AUTH_CANCEL = auditDomain + "/gateway/merchant/wxAuthCancelApply";
WX_AUTH_STATUS = auditDomain + "/gateway/merchant/wxAuthQueryByApplyNo";
WX_AUTHORIZE_STATUS = auditDomain + "/gateway/merchant/wxAuthState";
WX_BARCODE_PAY = payDomain + "/gateway/trade/wxBarCode";
WX_JSAPI_PAY = payDomain + "/gateway/trade/wxJs";
WX_APPLETS_PAY = payDomain + "/gateway/trade/wxMiniProgram";
ALI_BARCODE_PAY = payDomain + "/gateway/trade/alipayBarCode";
ALI_JSAPI_PAY = payDomain + "/gateway/trade/aliServicePay";
UNI_BARCODE_PAY = payDomain + "/gateway/trade/ylpayBarCode";
UNI_JSAPI_PAY = payDomain + "/gateway/trade/ylJsPay";
REFUND_PAY = payDomain + "/gateway/trade/applyRefund";
REFUND_QUERY = payDomain + "/gateway/trade/queryRefund";
PAY_ORDER_QUERY = payDomain + "/gateway/trade/queryOrder";
PAY_ORDER_DETAIL_QUERY = payDomain + "/gateway/trade/queryOrderDetail";
GET_UNION_USER_ID = payDomain + "/gateway/trade/ylUserId";
SETTLE_TRADE = payDomain + "/gateway/trade/withdraw";
SETTLE_TRADE_QUERY = payDomain + "/gateway/trade/withdrawQuery";
}
//旧版接口
// public String getPrikeyVal(String srcMerchantNo) {
// //获取秘钥
// if(StringUtil.isEmpty(srcMerchantNo) || YsOldSrcMerchantNo.RSCY.getValue().equals(srcMerchantNo)){
// return this.getPriKey();
// }
// return this.getOldPayV2().getPayPriKey();
// }
//
// public String getPubKeyVal(String srcMerchantNo) {
// //获取秘钥
// if(StringUtil.isEmpty(srcMerchantNo) || YsOldSrcMerchantNo.RSCY.getValue().equals(srcMerchantNo)){
// return this.getOldPubKey();
// }
// return this.getOldPayV2().getPayPubKey();
// }
}

View File

@ -0,0 +1,76 @@
package com.chaozhanggui.merchant.entity.ys;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @author 12847
*/
@Component
@ConfigurationProperties(prefix = "ys")
public class YsConfigV3 {
/**
* 发起方交易号
*/
private String srcMerchantNo;
@Value("agentNoV2")
private String agentNo;
@Value("agentNoD1")
private String agentNoD1;
@Value("srcMerchantNoD1")
private String srcMerchantNoD1;
@Value("priKeyV2D1")
private String priKeyV2D1;
@Value("pubKeyV2D1")
private String pubKeyV2D1;
public String getSrcMerchantNo() {
return srcMerchantNo;
}
public void setSrcMerchantNo(String srcMerchantNo) {
this.srcMerchantNo = srcMerchantNo;
}
public String getAgentNo() {
return agentNo;
}
public void setAgentNo(String agentNo) {
this.agentNo = agentNo;
}
public String getAgentNoD1() {
return agentNoD1;
}
public void setAgentNoD1(String agentNoD1) {
this.agentNoD1 = agentNoD1;
}
public String getSrcMerchantNoD1() {
return srcMerchantNoD1;
}
public void setSrcMerchantNoD1(String srcMerchantNoD1) {
this.srcMerchantNoD1 = srcMerchantNoD1;
}
public String getPriKeyV2D1() {
return priKeyV2D1;
}
public void setPriKeyV2D1(String priKeyV2D1) {
this.priKeyV2D1 = priKeyV2D1;
}
public String getPubKeyV2D1() {
return pubKeyV2D1;
}
public void setPubKeyV2D1(String pubKeyV2D1) {
this.pubKeyV2D1 = pubKeyV2D1;
}
}

View File

@ -1,7 +1,6 @@
package com.chaozhanggui.merchant.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.common.system.config.MsgException;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantBaseInfoMapper;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantChannelMapper;
@ -11,9 +10,11 @@ import com.chaozhanggui.dao.system.entity.TbPlussMerchantBaseInfo;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantChannel;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantChannelStatus;
import com.chaozhanggui.dao.system.entity.TbPlussUserInfo;
import com.chaozhanggui.merchant.service.sxf.SxfMerchantAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Map;
@Service
@ -33,7 +34,14 @@ public class MerchantService {
@Autowired
private LklAuditService lklAuditService;
@Resource
private SxfMerchantAuditService sxfMerchantAuditService;
/**
* 通用进件方法
* @param userId
* @param channelId
*/
public void merchantAudit(String userId, String channelId){
MsgException.checkBlank(channelId, "请选择进件通道");
MsgException.checkNull(userId,"请选择用户");
@ -79,6 +87,7 @@ public class MerchantService {
switch (channelId){
case "1":
sxfMerchantAuditService.merchantAudit(userId, false);
break;
case "2":
break;
@ -93,7 +102,6 @@ public class MerchantService {
}
break;
case "6":
break;

View File

@ -1,19 +1,24 @@
package com.chaozhanggui.admin.system.service;
package com.chaozhanggui.merchant.service.sxf;
import com.chaozhanggui.common.system.config.MsgException;
import com.chaozhanggui.dao.system.dao.TbPlussAccountMapper;
import com.chaozhanggui.dao.system.dao.TbPlussIdCardMapper;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantBaseInfoMapper;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantChannelStatusMapper;
import com.chaozhanggui.dao.system.entity.TbPlussIdCard;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantBaseInfo;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
/**
* 进件通用方法放到这里
* @author lyf
*
*/
@Slf4j
public abstract class BaseMerchantAuditService {
private static final int MAX_MIRCO_MERCHANT_NUM = 3;
@Resource
protected TbPlussMerchantChannelStatusMapper merchantChannelStatusMapper;
@Resource
@ -21,7 +26,7 @@ public abstract class BaseMerchantAuditService {
@Resource
protected TbPlussIdCardMapper idCardMapper;
@Resource
protected AccountService accountService;
protected TbPlussAccountMapper accountMapper;
/**
* 进件检测
* @param userId
@ -42,6 +47,17 @@ public abstract class BaseMerchantAuditService {
MsgException.checkBlank(principalPerson, "请完善营业执照信息");
}
accountService.checkCert(legalIdCard.getCertno(), "同一证件只能注册三个小微商户, 如有增加需求请联系客服");
//同一证件只能注册三个小微商户, 如有增加需求请联系客服
Integer num = 0;
try {
num = accountMapper.selectMicroMbiAccountNum(legalIdCard.getCertno());
} catch (Exception e) {
log.error(e.toString());
}
if (num >= MAX_MIRCO_MERCHANT_NUM) {
throw new MsgException("同一证件只能注册三个小微商户, 如有增加需求请联系客服");
}
}
}

View File

@ -1,6 +1,6 @@
package com.chaozhanggui.admin.system.service;
package com.chaozhanggui.merchant.service.sxf;
import com.chaozhanggui.admin.system.model.CommonError;
import com.chaozhanggui.common.system.config.MsgException;
import com.chaozhanggui.dao.system.dao.TbPlussIdCardMapper;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantBaseInfoMapper;
@ -8,6 +8,7 @@ import com.chaozhanggui.dao.system.dao.TbPlussMerchantChannelStatusMapper;
import com.chaozhanggui.dao.system.dao.TbPlussMerchantImageMapper;
import com.chaozhanggui.dao.system.entity.*;
import com.chaozhanggui.dao.system.entity.DTO.AccountDTO;
import com.chaozhanggui.merchant.service.sxf.model.CommonError;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -25,9 +26,11 @@ public class MerchantImageService {
@Resource
private TbPlussMerchantImageMapper merchantImageMapper;
@Resource
private AccountService accountService;
private MerchantImageService merchantImageService;
@Resource
private TbPlussIdCardMapper idCardMapper;
@Resource
private SxfMerchantAuditService sxfMerchantAuditService;
/**
* 根据用户id获取进件图片信息, 包含结算信息等.
@ -43,7 +46,7 @@ public class MerchantImageService {
//查询图片
List<TbPlussMerchantImage> miList = merchantImageMapper.getListOfMerch(merchantBaseInfo.getMerchantcode());
AccountDTO accountDTO = accountService.getRealAccount(userId, channelType);
AccountDTO accountDTO = sxfMerchantAuditService.getRealAccount(userId, channelType);
MsgException.checkNull(accountDTO.getIdcard(), CommonError.NO_ACCOUNT_ID_CARD);

View File

@ -1,8 +1,10 @@
package com.chaozhanggui.admin.system.service;
package com.chaozhanggui.merchant.service.sxf;
import com.chaozhanggui.common.system.config.MsgException;
import com.chaozhanggui.dao.system.dao.TbPlussRegionCodeSxfMapper;
import com.chaozhanggui.dao.system.dao.TbPlussRegionCodeYsMapper;
import com.chaozhanggui.dao.system.entity.TbPlussRegionCodeSxf;
import com.chaozhanggui.dao.system.entity.TbPlussRegionCodeYs;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -17,6 +19,8 @@ import javax.annotation.Resource;
public class RegionReflectService {
@Resource
private TbPlussRegionCodeSxfMapper regionCodeSxfMapper;
@Resource
private TbPlussRegionCodeYsMapper regionCodeYsMapper;
/**
* 获取随行付地区code信息
@ -39,4 +43,28 @@ public class RegionReflectService {
throw new MsgException("随行付获取地区信息异常");
}
}
/**
* 获取银盛地区code信息
*
* @param province
* @param city
* @param area /
* @return 地区信息
*/
public TbPlussRegionCodeYs getYsRegionCode(String province, String city, String area) {
try {
TbPlussRegionCodeYs regionCodeYs = regionCodeYsMapper.selectRegionCode(province, city, area);
if (regionCodeYs == null) {
throw new MsgException("银盛获取地区信息异常");
}
return regionCodeYs;
} catch (Exception e) {
e.printStackTrace();
log.error("===银盛获取地区信息异常===");
throw new MsgException("银盛获取地区信息异常");
}
}
}

View File

@ -1,4 +1,4 @@
package com.chaozhanggui.admin.system.service;
package com.chaozhanggui.merchant.service.sxf;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

View File

@ -1,21 +1,20 @@
package com.chaozhanggui.admin.system.service;
package com.chaozhanggui.merchant.service.sxf;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chaozhanggui.admin.system.util.RSAUtils;
import com.chaozhanggui.admin.system.util.SignUtils;
import com.chaozhanggui.admin.system.util.StringUtil;
import com.chaozhanggui.common.system.config.MsgException;
import com.chaozhanggui.common.system.config.channel.SxfConfig;
import com.chaozhanggui.common.system.util.FileUtil;
import com.chaozhanggui.common.system.util.ParametersUtil;
import com.chaozhanggui.common.system.util.*;
import com.chaozhanggui.dao.system.dao.*;
import com.chaozhanggui.dao.system.entity.*;
import com.chaozhanggui.dao.system.entity.DTO.AccountDTO;
import com.chaozhanggui.merchant.service.sxf.model.Converter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
@ -32,7 +31,7 @@ import java.util.*;
*/
@Service
@Slf4j
public class SxfMerchantAuditService extends BaseMerchantAuditService{
public class SxfMerchantAuditService extends BaseMerchantAuditService {
@Resource
private TbPlussMerchantBaseInfoMapper merchantBaseInfoMapper;
@ -50,7 +49,20 @@ public class SxfMerchantAuditService extends BaseMerchantAuditService{
private TbPlussIdCardMapper idCardMapper;
@Resource
private TbPlussBankCodeSxfMapper bankCodeSxfMapper;
@Resource
private TbPlussBankCardMapper bankCardMapper;
@Resource
private TbPlussAccountMapper accountMapper;
@Resource
private TbPlussUserAppMapper userAppMapper;
@Resource
private TbPlussMerchantImageMapper merchantImageMapper;
/**
* 进件
* @param userId
* @param isFailCheck
*/
@Transactional(rollbackFor = Exception.class)
public void merchantAudit(String userId, boolean isFailCheck) {
//进件检测
@ -143,7 +155,7 @@ public class SxfMerchantAuditService extends BaseMerchantAuditService{
JSONObject reqData = new JSONObject();
MsgException.checkBlank(merchantBaseInfo.getMerchanttype(), "请先填写商户资料");
AccountDTO accountDTO = accountService.getAccount(userId);
AccountDTO accountDTO = getAccount(userId);
List<TbPlussMerchantImage> merchantChannelImgList = merchantImageService.getListOfMerch(userId, TbPlussAccount.CHANNEL_TYPE_D1);
@ -450,7 +462,7 @@ public class SxfMerchantAuditService extends BaseMerchantAuditService{
*/
private void combineBankInfo(Map<String, Object> paramMap, String userId) {
// 结算信息
AccountDTO accountDTO = accountService.getRealAccount(userId);
AccountDTO accountDTO = getRealAccount(userId);
MsgException.checkNull(accountDTO, "请完善结算信息");
// 实名信息
@ -572,4 +584,124 @@ public class SxfMerchantAuditService extends BaseMerchantAuditService{
break;
}
}
public AccountDTO getAccount(String userId) {
TbPlussMerchantBaseInfo mbi = merchantBaseInfoMapper.selectByUserId(userId);
if (mbi == null) {
return getRealAccount(userId, TbPlussAccount.CHANNEL_TYPE_D1);
}
TbPlussMerchantChannelStatus mcs = getValidData(mbi.getMerchantcode());
if (mcs == null || !Objects.equals(mcs.getChannel(), 4)) {
return getRealAccount(userId, TbPlussAccount.CHANNEL_TYPE_D1);
} else {
return getRealAccount(userId, TbPlussAccount.CHANNEL_TYPE_D0);
}
}
/**
* 获取用户指定结算通道类型下的结算信息
*
* @param userId 用户id
* @param channelType 通道类型D1D0
* @return
*/
public AccountDTO getRealAccount(String userId, String channelType) {
if (!TbPlussAccount.CHANNEL_TYPE_D1.equals(channelType) && !TbPlussAccount.CHANNEL_TYPE_D0.equals(channelType)) {
throw new MsgException("未知的通道类型");
}
TbPlussAccount account = new TbPlussAccount();
account.setUserid(userId);
account.setChanneltype(channelType);
return getRealAccount(account);
}
public AccountDTO getRealAccount(TbPlussAccount account) {
String userId = account.getUserid();
if (account.getChanneltype() == null) {
throw new MsgException("缺少结算通道类型");
}
List<String> bloomFilter = new ArrayList<>(2);
bloomFilter.add(TbPlussAccount.CHANNEL_TYPE_D0);
bloomFilter.add(TbPlussAccount.CHANNEL_TYPE_D1);
if (!bloomFilter.contains(account.getChanneltype())) {
throw new MsgException("未知的结算类型");
}
account = accountMapper.selectByAccount(account);
AccountDTO accountDTO = Converter.toDTO(account);
TbPlussMerchantBaseInfo mbi = new TbPlussMerchantBaseInfo();
mbi.setUserid(Integer.valueOf(userId));
mbi = merchantBaseInfoMapper.selectByUserId(userId);
if (mbi == null) {
return null;
}
// 用户不存在结算信息
String merchantType = mbi.getMerchanttype();
if (account == null && "1".equals(merchantType)) {
AccountDTO result = new AccountDTO();
result.setUserid(String.valueOf(mbi.getUserid()));
result.setSettletype(TbPlussAccount.SETTLE_TYPE_MICRO_STORE);
return result;
}
// 异或小微但结算信息不是小微非小微但结算信息是小微
if (account == null || "1".equals(merchantType) ^ account.getSettletype().equals(TbPlussAccount.SETTLE_TYPE_MICRO_STORE)) {
return null;
}
// 获取身份证信息
TbPlussIdCard idCard = idCardMapper.selectByPrimaryKey(Integer.valueOf(account.getIdcardid()));
accountDTO.setIdcard(idCard);
// 获取银行卡信息
TbPlussBankCard bankCard = bankCardMapper.selectByPrimaryKey(Integer.valueOf(account.getBankcardid()));
accountDTO.setBankCard(bankCard);
if (account.getSettletype() == null) {
throw new MsgException("未知结算类型");
}
Optional.ofNullable(account.getSettletype()).ifPresent(s -> {
if (s.startsWith(TbPlussAccount.SETTLE_TYPE_PRIVATE_ILLEGAL)) {
TbPlussUserApp userApp = userAppMapper.selectByUserId(Integer.valueOf(userId));
TbPlussMerchantImage merchantImage = new TbPlussMerchantImage();
merchantImage.setMerchantcode(userApp.getMerchantcode());
merchantImage.setPhotoType(TbPlussMerchantImage.NON_LEG_SETTLE_AUTH);
merchantImage = merchantImageMapper.selectByMerchantCodeType(userApp.getMerchantcode(), TbPlussMerchantImage.NON_LEG_SETTLE_AUTH);
Optional.ofNullable(merchantImage).ifPresent(v -> accountDTO.setCertificateurl(v.getPicurl()));
}
});
TbPlussMerchantChannelStatus mcs = merchantChannelStatusMapper.getByMerchantCodeAndChannelType(mbi.getMerchantcode(), account.getChanneltype());
if (mcs == null || !TbPlussMerchantChannelStatus.AUDIT_STATUS_DATA_EDIT.equals(mcs.getStatus())) {
account.setBak(null);
}
return accountDTO;
}
public AccountDTO getRealAccount(String userId) {
return getRealAccount(userId, TbPlussAccount.CHANNEL_TYPE_D1);
}
public TbPlussMerchantChannelStatus getValidData(String merchantCode){
if (StringUtils.isEmpty(merchantCode)) {
return null;
}
TbPlussMerchantChannelStatus mcs = merchantChannelStatusMapper.getIncomingInfo(TbPlussMerchantChannelStatus.AUDIT_STATUS_SUCCESS,
TbPlussMerchantChannelStatus.AUDIT_STATUS_DATA_EDIT, merchantCode);
if (mcs != null) {
return mcs;
}
return merchantChannelStatusMapper.getIncomingInfoAnother(merchantCode);
}
}

View File

@ -1,4 +1,4 @@
package com.chaozhanggui.admin.system.model;
package com.chaozhanggui.merchant.service.sxf.model;
public class CommonError {

View File

@ -1,4 +1,4 @@
package com.chaozhanggui.admin.system.util;
package com.chaozhanggui.merchant.service.sxf.model;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.dao.system.entity.DTO.AccountDTO;

View File

@ -0,0 +1,492 @@
package com.chaozhanggui.merchant.service.ys;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.crypto.asymmetric.Sign;
import cn.hutool.crypto.asymmetric.SignAlgorithm;
import cn.hutool.crypto.symmetric.AES;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.chaozhanggui.common.system.config.MsgException;
import com.chaozhanggui.common.system.util.SignUtils;
import com.chaozhanggui.dao.system.dao.*;
import com.chaozhanggui.dao.system.entity.*;
import com.chaozhanggui.dao.system.entity.DTO.AccountDTO;
import com.chaozhanggui.merchant.entity.ys.*;
import com.chaozhanggui.merchant.service.sxf.RegionReflectService;
import com.chaozhanggui.merchant.service.sxf.SxfMerchantAuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;
import static com.chaozhanggui.dao.system.entity.TbPlussMerchantBaseInfo.MERCH_TYPE_MICRO;
/**银盛进件相关
* @author lyf
*/
@Service
@Slf4j
public class YSAuditServiceV3 {
public static final String INTERFACE_VERSION = "v3";
public static final String REQ_SUCCESS = "00000";
public static final String BIZ_SUCCESS = "0000";
//银盛进件回调
public static final String AUDIT_NOTIFY_URL = "https://ky.sxczgkj.cn/api/auditCallback/ysV3";
//银盛进件回调D1
public static final String AUDIT_NOTIFY_URL_D1 = "https://ky.sxczgkj.cn/api/auditCallback/ysV3D1";
//银盛签约回调
public static final String AUDIT_SIGN_NOTIFY_URL = "https://ky.sxczgkj.cn/api/auditCallback/ysSignV3";
/** 成功 */
public static final String STATUS_SUCCESS = "00";
/** 审核中 */
public static final String STATUS_IN_AUDIT = "02";
/** 转人工审核 */
public static final String STATUS_TO_MANUAL = "10";
/** 拒绝 */
public static final String STATUS_REFUSE = "90";
/** 签约拒绝,主动查询时候会存在该状态 */
public static final String STATUS_SIGN_REFUSE = "04";
/** 错误 */
public static final String STATUS_FAIL = "99";
@Resource
private TbPlussMerchantBaseInfoMapper merchantBaseInfoMapper;
@Resource
private TbPlussMccReflectMapper mccReflectMapper;
@Autowired
private YsConfigV3 ysConfigV3;
//将accountService中的部分方法搬过来了
@Resource
private SxfMerchantAuditService sxfMerchantAuditService;
@Resource
private TbPlussIdCardMapper idCardMapper;
@Resource
private RegionReflectService regionReflectService;
@Autowired
private YsConfig ysConfig;
@Autowired
private RestTemplate restTemplate;
@Resource
private TbPlussMerchantChannelStatusMapper merchantChannelStatusMapper;
@Resource
private TbPlussAccountMapper accountMapper;
/**
* 银盛进件3.0
* @param userId 用户id
*/
// public void merchantAuditV3(String userId, boolean isFailCheck, Integer channel) {
// try {
// self.step1(userId,channel);
// executorService.execute(() -> {
// try {
// self.step2(userId,channel);
// Thread.sleep(10000);
// self.step3(userId, channel);
// } catch (Exception e) {
// e.printStackTrace();
//
// MerchantBaseInfo mbi = mbiService.getMerchantBaseInfoByUserId(userId);
// MerchantChannelStatus mcs = mcsService.getByMerchantCode(mbi.getMerchantCode(), channel);
//
// if (e instanceof MsgException) {
// Serializable obj = ((MsgException) e).getObj();
// if (obj instanceof RespEntity) {
// mcs.getExtra().putAll((JSONObject) JSON.toJSON(obj));
// }
// }
//
// if (mcs != null && mcs.getChannel().equals(channel)) {
// mcs.setStatus(MerchantChannelStatus.AUDIT_STATUS_EXAMINING);
// mcs.setThirdStatus(MerchantChannelStatus.AUDIT_THIRD_STATUS_WAITING);
// mcs.setRemark("银盛审核失败: " + e.getMessage());
// mcs.setUpdateTime(new Date());
// transactionTemplate.execute(new TransactionCallbackWithoutResult() {
// @Override
// protected void doInTransactionWithoutResult(TransactionStatus status) {
// mcsService.updateById(mcs);
// }
// });
// }
// }
// });
// } catch (Exception e) {
// e.printStackTrace();
//
// MerchantBaseInfo mbi = mbiService.getMerchantBaseInfoByUserId(userId);
// MerchantChannelStatus mcs = mcsService.getByMerchantCode(mbi.getMerchantCode(), channel);
//
// if (mcs != null && Objects.equals(mcs.getChannel(), channel)) {
// mcs.setStatus(MerchantChannelStatus.AUDIT_STATUS_EXAMINING);
// mcs.setThirdStatus(MerchantChannelStatus.AUDIT_THIRD_STATUS_WAITING);
// mcs.setRemark("银盛审核失败: " + e.getMessage());
// mcs.setUpdateTime(new Date());
//
// // 这里将驳回的信息放入新的事务中防止被回滚
// transactionTemplate.execute(new TransactionCallbackWithoutResult() {
// @Override
// protected void doInTransactionWithoutResult(TransactionStatus status) {
// mcsService.updateById(mcs);
// }
// });
// }
//
// throw e;
// }
// }
/**
* 组装进件基本信息
* @param userId
* @param channel
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public void step1(String userId, Integer channel) {
MercInfo mercInfo = new MercInfo();
CustInfo custInfo = new CustInfo();
mercInfo.setCustInfo(custInfo);
//查询商户详情
TbPlussMerchantBaseInfo merchantBaseInfo = merchantBaseInfoMapper.selectByUserId(userId);
//如果是小微则用商户简称
if ("1".equals(merchantBaseInfo.getMerchanttype())) {
custInfo.setMercName(merchantBaseInfo.getAlias());
}else {
custInfo.setMercName(merchantBaseInfo.getMerchantname());
}
custInfo.setMercShortName(merchantBaseInfo.getAlias());
//对应商户类型
switch (merchantBaseInfo.getMerchanttype()) {
case MERCH_TYPE_MICRO:
custInfo.setMercType("2");
break;
case TbPlussMerchantBaseInfo.MERCH_TYPE_INDIVIDUAL:
custInfo.setMercType("3");
break;
case TbPlussMerchantBaseInfo.MERCH_TYPE_COMPANY:
custInfo.setMercType("4");
break;
default:
throw new MsgException("暂未找到用户类型");
}
//mcc,邮箱联系人
custInfo.setMccCd(merchantBaseInfo.getMcc());
custInfo.setContactMail("chaozhanggui2022@163.com");
custInfo.setCusMgrNm("蔡祥");
//回调地址以及银盛配置机构(D0或者D1)
if (channel.equals(4)) {
custInfo.setNotifyUrl(AUDIT_NOTIFY_URL);
custInfo.setAgtMercId(ysConfigV3.getAgentNo());
}else {
custInfo.setNotifyUrl(AUDIT_NOTIFY_URL_D1);
custInfo.setAgtMercId(ysConfigV3.getAgentNoD1());
}
//根据商户信息组装身份证银行卡等(D0或者D1)
CombineMercInfo combineMercInfo;
CrpInfo crpInfo = new CrpInfo();
mercInfo.setCrpInfo(crpInfo);
if (channel.equals(4)){
combineMercInfo = getMercInfo(userId, TbPlussAccount.CHANNEL_TYPE_D0);
}else {
combineMercInfo = getMercInfo(userId, TbPlussAccount.CHANNEL_TYPE_D1);
}
//身份证
TbPlussIdCard legalIdCard = combineMercInfo.getLegalIdCard();
crpInfo.setCrpCertNo(legalIdCard.getCertno());
crpInfo.setCrpCertType("00");
crpInfo.setCertBgn(legalIdCard.getCertstarttime().replace("-", ""));
if (legalIdCard.getCertendtime().equals("长期")) {
crpInfo.setCertExpire("29991231");
} else {
crpInfo.setCertExpire(legalIdCard.getCertendtime().replace("-", ""));
}
crpInfo.setCrpNm(legalIdCard.getCertname());
//银行卡相关
TbPlussBankCard bankCard = combineMercInfo.getBankCard();
crpInfo.setCrpPhone(bankCard.getPhone());
StlAccInfo stlAccInfo = new StlAccInfo();
mercInfo.setStlAccInfo(stlAccInfo);
// 如果是非法人授权信息
if (!legalIdCard.getCertno().equals(combineMercInfo.getSettleIdCard().getCertno())) {
TbPlussIdCard idCard = combineMercInfo.getSettleIdCard();
PersonInfo authInfo = new PersonInfo();
authInfo.setName(idCard.getCertname());
authInfo.setCertType("00");
authInfo.setCertNo(idCard.getCertno());
authInfo.setCertBgn(idCard.getCertstarttime().replace("-", ""));
if (idCard.getCertendtime().equals("长期")) {
authInfo.setCertExpire("29991231");
} else {
authInfo.setCertExpire(idCard.getCertendtime().replace("-", ""));
}
crpInfo.setAuthInfo(authInfo);
stlAccInfo.setIsUncrpSett("Y");
stlAccInfo.setBankMobile(bankCard.getPhone());
stlAccInfo.setOpenCertNo(idCard.getCertno());
}
stlAccInfo.setStlAccNm(bankCard.getBankholder());
stlAccInfo.setStlAccNo(bankCard.getBankcardno());
stlAccInfo.setBankSubCode(bankCard.getContactline());
TbPlussRegionCodeYs ysRegionCode = regionReflectService.getYsRegionCode(bankCard.getBranchprovince(), bankCard.getBranchcity(), bankCard.getBrancharea());
// 由于联行号地址存在对应不上的问题所以这里还是将地区信息给带上
stlAccInfo.setBankProince(ysRegionCode.getProvincecode());
stlAccInfo.setBankCity(ysRegionCode.getCitycode());
if (bankCard.getAccounttype().equals(TbPlussBankCard.ACCOUNT_TYPE_PRIVATE)) {
stlAccInfo.setStlAccType("11");
} else {
stlAccInfo.setStlAccType("21");
}
//营业执照相关
BusInfo busInfo = new BusInfo();
mercInfo.setBusInfo(busInfo);
if (!merchantBaseInfo.getMerchanttype().equals(MERCH_TYPE_MICRO)) {
busInfo.setBusNm(merchantBaseInfo.getBussauthname());
busInfo.setBusNo(merchantBaseInfo.getBussauthnum());
if (merchantBaseInfo.getBussauthstarttime() == null || merchantBaseInfo.getBussauthendtime() == null){
throw new MsgException("营业执照日期有误");
}
busInfo.setBusCertBgn(merchantBaseInfo.getBussauthstarttime().replace("","")
.replace("", "").replace("", ""));
busInfo.setBusCertExpire(merchantBaseInfo.getBussauthendtime().replace("","")
.replace("", "").replace("", ""));
busInfo.setBusAddr(merchantBaseInfo.getBussauthaddress());
busInfo.setBusCertType("19");
} else {
busInfo.setBusAddr(merchantBaseInfo.getProvince() + merchantBaseInfo.getCity() + merchantBaseInfo.getDistrict() + merchantBaseInfo.getAddress());
}
TbPlussRegionCodeYs regionData = regionReflectService.getYsRegionCode(merchantBaseInfo.getProvince(), merchantBaseInfo.getCity(), merchantBaseInfo.getDistrict());
busInfo.setBusProviceCode(regionData.getProvincecode());
busInfo.setBusCityCode(regionData.getCitycode());
busInfo.setBusAreaCode(regionData.getAreacode());
//向银盛发起进件请求
RespEntity req = req(ReqMethod.addCustInfoApply, (JSONObject) JSONObject.toJSON(mercInfo), channel);
String subCode = req.getSubCode();
//校验进件信息
if (!Objects.equals(subCode, BIZ_SUCCESS)) {
throw new MsgException(req.getSubMsg());
}
//再次检测
preCheck(userId, channel);
TbPlussMerchantChannelStatus mcs = new TbPlussMerchantChannelStatus();
TbPlussMerchantBaseInfo mbi = merchantBaseInfoMapper.selectByUserId(userId);
mcs = merchantChannelStatusMapper.getByMerchantCode(mbi.getMerchantcode(), String.valueOf(channel));
if (mcs == null) {
mcs = new TbPlussMerchantChannelStatus();
mcs.setMerchantcode(mcs.getMerchantcode());
mcs.setChannel(channel);
}
}
/**
* 获取商户信息
* @param userId
* @param channelType
* @return
*/
public CombineMercInfo getMercInfo(String userId, String channelType) {
CombineMercInfo mercInfo = new CombineMercInfo();
TbPlussMerchantBaseInfo mbi = merchantBaseInfoMapper.selectByUserId(userId);
mercInfo.setMbi(mbi);
AccountDTO realAccount = sxfMerchantAuditService.getRealAccount(userId, channelType);
if (!mbi.getMerchanttype().equals(MERCH_TYPE_MICRO)) {
TbPlussIdCard legalIdCard = idCardMapper.getLegalIdCard(userId);
mercInfo.setLegalIdCard(legalIdCard);
} else {
mercInfo.setLegalIdCard(realAccount.getIdcard());
}
mercInfo.setSettleIdCard(realAccount.getIdcard());
mercInfo.setBankCard(realAccount.getBankCard());
return mercInfo;
}
/**
* 只用于银盛进件接口发送通用请求
*
* @param reqMethod 请求方法
* @param reqData 请求参数
* @return
*/
public RespEntity req(ReqMethod reqMethod, JSONObject reqData, Integer channel) {
Calendar calendar = Calendar.getInstance();
int i = calendar.get(Calendar.HOUR_OF_DAY);
if (i < 8 || i >= 21) {
throw new MsgException("当前时段暂不支持入网请于8:00-21:00提交");
}
String key = RandomUtil.randomString(RandomUtil.BASE_NUMBER + "ABCDEF",16);
try {
ReqEntity request = ReqEntity.get(reqMethod);
Sign sign = null;
if (channel.equals(4)) {
request.setCertId(ysConfig.getSrcMerchantNo());
RSA rsa = SecureUtil.rsa(ysConfig.getPriKey(), ysConfig.getOldPubKey());
request.setCheck(rsa.encryptBase64(key, KeyType.PublicKey));
sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA, ysConfig.getPriKey(), ysConfig.getOldPubKey());
}else {
request.setCertId(ysConfigV3.getSrcMerchantNoD1());
RSA rsa = SecureUtil.rsa(ysConfigV3.getPriKeyV2D1(), ysConfigV3.getPubKeyV2D1());
request.setCheck(rsa.encryptBase64(key, KeyType.PublicKey));
sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA, ysConfigV3.getPriKeyV2D1(), ysConfigV3.getPubKeyV2D1());
}
request.setBizContent(reqData.toJSONString());
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.add("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
log.info("业务参数==============>" + JSONObject.toJSONString(reqData));
log.info("key = " + key);
AES aes = new AES(key.getBytes(StandardCharsets.UTF_8));
String s = aes.encryptBase64(request.getBizContent());
request.setBizContent(s);
String encryptOriginData = SignUtils.getSignContent((JSONObject) JSON.toJSON(request));
log.info("加签源数据==============>" + encryptOriginData);
request.setSign(Base64.encode(sign.sign(encryptOriginData.getBytes())));
log.warn("请求报文==============>" + JSONObject.toJSONString(request));
log.info("请求地址:{}", reqMethod.getUrl());
HttpEntity<JSONObject> reqEntity = new HttpEntity<>((JSONObject) JSON.toJSON(request), headers);
String respStr = restTemplate.postForObject(reqMethod.getUrl(), reqEntity, String.class);
log.info("返回信息base64{}", respStr);
byte[] decode = Base64.decode(respStr);
respStr = new String(decode, StandardCharsets.UTF_8);
log.info("返回信息:{}", respStr);
JSONObject param = JSON.parseObject(respStr);
String signContent = SignUtils.getSignContent(param);
System.out.println("加签原参数:" + signContent);
boolean checkSign;
try {
checkSign = sign.verify(signContent.getBytes(StandardCharsets.UTF_8), Base64.decode(param.getString("sign")));
} catch (Exception e) {
log.error("银盛云商服3.0接口验签失败{}", e.getMessage());
e.printStackTrace();
checkSign = true;
}
if (!checkSign) {
throw new MsgException("银盛云商服3.0接口验签不通过");
}
RespEntity respEntity = JSON.parseObject(respStr, RespEntity.class);
// 检查网关code码
if (!Objects.equals(respEntity.getCode(), REQ_SUCCESS)) {
throw new MsgException(respEntity.getMsg());
}
// 业务响应码这里不做判断交给具体接口业务逻辑去判断
if (StringUtils.hasText(respEntity.getBusinessData())) {
byte[] bizBytes = Base64.decode(respEntity.getBusinessData());
String decryptBizData = aes.decryptStr(bizBytes);
respEntity.setBusinessData(decryptBizData);
log.info("业务参数: {}", respEntity.getBusinessData());
}
return respEntity;
} catch (Exception e) {
if (e instanceof MsgException) {
throw e;
}
return null;
}
}
/**
* 再次检测
* @param userId
* @param channel
*/
public void preCheck(String userId, Integer channel) {
TbPlussMerchantBaseInfo mbi = merchantBaseInfoMapper.selectByUserId(userId);
TbPlussMerchantChannelStatus existD1 = merchantChannelStatusMapper.getByCodeAndChannelFlag(mbi.getMerchantcode(), TbPlussAccount.CHANNEL_TYPE_D1);
//D1
if (existD1 != null && !TbPlussMerchantChannelStatus.AUDIT_STATUS_SUCCESS.equals(existD1.getStatus()) &&
!TbPlussMerchantChannelStatus.AUDIT_STATUS_SIGNED.equals(existD1.getStatus()) && !TbPlussMerchantChannelStatus.AUDIT_STATUS_WAITING_SIGN.equals(existD1.getStatus())) {
throw new MsgException("当前D1通道存在未进件完成的的进件数据不允许进件银盛");
}
//TODO 非营业执照商户同一结算人仅可申请两次实时到账
if (MERCH_TYPE_MICRO.equals(mbi.getMerchanttype())) {
int ysCount = accountMapper.selectYSAuditSmallCount(String.valueOf(mbi.getUserid()));
if (ysCount >= 2) {
MsgException.throwException("非营业执照商户同一结算人仅可申请两次实时到账");
}
}
//D0
TbPlussMerchantChannelStatus existD0 = merchantChannelStatusMapper.getByCodeAndChannelFlag(mbi.getMerchantcode(), TbPlussAccount.CHANNEL_TYPE_D0);
if (existD0 == null) {
existD0 = merchantChannelStatusMapper.getByCodeNullChannel(mbi.getMerchantcode());
}
if (existD0 != null) {
existD0 = merchantChannelStatusMapper.getByIdLock(existD0.getId());
if (existD0.getStatus().equals(TbPlussMerchantChannelStatus.AUDIT_STATUS_REJECT)) {
return;
}
if (existD0.getStatus().equals(TbPlussMerchantChannelStatus.AUDIT_STATUS_EXAMINING) && existD0.getThirdstatus().equals(TbPlussMerchantChannelStatus.AUDIT_THIRD_STATUS_AUDITING)) {
throw new MsgException("当前商户已经在后台审核中");
}
// 此处先将进件状态锁住
existD0.setChannel(channel);
merchantChannelStatusMapper.updateByPrimaryKeySelective(existD0);
}
}
}

View File

@ -0,0 +1,66 @@
ys:
## 进件URL前缀
auditDomain: https://mpfpmerchantapi.ysepay.com
## 支付URL网关
payDomain: https://qrcode.ysepay.com/gateway.do
## 支付订单查询网关
searchDomain: https://search.ysepay.com/gateway.do
## 公共网关接口
commonDomain: https://openapi.ysepay.com/gateway.do
## 其他网关接口
otherDomain: https://commonapi.ysepay.com/gateway.do
## 代理商编号
agentNo: 801521000002WJW
## 交易发起方编号
srcMerchantNo: 826521773920170
## 私钥用于签名,对应的公钥给到银盛
priKey: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDky8v1JlxCfZM0e0p7rkZq/hpa3yHjsF3aJaE5rBt0+x5G7MnHX1AIgi9jJzG3Z8QnEPUVutVClVbRZ3k9hZChlm6T9Miv4IhyvE4kPGJEXRi2q2r7nHyUeGve3TC4jXvELy0muS30BWRyczM/f2x13/uzjxeCM1eMnI5+jxfdg8aaYS2NpCydgObtEvKQRpx6YoF+F7eIF8DNvbYyoRNzM/+NsmquDmgK7Ad1qNK7gqYSmfXHUys7F97Sd/NxfegaiBMapepruUvQSlcQkYXJprM9cBGQuWx/iK8kQ+yYfmOI0OWX8pBwYWut7rR/ritujAdKtIpg14XVxRLnop6dAgMBAAECggEASjJA6TZQcwuQIlPdOrCwi1/uIgv8TH9UYDsVxsMmgFAzaGK/qNUi+i9luKzsNYMEHHsmT66wHBCb//qjWa0n0w8auwaF0mtpNHQWjy+52luqeQqr/f6oc+l9ad+nPiI7wcpexREGcv0QrwDm3K+w96T0Vi2QPRvzR1k56Jb08VN+kpAXb3g7X++il0Ql2lKFM8NySI0utnHAFMH7erJqNc4KeKmr2fJYw23ldBUOxmU6oWEIGwO+KiysfNlmzu3JspYE/eQfKX5aaEKaDbPVGF5Dje5e1SlJ1x9sTAfhOPeh83canoRN61aAI5mEKu04li5LLscBZfW6li2sVVJi7QKBgQD6qPgPc9NOusBvYP02NPdARBswCoafA86QHftPtWpyza67/M2c3X7dd+EnOU1Q+9p2Wj+L64M2KnC1JB+RUrVDBhs4e+yZ3Gly8rD+OUt1kWdJTaK3hJyKAnKtbL9yE90CEwMxLEH0XnYTmC8GhYYXGbOS2ZsqzQJaGUaYel3kTwKBgQDpq5Z00hb8EcPF6l34aL+FL9nAxlASXbYJql/UkD8PdhIkoxezkox/UI5jeF+RXbQ+VfuZQa6HfUrBQOcHTmp9o4cInDqoN/DSjvqV3v8Cnjs/PuF+kxFMDJdYPsjkps4IqR24l8nypPCdPHRjCaRnyfOyc1AteB1jYxDxkUmXUwKBgDOu7V76SeKc3RraC7vGlgiZQmXYdcOJ3GiY1f2scWN0h4fZa2fhv8vYcQNObGO7WmM23o1yJR7hB1ZCOYQUYq2ML8aovrNG4DNEWTxCAg4eygYyTM+8Ny65rH2Xw6247MQFuY3FC2BgrcYChge5NlnDAeTQm47qsIZ1WboM2Rk/AoGBAIuT1kSjtd0OE34mV8lpcHVzNsQi8XN3DKTLY4DKRRDMO1wtG5xFPq1SBiu+nH9tlJvjqm1KQaFnIv868IV5vrybsK5g+9y9xZlQlLhvQq5irAtEWVfNK3jc0I6CumdyiAG+WyWHbbcF9UBG+1KpUM46YNpIbS0r4Yobg+R4H5hHAoGBAOCZOg2VFPiluOPWzIcILb6nYvZyPhZP4pzz7WyzBht2SoHcD70cduCQpcuAXbj5JY59gUfNxURCDxQDNW2x8cQs6Hxme1kVg5kZNJAaclfb7Jx+ZqsYk4ua0NqxOtyfhRmYXVaTVKDFNt8CmwoiKYse4VDC/E3yKgha0UdcE+co
## 签名公钥,由银盛提供
pubKey:
## 付款验签公钥,由银盛提供
oldPubKey: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7SPkmIUf2auwkgbVchMyfeCDgICuA1GKrSwRbDI24UMVhzDgcIxCUmFG5/DfcPJz0d3oV9Ggkd4/7NmteRvmNnOOGNOnmR6AGEKafDpL1mAdpndmpkAZ0f6OVo3Py5JDg2wt8d+u3dF0AFWwd2rrrqscWvxJVB55DnuZfXl2CyQIDAQAB
## 进件URL前缀v2
auditDomainV2: https://ouser.ysepay.com:6443/
## 机构号ID
src: 3520000064
## 代理商编号
agentNoV2: 801521000002WJW
## 进件私钥v2
priKeyV2: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBK gwggSkAgEAAoIBAQDky8v1JlxCfZM0e0p7rkZq/hpa3yHjsF3aJaE5rBt0+x5G7MnHX1AIgi9jJzG3Z8QnEPUVutVClVbRZ3k9hZChlm6T9Miv4IhyvE4kPGJEXRi2q2r7nHyUeGve3TC4jXvELy0muS30BWRyczM/f2x13/uzjxeCM1eMnI5+jxfdg8aaYS2NpCydgObtEvKQRpx6YoF+F7eIF8DNvbYyoRNzM/+NsmquDmgK7Ad1qNK7gqYSmfXHUys7F97Sd/NxfegaiBMapepruUvQSlcQkYXJprM9cBGQuWx/iK8kQ+yYfmOI0OWX8pBwYWut7rR/ritujAdKtIpg14XVxRLnop6dAgMBAAECggEASjJA6TZQcwuQIlPdOrCwi1/uIgv8TH9UYDsVxsMmgFAzaGK/qNUi+i9luKzsNYMEHHsmT66wHBCb//qjWa0n0w8auwaF0mtpNHQWjy+52luqeQqr/f6oc+l9ad+nPiI7wcpexREGcv0QrwDm3K+w96T0Vi2QPRvzR1k56Jb08VN+kpAXb3g7X++il0Ql2lKFM8NySI0utnHAFMH7erJqNc4KeKmr2fJYw23ldBUOxmU6oWEIGwO+KiysfNlmzu3JspYE/eQfKX5aaEKaDbPVGF5Dje5e1SlJ1x9sTAfhOPeh83canoRN61aAI5mEKu04li5LLscBZfW6li2sVVJi7QKBgQD6qPgPc9NOusBvYP02NPdARBswCoafA86QHftPtWpyza67/M2c3X7dd+EnOU1Q+9p2Wj+L64M2KnC1JB+RUrVDBhs4e+yZ3Gly8rD+OUt1kWdJTaK3hJyKAnKtbL9yE90CEwMxLEH0XnYTmC8GhYYXGbOS2ZsqzQJaGUaYel3kTwKBgQDpq5Z00hb8EcPF6l34aL+FL9nAxlASXbYJql/UkD8PdhIkoxezkox/UI5jeF+RXbQ+VfuZQa6HfUrBQOcHTmp9o4cInDqoN/DSjvqV3v8Cnjs/PuF+kxFMDJdYPsjkps4IqR24l8nypPCdPHRjCaRnyfOyc1AteB1jYxDxkUmXUwKBgDOu7V76SeKc3RraC7vGlgiZQmXYdcOJ3GiY1f2scWN0h4fZa2fhv8vYcQNObGO7WmM23o1yJR7hB1ZCOYQUYq2ML8aovrNG4DNEWTxCAg4eygYyTM+8Ny65rH2Xw6247MQFuY3FC2BgrcYChge5NlnDAeTQm47qsIZ1WboM2Rk/AoGBAIuT1kSjtd0OE34mV8lpcHVzNsQi8XN3DKTLY4DKRRDMO1wtG5xFPq1SBiu+nH9tlJvjqm1KQaFnIv868IV5vrybsK5g+9y9xZlQlLhvQq5irAtEWVfNK3jc0I6CumdyiAG+WyWHbbcF9UBG+1KpUM46YNpIbS0r4Yobg+R4H5hHAoGBAOCZOg2VFPiluOPWzIcILb6nYvZyPhZP4pzz7WyzBht2SoHcD70cduCQpcuAXbj5JY59gUfNxURCDxQDNW2x8cQs6Hxme1kVg5kZNJAaclfb7Jx+ZqsYk4ua0NqxOtyfhRmYXVaTVKDFNt8CmwoiKYse4VDC/E3yKgha0UdcE+co
## 进件公钥v2
pubKeyV2: MIGfMA0GCSGqSIb3DQEBAQUAA4GNADCBiQKBgQC7SPkmIUf2auwkgbVchMyfeCDgICuA1GKrSwRbDI24UMVhzDgcIxCUmFG5/DfcPJz0d3oV9Ggkd4/7NmteRvmNnOOGNOnmR6AGEKafDpL1mAdpndmpkAZ0f6OVo3Py5JDg2wt8d+u3dF0AFWwd2rrrqscWvxJVB55DnuZfXl2CyQIDAQAB
## 加密密钥
encryptPwd: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD2J82Gg79Tk8HZ9Zl7EOeLwvUn41c4ktUg6jveIhYLhT
oldPayV2:
## 交易发起方编号 收银呗(武汉)科技有限公司
srcMerchantNo:
## 收银呗(武汉)科技有限公司 私钥
payPriKey:
## 收银呗公钥
sybPubKey:
# 银盛公钥
payPubKey:
#D1相关配置
agentNoD1: 801521000002UUS
srcMerchantNoD1: 826521673920090
## 进件私钥v2(D1)
priKeyV2D1: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD2J82Gg79Tk8HZ9Zl7EOeLwvUn41c4ktUg6jveIhYLhT/PW5hpPAtgKXd9BvhtpfXhzbK6U9UURKhBgFIkQ+oIJQNfbB/F2jdVK9ke3IYi0/TXHMnY63x43qxciLeAOt+LxdhHn6ZImV4MsRkPjF/zLsaJrPOPWbc2m4T1yvinfzkrxhZaWn1dj4+IdyO3tA/juXCjydQqKR2kSqJlo6gdT9N3RIJ+ETda2UUahZyYXBfjyxFQEaOXthm6krZH1zBHs510Og6bQJQHjMmTskkslWvj38qPDfsuC4tq0Hgbu3LcyiX9vGYzQoGOaGhDEiNPObdDlOuh5gn0slRmg+PxAgMBAAECggEAJRvrCBRki50C5HD6Kmtp/M/vVYwYYhcAum2ViO9qk2ILNJ+CYpsCvASEVvzuBtm2L8xq3Vw2C1AubXGC8KSsa33o/EG4qIM1REnP+a8VKbr6dlOIuoMFyNMI+QpDX7mAafnxmRqgXuGAJDmupYFsFaU/mRHRxhKoZDsd2FA5HEbuDI9SJp86keE72NHsxyqfDIZyIk3Z8k7HZY2wg3FW+YaOKQBHVA9JYvhfZMeaQ1ymrA0IAqWpUqjLkqAa2Qa6xUsbj+QhvrkBCE48i8duamXKDSOaLfkqTb8IyxOM9eTsFwLVGEuZQrkhrLxdrg5aBPvu81pIJME6SgrquJJ84QKBgQD/MAFLiWU0wDJ4Hqf2jKa5vgrBmCqOsANBc079s8gDXM4zbsG/TjMHPDmiOGZxtDG8937twjYzRv9XpnqyITMArlhWWMhTOJ3r3CTVr/OISgeZKPGjfp+MbeDsOK4OggTVKZmNLx3nKiuc94IlTDOcz5qArVBTxKadWg56f1UGswKBgQD28G+haXxneMhRZozoHPjcfdgtDoZJaVa8XTXw8nvQala5ioU9yesbIAdtD/VR/eWwuMtO4rK1IFxtNZQ/MtSXwqlnKLf1xDJQPuj3kY5mC7H7sn4HGeFDP50VFnPgIaUnB5VwgyYFm8l19AW06OBjlnoBv0dnl1s5u+DgpzQcywKBgQCfeWSVzBtPR/1CTAYzcdqPoVAfg/S0jxK5yFHJAp0wXMMQKVszLq99CgoKcqyyyiV7LkBIXWJ50RipsgRjZZP2DP5vl7Q5LdyjFUR/tiG/PmRZNtkrj2ot3Ez/0rwTnPVgMUsgjB1n5Va0FYljvadTi/nGCIl2kCJ/m1QJAaIlOQKBgGV8TwRxS9ViiEEb+lDyhzxm488wpvPIvQLQ8/hAT65J5bZ/PV81etA9C5BA/Ltjs2A7siKLfJJ/6DxhxrlqdICiWeixjVkN9vePw0LrqTA7IjylELJuamuu2yntflXgvfUaYspIu/mWGufFEAtXodCL6TyKlhf21mEV28e4L+ydAoGAItgCUGbot95QNT1z+9QFN+18AvMnWCNvqanrC4qsk0phjYX9FFwfSCqWVeVm0Q0+2tUrRNcUEcbmlbQToBZq/hSu0nPcZIPvnNxLfW/NY7eVCXIcI5eNPjUIgbRCVMc6w5ukYMxPidOBuRXIt1iq2+iV20/FMbA58sY7AgOiaMw=
## 进件公钥v2
pubKeyV2D1: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7SPkmIUf2auwkgbVchMyfeCDgICuA1GKrSwRbDI24UMVhzDgcIxCUmFG5/DfcPJz0d3oV9Ggkd4/7NmteRvmNnOOGNOnmR6AGEKafDpL1mAdpndmpkAZ0f6OVo3Py5JDg2wt8d+u3dF0AFWwd2rrrqscWvxJVB55DnuZfXl2CyQIDAQAB
ys-extension:
## 进件URL前缀v2
auditDomainV2: https://ouser.ysepay.com:6443/
## 机构号ID
src:
## 代理商编号
agentNoV2: 801521000002WJW
## 进件私钥v2
priKeyV2:
## 进件公钥v2
pubKeyV2:
## 加密密钥
encryptPwd: