|
@@ -7,19 +7,16 @@ import com.yunzhi.liyuanhui.common.BaseController;
|
7
|
7
|
import com.yunzhi.liyuanhui.common.DateUtils;
|
8
|
8
|
import com.yunzhi.liyuanhui.common.ResponseBean;
|
9
|
9
|
import com.yunzhi.liyuanhui.common.StringUtils;
|
|
10
|
+import com.yunzhi.liyuanhui.entity.TaPerson;
|
|
11
|
+import com.yunzhi.liyuanhui.enums.StatusEnum;
|
10
|
12
|
import org.slf4j.Logger;
|
11
|
13
|
import org.slf4j.LoggerFactory;
|
12
|
14
|
import org.springframework.beans.factory.annotation.Autowired;
|
13
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
14
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
15
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
16
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
17
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
18
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
15
|
+import org.springframework.web.bind.annotation.*;
|
19
|
16
|
import com.yunzhi.liyuanhui.service.ITaRecommenderService;
|
20
|
17
|
import com.yunzhi.liyuanhui.entity.TaRecommender;
|
21
|
|
-import org.springframework.web.bind.annotation.RestController;
|
22
|
18
|
|
|
19
|
+import javax.servlet.http.HttpServletRequest;
|
23
|
20
|
import java.util.Date;
|
24
|
21
|
import java.util.Map;
|
25
|
22
|
|
|
@@ -62,7 +59,8 @@ public class TaRecommenderController extends BaseController {
|
62
|
59
|
@RequestParam(value ="recName", required = false) String recName,
|
63
|
60
|
@RequestParam(value ="recPhone", required = false) String recPhone,
|
64
|
61
|
@RequestParam(value ="name", required = false) String name,
|
65
|
|
- @RequestParam(value ="phone", required = false) String phone
|
|
62
|
+ @RequestParam(value ="phone", required = false) String phone,
|
|
63
|
+ @RequestParam(value ="status", required = false) Integer status
|
66
|
64
|
) throws Exception{
|
67
|
65
|
|
68
|
66
|
IPage<Map<String, Object>> pg = new Page<>(pageNum, pageSize);
|
|
@@ -74,17 +72,40 @@ public class TaRecommenderController extends BaseController {
|
74
|
72
|
endDate += " 23:59:59";
|
75
|
73
|
}
|
76
|
74
|
|
77
|
|
- IPage<Map<String, Object>> result = iTaRecommenderService.getListBy(pg, startDate, endDate, recName, recPhone, name, phone);
|
|
75
|
+ IPage<Map<String, Object>> result = iTaRecommenderService.getListBy(pg, startDate, endDate, recName, recPhone, name, phone, status);
|
78
|
76
|
return ResponseBean.success(result);
|
79
|
77
|
}
|
80
|
78
|
|
|
79
|
+ @GetMapping("/wx/person/{personId}/recommender")
|
|
80
|
+ public ResponseBean getRecommenderOf(@PathVariable Integer personId,
|
|
81
|
+ @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
82
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize
|
|
83
|
+ ) throws Exception {
|
|
84
|
+
|
|
85
|
+ IPage<TaRecommender> pg = new Page<>(pageNum, pageSize);
|
|
86
|
+ QueryWrapper<TaRecommender> queryWrapper = new QueryWrapper<>();
|
|
87
|
+ queryWrapper.eq("person_id", personId);
|
|
88
|
+ queryWrapper.gt("status", StatusEnum.DELETED);
|
|
89
|
+ queryWrapper.orderByDesc("create_date");
|
|
90
|
+ return ResponseBean.success(iTaRecommenderService.list(queryWrapper));
|
|
91
|
+ }
|
|
92
|
+
|
81
|
93
|
/**
|
82
|
94
|
* 保存对象
|
83
|
95
|
* @param taRecommender 实体对象
|
84
|
96
|
* @return
|
85
|
97
|
*/
|
86
|
|
- @RequestMapping(value="/taRecommender",method= RequestMethod.POST)
|
87
|
|
- public ResponseBean taRecommenderAdd(@RequestBody TaRecommender taRecommender) throws Exception{
|
|
98
|
+ @RequestMapping(value="/wx/recommender",method= RequestMethod.POST)
|
|
99
|
+ public ResponseBean taRecommenderAdd(@RequestBody TaRecommender taRecommender, HttpServletRequest request) throws Exception{
|
|
100
|
+ TaPerson taPerson = getPerson(request);
|
|
101
|
+ if (null == taPerson) {
|
|
102
|
+ return ResponseBean.error("获取当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ // 推荐客户状态是未审核
|
|
106
|
+ taRecommender.setStatus(StatusEnum.READY.getCode());
|
|
107
|
+ // 设置当前推荐人
|
|
108
|
+ taRecommender.setPersonId(taPerson.getPersonId());
|
88
|
109
|
|
89
|
110
|
if (iTaRecommenderService.save(taRecommender)){
|
90
|
111
|
return ResponseBean.success(taRecommender);
|
|
@@ -100,7 +121,6 @@ public class TaRecommenderController extends BaseController {
|
100
|
121
|
@ResponseBody
|
101
|
122
|
@RequestMapping(value="/taRecommender/{id}", method= RequestMethod.DELETE)
|
102
|
123
|
public ResponseBean taRecommenderDelete(@PathVariable Integer id) throws Exception{
|
103
|
|
-
|
104
|
124
|
if(iTaRecommenderService.removeById(id)){
|
105
|
125
|
return ResponseBean.success("success");
|
106
|
126
|
}else {
|
|
@@ -114,12 +134,12 @@ public class TaRecommenderController extends BaseController {
|
114
|
134
|
* @param taRecommender 实体对象
|
115
|
135
|
* @return
|
116
|
136
|
*/
|
117
|
|
- @RequestMapping(value="/taRecommender/{id}",method= RequestMethod.PUT)
|
|
137
|
+ @RequestMapping(value="/admin/recommender/{id}",method= RequestMethod.PUT)
|
118
|
138
|
public ResponseBean taRecommenderUpdate(@PathVariable Integer id,
|
119
|
139
|
@RequestBody TaRecommender taRecommender) throws Exception{
|
120
|
140
|
|
121
|
141
|
if (iTaRecommenderService.updateById(taRecommender)){
|
122
|
|
- return ResponseBean.success(taRecommender);
|
|
142
|
+ return ResponseBean.success(iTaRecommenderService.getById(id));
|
123
|
143
|
}else {
|
124
|
144
|
return ResponseBean.error("更新失败", ResponseBean.ERROR_UNAVAILABLE);
|
125
|
145
|
}
|