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

bugfix:头图审核返回状态更新数据库数据

panzhilin 3 hónapja
szülő
commit
bf64e2e388

+ 2 - 19
alien-store/src/main/java/shop/alien/store/controller/StoreImgController.java

@@ -144,9 +144,9 @@ public class StoreImgController {
             }
             Integer id = storeImgList.get(0).getId();
             if (storeImgService.saveOrUpdateBatch(storeImgList)) {
-                // 如果是头图,先设置审核状态为通过(1),然后进行AI审核
+                // 如果是头图,设置审核状态为通过(1),前端已完成门头图识别
                 if (isHeadImage) {
-                    // 有头图,设置为审核通过状态(1)
+                    // 有头图,设置为审核通过状态(1)
                     try {
                         storeInfoService.updateHeadImgStatus(storeImgInfoVo.getStoreId(), 1);
                         log.info("头图保存成功,设置审核状态为通过,storeId={}", storeImgInfoVo.getStoreId());
@@ -154,23 +154,6 @@ public class StoreImgController {
                         log.error("更新头图审核状态失败,storeId={}, error={}", 
                                 storeImgInfoVo.getStoreId(), e.getMessage(), e);
                     }
-                    
-                    // 然后进行AI审核,如果审核不通过则更新为2
-                    try {
-                        boolean auditResult = storeInfoService.auditHeadImageAndUpdateStatus(storeImgInfoVo);
-                        log.info("头图AI审核完成,storeId={}, imgType={}, auditResult={}", 
-                                storeImgInfoVo.getStoreId(), imgType, auditResult);
-                    } catch (Exception e) {
-                        log.error("头图AI审核异常,storeId={}, imgType={}, error={}", 
-                                storeImgInfoVo.getStoreId(), imgType, e.getMessage(), e);
-                        // AI审核异常时,设置审核状态为不通过
-                        try {
-                            storeInfoService.updateHeadImgStatus(storeImgInfoVo.getStoreId(), 2);
-                        } catch (Exception ex) {
-                            log.error("更新头图审核状态失败,storeId={}, error={}", 
-                                    storeImgInfoVo.getStoreId(), ex.getMessage(), ex);
-                        }
-                    }
                 }
                 if (null != id) {
                     return R.success("修改成功");

+ 30 - 11
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -277,18 +277,37 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             storeMainInfoVo.setHeadImgUrl("");
         }
         // 设置头图审核状态
-        // 逻辑说明:
-        // 1. 上传头图后,审核通过时,store_info.head_img_status会被设置为1
-        // 2. 查询时,如果store_info.head_img_status=1,说明头图已审核通过,返回1
-        // 从store_info表获取head_img_status字段值(通过getStoreInfo查询已包含此字段)
-        Integer headImgStatusFromDb = storeMainInfoVo.getHeadImgStatus();
-        if (headImgStatusFromDb != null && headImgStatusFromDb == 1) {
-            // 数据库head_img_status=1(审核通过),返回1
-            storeMainInfoVo.setHeadImgStatus(1); // 审核通过
-        } else {
-            // 数据库head_img_status不为1(待审核0、不通过2、拒绝3或为空),返回2
-            storeMainInfoVo.setHeadImgStatus(2); // 审核不通过
+        boolean hasHeadImg = false;
+        if (headImgList != null && !headImgList.isEmpty()) {
+            // 检查头图列表中是否有有效的图片地址
+            for (StoreImg headImg : headImgList) {
+                String imgUrl = headImg.getImgUrl();
+                if (imgUrl != null && !imgUrl.trim().isEmpty()) {
+                    hasHeadImg = true;
+                    log.debug("门店头图数据检查,storeId={}, imgType={}, imgUrl={}, 判断为有头图", 
+                            id, headImg.getImgType(), imgUrl);
+                    break;
+                }
+            }
+        }
+        // 根据是否有头图数据确定审核状态:有数据返回1(审核通过),没有数据返回2(审核不通过)
+        Integer headImgStatus = hasHeadImg ? 1 : 2;
+        // 获取数据库中的head_img_status状态
+        Integer headImgStatusFromDb = storeInfo.getHeadImgStatus();
+        // 记录查询结果日志
+        log.info("门店头图审核状态判断,storeId={}, 查询到头图数量={}, 是否有有效头图={}, 审核状态={}, 数据库原状态={}", 
+                id, headImgList != null ? headImgList.size() : 0, hasHeadImg, headImgStatus, headImgStatusFromDb);
+        // 实时更新数据库:如果数据库中的状态与实际情况不一致,或者为null,则更新数据库
+        if (headImgStatusFromDb == null || !headImgStatus.equals(headImgStatusFromDb)) {
+            try {
+                updateHeadImgStatus(id, headImgStatus);
+                log.info("门店头图审核状态已实时更新,storeId={}, 原状态={}, 新状态={}", id, headImgStatusFromDb, headImgStatus);
+            } catch (Exception e) {
+                log.error("更新门店头图审核状态失败,storeId={}, error={}", id, e.getMessage(), e);
+            }
         }
+        // 设置返回的审核状态(以实际的头图数据为准)
+        storeMainInfoVo.setHeadImgStatus(headImgStatus);
         List<StoreUser> storeUsers = storeUserMapper.selectList(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()));
         for (StoreUser storeUser : storeUsers) {
             storeMainInfoVo.setLogoutFlagUser(storeUser.getLogoutFlag());