Pārlūkot izejas kodu

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

‘linchangsheng’ 6 mēneši atpakaļ
vecāks
revīzija
17b1de1afb

+ 12 - 8
mall-server-api/src/main/java/com/gree/mall/manager/logic/worker/WorkerTeamLogic.java

@@ -86,26 +86,30 @@ public class WorkerTeamLogic {
     }
 
     private void checkUniqueTeam(WorkerTeam workerTeam) {
-        final Integer count = workerTeamService.lambdaQuery()
+        final WorkerTeam count = workerTeamService.lambdaQuery()
                 .eq(WorkerTeam::getCompanyWechatId, workerTeam.getCompanyWechatId())
                 .eq(WorkerTeam::getWebsitId, workerTeam.getWebsitId())
                 .eq(WorkerTeam::getMasterWorkerId, workerTeam.getMasterWorkerId())
                 .eq(WorkerTeam::getAssistantWorkerId, workerTeam.getAssistantWorkerId())
                 .ne(StringUtils.isNotBlank(workerTeam.getId()), WorkerTeam::getId, workerTeam.getId())
-                .count();
-        if (count > 0) {
-            throw new RemoteServiceException(workerTeam.getWebsitId() + "已存在一组同样师傅的记录" + workerTeam.getMasterWorkerId() + "," + workerTeam.getAssistantWorkerId());
+                .last("limit 1")
+                .one();
+        if (Objects.nonNull(count)) {
+            throw new RemoteServiceException(workerTeam.getWebsitId() + "已存在一组同样师傅的记录" + workerTeam.getMasterWorkerId()
+                    + "," + workerTeam.getAssistantWorkerId() + (count.getStatus().equals(StateEnum.OFF.getKey()) ? ", 请设为“有效”" : ""));
         }
 
-        final Integer count1 = workerTeamService.lambdaQuery()
+        final WorkerTeam count1 = workerTeamService.lambdaQuery()
                 .eq(WorkerTeam::getCompanyWechatId, workerTeam.getCompanyWechatId())
                 .eq(WorkerTeam::getWebsitId, workerTeam.getWebsitId())
                 .eq(WorkerTeam::getMasterWorkerId, workerTeam.getAssistantWorkerId())
                 .eq(WorkerTeam::getAssistantWorkerId, workerTeam.getMasterWorkerId())
                 .ne(StringUtils.isNotBlank(workerTeam.getId()), WorkerTeam::getId, workerTeam.getId())
-                .count();
-        if (count1 > 0) {
-            throw new RemoteServiceException(workerTeam.getWebsitId() + "已存在一组同样师傅的记录" + workerTeam.getMasterWorkerId() + "," + workerTeam.getAssistantWorkerId());
+                .last("limit 1")
+                .one();
+        if (Objects.nonNull(count1)) {
+            throw new RemoteServiceException(workerTeam.getWebsitId() + "已存在一组同样师傅的记录" + workerTeam.getMasterWorkerId()
+                    + "," + workerTeam.getAssistantWorkerId() + (count.getStatus().equals(StateEnum.OFF.getKey()) ? ", 请设为“有效”" : ""));
         }