Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
11571dba
Commit
11571dba
authored
Aug 29, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
d126095e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
17 deletions
+154
-17
AliYunSmsBiz.java
...in/java/com/xxfc/platform/universal/biz/AliYunSmsBiz.java
+151
-0
SmsService.java
.../java/com/xxfc/platform/universal/service/SmsService.java
+3
-17
No files found.
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/AliYunSmsBiz.java
0 → 100644
View file @
11571dba
package
com
.
xxfc
.
platform
.
universal
.
biz
;
import
com.xxfc.platform.universal.utils.CCPRestSmsUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
@Service
@Slf4j
public
class
AliYunSmsBiz
{
//租车订单通知(普通用户)1
public
static
final
String
TEMPLATE_ID_ORDER
=
"458626"
;
//租车订单短信(会员权益)2
public
static
final
String
TEMPLATE_ID_ORDER_MEMBER
=
"458625"
;
//旅游订单短信3
public
static
final
String
TEMPLATE_ID_ORDER_TOUR
=
"458624"
;
//加入会员通知4
public
static
final
String
TEMPLATE_ID_MEMBER
=
"458623"
;
//租/还车公司相同(订单支付后立即发送给相关负责人)5
public
static
final
String
TEMPLATE_ID_TAAKE_CAR
=
"458622"
;
//租/还车公司不同(发给租车公司负责人,订单支付后发送)6
public
static
final
String
TEMPLATE_ID_DIFFERENT_TAAKE_CAR
=
"458621"
;
// 租/还车公司不同(发给还车公司负责人,订单出车后发))(相同不发)7
public
static
final
String
TEMPLATE_ID_ALSO_CAR
=
"458620"
;
//取消订单9
public
static
final
String
TEMPLATE_ID_CANCEL
=
"458627"
;
//租车(通用)10
public
static
final
String
TEMPLATE_ID_PAY_A
=
"460759"
;
//租车(使用会员权益)11
public
static
final
String
TEMPLATE_ID_PAY_B
=
"460760"
;
//租车内部通知(客服)12
public
static
final
String
TEMPLATE_ID_PAY_C
=
"460763"
;
//租车内部通知(出车人)13
public
static
final
String
TEMPLATE_ID_PAY_D
=
"460762"
;
//租车内部通知(收车人)14
public
static
final
String
TEMPLATE_ID_PAY_E
=
"460764"
;
//旅游(通用)15
public
static
final
String
TEMPLATE_ID_PAY_F
=
"460765"
;
//会员购买(通用)16
public
static
final
String
TEMPLATE_ID_PAY_G
=
"460766"
;
//取消租车(通用)17
public
static
final
String
TEMPLATE_ID_CANCEL_A
=
"460767"
;
//取消租车(使用会员权益)18
public
static
final
String
TEMPLATE_ID_CANCEL_B
=
"460768"
;
//取消租车(通用扣违约金)19
public
static
final
String
TEMPLATE_ID_CANCEL_C
=
"460769"
;
//取消租车(会员权益&扣违 20
public
static
final
String
TEMPLATE_ID_CANCEL_D
=
"460770"
;
//取消租车(出车人)21
public
static
final
String
TEMPLATE_ID_CANCEL_E
=
"460771"
;
//租车押金退还 22
public
static
final
String
TEMPLATE_ID_FINISH_A
=
"460772"
;
//违章押金退还 23
public
static
final
String
TEMPLATE_ID_FINISH_B
=
"460773"
;
//旅游内部通知(客服)24
public
static
final
String
TEMPLATE_ID_PAY_H
=
"461421"
;
//取消旅游订单(客服)25
public
static
final
String
TEMPLATE_ID_CANCEL_F
=
"461424"
;
//发送模板消息
public
void
sendTemplateSMS
(
Integer
type
,
String
phoneNumbers
,
String
[]
params
){
switch
(
type
){
case
1
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_ORDER
);
break
;
case
2
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_ORDER_MEMBER
);
break
;
case
3
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_ORDER_TOUR
);
break
;
case
4
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_MEMBER
);
break
;
case
5
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_TAAKE_CAR
);
break
;
case
6
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_DIFFERENT_TAAKE_CAR
);
break
;
case
7
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_ALSO_CAR
);
break
;
case
8
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_CANCEL
);
break
;
case
10
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_A
);
break
;
case
11
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_B
);
break
;
case
12
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_C
);
break
;
case
13
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_D
);
break
;
case
14
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_E
);
break
;
case
15
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_F
);
break
;
case
16
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_G
);
break
;
case
17
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_CANCEL_A
);
break
;
case
18
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_CANCEL_B
);
break
;
case
19
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_CANCEL_C
);
break
;
case
20
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_CANCEL_D
);
break
;
case
21
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_CANCEL_E
);
break
;
case
22
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_FINISH_A
);
break
;
case
23
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_FINISH_B
);
break
;
case
24
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_H
);
break
;
case
25
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_CANCEL_F
);
break
;
}
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/SmsService.java
View file @
11571dba
...
@@ -3,24 +3,12 @@ package com.xxfc.platform.universal.service;
...
@@ -3,24 +3,12 @@ package com.xxfc.platform.universal.service;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendBatchSmsRequest
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendBatchSmsResponse
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.http.FormatType
;
import
com.aliyuncs.http.HttpResponse
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.IClientProfile
;
import
com.aliyuncs.profile.IClientProfile
;
import
java.nio.charset.Charset
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
import
com.github.wxiaoqi.security.common.util.RandomUtil
;
import
com.github.wxiaoqi.security.common.util.RandomUtil
;
import
com.github.wxiaoqi.security.common.util.process.SystemConfig
;
import
com.github.wxiaoqi.security.common.util.process.SystemConfig
;
import
com.github.wxiaoqi.security.common.util.result.JsonResultUtil
;
import
com.github.wxiaoqi.security.common.util.result.JsonResultUtil
;
...
@@ -173,8 +161,6 @@ public class SmsService {
...
@@ -173,8 +161,6 @@ public class SmsService {
//组装请求对象
//组装请求对象
SendSmsRequest
request
=
new
SendSmsRequest
();
SendSmsRequest
request
=
new
SendSmsRequest
();
//使用post提交
request
.
setMethod
(
MethodType
.
POST
);
//必填:待发送手机号。支持JSON格式的批量调用,批量上限为100个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
//必填:待发送手机号。支持JSON格式的批量调用,批量上限为100个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
request
.
setPhoneNumbers
(
PhoneNumbers
);
request
.
setPhoneNumbers
(
PhoneNumbers
);
//必填:短信签名-可在短信控制台中找到
//必填:短信签名-可在短信控制台中找到
...
@@ -209,7 +195,7 @@ public class SmsService {
...
@@ -209,7 +195,7 @@ public class SmsService {
try
{
try
{
JSONObject
jsonParams
=
new
JSONObject
();
JSONObject
jsonParams
=
new
JSONObject
();
for
(
int
i
=
0
;
i
<
params
.
length
;
i
++){
for
(
int
i
=
0
;
i
<
params
.
length
;
i
++){
jsonParams
.
put
(
param
+
i
+
1
,
params
[
i
]);
jsonParams
.
put
(
param
+
(
i
+
1
)
,
params
[
i
]);
}
}
sendTemplate
(
PhoneNumbers
,
jsonParams
.
toJSONString
(),
templateCode
);
sendTemplate
(
PhoneNumbers
,
jsonParams
.
toJSONString
(),
templateCode
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
@@ -222,8 +208,8 @@ public class SmsService {
...
@@ -222,8 +208,8 @@ public class SmsService {
public
static
void
main
(
String
[]
args
)
throws
ClientException
,
InterruptedException
{
public
static
void
main
(
String
[]
args
)
throws
ClientException
,
InterruptedException
{
SmsService
smsService
=
new
SmsService
();
SmsService
smsService
=
new
SmsService
();
//发短信
//发短信
String
[]
params
={
"1"
,
"2"
,
"3"
,
"
4"
,
"5
"
};
String
[]
params
={
"1"
,
"2"
,
"3"
,
"
2019-08-29"
,
"松山湖
"
};
smsService
.
sendTemplateToJson
(
"13612688539
"
,
params
,
"123
"
);
smsService
.
sendTemplateToJson
(
"13612688539
,13265487972"
,
params
,
"SMS_169904346
"
);
/*System.out.println("短信接口返回的数据----------------");
/*System.out.println("短信接口返回的数据----------------");
System.out.println("Code=" + response.getCode());
System.out.println("Code=" + response.getCode());
System.out.println("Message=" + response.getMessage());
System.out.println("Message=" + response.getMessage());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment