ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -155,6 +155,15 @@ String[] relUserIdArray = relUserIds.split(","); ShopRelUser shopRelUser; Long userId; if(mgtEditShopDto.getShopId()!=null){ for (String str : relUserIdArray) { userId = Long.valueOf(str); shopRelUser = shopRelUserService.getByUserId(userId); if(shopRelUser!=null&&!shopRelUser.getShopId().equals(mgtEditShopDto.getShopId())){ throw new ServiceException(AppErrorConstant.SHOP_USER_DOUBLE); } } }else { for (String str : relUserIdArray) { userId = Long.valueOf(str); shopRelUser = shopRelUserService.getByUserId(userId); @@ -163,6 +172,8 @@ } } } } //验证商户名唯一 Shop shopSame = this.getOne(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag,0).eq(Shop::getShopName,mgtEditShopDto.getShopName())); if(mgtEditShopDto.getShopId()!=null){ ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/Certificate.java
@@ -1,25 +1,8 @@ package com.ruoyi.shop.util; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.ruoyi.shop.util.dto.CertificateItem; import com.ruoyi.shop.util.dto.EncryptedCertificateItem; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; /** * @date 2020-03-18 15:06 @@ -41,7 +24,7 @@ * @param savePath * @return */ public static List<X509Certificate> getCertByAPI(String merchantId, int timeout, String serialNo, String mchPrivateKeyPath, String wechatPubKeyPath, String APIv3Key, String savePath) { /*public static List<X509Certificate> getCertByAPI(String merchantId, int timeout, String serialNo, String mchPrivateKeyPath, String wechatPubKeyPath, String APIv3Key, String savePath) { String result = ""; //创建http请求 HttpGet httpGet = new HttpGet("https://api.mch.weixin.qq.com/v3/certificates"); @@ -105,11 +88,11 @@ } logger.info("证书List:" + certList); /*List<PlainCertificateItem> plainList = decrypt(certList, APIv3Key); *//*List<PlainCertificateItem> plainList = decrypt(certList, APIv3Key); if (CollectionUtils.isNotEmpty(plainList)) { logger.info("平台证书开始保存"); x509Certs = saveCertificate(plainList, savePath); }*/ }*//* } } } @@ -121,7 +104,7 @@ logger.error("下载平台证书返回结果:" + e); } return x509Certs; } }*/ /*private static List<PlainCertificateItem> decrypt(List<CertificateItem> certList,CloseableHttpResponse response) throws GeneralSecurityException, IOException { ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/CertificateUtils.java
@@ -1,19 +1,5 @@ package com.ruoyi.shop.util; import cn.hutool.core.codec.Base64; import cn.hutool.core.io.FileUtil; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.cert.*; import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; /** * @date 2020-03-18 11:25 * @description 证书相关 @@ -26,7 +12,7 @@ * @param priKeyPath 商户私钥证书路径 * @return */ public static String getPrivateKey(String priKeyPath) throws Exception { /*public static String getPrivateKey(String priKeyPath) throws Exception { String originalKey = FileUtil.readUtf8String(priKeyPath); String privateKey = originalKey .replace("-----BEGIN PRIVATE KEY-----", "") @@ -41,11 +27,11 @@ } /** *//** * 从字符串中加载私钥 * @param privateKeyStr 私钥 * @return */ *//* public static PrivateKey loadPrivateKey(String privateKeyStr) throws Exception { try { byte[] buffer = Base64.decode(privateKeyStr); @@ -62,11 +48,11 @@ } /** *//** * 获取证书 * @param fileName 证书文件路径 (required) * @return */ *//* public static X509Certificate getCertificate(String fileName) throws IOException { InputStream fis = new FileInputStream(fileName); try (BufferedInputStream bis = new BufferedInputStream(fis)) { @@ -84,11 +70,11 @@ } /** *//** * 获取证书 * @param inputStream 证书文件 * @return */ *//* public static X509Certificate getCertificate(InputStream inputStream) { try { CertificateFactory cf = CertificateFactory.getInstance("X509"); @@ -102,5 +88,5 @@ } catch (CertificateException e) { throw new RuntimeException("无效的证书", e); } } }*/ } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/SignUtils.java
@@ -1,24 +1,7 @@ package com.ruoyi.shop.util; import cn.hutool.http.HttpResponse; import com.ruoyi.common.core.utils.uuid.IdUtils; import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.FileInputStream; import java.nio.charset.StandardCharsets; import java.security.KeyFactory; import java.security.PrivateKey; import java.security.PublicKey; import java.security.Signature; import java.security.cert.Certificate; import java.security.cert.CertificateFactory; import java.security.spec.PKCS8EncodedKeySpec; import java.util.List; import java.util.Map; /** * @date 2020-03-18 11:02 @@ -37,7 +20,7 @@ * @param mchPrivateKeyPath 电商平台商户API私钥 * @return */ public static String authorization(String method,String urlSuffix,String mchId,String serialNo,String body,String mchPrivateKeyPath) { /*public static String authorization(String method,String urlSuffix,String mchId,String serialNo,String body,String mchPrivateKeyPath) { try { String mchPrivateKey = CertificateUtils.getPrivateKey(mchPrivateKeyPath); //时间戳 @@ -69,7 +52,7 @@ } } /** *//** * Authorization 签名串 * @param method * @param urlSuffix @@ -77,7 +60,7 @@ * @param nonceStr * @param body * @return */ *//* private static StringBuilder signMessage(String method,String urlSuffix,String timestamp,String nonceStr,String body) { return new StringBuilder() .append(method) @@ -92,13 +75,13 @@ .append("\n"); } /** *//** * 私钥签名 * @param data 需要加密的数据 * @param mchPriKey * @return * @throws Exception */ *//* public static byte[] v3signRSA(String data, String mchPriKey) throws Exception { //签名的类型 Signature sign = Signature.getInstance("SHA256withRSA"); @@ -156,5 +139,5 @@ logger.info("v3VerifyRSA result:{}","签名验证失败"); } return result; } }*/ } ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopRelUserMapper.xml
@@ -72,6 +72,6 @@ </delete> <update id="deleteByShopId"> UPDATE shop_rel_user SET del_flag = 1 WHERE shop_id = #{shopId} UPDATE t_shop_rel_user SET del_flag = 1 WHERE shop_id = #{shopId} </update> </mapper> ruoyi-modules/ruoyi-shop/src/main/resources/mapper/task/ShopFileMapper.xml
@@ -67,7 +67,7 @@ </delete> <update id="deleteByShopId"> UPDATE shop_file SET del_flag = 1 WHERE shop_id = #{shopId} UPDATE t_shop_file SET del_flag = 1 WHERE shop_id = #{shopId} </update> </mapper>