forked from xeon2007/SpringBoot_Wechat_Sell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSellerOrderController.java
More file actions
119 lines (101 loc) · 3.75 KB
/
SellerOrderController.java
File metadata and controls
119 lines (101 loc) · 3.75 KB
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
package com.ldlood.controller;
import com.ldlood.dto.OrderDTO;
import com.ldlood.enums.ResultEnum;
import com.ldlood.exception.SellException;
import com.ldlood.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
/**
* Created by Ldlood on 2017/8/1.
*/
@Controller
@RequestMapping("/seller/order")
@Slf4j
public class SellerOrderController {
@Autowired
private OrderService orderService;
@GetMapping("/list")
public ModelAndView list(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "size", defaultValue = "10") Integer size,
Map<String, Object> map) {
PageRequest pageRequest = new PageRequest(page - 1, size);
Page<OrderDTO> orderDTOPage = orderService.findListAll(pageRequest);
map.put("orderDTOPage", orderDTOPage);
map.put("currentPage", page);
map.put("size", size);
return new ModelAndView("order/list", map);
}
/**
* 订单详情
* @param orderId
* @param map
* @return
*/
@GetMapping("/cancel")
public ModelAndView cancel(@RequestParam("orderId") String orderId,
Map<String, Object> map) {
try {
OrderDTO orderDTO = orderService.findOne(orderId);
orderService.cancel(orderDTO);
} catch (Exception ex) {
log.error("【后台取消订单】 查询不到订单");
map.put("msg", ex.getMessage());
map.put("url", "/seller/order/list");
return new ModelAndView("common/error", map);
}
map.put("msg", ResultEnum.ORDER_CANCEL_SUCCESS.getMessage());
map.put("url", "/seller/order/list");
return new ModelAndView("common/success");
}
/**
* 订单详情
* @param orderId
* @param map
* @return
*/
@GetMapping("/detail")
public ModelAndView detail(@RequestParam("orderId") String orderId,
Map<String, Object> map) {
OrderDTO orderDTO = new OrderDTO();
try {
orderDTO = orderService.findOne(orderId);
}catch (SellException e) {
log.error("【卖家端查询订单详情】发生异常{}", e);
map.put("msg", e.getMessage());
map.put("url", "/sell/seller/order/list.ftl");
return new ModelAndView("common/error", map);
}
map.put("orderDTO", orderDTO);
return new ModelAndView("order/detail", map);
}
/**
* 完结订单
* @param orderId
* @param map
* @return
*/
@GetMapping("/finish")
public ModelAndView finished(@RequestParam("orderId") String orderId,
Map<String, Object> map) {
try {
OrderDTO orderDTO = orderService.findOne(orderId);
orderService.finish(orderDTO);
} catch (SellException e) {
log.error("【卖家端完结订单】发生异常{}", e);
map.put("msg", e.getMessage());
map.put("url", "/seller/order/list");
return new ModelAndView("common/error", map);
}
map.put("msg", ResultEnum.ORDER_FINISH_SUCCESS.getMessage());
map.put("url", "/seller/order/list");
return new ModelAndView("common/success");
}
}