Browse Source

修改登录权限,修改吊牌翻倍价格

zhuyiyi 5 months ago
parent
commit
e178b27aa2

+ 6 - 4
src/main/java/lingtao/net/realm/ShiroRealm.java

@@ -64,7 +64,7 @@ public class ShiroRealm extends AuthorizingRealm {
     private boolean isPassIp(String loginIp) {
         // 获取所有的授权IP
         List<String> ipList = loginIpMapper.getAllIp();
-        if(loginIp == "127.0.0.1"){
+        if (loginIp == "127.0.0.1") {
             return true;
         }
         for (String agreeIp : ipList) {
@@ -112,7 +112,9 @@ public class ShiroRealm extends AuthorizingRealm {
                 loginLog.setStatus("异常");
                 agreeLogin = false;
             }
-
+            if ("2".equals(user.getNeedIp())) {
+                agreeLogin = true;
+            }
             loginLog.setLoginTime(new Date());
             loginLog.setRemark(loginRemark);
             loginLogMapper.addLog(loginLog);
@@ -122,7 +124,7 @@ public class ShiroRealm extends AuthorizingRealm {
             }
 
             /** 处理生日 */
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
             Date birthDate = null;
             String birthDay = "";
             // 生日日期/类型不为空
@@ -151,7 +153,7 @@ public class ShiroRealm extends AuthorizingRealm {
                 } catch (ParseException e) {
                     // e.printStackTrace();
                 }
-            }
+            }*/
 
             /** 处理session(将用户信息存入session) */
             // 将用户信息存入session

+ 4 - 2
src/main/java/lingtao/net/service/ProductService.java

@@ -1090,8 +1090,10 @@ public class ProductService {
 
                         for (Product product : priceList) {
                             // 服装吊牌里面的600克吊牌把价格*1.3倍
-                            if (!("6".equals(kind) && "无".equals(kind2) && area <= 0.00486)) {
-                                product.setPrice(Math.floor(product.getPrice() * 1.3));
+                            if (!("6".equals(kind) && "无".equals(kind2))) {
+                                if (area <= 0.00486) {
+                                    product.setPrice(Math.floor(product.getPrice() * 1.3));
+                                }
                             }
                             if ("4".equals(kind)) {
                                 // 服装吊牌里面的900克吊牌把价格

+ 4 - 2
src/main/java/lingtao/net/util/PriceUtils.java

@@ -416,7 +416,7 @@ public class PriceUtils {
             }
             Product product = new Product();
             product.setCount(count_item);
-            product.setPrice(Math.ceil(price * number));
+            product.setPrice(Math.ceil(price));
             priceList.add(product);
         }
         return priceList;
@@ -3428,8 +3428,10 @@ public class PriceUtils {
                 endIndex = Math.min(i + 1, areas.length - 1);
             }
         }
-        if (startIndex == endIndex) {
+        if (startIndex == 0) {
             price = price_list[endIndex];
+        } else if (startIndex == endIndex) {
+            price = (price_list[endIndex] / areas[endIndex]) * area;
         } else {
             price = ((areas[endIndex] - area) / (areas[endIndex] - areas[startIndex])) * price_list[startIndex] + ((area - areas[startIndex]) / (areas[endIndex] - areas[startIndex])) * price_list[endIndex];
         }