|
@@ -1,6 +1,7 @@
|
1
|
1
|
package com.huiju.estateagents.property.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.alibaba.fastjson.JSONObject;
|
|
4
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
4
|
5
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
5
|
6
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
6
|
7
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -8,8 +9,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
8
|
9
|
import com.huiju.estateagents.base.ResponseBean;
|
9
|
10
|
import com.huiju.estateagents.center.taUser.entity.TaUser;
|
10
|
11
|
import com.huiju.estateagents.center.taUser.mapper.TaUserMapper;
|
|
12
|
+import com.huiju.estateagents.common.CommConstant;
|
11
|
13
|
import com.huiju.estateagents.common.DateUtils;
|
12
|
14
|
import com.huiju.estateagents.common.StringUtils;
|
|
15
|
+import com.huiju.estateagents.common.WxUtils;
|
|
16
|
+import com.huiju.estateagents.entity.TaMiniapp;
|
|
17
|
+import com.huiju.estateagents.entity.TaMpTemplate;
|
|
18
|
+import com.huiju.estateagents.entity.TaPerson;
|
|
19
|
+import com.huiju.estateagents.mapper.TaPersonMapper;
|
13
|
20
|
import com.huiju.estateagents.property.common.UserElement;
|
14
|
21
|
import com.huiju.estateagents.property.dao.*;
|
15
|
22
|
import com.huiju.estateagents.property.exception.WisdomException;
|
|
@@ -17,6 +24,20 @@ import com.huiju.estateagents.property.model.*;
|
17
|
24
|
import com.huiju.estateagents.property.service.IBillInvoiceService;
|
18
|
25
|
import com.huiju.estateagents.property.service.IMessageService;
|
19
|
26
|
import com.google.common.collect.Maps;
|
|
27
|
+import com.huiju.estateagents.redpack.entity.TaMpMiniapp;
|
|
28
|
+import com.huiju.estateagents.redpack.entity.TaMpPerson;
|
|
29
|
+import com.huiju.estateagents.redpack.mapper.TaMpMiniappMapper;
|
|
30
|
+import com.huiju.estateagents.redpack.mapper.TaMpPersonMapper;
|
|
31
|
+import com.huiju.estateagents.redpack.service.ITaMpPersonService;
|
|
32
|
+import com.huiju.estateagents.service.IMiniAppService;
|
|
33
|
+import com.huiju.estateagents.service.ITaMpTemplateService;
|
|
34
|
+import com.huiju.estateagents.service.ITaPersonService;
|
|
35
|
+import com.huiju.estateagents.third.entity.TaMpInfo;
|
|
36
|
+import com.huiju.estateagents.third.service.ITaMpInfoService;
|
|
37
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
38
|
+import me.chanjar.weixin.mp.api.WxMpService;
|
|
39
|
+import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
|
|
40
|
+import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
20
|
41
|
import org.apache.poi.hssf.usermodel.*;
|
21
|
42
|
import org.springframework.beans.factory.annotation.Autowired;
|
22
|
43
|
import org.springframework.stereotype.Service;
|
|
@@ -24,10 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
|
24
|
45
|
|
25
|
46
|
import java.text.SimpleDateFormat;
|
26
|
47
|
import java.time.LocalDateTime;
|
27
|
|
-import java.util.Date;
|
28
|
|
-import java.util.List;
|
29
|
|
-import java.util.Map;
|
30
|
|
-import java.util.Random;
|
|
48
|
+import java.util.*;
|
31
|
49
|
import java.util.stream.Collectors;
|
32
|
50
|
|
33
|
51
|
/**
|
|
@@ -71,6 +89,31 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
|
71
|
89
|
@Autowired
|
72
|
90
|
private TpBillOrderMapper tpBillOrderMapper;
|
73
|
91
|
|
|
92
|
+ @Autowired
|
|
93
|
+ WxUtils wxUtils;
|
|
94
|
+
|
|
95
|
+ @Autowired
|
|
96
|
+ ITaMpInfoService iTaMpInfoService;
|
|
97
|
+
|
|
98
|
+ @Autowired
|
|
99
|
+ ITaMpPersonService iTaMpPersonService;
|
|
100
|
+
|
|
101
|
+ @Autowired
|
|
102
|
+ ITaPersonService iTaPersonService;
|
|
103
|
+ @Autowired
|
|
104
|
+ private IMiniAppService iMiniAppService;
|
|
105
|
+
|
|
106
|
+ @Autowired
|
|
107
|
+ private ITaMpTemplateService iTaMpTemplateService;
|
|
108
|
+
|
|
109
|
+ @Autowired
|
|
110
|
+ private TaMpMiniappMapper taMpMiniappMapper;
|
|
111
|
+
|
|
112
|
+ @Autowired
|
|
113
|
+ private TaMpPersonMapper taMpPersonMapper;
|
|
114
|
+ @Autowired
|
|
115
|
+ private TaPersonMapper taPersonMapper;
|
|
116
|
+
|
74
|
117
|
@Override
|
75
|
118
|
public ResponseBean getBillList(String parameter, TaUser userElement) {
|
76
|
119
|
ResponseBean responseBean = new ResponseBean();
|
|
@@ -672,4 +715,110 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
|
672
|
715
|
public List<Map<String, Object>> getPriceCount() {
|
673
|
716
|
return billInvoiceMapper.getPriceCount();
|
674
|
717
|
}
|
|
718
|
+
|
|
719
|
+ /**
|
|
720
|
+ * 催缴账单
|
|
721
|
+ *
|
|
722
|
+ * @param billInvoice
|
|
723
|
+ * @param userElement
|
|
724
|
+ * @return
|
|
725
|
+ */
|
|
726
|
+ @Override
|
|
727
|
+ public ResponseBean collectionBillList(BillInvoice billInvoice, TaUser userElement) {
|
|
728
|
+ LambdaQueryWrapper<BillInvoice> queryWrapper = new LambdaQueryWrapper<>();
|
|
729
|
+ queryWrapper.eq(BillInvoice::getBillId,billInvoice.getBillId());
|
|
730
|
+ queryWrapper.eq(BillInvoice::getStatus,"1");
|
|
731
|
+ List<BillInvoice> billInvoices = billInvoiceMapper.selectList(queryWrapper);
|
|
732
|
+ // 发送催缴消息
|
|
733
|
+ billInvoices.forEach(e -> {
|
|
734
|
+ if (CommConstant.BILL_STATUS_UNPAID.equals(e.getBillStatus())){
|
|
735
|
+ // 根据房间号获取person信息
|
|
736
|
+ LambdaQueryWrapper<TaUserVerify> taUserVerifyLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
737
|
+ taUserVerifyLambdaQueryWrapper.eq(TaUserVerify::getRoomNoId,e.getRoomNoId());
|
|
738
|
+ taUserVerifyLambdaQueryWrapper.eq(TaUserVerify::getRoleId,"1");
|
|
739
|
+ TaUserVerify taUserVerify = taUserVerifyMapper.selectOne(taUserVerifyLambdaQueryWrapper);
|
|
740
|
+
|
|
741
|
+ // 获取person
|
|
742
|
+ TaPerson taPerson = taPersonMapper.selectById(taUserVerify.getPersonId());
|
|
743
|
+ if (null != taPerson){
|
|
744
|
+ LambdaQueryWrapper<TaMpMiniapp> taMpMiniappLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
745
|
+ taMpMiniappLambdaQueryWrapper.eq(TaMpMiniapp::getMiniappPersonId,taPerson.getPersonId());
|
|
746
|
+ TaMpMiniapp taMpMiniapp = taMpMiniappMapper.selectOne(taMpMiniappLambdaQueryWrapper);
|
|
747
|
+ if (null != taMpMiniapp){
|
|
748
|
+ TaMpPerson taMpPerson = taMpPersonMapper.selectById(taMpMiniapp.getMpPersonId());
|
|
749
|
+ sendMpBillMessage(e,taMpPerson);
|
|
750
|
+ try {
|
|
751
|
+ // 一秒发一次
|
|
752
|
+ Thread.sleep(1000);
|
|
753
|
+ } catch (InterruptedException ex) {
|
|
754
|
+ ex.printStackTrace();
|
|
755
|
+ }
|
|
756
|
+ }
|
|
757
|
+
|
|
758
|
+ }
|
|
759
|
+ }
|
|
760
|
+ });
|
|
761
|
+
|
|
762
|
+ return ResponseBean.success("ok");
|
|
763
|
+ }
|
|
764
|
+
|
|
765
|
+ /**
|
|
766
|
+ * 发送催款消息
|
|
767
|
+ * @param billInvoice
|
|
768
|
+ * @param person
|
|
769
|
+ */
|
|
770
|
+ private void sendMpBillMessage(BillInvoice billInvoice, TaMpPerson person) {
|
|
771
|
+ WxMpService mpService = wxUtils.getMpService(billInvoice.getOrgId());
|
|
772
|
+
|
|
773
|
+ // 对应表数据
|
|
774
|
+ TaMpInfo mpInfo = iTaMpInfoService.getByOrgId(billInvoice.getOrgId());
|
|
775
|
+
|
|
776
|
+ TaMiniapp taMiniapp = iMiniAppService.getAppByOrg(mpInfo.getOrgId());
|
|
777
|
+
|
|
778
|
+ WxMpKefuMessage kefuMessage = WxMpKefuMessage.MINIPROGRAMPAGE().appId(taMiniapp.getMiniappId())
|
|
779
|
+ .toUser(person.getMpOpenid())
|
|
780
|
+ .title("您有一个新的工单待处理")
|
|
781
|
+// .pagePath(miniAppTicket + ticket.getId()) 无跳转页面
|
|
782
|
+ .thumbMediaId(mpInfo.getMiniappMedia())
|
|
783
|
+ .build();
|
|
784
|
+
|
|
785
|
+ try {
|
|
786
|
+ mpService.getKefuService().sendKefuMessage(kefuMessage);
|
|
787
|
+ } catch (WxErrorException e) {
|
|
788
|
+ e.printStackTrace();
|
|
789
|
+
|
|
790
|
+ // 如果客服消息发送失败, 则发送普通模板消息
|
|
791
|
+// List<TaMpTemplate> mpTemplateList = iTaMpTemplateService.getAvailableList(ticket.getOrgId(), CommConstant.TP_MESSAGE_TICKET);
|
|
792
|
+// if (null == mpTemplateList || mpTemplateList.size() < 1) {
|
|
793
|
+// return;
|
|
794
|
+// }
|
|
795
|
+ TaMpTemplate mpTemplate = iTaMpTemplateService.getByCode(billInvoice.getOrgId(), CommConstant.TP_MESSAGE_PROPERTY_FEE);
|
|
796
|
+ if (null == mpTemplate) {
|
|
797
|
+ return;
|
|
798
|
+ }
|
|
799
|
+
|
|
800
|
+ try {
|
|
801
|
+// TaPerson propOwner = iTaPersonService.getById(ticket.getPersonId());
|
|
802
|
+// String message = String.format("业主电话: %s ; 报修内容: %s", propOwner.getPhone(), ticket.getTicketTitle());
|
|
803
|
+ String message = "";
|
|
804
|
+ String remark = String.format("请及时进入【%s】小程序进行处理", taMiniapp.getName());
|
|
805
|
+
|
|
806
|
+ WxUtils.sendTemplateMessage(mpService,
|
|
807
|
+ person.getMpOpenid(),
|
|
808
|
+ mpTemplate.getTemplateCode(),
|
|
809
|
+ null,
|
|
810
|
+ new ArrayList<WxMpTemplateData>(){{
|
|
811
|
+ add(new WxMpTemplateData("first", "工单提醒"));
|
|
812
|
+ add(new WxMpTemplateData("keyword1", "您有一个新的工单"));
|
|
813
|
+ add(new WxMpTemplateData("keyword2", DateUtils.today()));
|
|
814
|
+ add(new WxMpTemplateData("keyword3", message));
|
|
815
|
+ add(new WxMpTemplateData("remark", remark));
|
|
816
|
+ }}
|
|
817
|
+ );
|
|
818
|
+ } catch (Exception e2) {
|
|
819
|
+ e2.printStackTrace();
|
|
820
|
+ }
|
|
821
|
+
|
|
822
|
+ }
|
|
823
|
+ }
|
675
|
824
|
}
|