chenhj
昨天 a4d3ac72a1d250517dcbc554aea4f09e505b7171
Merge branch 'dev_New' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_New
已添加18个文件
已修改5个文件
1328 ■■■■■ 文件已修改
src/main/java/com/ruoyi/basic/controller/CustomerController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/controller/CustomerFollowUpController.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/dto/CustomerDto.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/dto/CustomerFollowUpDto.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/dto/CustomerReturnVisitDto.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/mapper/CustomerFollowUpFileMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/mapper/CustomerFollowUpMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/mapper/CustomerReturnVisitMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/pojo/Customer.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/pojo/CustomerFollowUp.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/pojo/CustomerFollowUpFile.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/pojo/CustomerReturnVisit.java 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/CustomerFollowUpFileService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/CustomerFollowUpService.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/CustomerReturnVisitService.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/ICustomerService.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpFileServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpServiceImpl.java 227 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/impl/CustomerReturnVisitServiceImpl.java 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/impl/ReturnVisitReminderService.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/task/ReturnVisitReminderTask.java 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/controller/CustomerController.java
@@ -32,7 +32,7 @@
     * æŸ¥è¯¢å®¢æˆ·æ¡£æ¡ˆåˆ—表
     */
    @GetMapping("/list")
    public IPage<Customer> list(Page page, Customer customer) {
    public IPage<Customer> list(Page<Customer> page, Customer customer) {
        return customerService.selectCustomerList(page, customer);
    }
@@ -76,7 +76,7 @@
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(customerService.selectCustomerById(id));
        return success(customerService.selectCustomerDetailById(id));
    }
    /**
src/main/java/com/ruoyi/basic/controller/CustomerFollowUpController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,144 @@
package com.ruoyi.basic.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.basic.pojo.CustomerFollowUp;
import com.ruoyi.basic.pojo.CustomerReturnVisit;
import com.ruoyi.basic.service.CustomerFollowUpService;
import com.ruoyi.basic.service.CustomerReturnVisitService;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
 * <br>
 * å®¢æˆ·è·Ÿè¿›æŽ§åˆ¶å±‚
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:45
 */
@RestController
@RequestMapping("/basic/customer-follow")
public class CustomerFollowUpController extends BaseController {
    @Autowired
    private CustomerFollowUpService customerFollowUpService;
    @Autowired
    private CustomerReturnVisitService customerReturnVisitService;
    /**
     * æŸ¥è¯¢å®¢æˆ·è·Ÿè¿›åˆ—表
     */
    @GetMapping("/list")
    @ApiOperation("查询客户跟进列表")
    public IPage<CustomerFollowUp> list(Page<CustomerFollowUp> page, CustomerFollowUp customerFollowUp) {
        LambdaQueryWrapper<CustomerFollowUp> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(customerFollowUp.getCustomerId() != null, CustomerFollowUp::getCustomerId, customerFollowUp.getCustomerId())
                .like(customerFollowUp.getFollowerUserName() != null, CustomerFollowUp::getFollowerUserName, customerFollowUp.getFollowerUserName())
                .orderByDesc(CustomerFollowUp::getFollowUpTime);
        return customerFollowUpService.page(page, queryWrapper);
    }
    /**
     * èŽ·å–å®¢æˆ·è·Ÿè¿›è¯¦ç»†ä¿¡æ¯
     */
    @ApiOperation("获取客户跟进详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(customerFollowUpService.getFollowUpWithFiles(id));
    }
    /**
     * æ–°å¢žå®¢æˆ·è·Ÿè¿›
     */
    @PostMapping("/add")
    @ApiOperation("新增客户跟进")
    @Log(title = "客户跟进-新增", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody CustomerFollowUp customerFollowUp) {
        return toAjax(customerFollowUpService.insertCustomerFollowUp(customerFollowUp));
    }
    /**
     * ä¿®æ”¹å®¢æˆ·è·Ÿè¿›
     */
    @PutMapping("/edit")
    @ApiOperation("修改客户跟进")
    @Log(title = "客户跟进-修改", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@RequestBody CustomerFollowUp customerFollowUp) {
        return toAjax(customerFollowUpService.updateCustomerFollowUp(customerFollowUp));
    }
    /**
     * ä¸Šä¼ è·Ÿè¿›é™„ä»¶
     */
    @ApiOperation("上传跟进附件")
    @PostMapping("/upload/{followUpId}")
    @Log(title = "客户跟进-上传附件", businessType = BusinessType.INSERT)
    public AjaxResult uploadFiles(@RequestParam("files") List<MultipartFile> files, @PathVariable Integer followUpId) {
        customerFollowUpService.addFollowUpFiles(files, followUpId);
        return AjaxResult.success();
    }
    /**
     * åˆ é™¤è·Ÿè¿›é™„ä»¶
     */
    @ApiOperation("删除跟进附件")
    @DeleteMapping("/file/{fileId}")
    @Log(title = "客户跟进-删除附件", businessType = BusinessType.DELETE)
    public AjaxResult deleteFile(@PathVariable Integer fileId) {
        customerFollowUpService.deleteFollowUpFile(fileId);
        return AjaxResult.success();
    }
    /**
     * åˆ é™¤å®¢æˆ·è·Ÿè¿›
     */
    @ApiOperation("删除客户跟进")
    @DeleteMapping("/{id}")
    @Log(title = "客户跟进-删除", businessType = BusinessType.DELETE)
    public AjaxResult remove(@PathVariable Integer id) {
        return toAjax(customerFollowUpService.deleteCustomerFollowUpById(id));
    }
    /**
     * æ–°å¢ž/更新回访提醒
     */
    @ApiOperation("新增/更新回访提醒")
    @PostMapping("/return-visit")
    @Log(title = "回访提醒-新增/更新", businessType = BusinessType.UPDATE)
    public AjaxResult saveReturnVisit(@RequestBody CustomerReturnVisit customerReturnVisit) {
        return toAjax(customerReturnVisitService.saveOrUpdateReturnVisit(customerReturnVisit));
    }
    /**
     * èŽ·å–å›žè®¿æé†’è¯¦æƒ…
     */
    @ApiOperation("获取回访提醒详情")
    @GetMapping("/return-visit/{customerId}")
    public AjaxResult getReturnVisit(@PathVariable Integer customerId) {
        return AjaxResult.success(customerReturnVisitService.getByCustomerId(customerId));
    }
    /**
     * æ ‡è®°å›žè®¿æé†’已读
     */
    @ApiOperation("标记回访提醒已读")
    @PutMapping("/return-visit/read/{id}")
    @Log(title = "回访提醒-标记已读", businessType = BusinessType.UPDATE)
    public AjaxResult markAsRead(@PathVariable Long id) {
        customerReturnVisitService.markAsRead(id);
        return AjaxResult.success();
    }
}
src/main/java/com/ruoyi/basic/dto/CustomerDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
package com.ruoyi.basic.dto;
import com.ruoyi.basic.pojo.Customer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
 * <br>
 * å®¢æˆ·æ¡£æ¡ˆDTO,包含跟进记录
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/05 09:40
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CustomerDto extends Customer {
    private List<CustomerFollowUpDto> followUpList;
}
src/main/java/com/ruoyi/basic/dto/CustomerFollowUpDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package com.ruoyi.basic.dto;
import com.ruoyi.basic.pojo.CustomerFollowUp;
import com.ruoyi.basic.pojo.CustomerFollowUpFile;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
 * <br>
 * å®¢æˆ·è·Ÿè¿›DTO,包含附件列表
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/05 09:41
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CustomerFollowUpDto extends CustomerFollowUp {
    private List<CustomerFollowUpFile> fileList;
}
src/main/java/com/ruoyi/basic/dto/CustomerReturnVisitDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
package com.ruoyi.basic.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**
 * <br>
 * å®¢æˆ·å›žè®¿æé†’Dto
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/05 10:26
 */
@Data
public class CustomerReturnVisitDto {
    /**
     * å›žè®¿æé†’主键ID
     */
    private Long id;
    /**
     * å…³è”客户ID (对应 customer è¡¨çš„ id)
     */
    private Integer customerId;
    /**
     * æé†’开关状态 (0:关闭, 1:开启)
     */
    private Integer isEnabled;
    /**
     * æé†’的具体内容
     */
    private String content;
    /**
     * è®¾å®šçš„æé†’触发时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime reminderTime;
    /**
     * å¤„理状态 (0:待提醒, 1:已提醒)
     */
    private Integer isCompleted;
    /**
     * æŽ¥æ”¶æé†’的用户ID
     */
    private Long remindUserId;
}
src/main/java/com/ruoyi/basic/mapper/CustomerFollowUpFileMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.ruoyi.basic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.basic.pojo.CustomerFollowUpFile;
/**
 * <br>
 * å®¢æˆ·è·Ÿè¿›é™„ä»¶mapper
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:52
 */
public interface CustomerFollowUpFileMapper extends BaseMapper<CustomerFollowUpFile> {
}
src/main/java/com/ruoyi/basic/mapper/CustomerFollowUpMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.ruoyi.basic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.basic.pojo.CustomerFollowUp;
/**
 * <br>
 * å®¢æˆ·è·Ÿè¿›mapper
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:46
 */
public interface CustomerFollowUpMapper extends BaseMapper<CustomerFollowUp> {
}
src/main/java/com/ruoyi/basic/mapper/CustomerReturnVisitMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.ruoyi.basic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.basic.pojo.CustomerReturnVisit;
/**
 * <br>
 * å®¢æˆ·å›žè®¿æé†’mapper
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 17:57
 */
public interface CustomerReturnVisitMapper extends BaseMapper<CustomerReturnVisit> {
}
src/main/java/com/ruoyi/basic/pojo/Customer.java
@@ -1,6 +1,7 @@
package com.ruoyi.basic.pojo;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.*;
@@ -33,6 +34,21 @@
    private String customerName;
    /** å®¢æˆ·åˆ†ç±»ï¼šé›¶å”®å®¢æˆ·ï¼Œè¿›é”€å•†å®¢æˆ· */
    /**
     * è·Ÿè¿›ç¨‹åº¦
     */
    @Excel(name = "跟进程度")
    @TableField(exist = false)
    private String followUpLevel;
    /**
     * è·Ÿè¿›æ—¶é—´
     */
    @Excel(name = "跟进时间")
    @TableField(exist = false)
    private LocalDateTime followUpTime;
    @Excel(name = "客户分类")
    private String customerType;
src/main/java/com/ruoyi/basic/pojo/CustomerFollowUp.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,85 @@
package com.ruoyi.basic.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <br>
 * å®¢æˆ·è·Ÿè¿›è¿›åº¦è¡¨
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:37
 */
@Data
@TableName(value = "customer_follow_up")
public class CustomerFollowUp implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ä¸»é”®ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     * å…³è”的客户ID
     */
    private Integer customerId;
    /**
     * è·Ÿè¿›æ–¹å¼
     */
    private String followUpMethod;
    /**
     * è·Ÿè¿›ç¨‹åº¦
     */
    private String followUpLevel;
    /**
     * è·Ÿè¿›æ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime followUpTime;
    /**
     * è·Ÿè¿›äººå§“名
     */
    private String followerUserName;
    /**
     * è·Ÿè¿›å†…容
     */
    private String content;
    /**
     * è·Ÿè¿›äººID
     */
    private Long followerUserId;
    /**
     * ç§Ÿæˆ·ID
     */
    private Long tenantId;
    /**
     * åˆ›å»ºæ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * æ›´æ–°æ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
}
src/main/java/com/ruoyi/basic/pojo/CustomerFollowUpFile.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,81 @@
package com.ruoyi.basic.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <br>
 * å®¢æˆ·è·Ÿè¿›é™„件表
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:41
 */
@Data
@TableName(value = "customer_follow_up_file")
public class CustomerFollowUpFile implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ä¸»é”®
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * è·Ÿè¿›è®°å½•ID
     */
    private Integer followUpId;
    /**
     * æ–‡ä»¶åç§°
     */
    private String fileName;
    /**
     * æ–‡ä»¶è®¿é—®åœ°å€
     */
    private String fileUrl;
    /**
     * æ–‡ä»¶å¤§å°ï¼ˆå•位:字节)
     */
    private Long fileSize;
    /**
     * æ–‡ä»¶åŽç¼€
     */
    private String fileSuffix;
    /**
     * ä¸Šä¼ è€…
     */
    private Long createUser;
    /**
     * åˆ›å»ºæ—¶é—´
     */
    private LocalDateTime createTime;
    /**
     * ä¿®æ”¹è€…
     */
    private Long updateUser;
    /**
     * ä¿®æ”¹æ—¶é—´
     */
    private LocalDateTime updateTime;
    /**
     * ç§Ÿæˆ·ID
     */
    private Long tenantId;
}
src/main/java/com/ruoyi/basic/pojo/CustomerReturnVisit.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,92 @@
package com.ruoyi.basic.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <br>
 * å®¢æˆ·å›žè®¿æé†’
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 17:50
 */
@Data
@TableName(value = "customer_return_visit")
public class CustomerReturnVisit implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ä¸»é”®ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * å…³è”客户ID
     */
    private Integer customerId;
    /**
     * æé†’开关 (0:关闭, 1:开启)
     */
    private Integer isEnabled;
    /**
     * æé†’内容
     */
    private String content;
    /**
     * æé†’æ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime reminderTime;
    /**
     * å¤„理状态 (0:待提醒, 1:已提醒)
     */
    private Integer isCompleted;
    /**
     * æŽ¥æ”¶æé†’的用户ID
     */
    private Long remindUserId;
    /**
     * ç§Ÿæˆ·ID
     */
    private Long tenantId;
    /**
     * åˆ›å»ºè€…
     */
    private Long createUser;
    /**
     * åˆ›å»ºæ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;
    /**
     * ä¿®æ”¹è€…
     */
    private Long updateUser;
    /**
     * ä¿®æ”¹æ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;
}
src/main/java/com/ruoyi/basic/service/CustomerFollowUpFileService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.ruoyi.basic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.basic.pojo.CustomerFollowUpFile;
/**
 * <br>
 * å®¢æˆ·è·Ÿè¿›é™„件接口
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:52
 */
public interface CustomerFollowUpFileService extends IService<CustomerFollowUpFile> {
}
src/main/java/com/ruoyi/basic/service/CustomerFollowUpService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,55 @@
package com.ruoyi.basic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.basic.dto.CustomerFollowUpDto;
import com.ruoyi.basic.pojo.CustomerFollowUp;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
 * <br>
 * å®¢æˆ·è·Ÿè¿›æŽ¥å£
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:48
 */
public interface CustomerFollowUpService extends IService<CustomerFollowUp> {
    /**
     * æ–°å¢žå®¢æˆ·è·Ÿè¿›
     */
    boolean insertCustomerFollowUp(CustomerFollowUp customerFollowUp);
    /**
     * ä¿®æ”¹å®¢æˆ·è·Ÿè¿›
     */
    int updateCustomerFollowUp(CustomerFollowUp customerFollowUp);
    /**
     * æ‰¹é‡åˆ é™¤å®¢æˆ·è·Ÿè¿›
     */
    int deleteCustomerFollowUpById(Integer id);
    /**
     * æ ¹æ®å®¢æˆ·ID删除所有跟进记录
     */
    void deleteByCustomerId(Long customerId);
    /**
     * æ·»åŠ è·Ÿè¿›é™„ä»¶
     */
    void addFollowUpFiles(List<MultipartFile> files, Integer followUpId);
    /**
     * åˆ é™¤è·Ÿè¿›é™„ä»¶
     */
    void deleteFollowUpFile(Integer fileId);
    /**
     * èŽ·å–è·Ÿè¿›è¯¦æƒ…
     */
    CustomerFollowUpDto getFollowUpWithFiles(Integer id);
}
src/main/java/com/ruoyi/basic/service/CustomerReturnVisitService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package com.ruoyi.basic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.basic.dto.CustomerReturnVisitDto;
import com.ruoyi.basic.pojo.CustomerReturnVisit;
/**
 * <br>
 * å®¢æˆ·å›žè®¿æé†’接口
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 17:58
 */
public interface CustomerReturnVisitService extends IService<CustomerReturnVisit> {
    int saveOrUpdateReturnVisit(CustomerReturnVisit customerReturnVisit);
    CustomerReturnVisitDto getByCustomerId(Integer customerId);
    void deleteByCustomerId(Long customerId);
    void markAsRead(Long id);
}
src/main/java/com/ruoyi/basic/service/ICustomerService.java
@@ -3,11 +3,13 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.basic.dto.CustomerDto;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.framework.web.domain.AjaxResult;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
/**
 * å®¢æˆ·æ¡£æ¡ˆService接口
@@ -25,12 +27,20 @@
    Customer selectCustomerById(Long id);
    /**
     * æŸ¥è¯¢å®¢æˆ·è¯¦æƒ…(含跟进记录和附件)
     *
     * @param id å®¢æˆ·æ¡£æ¡ˆä¸»é”®
     * @return å®¢æˆ·è¯¦æƒ…DTO
     */
    CustomerDto selectCustomerDetailById(Long id);
    /**
     * æŸ¥è¯¢å®¢æˆ·æ¡£æ¡ˆåˆ—表
     *
     * @param customer å®¢æˆ·æ¡£æ¡ˆ
     * @return å®¢æˆ·æ¡£æ¡ˆé›†åˆ
     */
    IPage<Customer> selectCustomerList(Page page, Customer customer);
    IPage<Customer> selectCustomerList(Page<Customer> page, Customer customer);
    /**
     * æ–°å¢žå®¢æˆ·æ¡£æ¡ˆ
@@ -63,7 +73,7 @@
     *
     * @return ç»“æžœ
     */
    List customerList(Customer customer);
    List<Map<String, Object>> customerList(Customer customer);
    List<Customer> selectCustomerLists(Customer customer);
src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpFileServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.ruoyi.basic.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.mapper.CustomerFollowUpFileMapper;
import com.ruoyi.basic.pojo.CustomerFollowUpFile;
import com.ruoyi.basic.service.CustomerFollowUpFileService;
import org.springframework.stereotype.Service;
/**
 * <br>
 * å®¢æˆ·æ ¹æ®é™„件接口实现类
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:53
 */
@Service
public class CustomerFollowUpFileServiceImpl extends ServiceImpl<CustomerFollowUpFileMapper, CustomerFollowUpFile> implements CustomerFollowUpFileService {
}
src/main/java/com/ruoyi/basic/service/impl/CustomerFollowUpServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,227 @@
package com.ruoyi.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.CustomerFollowUpDto;
import com.ruoyi.basic.mapper.CustomerFollowUpMapper;
import com.ruoyi.basic.pojo.CustomerFollowUp;
import com.ruoyi.basic.pojo.CustomerFollowUpFile;
import com.ruoyi.basic.service.CustomerFollowUpFileService;
import com.ruoyi.basic.service.CustomerFollowUpService;
import com.ruoyi.basic.service.ICustomerService;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
 * <br>
 * å®¢æˆ·æ ¹æ®æŽ¥å£å®žçŽ°ç±»
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 14:48
 */
@Service
public class CustomerFollowUpServiceImpl extends ServiceImpl<CustomerFollowUpMapper, CustomerFollowUp> implements CustomerFollowUpService {
    @Autowired
    private CustomerFollowUpFileService customerFollowUpFileService;
    @Value("${file.upload-dir}")
    private String uploadDir;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean insertCustomerFollowUp(CustomerFollowUp customerFollowUp) {
        validateFollowUp(customerFollowUp);
        Long currentUserId = SecurityUtils.getUserId();
        Long currentTenantId = SecurityUtils.getLoginUser().getTenantId();
        customerFollowUp.setFollowerUserId(currentUserId);
        customerFollowUp.setCreateTime(LocalDateTime.now());
        customerFollowUp.setTenantId(currentTenantId);
        int result = baseMapper.insert(customerFollowUp);
        if (result < 1) {
            throw new ServiceException("客户跟进数据添加失败");
        }
        return true;
    }
    @Override
    public int updateCustomerFollowUp(CustomerFollowUp customerFollowUp) {
        validateFollowUp(customerFollowUp);
        customerFollowUp.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(customerFollowUp);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addFollowUpFiles(List<MultipartFile> files, Integer followUpId) {
        handleFollowUpFiles(files, followUpId);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteFollowUpFile(Integer fileId) {
        CustomerFollowUpFile file = customerFollowUpFileService.getById(fileId);
        if (file != null) {
            try {
                Files.deleteIfExists(Paths.get(file.getFileUrl()));
            } catch (Exception e) {
                throw new ServiceException("删除文件失败:" + e.getMessage());
            }
            customerFollowUpFileService.removeById(fileId);
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteCustomerFollowUpById(Integer id) {
        if (id == null) {
            throw new ServiceException("跟进ID不能为空");
        }
        List<CustomerFollowUpFile> files = customerFollowUpFileService.list(new LambdaQueryWrapper<CustomerFollowUpFile>()
                .eq(CustomerFollowUpFile::getFollowUpId, id));
        if (files != null && !files.isEmpty()) {
            for (CustomerFollowUpFile file : files) {
                deleteFollowUpFile(file.getId().intValue());
            }
        }
        int result = baseMapper.deleteById(id);
        if (result < 1) {
            throw new ServiceException("客户跟进记录删除失败");
        }
        return result;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteByCustomerId(Long customerId) {
        if (customerId == null) {
            throw new ServiceException("客户ID不能为空");
        }
        List<CustomerFollowUp> followUps = list(new LambdaQueryWrapper<CustomerFollowUp>()
                .eq(CustomerFollowUp::getCustomerId, customerId));
        if (followUps != null && !followUps.isEmpty()) {
            for (CustomerFollowUp followUp : followUps) {
                deleteCustomerFollowUpById(followUp.getId());
            }
        }
    }
    private void handleFollowUpFiles(List<MultipartFile> multipartFiles, Integer followUpId) {
        if (multipartFiles == null || multipartFiles.isEmpty()) {
            return;
        }
        Long currentUserId = SecurityUtils.getUserId();
        Long currentTenantId = SecurityUtils.getLoginUser().getTenantId();
        List<CustomerFollowUpFile> fileList = new ArrayList<>();
        for (MultipartFile file : multipartFiles) {
            if (file == null || file.isEmpty()) {
                continue;
            }
            try {
                String formalDir = uploadDir + "/" + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
                Path formalDirPath = Paths.get(formalDir);
                if (!Files.exists(formalDirPath)) {
                    Files.createDirectories(formalDirPath);
                }
                String originalFilename = file.getOriginalFilename();
                String fileExtension = FilenameUtils.getExtension(originalFilename);
                String formalFilename = followUpId + "_" +
                        System.currentTimeMillis() + "_" +
                        UUID.randomUUID().toString().substring(0, 8) +
                        (StringUtils.hasText(fileExtension) ? "." + fileExtension : "");
                Path formalFilePath = formalDirPath.resolve(formalFilename);
                file.transferTo(formalFilePath.toFile());
                CustomerFollowUpFile followUpFile = new CustomerFollowUpFile();
                followUpFile.setFollowUpId(followUpId);
                followUpFile.setFileName(originalFilename);
                followUpFile.setFileUrl(formalFilePath.toString());
                followUpFile.setFileSize(file.getSize());
                followUpFile.setFileSuffix(fileExtension);
                followUpFile.setCreateUser(currentUserId);
                followUpFile.setCreateTime(LocalDateTime.now());
                followUpFile.setTenantId(currentTenantId);
                fileList.add(followUpFile);
            } catch (Exception e) {
                throw new ServiceException("文件 [" + file.getOriginalFilename() + "] ä¸Šä¼ å¤±è´¥ï¼š" + e.getMessage());
            }
        }
        if (!fileList.isEmpty()) {
            customerFollowUpFileService.saveBatch(fileList);
        }
    }
    private void validateFollowUp(CustomerFollowUp followUp) {
        if (followUp == null) {
            throw new ServiceException("跟进数据不能为空");
        }
        if (StringUtils.isEmpty(followUp.getFollowUpMethod())) {
            throw new ServiceException("跟进方式不能为空");
        }
        if (StringUtils.isEmpty(followUp.getFollowUpLevel())) {
            throw new ServiceException("跟进程度不能为空");
        }
        if (followUp.getFollowUpTime() == null) {
            throw new ServiceException("跟进时间不能为空");
        }
        if (StringUtils.isEmpty(followUp.getFollowerUserName())) {
            throw new ServiceException("跟进人不能为空");
        }
        if (StringUtils.isEmpty(followUp.getContent())) {
            throw new ServiceException("跟进内容不能为空");
        }
    }
    @Override
    public CustomerFollowUpDto getFollowUpWithFiles(Integer id) {
        CustomerFollowUp followUp = baseMapper.selectById(id);
        if (followUp == null) {
            return null;
        }
        CustomerFollowUpDto dto = new CustomerFollowUpDto();
        BeanUtils.copyProperties(followUp, dto);
        List<CustomerFollowUpFile> fileList = customerFollowUpFileService.list(new LambdaQueryWrapper<CustomerFollowUpFile>()
                .eq(CustomerFollowUpFile::getFollowUpId, id));
        dto.setFileList(fileList);
        return dto;
    }
}
src/main/java/com/ruoyi/basic/service/impl/CustomerReturnVisitServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,139 @@
package com.ruoyi.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.CustomerReturnVisitDto;
import com.ruoyi.basic.mapper.CustomerReturnVisitMapper;
import com.ruoyi.basic.pojo.CustomerReturnVisit;
import com.ruoyi.basic.service.CustomerReturnVisitService;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
/**
 * <br>
 * å®¢æˆ·å›žè®¿æé†’接口实现类
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/04 17:58
 */
@Service
public class CustomerReturnVisitServiceImpl extends ServiceImpl<CustomerReturnVisitMapper, CustomerReturnVisit> implements CustomerReturnVisitService {
    @Autowired
    private ReturnVisitReminderService returnVisitReminderService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int saveOrUpdateReturnVisit(CustomerReturnVisit customerReturnVisit) {
        validateReturnVisit(customerReturnVisit);
        Long currentUserId = SecurityUtils.getUserId();
        Long currentTenantId = SecurityUtils.getLoginUser().getTenantId();
        if (customerReturnVisit.getId() != null) {
            CustomerReturnVisit existing = baseMapper.selectById(customerReturnVisit.getId());
            if (existing == null) {
                throw new ServiceException("回访提醒不存在");
            }
            if (!existing.getTenantId().equals(currentTenantId)) {
                throw new ServiceException("无权限修改此回访提醒");
            }
            customerReturnVisit.setUpdateUser(currentUserId);
            customerReturnVisit.setUpdateTime(LocalDateTime.now());
            int result = baseMapper.updateById(customerReturnVisit);
            //  æ ¹æ®æé†’开关来判断队列信息新增或取消
            if (customerReturnVisit.getIsEnabled() == 1) {
                returnVisitReminderService.scheduleReminder(customerReturnVisit.getId());
            } else {
                returnVisitReminderService.cancelReminder(customerReturnVisit.getId());
            }
            return result;
        } else {
            customerReturnVisit.setCreateUser(currentUserId);
            customerReturnVisit.setCreateTime(LocalDateTime.now());
            customerReturnVisit.setTenantId(currentTenantId);
            int result = baseMapper.insert(customerReturnVisit);
            if (customerReturnVisit.getIsEnabled() == 1) {
                returnVisitReminderService.scheduleReminder(customerReturnVisit.getId());
            }
            return result;
        }
    }
    @Override
    public CustomerReturnVisitDto getByCustomerId(Integer customerId) {
        if (customerId == null) {
            throw new ServiceException("客户ID不能为空");
        }
        LambdaQueryWrapper<CustomerReturnVisit> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CustomerReturnVisit::getCustomerId, customerId);
        CustomerReturnVisit returnVisit = baseMapper.selectOne(queryWrapper);
        if (returnVisit == null) {
            return null;
        }
        CustomerReturnVisitDto dto = new CustomerReturnVisitDto();
        BeanUtils.copyProperties(returnVisit, dto);
        return dto;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteByCustomerId(Long customerId) {
        if (customerId == null) {
            throw new ServiceException("客户ID不能为空");
        }
        LambdaQueryWrapper<CustomerReturnVisit> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CustomerReturnVisit::getCustomerId, customerId);
        List<CustomerReturnVisit> returnVisits = baseMapper.selectList(queryWrapper);
        for (CustomerReturnVisit returnVisit : returnVisits) {
            returnVisitReminderService.cancelReminder(returnVisit.getId());
        }
        baseMapper.delete(queryWrapper);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void markAsRead(Long id) {
        if (id == null) {
            throw new ServiceException("回访提醒ID不能为空");
        }
        CustomerReturnVisit returnVisit = baseMapper.selectById(id);
        if (returnVisit == null) {
            throw new ServiceException("回访提醒不存在");
        }
        CustomerReturnVisit updateObj = new CustomerReturnVisit();
        updateObj.setId(id);
        updateObj.setIsCompleted(1);
        baseMapper.updateById(updateObj);
    }
    private void validateReturnVisit(CustomerReturnVisit returnVisit) {
        if (returnVisit == null) {
            throw new ServiceException("回访提醒数据不能为空");
        }
        if (returnVisit.getCustomerId() == null) {
            throw new ServiceException("客户ID不能为空");
        }
        if (returnVisit.getReminderTime() == null) {
            throw new ServiceException("提醒时间不能为空");
        }
        if (returnVisit.getIsEnabled() != null && returnVisit.getIsEnabled() == 1) {
            if (returnVisit.getReminderTime().isBefore(LocalDateTime.now())) {
                throw new ServiceException("提醒时间不能早于当前时间");
            }
        }
    }
}
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -7,8 +7,15 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.CustomerDto;
import com.ruoyi.basic.dto.CustomerFollowUpDto;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.basic.pojo.CustomerFollowUp;
import com.ruoyi.basic.pojo.CustomerFollowUpFile;
import com.ruoyi.basic.service.CustomerFollowUpFileService;
import com.ruoyi.basic.service.CustomerFollowUpService;
import com.ruoyi.basic.service.CustomerReturnVisitService;
import com.ruoyi.basic.service.ICustomerService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
@@ -20,7 +27,9 @@
import com.ruoyi.sales.pojo.SalesLedger;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -44,6 +53,12 @@
    private final SalesLedgerMapper salesLedgerMapper;
    private CustomerMapper customerMapper;
    private CustomerFollowUpService customerFollowUpService;
    private CustomerFollowUpFileService customerFollowUpFileService;
    private CustomerReturnVisitService customerReturnVisitService;
    /**
     * æŸ¥è¯¢å®¢æˆ·æ¡£æ¡ˆ
     *
@@ -56,13 +71,57 @@
    }
    /**
     * æŸ¥è¯¢å®¢æˆ·è¯¦æƒ…(含跟进记录和附件)
     *
     * @param id å®¢æˆ·æ¡£æ¡ˆä¸»é”®
     * @return å®¢æˆ·è¯¦æƒ…DTO
     */
    @Override
    public CustomerDto selectCustomerDetailById(Long id) {
        Customer customer = customerMapper.selectById(id);
        if (customer == null) {
            return null;
        }
        CustomerDto dto = new CustomerDto();
        BeanUtils.copyProperties(customer, dto);
        // æŸ¥è¯¢è·Ÿè¿›è®°å½•
        List<CustomerFollowUp> followUpList = customerFollowUpService.list(
                new LambdaQueryWrapper<CustomerFollowUp>()
                        .eq(CustomerFollowUp::getCustomerId, id)
                        .orderByDesc(CustomerFollowUp::getFollowUpTime)
        );
        if (!CollectionUtils.isEmpty(followUpList)) {
            List<CustomerFollowUpDto> followUpDtoList = followUpList.stream().map(followUp -> {
                CustomerFollowUpDto followUpDto = new CustomerFollowUpDto();
                BeanUtils.copyProperties(followUp, followUpDto);
                // æŸ¥è¯¢é™„ä»¶
                List<CustomerFollowUpFile> fileList = customerFollowUpFileService.list(
                        new LambdaQueryWrapper<CustomerFollowUpFile>()
                                .eq(CustomerFollowUpFile::getFollowUpId, followUp.getId())
                );
                followUpDto.setFileList(fileList);
                return followUpDto;
            }).collect(Collectors.toList());
            dto.setFollowUpList(followUpDtoList);
        }
        return dto;
    }
    /**
     * æŸ¥è¯¢å®¢æˆ·æ¡£æ¡ˆåˆ—表
     *
     * @param customer å®¢æˆ·æ¡£æ¡ˆ
     * @return å®¢æˆ·æ¡£æ¡ˆ
     */
    @Override
    public IPage<Customer> selectCustomerList(Page page, Customer customer) {
    public IPage<Customer> selectCustomerList(Page<Customer> page, Customer customer) {
        // 1. å¤„理空值场景(参数校验)
        if (page == null) {
            page = Page.of(1, 10); // é»˜è®¤ç¬¬1页,每页10条数据
@@ -92,12 +151,26 @@
                    // å®‰å…¨èŽ·å–å­—æ®µï¼Œé¿å…null值拼接
                    String address = StringUtils.defaultString(c.getCompanyAddress(), "");
                    String phone = StringUtils.defaultString(c.getCompanyPhone(), "");
                    c.setAddressPhone(address + "(" + phone + ")"); // ä¼˜åŒ–字符串拼接
                    c.setAddressPhone(address + "(" + phone + ")");
                    // æŸ¥è¯¢æœ€æ–°çš„跟进记录
                    CustomerFollowUp followUp = customerFollowUpService.getOne(
                            new LambdaQueryWrapper<CustomerFollowUp>()
                                    .eq(CustomerFollowUp::getCustomerId, c.getId())
                                    .orderByDesc(CustomerFollowUp::getFollowUpTime)
                                    .last("LIMIT 1")
                    );
                    if (followUp != null) {
                        c.setFollowUpLevel(followUp.getFollowUpLevel());
                        c.setFollowUpTime(followUp.getFollowUpTime());
                    }
                })
                .collect(Collectors.toList());
        // 5. æ›´æ–°åˆ†é¡µç»“果中的数据(保持分页信息完整)
        customerPage.setRecords(processedList);
        IPage<Customer> resultPage = new Page<>(customerPage.getCurrent(), customerPage.getSize(), customerPage.getTotal());
        resultPage.setRecords(processedList);
        return customerPage; // è¿”回包含分页信息的IPage对象
    }
@@ -137,12 +210,19 @@
     * @return ç»“æžœ
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteCustomerByIds(Long[] ids) {
        List<Long> idList = Arrays.asList(ids);
        List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(new QueryWrapper<SalesLedger>().lambda().in(SalesLedger::getCustomerId, idList));
        if (!salesLedgers.isEmpty()) {
            throw new RuntimeException("客户档案下有销售合同,请先删除销售合同");
        }
        //  åˆ é™¤å®¢æˆ·çš„同时也需要删除对应的客户跟随、附件和回访提醒
        for (Long id : ids) {
            customerFollowUpService.deleteByCustomerId(id);
            customerReturnVisitService.deleteByCustomerId(id);
        }
        return customerMapper.deleteBatchIds(idList);
    }
src/main/java/com/ruoyi/basic/service/impl/ReturnVisitReminderService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
package com.ruoyi.basic.service.impl;
import com.ruoyi.basic.pojo.CustomerReturnVisit;
import com.ruoyi.basic.service.CustomerReturnVisitService;
import com.ruoyi.framework.redis.RedisCache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.ZoneId;
/**
 * <br>
 * å®¢æˆ·å›žè®¿æé†’服务
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/05 10:45
 */
@Slf4j
@Service
public class ReturnVisitReminderService {
    private static final String REMINDER_QUEUE_KEY = "return_visit:reminder:queue";
    @Autowired
    private RedisCache redisCache;
    @Autowired
    private CustomerReturnVisitService customerReturnVisitService;
    @SuppressWarnings("unchecked")
    public void scheduleReminder(Long returnVisitId) {
        CustomerReturnVisit returnVisit = customerReturnVisitService.getById(returnVisitId);
        if (returnVisit == null || returnVisit.getIsEnabled() == 0) {
            return;
        }
        long timestamp = returnVisit.getReminderTime()
                .atZone(ZoneId.systemDefault())
                .toInstant()
                .toEpochMilli();
        redisCache.redisTemplate.opsForZSet().add(REMINDER_QUEUE_KEY, returnVisitId, timestamp);
        log.info("已添加回访提醒到队列: ID={}, æé†’æ—¶é—´={}", returnVisitId, returnVisit.getReminderTime());
    }
    @SuppressWarnings("unchecked")
    public void cancelReminder(Long returnVisitId) {
        redisCache.redisTemplate.opsForZSet().remove(REMINDER_QUEUE_KEY, returnVisitId);
        log.info("已取消回访提醒: ID={}", returnVisitId);
    }
}
src/main/java/com/ruoyi/basic/task/ReturnVisitReminderTask.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,92 @@
package com.ruoyi.basic.task;
import com.ruoyi.basic.pojo.CustomerReturnVisit;
import com.ruoyi.basic.service.CustomerReturnVisitService;
import com.ruoyi.framework.redis.RedisCache;
import com.ruoyi.project.system.domain.SysUserClient;
import com.ruoyi.project.system.service.SysUserClientService;
import com.ruoyi.project.system.service.impl.UnipushService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Set;
/**
 * <br>
 * å®¢æˆ·å›žè®¿æé†’定时任务
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/05 9:04
 */
@Slf4j
@Component
public class ReturnVisitReminderTask {
    private static final String REMINDER_QUEUE_KEY = "return_visit:reminder:queue";
    @Autowired
    private RedisCache redisCache;
    @Autowired
    private CustomerReturnVisitService customerReturnVisitService;
    @Autowired
    private UnipushService unipushService;
    @Autowired
    private SysUserClientService userClientService;
    @SuppressWarnings("unchecked")
    @Scheduled(fixedDelay = 60000)
    public void processReminders() {
        long now = System.currentTimeMillis();
        Set<Object> dueReminders = redisCache.redisTemplate.opsForZSet().rangeByScore(REMINDER_QUEUE_KEY, 0, now);
        if (dueReminders == null || dueReminders.isEmpty()) {
            return;
        }
        for (Object obj : dueReminders) {
            Long returnVisitId = Long.valueOf(obj.toString());
            try {
                Long removeCount = redisCache.redisTemplate.opsForZSet().remove(REMINDER_QUEUE_KEY, obj);
                if (removeCount != null && removeCount > 0) {
                    processReminder(returnVisitId);
                }
            } catch (Exception e) {
                log.error("处理回访提醒失败: ID={}", returnVisitId, e);
            }
        }
    }
    @SuppressWarnings("unchecked")
    private void processReminder(Long returnVisitId) {
        CustomerReturnVisit returnVisit = customerReturnVisitService.getById(returnVisitId);
        if (returnVisit == null || returnVisit.getIsEnabled() == 0 || returnVisit.getIsCompleted() == 1) {
            return;
        }
        SysUserClient client = userClientService.getById(returnVisit.getRemindUserId());
        if (client == null || client.getCid() == null) {
            log.warn("用户未绑定CID, æ— æ³•发送Unipush推送: userId={}", returnVisit.getRemindUserId());
            return;
        }
        try {
            unipushService.sendReturnVisitReminder(returnVisitId, client.getCid(), returnVisit.getContent(), returnVisit.getCustomerId());
            CustomerReturnVisit updateObj = new CustomerReturnVisit();
            updateObj.setId(returnVisitId);
            updateObj.setIsCompleted(1);
            customerReturnVisitService.updateById(updateObj);
            log.info("回访提醒已通过 Unipush å‘送: ID={}", returnVisitId);
        } catch (Exception e) {
            log.error("发送回访提醒失败,重新加入队列: ID={}", returnVisitId, e);
            long retryTime = System.currentTimeMillis() + 60000;
            redisCache.redisTemplate.opsForZSet().add(REMINDER_QUEUE_KEY, returnVisitId, retryTime);
        }
    }
}
src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java
@@ -80,16 +80,19 @@
                log.warn("用户 {} æœªç»‘定移动端 CID,跳过推送", sysNotice.getConsigneeId());
                continue;
            }
            // è½¬æ¢è·¯å¾„
            String appPath = convertWebPathToAppPath(sysNotice.getJumpPath());
            String content = sysNotice.getNoticeContent();
            if (StringUtils.isNotEmpty(sysNotice.getRemark())) {
                content = content + " " + sysNotice.getRemark();
            }
            // æŽ¨é€
            sendRoutingPush(
                    sysNotice.getNoticeId(),
                    client.getCid(),
                    sysNotice.getNoticeTitle(),
                    sysNotice.getRemark() != null ? sysNotice.getRemark() : sysNotice.getNoticeContent(),
                    content,
                    appPath
            );
        }
@@ -118,31 +121,41 @@
        } else {
            lastSegment = pathOnly;
        }
        if (StringUtils.isEmpty(lastSegment)) {
            return DEFAULT_APP_PAGE;
        }
        SysMenu menu = sysMenuMapper.selectMenuByPath(lastSegment);
        if (menu != null && StringUtils.isNotEmpty(menu.getAppComponent())) {
            String appPath = menu.getAppComponent();
            if (appPath.startsWith("/")) {
                appPath = appPath.substring(1);
            }
            //  æ‹¼æŽ¥ Web ç«¯åŽŸå§‹å‚æ•°å¹¶è¿”å›ž
            return appPath + queryString;
        }
        return DEFAULT_APP_PAGE;
    }
    /**
     * å‘送回访提醒
     */
    public void sendReturnVisitReminder(Long returnVisitId, String cid, String content, Integer customerId) {
        String targetPath = "pages/cooperativeOffice/customerManage/detail?customerId=" + customerId;
        sendRoutingPush(returnVisitId, cid, "客户回访提醒", content, targetPath, false);
    }
    /**
     * å‘送单人路由推送
     */
    private void sendRoutingPush(Long noticeId, String cid, String title, String content, String targetPath) {
        sendRoutingPush(noticeId, cid, title, content, targetPath, true);
    }
    /**
     * å‘送单人路由推送
     */
    private void sendRoutingPush(Long noticeId, String cid, String title, String content, String targetPath, boolean needMarkRead) {
        log.info("准备推送消息:NoticeId={}, CID={}, Title={}, TargetPath={}", noticeId, cid, title, targetPath);
        PushDTO<Audience> pushDTO = new PushDTO<>();
@@ -156,6 +169,7 @@
        pushMessageMap.put("content", content);
        payloadMap.put("url", targetPath);
        payloadMap.put("noticeId", noticeId);
        payloadMap.put("needMarkRead", needMarkRead);
        pushMessageMap.put("payload", JSON.toJSONString(payloadMap));
        String transmissionContent = JSON.toJSONString(pushMessageMap);