Browse Source

消息、通知修改

qrs 2 weeks ago
parent
commit
0b4f0a0d07

+ 69 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeMessageNotDisturb.java

@@ -0,0 +1,69 @@
+package shop.alien.entity.store;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 消息免打扰
+ * </p>
+ *
+ * @author ssk
+ * @since 2025-07-11
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="LifeMessageNotDisturb对象", description="消息免打扰")
+public class LifeMessageNotDisturb extends Model<LifeMessageNotDisturb> {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键id")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "用户id")
+    @TableField("phone_id")
+    private String phoneId;
+
+    @ApiModelProperty(value = "免打扰id")
+    @TableField("not_disturb_id")
+    private String notDisturbId;
+
+    @ApiModelProperty(value = "删除标记  0:未删除  1:已删除")
+    @TableField("delete_flag")
+    @TableLogic
+    private Integer deleteFlag;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "created_time", fill = FieldFill.INSERT)
+    private Date createdTime;
+
+    @ApiModelProperty(value = "创建人ID")
+    @TableField(value = "created_user_id", fill = FieldFill.INSERT)
+    private Integer createdUserId;
+
+    @ApiModelProperty(value = "修改时间")
+    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
+    private Date updatedTime;
+
+    @ApiModelProperty(value = "修改人ID")
+    @TableField(value = "updated_user_id", fill = FieldFill.INSERT_UPDATE)
+    private Integer updatedUserId;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeMessageVo.java

@@ -31,6 +31,9 @@ public class LifeMessageVo extends LifeMessage {
     @ApiModelProperty(value = "未读消息数量")
     private Long notReadCount;
 
+    @ApiModelProperty(value = "是否免打扰 0-未免打扰 1-免打扰")
+    private String isNotDisturb;
+
     @ApiModelProperty(value = "我是否关注对方 0-未关注 1-已关注")
     private String isFollowThis;
 

+ 9 - 0
alien-entity/src/main/java/shop/alien/mapper/LifeBlacklistMapper.java

@@ -2,7 +2,9 @@ package shop.alien.mapper;
 
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Select;
 import shop.alien.entity.store.LifeBlacklist;
+import shop.alien.entity.store.vo.LifeBlacklistVo;
 
 import java.util.List;
 
@@ -26,4 +28,11 @@ public interface LifeBlacklistMapper extends BaseMapper<LifeBlacklist> {
      * @return 拉黑用户id 集合
      */
     List<Integer> getBlackList(Integer userId);
+
+    @Select("select if (black.blocked_type = '2', concat('user_', user.user_phone), concat('store_', suser.phone)) phoneId " +
+            "from life_blacklist black " +
+            "left join life_user user on user.id = black.blocked_id and black.blocked_type = '2' and user.delete_flag = 0 " +
+            "left join store_user suser on suser.id = black.blocked_id and black.blocked_type = '1' and suser.delete_flag = 0 " +
+            "where black.blocker_type = #{userType} and black.blocker_id = #{userId} and black.delete_flag = 0 ")
+    List<LifeBlacklistVo> getPhoneIdByUserId(String userType, String userId);
 }

+ 16 - 0
alien-entity/src/main/java/shop/alien/mapper/LifeMessageNotDisturbMapper.java

@@ -0,0 +1,16 @@
+package shop.alien.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import shop.alien.entity.store.LifeMessageNotDisturb;
+
+/**
+ * <p>
+ * 消息免打扰 Mapper 接口
+ * </p>
+ *
+ * @author ssk
+ * @since 2025-07-11
+ */
+public interface LifeMessageNotDisturbMapper extends BaseMapper<LifeMessageNotDisturb> {
+
+}

+ 6 - 0
alien-entity/src/main/java/shop/alien/mapper/LifeNoticeMapper.java

@@ -2,9 +2,15 @@ package shop.alien.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import shop.alien.entity.store.LifeNotice;
 
 @Mapper
 public interface LifeNoticeMapper extends BaseMapper<LifeNotice> {
 
+    @Select("select count(id) noReadNum from life_notice " +
+            "where delete_flag = 0 and is_read = 0 and receiver_id = #{receiverId} ")
+    int selectNoReadCount(@Param("receiverId") String receiverId);
+
 }

+ 1 - 1
alien-store/src/main/java/shop/alien/store/config/WebSocketProcess.java

@@ -66,7 +66,7 @@ public class WebSocketProcess {
      * 接收到客户端消息时触发
      */
     @OnMessage
-    public R<String> onMessage(String message, @PathParam("sendId") String sendId) throws Exception {
+    public R<String> onMessage(String message) throws Exception {
         try {
             WebsocketVo websocketVo = JSONObject.parseObject(message, WebsocketVo.class);
             JSONObject jsonObject = new JSONObject();

+ 47 - 39
alien-store/src/main/java/shop/alien/store/controller/LifeMessageController.java

@@ -3,6 +3,7 @@ package shop.alien.store.controller;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;
+import io.swagger.models.auth.In;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.messaging.handler.annotation.MessageMapping;
@@ -19,7 +20,7 @@ import java.util.List;
 /**
  * 消息
  */
-@Api(tags = {"期-消息"})
+@Api(tags = {"期-消息"})
 @Slf4j
 @RestController
 @CrossOrigin
@@ -27,8 +28,6 @@ import java.util.List;
 @RequiredArgsConstructor
 public class LifeMessageController {
 
-    private final LifeMessageMapper messageMapper;
-
     private final LifeMessageService lifeMessageService;
 
     @ApiOperation("消息列表")
@@ -40,34 +39,34 @@ public class LifeMessageController {
     @GetMapping("/getMessageList")
     public R<List<LifeMessageVo>> getMessageList(@RequestParam String receiverId,
                                                   @RequestParam int friendType,
-                                                  @RequestParam String search) {
+                                                  @RequestParam String search) throws Exception {
         log.info("LifeMessageController.getMessageList?receiverId={}, friendType={}, search={}", receiverId, friendType, search);
         return R.data(lifeMessageService.getMessageList(receiverId, friendType, search));
     }
 
-    @ApiOperation("未聊过的消息数据")
+    @ApiOperation("未读消息与通知数量")
     @ApiOperationSupport(order = 2)
     @ApiImplicitParams({@ApiImplicitParam(name = "receiverId", value = "当前登录人", dataType = "String", paramType = "query")})
-    @GetMapping("/getStrangerMessageNum")
-    public R<LifeMessageVo> getStrangerMessageNum(@RequestParam String receiverId) {
-        log.info("LifeMessageController.getStrangerMessageNum?receiverId={}", receiverId);
-        return R.data(lifeMessageService.getStrangerMessageNum(receiverId));
+    @GetMapping("/getAllNoReadCount")
+    public R<Integer> getAllNoReadCount(@RequestParam String receiverId) throws Exception {
+        log.info("LifeMessageController.getAllNoReadCount?receiverId={}", receiverId);
+        return R.data(lifeMessageService.getAllNoReadCount(receiverId));
     }
 
-    @ApiOperation("未关注人的消息数据")
+    @ApiOperation("未聊过的消息数据")
     @ApiOperationSupport(order = 3)
     @ApiImplicitParams({@ApiImplicitParam(name = "receiverId", value = "当前登录人", dataType = "String", paramType = "query")})
-    @GetMapping("/getNoFriendMessage")
-    public R<LifeMessageVo> getNoFriendMessage(@RequestParam String receiverId) {
-        log.info("LifeMessageController.getNoFriendMessageNum?receiverId={}", receiverId);
-        return R.data(lifeMessageService.getNoFriendMessageNum(receiverId));
+    @GetMapping("/getStrangerMessageNum")
+    public R<LifeMessageVo> getStrangerMessageNum(@RequestParam String receiverId) throws Exception {
+        log.info("LifeMessageController.getStrangerMessageNum?receiverId={}", receiverId);
+        return R.data(lifeMessageService.getStrangerMessageNum(receiverId));
     }
 
     @ApiOperation("消息详情")
     @ApiOperationSupport(order = 4)
     @ApiImplicitParams({@ApiImplicitParam(name = "当前登录人", value = "receiverId", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "senderId", value = "聊天对方", dataType = "String", paramType = "query")})
     @GetMapping("/getMessageListByReceiverId")
-    public R<List<LifeMessageVo>> getMessageListByReceiverId(@RequestParam String receiverId, @RequestParam String senderId) {
+    public R<List<LifeMessageVo>> getMessageListByReceiverId(@RequestParam String receiverId, @RequestParam String senderId) throws Exception {
         log.info("LifeMessageController.getMessageListByReceiverId?receiverId={}, senderId={}", receiverId, senderId);
         return R.data(lifeMessageService.getMessageListByReceiverId(receiverId, senderId));
     }
@@ -76,43 +75,52 @@ public class LifeMessageController {
     @ApiOperationSupport(order = 5)
     @ApiImplicitParams({@ApiImplicitParam(name = "receiverId", value = "当前登录人", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "senderId", value = "聊天对方", dataType = "String", paramType = "query")})
     @GetMapping("/read")
-    public R<Boolean> read(@RequestParam String receiverId, @RequestParam String senderId) {
+    public R<Boolean> read(@RequestParam String receiverId, @RequestParam String senderId) throws Exception {
         log.info("LifeMessageController.read?receiverId={}, senderId={}", receiverId, senderId);
         lifeMessageService.read(receiverId, senderId);
         return R.success("操作成功");
     }
 
-    @ApiOperation("未读消息数量")
-    @ApiOperationSupport(order = 6)
-    @ApiImplicitParams({@ApiImplicitParam(name = "receiverId", value = "当前登录人", dataType = "String", paramType = "query")})
-    @GetMapping("/noReadCount")
-    public R<Integer> noReadCount(@RequestParam String receiverId) {
-        log.info("LifeMessageController.noReadCount?receiverId={}", receiverId);
-        return R.data(lifeMessageService.noReadCount(receiverId));
-    }
-
     @ApiOperation("删除消息")
-    @ApiOperationSupport(order = 7)
+    @ApiOperationSupport(order = 6)
     @ApiImplicitParams({@ApiImplicitParam(name = "senderId", value = "聊天对方", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "receiverId", value = "当前登录人", dataType = "String", paramType = "query")})
     @GetMapping("/deleteMessageByPhoneId")
-    public R<Integer> deleteMessageByPhoneId(@RequestParam String senderId, @RequestParam String receiverId) {
+    public R<Integer> deleteMessageByPhoneId(@RequestParam String senderId, @RequestParam String receiverId) throws Exception {
         log.info("LifeMessageController.deleteMessageByPhoneId?senderId={},receiverId={}", senderId, receiverId);
         return R.data(lifeMessageService.deleteMessageByPhoneId(senderId, receiverId));
     }
 
-    @MessageMapping("/send")
-    @SendTo("/topic/messages")
-    public LifeMessage sendMessage(LifeMessage message) {
-        log.info("LifeMessageController.sendMessage?message={}", message.toString());
-        messageMapper.insert(message);
-        return message;
+    @ApiOperation("未关注人的消息数据")
+    @ApiOperationSupport(order = 7)
+    @ApiImplicitParams({@ApiImplicitParam(name = "receiverId", value = "当前登录人", dataType = "String", paramType = "query")})
+    @GetMapping("/getNoFriendMessage")
+    public R<LifeMessageVo> getNoFriendMessage(@RequestParam String receiverId) throws Exception {
+        log.info("LifeMessageController.getNoFriendMessageNum?receiverId={}", receiverId);
+        return R.data(lifeMessageService.getNoFriendMessageNum(receiverId));
     }
 
-    @GetMapping("/messages")
-    public List<LifeMessage> getMessages(@RequestParam String receiverId) {
-        log.info("LifeMessageController.getMessages?receiverId={}", receiverId);
-        LambdaUpdateWrapper<LifeMessage> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(LifeMessage::getReceiverId, receiverId);
-        return messageMapper.selectList(wrapper);
+    @ApiOperation("未读消息数量")
+    @ApiOperationSupport(order = 8)
+    @ApiImplicitParams({@ApiImplicitParam(name = "receiverId", value = "当前登录人", dataType = "String", paramType = "query")})
+    @GetMapping("/noReadCount")
+    public R<Integer> noReadCount(@RequestParam String receiverId) throws Exception {
+        log.info("LifeMessageController.noReadCount?receiverId={}", receiverId);
+        return R.data(lifeMessageService.noReadCount(receiverId));
     }
+
+//    @MessageMapping("/send")
+//    @SendTo("/topic/messages")
+//    public LifeMessage sendMessage(LifeMessage message) {
+//        log.info("LifeMessageController.sendMessage?message={}", message.toString());
+//        messageMapper.insert(message);
+//        return message;
+//    }
+//
+//    @GetMapping("/messages")
+//    public List<LifeMessage> getMessages(@RequestParam String receiverId) {
+//        log.info("LifeMessageController.getMessages?receiverId={}", receiverId);
+//        LambdaUpdateWrapper<LifeMessage> wrapper = new LambdaUpdateWrapper<>();
+//        wrapper.eq(LifeMessage::getReceiverId, receiverId);
+//        return messageMapper.selectList(wrapper);
+//    }
 }

+ 43 - 0
alien-store/src/main/java/shop/alien/store/controller/LifeMessageNotDisturbController.java

@@ -0,0 +1,43 @@
+package shop.alien.store.controller;
+
+import io.swagger.annotations.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import shop.alien.entity.result.R;
+import shop.alien.store.service.LifeMessageNotDisturbService;
+
+/**
+ * <p>
+ * 消息免打扰 前端控制器
+ * </p>
+ *
+ * @author ssk
+ * @since 2025-07-11
+ */
+@Api(tags = {"三期-消息免打扰"})
+@Slf4j
+@CrossOrigin
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/lifeMessageNotDisturb")
+public class LifeMessageNotDisturbController {
+
+    private final LifeMessageNotDisturbService lifeMessageNotDisturbService;
+
+    @ApiOperation("免打扰")
+    @ApiOperationSupport(order = 1)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "receiverId", value = "当前登录人phoneId", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "disturbId", value = "秒打扰人phoneId", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "type", value = "1-免打扰  2-取消免打扰", dataType = "Integer", paramType = "query")})
+    @GetMapping("/notDisturb")
+    public R<Boolean> notDisturb(@RequestParam String receiverId,
+                                 @RequestParam String disturbId,
+                                 @RequestParam int type) {
+        log.info("LifeMessageNotDisturbController.notDisturb?receiverId={}, disturbId={}, type={}", receiverId, disturbId, type);
+        if (lifeMessageNotDisturbService.notDisturb(receiverId, disturbId, type)) return R.success("操作成功");
+        return R.fail("操作失败");
+    }
+
+}

+ 18 - 0
alien-store/src/main/java/shop/alien/store/service/LifeMessageNotDisturbService.java

@@ -0,0 +1,18 @@
+package shop.alien.store.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.entity.store.LifeMessageNotDisturb;
+
+/**
+ * <p>
+ * 消息免打扰 服务类
+ * </p>
+ *
+ * @author ssk
+ * @since 2025-07-11
+ */
+public interface LifeMessageNotDisturbService extends IService<LifeMessageNotDisturb> {
+
+    boolean notDisturb(String receiverId, String disturbId, int type);
+
+}

+ 9 - 8
alien-store/src/main/java/shop/alien/store/service/LifeMessageService.java

@@ -9,19 +9,20 @@ import java.util.List;
 
 public interface LifeMessageService extends IService<LifeMessage> {
 
-    List<LifeMessageVo> getMessageList(String receiverId, int friendType, String search);
+    List<LifeMessageVo> getMessageList(String receiverId, int friendType, String search) throws Exception;
 
-    LifeMessageVo getStrangerMessageNum(String receiverId);
+    LifeMessageVo getStrangerMessageNum(String receiverId) throws Exception ;
 
-    LifeMessageVo getNoFriendMessageNum(String receiverId);
+    LifeMessageVo getNoFriendMessageNum(String receiverId) throws Exception ;
 
-    List<LifeMessageVo> getMessageListByReceiverId(String senderId, String receiverId);
+    List<LifeMessageVo> getMessageListByReceiverId(String senderId, String receiverId) throws Exception;
 
-    int read(String receiverId, String senderId);
+    int read(String receiverId, String senderId) throws Exception;
 
-    int noReadCount(String receiverId);
+    int noReadCount(String receiverId)throws Exception;
 
-    int deleteMessageByPhoneId(String senderId, String receiverId);
+    int deleteMessageByPhoneId(String senderId, String receiverId) throws Exception;
+
+    int getAllNoReadCount(String receiverId) throws Exception;
 
-    boolean notDisturb(String receiverId, int disturbId, int type);
 }

+ 42 - 0
alien-store/src/main/java/shop/alien/store/service/impl/LifeMessageNotDisturbServiceImpl.java

@@ -0,0 +1,42 @@
+package shop.alien.store.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import shop.alien.entity.store.LifeMessageNotDisturb;
+import shop.alien.mapper.LifeMessageNotDisturbMapper;
+import shop.alien.store.service.LifeMessageNotDisturbService;
+
+/**
+ * <p>
+ * 消息免打扰 服务实现类
+ * </p>
+ *
+ * @author ssk
+ * @since 2025-07-11
+ */
+@Service
+@RequiredArgsConstructor
+public class LifeMessageNotDisturbServiceImpl extends ServiceImpl<LifeMessageNotDisturbMapper, LifeMessageNotDisturb> implements LifeMessageNotDisturbService {
+
+    private final LifeMessageNotDisturbMapper lifeMessageNotDisturbMapper;
+
+    @Override
+    public boolean notDisturb(String receiverId, String disturbId, int type) {
+        if (1 == type) {
+            LifeMessageNotDisturb disturb = new LifeMessageNotDisturb();
+            disturb.setPhoneId(receiverId);
+            disturb.setNotDisturbId(disturbId);
+            lifeMessageNotDisturbMapper.insert(disturb);
+            return true;
+        } else if (2 == type) {
+            UpdateWrapper<LifeMessageNotDisturb> wrapper = new UpdateWrapper<>();
+            wrapper.eq("phone_id", receiverId);
+            wrapper.eq("not_disturb_id", disturbId);
+            lifeMessageNotDisturbMapper.delete(wrapper);
+            return true;
+        }
+        return false;
+    }
+}

+ 319 - 236
alien-store/src/main/java/shop/alien/store/service/impl/LifeMessageServiceImpl.java

@@ -3,46 +3,48 @@ package shop.alien.store.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.util.StringUtil;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
 import shop.alien.entity.store.*;
+import shop.alien.entity.store.vo.LifeBlacklistVo;
 import shop.alien.entity.store.vo.LifeFansVo;
 import shop.alien.entity.store.vo.LifeMessageVo;
-import shop.alien.mapper.LifeFansMapper;
-import shop.alien.mapper.LifeMessageMapper;
-import shop.alien.mapper.LifeUserMapper;
+import shop.alien.mapper.*;
 import shop.alien.store.service.LifeMessageService;
 import shop.alien.store.service.LifeUserService;
 import shop.alien.util.common.JwtUtil;
 
+import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
+@Slf4j
 @Service
 @RequiredArgsConstructor
 public class LifeMessageServiceImpl extends ServiceImpl<LifeMessageMapper, LifeMessage> implements LifeMessageService {
 
-    private final LifeMessageMapper messageMapper;
-
+    private final LifeMessageMapper lifeMessageMapper;
     private final LifeFansMapper fansMapper;
     private final LifeFansMapper lifeFansMapper;
     private final LifeUserMapper lifeUserMapper;
     private final StoreUserServiceImpl storeUserService;
     private final StoreImgServiceImpl storeImgService;
     private final LifeUserService lifeUserService;
-
+    private final LifeMessageNotDisturbMapper lifeMessageNotDisturbMapper;
+    private final LifeBlacklistMapper lifeBlacklistMapper;
+    private final LifeNoticeMapper lifeNoticeMapper;
 
     @Override
-    public List<LifeMessageVo> getMessageList(String receiverId, int friendType, String search) {
-        // 查询所有好友
+    public List<LifeMessageVo> getMessageList(String receiverId, int friendType, String search) throws Exception {
+        try {
+            // 查询所有好友
 //        QueryWrapper<LifeFansVo> wrapper = new QueryWrapper<>();
 //        wrapper.groupBy("foll.phoneId");
 
@@ -72,283 +74,364 @@ public class LifeMessageServiceImpl extends ServiceImpl<LifeMessageMapper, LifeM
 //            wrapper.apply("(sender_id not in (" + friendsIdsStr + ") and receiver_id not in (" + friendsIdsStr + "))");
 //        }
 
-        String blockerType = "user".equals(Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getString("userType")) ? "2" : "1";
-        String blockerId = JwtUtil.getCurrentUserInfo().getString("userId");
-        QueryWrapper<LifeFansVo> wrapper = new QueryWrapper<>();
-        wrapper.eq("message.num", 1);
-        // 过滤拉黑
-        wrapper.apply("(user.id not in ( " +
-                            "     select blocked_id from life_blacklist " +
-                            "     where blocker_type = '" + blockerType + "' and blocker_id = '" + blockerId + "' and blocked_type = '2' and delete_flag = 0 " +
-                            ") or user.id is null)");
-        wrapper.apply("(suser.id not in ( " +
-                            "     select blocked_id from life_blacklist " +
-                            "     where blocker_type = '" + blockerType + "' and blocker_id = '" + blockerId + "' and blocked_type = '1' and delete_flag = 0 " +
-                            ") or suser.id is null)");
-
-        // 通过搜索查询的情况下  不区分是否聊过  搜索所有消息
-        if (0 == friendType && StringUtil.isNotEmpty(search)) {
-            wrapper.apply("(user.user_name like '%" + search + "%' or suser.name like '%" + search + "%')");
-        // 聊过
-        } else if (1 == friendType) {
-            wrapper.apply("message.phoneId in ( " +
-                    "    select receiver_id " +
-                    "    from life_message " +
-                    "    where sender_id = '" + receiverId + "'" +
-                    "    group by receiver_id " +
-                    ")");
-        // 没聊过
-        } else if (2 == friendType) {
-            wrapper.apply("message.phoneId not in ( " +
-                    "    select receiver_id " +
-                    "    from life_message " +
-                    "    where sender_id = '" + receiverId + "'" +
-                    "    group by receiver_id " +
-                    ")");
-        }
-        wrapper.orderByDesc("message.created_time");
+            String blockerType = "user".equals(Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getString("userType")) ? "2" : "1";
+            String blockerId = JwtUtil.getCurrentUserInfo().getString("userId");
+            QueryWrapper<LifeFansVo> wrapper = new QueryWrapper<>();
+            wrapper.eq("message.num", 1);
+            // 过滤拉黑
+            wrapper.apply("(user.id not in ( " +
+                    "     select blocked_id from life_blacklist " +
+                    "     where blocker_type = '" + blockerType + "' and blocker_id = '" + blockerId + "' and blocked_type = '2' and delete_flag = 0 " +
+                    ") or user.id is null)");
+            wrapper.apply("(suser.id not in ( " +
+                    "     select blocked_id from life_blacklist " +
+                    "     where blocker_type = '" + blockerType + "' and blocker_id = '" + blockerId + "' and blocked_type = '1' and delete_flag = 0 " +
+                    ") or suser.id is null)");
+
+            // 通过搜索查询的情况下  不区分是否聊过  搜索所有消息
+            if (0 == friendType && StringUtil.isNotEmpty(search)) {
+                wrapper.apply("(user.user_name like '%" + search + "%' or suser.name like '%" + search + "%')");
+                // 聊过
+            } else if (1 == friendType) {
+                wrapper.apply("message.phoneId in ( " +
+                        "    select receiver_id " +
+                        "    from life_message " +
+                        "    where sender_id = '" + receiverId + "'" +
+                        "    group by receiver_id " +
+                        ")");
+                // 没聊过
+            } else if (2 == friendType) {
+                wrapper.apply("message.phoneId not in ( " +
+                        "    select receiver_id " +
+                        "    from life_message " +
+                        "    where sender_id = '" + receiverId + "'" +
+                        "    group by receiver_id " +
+                        ")");
+            }
+            wrapper.orderByDesc("message.created_time");
 //        IPage<LifeMessageVo> ipage = new Page<>(page, size);
-        List<LifeMessageVo> lifeMessagePageList = messageMapper.getLifeMessagePageByPhoneId(receiverId, wrapper);
-        if (!CollectionUtils.isEmpty(lifeMessagePageList)) {
-            // 取出所有发送消息的用户
+            List<LifeMessageVo> lifeMessagePageList = lifeMessageMapper.getLifeMessagePageByPhoneId(receiverId, wrapper);
+            if (!CollectionUtils.isEmpty(lifeMessagePageList)) {
+                // 取出所有发送消息的用户
 //            List<String> phoneIdList = lifeMessagePageList.stream().map(LifeMessageVo::getPhoneId).filter(item -> item.contains("_")).collect(Collectors.toList());
 
-            // 当前用户的所有关注
-            LambdaQueryWrapper<LifeFans> followWrapper = new LambdaQueryWrapper<>();
-            followWrapper.eq(LifeFans::getFansId, receiverId);
-            followWrapper.eq(LifeFans::getDeleteFlag, 0);
-            List<LifeFans> followList = fansMapper.selectList(followWrapper);
-            List<String> followIds = followList.stream().map(LifeFans::getFollowedId).collect(Collectors.toList());
-
-            // 当前用户的所有粉丝
-            LambdaQueryWrapper<LifeFans> fansWrapper = new LambdaQueryWrapper<>();
-            fansWrapper.eq(LifeFans::getFollowedId, receiverId);
-            followWrapper.eq(LifeFans::getDeleteFlag, 0);
-            List<LifeFans> fansList = fansMapper.selectList(fansWrapper);
-            List<String> fansIds = fansList.stream().map(LifeFans::getFansId).collect(Collectors.toList());
-
-            // 查询所有未读消息
-            LambdaQueryWrapper<LifeMessage> messageWrapper = new LambdaQueryWrapper<>();
-            messageWrapper.eq(LifeMessage::getReceiverId, receiverId);
-            messageWrapper.eq(LifeMessage::getIsRead, 0);
-            messageWrapper.eq(LifeMessage::getType, "1");
-            messageWrapper.eq(LifeMessage::getDeleteFlag, 0);
-            List<LifeMessage> noReadList = messageMapper.selectList(messageWrapper);
+                // 当前用户的所有关注
+                LambdaQueryWrapper<LifeFans> followWrapper = new LambdaQueryWrapper<>();
+                followWrapper.eq(LifeFans::getFansId, receiverId);
+                followWrapper.eq(LifeFans::getDeleteFlag, 0);
+                List<LifeFans> followList = fansMapper.selectList(followWrapper);
+                List<String> followIds = followList.stream().map(LifeFans::getFollowedId).collect(Collectors.toList());
+
+                // 当前用户的所有粉丝
+                LambdaQueryWrapper<LifeFans> fansWrapper = new LambdaQueryWrapper<>();
+                fansWrapper.eq(LifeFans::getFollowedId, receiverId);
+                followWrapper.eq(LifeFans::getDeleteFlag, 0);
+                List<LifeFans> fansList = fansMapper.selectList(fansWrapper);
+                List<String> fansIds = fansList.stream().map(LifeFans::getFansId).collect(Collectors.toList());
+
+                // 查询所有未读消息
+                LambdaQueryWrapper<LifeMessage> messageWrapper = new LambdaQueryWrapper<>();
+                messageWrapper.eq(LifeMessage::getReceiverId, receiverId);
+                messageWrapper.eq(LifeMessage::getIsRead, 0);
+                messageWrapper.eq(LifeMessage::getDeleteFlag, 0);
+                List<LifeMessage> noReadList = lifeMessageMapper.selectList(messageWrapper);
+
+                // 查询免打扰用户
+                QueryWrapper<LifeMessageNotDisturb> notDisturbWrapper = new QueryWrapper<>();
+                notDisturbWrapper.eq("phone_id", receiverId);
+                List<String> notDisturbList = lifeMessageNotDisturbMapper.selectList(notDisturbWrapper).stream().map(LifeMessageNotDisturb::getNotDisturbId).collect(Collectors.toList());
 
 //            // 根据手机号查询发送人信息
 //            List<String> storePhoneList = phoneIdList.stream().filter(item -> "store".equals(item.split("_")[0])).map(item -> item.split("_")[1]).collect(Collectors.toList());
 //            List<String> userPhoneList = phoneIdList.stream().filter(item -> "user".equals(item.split("_")[0])).map(item -> item.split("_")[1]).collect(Collectors.toList());
 //            String storePhones = "'" + String.join("','", storePhoneList) + "'";
 //            String userPhones = "'" + String.join("','", userPhoneList) + "'";
-//            List<LifeMessageVo> userList = messageMapper.getLifeUserAndStoreUserByPhone(storePhones, userPhones);
+//            List<LifeMessageVo> userList = lifeMessageMapper.getLifeUserAndStoreUserByPhone(storePhones, userPhones);
 
-            for (LifeMessageVo messageVo : lifeMessagePageList) {
+                for (LifeMessageVo messageVo : lifeMessagePageList) {
 //                // 发送人信息
 //                LifeMessageVo user = userList.stream().filter(item -> item.getPhoneId().equals(messageVo.getPhoneId())).findFirst().orElse(null);
 //                messageVo.setUserName(null == user ? "" : user.getUserName());
 //                messageVo.setUserImage(null == user ? "" : user.getUserImage());
 
-                // 未读消息数量
-                messageVo.setNotReadCount(noReadList.stream().filter(item -> item.getSenderId().equals(messageVo.getPhoneId())).count());
-
-                // 我是否关注对方
-                if (followIds.contains(messageVo.getPhoneId())) {
-                    messageVo.setIsFollowThis("1");
-                } else {
-                    messageVo.setIsFollowThis("0");
-                }
-
-                // 对方是否关注我
-                if (fansIds.contains(messageVo.getPhoneId())) {
-                    messageVo.setIsFollowMe("1");
-                } else {
-                    messageVo.setIsFollowMe("0");
-                }
-
-                // 判断当前登录人是否是商户
-                boolean store = messageVo.getPhoneId().contains("store_");
-                if (store) {
-                    messageVo.setIsMerchant("1");
-                } else {
-                    messageVo.setIsMerchant("0");
+                    // 免打扰
+                    if (notDisturbList.contains(messageVo.getPhoneId())) {
+                        messageVo.setIsNotDisturb("1");
+                        // 未读消息数量
+                        messageVo.setNotReadCount(0L);
+                    } else {
+                        messageVo.setIsNotDisturb("0");
+                        messageVo.setNotReadCount(noReadList.stream().filter(item -> item.getSenderId().equals(messageVo.getPhoneId())).count());
+                        // 未读消息数量
+                    }
+
+                    // 我是否关注对方
+                    if (followIds.contains(messageVo.getPhoneId())) {
+                        messageVo.setIsFollowThis("1");
+                    } else {
+                        messageVo.setIsFollowThis("0");
+                    }
+
+                    // 对方是否关注我
+                    if (fansIds.contains(messageVo.getPhoneId())) {
+                        messageVo.setIsFollowMe("1");
+                    } else {
+                        messageVo.setIsFollowMe("0");
+                    }
+
+                    // 判断当前登录人是否是商户
+                    boolean store = messageVo.getPhoneId().contains("store_");
+                    if (store) {
+                        messageVo.setIsMerchant("1");
+                    } else {
+                        messageVo.setIsMerchant("0");
+                    }
                 }
             }
-        }
 
-        return lifeMessagePageList;
+            return lifeMessagePageList;
+        } catch (Exception e) {
+            log.error("LifeMessageServiceImpl.getMessageList Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
 
     @Override
-    public LifeMessageVo getStrangerMessageNum(String receiverId) {
-        String blockerType = "user".equals(Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getString("userType")) ? "2" : "1";
-        String blockerId = JwtUtil.getCurrentUserInfo().getString("userId");
-        QueryWrapper<LifeFansVo> wrapper = new QueryWrapper<>();
-        // 过滤拉黑
-        wrapper.apply("(user.id not in ( " +
-                "     select blocked_id from life_blacklist " +
-                "     where blocker_type = '" + blockerType + "' and blocker_id = '" + blockerId + "' and blocked_type = '2' and delete_flag = 0 " +
-                ") or user.id is null)");
-        wrapper.apply("(suser.id not in ( " +
-                "     select blocked_id from life_blacklist " +
-                "     where blocker_type = '" + blockerType + "' and blocker_id = '" + blockerId + "' and blocked_type = '1' and delete_flag = 0 " +
-                ") or suser.id is null)");
-        // 没聊过
-        wrapper.apply("message.phoneId not in ( " +
-                "    select receiver_id " +
-                "    from life_message " +
-                "    where sender_id = '" + receiverId + "'" +
-                "    group by receiver_id " +
-                ")");
-        wrapper.orderByDesc("message.created_time");
-//        IPage<LifeMessageVo> ipage = new Page<>(1, Integer.MAX_VALUE);
-        List<LifeMessageVo> lifeMessagePageList = messageMapper.getLifeMessagePageByPhoneId(receiverId, wrapper);
-        LifeMessageVo vo = new LifeMessageVo();
-        if (!CollectionUtils.isEmpty(lifeMessagePageList)) {
-            vo.setUserName(lifeMessagePageList.get(0).getUserName());
-            vo.setNotReadCount(lifeMessagePageList.stream().filter(item -> 0 == item.getIsRead()).count());
-        }
+    public LifeMessageVo getStrangerMessageNum(String receiverId) throws Exception {
+        try {
+            // 查询免打扰用户
+            QueryWrapper<LifeMessageNotDisturb> notDisturbWrapper = new QueryWrapper<>();
+            notDisturbWrapper.eq("phone_id", receiverId);
+            List<String> notDisturbList = lifeMessageNotDisturbMapper.selectList(notDisturbWrapper).stream().map(LifeMessageNotDisturb::getNotDisturbId).collect(Collectors.toList());
+
+            String blockerType = "user".equals(Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getString("userType")) ? "2" : "1";
+            String blockerId = JwtUtil.getCurrentUserInfo().getString("userId");
+            QueryWrapper<LifeFansVo> wrapper = new QueryWrapper<>();
+            // 过滤拉黑
+            wrapper.apply("(user.id not in ( " +
+                    "     select blocked_id from life_blacklist " +
+                    "     where blocker_type = '" + blockerType + "' and blocker_id = '" + blockerId + "' and blocked_type = '2' and delete_flag = 0 " +
+                    ") or user.id is null)");
+            wrapper.apply("(suser.id not in ( " +
+                    "     select blocked_id from life_blacklist " +
+                    "     where blocker_type = '" + blockerType + "' and blocker_id = '" + blockerId + "' and blocked_type = '1' and delete_flag = 0 " +
+                    ") or suser.id is null)");
+            // 没聊过
+            wrapper.apply("message.phoneId not in ( " +
+                    "    select receiver_id " +
+                    "    from life_message " +
+                    "    where sender_id = '" + receiverId + "'" +
+                    "    group by receiver_id " +
+                    ")");
+            wrapper.orderByDesc("message.created_time");
+
+            List<LifeMessageVo> lifeMessagePageList = lifeMessageMapper.getLifeMessagePageByPhoneId(receiverId, wrapper);
+            LifeMessageVo vo = new LifeMessageVo();
+            if (!CollectionUtils.isEmpty(lifeMessagePageList)) {
+                vo.setUserName(lifeMessagePageList.get(0).getUserName());
+                lifeMessagePageList = lifeMessagePageList.stream().filter(item -> !notDisturbList.contains(item.getPhoneId())).collect(Collectors.toList());
+                vo.setNotReadCount(lifeMessagePageList.stream().filter(item -> 0 == item.getIsRead()).count());
+            }
 
-        return vo;
+            return vo;
+        } catch (Exception e) {
+            log.error("LifeMessageServiceImpl.getStrangerMessageNum Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
 
     @Override
-    public LifeMessageVo getNoFriendMessageNum(String receiverId) {
-        // 查询所有好友
-        QueryWrapper<LifeFansVo> wrapper = new QueryWrapper<>();
-        wrapper.groupBy("foll.phoneId");
-        String blockerType = "";
-        String blockerId = "";
-        if ("user".equals(receiverId.split("_")[0])) {
-            String myselfUserPhone = receiverId.split("_")[1];
-            blockerType = "2";
-            LifeUser myLifeUser = lifeUserService.getUserByPhone(myselfUserPhone);
-            blockerId = String.valueOf(myLifeUser.getId());
-        } else {
-            String myselfStorePhone = receiverId.split("_")[1];
-            blockerType = "1";
-            StoreUser myStoreUser = storeUserService.getUserByPhone(myselfStorePhone);
-            blockerId = String.valueOf(myStoreUser.getId());
-        }
-
-        List<LifeFansVo> lifeFansList = lifeFansMapper.getMutualAttention(new Page<>(1, Integer.MAX_VALUE), receiverId, blockerType, blockerId, wrapper).getRecords();
-        List<String> friendsIds = lifeFansList.stream().map(LifeFansVo::getPhoneId).filter(item -> !item.equals(receiverId)).collect(Collectors.toList());
-        String friendsIdsStr = "'" + String.join("','", friendsIds) + "'";
-
-        // 当前用户的所有未关注人消息
-        wrapper = new QueryWrapper<>();
-        wrapper.eq("num", 1);
-        wrapper.apply("(sender_id not in (" + friendsIdsStr + ") and receiver_id not in (" + friendsIdsStr + "))");
-        wrapper.orderByDesc("created_time");
-//        IPage<LifeMessageVo> ipage = new Page<>(1, Integer.MAX_VALUE);
-        List<LifeMessageVo> lifeMessageVoList = messageMapper.getLifeMessagePageByPhoneId(receiverId, wrapper);
-
-        LifeMessageVo messageVo = lifeMessageVoList.stream().max(Comparator.comparing(LifeMessageVo::getCreatedTime)).orElse(null);
-        if (messageVo != null) {
-            messageVo.setNotReadCount(lifeMessageVoList.stream().filter(item -> 0 == item.getIsRead()).count());
-            // 根据手机号查询发送人信息
-            String storePhones = "''";
-            String userPhones = "''";
-            if (messageVo.getPhoneId().split("_")[0].equals("store")) {
-                storePhones = "'" + messageVo.getPhoneId().split("_")[1] + "'";
+    public LifeMessageVo getNoFriendMessageNum(String receiverId) throws Exception {
+        try {
+            // 查询所有好友
+            QueryWrapper<LifeFansVo> wrapper = new QueryWrapper<>();
+            wrapper.groupBy("foll.phoneId");
+            String blockerType = "";
+            String blockerId = "";
+            if ("user".equals(receiverId.split("_")[0])) {
+                String myselfUserPhone = receiverId.split("_")[1];
+                blockerType = "2";
+                LifeUser myLifeUser = lifeUserService.getUserByPhone(myselfUserPhone);
+                blockerId = String.valueOf(myLifeUser.getId());
             } else {
-                userPhones = "'" + messageVo.getPhoneId().split("_")[1] + "'";
+                String myselfStorePhone = receiverId.split("_")[1];
+                blockerType = "1";
+                StoreUser myStoreUser = storeUserService.getUserByPhone(myselfStorePhone);
+                blockerId = String.valueOf(myStoreUser.getId());
             }
-            List<LifeMessageVo> userList = messageMapper.getLifeUserAndStoreUserByPhone(storePhones, userPhones);
-            if (!CollectionUtils.isEmpty(userList)) {
-                messageVo.setUserName(userList.get(0).getUserName());
-                messageVo.setUserImage(userList.get(0).getUserImage());
-            }
-        }
 
-        return messageVo;
-    }
+            List<LifeFansVo> lifeFansList = lifeFansMapper.getMutualAttention(new Page<>(1, Integer.MAX_VALUE), receiverId, blockerType, blockerId, wrapper).getRecords();
+            List<String> friendsIds = lifeFansList.stream().map(LifeFansVo::getPhoneId).filter(item -> !item.equals(receiverId)).collect(Collectors.toList());
+            String friendsIdsStr = "'" + String.join("','", friendsIds) + "'";
 
-    @Override
-    public List<LifeMessageVo> getMessageListByReceiverId(String receiverId, String senderId) {
-
-
-        // 获取发送方与接收方头像
-        LifeUser lifeUser1 = null;
-        StoreImg storeImg = null;
-        if (receiverId.startsWith("user_")) {
-            lifeUser1 = lifeUserMapper.selectOne(new QueryWrapper<LifeUser>().eq("user_phone", receiverId.substring(5)));
-        } else {
-            StoreUser storeUser1 = storeUserService.getOne(new QueryWrapper<StoreUser>().eq("phone", receiverId.substring(6)));
-            List<StoreImg> storeImgList = storeImgService.getStoreImg(storeUser1.getStoreId(), 10);
-            if (!storeImgList.isEmpty()) {
-                storeImg = storeImgList.get(0);
+            // 当前用户的所有未关注人消息
+            wrapper = new QueryWrapper<>();
+            wrapper.eq("num", 1);
+            wrapper.apply("(sender_id not in (" + friendsIdsStr + ") and receiver_id not in (" + friendsIdsStr + "))");
+            wrapper.orderByDesc("created_time");
+//        IPage<LifeMessageVo> ipage = new Page<>(1, Integer.MAX_VALUE);
+            List<LifeMessageVo> lifeMessageVoList = lifeMessageMapper.getLifeMessagePageByPhoneId(receiverId, wrapper);
+
+            LifeMessageVo messageVo = lifeMessageVoList.stream().max(Comparator.comparing(LifeMessageVo::getCreatedTime)).orElse(null);
+            if (messageVo != null) {
+                messageVo.setNotReadCount(lifeMessageVoList.stream().filter(item -> 0 == item.getIsRead()).count());
+                // 根据手机号查询发送人信息
+                String storePhones = "''";
+                String userPhones = "''";
+                if (messageVo.getPhoneId().split("_")[0].equals("store")) {
+                    storePhones = "'" + messageVo.getPhoneId().split("_")[1] + "'";
+                } else {
+                    userPhones = "'" + messageVo.getPhoneId().split("_")[1] + "'";
+                }
+                List<LifeMessageVo> userList = lifeMessageMapper.getLifeUserAndStoreUserByPhone(storePhones, userPhones);
+                if (!CollectionUtils.isEmpty(userList)) {
+                    messageVo.setUserName(userList.get(0).getUserName());
+                    messageVo.setUserImage(userList.get(0).getUserImage());
+                }
             }
-        }
 
-        LifeUser lifeUser2 = null;
-        StoreImg storeImg1 = null;
-        if (senderId.startsWith("user_")) {
-            lifeUser2 = lifeUserMapper.selectOne(new QueryWrapper<LifeUser>().eq("user_phone", senderId.substring(5)));
-        } else {
-            StoreUser storeUser2 = storeUserService.getOne(new QueryWrapper<StoreUser>().eq("phone", senderId.substring(6)));
-            List<StoreImg> storeImgList = storeImgService.getStoreImg(storeUser2.getStoreId(), 10);
-            if (!storeImgList.isEmpty()) {
-                storeImg1 = storeImgList.get(0);
-            }
+            return messageVo;
+        } catch (Exception e) {
+            log.error("LifeMessageServiceImpl.getNoFriendMessageNum Error Mgs={}", e.getMessage());
+            throw new Exception(e);
         }
+    }
 
-
-        List<LifeMessageVo> lifeMessageVos = messageMapper.selectUserImageLists(receiverId, senderId);
-        for (LifeMessageVo lifeMessageVo : lifeMessageVos) {
-            if (lifeMessageVo.getReceiverId().equals(receiverId)) {
-                if (null != lifeUser1) {
-                    lifeMessageVo.setReceiverImg(lifeUser1.getUserImage());
-                } else if (null != storeImg) {
-                    lifeMessageVo.setReceiverImg(storeImg.getImgUrl());
+    @Override
+    public List<LifeMessageVo> getMessageListByReceiverId(String receiverId, String senderId) throws Exception {
+        try {
+            // 获取发送方与接收方头像
+            LifeUser lifeUser1 = null;
+            StoreImg storeImg = null;
+            if (receiverId.startsWith("user_")) {
+                lifeUser1 = lifeUserMapper.selectOne(new QueryWrapper<LifeUser>().eq("user_phone", receiverId.substring(5)));
+            } else {
+                StoreUser storeUser1 = storeUserService.getOne(new QueryWrapper<StoreUser>().eq("phone", receiverId.substring(6)));
+                List<StoreImg> storeImgList = storeImgService.getStoreImg(storeUser1.getStoreId(), 10);
+                if (!storeImgList.isEmpty()) {
+                    storeImg = storeImgList.get(0);
                 }
+            }
 
-                if (null != lifeUser2) {
-                    lifeMessageVo.setSenderImg(lifeUser2.getUserImage());
-                } else if (null != storeImg1) {
-                    lifeMessageVo.setSenderImg(storeImg1.getImgUrl());
-                }
+            LifeUser lifeUser2 = null;
+            StoreImg storeImg1 = null;
+            if (senderId.startsWith("user_")) {
+                lifeUser2 = lifeUserMapper.selectOne(new QueryWrapper<LifeUser>().eq("user_phone", senderId.substring(5)));
             } else {
-                if (null != lifeUser1) {
-                    lifeMessageVo.setSenderImg(lifeUser1.getUserImage());
-                } else if (null != storeImg) {
-                    lifeMessageVo.setSenderImg(storeImg.getImgUrl());
+                StoreUser storeUser2 = storeUserService.getOne(new QueryWrapper<StoreUser>().eq("phone", senderId.substring(6)));
+                List<StoreImg> storeImgList = storeImgService.getStoreImg(storeUser2.getStoreId(), 10);
+                if (!storeImgList.isEmpty()) {
+                    storeImg1 = storeImgList.get(0);
                 }
-                if (null != lifeUser2) {
-                    lifeMessageVo.setReceiverImg(lifeUser2.getUserImage());
-                } else if (null != storeImg1) {
-                    lifeMessageVo.setReceiverImg(storeImg1.getImgUrl());
+            }
+
+            List<LifeMessageVo> lifeMessageVos = lifeMessageMapper.selectUserImageLists(receiverId, senderId);
+            for (LifeMessageVo lifeMessageVo : lifeMessageVos) {
+                if (lifeMessageVo.getReceiverId().equals(receiverId)) {
+                    if (null != lifeUser1) {
+                        lifeMessageVo.setReceiverImg(lifeUser1.getUserImage());
+                    } else if (null != storeImg) {
+                        lifeMessageVo.setReceiverImg(storeImg.getImgUrl());
+                    }
+
+                    if (null != lifeUser2) {
+                        lifeMessageVo.setSenderImg(lifeUser2.getUserImage());
+                    } else if (null != storeImg1) {
+                        lifeMessageVo.setSenderImg(storeImg1.getImgUrl());
+                    }
+                } else {
+                    if (null != lifeUser1) {
+                        lifeMessageVo.setSenderImg(lifeUser1.getUserImage());
+                    } else if (null != storeImg) {
+                        lifeMessageVo.setSenderImg(storeImg.getImgUrl());
+                    }
+                    if (null != lifeUser2) {
+                        lifeMessageVo.setReceiverImg(lifeUser2.getUserImage());
+                    } else if (null != storeImg1) {
+                        lifeMessageVo.setReceiverImg(storeImg1.getImgUrl());
+                    }
                 }
             }
+            return lifeMessageVos;
+        } catch (Exception e) {
+            log.error("LifeMessageServiceImpl.getMessageListByReceiverId Error Mgs={}", e.getMessage());
+            throw new Exception(e);
         }
-        return lifeMessageVos;
     }
 
     @Override
-    public int read(String receiverId, String senderId) {
-        LambdaUpdateWrapper<LifeMessage> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(LifeMessage::getReceiverId, receiverId);
-        wrapper.eq(LifeMessage::getSenderId, senderId);
-        wrapper.eq(LifeMessage::getDeleteFlag, 0);
-        wrapper.set(LifeMessage::getIsRead, 1);
-        return messageMapper.update(null, wrapper);
+    public int read(String receiverId, String senderId) throws Exception {
+        try {
+            LambdaUpdateWrapper<LifeMessage> wrapper = new LambdaUpdateWrapper<>();
+            wrapper.eq(LifeMessage::getReceiverId, receiverId);
+            wrapper.eq(LifeMessage::getSenderId, senderId);
+            wrapper.eq(LifeMessage::getDeleteFlag, 0);
+            wrapper.set(LifeMessage::getIsRead, 1);
+            return lifeMessageMapper.update(null, wrapper);
+        } catch (Exception e) {
+            log.error("LifeMessageServiceImpl.read Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
 
     @Override
-    public int noReadCount(String receiverId) {
-        LambdaUpdateWrapper<LifeMessage> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(LifeMessage::getReceiverId, receiverId);
-        wrapper.eq(LifeMessage::getIsRead, 0);
-        wrapper.eq(LifeMessage::getDeleteFlag, 0);
-        return messageMapper.selectCount(wrapper);
+    public int noReadCount(String receiverId) throws Exception {
+        try {
+            LambdaUpdateWrapper<LifeMessage> wrapper = new LambdaUpdateWrapper<>();
+            wrapper.eq(LifeMessage::getReceiverId, receiverId);
+            wrapper.eq(LifeMessage::getIsRead, 0);
+            wrapper.eq(LifeMessage::getDeleteFlag, 0);
+            return lifeMessageMapper.selectCount(wrapper);
+        } catch (Exception e) {
+            log.error("LifeMessageServiceImpl.noReadCount Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
 
     @Override
-    public int deleteMessageByPhoneId(String senderId, String receiverId) {
-        return messageMapper.deleteMessageByPhoneId(senderId, receiverId);
+    public int deleteMessageByPhoneId(String senderId, String receiverId) throws Exception {
+        try {
+            return lifeMessageMapper.deleteMessageByPhoneId(senderId, receiverId);
+        } catch (Exception e) {
+            log.error("LifeMessageServiceImpl.deleteMessageByPhoneId Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
 
     @Override
-    public boolean notDisturb(String receiverId, int disturbId, int type) {
-        return false;
+    public int getAllNoReadCount(String receiverId) throws Exception {
+        try {
+            String blockerType = "user".equals(Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getString("userType")) ? "2" : "1";
+            String blockerId = JwtUtil.getCurrentUserInfo().getString("userId");
+
+            // 查询拉黑
+            List<String> lifeBlacklistVoList = lifeBlacklistMapper.getPhoneIdByUserId(blockerType, blockerId).stream().map(LifeBlacklistVo::getPhoneId).collect(Collectors.toList());
+
+            // 查询免打扰用户
+            QueryWrapper<LifeMessageNotDisturb> notDisturbWrapper = new QueryWrapper<>();
+            notDisturbWrapper.eq("phone_id", receiverId);
+            List<String> notDisturbList = lifeMessageNotDisturbMapper.selectList(notDisturbWrapper).stream().map(LifeMessageNotDisturb::getNotDisturbId).collect(Collectors.toList());
+            notDisturbList.addAll(lifeBlacklistVoList);
+            String notDisturbIdsStr = "'" + String.join("','", notDisturbList) + "'";
+
+            // 查询未读消息数量
+            LambdaQueryWrapper<LifeMessage> messageWrapper = new LambdaQueryWrapper<>();
+            messageWrapper.eq(LifeMessage::getReceiverId, receiverId);
+            messageWrapper.eq(LifeMessage::getIsRead, 0);
+            messageWrapper.notIn(LifeMessage::getSenderId, notDisturbIdsStr);
+            int noReadMessageCount = lifeMessageMapper.selectCount(messageWrapper);
+
+            // 查询未读通知数量
+            LambdaQueryWrapper<LifeNotice> noticeWrapper = new LambdaQueryWrapper<>();
+            noticeWrapper.eq(LifeNotice::getReceiverId, receiverId);
+            noticeWrapper.eq(LifeNotice::getIsRead, 0);
+            int noReadNoticeCount = lifeNoticeMapper.selectCount(noticeWrapper);
+
+            return noReadMessageCount + noReadNoticeCount;
+        } catch (Exception e) {
+            log.error("LifeMessageServiceImpl.getAllNoReadCount Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
+
 }