Ver Fonte

fix: 修改人员配置ai审核通过后逻辑,清空拒绝原因

penghao há 2 meses atrás
pai
commit
6a58d6d160

+ 17 - 14
alien-store/src/main/java/shop/alien/store/service/impl/StoreStaffAuditAsyncService.java

@@ -1,5 +1,6 @@
 package shop.alien.store.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -62,11 +63,11 @@ public class StoreStaffAuditAsyncService {
             log.info("开始异步审核员工内容,staffId={}", staffId);
 
             // 将状态置为"审核中"(0),清空拒绝原因
-            StoreStaffConfig auditingUpdate = new StoreStaffConfig();
-            auditingUpdate.setId(staffId);
-            auditingUpdate.setStatus("0");
-            auditingUpdate.setRejectionReason(null);
-            storeStaffConfigMapper.updateById(auditingUpdate);
+            LambdaUpdateWrapper<StoreStaffConfig> auditingWrapper = new LambdaUpdateWrapper<>();
+            auditingWrapper.eq(StoreStaffConfig::getId, staffId)
+                          .set(StoreStaffConfig::getStatus, "0")
+                          .set(StoreStaffConfig::getRejectionReason, null);
+            storeStaffConfigMapper.update(null, auditingWrapper);
 
             // 组装 AI 审核文本和图片
             StringBuilder textContent = new StringBuilder();
@@ -123,13 +124,15 @@ public class StoreStaffAuditAsyncService {
             // 根据 AI 审核结果更新状态
             // 审核通过:状态保持为"1"(审核通过)
             // 审核失败:状态设置为"2"(审核拒绝)
-            StoreStaffConfig auditUpdate = new StoreStaffConfig();
-            auditUpdate.setId(staffId);
+            LambdaUpdateWrapper<StoreStaffConfig> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.eq(StoreStaffConfig::getId, staffId);
+            
             if (allPassed) {
-                // AI审核通过,状态保持为"审核中"(1)
-                auditUpdate.setStatus("1");
-                auditUpdate.setRejectionReason(null);
-                log.info("人员AI审核通过,状态设置为审核通过:staffId={}", staffId);
+                // AI审核通过,状态设置为"审核通过"(1),明确清空拒绝原因
+                updateWrapper.set(StoreStaffConfig::getStatus, "1")
+                             .set(StoreStaffConfig::getRejectionReason, null);
+                storeStaffConfigMapper.update(null, updateWrapper);
+                log.info("人员AI审核通过,状态设置为审核通过,已清空拒绝原因:staffId={}", staffId);
             } else {
                 // AI审核失败,状态设置为"审核拒绝"(2)
                 // 收集所有失败原因
@@ -147,11 +150,11 @@ public class StoreStaffAuditAsyncService {
                 }
 
                 String reason = failureReasons.isEmpty() ? "审核未通过" : String.join("; ", failureReasons);
+                updateWrapper.set(StoreStaffConfig::getStatus, "2")
+                             .set(StoreStaffConfig::getRejectionReason, reason);
+                storeStaffConfigMapper.update(null, updateWrapper);
                 log.warn("人员AI审核失败,状态设置为审核拒绝:staffId={}, reason={}", staffId, reason);
-                auditUpdate.setStatus("2");
-                auditUpdate.setRejectionReason(reason);
             }
-            storeStaffConfigMapper.updateById(auditUpdate);
 
             log.info("异步审核员工内容完成,staffId={}", staffId);
         } catch (Exception e) {