xuhy
2024-12-18 52dbce830374cf635f5d50296630cdb6158437a4
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
package com.jilongda.applet.controller;
 
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jilongda.applet.model.TOptometryDetail;
import com.jilongda.applet.model.TOrder;
import com.jilongda.applet.model.TStore;
import com.jilongda.applet.query.TOrderQuery;
import com.jilongda.applet.service.*;
import com.jilongda.applet.utils.LoginInfoUtil;
import com.jilongda.applet.vo.TOrderVO;
import com.jilongda.common.basic.ApiResult;
import com.jilongda.common.basic.PageInfo;
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.web.bind.annotation.*;
 
import java.util.List;
import java.util.Objects;
 
/**
 * <p>
 * 销售订单表 前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-12-09
 */
@Api(tags = "销售订单")
@RestController
@RequestMapping("/t-order")
public class TOrderController {
 
    @Autowired
    private TOrderService tOrderService;
    @Autowired
    private LoginInfoUtil loginInfoUtil;
    @Autowired
    private TStoreService tStoreService;
    @Autowired
    private TOptometryDetailService optometryDetailService;
    @ApiOperation(value = "查询订单列表")
    @PostMapping(value = "/pageList")
    public ApiResult pageList(@RequestBody TOrderQuery query) {
        Integer userId = loginInfoUtil.getUserId();
        query.setUserId(userId);
        PageInfo<TOrderVO> pageInfo = tOrderService.pageList(query);
        return ApiResult.success(pageInfo);
    }
 
    @ApiOperation(value = "查询订单详情")
    @GetMapping(value = "/getDetailById")
    public ApiResult getDetailById(@RequestParam Integer id) {
 
        TOrder order = tOrderService.getById(id);
        TOrderVO tOrderVO = new TOrderVO();
        BeanUtils.copyProperties(order, tOrderVO);
        // 查询门店
        TStore store = tStoreService.getById(order.getStoreId());
        if(Objects.nonNull(store)){
            tOrderVO.setStoreName(store.getName());
        }
        // 查询配镜处方
        List<TOptometryDetail> list = optometryDetailService.list(Wrappers.lambdaQuery(TOptometryDetail.class)
                .eq(TOptometryDetail::getOptometryId, order.getOptometryId()));
        tOrderVO.setOptometryDetails(list);
 
        return ApiResult.success(tOrderVO);
    }
 
}