liyong
6 天以前 9a30a3a8d3862a9b2ce898535b7cb51c3ddac816
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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.dto.CustomerFollowUpFileDto;
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.R;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
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")
@AllArgsConstructor
public class CustomerFollowUpController extends BaseController {
 
    private final CustomerFollowUpService customerFollowUpService;
 
    private final CustomerReturnVisitService customerReturnVisitService;
 
    /**
     * 查询客户跟进列表
     */
    @GetMapping("/list")
    @Operation(summary = "查询客户跟进列表")
    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);
    }
 
    /**
     * 获取客户跟进详细信息
     */
    @Operation(summary = "获取客户跟进详细信息")
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Integer id) {
        return R.ok(customerFollowUpService.getFollowUpWithFiles(id));
    }
 
    /**
     * 新增客户跟进
     */
    @PostMapping("/add")
    @Operation(summary = "新增客户跟进")
    @Log(title = "客户跟进-新增", businessType = BusinessType.INSERT)
    public R<?> add(@RequestBody CustomerFollowUp customerFollowUp) {
        return R.ok();
    }
 
    /**
     * 修改客户跟进
     */
    @PutMapping("/edit")
    @Operation(summary = "修改客户跟进")
    @Log(title = "客户跟进-修改", businessType = BusinessType.UPDATE)
    public R<?> edit(@RequestBody CustomerFollowUp customerFollowUp) {
        return R.ok();
    }
 
    /**
     * 上传跟进附件
     */
    @Operation(summary = "上传跟进附件")
    @PostMapping("/upload/{followUpId}")
    @Log(title = "客户跟进-上传附件", businessType = BusinessType.INSERT)
    public R uploadFiles(@RequestParam("files") List<MultipartFile> files, @PathVariable Integer followUpId) {
        return R.ok(customerFollowUpService.addFollowUpFiles(files, followUpId));
    }
 
    /**
     * 上传跟进附件(复用,无ID)
     */
    @Operation(summary = "上传附件(复用)")
    @PostMapping("/upload")
    @Log(title = "上传附件(复用)", businessType = BusinessType.INSERT)
    public R uploadFiles(@RequestParam("files") List<MultipartFile> files, @RequestParam(required = false) String name) {
        List<CustomerFollowUpFileDto> uploadedFiles = customerFollowUpService.addFollowUpFiles(files, null);
        return R.ok(uploadedFiles);
    }
 
    /**
     * 批量查询附件列表
     */
    @Operation(summary = "批量查询附件列表")
    @PostMapping("/file/list")
    public R getFileList(@RequestBody List<Long> ids) {
        return R.ok(customerFollowUpService.getFollowUpFilesByIds(ids));
    }
 
    /**
     * 删除跟进附件
     */
    @Operation(summary = "删除跟进附件")
    @DeleteMapping("/file/{fileId}")
    @Log(title = "客户跟进-删除附件", businessType = BusinessType.DELETE)
    public R deleteFile(@PathVariable Integer fileId) {
        customerFollowUpService.deleteFollowUpFile(fileId);
        return R.ok();
    }
 
    /**
     * 删除客户跟进
     */
    @Operation(summary = "删除客户跟进")
    @DeleteMapping("/{id}")
    @Log(title = "客户跟进-删除", businessType = BusinessType.DELETE)
    public R remove(@PathVariable Integer id) {
        return R.ok(customerFollowUpService.deleteCustomerFollowUpById(id));
    }
 
    /**
     * 新增/更新回访提醒
     */
    @Operation(summary = "新增/更新回访提醒")
    @PostMapping("/return-visit")
    @Log(title = "回访提醒-新增/更新", businessType = BusinessType.UPDATE)
    public R saveReturnVisit(@RequestBody CustomerReturnVisit customerReturnVisit) {
        return  R.ok(customerReturnVisitService.saveOrUpdateReturnVisit(customerReturnVisit));
    }
 
    /**
     * 获取回访提醒详情
     */
    @Operation(summary = "获取回访提醒详情")
    @GetMapping("/return-visit/{customerId}")
    public R getReturnVisit(@PathVariable Integer customerId) {
        return R.ok(customerReturnVisitService.getByCustomerId(customerId));
    }
 
    /**
     * 标记回访提醒已读
     */
    @Operation(summary = "标记回访提醒已读")
    @PutMapping("/return-visit/read/{id}")
    @Log(title = "回访提醒-标记已读", businessType = BusinessType.UPDATE)
    public R markAsRead(@PathVariable Long id) {
        customerReturnVisitService.markAsRead(id);
        return R.ok();
    }
 
}