puzhibing
2024-08-29 657d9812259a5c100b2afb71a9eae1769d9432cb
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
package com.ruoyi.order.controller;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.order.api.model.TOrderAppeal;
import com.ruoyi.order.api.query.TOrderAppealQuery;
import com.ruoyi.order.api.vo.TOrderAppealVO;
import com.ruoyi.order.dto.ManageFeedbackDto;
import com.ruoyi.order.dto.ManageOrderAppealQuery;
import com.ruoyi.order.service.TOrderAppealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2024-08-07
 */
@RestController
@RequestMapping("/t-order-appeal")
public class TOrderAppealController {
 
    private final TOrderAppealService orderAppealService;
    private final TokenService tokenService;
    @Resource
    private AppUserClient appUserClient;
 
    @Autowired
    public TOrderAppealController(TOrderAppealService orderAppealService, TokenService tokenService) {
        this.orderAppealService = orderAppealService;
        this.tokenService = tokenService;
    }
    @ApiOperation(tags = {"后台-订单管理-订单申诉"},value = "列表")
    @PostMapping(value = "/manage/pageList")
    public R<Page<TOrderAppeal>> managePageList(@RequestBody ManageOrderAppealQuery manageOrderAppealQuery) {
 
        Page<TOrderAppeal> page = orderAppealService.lambdaQuery().eq(manageOrderAppealQuery.getStatus() != null, TOrderAppeal::getStatus, manageOrderAppealQuery.getStatus())
                .like(manageOrderAppealQuery.getCode() != null, TOrderAppeal::getCode, manageOrderAppealQuery.getCode())
                .like(manageOrderAppealQuery.getPhone() != null, TOrderAppeal::getPhone, manageOrderAppealQuery.getPhone())
                .eq(manageOrderAppealQuery.getOrderType() != null, TOrderAppeal::getOrderType, manageOrderAppealQuery.getOrderType())
                .in(TOrderAppeal::getOrderType, 1, 2).page(Page.of(manageOrderAppealQuery.getPageCurr(), manageOrderAppealQuery.getPageSize()));
        return R.ok(page);
 
 
    }
 
    @ApiOperation(tags = {"后台-订单管理-订单申诉"},value = "后台-订单管理-订单申诉")
    @PostMapping(value = "/manage/feedback")
    public R manageFeedback(@RequestBody ManageFeedbackDto manageFeedbackDto) {
        TOrderAppeal byId = orderAppealService.getById(manageFeedbackDto.getId());
        byId.setFeedback(manageFeedbackDto.getFeedback());
        orderAppealService.updateById(byId);
        return R.ok();
    }
 
    /**
     * 查询订单申诉列表
     */
    @ApiOperation(tags = {"小程序-订单申诉"},value = "查询订单申诉分页列表")
    @PostMapping(value = "/pageList")
    public AjaxResult<PageInfo<TOrderAppealVO>> pageList(@RequestBody TOrderAppealQuery query) {
        Long userId = tokenService.getLoginUserApplet().getUserId();
        query.setAppUserId(userId);
        return AjaxResult.ok(orderAppealService.pageList(query));
    }
 
    /**
     * 查询订单申诉详情
     */
    @GetMapping(value = "/getDetailById")
    @ApiOperation(tags = {"小程序-订单申诉"},value = "查询订单申诉详情")
    public AjaxResult<TOrderAppealVO> getDetailById(Integer id) {
        return AjaxResult.ok(orderAppealService.getDetailById(id));
    }
    
    
    
    @ResponseBody
    @PostMapping(value = "/addOrderAppeal")
    @ApiOperation(value = "申诉订单", tags = {"小程序-充电记录(个人中心)"})
    public AjaxResult addOrderAppeal(@RequestBody TOrderAppeal orderAppeal){
        Long appUserId = tokenService.getLoginUserApplet().getUserId();
        TAppUser data = appUserClient.getUserById(appUserId).getData();
        orderAppeal.setAppUserId(appUserId);
        orderAppeal.setStatus(1);
        orderAppeal.setPhone(data.getPhone());
        orderAppealService.save(orderAppeal);
        return AjaxResult.success();
    }
}