Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

FengChaoYu 6 dní pred
rodič
commit
ed34f617fe

+ 7 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/policy/WorkerLogic.java

@@ -456,7 +456,13 @@ public class WorkerLogic {
         int month = DateUtil.month(startTime);
 
         Mailbox mailbox = mailboxService.getById("1");
-        Date endTime = DateUtil.parseDateTime(DateUtils.formatDate(new Date(),"yyyy-MM-dd") +" "+ mailbox.getSendTime()+":00");
+
+        // 1. 获取当前月份的最后一天
+        Date lastDayOfMonth = DateUtil.endOfMonth(new Date());
+        // 2. 将最后一天减1天,得到倒数第二天
+        Date secondLastDay = DateUtil.offsetDay(lastDayOfMonth, -1);
+
+        Date endTime = DateUtil.parseDateTime(DateUtils.formatDate(secondLastDay,"yyyy-MM-dd") +" "+ mailbox.getSendTime()+":00");
 
         if (new Date().after(endTime) && DateUtil.offsetDay(startTime,2).month() != DateUtil.month(startTime)){
             month = month+1;

+ 4 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/user/UserLogic.java

@@ -1363,11 +1363,13 @@ public class UserLogic {
                 throw new RemoteServiceException("您已入驻当前网点");
             }
 
-            websitUserService.lambdaUpdate().eq(WebsitUser::getUserId, user.getUserId()).eq(WebsitUser::getWebsitId, websitId).remove();
+            WebsitUser websitUser1 = websitUserService.lambdaQuery().eq(WebsitUser::getUserId, user.getUserId()).eq(WebsitUser::getWebsitId, websitId).one();
 
             AdminWebsit adminWebsit = adminWebsitService.getById(websitId);
 
             WebsitUser websitUser = new WebsitUser();
+            if (websitUser1 != null)
+                websitUser.setId(websitUser1.getId());
             websitUser.setWebsitId(websitId);
             websitUser.setWebsitName(adminWebsit.getName());
             if (!StringUtil.isEmpty(currentCompanyWechat.getUser().getWorkerNumber()) &&
@@ -1391,7 +1393,7 @@ public class UserLogic {
             websitUser.setCreateTime(new Date());
             websitUser.setExamineStatus(OrderExamineEnum.WAIT.toString());
             websitUser.setBankAccount(bankAccount);
-            websitUser.insert();
+            websitUser.insertOrUpdate();
 
             if (userApplyBean.getWorkerPolicy()!= null) {
 

+ 0 - 1
mall-miniapp-service/src/main/resources/logback.xml

@@ -1,6 +1,5 @@
 <!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
 <configuration scan="true" scanPeriod="2 seconds">
-<!--    <include resource="org/springframework/boot/logging/logback/base.xml" />-->
     <property name="LOG_PATH" value="../logs" />
 
     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">

+ 5 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/user/UserLogic.java

@@ -299,6 +299,10 @@ public class UserLogic {
 
             List<User> userList = userService.lambdaQuery().eq(User::getIdCard, idcard).list();
 
+            List<User> list1 = userService.lambdaQuery().eq(User::getMobile, mobile).list();
+
+            userList.addAll(list1);
+
             if (!CollectionUtils.isEmpty(userList)) {
 
                 User user = userList.get(0);
@@ -436,7 +440,7 @@ public class UserLogic {
                     userWait.setWebsitName(adminWebsit.getName());
                     //入驻已存在的师傅到网点
                     User worker = userService.lambdaQuery()
-                            .eq(User::getMobile, mobile)
+                            .eq(User::getIdCard, idcard)
                             .eq(User::getType, UserTypeEnum.WORKER.getKey())
                             .last("limit 1")
                             .one();

+ 115 - 0
mall-server-sync-api/src/main/java/com/gree/mall/manager/utils/CryptTool.java

@@ -0,0 +1,115 @@
+package com.gree.mall.manager.utils;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+import javax.crypto.*;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
+import java.security.*;
+
+public class CryptTool {
+    public CryptTool() {
+    }
+
+    public static String byte2hex(byte[] b) {
+        StringBuffer stringBuffer = new StringBuffer();
+        String temp = null;
+
+        for(int i = 0; i < b.length; ++i) {
+            temp = Integer.toHexString(b[i] & 255);
+            if (temp.length() == 1) {
+                stringBuffer.append("0").append(temp);
+            } else {
+                stringBuffer.append(temp);
+            }
+        }
+
+        return stringBuffer.toString();
+    }
+
+    public static byte[] decodeBase64(String key) {
+        return Base64.decodeBase64(key);
+    }
+
+    public static SecretKeySpec initAESSecretKey(String secretKeySource) throws NoSuchAlgorithmException, DecoderException, UnsupportedEncodingException {
+        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
+        SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
+        byte[] decodeHex = Hex.decodeHex(sha256(secretKeySource).toCharArray());
+        secureRandom.setSeed(decodeHex);
+        keyGen.init(128, secureRandom);
+        SecretKey secretKey = keyGen.generateKey();
+        byte[] secretKeyEncoded = secretKey.getEncoded();
+        SecretKeySpec key = new SecretKeySpec(secretKeyEncoded, "AES");
+        Security.addProvider(new BouncyCastleProvider());
+        return key;
+    }
+
+    public static String decryptAES(String source, String secretKey) {
+        try {
+            byte[] sourceBytes = decodeBase64(source);
+            SecretKeySpec secretKeySpec = initAESSecretKey(secretKey);
+            byte[] decryptBytes = decrypt(source.getBytes(), secretKeySpec);
+            return new String(decryptBytes, "utf8");
+        } catch (Exception var5) {
+            throw new RuntimeException("AES算法解密失败", var5);
+        }
+    }
+
+    private static byte[] decrypt(byte[] source, SecretKeySpec secretKeySpec) throws NoSuchPaddingException, NoSuchAlgorithmException, BadPaddingException, IllegalBlockSizeException, InvalidKeyException {
+        Cipher cipher = Cipher.getInstance(secretKeySpec.getAlgorithm());
+        cipher.init(2, secretKeySpec);
+        return cipher.doFinal(source);
+    }
+
+    public static String digest(byte[] inputBytes, String algorithm) throws NoSuchAlgorithmException {
+        String outputStr = null;
+        MessageDigest alg = MessageDigest.getInstance(algorithm);
+        alg.update(inputBytes);
+        byte[] digest = alg.digest();
+        outputStr = byte2hex(digest);
+        return outputStr.toUpperCase();
+    }
+
+    public static String sha1(String inStr) throws UnsupportedEncodingException, NoSuchAlgorithmException {
+        String outStr = digest(inStr.getBytes("UTF-8"), "SHA-1");
+        return outStr;
+    }
+
+    public static String sha256(String inStr) throws UnsupportedEncodingException, NoSuchAlgorithmException {
+        String outStr = digest(inStr.getBytes("UTF-8"), "SHA-256");
+        return outStr;
+    }
+
+    public static String md5(String inStr) throws UnsupportedEncodingException, NoSuchAlgorithmException {
+        String outStr = digest(inStr.getBytes("UTF-8"), "MD5");
+        return outStr;
+    }
+
+    public static String encryptBASE64(byte[] key) throws Exception {
+        return Base64.encodeBase64String(key);
+    }
+
+    public static String encryptAES(String source, String secretKey) {
+        try {
+            byte[] sourceBytes = source.getBytes("utf8");
+            SecretKeySpec secretKeySpec = initAESSecretKey(secretKey);
+            byte[] encryptBytes = encrypt(sourceBytes, secretKeySpec);
+            return Base64.encodeBase64URLSafeString(encryptBytes);
+        } catch (Exception var5) {
+            throw new RuntimeException("AES算法加密失败", var5);
+        }
+    }
+
+    private static byte[] encrypt(byte[] source, SecretKeySpec secretKeySpec) throws BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException {
+        Cipher cipher = Cipher.getInstance(secretKeySpec.getAlgorithm());
+        cipher.init(1, secretKeySpec);
+        return cipher.doFinal(source);
+    }
+
+    public static String encodeBase64String(byte[] source) {
+        return Base64.encodeBase64String(source);
+    }
+}

+ 0 - 2
mall-server-sync-api/src/main/java/com/gree/mall/manager/utils/SignUtil.java

@@ -1,8 +1,6 @@
 package com.gree.mall.manager.utils;
 
 import com.gree.mall.manager.bean.OutAppDefaultReq;
-import com.gree.mall.manager.controller.common.CryptTool;
-import org.apache.commons.codec.binary.Base64;
 
 import java.net.URLEncoder;
 import java.security.MessageDigest;