|
@@ -548,4 +548,47 @@ public class MiniAppServiceImpl implements IMiniAppService {
|
548
|
548
|
|
549
|
549
|
return taMiniappMapper.selectOne(queryWrapper);
|
550
|
550
|
}
|
|
551
|
+
|
|
552
|
+ public void sendContractMessage(TaPerson toUser, String link, String name, String result, String programName,
|
|
553
|
+ String failReason, String remark, LocalDateTime dt, Boolean isSuccess) {
|
|
554
|
+
|
|
555
|
+ TaMiniapp miniapp = taMiniappMapper.selectById(toUser.getMiniappId());
|
|
556
|
+ if (null == miniapp) {
|
|
557
|
+ log.error("小程序 {} 不存在", toUser.getMiniappId());
|
|
558
|
+ return;
|
|
559
|
+ }
|
|
560
|
+
|
|
561
|
+ // 消息内容类型
|
|
562
|
+ String contentType = CommConstant.MESSAGE_CONTENT_OF_HOUSE;
|
|
563
|
+ TaMiniappTemplate tpl = getTplByType(contentType, toUser.getMiniappId());
|
|
564
|
+ boolean isSubscribe = null != tpl && (null == tpl.getIsSubscribe() ? false : tpl.getIsSubscribe());
|
|
565
|
+ // 消息发送类型
|
|
566
|
+ String messageType = null == tpl ? CommConstant.MESSAGE_TYPE_OF_SMS :
|
|
567
|
+ isSubscribe ? CommConstant.MESSAGE_TYPE_OF_MINIAPP_SUBSCRIBE : CommConstant.MESSAGE_TYPE_OF_MINIAPP_TEMPLATE;
|
|
568
|
+
|
|
569
|
+ String[] smsParams = {programName, "电子合同待签署"};
|
|
570
|
+
|
|
571
|
+ if (null == tpl) {
|
|
572
|
+ if (isSuccess) {
|
|
573
|
+ log.error("小程序 {} 无通知消息模板 {}", toUser.getMiniappId(), contentType);
|
|
574
|
+ // 短信发送
|
|
575
|
+ sendSmsMessage(StringUtils.ifNull(toUser.getTel(), toUser.getPhone()), "contract", smsParams);
|
|
576
|
+ }
|
|
577
|
+ } else {
|
|
578
|
+ if (isSubscribe) {
|
|
579
|
+ String[] data = new String[]{name, result, programName, remark, failReason, DateUtils.cutSecond(dt)};
|
|
580
|
+ ResponseBean res = sendSubscribeMessage(tpl, toUser, link, data);
|
|
581
|
+ if (res.getCode() != ResponseBean.CODE_SUCCESS) {
|
|
582
|
+ // 使用短信发送
|
|
583
|
+ sendSmsMessage(StringUtils.ifNull(toUser.getTel(), toUser.getPhone()), "contract", smsParams);
|
|
584
|
+ messageType = CommConstant.MESSAGE_TYPE_OF_SMS;
|
|
585
|
+ }
|
|
586
|
+ } else {
|
|
587
|
+ log.info("发送模板消息");
|
|
588
|
+ }
|
|
589
|
+ }
|
|
590
|
+ // TODO 写消息发送日志
|
|
591
|
+ // 更新消息发送时间
|
|
592
|
+ iTaPersonMessageRuleService.saveOrUpdateByPersonAndMessage(toUser.getPersonId(), messageType, "contract", toUser.getOrgId());
|
|
593
|
+ }
|
551
|
594
|
}
|