Showing
1 changed file
with
55 additions
and
48 deletions
@@ -95,57 +95,30 @@ public class BaseNoticeFacade { | @@ -95,57 +95,30 @@ public class BaseNoticeFacade { | ||
95 | 95 | ||
96 | public void send() { | 96 | public void send() { |
97 | executorService.execute(() -> { | 97 | executorService.execute(() -> { |
98 | - final Logger log = getLogger(); | ||
99 | final String logPrefix = getReplacedContent("{} send uid {}", this.logPrefix, this.uid); | 98 | final String logPrefix = getReplacedContent("{} send uid {}", this.logPrefix, this.uid); |
100 | - log.warn("{}, inBoxContent {} smsContent {}", logPrefix, inBoxContent, smsContent); | ||
101 | - | ||
102 | - // 发送站内信 | ||
103 | - InboxReqVO inBoxContent = getInBoxContentWhenExceptionAnd(e -> { | ||
104 | - log.warn("{}, send in box fail, get content fail", logPrefix, e); | ||
105 | - return null; | ||
106 | - }); | ||
107 | - if (Objects.nonNull(inBoxContent)) { | ||
108 | - try { | ||
109 | - inBoxContent.setUid(uid); | ||
110 | - InBoxResponse resp = inBoxSDK.addInbox(inBoxContent); | ||
111 | - log.info("{}, send in box success content {} response {}", logPrefix, inBoxContent, JSON.toJSON(resp)); | ||
112 | - } catch (Exception e) { | ||
113 | - log.warn("{}, send in box fail content {}", logPrefix, inBoxContent, e); | ||
114 | - } | ||
115 | - } | ||
116 | - | ||
117 | - // 发送PUSH | ||
118 | - if (Objects.nonNull(pushSupplier)) { | ||
119 | - try { | ||
120 | - SendMessageRspBo resp = pushSupplier.get(); | ||
121 | - log.info("{}, send push success, response {}", logPrefix, JSON.toJSON(resp)); | ||
122 | - } catch (Exception e) { | ||
123 | - log.warn("{}, send push fail", logPrefix, e); | ||
124 | - } | ||
125 | - } | ||
126 | - | ||
127 | - // 发送短信 | ||
128 | - String smsContent = getSmsContentWhenExceptionAnd(e -> { | ||
129 | - log.warn("{}, send sms fail, get content fail", logPrefix, e); | ||
130 | - return null; | ||
131 | - }); | ||
132 | - if (Objects.nonNull(smsContent)) { | ||
133 | - try { | ||
134 | - String phone = userProxyService.getMobile(uid); | ||
135 | - if (StringUtils.isBlank(phone)) { | ||
136 | - log.warn("{}, send sms fail content {} phone is blank", logPrefix, smsContent); | ||
137 | - } else { | ||
138 | - List<String> mobileList = Arrays.asList(phone); | ||
139 | - sendSmsService.smsSendByMobile(smsContent, mobileList); | ||
140 | - log.info("{}, send sms success content {} phone {} ", logPrefix, smsContent, phone); | ||
141 | - } | ||
142 | - } catch (Exception e) { | ||
143 | - log.warn("{}, send sms fail content {}", logPrefix, smsContent, e); | ||
144 | - } | ||
145 | - } | 99 | + log.info("{}, start", logPrefix); |
100 | + sendInbox(logPrefix); | ||
101 | + sendPush(logPrefix); | ||
102 | + sendSms(logPrefix); | ||
103 | + log.info("{}, end", logPrefix); | ||
104 | + }); | ||
105 | + } | ||
146 | 106 | ||
147 | - // END | 107 | + private void sendInbox(String logPrefix) { |
108 | + final Logger log = getLogger(); | ||
109 | + InboxReqVO inBoxContent = getInBoxContentWhenExceptionAnd(e -> { | ||
110 | + log.warn("{}, send in box fail, get content fail", logPrefix, e); | ||
111 | + return null; | ||
148 | }); | 112 | }); |
113 | + if (Objects.nonNull(inBoxContent)) { | ||
114 | + try { | ||
115 | + inBoxContent.setUid(uid); | ||
116 | + InBoxResponse resp = inBoxSDK.addInbox(inBoxContent); | ||
117 | + log.info("{}, send in box success content {} response {}", logPrefix, JSON.toJSON(inBoxContent), JSON.toJSON(resp)); | ||
118 | + } catch (Exception e) { | ||
119 | + log.warn("{}, send in box fail content {}", logPrefix, JSON.toJSON(inBoxContent), e); | ||
120 | + } | ||
121 | + } | ||
149 | } | 122 | } |
150 | 123 | ||
151 | private InboxReqVO getInBoxContentWhenExceptionAnd(Function<Exception, InboxReqVO> exceptionFunction) { | 124 | private InboxReqVO getInBoxContentWhenExceptionAnd(Function<Exception, InboxReqVO> exceptionFunction) { |
@@ -160,6 +133,40 @@ public class BaseNoticeFacade { | @@ -160,6 +133,40 @@ public class BaseNoticeFacade { | ||
160 | } | 133 | } |
161 | } | 134 | } |
162 | 135 | ||
136 | + private void sendPush(String logPrefix) { | ||
137 | + final Logger log = getLogger(); | ||
138 | + if (Objects.nonNull(pushSupplier)) { | ||
139 | + try { | ||
140 | + SendMessageRspBo resp = pushSupplier.get(); | ||
141 | + log.info("{}, send push success, response {}", logPrefix, JSON.toJSON(resp)); | ||
142 | + } catch (Exception e) { | ||
143 | + log.warn("{}, send push fail", logPrefix, e); | ||
144 | + } | ||
145 | + } | ||
146 | + } | ||
147 | + | ||
148 | + private void sendSms(String logPrefix) { | ||
149 | + final Logger log = getLogger(); | ||
150 | + String smsContent = getSmsContentWhenExceptionAnd(e -> { | ||
151 | + log.warn("{}, send sms fail, get content fail", logPrefix, e); | ||
152 | + return null; | ||
153 | + }); | ||
154 | + if (Objects.nonNull(smsContent)) { | ||
155 | + try { | ||
156 | + String phone = userProxyService.getMobile(uid); | ||
157 | + if (StringUtils.isBlank(phone)) { | ||
158 | + log.warn("{}, send sms fail content {} phone is blank", logPrefix, smsContent); | ||
159 | + } else { | ||
160 | + List<String> mobileList = Arrays.asList(phone); | ||
161 | + sendSmsService.smsSendByMobile(smsContent, mobileList); | ||
162 | + log.info("{}, send sms success content {} phone {} ", logPrefix, smsContent, phone); | ||
163 | + } | ||
164 | + } catch (Exception e) { | ||
165 | + log.warn("{}, send sms fail content {}", logPrefix, smsContent, e); | ||
166 | + } | ||
167 | + } | ||
168 | + } | ||
169 | + | ||
163 | private String getSmsContentWhenExceptionAnd(Function<Exception, String> exceptionFunction) { | 170 | private String getSmsContentWhenExceptionAnd(Function<Exception, String> exceptionFunction) { |
164 | if (Objects.nonNull(smsContentSupplier)) { | 171 | if (Objects.nonNull(smsContentSupplier)) { |
165 | try { | 172 | try { |
-
Please register or login to post a comment