浏览代码

chore[litemall-core]: 调整notify和express代码结果,以及调整配置命名以litemall开始

Junling Bu 7 年之前
父节点
当前提交
d12f3c4797
共有 33 个文件被更改,包括 643 次插入515 次删除
  1. 5 6
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminOrderController.java
  2. 1 1
      litemall-admin-api/src/test/java/org/linlinjava/litemall/admin/AdminConfigTest.java
  3. 1 1
      litemall-all/src/test/java/org/linlinjava/litemall/allinone/AllinoneConfigTest.java
  4. 17 8
      litemall-core/src/main/java/org/linlinjava/litemall/core/express/ExpressService.java
  5. 31 0
      litemall-core/src/main/java/org/linlinjava/litemall/core/express/config/ExpressAutoConfiguration.java
  6. 12 8
      litemall-core/src/main/java/org/linlinjava/litemall/core/express/config/ExpressConfig.java
  7. 0 93
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/LitemallNotifyService.java
  8. 0 50
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/MailSendService.java
  9. 160 0
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/NotifyService.java
  10. 18 0
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/NotifyType.java
  11. 0 61
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/SMSSendService.java
  12. 22 0
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/SmsSender.java
  13. 45 0
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/TencentSmsSender.java
  14. 1 5
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/WXTemplateSendService.java
  15. 0 54
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/MailNotifyConfig.java
  16. 54 0
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyAutoConfiguration.java
  17. 156 0
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyProperties.java
  18. 0 58
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/SMSNotifyConfig.java
  19. 0 31
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/WXNotifyConfig.java
  20. 0 58
      litemall-core/src/main/java/org/linlinjava/litemall/core/notify/util/ConfigUtil.java
  21. 44 38
      litemall-core/src/main/resources/application-core.yml
  22. 1 7
      litemall-core/src/test/java/org/linlinjava/litemall/core/CoreConfigTest.java
  23. 3 3
      litemall-core/src/test/java/org/linlinjava/litemall/core/MailTest.java
  24. 7 7
      litemall-core/src/test/java/org/linlinjava/litemall/core/SmsTest.java
  25. 37 0
      litemall-core/src/test/java/org/linlinjava/litemall/core/WxTemplateTest.java
  26. 1 1
      litemall-os-api/src/main/java/org/linlinjava/litemall/os/config/ObjectStorageConfig.java
  27. 2 2
      litemall-os-api/src/main/resources/application-os.yml
  28. 2 2
      litemall-os-api/src/test/java/org/linlinjava/litemall/os/OsTest.java
  29. 1 1
      litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/config/WxProperties.java
  30. 6 6
      litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java
  31. 7 6
      litemall-wx-api/src/main/resources/application-docker.yml
  32. 7 6
      litemall-wx-api/src/main/resources/application-wx.yml
  33. 2 2
      litemall-wx-api/src/test/java/org/linlinjava/litemall/wx/WxConfigTest.java

+ 5 - 6
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminOrderController.java

@@ -3,15 +3,14 @@ package org.linlinjava.litemall.admin.web;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.linlinjava.litemall.admin.annotation.LoginAdmin;
-import org.linlinjava.litemall.core.notify.LitemallNotifyService;
-import org.linlinjava.litemall.core.notify.util.ConfigUtil;
+import org.linlinjava.litemall.core.notify.NotifyService;
+import org.linlinjava.litemall.core.notify.NotifyType;
 import org.linlinjava.litemall.core.util.JacksonUtil;
 import org.linlinjava.litemall.db.domain.*;
 import org.linlinjava.litemall.db.service.LitemallOrderGoodsService;
 import org.linlinjava.litemall.db.service.LitemallOrderService;
 import org.linlinjava.litemall.db.service.LitemallProductService;
 import org.linlinjava.litemall.db.service.LitemallUserService;
-import org.linlinjava.litemall.db.util.OrderHandleOption;
 import org.linlinjava.litemall.db.util.OrderUtil;
 import org.linlinjava.litemall.core.util.ResponseUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,7 +45,7 @@ public class AdminOrderController {
     private LitemallUserService userService;
 
     @Autowired
-    private LitemallNotifyService litemallNotifyService;
+    private NotifyService notifyService;
 
     @GetMapping("/list")
     public Object list(@LoginAdmin Integer adminId,
@@ -153,7 +152,7 @@ public class AdminOrderController {
          * 注意订单号只发后6位
          *
          */
-        litemallNotifyService.notifySMSTemplate(order.getMobile(), ConfigUtil.NotifyType.REFUND, new String[]{order.getOrderSn().substring(8, 14)});
+        notifyService.notifySmsTemplate(order.getMobile(), NotifyType.REFUND, new String[]{order.getOrderSn().substring(8, 14)});
 
 
         txManager.commit(status);
@@ -207,7 +206,7 @@ public class AdminOrderController {
          * 您的订单已经发货,快递公司 {1},快递单 {2} ,请注意查收
          *
          */
-        litemallNotifyService.notifySMSTemplate(order.getMobile(), ConfigUtil.NotifyType.SHIP, new String[]{shipChannel, shipSn});
+        notifyService.notifySmsTemplate(order.getMobile(), NotifyType.SHIP, new String[]{shipChannel, shipSn});
 
         return ResponseUtil.ok();
     }

+ 1 - 1
litemall-admin-api/src/test/java/org/linlinjava/litemall/admin/AdminConfigTest.java

@@ -18,7 +18,7 @@ public class AdminConfigTest {
     @Test
     public void test() {
         // 测试获取application-core.yml配置信息
-        System.out.println(environment.getProperty("express.appId"));
+        System.out.println(environment.getProperty("litemall.express.appId"));
         // 测试获取application-db.yml配置信息
         System.out.println(environment.getProperty("spring.datasource.druid.url"));
         // 测试获取application-admin.yml配置信息

+ 1 - 1
litemall-all/src/test/java/org/linlinjava/litemall/allinone/AllinoneConfigTest.java

@@ -18,7 +18,7 @@ public class AllinoneConfigTest {
     @Test
     public void test() {
         // 测试获取application-core.yml配置信息
-        System.out.println(environment.getProperty("express.appId"));
+        System.out.println(environment.getProperty("litemall.express.appId"));
         // 测试获取application-db.yml配置信息
         System.out.println(environment.getProperty("spring.datasource.druid.url"));
         // 测试获取application-wx.yml配置信息

+ 17 - 8
litemall-core/src/main/java/org/linlinjava/litemall/core/express/ExpressService.java

@@ -1,12 +1,11 @@
 package org.linlinjava.litemall.core.express;
 
-import org.linlinjava.litemall.core.express.config.ExpressConfig;
+import org.linlinjava.litemall.core.express.config.ExpressProperties;
 import org.linlinjava.litemall.core.util.HttpUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.Base64Utils;
 
-import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.security.MessageDigest;
 import java.util.HashMap;
@@ -17,13 +16,19 @@ import java.util.Map;
  * <p>
  * 3831775044640 韵达快递(YD)
  */
-@Service
 public class ExpressService {
     //请求url
     private String ReqURL = "http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx";
 
-    @Autowired
-    ExpressConfig config;
+    private ExpressProperties properties;
+
+    public ExpressProperties getProperties() {
+        return properties;
+    }
+
+    public void setProperties(ExpressProperties properties) {
+        this.properties = properties;
+    }
 
     /**
      * 获取物流供应商名
@@ -32,7 +37,7 @@ public class ExpressService {
      * @return
      */
     public String getVendorName(String vendooCode) {
-        for (Map<String, String> item : config.getVendors()) {
+        for (Map<String, String> item : properties.getVendors()) {
             if (item.get("code").equals(vendooCode))
                 return item.get("name");
         }
@@ -45,13 +50,17 @@ public class ExpressService {
      * @throws Exception
      */
     public String getOrderTracesByJson(String expCode, String expNo) throws Exception {
+        if(!properties.isEnable()){
+            return null;
+        }
+
         String requestData = "{'OrderCode':'','ShipperCode':'" + expCode + "','LogisticCode':'" + expNo + "'}";
 
         Map<String, String> params = new HashMap<String, String>();
         params.put("RequestData", URLEncoder.encode(requestData, "UTF-8"));
-        params.put("EBusinessID", config.getAppId());
+        params.put("EBusinessID", properties.getAppId());
         params.put("RequestType", "1002");
-        String dataSign = encrypt(requestData, config.getAppKey(), "UTF-8");
+        String dataSign = encrypt(requestData, properties.getAppKey(), "UTF-8");
         params.put("DataSign", URLEncoder.encode(dataSign, "UTF-8"));
         params.put("DataType", "2");
 

+ 31 - 0
litemall-core/src/main/java/org/linlinjava/litemall/core/express/config/ExpressAutoConfiguration.java

@@ -0,0 +1,31 @@
+package org.linlinjava.litemall.core.express.config;
+
+import com.github.qcloudsms.SmsSingleSender;
+import org.linlinjava.litemall.core.express.ExpressService;
+import org.linlinjava.litemall.core.notify.NotifyService;
+import org.linlinjava.litemall.core.notify.TencentSmsSender;
+import org.linlinjava.litemall.core.notify.WxTemplateSender;
+import org.linlinjava.litemall.core.notify.config.NotifyProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.mail.javamail.JavaMailSenderImpl;
+
+@Configuration
+@EnableConfigurationProperties(ExpressProperties.class)
+public class ExpressAutoConfiguration {
+
+    private final ExpressProperties properties;
+
+    public ExpressAutoConfiguration(ExpressProperties properties) {
+        this.properties = properties;
+    }
+
+    @Bean
+    public ExpressService expressService(){
+        ExpressService expressService = new ExpressService();
+        expressService.setProperties(properties);
+        return expressService;
+    }
+
+}

+ 12 - 8
litemall-core/src/main/java/org/linlinjava/litemall/core/express/config/ExpressConfig.java

@@ -1,19 +1,23 @@
 package org.linlinjava.litemall.core.express.config;
 
-import org.linlinjava.litemall.core.util.YmlPropertyFactory;
 import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-@Component
-@Configuration
-@ConfigurationProperties(prefix = "express")
-public class ExpressConfig {
+@ConfigurationProperties(prefix = "litemall.express")
+public class ExpressProperties {
+    private boolean enable;
+
+    public boolean isEnable() {
+        return enable;
+    }
+
+    public void setEnable(boolean enable) {
+        this.enable = enable;
+    }
+
     private String appId;
     private String appKey;
 

+ 0 - 93
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/LitemallNotifyService.java

@@ -1,93 +0,0 @@
-package org.linlinjava.litemall.core.notify;
-
-import org.linlinjava.litemall.core.notify.util.ConfigUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-
-/**
- * Litemall商城通知服务类
- */
-@Service("litemallNotifyService")
-public class LitemallNotifyService {
-    @Autowired
-    private MailSendService mailSendService;
-    @Autowired
-    private SMSSendService smsSendService;
-    @Autowired
-    private WXTemplateSendService wxTemplateSendService;
-
-    @Async
-    public void notifySMSMessage(String phoneNumber, String message) {
-        if (!smsSendService.config.isEnable())
-            return;
-
-        smsSendService.sendSMS(phoneNumber, message);
-    }
-
-    /**
-     * 微信模版消息通知
-     * @param token         通过wxMAService获取token或者通过url请求token
-     * @param touser        接收者openId
-     * @param formId        表单ID或者 prepayId
-     * @param notifyType    通知类别,通过该枚举值在配置文件中获取相应的模版ID
-     * @param params        通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
-     */
-    @Async
-    public void notifyWXTemplate(String token,String touser, String formId, ConfigUtil.NotifyType notifyType, String[] params) {
-        if (!wxTemplateSendService.config.isEnable())
-            return;
-
-        String templateId = ConfigUtil.getTemplateId(notifyType, wxTemplateSendService.config.getTemplate());
-
-        if (templateId != "")
-            wxTemplateSendService.sendWechatMsg(token,touser, templateId, formId, "", "", params);
-    }
-
-    /**
-     * 短信模版通知
-     *
-     * @param phoneNumber 接收通知的电话号码
-     * @param notifyType  通知类别,通过该枚举值在配置文件中获取相应的模版ID
-     * @param params      通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
-     */
-    @Async
-    public void notifySMSTemplate(String phoneNumber, ConfigUtil.NotifyType notifyType, String[] params) {
-        if (!smsSendService.config.isEnable())
-            return;
-
-        int templateId = Integer.parseInt(ConfigUtil.getTemplateId(notifyType, smsSendService.config.getTemplate()));
-
-        if (templateId != -1)
-            smsSendService.sendSMSWithTemplate(phoneNumber, templateId, params);
-    }
-
-    /**
-     * 短信模版通知
-     *
-     * @param phoneNumber 接收通知的电话号码
-     * @param templateId  模板ID
-     * @param params      通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
-     */
-    @Async
-    public void notifySMSTemplate(String phoneNumber, int templateId, String[] params) {
-        if (!smsSendService.config.isEnable())
-            return;
-
-        smsSendService.sendSMSWithTemplate(phoneNumber, templateId, params);
-    }
-
-    /**
-     * 发送邮件通知,接收者在spring.mail.sendto中指定
-     *
-     * @param setSubject 邮件标题
-     * @param setText    邮件内容
-     */
-    @Async
-    public void notifyMailMessage(String setSubject, String setText) {
-        if (!mailSendService.config.isEnable())
-            return;
-
-        mailSendService.sendEmail(setSubject, setText);
-    }
-}

+ 0 - 50
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/MailSendService.java

@@ -1,50 +0,0 @@
-package org.linlinjava.litemall.core.notify;
-
-import org.linlinjava.litemall.core.notify.config.MailNotifyConfig;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.mail.javamail.JavaMailSenderImpl;
-import org.springframework.mail.javamail.MimeMessageHelper;
-import org.springframework.stereotype.Service;
-
-import javax.mail.internet.MimeMessage;
-
-@Service("mailSendService")
-class MailSendService {
-    @Autowired
-    MailNotifyConfig config;
-
-    private JavaMailSenderImpl mailSender;
-
-    private JavaMailSenderImpl getMailSender() {
-        if (mailSender == null) {
-            mailSender = new JavaMailSenderImpl();
-            mailSender.setHost(config.getHost());
-            mailSender.setUsername(config.getUsername());
-            mailSender.setPassword(config.getPassword());
-        }
-
-        return mailSender;
-    }
-
-    /**
-     * 发送邮件通知
-     *
-     * @param setSubject 邮件标题
-     * @param setText    邮件内容
-     */
-    public void sendEmail(String setSubject, String setText) {
-        try {
-            final MimeMessage mimeMessage = getMailSender().createMimeMessage();
-            final MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
-
-            message.setFrom(config.getUsername());
-            message.setTo(config.getSendto());
-            message.setSubject(setSubject);
-            message.setText(setText);
-            getMailSender().send(mimeMessage);
-
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-    }
-}

+ 160 - 0
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/NotifyService.java

@@ -0,0 +1,160 @@
+package org.linlinjava.litemall.core.notify;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mail.MailSender;
+import org.springframework.mail.SimpleMailMessage;
+import org.springframework.scheduling.annotation.Async;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 商城通知服务类
+ */
+public class NotifyService {
+    private MailSender mailSender;
+    private String sendFrom;
+    private String sendTo;
+
+    private SmsSender smsSender;
+    private List<Map<String, String>> smsTemplate = new ArrayList<>();
+
+    private WxTemplateSender wxTemplateSender;
+    private List<Map<String, String>> wxTemplate = new ArrayList<>();
+
+    /**
+     * 短信消息通知
+     *
+     * @param phoneNumber 接收通知的电话号码
+     * @param message     短消息内容,这里短消息内容必须已经在短信平台审核通过
+     */
+    @Async
+    public void notifySms(String phoneNumber, String message) {
+        if (mailSender == null)
+            return;
+
+        smsSender.send(phoneNumber, message);
+    }
+
+    /**
+     * 短信模版消息通知
+     *
+     * @param phoneNumber 接收通知的电话号码
+     * @param notifyType  通知类别,通过该枚举值在配置文件中获取相应的模版ID
+     * @param params      通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
+     */
+    @Async
+    public void notifySmsTemplate(String phoneNumber, NotifyType notifyType, String[] params) {
+        if (wxTemplateSender == null)
+            return;
+
+        int templateId = Integer.parseInt(getTemplateId(notifyType, smsTemplate));
+
+        smsSender.sendWithTemplate(phoneNumber, templateId, params);
+    }
+
+    /**
+     * 微信模版消息通知
+     *
+     * @param token      通过wxMAService获取token或者通过url请求token
+     * @param touser     接收者openId
+     * @param formId     表单ID或者 prepayId
+     * @param notifyType 通知类别,通过该枚举值在配置文件中获取相应的模版ID
+     * @param params     通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
+     */
+    @Async
+    public void notifyWxTemplate(String token, String touser, String formId, NotifyType notifyType, String[] params) {
+        if (wxTemplateSender == null)
+            return;
+
+        String templateId = getTemplateId(notifyType, wxTemplate);
+        wxTemplateSender.sendWechatMsg(token, touser, templateId, formId, "", "", params);
+    }
+
+    /**
+     * 邮件消息通知,
+     * 接收者在spring.mail.sendto中指定
+     *
+     * @param subject 邮件标题
+     * @param content 邮件内容
+     */
+    @Async
+    public void notifyMail(String subject, String content) {
+        if (mailSender == null)
+            return;
+
+        SimpleMailMessage message = new SimpleMailMessage();
+        message.setFrom(sendFrom);
+        message.setTo(sendTo);
+        message.setSubject(subject);
+        message.setText(content);
+        mailSender.send(message);
+    }
+
+    private String getTemplateId(NotifyType notifyType, List<Map<String, String>> values) {
+        for (Map<String, String> item : values) {
+            String notifyTypeStr = notifyType.getType();
+
+            if (item.get("name").equals(notifyTypeStr))
+                return item.get("templateId");
+        }
+        return null;
+    }
+
+    public MailSender getMailSender() {
+        return mailSender;
+    }
+
+    public void setMailSender(MailSender mailSender) {
+        this.mailSender = mailSender;
+    }
+
+    public String getSendFrom() {
+        return sendFrom;
+    }
+
+    public void setSendFrom(String sendFrom) {
+        this.sendFrom = sendFrom;
+    }
+
+    public String getSendTo() {
+        return sendTo;
+    }
+
+    public void setSendTo(String sendTo) {
+        this.sendTo = sendTo;
+    }
+
+    public SmsSender getSmsSender() {
+        return smsSender;
+    }
+
+    public void setSmsSender(SmsSender smsSender) {
+        this.smsSender = smsSender;
+    }
+
+    public List<Map<String, String>> getSmsTemplate() {
+        return smsTemplate;
+    }
+
+    public void setSmsTemplate(List<Map<String, String>> smsTemplate) {
+        this.smsTemplate = smsTemplate;
+    }
+
+    public WxTemplateSender getWxTemplateSender() {
+        return wxTemplateSender;
+    }
+
+    public void setWxTemplateSender(WxTemplateSender wxTemplateSender) {
+        this.wxTemplateSender = wxTemplateSender;
+    }
+
+    public List<Map<String, String>> getWxTemplate() {
+        return wxTemplate;
+    }
+
+    public void setWxTemplate(List<Map<String, String>> wxTemplate) {
+        this.wxTemplate = wxTemplate;
+    }
+}

+ 18 - 0
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/NotifyType.java

@@ -0,0 +1,18 @@
+package org.linlinjava.litemall.core.notify;
+
+public enum NotifyType {
+    PAY_SUCCEED("paySucceed"),
+    SHIP("ship"),
+    REFUND("refund"),
+    CAPTCHA("captcha");
+
+    NotifyType(String type) {
+        this.type = type;
+    }
+
+    private String type;
+
+    public String getType() {
+        return this.type;
+    }
+}

+ 0 - 61
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/SMSSendService.java

@@ -1,61 +0,0 @@
-package org.linlinjava.litemall.core.notify;
-
-import com.github.qcloudsms.SmsSingleSender;
-import com.github.qcloudsms.SmsSingleSenderResult;
-import com.github.qcloudsms.httpclient.HTTPException;
-import org.json.JSONException;
-import org.linlinjava.litemall.core.notify.config.SMSNotifyConfig;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.io.IOException;
-
-
-@Service("smsSendService")
-class SMSSendService {
-    @Autowired
-    SMSNotifyConfig config;
-
-    public void sendSMS(String phoneNumber, String content) {
-        try {
-            SmsSingleSender ssender = new SmsSingleSender(config.getAppid(), config.getAppkey());
-            SmsSingleSenderResult result = ssender.send(0, "86", phoneNumber,
-                    content, "", "");
-
-//            System.out.println(result);
-        } catch (HTTPException e) {
-            // HTTP响应码错误
-            e.printStackTrace();
-        } catch (JSONException e) {
-            // json解析错误
-            e.printStackTrace();
-        } catch (IOException e) {
-            // 网络IO错误
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * 通过模版发送短信息
-     * @param phoneNumber
-     * @param templateId
-     * @param params
-     */
-    public void sendSMSWithTemplate(String phoneNumber, int templateId, String[] params) {
-        try {
-            SmsSingleSender ssender = new SmsSingleSender(config.getAppid(), config.getAppkey());
-            SmsSingleSenderResult result = ssender.sendWithParam("86", phoneNumber,
-                    templateId, params, config.getSign(), "", "");  // 签名参数未提供或者为空时,会使用默认签名发送短信
-//            System.out.println(result);
-        } catch (HTTPException e) {
-            // HTTP响应码错误
-            e.printStackTrace();
-        } catch (JSONException e) {
-            // json解析错误
-            e.printStackTrace();
-        } catch (IOException e) {
-            // 网络IO错误
-            e.printStackTrace();
-        }
-    }
-}

+ 22 - 0
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/SmsSender.java

@@ -0,0 +1,22 @@
+package org.linlinjava.litemall.core.notify;
+
+public interface SmsSender {
+
+    /**
+     * 发送短信息
+     *
+     * @param phone   接收通知的电话号码
+     * @param content 短消息内容
+     */
+    void send(String phone, String content);
+
+
+    /**
+     * 通过短信模版发送短信息
+     *
+     * @param phone      接收通知的电话号码
+     * @param templateId 通知模板ID
+     * @param params     通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
+     */
+    void sendWithTemplate(String phone, int templateId, String[] params);
+}

+ 45 - 0
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/TencentSmsSender.java

@@ -0,0 +1,45 @@
+package org.linlinjava.litemall.core.notify;
+
+import com.github.qcloudsms.SmsSingleSender;
+import com.github.qcloudsms.SmsSingleSenderResult;
+import com.github.qcloudsms.httpclient.HTTPException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import java.io.IOException;
+
+/*
+ * 腾讯云短信服务
+ */
+public class TencentSmsSender implements SmsSender {
+    private final Log logger = LogFactory.getLog(TencentSmsSender.class);
+
+    private SmsSingleSender sender;
+
+    public SmsSingleSender getSender() {
+        return sender;
+    }
+
+    public void setSender(SmsSingleSender sender) {
+        this.sender = sender;
+    }
+
+    @Override
+    public void send(String phone, String content) {
+        try {
+            SmsSingleSenderResult result = sender.send(0, "86", phone, content, "", "");
+            logger.debug(result);
+        } catch (HTTPException | IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void sendWithTemplate(String phone, int templateId, String[] params) {
+        try {
+            SmsSingleSenderResult result = sender.sendWithParam("86", phone, templateId, params, "", "", "");
+            logger.debug(result);
+        } catch (HTTPException | IOException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 1 - 5
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/WXTemplateSendService.java

@@ -1,7 +1,6 @@
 package org.linlinjava.litemall.core.notify;
 
 import org.json.JSONObject;
-import org.linlinjava.litemall.core.notify.config.WXNotifyConfig;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -19,10 +18,7 @@ import java.security.cert.X509Certificate;
 /**
  * 微信模版消息通知
  */
-@Service("wxTemplateMsgSendService")
-class WXTemplateSendService {
-    @Autowired
-    WXNotifyConfig config;
+public class WxTemplateSender {
 
     /**
      * 发送微信消息(模板消息)

+ 0 - 54
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/MailNotifyConfig.java

@@ -1,54 +0,0 @@
-package org.linlinjava.litemall.core.notify.config;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-@Component
-@ConfigurationProperties(prefix = "MailNotifyConfig")
-public class MailNotifyConfig {
-    private boolean enable;
-    private String host;
-    private String username;
-    private String password;
-    private String sendto;
-
-    public boolean isEnable() {
-        return enable;
-    }
-
-    public void setEnable(boolean enable) {
-        this.enable = enable;
-    }
-
-    public String getHost() {
-        return host;
-    }
-
-    public void setHost(String host) {
-        this.host = host;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public void setUsername(String username) {
-        this.username = username;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public String getSendto() {
-        return sendto;
-    }
-
-    public void setSendto(String sendto) {
-        this.sendto = sendto;
-    }
-}

+ 54 - 0
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyAutoConfiguration.java

@@ -0,0 +1,54 @@
+package org.linlinjava.litemall.core.notify.config;
+
+import com.github.qcloudsms.SmsSingleSender;
+import org.linlinjava.litemall.core.notify.NotifyService;
+import org.linlinjava.litemall.core.notify.TencentSmsSender;
+import org.linlinjava.litemall.core.notify.WxTemplateSender;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.mail.javamail.JavaMailSenderImpl;
+
+@Configuration
+@EnableConfigurationProperties(NotifyProperties.class)
+public class NotifyAutoConfiguration {
+
+    private final NotifyProperties properties;
+
+    public NotifyAutoConfiguration(NotifyProperties properties) {
+        this.properties = properties;
+    }
+
+    @Bean
+    public NotifyService notifyService(){
+        NotifyService notifyService = new NotifyService();
+
+        NotifyProperties.Mail mailConfig = properties.getMail();
+        if(mailConfig.isEnable()) {
+            JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
+            mailSender.setHost(mailConfig.getHost());
+            mailSender.setUsername(mailConfig.getUsername());
+            mailSender.setPassword(mailConfig.getPassword());
+            notifyService.setMailSender(mailSender);
+            notifyService.setSendFrom(mailConfig.getSendfrom());
+            notifyService.setSendTo(mailConfig.getSendto());
+        }
+
+        NotifyProperties.Sms smsConfig = properties.getSms();
+        if(smsConfig.isEnable()){
+            TencentSmsSender smsSender = new TencentSmsSender();
+            smsSender.setSender(new SmsSingleSender(smsConfig.getAppid(), smsConfig.getAppkey()));
+            notifyService.setSmsSender(smsSender);
+            notifyService.setSmsTemplate(smsConfig.getTemplate());
+        }
+
+        NotifyProperties.Wx wxConfig = properties.getWx();
+        if(wxConfig.isEnable()){
+            WxTemplateSender wxTemplateSender = new WxTemplateSender();
+            notifyService.setWxTemplateSender(wxTemplateSender);
+            notifyService.setWxTemplate(wxConfig.getTemplate());
+        }
+        return notifyService;
+    }
+
+}

+ 156 - 0
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyProperties.java

@@ -0,0 +1,156 @@
+package org.linlinjava.litemall.core.notify.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@ConfigurationProperties(prefix = "litemall.notify")
+public class NotifyProperties {
+    private Mail mail;
+    private Sms sms;
+    private Wx wx;
+
+    public Mail getMail() {
+        return mail;
+    }
+
+    public void setMail(Mail mail) {
+        this.mail = mail;
+    }
+
+    public Sms getSms() {
+        return sms;
+    }
+
+    public void setSms(Sms sms) {
+        this.sms = sms;
+    }
+
+    public Wx getWx() {
+        return wx;
+    }
+
+    public void setWx(Wx wx) {
+        this.wx = wx;
+    }
+
+    public static class Mail {
+        private boolean enable;
+        private String host;
+        private String username;
+        private String password;
+        private String sendfrom;
+        private String sendto;
+
+        public boolean isEnable() {
+            return enable;
+        }
+
+        public void setEnable(boolean enable) {
+            this.enable = enable;
+        }
+
+        public String getHost() {
+            return host;
+        }
+
+        public void setHost(String host) {
+            this.host = host;
+        }
+
+        public String getUsername() {
+            return username;
+        }
+
+        public void setUsername(String username) {
+            this.username = username;
+        }
+
+        public String getPassword() {
+            return password;
+        }
+
+        public void setPassword(String password) {
+            this.password = password;
+        }
+
+        public String getSendfrom() {
+            return sendfrom;
+        }
+
+        public void setSendfrom(String sendfrom) {
+            this.sendfrom = sendfrom;
+        }
+
+        public String getSendto() {
+            return sendto;
+        }
+
+        public void setSendto(String sendto) {
+            this.sendto = sendto;
+        }
+    }
+
+    public static class Sms {
+        private boolean enable;
+        private int appid;
+        private String appkey;
+        private List<Map<String,String>> template = new ArrayList<>();
+
+        public boolean isEnable() {
+            return enable;
+        }
+
+        public void setEnable(boolean enable) {
+            this.enable = enable;
+        }
+
+        public int getAppid() {
+            return appid;
+        }
+
+        public void setAppid(int appid) {
+            this.appid = appid;
+        }
+
+        public String getAppkey() {
+            return appkey;
+        }
+
+        public void setAppkey(String appkey) {
+            this.appkey = appkey;
+        }
+
+        public List<Map<String, String>> getTemplate() {
+            return template;
+        }
+
+        public void setTemplate(List<Map<String, String>> template) {
+            this.template = template;
+        }
+    }
+
+    public static class Wx {
+        private boolean enable;
+        private List<Map<String,String>> template = new ArrayList<>();
+
+        public boolean isEnable() {
+            return enable;
+        }
+
+        public void setEnable(boolean enable) {
+            this.enable = enable;
+        }
+
+        public List<Map<String, String>> getTemplate() {
+            return template;
+        }
+
+        public void setTemplate(List<Map<String, String>> template) {
+            this.template = template;
+        }
+    }
+
+}

+ 0 - 58
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/SMSNotifyConfig.java

@@ -1,58 +0,0 @@
-package org.linlinjava.litemall.core.notify.config;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-@Component
-@ConfigurationProperties(prefix = "SMSNotifyConfig")
-public class SMSNotifyConfig {
-    private boolean enable;
-    private int appid;
-    private String appkey;
-    private String sign;
-    private List<Map<String,String>> template = new ArrayList<>();
-
-    public boolean isEnable() {
-        return enable;
-    }
-
-    public void setEnable(boolean enable) {
-        this.enable = enable;
-    }
-
-    public int getAppid() {
-        return appid;
-    }
-
-    public void setAppid(int appid) {
-        this.appid = appid;
-    }
-
-    public String getAppkey() {
-        return appkey;
-    }
-
-    public void setAppkey(String appkey) {
-        this.appkey = appkey;
-    }
-
-    public String getSign() {
-        return sign;
-    }
-
-    public void setSign(String sign) {
-        this.sign = sign;
-    }
-
-    public List<Map<String, String>> getTemplate() {
-        return template;
-    }
-
-    public void setTemplate(List<Map<String, String>> template) {
-        this.template = template;
-    }
-}

+ 0 - 31
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/WXNotifyConfig.java

@@ -1,31 +0,0 @@
-package org.linlinjava.litemall.core.notify.config;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-@Component
-@ConfigurationProperties(prefix = "WXNotifyConfig")
-public class WXNotifyConfig {
-    private boolean enable;
-    private List<Map<String,String>> template = new ArrayList<>();
-
-    public boolean isEnable() {
-        return enable;
-    }
-
-    public void setEnable(boolean enable) {
-        this.enable = enable;
-    }
-
-    public List<Map<String, String>> getTemplate() {
-        return template;
-    }
-
-    public void setTemplate(List<Map<String, String>> template) {
-        this.template = template;
-    }
-}

+ 0 - 58
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/util/ConfigUtil.java

@@ -1,58 +0,0 @@
-package org.linlinjava.litemall.core.notify.util;
-
-import java.util.List;
-import java.util.Map;
-
-public class ConfigUtil {
-
-    /**
-     * 通过枚举获取对应的 templateId,注意 application.yaml 里字段名必须一致
-     *
-     * @param notifyType
-     * @param values
-     * @return
-     */
-    public static String getTemplateId(NotifyType notifyType, List<Map<String, String>> values) {
-        for (Map<String, String> item : values) {
-            String notifyTypeStr = getNotifyType(notifyType);
-
-            if (item.get("name").equals(notifyTypeStr))
-                return item.get("templateId");
-        }
-        return "";
-    }
-
-    /**
-     * 该处字符串对应 application.yaml 里 template.name 的值,请注意
-     *
-     * @param notifyType
-     * @return
-     */
-    private static String getNotifyType(NotifyType notifyType) {
-        switch (notifyType) {
-            case PAY_SUCCEED:
-                return "paySucceed";
-            case CAPTCHA:
-                return "captcha";
-            case SHIP:
-                return "ship";
-            case REFUND:
-                return "refund";
-        }
-
-        return "";
-    }
-
-    /**
-     * 该枚举定义了所有的需要通知的事件,调用通知时作为参数
-     * <p>
-     * PAY_SUCCEED 支付成功,通常用于用户支付成功
-     * CAPTCHA 验证码,通常用于登录、注册、找回密码
-     */
-    public enum NotifyType {
-        PAY_SUCCEED,
-        SHIP,
-        REFUND,
-        CAPTCHA
-    }
-}

+ 44 - 38
litemall-core/src/main/resources/application-core.yml

@@ -1,44 +1,50 @@
-# 邮件通知配置,邮箱一般用于接收业务通知例如收到新的订单,sendto 定义邮件接收者,通常为商城运营人员
-MailNotifyConfig:
-  enable: false
-  host: smtp.exmail.qq.com
-  username: ex@ex.com.cn
-  password: XXXXXXXXXXXXX
-  sendto: ex@qq.com
+litemall:
+  notify:
+    mail:
+      # 邮件通知配置,邮箱一般用于接收业务通知例如收到新的订单,sendto 定义邮件接收者,通常为商城运营人员
+      enable: false
+      host: smtp.exmail.qq.com
+      username: ex@ex.com.cn
+      password: XXXXXXXXXXXXX
+      sendfrom: ex@ex.com.cn
+      sendto: ex@qq.com
 
-# 短消息模版通知配置
-# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 ConfigUtil 内枚举值
-SMSNotifyConfig:
-  enable: false
-  appid: 111111111
-  appkey: xxxxxxxxxxxxxx
-  sign: xxxxxxxxx
-  template:
-    - name: paySucceed
-      templateId: 156349
-    - name: captcha
-      templateId: 156433
-    - name: ship
-      templateId: 158002
-    - name: refund
-      templateId: 159447
+    # 短消息模版通知配置
+    # 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
+    sms:
+      enable: false
+      appid: 111111111
+      appkey: xxxxxxxxxxxxxx
+      template:
+      - name: paySucceed
+        templateId: 156349
+      - name: captcha
+        templateId: 156433
+      - name: ship
+        templateId: 158002
+      - name: refund
+        templateId: 159447
 
+    # 微信模版通知配置
+    # 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
+    wx:
+      enable: false
+      template:
+      - name: paySucceed
+        templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+      - name: captcha
+        templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+      - name: ship
+        templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+      - name: refund
+        templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
-# 微信模版通知配置
-# 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 ConfigUtil 内枚举值
-WXNotifyConfig:
-  enable: false
-  template:
-    - name: paySucceed
-      templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-    - name: captcha
-      templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
-#快鸟物流查询配置
-express:
-  appId: "XXXXXXXXX"
-  appKey: "XXXXXXXXXXXXXXXXXXXXXXXXX"
-  vendors:
+  # 快鸟物流查询配置
+  express:
+    enable: false
+    appId: "XXXXXXXXX"
+    appKey: "XXXXXXXXXXXXXXXXXXXXXXXXX"
+    vendors:
     - code: "ZTO"
       name: "中通快递"
     - code: "YTO"

+ 1 - 7
litemall-core/src/test/java/org/linlinjava/litemall/core/CoreConfigTest.java

@@ -2,8 +2,6 @@ package org.linlinjava.litemall.core;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.linlinjava.litemall.core.express.config.ExpressConfig;
-import org.linlinjava.litemall.core.notify.config.MailNotifyConfig;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.core.env.Environment;
@@ -15,15 +13,11 @@ import org.springframework.test.context.web.WebAppConfiguration;
 @SpringBootTest
 public class CoreConfigTest {
     @Autowired
-    ExpressConfig config;
-    @Autowired
     Environment environment;
 
     @Test
     public void test() {
-        System.out.println(config.getAppId());
-        System.out.println(config.getAppKey());
         // 测试获取application-core.yml配置信息
-        System.out.println(environment.getProperty("express.appId"));
+        System.out.println(environment.getProperty("litemall.express.appId"));
     }
 }

+ 3 - 3
litemall-core/src/test/java/org/linlinjava/litemall/core/MailTest.java

@@ -2,7 +2,7 @@ package org.linlinjava.litemall.core;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.linlinjava.litemall.core.notify.LitemallNotifyService;
+import org.linlinjava.litemall.core.notify.NotifyService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -24,11 +24,11 @@ import org.springframework.test.context.web.WebAppConfiguration;
 public class MailTest {
 
     @Autowired
-    private LitemallNotifyService litemallNotifyService;
+    private NotifyService notifyService;
 
     @Test
     public void testMail() {
-        litemallNotifyService.notifyMailMessage("订单信息", "订单1111111已付款,请发货");
+        notifyService.notifyMail("订单信息", "订单1111111已付款,请发货");
 
         try {
             Thread.sleep(5000);

+ 7 - 7
litemall-core/src/test/java/org/linlinjava/litemall/core/SmsTest.java

@@ -2,8 +2,8 @@ package org.linlinjava.litemall.core;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.linlinjava.litemall.core.notify.LitemallNotifyService;
-import org.linlinjava.litemall.core.notify.util.ConfigUtil;
+import org.linlinjava.litemall.core.notify.NotifyService;
+import org.linlinjava.litemall.core.notify.NotifyType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -26,14 +26,14 @@ import org.springframework.test.context.web.WebAppConfiguration;
 public class SmsTest {
 
     @Autowired
-    private LitemallNotifyService litemallNotifyService;
+    private NotifyService notifyService;
 
-//    @Test
+    @Test
     public void testSingle() {
         String phone = "xxxxxxxxxxx";
         // 这里的短信签名必须在短信管理平台内设置正确并且相符合
         String msg = "【xxx】你的验证码为:123456,请与2分钟内填写,如非本人操作,请忽略本短信。";
-        litemallNotifyService.notifySMSMessage(phone, msg);
+        notifyService.notifySms(phone, msg);
 
         try {
             Thread.sleep(5000);
@@ -47,7 +47,7 @@ public class SmsTest {
         String phone = "xxxxxxxxxxx";
         String[] params = new String[] {"123456"};
 
-        litemallNotifyService.notifySMSTemplate(phone, ConfigUtil.NotifyType.CAPTCHA, params);
+        notifyService.notifySmsTemplate(phone, NotifyType.CAPTCHA, params);
 
         try {
             Thread.sleep(5000);
@@ -61,7 +61,7 @@ public class SmsTest {
         String phone = "xxxxxxxxxxx";
         String[] params = new String[] {"123456"};
 
-        litemallNotifyService.notifySMSTemplate(phone, ConfigUtil.NotifyType.PAY_SUCCEED, params);
+        notifyService.notifySmsTemplate(phone, NotifyType.PAY_SUCCEED, params);
 
         try {
             Thread.sleep(5000);

+ 37 - 0
litemall-core/src/test/java/org/linlinjava/litemall/core/WxTemplateTest.java

@@ -0,0 +1,37 @@
+package org.linlinjava.litemall.core;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.linlinjava.litemall.core.notify.NotifyService;
+import org.linlinjava.litemall.core.notify.NotifyType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+/**
+ */
+@WebAppConfiguration
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest
+public class WxTemplateTest {
+
+    @Autowired
+    private NotifyService notifyService;
+
+    @Test
+    public void testPaySucceed() {
+        String token = "xx";
+        String touser = "xx";
+        String formId = "";
+        String[] params = new String[]{"xxx"};
+        notifyService.notifyWxTemplate(token, touser, formId, NotifyType.PAY_SUCCEED, params);
+        try {
+            Thread.sleep(5000);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+}

+ 1 - 1
litemall-os-api/src/main/java/org/linlinjava/litemall/os/config/ObjectStorageConfig.java

@@ -4,7 +4,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
 @Component
-@ConfigurationProperties(prefix = "org.linlinjava.litemall.os")
+@ConfigurationProperties(prefix = "litemall.os")
 public class ObjectStorageConfig {
     private String address;
 

+ 2 - 2
litemall-os-api/src/main/resources/application-os.yml

@@ -8,5 +8,5 @@ activeStorage: los
 
 # 开发者应该设置成自己的域名,必须附带http或者https
 # 开发者可以查看OsStorageController.generateUrl
-org.linlinjava.litemall.os.address: http://127.0.0.1
-org.linlinjava.litemall.os.port: 8081
+litemall.os.address: http://127.0.0.1
+litemall.os.port: 8081

+ 2 - 2
litemall-os-api/src/test/java/org/linlinjava/litemall/os/OsTest.java

@@ -18,11 +18,11 @@ public class OsTest {
     @Test
     public void test() {
         // 测试获取application-core.yml配置信息
-        System.out.println(environment.getProperty("express.appId"));
+        System.out.println(environment.getProperty("litemall.express.appId"));
         // 测试获取application-db.yml配置信息
         System.out.println(environment.getProperty("spring.datasource.druid.url"));
         // 测试获取application-os.yml配置信息
-        System.out.println(environment.getProperty("org.linlinjava.litemall.os.address"));
+        System.out.println(environment.getProperty("litemall.os.address"));
         // 测试获取application.yml配置信息
         System.out.println(environment.getProperty("logging.level.org.linlinjava.litemall.os"));
     }

+ 1 - 1
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/config/WxProperties.java

@@ -6,7 +6,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
 
 @Configuration
-@ConfigurationProperties(prefix = "wx")
+@ConfigurationProperties(prefix = "litemall.wx")
 public class WxProperties {
 
     private String appId;

+ 6 - 6
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java

@@ -9,8 +9,8 @@ import com.github.binarywang.wxpay.service.WxPayService;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.linlinjava.litemall.core.notify.LitemallNotifyService;
-import org.linlinjava.litemall.core.notify.util.ConfigUtil;
+import org.linlinjava.litemall.core.notify.NotifyService;
+import org.linlinjava.litemall.core.notify.NotifyType;
 import org.linlinjava.litemall.core.util.JacksonUtil;
 import org.linlinjava.litemall.core.util.ResponseUtil;
 import org.linlinjava.litemall.db.domain.*;
@@ -82,7 +82,7 @@ public class WxOrderController {
     private WxPayService wxPayService;
 
     @Autowired
-    private LitemallNotifyService litemallNotifyService;
+    private NotifyService notifyService;
 
     public WxOrderController() {
     }
@@ -553,12 +553,12 @@ public class WxOrderController {
 
             //TODO 发送邮件和短信通知,这里采用异步发送
             // 订单支付成功以后,会发送短信给用户,以及发送邮件给管理员
-            litemallNotifyService.notifyMailMessage("新订单通知", order.toString());
+            notifyService.notifyMail("新订单通知", order.toString());
             /**
              * 这里微信的短信平台对参数长度有限制,所以将订单号只截取后6位
              *
              */
-            litemallNotifyService.notifySMSTemplate(order.getMobile(), ConfigUtil.NotifyType.PAY_SUCCEED, new String[]{orderSn.substring(8, 14)});
+            notifyService.notifySmsTemplate(order.getMobile(), NotifyType.PAY_SUCCEED, new String[]{orderSn.substring(8, 14)});
 
             return WxPayNotifyResponse.success("处理成功!");
         } catch (Exception e) {
@@ -607,7 +607,7 @@ public class WxOrderController {
 
         //TODO 发送邮件和短信通知,这里采用异步发送
         // 有用户申请退款,邮件通知运营人员
-        litemallNotifyService.notifyMailMessage("退款申请", order.toString());
+        notifyService.notifyMail("退款申请", order.toString());
 
         return ResponseUtil.ok();
     }

+ 7 - 6
litemall-wx-api/src/main/resources/application-docker.yml

@@ -6,9 +6,10 @@ spring:
         password: ${MYSQL_PASSWORD}
         type: com.alibaba.druid.pool.DruidDataSource
 
-wx:
-  app-id: ${WX_APP_ID}
-  app-secret: ${WX_APP_SECRET}
-  mch-id: ${WX_MCH_ID}
-  mch-key: ${WX_MCH_KEY}
-  notify-url: ${WX_NOTIFY_URL}
+litemall:
+  wx:
+    app-id: ${WX_APP_ID}
+    app-secret: ${WX_APP_SECRET}
+    mch-id: ${WX_MCH_ID}
+    mch-key: ${WX_MCH_KEY}
+    notify-url: ${WX_NOTIFY_URL}

+ 7 - 6
litemall-wx-api/src/main/resources/application-wx.yml

@@ -1,7 +1,8 @@
 # 开发者应该设置成自己的wx相关信息
-wx:
-  app-id: wxa5b486c6b918ecfb
-  app-secret: e04004829d4c383b4db7769d88dfbca1
-  mch-id: 111111
-  mch-key: xxxxxx
-  notify-url: http://www.example.com/wx/order/pay-notify
+litemall:
+  wx:
+    app-id: wxa5b486c6b918ecfb
+    app-secret: e04004829d4c383b4db7769d88dfbca1
+    mch-id: 111111
+    mch-key: xxxxxx
+    notify-url: http://www.example.com/wx/order/pay-notify

+ 2 - 2
litemall-wx-api/src/test/java/org/linlinjava/litemall/wx/WxConfigTest.java

@@ -20,11 +20,11 @@ public class WxConfigTest {
     @Test
     public void test() {
         // 测试获取application-core.yml配置信息
-        System.out.println(environment.getProperty("express.appId"));
+        System.out.println(environment.getProperty("litemall.express.appId"));
         // 测试获取application-db.yml配置信息
         System.out.println(environment.getProperty("spring.datasource.druid.url"));
         // 测试获取application-wx.yml配置信息
-        System.out.println(environment.getProperty("wx.app-id"));
+        System.out.println(environment.getProperty("litemall.wx.app-id"));
         // 测试获取application.yml配置信息
         System.out.println(environment.getProperty("logging.level.org.linlinjava.litemall.wx"));
     }