From d17f28fb9a5894b08cd8754d763f0f06e93cb958 Mon Sep 17 00:00:00 2001
From: xiaogang <905166056@qq.com>
Date: 星期三, 10 二月 2021 15:11:34 +0800
Subject: [PATCH] 1、优化报修汇总报表增加汇总数据展示2、增加业主绑定后登录获取头像和昵称3、员工办结维修前图片和维修后图片上传4、业主手机端查询详情时刷入图片信息

---
 java110-core/src/main/java/com/java110/core/factory/WechatFactory.java |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/java110-core/src/main/java/com/java110/core/factory/WechatFactory.java b/java110-core/src/main/java/com/java110/core/factory/WechatFactory.java
index b5685c5..9f0f973 100644
--- a/java110-core/src/main/java/com/java110/core/factory/WechatFactory.java
+++ b/java110-core/src/main/java/com/java110/core/factory/WechatFactory.java
@@ -1,6 +1,7 @@
 package com.java110.core.factory;
 
 import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Synchronized;
 import com.java110.utils.cache.JWTCache;
 import com.java110.utils.constant.WechatConstant;
 import com.java110.utils.factory.ApplicationContextFactory;
@@ -8,7 +9,11 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.web.client.RestTemplate;
+import sun.misc.BASE64Decoder;
 
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
 import java.util.Date;
 
 /**
@@ -45,6 +50,7 @@
      * @param appSecure
      * @return
      */
+    @Java110Synchronized(value = "appId")
     public static String getAccessToken(String appId, String appSecure) {
         String accessToken = JWTCache.getValue(WECHAT + appId);
         if (StringUtil.isEmpty(accessToken)) {
@@ -96,7 +102,34 @@
      * @return
      */
     public static String getAppId(String wId) {
+        wId = wId.replace(" ", "+");
         return AuthenticationFactory.decrypt(password, wId);
     }
 
+
+    public static String getPhoneNumberBeanS5(String decryptData, String key, String iv) {
+        /*
+         *杩欓噷浣犳病蹇呰闈炴寜鐓ф垜鐨勬柟寮忓啓锛屼笅闈㈡墦浠g爜涓昏鏄湪涓�涓嚜宸辩殑绫讳腑 鏀句笂decrypts5杩欎釜瑙e瘑宸ュ叿锛屽伐鍏峰湪涓嬫柟鏈変唬鐮�
+         */
+        String resultMessage = decryptS5(decryptData, "UTF-8", key, iv);
+        return resultMessage;
+    }
+
+    public static String decryptS5(String sSrc, String encodingFormat, String sKey, String ivParameter) {
+        try {
+            BASE64Decoder decoder = new BASE64Decoder();
+            byte[] raw = decoder.decodeBuffer(sKey);
+            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+            IvParameterSpec iv = new IvParameterSpec(decoder.decodeBuffer(ivParameter));
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+            byte[] myendicod = decoder.decodeBuffer(sSrc);
+            byte[] original = cipher.doFinal(myendicod);
+            String originalString = new String(original, encodingFormat);
+            return originalString;
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+
 }

--
Gitblit v1.8.0