|
@@ -3,15 +3,21 @@ package com.yunzhi.marketing.controller;
|
3
|
3
|
import com.alibaba.excel.EasyExcel;
|
4
|
4
|
import com.alibaba.excel.ExcelWriter;
|
5
|
5
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
6
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
7
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
6
|
8
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
7
|
9
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
8
|
10
|
import com.yunzhi.marketing.base.BaseController;
|
9
|
11
|
import com.yunzhi.marketing.base.ResponseBean;
|
|
12
|
+import com.yunzhi.marketing.common.CommConstant;
|
10
|
13
|
import com.yunzhi.marketing.common.StringUtils;
|
11
|
14
|
import com.yunzhi.marketing.entity.TaChannel;
|
|
15
|
+import com.yunzhi.marketing.entity.TaChannelPerson;
|
|
16
|
+import com.yunzhi.marketing.entity.TaPerson;
|
12
|
17
|
import com.yunzhi.marketing.excel.handler.CustomCellWriteHandler;
|
13
|
18
|
import com.yunzhi.marketing.mapper.TaChannelMapper;
|
14
|
19
|
import com.yunzhi.marketing.service.ITaPersonService;
|
|
20
|
+import com.yunzhi.marketing.service.TaChannelPersonService;
|
15
|
21
|
import com.yunzhi.marketing.service.TaChannelService;
|
16
|
22
|
import com.yunzhi.marketing.excel.ActivityStatistics.ChannelAddRegistNum;
|
17
|
23
|
import com.yunzhi.marketing.excel.ActivityStatistics.ChannelVisitNum;
|
|
@@ -59,6 +65,9 @@ public class TaChannelController extends BaseController {
|
59
|
65
|
@Autowired
|
60
|
66
|
public TaChannelMapper taChannelMapper;
|
61
|
67
|
|
|
68
|
+ @Autowired
|
|
69
|
+ private TaChannelPersonService taChannelPersonService;
|
|
70
|
+
|
62
|
71
|
|
63
|
72
|
/**
|
64
|
73
|
* 渠道管理列表
|
|
@@ -147,11 +156,29 @@ public class TaChannelController extends BaseController {
|
147
|
156
|
@ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
|
148
|
157
|
})
|
149
|
158
|
@ResponseBody
|
150
|
|
- @RequestMapping(value="/channel/{id}", method= RequestMethod.DELETE)
|
|
159
|
+ @RequestMapping(value="/admin/channel/{id}", method= RequestMethod.DELETE)
|
151
|
160
|
public ResponseBean channelDelete(@PathVariable Integer id){
|
152
|
161
|
ResponseBean responseBean = new ResponseBean();
|
153
|
162
|
try {
|
154
|
|
- if(taChannelService.removeById(id)){
|
|
163
|
+ TaChannel taChannel = taChannelService.getById(id);
|
|
164
|
+ taChannel.setStatus(CommConstant.STATUS_DELETE);
|
|
165
|
+ if(taChannelService.updateById(taChannel)){
|
|
166
|
+ // 删除成功后更新此渠道的所有的经纪人为普通客户
|
|
167
|
+ LambdaQueryWrapper<TaChannelPerson> channelPersonLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
168
|
+ channelPersonLambdaQueryWrapper.eq(TaChannelPerson::getChannelId,id);
|
|
169
|
+ //查询出所有的渠道person
|
|
170
|
+ List<TaChannelPerson> list = taChannelPersonService.list(channelPersonLambdaQueryWrapper);
|
|
171
|
+ TaChannelPerson taChannelPerson = new TaChannelPerson();
|
|
172
|
+ taChannelPerson.setStatus(CommConstant.STATUS_DELETE);
|
|
173
|
+ // 把所有的渠道person 更新为删除状态
|
|
174
|
+ taChannelPersonService.update(taChannelPerson, channelPersonLambdaQueryWrapper);
|
|
175
|
+
|
|
176
|
+ // 把所有的person的type 更新为普通用户
|
|
177
|
+ list.forEach(e -> {
|
|
178
|
+ TaPerson taPerson = taPersonService.getById(e.getPersonId());
|
|
179
|
+ taPerson.setPersonType(CommConstant.PERSON_ESTATE_CUSTOMER);
|
|
180
|
+ taPersonService.updateById(taPerson);
|
|
181
|
+ });
|
155
|
182
|
responseBean.addSuccess("success");
|
156
|
183
|
}else {
|
157
|
184
|
responseBean.addError("fail");
|
|
@@ -164,6 +191,32 @@ public class TaChannelController extends BaseController {
|
164
|
191
|
return responseBean;
|
165
|
192
|
}
|
166
|
193
|
|
|
194
|
+ @ResponseBody
|
|
195
|
+ @RequestMapping(value="/admin/channelPerson/{personId}", method= RequestMethod.DELETE)
|
|
196
|
+ public ResponseBean channelPersonDelete(@PathVariable String personId){
|
|
197
|
+ ResponseBean responseBean = new ResponseBean();
|
|
198
|
+ try {
|
|
199
|
+ // 删除成功后更新此渠道的所有的经纪人为普通客户
|
|
200
|
+ LambdaQueryWrapper<TaChannelPerson> channelPersonLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
201
|
+ channelPersonLambdaQueryWrapper.eq(TaChannelPerson::getPersonId,personId);
|
|
202
|
+ TaChannelPerson taChannelPerson = new TaChannelPerson();
|
|
203
|
+ taChannelPerson.setStatus(CommConstant.STATUS_DELETE);
|
|
204
|
+ // 把所有的渠道person 更新为删除状态
|
|
205
|
+ taChannelPersonService.update(taChannelPerson, channelPersonLambdaQueryWrapper);
|
|
206
|
+
|
|
207
|
+ // 更新为普通用户
|
|
208
|
+ TaPerson taPerson = taPersonService.getById(personId);
|
|
209
|
+ taPerson.setPersonType(CommConstant.PERSON_ESTATE_CUSTOMER);
|
|
210
|
+ taPersonService.updateById(taPerson);
|
|
211
|
+ responseBean.addSuccess("success");
|
|
212
|
+ }catch (Exception e){
|
|
213
|
+ e.printStackTrace();
|
|
214
|
+ logger.error("channelDelete -=- {}",e.toString());
|
|
215
|
+ responseBean.addError(e.getMessage());
|
|
216
|
+ }
|
|
217
|
+ return responseBean;
|
|
218
|
+ }
|
|
219
|
+
|
167
|
220
|
/**
|
168
|
221
|
* 修改对象
|
169
|
222
|
* @param id 实体ID
|