|
|
@@ -0,0 +1,68 @@
|
|
|
+package com.uas.service.donate.impl;
|
|
|
+
|
|
|
+import com.uas.message.mail.service.MailService;
|
|
|
+import com.uas.platform.core.util.HttpUtil;
|
|
|
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
+import com.uas.service.donate.MessageConfiguration;
|
|
|
+import com.uas.service.donate.model.SmsMessage;
|
|
|
+import com.uas.service.donate.service.MessageService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 发送消息提醒实现方法
|
|
|
+ *
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class MessageServiceImpl implements MessageService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MailService mailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MessageConfiguration messageConfiguration;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseEntity<String> sendMail(String receivedEmail, Map<String, Object> model) {
|
|
|
+ try {
|
|
|
+ if (null != messageConfiguration.getTplInvitationForB2B()) {
|
|
|
+ model.put("vendorusername", "");
|
|
|
+ model.put("vendorname", "");
|
|
|
+ model.put("custname", "");
|
|
|
+ model.put("inviteuid", "");
|
|
|
+ model.put("inviteUserCode", "");
|
|
|
+ mailService.send(messageConfiguration.getTplInvitationForB2B(), receivedEmail, model);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseEntity<String> sendMessage(String receiverTel, List<Object> obj) {
|
|
|
+ try {
|
|
|
+ if (null != messageConfiguration.getMsgInvitationForB2B()) {
|
|
|
+ SmsMessage sms = new SmsMessage();
|
|
|
+// obj.add(record.getVendusername());
|
|
|
+// obj.add(record.getVendname());
|
|
|
+// obj.add(SystemSession.getUser().getUserName() + "("
|
|
|
+// + SystemSession.getUser().getEnterprise().getEnName() + ")");
|
|
|
+ sms.setParams(obj);
|
|
|
+ sms.setReceiver(receiverTel);
|
|
|
+ sms.setTemplateId(messageConfiguration.getMsgInvitationForB2B());
|
|
|
+ HttpUtil.sendPost(messageConfiguration.getMessageSendUrl(), FlexJsonUtils.toJsonDeep(sms));
|
|
|
+ }
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|