From eb5d7885fa9e4bd20c0827eec9b4cdd48c47b509 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 07 一月 2025 09:11:20 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java |   58 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
index c557b95..d4e7951 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
@@ -3,7 +3,10 @@
 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.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.AppUser;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.web.page.PageInfo;
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.order.feignClient.RemoteOrderGoodsClient;
 import com.ruoyi.other.api.domain.TechnicianSubscribe;
@@ -11,10 +14,12 @@
 import com.ruoyi.other.mapper.TechnicianSubscribeMapper;
 import com.ruoyi.other.service.TechnicianSubscribeService;
 import com.ruoyi.other.vo.TechnicianSubscribeVO;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.util.List;
 
 /**
@@ -31,10 +36,36 @@
     private TechnicianSubscribeMapper technicianSubscribeMapper;
     @Resource
     private RemoteOrderGoodsClient orderGoodsClient;
+    @Resource
+    private RedisTemplate<String, String> redisTemplate;
+    
+    @Resource
+    private AppUserClient appUserClient;
+    
+    
+    
+    
 
     @Override
-    public List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop(Long userId, Long shopId, Integer status) {
-        return technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop(userId, shopId,status);
+    public PageInfo<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop(Long shopId, Integer status, Integer pageCurr, Integer pageSize) {
+        PageInfo<TechnicianSubscribeVO> pageInfo = new PageInfo(pageCurr, pageSize);
+        List<TechnicianSubscribeVO> list = technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop(pageInfo, shopId, status);
+        for (TechnicianSubscribeVO technicianSubscribeVO : list) {
+            Long id = technicianSubscribeVO.getId();
+            TechnicianSubscribe technicianSubscribe = this.getById(id);
+            AppUser appUser = appUserClient.getAppUserById(technicianSubscribe.getAppUserId());
+            technicianSubscribeVO.setUserName(appUser.getName());
+            technicianSubscribeVO.setPhone(appUser.getPhone());
+        }
+        return pageInfo.setRecords(list);
+    }
+    @Override
+    public PageInfo<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop1(Long shopId, Integer status , String phone,
+                                                                                String name,
+                                                                                Integer serviceMode, Integer pageCurr, Integer pageSize) {
+        PageInfo<TechnicianSubscribeVO> pageInfo = new PageInfo(pageCurr, pageSize);
+        List<TechnicianSubscribeVO> technicianSubscribeByUserAndShop1 = technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop1(pageInfo, shopId, status, phone, name, serviceMode);
+        return pageInfo.setRecords(technicianSubscribeByUserAndShop1);
     }
     @Override
     public IPage<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Page<TechnicianSubscribe> page, Long userId, Integer status) {
@@ -43,20 +74,17 @@
 
     @Override
     public void subscribe(TechnicianSubscribe subscribe) {
-        if (StringUtils.isNotEmpty(subscribe.getIdStr())){
-            subscribe.setId(Long.parseLong(subscribe.getIdStr()));
-            technicianSubscribeMapper.updateById(subscribe);
-        }else {
-            Long userId = SecurityUtils.getUserId();
-            subscribe.setAppUserId(userId);
-            subscribe.setStatus(TechnicianStatus.UNSUBSCRIBE.getCode());
-            subscribe.setDelFlag(0);
-            subscribe.setCreateTime(LocalDateTime.now());
-            technicianSubscribeMapper.insert(subscribe);
-        }
-        if (subscribe.getTechnicianId() != null){
+        Long userId = SecurityUtils.getUserId();
+        subscribe.setAppUserId(userId);
+        subscribe.setStatus(TechnicianStatus.UNSUBSCRIBE.getCode());
+        subscribe.setDelFlag(0);
+        subscribe.setCreateTime(LocalDateTime.now());
+        technicianSubscribeMapper.insert(subscribe);
+        if (subscribe.getOrderId() != null){
             orderGoodsClient.subscribe(subscribe.getOrderId(), subscribe.getTechnicianId());
         }
-
+        LocalDateTime subscribeTime = subscribe.getSubscribeTime();
+        long deadlineTimestamp = subscribeTime.atZone(ZoneId.systemDefault()).toEpochSecond();
+        redisTemplate.opsForZSet().add("delay_queue:subscribe", subscribe.getId().toString(), deadlineTimestamp);
     }
 }

--
Gitblit v1.7.1