Bläddra i källkod

fix 车队生成新账号时,校验账号是否存在

zoujiajian 3 år sedan
förälder
incheckning
6fec39d71e

+ 10 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -319,6 +319,16 @@ public class CmsAccountController {
 	    }
 	    if (StrUtil.isNotBlank(account.getAccount())){
 			account.setAccount(account.getAccount().trim());
+			//账号是否已经添加过
+			if (!account.getAccount().contains("客服")) {
+				int count = accountService.count(Wrappers.lambdaQuery(Account.class)
+						.ne(Account::getId, account.getId())
+						.eq(Account::getAccount, account.getAccount())
+						.eq(Account::getGoodsId, account.getGoodsId()));
+				if (count > 0) {
+					throw BusinessRuntimeException.getInstance("该平台下已生成该账号");
+				}
+			}
 		}
 	    if (StrUtil.isNotBlank(account.getPassword())){
 		    account.setPassword(account.getPassword().trim());

+ 10 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/group/CmsGroupController.java

@@ -2,6 +2,7 @@ package com.cyksj.web.controller.manage.group;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.annotation.Log;
 import com.cyksj.common.annotation.NoSubmit;
 import com.cyksj.common.exception.BusinessRuntimeException;
@@ -141,6 +142,15 @@ public class CmsGroupController {
         if (goodsDonSkuView == null) {
             throw BusinessRuntimeException.getInstance("该车队规格不属于该账号平台");
         }
+        //账号是否已经添加过
+        if (!account.getAccount().contains("客服")) {
+            int count = accountService.count(Wrappers.lambdaQuery(Account.class)
+                    .eq(Account::getAccount, account.getAccount())
+                    .eq(Account::getGoodsId, account.getGoodsId()));
+            if (count > 0) {
+                throw BusinessRuntimeException.getInstance("该平台下已生成该账号");
+            }
+        }
         accountService.save(account);
         groupsTrips.setAccountId(account.getId());
         groupService.setAccount(groupsTrips);