傅行帆 il y a 3 ans
Parent
révision
9033fc57e4

+ 55
- 2
src/main/java/com/yunzhi/marketing/controller/TaChannelController.java Voir le fichier

3
 import com.alibaba.excel.EasyExcel;
3
 import com.alibaba.excel.EasyExcel;
4
 import com.alibaba.excel.ExcelWriter;
4
 import com.alibaba.excel.ExcelWriter;
5
 import com.alibaba.excel.write.metadata.WriteSheet;
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
 import com.baomidou.mybatisplus.core.metadata.IPage;
8
 import com.baomidou.mybatisplus.core.metadata.IPage;
7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
9
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8
 import com.yunzhi.marketing.base.BaseController;
10
 import com.yunzhi.marketing.base.BaseController;
9
 import com.yunzhi.marketing.base.ResponseBean;
11
 import com.yunzhi.marketing.base.ResponseBean;
12
+import com.yunzhi.marketing.common.CommConstant;
10
 import com.yunzhi.marketing.common.StringUtils;
13
 import com.yunzhi.marketing.common.StringUtils;
11
 import com.yunzhi.marketing.entity.TaChannel;
14
 import com.yunzhi.marketing.entity.TaChannel;
15
+import com.yunzhi.marketing.entity.TaChannelPerson;
16
+import com.yunzhi.marketing.entity.TaPerson;
12
 import com.yunzhi.marketing.excel.handler.CustomCellWriteHandler;
17
 import com.yunzhi.marketing.excel.handler.CustomCellWriteHandler;
13
 import com.yunzhi.marketing.mapper.TaChannelMapper;
18
 import com.yunzhi.marketing.mapper.TaChannelMapper;
14
 import com.yunzhi.marketing.service.ITaPersonService;
19
 import com.yunzhi.marketing.service.ITaPersonService;
20
+import com.yunzhi.marketing.service.TaChannelPersonService;
15
 import com.yunzhi.marketing.service.TaChannelService;
21
 import com.yunzhi.marketing.service.TaChannelService;
16
 import com.yunzhi.marketing.excel.ActivityStatistics.ChannelAddRegistNum;
22
 import com.yunzhi.marketing.excel.ActivityStatistics.ChannelAddRegistNum;
17
 import com.yunzhi.marketing.excel.ActivityStatistics.ChannelVisitNum;
23
 import com.yunzhi.marketing.excel.ActivityStatistics.ChannelVisitNum;
59
     @Autowired
65
     @Autowired
60
     public TaChannelMapper taChannelMapper;
66
     public TaChannelMapper taChannelMapper;
61
 
67
 
68
+    @Autowired
69
+    private TaChannelPersonService taChannelPersonService;
70
+
62
 
71
 
63
     /**
72
     /**
64
      * 渠道管理列表
73
      * 渠道管理列表
147
             @ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
156
             @ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
148
     })
157
     })
149
     @ResponseBody
158
     @ResponseBody
150
-    @RequestMapping(value="/channel/{id}", method= RequestMethod.DELETE)
159
+    @RequestMapping(value="/admin/channel/{id}", method= RequestMethod.DELETE)
151
     public ResponseBean channelDelete(@PathVariable Integer id){
160
     public ResponseBean channelDelete(@PathVariable Integer id){
152
         ResponseBean responseBean = new ResponseBean();
161
         ResponseBean responseBean = new ResponseBean();
153
         try {
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
                 responseBean.addSuccess("success");
182
                 responseBean.addSuccess("success");
156
             }else {
183
             }else {
157
                 responseBean.addError("fail");
184
                 responseBean.addError("fail");
164
         return responseBean;
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
      * @param id  实体ID
222
      * @param id  实体ID

+ 5
- 0
src/main/java/com/yunzhi/marketing/entity/TaChannel.java Voir le fichier

94
      */
94
      */
95
     private String buildingId;
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 Voir le fichier

21
         FROM
21
         FROM
22
         ta_channel c
22
         ta_channel c
23
         LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
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
         LEFT JOIN (
25
         LEFT JOIN (
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
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
         <where>
27
         <where>
29
                 c.channel_id = #{channelId}
29
                 c.channel_id = #{channelId}
30
             </if>
30
             </if>
31
             and c.org_id = #{orgId}
31
             and c.org_id = #{orgId}
32
+            and c.status = 1
32
         </where>
33
         </where>
33
         GROUP BY c.channel_id
34
         GROUP BY c.channel_id
34
     </select>
35
     </select>

+ 1
- 1
src/main/resources/mapper/TaRecommendCustomerMapper.xml Voir le fichier

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