Forráskód Böngészése

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

yangc 8 éve
szülő
commit
0801d9e092

+ 29 - 27
src/main/java/com/uas/platform/b2c/common/account/controller/UserController.java

@@ -116,26 +116,27 @@ public class UserController {
 
 	/**
 	 * 修改用户密码
-	 *
-	 * @param password	用户输入密码
+	 * @param session 获取session
+	 * @param password 旧密码
+	 * @param newPassword 新密码
+	 * @param secLevel 密码强度
+	 * @return
 	 */
 	@RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
-	public ResponseEntity<String> updatePassword(final HttpSession session, final String password, final String newPassword,final Short secLevel) {
+	public ResponseEntity<String> updatePassword(final HttpSession session, final String password, final String newPassword, final Short secLevel) {
 		if (password.equals(newPassword)) {
 			throw new IllegalOperatorException("新密码与旧密码相同");
 		}
-		if(newPassword.length()<8 || newPassword.matches("^[0-9]*$") || newPassword.matches("^[A-Za-z]*$")){
-			throw new IllegalOperatorException("密码强度不够,请重新输入");
-		}
-		if(newPassword.length()>20){
-			throw new IllegalOperatorException("密码超过20位,请重新输入");
+		String middlLevelReg = "^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$";
+		if (!newPassword.matches(middlLevelReg)) {
+			throw new IllegalOperatorException("密码格式有误,请重新输入");
 		}
 		User sysUser = SystemSession.getUser();
 		User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
 		if (!StringUtils.isEmpty(newPassword)) {
 			user.setPwdSecLevel(secLevel);
 			user = userService.updatePassword(user, password, newPassword);
-			if(sysUser.getEnterprise()!=null){
+			if (sysUser.getEnterprise() != null) {
 				user.setCurrentEnterprise(sysUser.getEnterprise().getUu());
 			}
 			session.setAttribute("user", user);
@@ -176,7 +177,7 @@ public class UserController {
 		User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
 		Long checkTime = (Long)session.getAttribute("checkTime");
 		if (!StringUtils.isEmpty(checkTime)){
-			Long nowTime = new Date().getTime();
+			Long nowTime = System.currentTimeMillis();
 			if((nowTime-checkTime)<60 * 1000){
 				throw new IllegalOperatorException("验证码发送频繁...");
 			}
@@ -186,14 +187,14 @@ public class UserController {
 			if (pageToken == null || pageToken.equals("")) {
 				throw new IllegalOperatorException("页面信息获取失败!");
 			}
-			//发送邮件
+			// 发送邮件
 			ModelMap data = new ModelMap();
 			String checkCode = String.valueOf((int) ((Math.random() * 9 + 1) * 100000));
 			data.put("checkcode", checkCode);
 			try {
 				mailService.send("a4c45a22-436a-430c-9667-4edfd7d04a27", newUserEmail, data);
 				session.setAttribute("checkCode", checkCode);
-				session.setAttribute("checkTime", new Date().getTime());
+				session.setAttribute("checkTime", System.currentTimeMillis());
 				session.setAttribute("newUserEmail",newUserEmail);
 				assert logger != null;
 				logger.log("用户信息", "发送用户邮箱地址,UU:" + user.getUserUU());
@@ -217,22 +218,22 @@ public class UserController {
 		Map<String,Object> result = new HashMap<String,Object>();
 		if (!StringUtils.isEmpty(checkCode) && !StringUtils.isEmpty(newUserEmail)) {
 			Long checkTime = (Long) session.getAttribute("checkTime");
-			Long nowTime = new Date().getTime();
+			Long nowTime = System.currentTimeMillis();
 			String _checkCode = (String) session.getAttribute("checkCode");
 			String _newUserEmail = (String) session.getAttribute("newUserEmail");
-			//验证码失效
+			// 验证码失效
 			if((nowTime-checkTime)>10 * 60 * 1000 || _checkCode == null) {
 				result.put("status", 2);
 				result.put("message", "验证码失效");
 				return result;
 			}
-			//验证码错误
+			// 验证码错误
 			if (!_checkCode.equals(checkCode) || !_newUserEmail.equals(newUserEmail)) {
 				result.put("status", 0);
 				result.put("message", "验证码错误");
 				return result;
 			}
-			//验证码正确
+			// 验证码正确
 			if (_checkCode.equals(checkCode)) {
 				result.put("status", 1);
 				result.put("message", "验证码正确");
@@ -256,7 +257,7 @@ public class UserController {
 		if (userEmail!=null && userEmail.equals(newUserEmail)) {
 			throw new IllegalOperatorException("新邮箱地址与旧邮箱地址相同");
 		}
-		//正则校验邮箱地址
+		// 正则校验邮箱地址
 		if(!newUserEmail.matches("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+")){
 			throw new IllegalOperatorException("新邮箱地址格式不正确");
 		}
@@ -322,13 +323,13 @@ public class UserController {
 		User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
 		Long checkTime = (Long)session.getAttribute("telCheckTime");
 		if (!StringUtils.isEmpty(checkTime)){
-			Long nowTime = new Date().getTime();
+			Long nowTime = System.currentTimeMillis();
 			if((nowTime-checkTime)<60 * 1000){
 				throw new IllegalOperatorException("验证码发送频繁...");
 			}
 		}
 		if (!StringUtils.isEmpty(newUserTel)) {
-			//页面Token校验
+			// 页面Token校验
 			String pageToken = (String) session.getAttribute("pageToken");
 			if (pageToken == null || pageToken.equals("")) {
 				throw new IllegalOperatorException("页面信息获取失败!");
@@ -337,7 +338,7 @@ public class UserController {
 			try {
 				smsService.send("1eba04ae-f3d9-4105-ad32-0196309fabb3", newUserTel, new Object[] {checkCode});
 				session.setAttribute("telCheckCode", checkCode);
-				session.setAttribute("telCheckTime", new Date().getTime());
+				session.setAttribute("telCheckTime", System.currentTimeMillis());
 				session.setAttribute("newUserTel", newUserTel);
 				assert logger != null;
 				logger.log("用户信息", "发送手机验证码,UU:" + user.getUserUU());
@@ -360,22 +361,22 @@ public class UserController {
 		Map<String, Object> result = new HashMap<String, Object>();
 		if (!StringUtils.isEmpty(telCheckCode) && !StringUtils.isEmpty(newUserTel)) {
 			Long checkTime = (Long) session.getAttribute("telCheckTime");
-			Long nowTime = new Date().getTime();
+			Long nowTime = System.currentTimeMillis();
 			String _checkCode = (String) session.getAttribute("telCheckCode");
 			String _newUserTel = (String) session.getAttribute("newUserTel");
-			//验证码失效
+			// 验证码失效
 			if ((nowTime - checkTime) > 10 * 60 * 1000 || _checkCode == null) {
 				result.put("status", 2);
 				result.put("message", "验证码失效");
 				return result;
 			}
-			//验证码错误
+			// 验证码错误
 			if (!_checkCode.equals(telCheckCode) || !_newUserTel.equals(newUserTel)) {
 				result.put("status",0);
 				result.put("message", "验证码错误");
 				return result;
 			}
-			//验证码正确
+			// 验证码正确
 			if (_checkCode.equals(telCheckCode)) {
 				result.put("status", 1);
 				result.put("message", "验证码正确");
@@ -399,11 +400,11 @@ public class UserController {
 		if (userTel.equals(newUserTel)) {
 			throw new IllegalOperatorException("新手机号与旧手机号相同");
 		}
-		//手机号码正则表达式校验
+		// 手机号码正则表达式校验
 		if(!newUserTel.matches("^[0-9]{8,11}$")){
 			throw new IllegalOperatorException("新手机号格式不正确...");
 		}
-		//防止用户非法操作
+		// 防止用户非法操作
 		String _checkCode = (String) session.getAttribute("telCheckCode");
 		if(!_checkCode.equals(telCheckCode)){
 			throw new IllegalOperatorException("验证码错误");
@@ -418,6 +419,7 @@ public class UserController {
 			if (!userService.isTelUseable(newUserTel)) {
 				throw new IllegalOperatorException("手机号不可用...");
 			}
+			user.setUserTel(newUserTel);
 			user = userService.updateUserTel(userTel,newUserTel,user.getUserUU());
 			if(sysUser.getEnterprise()!=null){
 				user.setCurrentEnterprise(sysUser.getEnterprise().getUu());
@@ -481,7 +483,7 @@ public class UserController {
 		if (userPay != null && userPay.equals(newUserPay)) {
 			throw new IllegalOperatorException("新密码与旧密码相同");
 		}
-		//新密码正则校验
+		// 新密码正则校验
 		if(!newUserPay.matches("^\\d{6}$")){
 			throw new IllegalOperatorException("新密码格式不正确...");
 		}

+ 4 - 4
src/main/java/com/uas/platform/b2c/common/account/service/impl/UserServiceImpl.java

@@ -462,14 +462,14 @@ public class UserServiceImpl implements UserService {
 
 	@Override
 	public User updateUserTel(String oldTel, String newTel,Long uu) {
-		//旧手机号是否正确
+		// 旧手机号是否正确
 		User user = userDao.findOne(uu);
 			if(!user.getUserTel().equals(oldTel)){
 				throw new IllegalOperatorException("旧手机号错误");
 			}
 			try {
 				if(!StringUtils.isEmpty(oldTel) && !StringUtils.isEmpty(newTel)) {
-					//保存数据库
+					// 保存数据库
 					List<com.uas.account.entity.User> users = AccountUtils.updateTel(oldTel, newTel);
 					if (users != null && users.size() > 0) {
 						user.setUserTel(users.get(0).getUid());
@@ -489,9 +489,9 @@ public class UserServiceImpl implements UserService {
 		try {
 			if(!StringUtils.isEmpty(tel) && !StringUtils.isEmpty(newEmail)) {
 				User user = userDao.findOne(uu);
-				//从账户中心返回的数据
+				// 从账户中心返回的数据
 				List<com.uas.account.entity.User> users = AccountUtils.updateEmail(tel,newEmail);
-				//保存数据库
+				// 保存数据库
 				if (users != null && users.size() > 0) {
 					user.setUserEmail(users.get(0).getSecondUID());
 					user = userDao.save(user);

+ 0 - 32
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java

@@ -1941,19 +1941,6 @@ public class GoodsServiceImpl implements GoodsService {
 		goodsHist.setMessage(goodsHist.getMessage() + "该批次下架");
 		goodsHistoryService.save(goodsHist);
 
-//		ProductStandardPutOnInfo standardPutOnInfo = productStandardPutOnInfoDao.findOne(goods.getStandprodid());
-//		if(standardPutOnInfo != null) {
-//			standardPutOnInfo.setStatus(Status.REMOVED.value());
-//			standardPutOnInfo.setAvailableOnSale(NumberUtil.add(standardPutOnInfo.getAvailableOnSale(), standardPutOnInfo.getOnSaleQty()));
-//			standardPutOnInfo.setOnSaleQty(0.0d);
-//			productStandardPutOnInfoDao.save(standardPutOnInfo);
-//
-//			Product product = productDao.findOne(standardPutOnInfo.getProductid());
-//			product.setAvailableOnSale(standardPutOnInfo.getAvailableOnSale());
-//			product.setOnSaleQty(standardPutOnInfo.getOnSaleQty());
-//			productDao.save(product);
-//		}
-
 		//下架对应的批次
 		goodsDao.deleteByBatchCode(goods.getBatchCode());
 		return ResultMap.success(goods);
@@ -2277,28 +2264,11 @@ public class GoodsServiceImpl implements GoodsService {
 			histories.add(goodsHistory);
 			goodsUpdate.add(goods);
 
-//			ProductStandardPutOnInfo standardPutOnInfo = productStandardPutOnInfoDao.findOne(goods.getStandprodid());
-//			if(standardPutOnInfo != null) {
-//				standardPutOnInfo.setStatus(Status.REMOVED.value());
-//				standardPutOnInfo.setAvailableOnSale(NumberUtil.add(standardPutOnInfo.getAvailableOnSale(), standardPutOnInfo.getOnSaleQty()));
-//				standardPutOnInfo.setOnSaleQty(0.0d);
-//				productStandardPutOnInfoList.add(standardPutOnInfo);
-//
-//				Product product = productDao.findOne(standardPutOnInfo.getProductid());
-//				product.setAvailableOnSale(standardPutOnInfo.getAvailableOnSale());
-//				product.setOnSaleQty(standardPutOnInfo.getOnSaleQty());
-//				products.add(product);
-//			}else {
-//				throw new IllegalOperatorException("找不到对应的标准上架产品信息");
-//			}
-//			productStandardPutOnInfoService.updateAvailableQty(goods.getStandprodid(), goods.getReserve());
             uuids.add(goods.getUuid());
 		}
 
 		goodsDao.delete(goodsUpdate);
         goodsHistoryDao.save(histories);
-//		productDao.save(products);
-//		productStandardPutOnInfoDao.save(productStandardPutOnInfoList);
         for (String uuid : uuids) {
             updateComponentTradeInfos(uuid);
         }
@@ -2360,8 +2330,6 @@ public class GoodsServiceImpl implements GoodsService {
 		orderService.save(orders);
 		cartService.saveCart(carts);
 		browsingHistoryService.saveGoodsBrowsingHistoryList(browsingHistoryList);
-//		productStandardPutOnInfoService.save(putOnInfo);
-//		productService.save(product);
 		goodsHistoryService.save(goodsHistory);
 		return ResultMap.success(null);
 	}

+ 13 - 15
src/main/webapp/resources/js/usercenter/controllers/forstore/account_manager_ctrl.js

@@ -671,12 +671,12 @@ define(['app/app'], function (app) {
             });
           };
 
-          //对新密码进行校验
+          // 对新密码进行校验
           $scope.checkSuccess1 = false;
           $scope.checkFailed1 = false;
           $scope.checkNewPassword = function (newPassword) {
-            var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$/;
-            if (newPassword == null || !reg.test(newPassword)) {
+            var middlLevelReg = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/;
+            if (newPassword == null || !middlLevelReg.test(newPassword)) {
               //toaster.pop('error', '错误', '密码为8-20字符的英文、数字混合');
               $scope.checkSuccess1 = false;
               $scope.checkFailed1 = true;
@@ -691,7 +691,7 @@ define(['app/app'], function (app) {
             $scope.checkPasswordLevel(newValue);
           });
 
-          //密码强度校验
+          // 密码强度校验
           $scope.secLevel = 0;
           $scope.checkPasswordLevel = function (newPassword) {
             $scope.checkFailed1 = false;
@@ -699,20 +699,18 @@ define(['app/app'], function (app) {
               $scope.secLevel = 0;
               return false;
             }
-            //不足8位,或仅有数字,或仅有英文
-            if (newPassword.length < 8 || /^[0-9]*$/.test(newPassword)
-                || /^[A-Za-z]*$/.test(newPassword)) {
-              $scope.secLevel = 1;
+            // 密码强度中的正则
+            var middlLevelReg = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/;
+            // 密码强度高的正则
+            var heightLevelReg = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/;
+            if(heightLevelReg.test(newPassword)){
+              $scope.secLevel = 3;
               return false;
-            }
-            if (/^[A-Z0-9]{8,20}$/.test(newPassword) || /^[a-z0-9]{8,20}$/.test(
-                    newPassword)) {//达到8位,且 仅有数字+英文小写 或 仅有数字+英文大写
+            }else if(middlLevelReg.test(newPassword)){
               $scope.secLevel = 2;
               return false;
-            }
-            if (/^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,20}$/.test(
-                    newPassword)) {
-              $scope.secLevel = 3;
+            }else{
+              $scope.secLevel = 1;
               return false;
             }
           }

+ 13 - 15
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_account_management_ctrl.js

@@ -592,12 +592,12 @@ define(['app/app'], function(app) {
             });
           };
 
-          //对新密码进行校验
+          // 对新密码进行校验
           $scope.checkSuccess1 = false;
           $scope.checkFailed1 = false;
           $scope.checkNewPassword = function (newPassword) {
-            var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$/;
-            if (newPassword == null || !reg.test(newPassword)) {
+            var middlLevelReg = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/;
+            if (newPassword == null || !middlLevelReg.test(newPassword)) {
               //toaster.pop('error', '错误', '密码为8-20字符的英文、数字混合');
               $scope.checkSuccess1 = false;
               $scope.checkFailed1 = true;
@@ -612,7 +612,7 @@ define(['app/app'], function(app) {
             $scope.checkPasswordLevel(newValue);
           });
 
-          //密码强度校验
+          // 密码强度校验
           $scope.secLevel = 0;
           $scope.checkPasswordLevel = function (newPassword) {
             $scope.checkFailed1 = false;
@@ -620,20 +620,18 @@ define(['app/app'], function(app) {
               $scope.secLevel = 0;
               return false;
             }
-            //不足8位,或仅有数字,或仅有英文
-            if (newPassword.length < 8 || /^[0-9]*$/.test(newPassword)
-                || /^[A-Za-z]*$/.test(newPassword)) {
-              $scope.secLevel = 1;
+            // 密码强度中的正则
+            var middlLevelReg = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/;
+            // 密码强度高的正则
+            var heightLevelReg = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/;
+            if(heightLevelReg.test(newPassword)){
+              $scope.secLevel = 3;
               return false;
-            }
-            if (/^[A-Z0-9]{8,20}$/.test(newPassword) || /^[a-z0-9]{8,20}$/.test(
-                    newPassword)) {//达到8位,且 仅有数字+英文小写 或 仅有数字+英文大写
+            }else if(middlLevelReg.test(newPassword)){
               $scope.secLevel = 2;
               return false;
-            }
-            if (/^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,20}$/.test(
-                    newPassword)) {
-              $scope.secLevel = 3;
+            }else{
+              $scope.secLevel = 1;
               return false;
             }
           }