liyong
2 天以前 d611ae157097e36ab80106c24f4d5966c6ff8109
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
package com.ruoyi.aftersalesservice.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.aftersalesservice.dto.AfterSalesServiceExeclDto;
import com.ruoyi.aftersalesservice.dto.AfterSalesServiceNewDto;
import com.ruoyi.aftersalesservice.pojo.AfterSalesService;
import com.ruoyi.aftersalesservice.service.AfterSalesServiceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
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 com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.sales.dto.SalesLedgerDto;
import com.ruoyi.sales.service.ISalesLedgerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @author :yys
 * @date : 2025/7/30 9:27
 */
@RestController
@Api(tags = "售后服务")
@RequestMapping("/afterSalesService")
public class AfterSalesServiceController extends BaseController {
 
 
    @Autowired
    private AfterSalesServiceService afterSalesServiceService;
 
    @Autowired
    private SysUserMapper sysUserMapper;
 
    @Autowired
    private ISalesLedgerService salesLedgerService;
 
    @GetMapping("/listPage")
    @ApiOperation("售后服务-分页查询")
    @Log(title = "售后服务-分页查询", businessType = BusinessType.OTHER)
    public AjaxResult listPage(Page page, AfterSalesServiceNewDto afterSalesService) {
        IPage<AfterSalesServiceNewDto> listPage = afterSalesServiceService.listPage(page, afterSalesService);
        return AjaxResult.success(listPage);
    }
 
    @Log(title = "售后服务-反馈登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("售后服务-反馈登记")
    public void export(HttpServletResponse response) {
        Page page = new Page(-1,-1);
        AfterSalesServiceNewDto afterSalesService = new AfterSalesServiceNewDto();
        IPage<AfterSalesServiceNewDto> listPage = afterSalesServiceService.listPage(page, afterSalesService);
        List<AfterSalesServiceExeclDto> list = new ArrayList<>();
        listPage.getRecords().forEach(item -> {
            AfterSalesServiceExeclDto dto = new AfterSalesServiceExeclDto();
            BeanUtils.copyProperties(item, dto);
            dto.setStatusName(item.getStatus().toString());
            list.add(dto);
        });
        ExcelUtil<AfterSalesServiceExeclDto> util = new ExcelUtil<AfterSalesServiceExeclDto>(AfterSalesServiceExeclDto.class);
        util.exportExcel(response, list , "反馈登记");
    }
 
    @Log(title = "售后服务-售后处理", businessType = BusinessType.EXPORT)
    @PostMapping("/exportTwo")
    @ApiOperation("售后服务-售后处理")
    public void exportTwo(HttpServletResponse response) {
        Page page = new Page(-1,-1);
        AfterSalesServiceNewDto afterSalesService = new AfterSalesServiceNewDto();
        IPage<AfterSalesServiceNewDto> listPage = afterSalesServiceService.listPage(page, afterSalesService);
        listPage.getRecords().forEach(item -> {
            item.setStatusName(item.getStatus().toString());
        });
        ExcelUtil<AfterSalesServiceNewDto> util = new ExcelUtil<AfterSalesServiceNewDto>(AfterSalesServiceNewDto.class);
        util.exportExcel(response, listPage.getRecords() , "售后处理");
    }
 
    @PostMapping("/add")
    @ApiOperation("售后服务-新增")
    @Log(title = "售后服务-新增", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody AfterSalesServiceNewDto afterSalesServiceNewDto) {
        return afterSalesServiceService.addAfterSalesServiceDto(afterSalesServiceNewDto) ? AjaxResult.success() : AjaxResult.error();
    }
 
    @PostMapping("/update")
    @ApiOperation("售后服务-修改")
    @Log(title = "售后服务-修改", businessType = BusinessType.UPDATE)
    public AjaxResult update(@RequestBody AfterSalesServiceNewDto afterSalesServiceNewDto) {
        if (afterSalesServiceNewDto.getProductModelIdList() != null && afterSalesServiceNewDto.getProductModelIdList().isEmpty() ) {
            String productModelIds = afterSalesServiceNewDto.getProductModelIdList().stream()
                    .map(String::valueOf)
                    .collect(Collectors.joining(","));
            afterSalesServiceNewDto.setProductModelIds(productModelIds);
        }
        boolean update = afterSalesServiceService.updateById(afterSalesServiceNewDto);
        return update ? AjaxResult.success() : AjaxResult.error();
    }
 
    @DeleteMapping("/delete")
    @ApiOperation("售后服务-删除")
    @Log(title = "售后服务-删除", businessType = BusinessType.DELETE)
    public AjaxResult delete(@RequestBody List<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return AjaxResult.error("请传入要删除的ID");
        }
        boolean delete = afterSalesServiceService.removeByIds(ids);
        return delete ? AjaxResult.success() : AjaxResult.error();
    }
 
    @PostMapping("/dispose")
    @ApiOperation("售后服务-处理")
    @Log(title = "售后服务-处理", businessType = BusinessType.UPDATE)
    public AjaxResult dispose(@RequestBody AfterSalesService afterSalesService) {
        AfterSalesService byId = afterSalesServiceService.getById(afterSalesService.getId());
        if(byId == null) throw new RuntimeException("未找到该数据");
        if(byId.getStatus().equals(2)) throw new RuntimeException("该数据已处理");
        SysUser sysUser = sysUserMapper.selectUserById(afterSalesService.getDisposeUserId());
        if(sysUser == null) throw new RuntimeException("处理人不存在");
        afterSalesService.setDisposeNickName(sysUser.getNickName());
        afterSalesService.setStatus(2);
        boolean update = afterSalesServiceService.updateById(afterSalesService);
        return update ? AjaxResult.success() : AjaxResult.error();
    }
 
 
    @GetMapping("listSalesLedger")
    @ApiOperation("售后服务-获取销售台账")
    public AjaxResult listSalesLedger(SalesLedgerDto salesLedgerDto, Page page) {
        IPage<SalesLedgerDto> list = salesLedgerService.listSalesLedger(salesLedgerDto,page);
        return AjaxResult.success(list);
    }
 
 
    @GetMapping("getById")
    @ApiOperation("售后服务-根据id获取详情")
    public AjaxResult getById(Long id) {
        return AjaxResult.success(afterSalesServiceService.getAfterSalesServiceNewDtoById(id));
    }
 
    @ApiOperation("售后服务-统计工单情况")
    @GetMapping("count")
    public AjaxResult count() {
        return AjaxResult.success(afterSalesServiceService.countAfterSalesService());
    }
 
}