andrew 4 년 전
부모
커밋
30374f9d0a

+ 277
- 0
src/main/java/com/huiju/estateagents/property/common/Constant.java 파일 보기

@@ -246,4 +246,281 @@ public class Constant {
246 246
     public static final String PAY_TYPE_CAR = "car";
247 247
 
248 248
 
249
+    /**
250
+     * 房产关联审核通过
251
+     */
252
+    public static final String ESTATE_RELATE_VERIFY_PASSED = "estate_relate_verify_passed";
253
+
254
+    /**
255
+     * 家/租/户 审核房产推物业
256
+     */
257
+    public static final String CUSTOMER_SUBMIT_PROP_VERIFY = "customer_submit_prop_verify";
258
+
259
+    /**
260
+     * 活动报名成功
261
+     */
262
+    public static final String ESTATE_SERVICE_ACTIVITY_SIGN_SUCCESS ="estate_service_activity_sign_success";
263
+
264
+    /**
265
+     * 房产关联审核不通过
266
+     */
267
+    public static final String ESTATE_RELATE_VERIFY_REJECTED = "estate_relate_verify_rejected";
268
+
269
+    /**
270
+     * 物业发布公告成功
271
+     */
272
+    public static final String ESTATE_SERVICE_ANNOUNCEMENT_SUCCESS = "estate_service_announcement_success";
273
+
274
+    /**
275
+     * 物业发布活动成功
276
+     */
277
+    public static final String ESTATE_SERVICE_ACTIVITY_SUCCESS = "estate_service_activity_success";
278
+
279
+    /**
280
+     *15条消息
281
+     */
282
+    public static final String SYSTEM_MESSAGE ="system_message";
283
+
284
+    /**
285
+     * 消息message_type为9表示不可点击
286
+     */
287
+    public static final String SYSTEM_MESSAGE_TYPE ="9";
288
+    /**
289
+     * 话题被回复
290
+     */
291
+    public static final String THREAD_REPLY = "thread_reply";
292
+
293
+    /**
294
+     * 话题被举报
295
+     */
296
+    public static final String THREAD_REPORT = "thread_report";
297
+
298
+    /**
299
+     * 活动报名后被物业后台删除
300
+     */
301
+    public static final String ACTIVITY_JOINED_DELETE_BY_ESTATE_SERVICE = "activity_joined_delete_by_estate_service";
302
+
303
+    /**
304
+     * 活动被作废
305
+     */
306
+    public static final String ACTIVITY_CANCELLED = "activity_cancelled";
307
+
308
+    /**
309
+     * 话题被作废
310
+     */
311
+    public static final String THREAD_CANCELLED = "thread_cancelled";
312
+
313
+    /**
314
+     * 收费组被发布
315
+     */
316
+    public static final String PUBLISH_BILL = "publish_bill";
317
+
318
+    /**
319
+     * 月租车缴费推送消息
320
+     */
321
+    public static final String PAY_MONTH_Bill_SUCCEED = "pay_month_bill_succeed";
322
+
323
+    /**
324
+     * 工单被拒绝受理
325
+     */
326
+    public static final String TICKET_REJECTED = "ticket_rejected";
327
+
328
+    /**
329
+     * 添加工单
330
+     */
331
+    public static final String TICKET_ADD = "ticket_add";
332
+
333
+    /**
334
+     * 工单修改
335
+     */
336
+    public static final String TICKET_UPDATE = "ticket_update";
337
+
338
+    /**
339
+     * 工单被分配
340
+     */
341
+    public static final String TICKET_DISTRIBUTED = "ticket_distributed";
342
+
343
+    /**
344
+     * 工单终止
345
+     */
346
+    public static final String TICKET_TERMINATION = "ticket_termination";
347
+    /**
348
+     * 工单被提交处理结果
349
+     */
350
+    public static final String TICKET_SUBMIT_RESULT = "ticket_submit_result";
351
+
352
+    /**
353
+     * 工单被回复
354
+     */
355
+    public static final String TICKET_REPLY = "ticket_reply";
356
+
357
+    /**
358
+     * 商铺评价被回复
359
+     */
360
+    public static final String SHOP_REVIEW_REPLY = "shop_review_reply";
361
+
362
+    /**
363
+     * 商铺评价时推送消息
364
+     */
365
+    public static final String SHOP_REVIEW_PROP_REPLY ="shop_review_prop_reply";
366
+
367
+    /**
368
+     * 家属或租客提交审核信息
369
+     */
370
+    public static final String CUSTOMER_SUBMIT_VERIFY = "customer_submit_verify";
371
+
372
+    /**
373
+     * 添加帖子时推送物业端消息
374
+     */
375
+    public static final String THREAD_ADD_TRANSACTION ="thread_add_transaction";
376
+
377
+    /**
378
+     * 话题举报时推送物业端
379
+     */
380
+    public static final String THREAD_REPORT_RROP = "thread_report_prop";
381
+
382
+    /**
383
+     * 话题修改时推送消息
384
+     */
385
+    public static final String THREAD_UPDATE_TRANSACTION = "thread_update_transaction";
386
+
387
+    /**
388
+     * 缴费成功时推送消息
389
+     */
390
+    public static final String PAY_TYPE_SUCCEED = "pay_type_succeed";
391
+
392
+    /**
393
+     * 短信通知
394
+     */
395
+    public static final String SMS_NOTIFICATION = "1";
396
+
397
+    /**
398
+     * 论坛消息
399
+     */
400
+    public static final String FORUM_NEWS = "2";
401
+
402
+    /**
403
+     * 物业消息
404
+     */
405
+    public static final String PROPERTY_NEWS = "3";
406
+
407
+    /**
408
+     * 工单消息
409
+     */
410
+    public static final String TICKET_NEWS = "4";
411
+
412
+    /**
413
+     * 其他消息
414
+     */
415
+    public static final String OTHER_NEWS = "5";
416
+
417
+    /**
418
+     * 系统消息
419
+     */
420
+    public static final String SYS_NEWS = "6";
421
+
422
+    /**
423
+     * 费用消息
424
+     */
425
+    public static final String BILL_NEWS = "7";
426
+
427
+    /**
428
+     * 审核消息
429
+     */
430
+    public static final String AUDIT_NEWS = "8";
431
+
432
+    /**
433
+     * app端
434
+     */
435
+    public static final String UUID_TYPE_APP = "app";
436
+
437
+    /**
438
+     * 物业端
439
+     */
440
+    public static final String UUID_TYPE_PROP = "prop";
441
+
442
+    /**
443
+     * app端
444
+     */
445
+    public static final String SOURCE_APP = "app";
446
+
447
+    /**
448
+     * 物业端
449
+     */
450
+    public static final String SOURCE_PROP = "prop";
451
+
452
+    /**
453
+     * 有效
454
+     */
455
+    public static final String STATUS_EFFECTIVE = "1";
456
+
457
+    /**
458
+     * 无效
459
+     */
460
+    public static final String STATUS_INVALID = "0";
461
+
462
+    /**
463
+     * 已读
464
+     */
465
+    public static final String READ_STATUS_READ = "1";
466
+
467
+    /**
468
+     * 未读
469
+     */
470
+    public static final String READ_STATUS_UNREAD = "0";
471
+
472
+    /**
473
+     * 审核未通过短信通知
474
+     */
475
+    public static final String ESTATE_RELATE_VERIFY_REJECTED_SMS = "0401";
476
+
477
+    /**
478
+     * 审核通过短信通知
479
+     */
480
+    public static final String ESTATE_RELATE_VERIFY_PASSED_SMS = "0402";
481
+
482
+    /**
483
+     * 公告类型
484
+     */
485
+    public static final String MESSAGE_UUID_TYPE_ANNOUNCEMENT = "announcement";
486
+
487
+    /**
488
+     * 活动类型
489
+     */
490
+    public static final String MESSAGE_UUID_TYPE_ACTIVITY = "activity";
491
+
492
+    /**
493
+     * 话题类型
494
+     */
495
+    public static final String MESSAGE_UUID_TYPE_TRANSACTION = "transaction";
496
+
497
+    /**
498
+     * 工单类型
499
+     */
500
+    public static final String MESSAGE_UUID_TYPE_TICKET = "ticket";
501
+
502
+    /**
503
+     * 商铺类型
504
+     */
505
+    public static final String MESSAGE_UUID_TYPE_SHOP = "shop";
506
+
507
+    /**
508
+     * 收费类型
509
+     */
510
+    public static final String MESSAGE_UUID_TYPE_BILL= "bill";
511
+
512
+    /**
513
+     * 资料审核类型
514
+     */
515
+    public static final String MESSAGE_UUID_TYPE_AUDIT= "audit";
516
+
517
+    /**
518
+     * app回复物业
519
+     */
520
+    public static final String TICKET_REPLY_PROP = "ticketReplyProp";
521
+
522
+    /**
523
+     * app评价物业
524
+     */
525
+    public static final String TICKET_EVALUATE_PROP = "ticketEvaluateProp";
249 526
 }

+ 1
- 2
src/main/java/com/huiju/estateagents/property/controller/BillController.java 파일 보기

@@ -168,7 +168,6 @@ public class BillController extends BaseController {
168 168
     @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "Integer", name = "payType", value = "0是未缴费1是已缴费"),
169 169
             @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageNum", value = "分页第几页"),
170 170
             @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageSize", value = "分页每页长度"),
171
-            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token"),
172 171
     })
173 172
     @RequestMapping(value = "/wx/bills/current_user/{payType}",method = RequestMethod.GET)
174 173
     public ResponseBean getBillInvoice(@PathVariable Integer payType,
@@ -196,7 +195,7 @@ public class BillController extends BaseController {
196 195
 
197 196
     @ApiOperation(value = "获取历史缴费", notes = "获取历史缴费")
198 197
     @ApiImplicitParams({
199
-            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
198
+
200 199
     })
201 200
     @RequestMapping(value = "/wx/bill/pay/history", method = RequestMethod.GET)
202 201
     public ResponseBean payHistory(HttpServletRequest request) {

+ 1
- 1
src/main/java/com/huiju/estateagents/property/controller/BuildingOwnerInfoController.java 파일 보기

@@ -358,7 +358,7 @@ public class BuildingOwnerInfoController extends BaseController {
358 358
             @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "unitId", value = "单元"),
359 359
             @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "levelId", value = "楼层"),
360 360
             @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "roomNoId", value = "户号"),
361
-            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
361
+
362 362
     })
363 363
     public ResponseBean hasBuilding(@RequestParam(value = "orgId", required = false) Integer orgId,
364 364
                                     @RequestParam(value = "phaseId", required = false) Integer phaseId,

+ 86
- 6
src/main/java/com/huiju/estateagents/property/controller/MessageController.java 파일 보기

@@ -4,6 +4,7 @@ package com.huiju.estateagents.property.controller;
4 4
 import com.huiju.estateagents.base.BaseController;
5 5
 import com.huiju.estateagents.base.ResponseBean;
6 6
 import com.huiju.estateagents.center.taUser.entity.TaUser;
7
+import com.huiju.estateagents.property.common.Constant;
7 8
 import com.huiju.estateagents.property.common.UserElement;
8 9
 import com.huiju.estateagents.property.service.IMessageService;
9 10
 import io.swagger.annotations.Api;
@@ -11,13 +12,11 @@ import io.swagger.annotations.ApiImplicitParam;
11 12
 import io.swagger.annotations.ApiImplicitParams;
12 13
 import io.swagger.annotations.ApiOperation;
13 14
 import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
15
+import org.springframework.web.bind.annotation.*;
18 16
 
19 17
 import javax.servlet.http.HttpServletRequest;
20 18
 import javax.servlet.http.HttpSession;
19
+import java.util.Map;
21 20
 
22 21
 /**
23 22
  * <p>
@@ -28,8 +27,8 @@ import javax.servlet.http.HttpSession;
28 27
  * @since 2019-03-05
29 28
  */
30 29
 @RestController
31
-@RequestMapping("/")
32
-@Api(value = "消息通知API", description = "消息通知API")
30
+@RequestMapping("/api")
31
+@Api(value = "消息通知API", tags = "消息通知API")
33 32
 public class MessageController extends BaseController {
34 33
 
35 34
     @Autowired
@@ -69,6 +68,87 @@ public class MessageController extends BaseController {
69 68
         ResponseBean  responseBean = messageService.delectRead(parameter,userElement.getUserId());
70 69
         return responseBean;
71 70
     }
71
+
72
+
73
+    @ApiOperation(value = "按小区获取消息总数", notes = "按小区获取个人消息总数")
74
+    @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "orgId", value = "小区Id")})
75
+    @RequestMapping(value = "/wx/message/{orgId}/total",method = RequestMethod.GET)
76
+    public ResponseBean getMessageTotal(@PathVariable Integer orgId, HttpServletRequest request){
77
+        TaUser userElement = getTaUser(request);
78
+        ResponseBean responseBean = new ResponseBean();
79
+        Map<String,Object> totalMap = messageService.getMessageTotal(orgId, userElement.getUserId());
80
+        responseBean.addSuccess(totalMap);
81
+        return responseBean;
82
+    }
83
+
84
+    @ApiOperation(value = "按小区获取分页消息", notes = "按小区获取分页消息")
85
+    @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "communityId", value = "小区Id"),
86
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageNum", value = "分页第几页"),
87
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageSize", value = "分页每页长度")})
88
+    @RequestMapping(value = "/wx/message/{orgId}/news",method = RequestMethod.GET)
89
+    public ResponseBean getNews(@PathVariable Integer orgId,
90
+                                @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
91
+                                @RequestParam(value ="pageSize",defaultValue = "5") Integer pageSize, HttpServletRequest request){
92
+        TaUser userElement = getTaUser(request);
93
+        ResponseBean responseBean = new ResponseBean();
94
+
95
+        Map<String,Object> map = messageService.getMessages(orgId,pageNum,pageSize, Constant.MODEL_TYPE_NEWS, userElement.getUserId());
96
+        responseBean.addSuccess(map);
97
+        return responseBean;
98
+    }
99
+
100
+    @ApiOperation(value = "按小区获取分页待办", notes = "按小区获取分页待办")
101
+    @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "communityId", value = "小区Id"),
102
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageNum", value = "分页第几页"),
103
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageSize", value = "分页每页长度")})
104
+    @RequestMapping(value = "/wx/message/{orgId}/upcoming",method = RequestMethod.GET)
105
+    public ResponseBean getUpcoming(@PathVariable Integer orgId,
106
+                                    @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
107
+                                    @RequestParam(value ="pageSize",defaultValue = "5") Integer pageSize, HttpServletRequest request){
108
+        TaUser userElement = getTaUser(request);
109
+        Integer userId = userElement.getUserId();
110
+        ResponseBean responseBean = new ResponseBean();
111
+
112
+        Map<String,Object> map = messageService.getMessages(orgId,pageNum,pageSize,Constant.MODEL_TYPE_UPCOMING, userId);
113
+        responseBean.addSuccess(map);
114
+        return responseBean;
115
+    }
116
+
117
+    @ApiOperation(value = "消息已读接口", notes = "消息已读接口")
118
+    @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "communityId", value = "小区Id"),
119
+            })
120
+    @RequestMapping(value = "/wx/readStatus/{orgId}",method = RequestMethod.POST)
121
+    public ResponseBean allMessageRead(@PathVariable("orgId") Integer orgId, HttpServletRequest request){
122
+        TaUser userElement = getTaUser(request);
123
+        Integer userId = userElement.getUserId();
124
+        ResponseBean responseBean = new ResponseBean();
125
+
126
+        messageService.updateMessageReadStatus(orgId, userId);
127
+        return responseBean;
128
+    }
129
+
130
+
131
+    @ApiOperation(value = "根据消息id进行已读", notes = "根据消息id进行已读")
132
+    @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "messageId", value = "消息id"),
133
+            })
134
+    @RequestMapping(value = "/wx/messageIdreadStatus/{messageId}",method = RequestMethod.PUT)
135
+    public ResponseBean updateMessageByIdReadStatus(HttpServletRequest request, @PathVariable("messageId") Integer messageId) {
136
+        ResponseBean responseBean = new ResponseBean();
137
+        TaUser userElement = getTaUser(request);
138
+        responseBean = messageService.updateMessageByIdReadStatus(userElement, messageId);
139
+        return responseBean;
140
+    }
141
+
142
+    @ApiOperation(value = "根据消息id获取详细数据", notes = "根据消息id获取详细数据")
143
+    @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "messageId", value = "消息id"),
144
+            })
145
+    @RequestMapping(value = "/wx/message/get/{messageId}",method = RequestMethod.GET)
146
+    public ResponseBean getMessageById(HttpServletRequest request, @PathVariable("messageId") Integer messageId) {
147
+        ResponseBean responseBean = new ResponseBean();
148
+        TaUser userElement = getTaUser(request);
149
+        responseBean = messageService.getMessageById(userElement.getOrgId(), messageId);
150
+        return responseBean;
151
+    }
72 152
 }
73 153
 
74 154
 

+ 8
- 0
src/main/java/com/huiju/estateagents/property/dao/MessageMapper.java 파일 보기

@@ -9,6 +9,8 @@ import org.apache.ibatis.annotations.Mapper;
9 9
 import org.apache.ibatis.annotations.Param;
10 10
 
11 11
 import java.util.Date;
12
+import java.util.List;
13
+import java.util.Map;
12 14
 
13 15
 /**
14 16
  * <p>
@@ -61,4 +63,10 @@ public interface MessageMapper extends BaseMapper<Message> {
61 63
      * @param ticketId
62 64
      */
63 65
     void updateTickMessageStatus(@Param("ticketId") Integer ticketId);
66
+
67
+    Map<String, Object> getMessageTotal(@Param(value = "userId") Integer userId, @Param(value = "orgId") Integer orgId);
68
+
69
+    IPage<Message> getMessages(IPage<Message> page,@Param(value = "userId") Integer userId, @Param(value = "orgId") Integer orgId, @Param(value = "modelType") Integer modelType);
70
+
71
+    void updateReadStatus(@Param(value = "orgId")Integer orgId, @Param(value = "userId")Integer userId);
64 72
 }

+ 3
- 3
src/main/java/com/huiju/estateagents/property/dao/TpTransactionMapper.java 파일 보기

@@ -3,9 +3,7 @@ package com.huiju.estateagents.property.dao;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 5
 import com.huiju.estateagents.property.model.TpTransaction;
6
-import org.apache.ibatis.annotations.Mapper;
7
-import org.apache.ibatis.annotations.Param;
8
-import org.apache.ibatis.annotations.Update;
6
+import org.apache.ibatis.annotations.*;
9 7
 
10 8
 import java.util.List;
11 9
 
@@ -30,4 +28,6 @@ public interface TpTransactionMapper extends BaseMapper<TpTransaction> {
30 28
      */
31 29
     @Update("update tp_transaction set status = 0 where uuid = #{uuid} and uuid_type = #{uuidType}")
32 30
     void invalidByUuidAndUuidType(@Param("uuid") Integer uuid, @Param("uuidType") String uuidType);
31
+
32
+    TpTransaction selectByPrimaryKey(@Param("id") Integer id,@Param("orgId")  Integer orgId);
33 33
 }

+ 37
- 0
src/main/java/com/huiju/estateagents/property/model/Message.java 파일 보기

@@ -1,5 +1,6 @@
1 1
 package com.huiju.estateagents.property.model;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.TableField;
3 4
 import com.baomidou.mybatisplus.annotation.TableName;
4 5
 import lombok.Data;
5 6
 import lombok.EqualsAndHashCode;
@@ -130,4 +131,40 @@ public class Message implements Serializable {
130 131
      */
131 132
     private Integer transactionId;
132 133
 
134
+
135
+    /**
136
+     * 跳转的消息详情id
137
+     */
138
+    @TableField(exist = false)
139
+    private Integer messageUuid;
140
+
141
+    @TableField(exist = false)
142
+    private String readMessageIcon;
143
+
144
+    @TableField(exist = false)
145
+    private String unreadMessageIcon;
146
+
147
+    @TableField(exist = false)
148
+    private String messageDetailUrl;
149
+
150
+    @TableField(exist = false)
151
+    private String messageIconTitle;
152
+
153
+    @TableField(exist = false)
154
+    private String ticketStatus;
155
+
156
+    @TableField(exist = false)
157
+    private String content;
158
+    /**
159
+     * 需要跳转的消息的类型
160
+     */
161
+    @TableField(exist = false)
162
+    private String messageUuidType;
163
+
164
+    /**
165
+     * 工单类型
166
+     * @return
167
+     */
168
+    @TableField(exist = false)
169
+    private String ticketType;
133 170
 }

+ 42
- 0
src/main/java/com/huiju/estateagents/property/service/IMessageService.java 파일 보기

@@ -2,8 +2,12 @@ package com.huiju.estateagents.property.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.huiju.estateagents.base.ResponseBean;
5
+import com.huiju.estateagents.center.taUser.entity.TaUser;
6
+import com.huiju.estateagents.property.common.UserElement;
5 7
 import com.huiju.estateagents.property.model.Message;
6 8
 
9
+import java.util.Map;
10
+
7 11
 /**
8 12
  * <p>
9 13
  * 物业端消息表 服务类
@@ -37,4 +41,42 @@ public interface IMessageService extends IService<Message> {
37 41
      * @return
38 42
      */
39 43
     ResponseBean delectRead(String parameter, Integer id);
44
+
45
+    /**
46
+     * 获取消息数量
47
+     * @param orgId
48
+     * @return
49
+     */
50
+    Map<String, Object> getMessageTotal(Integer orgId, Integer verifyId);
51
+
52
+    /**
53
+     * 分页获取消息或待办
54
+     * @param orgId
55
+     * @param pageNum
56
+     * @param pageSize
57
+     * @param modelType
58
+     * @return
59
+     */
60
+    Map<String,Object> getMessages(Integer orgId, Integer pageNum, Integer pageSize,Integer modelType, Integer verifyId);
61
+
62
+    /**
63
+     * 全部已读
64
+     */
65
+    void updateMessageReadStatus(Integer orgId, Integer userId);
66
+
67
+    /**
68
+     * 根据消息的id, 进行已读操作
69
+     * @param userElement
70
+     * @param messageId
71
+     * @return
72
+     */
73
+    ResponseBean updateMessageByIdReadStatus(TaUser userElement, Integer messageId);
74
+
75
+    /**
76
+     * 根据消息ID 查询详情数据
77
+     * @param orgId
78
+     * @param messageId
79
+     * @return
80
+     */
81
+    ResponseBean getMessageById(Integer orgId, Integer messageId);
40 82
 }

+ 177
- 2
src/main/java/com/huiju/estateagents/property/service/impl/MessageServiceImpl.java 파일 보기

@@ -7,16 +7,22 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
7 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9 9
 import com.huiju.estateagents.base.ResponseBean;
10
-import com.huiju.estateagents.property.dao.MessageMapper;
11
-import com.huiju.estateagents.property.model.Message;
10
+import com.huiju.estateagents.center.taUser.entity.TaUser;
11
+import com.huiju.estateagents.center.taUser.mapper.TaUserMapper;
12
+import com.huiju.estateagents.property.common.Constant;
13
+import com.huiju.estateagents.property.common.UserElement;
14
+import com.huiju.estateagents.property.dao.*;
15
+import com.huiju.estateagents.property.model.*;
12 16
 import com.huiju.estateagents.property.service.IMessageService;
13 17
 import org.springframework.beans.factory.annotation.Autowired;
14 18
 import org.springframework.stereotype.Service;
19
+import springfox.documentation.swagger2.mappers.ModelMapper;
15 20
 
16 21
 import java.time.LocalDateTime;
17 22
 import java.util.Date;
18 23
 import java.util.HashMap;
19 24
 import java.util.List;
25
+import java.util.Map;
20 26
 
21 27
 /**
22 28
  * <p>
@@ -30,6 +36,28 @@ import java.util.List;
30 36
 public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements IMessageService {
31 37
     @Autowired
32 38
     private MessageMapper messageMapper;
39
+
40
+    @Autowired
41
+    private BillMapper tpBillMapper;
42
+
43
+    @Autowired
44
+    private TpTicketMapper tpTicketMapper;
45
+
46
+    @Autowired
47
+    private TpTransactionMapper tpTransactionMapper;
48
+
49
+    @Autowired
50
+    private TaUserVerifyMapper taUserVerifyMapper;
51
+
52
+    @Autowired
53
+    private TpAnnouncementMapper tpAnnouncementMapper;
54
+
55
+    @Autowired
56
+    private  TpActivityMapper tpActivityMapper;
57
+
58
+    @Autowired
59
+    private  TpShopMapper tpShopMapper;
60
+
33 61
     @Override
34 62
     public ResponseBean messageLiset(String parameter, Integer orgId,Integer user) {
35 63
         ResponseBean response= new  ResponseBean();
@@ -104,4 +132,151 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
104 132
                 response.addSuccess("成功");
105 133
                 return response;
106 134
     }
135
+
136
+
137
+
138
+    /**
139
+     * 获取消息数量
140
+     * @param orgId
141
+     * @return
142
+     */
143
+    @Override
144
+    public Map<String, Object> getMessageTotal(Integer orgId, Integer verifyId) {
145
+        return messageMapper.getMessageTotal(verifyId,orgId);
146
+    }
147
+
148
+    /**
149
+     * 分页获取消息或待办
150
+     * @param orgId
151
+     * @param pageNum
152
+     * @param pageSize
153
+     * @param modelType
154
+     * @return
155
+     */
156
+    @Override
157
+    public Map<String,Object> getMessages(Integer orgId, Integer pageNum, Integer pageSize,Integer modelType, Integer verifyId) {
158
+        //使用分页插件
159
+        Page<Message> page = new Page(pageNum, pageSize);
160
+        // 获取数据
161
+        IPage<Message> messagePage = messageMapper.getMessages(page,verifyId,orgId, modelType);
162
+        List<Message> messageList = messagePage.getRecords();
163
+        // 查找标题
164
+        for (Message tpMessage:messageList){
165
+            // 工单
166
+            if (Constant.MESSAGE_UUID_TYPE_TICKET.equals(tpMessage.getMessageUuidType())) {
167
+                TpTicket tpTicket = tpTicketMapper.selectById(tpMessage.getMessageUuid());
168
+                tpMessage.setContent(tpTicket.getTicketTitle());
169
+            }
170
+            // 话题
171
+            if (Constant.MESSAGE_UUID_TYPE_TRANSACTION.equals(tpMessage.getMessageUuidType())){
172
+                TpTransaction tpTransaction = tpTransactionMapper.selectByPrimaryKey(tpMessage.getMessageUuid(),tpMessage.getOrgId());
173
+                tpMessage.setContent(tpTransaction.getTransactionTitle());
174
+            }
175
+            // 公告
176
+            if (Constant.MESSAGE_UUID_TYPE_ANNOUNCEMENT.equals(tpMessage.getMessageUuidType())){
177
+                TpAnnouncement tpAnnouncement = tpAnnouncementMapper.selectByPrimaryKey(tpMessage.getMessageUuid(),tpMessage.getOrgId());
178
+                tpMessage.setContent(tpAnnouncement.getAnnouncementTitle());
179
+            }
180
+            // 活动
181
+            if (Constant.MESSAGE_UUID_TYPE_ACTIVITY.equals(tpMessage.getMessageUuidType())){
182
+                TpActivity tpActivity = tpActivityMapper.selectById(tpMessage.getMessageUuid());
183
+                tpMessage.setContent(tpActivity.getActivityTitle());
184
+            }
185
+            // 收费组名称
186
+            if (Constant.MESSAGE_UUID_TYPE_BILL.equals(tpMessage.getMessageUuidType())){
187
+                Bill tpBill = tpBillMapper.selectById(tpMessage.getMessageUuid());
188
+                tpMessage.setContent(tpBill.getBillName());
189
+            }
190
+            // 商铺
191
+            if (Constant.MESSAGE_UUID_TYPE_SHOP.equals(tpMessage.getMessageUuidType())){
192
+                TpShop tpShop = tpShopMapper.selectById(tpMessage.getMessageUuid());
193
+                tpMessage.setContent(tpShop.getShopName());
194
+            }
195
+
196
+            //活动被作废
197
+            if (Constant.MESSAGE_UUID_TYPE_ACTIVITY.equals(tpMessage.getMessageUuidType())){
198
+                Message message = messageMapper.selectById(tpMessage.getId());
199
+                if(Constant.ACTIVITY_CANCELLED.equals(message.getMessageType())) {
200
+                    tpMessage.setMessageDetailUrl(null);
201
+                    tpMessage.setContent(null);
202
+                }
203
+            }
204
+            //话题被作废
205
+            if(Constant.MESSAGE_UUID_TYPE_TRANSACTION.equals(tpMessage.getMessageUuidType())){
206
+                Message message = messageMapper.selectById(tpMessage.getId());
207
+                if(Constant.THREAD_CANCELLED.equals(message.getMessageType())){
208
+                    tpMessage.setMessageDetailUrl(null);
209
+                    tpMessage.setContent(null);
210
+                }
211
+            }
212
+        }
213
+        Map<String,Object> map = new HashMap<>();
214
+        map.put("list",messageList);
215
+        map.put("total",page.getTotal());
216
+        return map;
217
+    }
218
+
219
+    /**
220
+     * 消息全部已读
221
+     */
222
+    @Override
223
+    public void updateMessageReadStatus(Integer orgId, Integer userId) {
224
+        messageMapper.updateReadStatus(orgId, userId);
225
+    }
226
+
227
+    @Override
228
+    public ResponseBean updateMessageByIdReadStatus(TaUser userElement, Integer messageId) {
229
+        ResponseBean responseBean = new ResponseBean();
230
+
231
+        Message tpMessage = messageMapper.selectById(messageId);
232
+        if (null == tpMessage) {
233
+            responseBean.addError("消息不存在!");
234
+            return responseBean;
235
+        }
236
+        tpMessage.setReadStatus("1");
237
+        tpMessage.setUpdateDate(LocalDateTime.now());
238
+        tpMessage.setUpdateUser(userElement.getUserId());
239
+        int row = messageMapper.updateById(tpMessage);
240
+        if (row > 0) {
241
+            responseBean.addSuccess("操作成功!");
242
+            return responseBean;
243
+        }
244
+        responseBean.addError("操作失败!");
245
+        return responseBean;
246
+    }
247
+
248
+    /**
249
+     * 根据消息ID 查询详情数据
250
+     *
251
+     * @param orgId
252
+     * @param messageId
253
+     * @return
254
+     */
255
+    @Override
256
+    public ResponseBean getMessageById(Integer orgId, Integer messageId) {
257
+        ResponseBean responseBean = new ResponseBean();
258
+        Message tpMessage = messageMapper.selectById(messageId);
259
+        if (null != tpMessage){
260
+            // 设置当前工单类型
261
+            if (Constant.MESSAGE_UUID_TYPE_TICKET.equals(tpMessage.getMessageUuidType())){
262
+                TpTicket tpTicket= tpTicketMapper.selectById(tpMessage.getMessageUuid());
263
+                tpMessage.setTicketType(tpTicket.getType());
264
+            }
265
+            // 当前发帖人是否存在(app发帖)
266
+            if (Constant.MESSAGE_UUID_TYPE_TRANSACTION.equals(tpMessage.getMessageUuidType())){
267
+                TpTransaction tpTransaction = tpTransactionMapper.selectByPrimaryKey(tpMessage.getMessageUuid(),tpMessage.getOrgId());
268
+                if ("app".equals(tpTransaction.getUuidType())){
269
+                    TaUserVerify taUserVerify = taUserVerifyMapper.selectById(tpTransaction.getUuid());
270
+                    if (null == taUserVerify){
271
+                        responseBean.addError("此贴已丢失,无法查看");
272
+                        return  responseBean;
273
+                    }
274
+                }
275
+            }
276
+            responseBean.addSuccess(tpMessage);
277
+            return responseBean;
278
+        }
279
+        responseBean.addError("不存在的ID");
280
+        return responseBean;
281
+    }
107 282
 }

+ 66
- 0
src/main/resources/mapper/property/MessageMapper.xml 파일 보기

@@ -149,4 +149,70 @@
149 149
         order by create_date ASC
150 150
         LIMIT 1
151 151
     </update>
152
+
153
+    <select id="getMessageTotal" resultType="map">
154
+    SELECT
155
+        count( CASE WHEN model_type = 1 AND read_status = 0 THEN 1 ELSE NULL END ) AS messageTotal,
156
+        count( CASE WHEN model_type = 2 AND status = 1 THEN 1 ELSE NULL END ) AS toDoTotal
157
+    FROM
158
+        tp_message
159
+    WHERE
160
+        uuid_type = "app"
161
+        AND org_id = #{orgId,jdbcType=INTEGER}
162
+        AND uuid = #{userId,jdbcType=INTEGER}
163
+        AND STATUS = 1
164
+        AND advice_type != 1
165
+  </select>
166
+
167
+    <select id="getMessages" resultType="com.huiju.estateagents.property.model.Message">
168
+    SELECT
169
+        t.id,
170
+        t.community_id,
171
+        t.message_type AS new_message_type,
172
+        CASE
173
+          WHEN t.message_type = 9 THEN
174
+              9
175
+        ELSE
176
+            2
177
+        END message_type,
178
+        t.advice_type,
179
+        t.model_type,
180
+        t.uuid,
181
+        t.uuid_type,
182
+        t.source,
183
+        t.message_content,
184
+        t.result,
185
+        t.meaasge_type_id,
186
+        t.read_status,
187
+        t.create_user,
188
+        t.create_date,
189
+        t.update_user,
190
+        t.update_date,
191
+        t.message_uuid,
192
+        t.message_uuid_type,
193
+        i.read_message_icon,
194
+        i.unread_message_icon,
195
+        CONCAT( i.message_detail_url, t.id ) AS message_detail_url,
196
+        i.message_icon_title
197
+    FROM
198
+        tp_message t
199
+        LEFT JOIN tp_message_icon i ON t.message_type = i.message_type
200
+    WHERE
201
+        t.uuid_type = "app"
202
+        AND t.community_id = #{communityId,jdbcType=INTEGER}
203
+        AND t.uuid = #{userId,jdbcType=INTEGER}
204
+        AND t.STATUS = 1
205
+        AND t.advice_type != 1
206
+        AND t.model_type = #{modelType,jdbcType=INTEGER}
207
+    ORDER BY
208
+    t.create_date DESC , t.id
209
+  </select>
210
+
211
+    <update id="updateReadStatus" parameterType="java.lang.Integer" >
212
+    update tp_message
213
+    set
214
+      read_status = 1
215
+    where org_id = #{orgId}
216
+    and uuid = #{userId}
217
+  </update>
152 218
 </mapper>

+ 8
- 0
src/main/resources/mapper/property/TpTransactionMapper.xml 파일 보기

@@ -37,4 +37,12 @@
37 37
         t.id
38 38
         ORDER BY t.create_date desc
39 39
     </select>
40
+
41
+
42
+    <select id="selectByPrimaryKey" resultType="com.huiju.estateagents.property.model.TpTransaction" parameterType="com.huiju.estateagents.property.model.TpTransaction">
43
+        select
44
+         *
45
+        from tp_transaction ttr
46
+        where ttr.id = #{id,jdbcType=INTEGER} and ttr.community_id=#{communityId,jdbcType=INTEGER}
47
+    </select>
40 48
 </mapper>