Просмотр исходного кода

Merge remote-tracking branch 'origin/dev' into dev

2 месяцев назад
Родитель
Сommit
3391e432a8

+ 1 - 1
08.src/Xingxi/xingxi-admin/src/main/resources/templates/business/prodInventory/mercProdInventory.html

@@ -157,7 +157,7 @@
                         });
                         layer.closeAll();
                     } else {
-                        $.modal.alertWarning("需要添加的库存数量不正确,请重新输入!");
+                        $.modal.alertWarning("需要添加的库存数量未输入,请输入库存后重试!");
                     }
                 }
             });

+ 1 - 0
08.src/Xingxi/xingxi-common/src/main/java/com/xingxi/common/constant/ShiroConstants.java

@@ -71,6 +71,7 @@ public class ShiroConstants
      * 登录记录缓存
      */
     public static final String LOGIN_RECORD_CACHE = "loginRecordCache";
+    public static final String LOGINTIME_RECORD_CACHE = "loginTimeRecordCache";
 
     /**
      * 系统活跃用户缓存

+ 30 - 6
08.src/Xingxi/xingxi-framework/src/main/java/com/xingxi/framework/shiro/service/SysPasswordService.java

@@ -1,10 +1,18 @@
 package com.xingxi.framework.shiro.service;
 
+import java.util.Date;
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.annotation.PostConstruct;
+
+import com.xingxi.common.core.redis.RedisCache;
+import com.xingxi.common.utils.CacheUtils;
+import com.xingxi.common.utils.DateUtils;
 import org.apache.shiro.cache.Cache;
 import org.apache.shiro.cache.CacheManager;
 import org.apache.shiro.crypto.hash.Md5Hash;
+import org.crazycake.shiro.RedisCacheManager;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
@@ -25,41 +33,56 @@ import com.xingxi.framework.manager.factory.AsyncFactory;
 @Component
 public class SysPasswordService
 {
+//    @Autowired
+//    private CacheManager cacheManager;
     @Autowired
-    private CacheManager cacheManager;
+    private RedisCache redisCache;
+
+    private HashMap<String, AtomicInteger> loginRecordCache;
+    private HashMap<String, Date> loginTimeRecordCache;
 
-    private Cache<String, AtomicInteger> loginRecordCache;
+//    private Cache<String, AtomicInteger> loginRecordCache;
 
     @Value(value = "${user.password.maxRetryCount}")
     private String maxRetryCount;
+    @Autowired
+    private RedisCacheManager cacheManager;
 
     @PostConstruct
     public void init()
     {
-        loginRecordCache = cacheManager.getCache(ShiroConstants.LOGIN_RECORD_CACHE);
+
+        redisCache.setCacheObject(ShiroConstants.LOGIN_RECORD_CACHE, new HashMap<String, AtomicInteger>());
+        redisCache.setCacheObject(ShiroConstants.LOGINTIME_RECORD_CACHE, new HashMap<String, AtomicInteger>());
+        loginRecordCache = redisCache.getCacheObject(ShiroConstants.LOGIN_RECORD_CACHE);
+        loginTimeRecordCache = redisCache.getCacheObject(ShiroConstants.LOGIN_RECORD_CACHE);
     }
 
     public void validate(SysUser user, String password)
     {
         String loginName = user.getLoginName();
 
-        AtomicInteger retryCount = loginRecordCache.get(loginName);
+        AtomicInteger retryCount = (AtomicInteger)loginRecordCache.get(loginName);
 
         if (retryCount == null)
         {
             retryCount = new AtomicInteger(0);
             loginRecordCache.put(loginName, retryCount);
+            loginTimeRecordCache.put(loginName, new Date());
         }
         if (retryCount.incrementAndGet() > Integer.valueOf(maxRetryCount).intValue())
         {
-            AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount)));
-            throw new UserPasswordRetryLimitExceedException(Integer.valueOf(maxRetryCount).intValue());
+            if (DateUtils.getNowDate().getTime() - loginTimeRecordCache.get(loginName).getTime() < 1000 * 60 * 10) {
+                AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount)));
+                throw new UserPasswordRetryLimitExceedException(Integer.valueOf(maxRetryCount).intValue());
+            }
         }
 
         if (!matches(user, password))
         {
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.count", retryCount)));
             loginRecordCache.put(loginName, retryCount);
+            loginTimeRecordCache.put(loginName, new Date());
             throw new UserPasswordNotMatchException();
         }
         else
@@ -76,6 +99,7 @@ public class SysPasswordService
     public void clearLoginRecordCache(String loginName)
     {
         loginRecordCache.remove(loginName);
+        loginTimeRecordCache.remove(loginName);
     }
 
     public String encryptPassword(String loginName, String password, String salt)

+ 1 - 1
08.src/Xingxi/xingxi-miniprogram-api/src/main/java/com/xingxi/api/model/OrderItemDTO.java

@@ -10,7 +10,7 @@ public class OrderItemDTO {
     private Long cartsId;
 
     private Long mercId;
-    private Long prodId;
+    private Long mercProdId;
     private Long prodAttrId;
 
     private Integer count;

+ 1 - 7
08.src/Xingxi/xingxi-miniprogram-api/src/main/java/com/xingxi/api/service/impl/OrderApiServiceImpl.java

@@ -211,13 +211,8 @@ class OrderApiServiceImpl implements OrderServiceI {
         List<OrderDetail> orderDetailItems = new ArrayList<>();
 
         for (OrderItemDTO orderItemDTO : orderItemDTOS) {
-//            MerchantProd merchantProd = merchantProdMapper.selectMerchantProdByMercProdId(orderItemDTO.getMercProdId());
-            MerchantProd condMerchant = new MerchantProd();
-            condMerchant.setMercId(orderItemDTO.getMercId());
-            condMerchant.setProdId(orderItemDTO.getProdId());
-            condMerchant.setProdAttrId(orderItemDTO.getProdAttrId());
 
-            MerchantProd merchantProd = wxApiProductMapper.selectFirstMerchantProdByCondition(condMerchant);
+            MerchantProd merchantProd = wxApiProductMapper.selectMerchantProdByMercProdId(orderItemDTO.getMercProdId());
 
             Prod prod = prodMapper.selectProdById(merchantProd.getProdId());
             order.setSellerId(merchantProd.getMercId());
@@ -225,7 +220,6 @@ class OrderApiServiceImpl implements OrderServiceI {
             ProdVendor condPv = new ProdVendor();
             condPv.setDelFlag(EDelFlag.NO.getVal());
             condPv.setProdId(merchantProd.getProdId());
-//            condPv.setProdAttrId(merchantProd.getProdAttrId());
 
             List<ProdVendor> prodVendorList = prodVendorMapper.selectProdVendorList(condPv);
             if (prodVendorList.isEmpty()) {