|
@@ -40,6 +40,7 @@ import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
|
40
|
40
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
41
|
41
|
import org.apache.poi.hssf.usermodel.*;
|
42
|
42
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
43
|
+import org.springframework.beans.factory.annotation.Value;
|
43
|
44
|
import org.springframework.stereotype.Service;
|
44
|
45
|
import org.springframework.transaction.annotation.Transactional;
|
45
|
46
|
|
|
@@ -114,6 +115,9 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
|
114
|
115
|
@Autowired
|
115
|
116
|
private TaPersonMapper taPersonMapper;
|
116
|
117
|
|
|
118
|
+ @Value("${wx.miniapp.propertyPay}")
|
|
119
|
+ String propertyPayPage;
|
|
120
|
+
|
117
|
121
|
@Override
|
118
|
122
|
public ResponseBean getBillList(String parameter, TaUser userElement) {
|
119
|
123
|
ResponseBean responseBean = new ResponseBean();
|
|
@@ -727,32 +731,21 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
|
727
|
731
|
public ResponseBean collectionBillList(BillInvoice billInvoice, TaUser userElement) {
|
728
|
732
|
LambdaQueryWrapper<BillInvoice> queryWrapper = new LambdaQueryWrapper<>();
|
729
|
733
|
queryWrapper.eq(BillInvoice::getBillId,billInvoice.getBillId());
|
|
734
|
+ queryWrapper.eq(BillInvoice::getBillStatus,CommConstant.BILL_STATUS_UNPAID);
|
730
|
735
|
queryWrapper.eq(BillInvoice::getStatus,"1");
|
731
|
736
|
List<BillInvoice> billInvoices = billInvoiceMapper.selectList(queryWrapper);
|
732
|
737
|
// 发送催缴消息
|
733
|
738
|
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
|
|
- }
|
|
739
|
+ // 根据房间号获取person信息
|
|
740
|
+ List<TaMpMiniapp> taMpMiniappList = taMpMiniappMapper.getByRoom(billInvoice.getOrgId(), billInvoice.getRoomNoId());
|
|
741
|
+ if (null != taMpMiniappList) {
|
|
742
|
+ for (TaMpMiniapp taMpMiniapp : taMpMiniappList) {
|
|
743
|
+ sendMpBillMessage(e, taMpMiniapp);
|
|
744
|
+ try {
|
|
745
|
+ // 一秒发一次
|
|
746
|
+ Thread.sleep(1000);
|
|
747
|
+ } catch (InterruptedException ex) {
|
|
748
|
+ ex.printStackTrace();
|
756
|
749
|
}
|
757
|
750
|
|
758
|
751
|
}
|
|
@@ -767,7 +760,7 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
|
767
|
760
|
* @param billInvoice
|
768
|
761
|
* @param person
|
769
|
762
|
*/
|
770
|
|
- private void sendMpBillMessage(BillInvoice billInvoice, TaMpPerson person) {
|
|
763
|
+ private void sendMpBillMessage(BillInvoice billInvoice, TaMpMiniapp person) {
|
771
|
764
|
WxMpService mpService = wxUtils.getMpService(billInvoice.getOrgId());
|
772
|
765
|
|
773
|
766
|
// 对应表数据
|
|
@@ -775,50 +768,31 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
|
775
|
768
|
|
776
|
769
|
TaMiniapp taMiniapp = iMiniAppService.getAppByOrg(mpInfo.getOrgId());
|
777
|
770
|
|
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();
|
|
771
|
+ TaMpTemplate mpTemplate = iTaMpTemplateService.getByCode(billInvoice.getOrgId(), CommConstant.TP_MESSAGE_PROPERTY_FEE);
|
|
772
|
+ if (null == mpTemplate) {
|
|
773
|
+ return;
|
|
774
|
+ }
|
784
|
775
|
|
785
|
776
|
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
|
|
-
|
|
777
|
+ String message = String.format("待缴费用: %s", StringUtils.isEmpty(billInvoice.getBillInvoiceExplain()) ? "未知" : billInvoice.getBillInvoiceExplain());
|
|
778
|
+ String remark = String.format("请及时进入【%s】小程序完成缴费", taMiniapp.getName());
|
|
779
|
+
|
|
780
|
+ WxUtils.sendTemplateMessage(mpService,
|
|
781
|
+ person.getMpPersonId(),
|
|
782
|
+ mpTemplate.getTemplateCode(),
|
|
783
|
+ taMiniapp.getMiniappId(),
|
|
784
|
+ propertyPayPage,
|
|
785
|
+ null,
|
|
786
|
+ new ArrayList<WxMpTemplateData>(){{
|
|
787
|
+ add(new WxMpTemplateData("first", "缴费提醒"));
|
|
788
|
+ add(new WxMpTemplateData("keyword1", "您有一个代缴费用"));
|
|
789
|
+ add(new WxMpTemplateData("keyword2", DateUtils.today()));
|
|
790
|
+ add(new WxMpTemplateData("keyword3", message));
|
|
791
|
+ add(new WxMpTemplateData("remark", remark));
|
|
792
|
+ }}
|
|
793
|
+ );
|
|
794
|
+ } catch (Exception e2) {
|
|
795
|
+ e2.printStackTrace();
|
822
|
796
|
}
|
823
|
797
|
}
|
824
|
798
|
}
|