傅行帆 3 anni fa
parent
commit
9033fc57e4

+ 55
- 2
src/main/java/com/yunzhi/marketing/controller/TaChannelController.java Vedi File

@@ -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

+ 5
- 0
src/main/java/com/yunzhi/marketing/entity/TaChannel.java Vedi File

@@ -94,6 +94,11 @@ public class TaChannel implements Serializable {
94 94
      */
95 95
     private String buildingId;
96 96
 
97
+    /**
98
+     * 状态
99
+     */
100
+    private Integer status;
101
+
97 102
     /**
98 103
      * 说明描述
99 104
      */

+ 2
- 1
src/main/resources/mapper/TaChannelMapper.xml Vedi File

@@ -21,7 +21,7 @@
21 21
         FROM
22 22
         ta_channel c
23 23
         LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
24
-        LEFT JOIN ta_person tp ON cp.person_id = tp.person_id 	AND tp.person_type = 'estate agent' 	AND cp.STATUS = 1
24
+        LEFT JOIN ta_person tp ON cp.person_id = tp.person_id	AND cp.STATUS = 1
25 25
         LEFT JOIN (
26 26
         SELECT sum(new_customers) as customerNum,qr_code_id,channel_id,org_id from ts_channel_daily where channel_id is not null and org_id = #{orgId} GROUP BY channel_id) ts on c.channel_id = ts.channel_id
27 27
         <where>
@@ -29,6 +29,7 @@
29 29
                 c.channel_id = #{channelId}
30 30
             </if>
31 31
             and c.org_id = #{orgId}
32
+            and c.status = 1
32 33
         </where>
33 34
         GROUP BY c.channel_id
34 35
     </select>

+ 1
- 1
src/main/resources/mapper/TaRecommendCustomerMapper.xml Vedi File

@@ -89,7 +89,7 @@ FROM
89 89
         left join ta_channel_person tcp on a.person_id = tcp.person_id
90 90
         left join ta_channel tc on tc.channel_id = tcp.channel_id
91 91
         <where>
92
-            a.person_type in ('estate agent', 'channel agent')
92
+            a.person_type in ('channel agent')
93 93
             and a.status >0
94 94
             <if test="name != null and name !=''">
95 95
                 and a.nickname = #{name}