Commit d12f3c47 authored by Junling Bu's avatar Junling Bu
Browse files

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

parent 29751a5f
# 邮件通知配置,邮箱一般用于接收业务通知例如收到新的订单,sendto 定义邮件接收者,通常为商城运营人员 litemall:
MailNotifyConfig: notify:
mail:
# 邮件通知配置,邮箱一般用于接收业务通知例如收到新的订单,sendto 定义邮件接收者,通常为商城运营人员
enable: false enable: false
host: smtp.exmail.qq.com host: smtp.exmail.qq.com
username: ex@ex.com.cn username: ex@ex.com.cn
password: XXXXXXXXXXXXX password: XXXXXXXXXXXXX
sendfrom: ex@ex.com.cn
sendto: ex@qq.com sendto: ex@qq.com
# 短消息模版通知配置 # 短消息模版通知配置
# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 ConfigUtil 内枚举值 # 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
SMSNotifyConfig: sms:
enable: false enable: false
appid: 111111111 appid: 111111111
appkey: xxxxxxxxxxxxxx appkey: xxxxxxxxxxxxxx
sign: xxxxxxxxx
template: template:
- name: paySucceed - name: paySucceed
templateId: 156349 templateId: 156349
...@@ -23,19 +25,23 @@ SMSNotifyConfig: ...@@ -23,19 +25,23 @@ SMSNotifyConfig:
- name: refund - name: refund
templateId: 159447 templateId: 159447
# 微信模版通知配置
# 微信模版通知配置 # 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
# 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 ConfigUtil 内枚举值 wx:
WXNotifyConfig:
enable: false enable: false
template: template:
- name: paySucceed - name: paySucceed
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: captcha - name: captcha
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: ship
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: refund
templateId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#快鸟物流查询配置 # 快鸟物流查询配置
express: express:
enable: false
appId: "XXXXXXXXX" appId: "XXXXXXXXX"
appKey: "XXXXXXXXXXXXXXXXXXXXXXXXX" appKey: "XXXXXXXXXXXXXXXXXXXXXXXXX"
vendors: vendors:
......
...@@ -2,8 +2,6 @@ package org.linlinjava.litemall.core; ...@@ -2,8 +2,6 @@ package org.linlinjava.litemall.core;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; 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.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
...@@ -14,16 +12,12 @@ import org.springframework.test.context.web.WebAppConfiguration; ...@@ -14,16 +12,12 @@ import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest @SpringBootTest
public class CoreConfigTest { public class CoreConfigTest {
@Autowired
ExpressConfig config;
@Autowired @Autowired
Environment environment; Environment environment;
@Test @Test
public void test() { public void test() {
System.out.println(config.getAppId());
System.out.println(config.getAppKey());
// 测试获取application-core.yml配置信息 // 测试获取application-core.yml配置信息
System.out.println(environment.getProperty("express.appId")); System.out.println(environment.getProperty("litemall.express.appId"));
} }
} }
...@@ -2,7 +2,7 @@ package org.linlinjava.litemall.core; ...@@ -2,7 +2,7 @@ package org.linlinjava.litemall.core;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; 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.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
...@@ -24,11 +24,11 @@ import org.springframework.test.context.web.WebAppConfiguration; ...@@ -24,11 +24,11 @@ import org.springframework.test.context.web.WebAppConfiguration;
public class MailTest { public class MailTest {
@Autowired @Autowired
private LitemallNotifyService litemallNotifyService; private NotifyService notifyService;
@Test @Test
public void testMail() { public void testMail() {
litemallNotifyService.notifyMailMessage("订单信息", "订单1111111已付款,请发货"); notifyService.notifyMail("订单信息", "订单1111111已付款,请发货");
try { try {
Thread.sleep(5000); Thread.sleep(5000);
......
...@@ -2,8 +2,8 @@ package org.linlinjava.litemall.core; ...@@ -2,8 +2,8 @@ package org.linlinjava.litemall.core;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.linlinjava.litemall.core.notify.LitemallNotifyService; import org.linlinjava.litemall.core.notify.NotifyService;
import org.linlinjava.litemall.core.notify.util.ConfigUtil; import org.linlinjava.litemall.core.notify.NotifyType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
...@@ -26,14 +26,14 @@ import org.springframework.test.context.web.WebAppConfiguration; ...@@ -26,14 +26,14 @@ import org.springframework.test.context.web.WebAppConfiguration;
public class SmsTest { public class SmsTest {
@Autowired @Autowired
private LitemallNotifyService litemallNotifyService; private NotifyService notifyService;
// @Test @Test
public void testSingle() { public void testSingle() {
String phone = "xxxxxxxxxxx"; String phone = "xxxxxxxxxxx";
// 这里的短信签名必须在短信管理平台内设置正确并且相符合 // 这里的短信签名必须在短信管理平台内设置正确并且相符合
String msg = "【xxx】你的验证码为:123456,请与2分钟内填写,如非本人操作,请忽略本短信。"; String msg = "【xxx】你的验证码为:123456,请与2分钟内填写,如非本人操作,请忽略本短信。";
litemallNotifyService.notifySMSMessage(phone, msg); notifyService.notifySms(phone, msg);
try { try {
Thread.sleep(5000); Thread.sleep(5000);
...@@ -47,7 +47,7 @@ public class SmsTest { ...@@ -47,7 +47,7 @@ public class SmsTest {
String phone = "xxxxxxxxxxx"; String phone = "xxxxxxxxxxx";
String[] params = new String[] {"123456"}; String[] params = new String[] {"123456"};
litemallNotifyService.notifySMSTemplate(phone, ConfigUtil.NotifyType.CAPTCHA, params); notifyService.notifySmsTemplate(phone, NotifyType.CAPTCHA, params);
try { try {
Thread.sleep(5000); Thread.sleep(5000);
...@@ -61,7 +61,7 @@ public class SmsTest { ...@@ -61,7 +61,7 @@ public class SmsTest {
String phone = "xxxxxxxxxxx"; String phone = "xxxxxxxxxxx";
String[] params = new String[] {"123456"}; String[] params = new String[] {"123456"};
litemallNotifyService.notifySMSTemplate(phone, ConfigUtil.NotifyType.PAY_SUCCEED, params); notifyService.notifySmsTemplate(phone, NotifyType.PAY_SUCCEED, params);
try { try {
Thread.sleep(5000); Thread.sleep(5000);
......
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();
}
}
}
...@@ -4,7 +4,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -4,7 +4,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
@ConfigurationProperties(prefix = "org.linlinjava.litemall.os") @ConfigurationProperties(prefix = "litemall.os")
public class ObjectStorageConfig { public class ObjectStorageConfig {
private String address; private String address;
......
...@@ -8,5 +8,5 @@ activeStorage: los ...@@ -8,5 +8,5 @@ activeStorage: los
# 开发者应该设置成自己的域名,必须附带http或者https # 开发者应该设置成自己的域名,必须附带http或者https
# 开发者可以查看OsStorageController.generateUrl # 开发者可以查看OsStorageController.generateUrl
org.linlinjava.litemall.os.address: http://127.0.0.1 litemall.os.address: http://127.0.0.1
org.linlinjava.litemall.os.port: 8081 litemall.os.port: 8081
\ No newline at end of file \ No newline at end of file
...@@ -18,11 +18,11 @@ public class OsTest { ...@@ -18,11 +18,11 @@ public class OsTest {
@Test @Test
public void test() { public void test() {
// 测试获取application-core.yml配置信息 // 测试获取application-core.yml配置信息
System.out.println(environment.getProperty("express.appId")); System.out.println(environment.getProperty("litemall.express.appId"));
// 测试获取application-db.yml配置信息 // 测试获取application-db.yml配置信息
System.out.println(environment.getProperty("spring.datasource.druid.url")); System.out.println(environment.getProperty("spring.datasource.druid.url"));
// 测试获取application-os.yml配置信息 // 测试获取application-os.yml配置信息
System.out.println(environment.getProperty("org.linlinjava.litemall.os.address")); System.out.println(environment.getProperty("litemall.os.address"));
// 测试获取application.yml配置信息 // 测试获取application.yml配置信息
System.out.println(environment.getProperty("logging.level.org.linlinjava.litemall.os")); System.out.println(environment.getProperty("logging.level.org.linlinjava.litemall.os"));
} }
......
...@@ -6,7 +6,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -6,7 +6,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
@ConfigurationProperties(prefix = "wx") @ConfigurationProperties(prefix = "litemall.wx")
public class WxProperties { public class WxProperties {
private String appId; private String appId;
......
...@@ -9,8 +9,8 @@ import com.github.binarywang.wxpay.service.WxPayService; ...@@ -9,8 +9,8 @@ import com.github.binarywang.wxpay.service.WxPayService;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.notify.LitemallNotifyService; import org.linlinjava.litemall.core.notify.NotifyService;
import org.linlinjava.litemall.core.notify.util.ConfigUtil; import org.linlinjava.litemall.core.notify.NotifyType;
import org.linlinjava.litemall.core.util.JacksonUtil; import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil; import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.*; import org.linlinjava.litemall.db.domain.*;
...@@ -82,7 +82,7 @@ public class WxOrderController { ...@@ -82,7 +82,7 @@ public class WxOrderController {
private WxPayService wxPayService; private WxPayService wxPayService;
@Autowired @Autowired
private LitemallNotifyService litemallNotifyService; private NotifyService notifyService;
public WxOrderController() { public WxOrderController() {
} }
...@@ -553,12 +553,12 @@ public class WxOrderController { ...@@ -553,12 +553,12 @@ public class WxOrderController {
//TODO 发送邮件和短信通知,这里采用异步发送 //TODO 发送邮件和短信通知,这里采用异步发送
// 订单支付成功以后,会发送短信给用户,以及发送邮件给管理员 // 订单支付成功以后,会发送短信给用户,以及发送邮件给管理员
litemallNotifyService.notifyMailMessage("新订单通知", order.toString()); notifyService.notifyMail("新订单通知", order.toString());
/** /**
* 这里微信的短信平台对参数长度有限制,所以将订单号只截取后6位 * 这里微信的短信平台对参数长度有限制,所以将订单号只截取后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("处理成功!"); return WxPayNotifyResponse.success("处理成功!");
} catch (Exception e) { } catch (Exception e) {
...@@ -607,7 +607,7 @@ public class WxOrderController { ...@@ -607,7 +607,7 @@ public class WxOrderController {
//TODO 发送邮件和短信通知,这里采用异步发送 //TODO 发送邮件和短信通知,这里采用异步发送
// 有用户申请退款,邮件通知运营人员 // 有用户申请退款,邮件通知运营人员
litemallNotifyService.notifyMailMessage("退款申请", order.toString()); notifyService.notifyMail("退款申请", order.toString());
return ResponseUtil.ok(); return ResponseUtil.ok();
} }
......
...@@ -6,7 +6,8 @@ spring: ...@@ -6,7 +6,8 @@ spring:
password: ${MYSQL_PASSWORD} password: ${MYSQL_PASSWORD}
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
wx: litemall:
wx:
app-id: ${WX_APP_ID} app-id: ${WX_APP_ID}
app-secret: ${WX_APP_SECRET} app-secret: ${WX_APP_SECRET}
mch-id: ${WX_MCH_ID} mch-id: ${WX_MCH_ID}
......
# 开发者应该设置成自己的wx相关信息 # 开发者应该设置成自己的wx相关信息
wx: litemall:
wx:
app-id: wxa5b486c6b918ecfb app-id: wxa5b486c6b918ecfb
app-secret: e04004829d4c383b4db7769d88dfbca1 app-secret: e04004829d4c383b4db7769d88dfbca1
mch-id: 111111 mch-id: 111111
......
...@@ -20,11 +20,11 @@ public class WxConfigTest { ...@@ -20,11 +20,11 @@ public class WxConfigTest {
@Test @Test
public void test() { public void test() {
// 测试获取application-core.yml配置信息 // 测试获取application-core.yml配置信息
System.out.println(environment.getProperty("express.appId")); System.out.println(environment.getProperty("litemall.express.appId"));
// 测试获取application-db.yml配置信息 // 测试获取application-db.yml配置信息
System.out.println(environment.getProperty("spring.datasource.druid.url")); System.out.println(environment.getProperty("spring.datasource.druid.url"));
// 测试获取application-wx.yml配置信息 // 测试获取application-wx.yml配置信息
System.out.println(environment.getProperty("wx.app-id")); System.out.println(environment.getProperty("litemall.wx.app-id"));
// 测试获取application.yml配置信息 // 测试获取application.yml配置信息
System.out.println(environment.getProperty("logging.level.org.linlinjava.litemall.wx")); System.out.println(environment.getProperty("logging.level.org.linlinjava.litemall.wx"));
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment