lutong 3 месяцев назад
Родитель
Сommit
349880472e

+ 7 - 8
alien-store/src/main/java/shop/alien/store/service/impl/StoreRenovationBrowseRecordServiceImpl.java

@@ -200,15 +200,14 @@ public class StoreRenovationBrowseRecordServiceImpl extends ServiceImpl<StoreRen
     public List<StoreRenovationBrowseRequirementDto> getBrowsedRequirementsByStoreTel(String renovationStoreTel, String normalStoreTel) {
         log.info("StoreRenovationBrowseRecordServiceImpl.getBrowsedRequirementsByStoreTel?renovationStoreTel={}, normalStoreTel={}", renovationStoreTel, normalStoreTel);
         try {
-            // 0. 通过门店电话查询门店ID
-            LambdaQueryWrapper<StoreInfo> renovationStoreWrapper = new LambdaQueryWrapper<>();
-            renovationStoreWrapper.eq(StoreInfo::getStoreTel, renovationStoreTel);
-            renovationStoreWrapper.eq(StoreInfo::getDeleteFlag, 0);
-            StoreInfo renovationStoreInfo = storeInfoMapper.selectOne(renovationStoreWrapper);
-            if (renovationStoreInfo == null) {
-                throw new RuntimeException("装修商铺不存在,门店电话: " + renovationStoreTel);
+            // 0. 通过手机号查询门店ID
+            LambdaQueryWrapper<StoreUser> renovationStoreUserWrapper = new LambdaQueryWrapper<>();
+            renovationStoreUserWrapper.eq(StoreUser::getPhone, renovationStoreTel);
+            StoreUser renovationStoreUser = storeUserMapper.selectOne(renovationStoreUserWrapper);
+            if (renovationStoreUser == null || renovationStoreUser.getStoreId() == null) {
+                throw new RuntimeException("装修商铺不存在,手机号: " + renovationStoreTel);
             }
-            Integer renovationStoreId = renovationStoreInfo.getId();
+            Integer renovationStoreId = renovationStoreUser.getStoreId();
 
             LambdaQueryWrapper<StoreInfo> normalStoreWrapper = new LambdaQueryWrapper<>();
             normalStoreWrapper.eq(StoreInfo::getStoreTel, normalStoreTel);

+ 58 - 14
alien-store/src/main/java/shop/alien/store/service/impl/StoreRenovationRequirementServiceImpl.java

@@ -12,16 +12,10 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
-import shop.alien.entity.store.LifeNotice;
-import shop.alien.entity.store.StoreInfo;
-import shop.alien.entity.store.StoreRenovationRequirement;
-import shop.alien.entity.store.StoreUser;
+import shop.alien.entity.store.*;
 import shop.alien.entity.store.dto.StoreRenovationRequirementDto;
 import shop.alien.entity.store.vo.WebSocketVo;
-import shop.alien.mapper.LifeNoticeMapper;
-import shop.alien.mapper.StoreInfoMapper;
-import shop.alien.mapper.StoreRenovationRequirementMapper;
-import shop.alien.mapper.StoreUserMapper;
+import shop.alien.mapper.*;
 import shop.alien.store.config.WebSocketProcess;
 import shop.alien.store.service.StoreRenovationRequirementService;
 import shop.alien.store.util.ai.AiContentModerationUtil;
@@ -52,6 +46,7 @@ public class StoreRenovationRequirementServiceImpl extends ServiceImpl<StoreReno
 
     private final StoreInfoMapper storeInfoMapper;
 
+    private final LifeMessageMapper lifeMessageMapper;
 
     private final LifeNoticeMapper lifeNoticeMapper;
 
@@ -363,18 +358,18 @@ public class StoreRenovationRequirementServiceImpl extends ServiceImpl<StoreReno
                 if ("video".equals(auditType)) {
                     message = "在" + commonDate + ",您发布的装修动态视频审核已通过。";
                 } else {
-                    message = "在" + commonDate + ",您发布的装修动态审核已通过。";
+                    message = "您发布的装修需求已通过审核,平台已将此需求发布,有意向的装修公司会与您联系";
                 }
             } else {
                 // 审核不通过
                 title = "审核通知";
-                String reasonText = auditReason != null && !auditReason.trim().isEmpty() 
-                    ? ",原因:" + auditReason 
-                    : "";
+//                String reasonText = auditReason != null && !auditReason.trim().isEmpty()
+//                    ? ",原因:" + auditReason
+//                    : "";
                 if ("video".equals(auditType)) {
-                    message = "在" + commonDate + ",您发布的装修动态视频审核未通过" + reasonText + ",请修改后重新提交。";
+                    message = "在" + commonDate + ",您发布的装修动态视频审核未通过" + auditReason + ",请修改后重新提交。";
                 } else {
-                    message = "在" + commonDate + ",您发布的装修动态审核未通过" + reasonText + ",请修改后重新提交。";
+                    message = "您发布的装修需求未通过审核.驳回原因:"+auditReason+"请您重新发布.";
                 }
             }
 
@@ -519,6 +514,55 @@ public class StoreRenovationRequirementServiceImpl extends ServiceImpl<StoreReno
                     }
                 });
             }
+
+            // 检查是否已与发布商铺发生沟通
+            String currentUserPhone = null;
+            try {
+                com.alibaba.fastjson.JSONObject userInfo = JwtUtil.getCurrentUserInfo();
+                if (userInfo != null) {
+                    currentUserPhone = userInfo.getString("phone");
+                }
+            } catch (Exception e) {
+                log.debug("获取当前用户手机号失败(用户可能未登录): {}", e.getMessage());
+            }
+
+            if (currentUserPhone != null && StringUtils.hasText(currentUserPhone)) {
+                String currentUserPhoneId = "store_" + currentUserPhone;
+
+                // 批量查询沟通状态(优化:使用Map缓存结果,避免重复查询)
+                Map<String, Boolean> communicationStatusMap = new HashMap<>();
+
+                dtoPage.getRecords().forEach(dto -> {
+                    String storeTel = dto.getStoreTel();
+                    if (storeTel != null && StringUtils.hasText(storeTel)) {
+                        String publishingShopPhoneId = "store_" + storeTel;
+
+                        // 检查是否已查询过该商铺的沟通状态
+                        String communicationKey = currentUserPhoneId + "_" + publishingShopPhoneId;
+                        Boolean hasCommunicated = communicationStatusMap.get(communicationKey);
+
+                        if (hasCommunicated == null) {
+                            // 查询是否有消息记录(检查双向消息)
+                            LambdaQueryWrapper<LifeMessage> messageWrapper = new LambdaQueryWrapper<>();
+                            messageWrapper.eq(LifeMessage::getDeleteFlag, 0);
+                            messageWrapper.and(w -> w.and(w1 -> w1.eq(LifeMessage::getSenderId, currentUserPhoneId)
+                                            .eq(LifeMessage::getReceiverId, publishingShopPhoneId))
+                                    .or(w2 -> w2.eq(LifeMessage::getSenderId, publishingShopPhoneId)
+                                            .eq(LifeMessage::getReceiverId, currentUserPhoneId)));
+                            Integer messageCount = lifeMessageMapper.selectCount(messageWrapper);
+                            hasCommunicated = messageCount != null && messageCount > 0;
+                            communicationStatusMap.put(communicationKey, hasCommunicated);
+                        }
+
+                        dto.setHasCommunicated(hasCommunicated);
+                    } else {
+                        dto.setHasCommunicated(false);
+                    }
+                });
+            } else {
+                // 用户未登录,所有记录都设为未沟通
+                dtoPage.getRecords().forEach(dto -> dto.setHasCommunicated(false));
+            }
         }
 
         return dtoPage;