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
fbee8634
Commit
fbee8634
authored
Jul 15, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/base-modify' into base-modify
parents
c86fad66
e720509a
Changes
51
Hide whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
3119 additions
and
102 deletions
+3119
-102
pom.xml
ace-common/pom.xml
+18
-0
CommonLogService.java
.../github/wxiaoqi/security/common/log/CommonLogService.java
+64
-0
CommonLogServiceImpl.java
...xiaoqi/security/common/log/Impl/CommonLogServiceImpl.java
+137
-0
XxLogInterceptor.java
.../github/wxiaoqi/security/common/log/XxLogInterceptor.java
+159
-0
LogEntity.java
.../github/wxiaoqi/security/common/log/entity/LogEntity.java
+40
-0
XxLogEntity.java
...ithub/wxiaoqi/security/common/log/entity/XxLogEntity.java
+40
-0
UserFeign.java
...va/com/github/wxiaoqi/security/admin/feign/UserFeign.java
+8
-0
WalletCathDetailVo.java
.../github/wxiaoqi/security/admin/vo/WalletCathDetailVo.java
+32
-0
WalletCathVo.java
...va/com/github/wxiaoqi/security/admin/vo/WalletCathVo.java
+1
-0
WalletDetailPageVo.java
.../github/wxiaoqi/security/admin/vo/WalletDetailPageVo.java
+45
-0
MyWalletCathBiz.java
...om/github/wxiaoqi/security/admin/biz/MyWalletCathBiz.java
+12
-0
MyWalletDetailBiz.java
.../github/wxiaoqi/security/admin/biz/MyWalletDetailBiz.java
+35
-0
MyWalletDetailController.java
...wxiaoqi/security/admin/rest/MyWalletDetailController.java
+49
-0
PublicController.java
.../github/wxiaoqi/security/admin/rest/PublicController.java
+22
-8
WalletCathController.java
...hub/wxiaoqi/security/admin/rest/WalletCathController.java
+12
-5
bootstrap.yml
...ivity/xx-activity-server/src/main/resources/bootstrap.yml
+2
-1
AppApplication.java
...r/src/main/java/com/xxfc/platform/app/AppApplication.java
+2
-1
bootstrap.yml
xx-app/xx-app-server/src/main/resources/bootstrap.yml
+2
-1
CampSiteApplication.java
.../java/com/xxfc/platform/campsite/CampSiteApplication.java
+2
-1
bootstrap.yml
...psite/xx-campsite-server/src/main/resources/bootstrap.yml
+2
-0
pom.xml
xx-common/xx-common-platform-web/pom.xml
+7
-0
pom.xml
xx-im/xx-im-server/pom.xml
+0
-4
ImApplication.java
...ver/src/main/java/com/xxfc/platform/im/ImApplication.java
+2
-1
OrderTypeEnum.java
.../xxfc/platform/order/contant/enumerate/OrderTypeEnum.java
+8
-1
RefundTypeEnum.java
...xxfc/platform/order/contant/enumerate/RefundTypeEnum.java
+5
-5
OrderApplication.java
...c/main/java/com/xxfc/platform/order/OrderApplication.java
+2
-1
BaseOrderBiz.java
...c/main/java/com/xxfc/platform/order/biz/BaseOrderBiz.java
+59
-9
OrderRentVehicleService.java
.../xxfc/platform/order/service/OrderRentVehicleService.java
+1
-1
bootstrap.yml
xx-order/xx-order-server/src/main/resources/bootstrap.yml
+2
-2
bootstrap.yml
xx-tour/xx-tour-server/src/main/resources/bootstrap.yml
+45
-44
TourGoodMapper.xml
...-tour-server/src/main/resources/mapper/TourGoodMapper.xml
+2
-2
pom.xml
xx-universal/xx-universal-api/pom.xml
+10
-0
SmsTemplateDTO.java
.../java/com/xxfc/platform/universal/dto/SmsTemplateDTO.java
+26
-0
ThirdFeign.java
...in/java/com/xxfc/platform/universal/feign/ThirdFeign.java
+4
-0
CCPRestSDK.java
...in/java/com/xxfc/platform/universal/utils/CCPRestSDK.java
+1806
-0
CCPRestSmsUtils.java
...va/com/xxfc/platform/universal/utils/CCPRestSmsUtils.java
+40
-0
CcopHttpClient.java
...ava/com/xxfc/platform/universal/utils/CcopHttpClient.java
+67
-0
DateUtil.java
...main/java/com/xxfc/platform/universal/utils/DateUtil.java
+78
-0
EncryptUtil.java
...n/java/com/xxfc/platform/universal/utils/EncryptUtil.java
+59
-0
PublicMsg.java
...ain/java/com/xxfc/platform/universal/utils/PublicMsg.java
+90
-0
Ueditor.java
...src/main/java/com/xxfc/platform/universal/vo/Ueditor.java
+14
-0
pom.xml
xx-universal/xx-universal-server/pom.xml
+6
-0
UniversalApplication.java
...ava/com/xxfc/platform/universal/UniversalApplication.java
+2
-1
CCPRestSmsBiz.java
...n/java/com/xxfc/platform/universal/biz/CCPRestSmsBiz.java
+42
-0
SmsController.java
...com/xxfc/platform/universal/controller/SmsController.java
+19
-4
UploadController.java
.../xxfc/platform/universal/controller/UploadController.java
+24
-4
bootstrap.yml
...rsal/xx-universal-server/src/main/resources/bootstrap.yml
+2
-1
VehicleApplication.java
...in/java/com/xxfc/platform/vehicle/VehicleApplication.java
+2
-1
WebConfiguration.java
...va/com/xxfc/platform/vehicle/config/WebConfiguration.java
+8
-1
bootstrap.yml
...ehicle/xx-vehicle-server/src/main/resources/bootstrap.yml
+1
-1
VehicleMapper.xml
...ehicle-server/src/main/resources/mapper/VehicleMapper.xml
+2
-2
No files found.
ace-common/pom.xml
View file @
fbee8634
...
...
@@ -170,6 +170,24 @@
<optional>
true
</optional>
</dependency>
<!-- mongodb -->
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-mongodb
</artifactId>
<version>
2.1.5.RELEASE
</version>
<scope>
compile
</scope>
<exclusions>
<exclusion>
<artifactId>
mongo-java-driver
</artifactId>
<groupId>
org.mongodb
</groupId>
</exclusion>
<exclusion>
<artifactId>
jcl-over-slf4j
</artifactId>
<groupId>
org.slf4j
</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
...
...
ace-common/src/main/java/com/github/wxiaoqi/security/common/log/CommonLogService.java
0 → 100644
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
common
.
log
;
import
com.github.wxiaoqi.security.common.log.entity.LogEntity
;
import
com.github.wxiaoqi.security.common.log.entity.XxLogEntity
;
import
com.github.wxiaoqi.security.common.msg.BaseResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Method
;
public
interface
CommonLogService
{
/**
* 记录日志
* @param logEntity
*/
void
log
(
LogEntity
logEntity
);
/**
* 记录日志
* @param xxLogEntity
*/
void
commonLog
(
XxLogEntity
xxLogEntity
);
/**
* 初始化日志前半部分
* @param xxLogEntity
* @param request
*/
void
initCommonLogPrePart
(
XxLogEntity
xxLogEntity
,
HttpServletRequest
request
,
ProceedingJoinPoint
pjp
);
/**
* 初始化日志后半部分
* @param xxLogEntity
* @param result
*/
void
initCommonLogLastPart
(
XxLogEntity
xxLogEntity
,
Object
result
);
/**
* 初始化日志后半部分(String)
* @param xxLogEntity
* @param result
*/
void
initCommonLogLastPart
(
XxLogEntity
xxLogEntity
,
String
result
);
/**
* 初始化FeignClient日志前半部分
* @param xxLogEntity
* @param targetMethod
*/
void
initFeignClientLogPrePart
(
XxLogEntity
xxLogEntity
,
Method
targetMethod
);
/**
* 初始化mq消息日志前半部分
* @param xxLogEntity
* @param targetMethod
*/
void
initMqLogPrePart
(
XxLogEntity
xxLogEntity
,
Method
targetMethod
);
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/log/Impl/CommonLogServiceImpl.java
0 → 100644
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
common
.
log
.
Impl
;
import
com.alibaba.fastjson.JSON
;
import
com.github.wxiaoqi.security.common.log.CommonLogService
;
import
com.github.wxiaoqi.security.common.log.entity.LogEntity
;
import
com.github.wxiaoqi.security.common.log.entity.XxLogEntity
;
import
com.github.wxiaoqi.security.common.msg.BaseResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Method
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
@Service
public
class
CommonLogServiceImpl
implements
CommonLogService
{
@Value
(
"${spring.application.name}"
)
private
String
applicationName
;
// 获取当前cpu个数
private
static
int
corePoolSize
=
Runtime
.
getRuntime
().
availableProcessors
();
// 设置任务队列,长度无限制
private
static
BlockingQueue
blockingQueue
=
new
LinkedBlockingQueue
<>();
// 定义线程池,初始化线程数为cpu个数,最大线程数为cpu个数*2, 档队列类型为LinkedBlockingQueue,maximumPoolSize 参数无效
private
static
ThreadPoolExecutor
threadPoolExecutor
=
new
ThreadPoolExecutor
(
corePoolSize
,
corePoolSize
*
2
,
60L
,
TimeUnit
.
SECONDS
,
blockingQueue
);
@Autowired
private
MongoTemplate
mongoTemplate
;
@Override
public
void
log
(
LogEntity
logEntity
){
threadPoolExecutor
.
execute
(
new
SycnLog
(
logEntity
)
);
}
class
SycnLog
implements
Runnable
{
private
LogEntity
logEntity
;
public
SycnLog
()
{
super
();
}
public
SycnLog
(
LogEntity
logEntity
)
{
super
();
this
.
logEntity
=
logEntity
;
}
@Override
public
void
run
()
{
mongoTemplate
.
insert
(
logEntity
);
}
}
@Override
public
void
commonLog
(
XxLogEntity
xxLogEntity
){
threadPoolExecutor
.
execute
(
new
SycnCommonLog
(
xxLogEntity
)
);
}
class
SycnCommonLog
implements
Runnable
{
private
XxLogEntity
xxLogEntity
;
public
SycnCommonLog
()
{
super
();
}
public
SycnCommonLog
(
XxLogEntity
xxLogEntity
)
{
super
();
this
.
xxLogEntity
=
xxLogEntity
;
}
@Override
public
void
run
()
{
mongoTemplate
.
insert
(
xxLogEntity
,
xxLogEntity
.
getMongoKey
());
}
}
@Override
public
void
initCommonLogPrePart
(
XxLogEntity
xxLogEntity
,
HttpServletRequest
request
,
ProceedingJoinPoint
pjp
)
{
//request 获得头部
xxLogEntity
.
setApp
(
request
.
getHeader
(
"app"
));
LocalDateTime
startTime
=
LocalDateTime
.
now
();
//开始时间
xxLogEntity
.
setCreateDate
(
startTime
.
toString
());
xxLogEntity
.
setServletPath
(
request
.
getServletPath
());
MethodSignature
signature
=
(
MethodSignature
)
pjp
.
getSignature
();
xxLogEntity
.
setMethod
(
signature
.
getMethod
().
toString
());
xxLogEntity
.
setMongoKey
(
applicationName
+
":"
+
request
.
getServletPath
());
}
@Override
public
void
initCommonLogLastPart
(
XxLogEntity
xxLogEntity
,
Object
result
)
{
initCommonLogLastPart
(
xxLogEntity
,
JSON
.
toJSONString
(
result
));
}
@Override
public
void
initCommonLogLastPart
(
XxLogEntity
xxLogEntity
,
String
result
)
{
LocalDateTime
endTime
=
LocalDateTime
.
now
();
//结束时间
xxLogEntity
.
setEndDate
(
endTime
.
toString
());
xxLogEntity
.
setResponseData
(
result
);
}
@Override
public
void
initFeignClientLogPrePart
(
XxLogEntity
xxLogEntity
,
Method
targetMethod
)
{
PostMapping
postMapping
=
targetMethod
.
getAnnotation
(
PostMapping
.
class
);
String
header
=
postMapping
.
headers
()[
0
];
xxLogEntity
.
setApp
(
header
.
substring
(
header
.
lastIndexOf
(
"app="
)
+
4
,
header
.
length
()));
LocalDateTime
startTime
=
LocalDateTime
.
now
();
//开始时间
xxLogEntity
.
setCreateDate
(
startTime
.
toString
());
xxLogEntity
.
setServletPath
(
postMapping
.
value
()[
0
]);
xxLogEntity
.
setMongoKey
(
applicationName
+
":"
+
"feignClient"
);
}
@Override
public
void
initMqLogPrePart
(
XxLogEntity
xxLogEntity
,
Method
targetMethod
)
{
PostMapping
postMapping
=
targetMethod
.
getAnnotation
(
PostMapping
.
class
);
String
header
=
postMapping
.
headers
()[
0
];
LocalDateTime
startTime
=
LocalDateTime
.
now
();
//开始时间
xxLogEntity
.
setCreateDate
(
startTime
.
toString
());
xxLogEntity
.
setServletPath
(
postMapping
.
value
()[
0
]);
xxLogEntity
.
setMongoKey
(
applicationName
+
":"
+
"mqSender"
);
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/log/XxLogInterceptor.java
0 → 100644
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
common
.
log
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.log.CommonLogService
;
import
com.github.wxiaoqi.security.common.log.entity.XxLogEntity
;
import
com.github.wxiaoqi.security.common.msg.BaseResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* Created by zhoujianwei
* cas 项目注解相关拦截器
* Date : 2018/6/6.
* Time : 18:13
*/
@Aspect
@Component
@Slf4j
public
class
XxLogInterceptor
{
@Autowired
CommonLogService
commonLogService
;
//触发条件为:com.xxfc.platform包下面所有controller
@Around
(
"within(com.xxfc.platform.*.rest..* || com.xxfc.platform.*.controller..*)"
)
public
Object
doAroundXxControllerLog
(
ProceedingJoinPoint
pjp
)
throws
Throwable
{
ServletRequestAttributes
servletRequestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
servletRequestAttributes
.
getRequest
();
//获取request
HttpServletResponse
response
=
servletRequestAttributes
.
getResponse
();
//获取response
//request 获得头部
XxLogEntity
xxLogEntity
=
new
XxLogEntity
();
commonLogService
.
initCommonLogPrePart
(
xxLogEntity
,
request
,
pjp
);
Object
[]
params
=
pjp
.
getArgs
();
//获取请求参数
MethodSignature
signature
=
(
MethodSignature
)
pjp
.
getSignature
();
if
(
params
!=
null
&&
params
.
length
>
0
)
{
try
{
xxLogEntity
.
setRequestData
(
JSON
.
toJSONString
(
params
[
0
]));
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
Object
result
=
new
Object
();
try
{
//###################上面代码为方法执行前#####################
result
=
pjp
.
proceed
();
//执行方法,获取返回参数
//###################下面代码为方法执行后#####################
if
(
result
instanceof
JSONObject
)
{
commonLogService
.
initCommonLogLastPart
(
xxLogEntity
,
((
JSONObject
)
result
).
toJSONString
());
}
else
{
commonLogService
.
initCommonLogLastPart
(
xxLogEntity
,
result
);
}
}
catch
(
BaseException
e
){
commonLogService
.
initCommonLogLastPart
(
xxLogEntity
,
ObjectRestResponse
.
createFailedResult
(
e
.
getStatus
(),
e
.
getMessage
()));
throw
e
;
}
catch
(
Exception
e
){
commonLogService
.
initCommonLogLastPart
(
xxLogEntity
,
ObjectRestResponse
.
createFailedResult
(
500
,
e
.
getMessage
()));
throw
e
;
}
finally
{
commonLogService
.
commonLog
(
xxLogEntity
);
}
return
result
;
}
// @Around("within(com.github.wxiaoqi.security.security.gate.filter..*)")
// public Object doAroundXxControllerLog(ProceedingJoinPoint pjp) throws Throwable {
//
// }
// //casEipMsgErrDeal:外联报错消息处理
// @AfterReturning(value = "within(com.ht.cas.*.*.*.*) && @annotation(casEipMsgErrDeal)", returning = "result")
// public Result doAfterCasEipMsgErrDeal(JoinPoint jp, Result result, CasEipMsgErrDeal casEipMsgErrDeal) {
// String msg = result.getMsg();
// if(StringUtils.isBlank(msg)) {
// msg = result.getCodeDesc();
// }
// //returnCode不为EIP_SUCCESS_CODE 并且 msg 没有信息
// if(!CommonConstant.EIP_SUCCESS_CODE.equals(result.getReturnCode())) {
// result.setData(null);
// if(StringUtils.isBlank(msg)) {
// Map map = ((List<Map>)result.getData()).get(0);
// msg = map.get("field").toString() + " " + map.get("defaultMessage");
// }
// }
// result.setMsg(msg);
// return result;
// }
//
// //casMqSenderLog:mq发送消息
// @Around(value = "within(com.ht.cas..*) && @annotation(casMqSenderLog)")
// public void doAfterCasMqSenderLog(ProceedingJoinPoint pjp, CasMqSenderLog casMqSenderLog) {
//
// }
//
// //casMqSenderLog:mq接收消息
// @Around(value = "within(com.ht.cas..*) && @annotation(casMqReceiverLog)")
// public void doAfterCasMqLog(ProceedingJoinPoint pjp, CasMqReceiverLog casMqReceiverLog) {
//
// }
//
//
// // defined aop pointcut
// @Pointcut("execution(* com.ht.cas.common.feignClient.*.*(..))")
// public void casFeignClientLog() {
// }
//
//
// //@Around("casFeignClientLog()")
// public Object doAroundCasFeignClientLog(ProceedingJoinPoint pjp) throws Throwable {
// //request 获得头部
// Signature signature = pjp.getSignature();
// MethodSignature methodSignature = (MethodSignature)signature;
// Method targetMethod = methodSignature.getMethod();
//
// XxLogEntity xxLogEntity = new XxLogEntity();
// commonLogService.initFeignClientLogPrePart(xxLogEntity, targetMethod);
//
// Object[] params = pjp.getArgs();//获取请求参数
//
// if(params != null && params.length > 0) {
// xxLogEntity.setRequestData(JSON.toJSONString(params[0]));
// }
// Object result = new Object();
// try{
// //###################上面代码为方法执行前#####################
// result = pjp.proceed();//执行方法,获取返回参数
// //###################下面代码为方法执行后#####################
// commonLogService.initCommonLogLastPart(xxLogEntity, (Result) result);
// }catch (Exception e){
// commonLogService.initCommonLogLastPart(xxLogEntity, (Result) result);
// xxLogEntity.setResponseData(JSON.toJSONString(ResultHelper.buildFail(e.getMessage())));
// throw e;
// }finally {
// commonLogService.commonLog(xxLogEntity);
// }
//
// return result;
// }
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/log/entity/LogEntity.java
0 → 100644
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
common
.
log
.
entity
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.UUID
;
/**
* 日誌信息
*/
@Data
public
class
LogEntity
implements
Serializable
{
public
LogEntity
(){
super
();
}
public
LogEntity
(
String
businessCode
,
String
url
,
String
app
,
String
appName
,
String
requestData
,
String
responseData
,
Date
createDate
,
Date
endDate
)
{
super
();
this
.
businessCode
=
businessCode
;
this
.
url
=
url
;
this
.
app
=
app
;
this
.
appName
=
appName
;
this
.
requestData
=
requestData
;
this
.
responseData
=
responseData
;
this
.
createDate
=
createDate
;
this
.
endDate
=
endDate
;
}
private
String
businessCode
;
private
String
url
;
private
String
app
;
private
String
appName
;
private
String
requestData
;
private
String
responseData
;
private
Date
createDate
;
private
Date
endDate
;
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/log/entity/XxLogEntity.java
0 → 100644
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
common
.
log
.
entity
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* Created by zhoujianwei
* Date : 2018/6/6.
* Time : 16:59
*/
@Data
public
class
XxLogEntity
implements
Serializable
{
private
String
app
;
private
String
servletPath
;
private
String
requestData
;
private
String
responseData
;
private
String
createDate
;
private
String
endDate
;
private
String
requestPath
;
private
String
method
;
private
String
mongoKey
;
public
XxLogEntity
()
{
super
();
}
public
XxLogEntity
(
String
app
,
String
servletPath
,
String
requestData
,
String
responseData
,
String
createDate
,
String
endDate
,
String
requestPath
,
String
mongoKey
)
{
this
.
app
=
app
;
this
.
servletPath
=
servletPath
;
this
.
requestData
=
requestData
;
this
.
responseData
=
responseData
;
this
.
createDate
=
createDate
;
this
.
endDate
=
endDate
;
this
.
requestPath
=
requestPath
;
this
.
mongoKey
=
mongoKey
;
}
}
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/feign/UserFeign.java
View file @
fbee8634
...
...
@@ -39,6 +39,14 @@ public interface UserFeign {
@RequestMapping
(
value
=
"/public/userinfo-by-uid"
)
public
ObjectRestResponse
<
UserDTO
>
userinfoByUid
(
@RequestParam
(
"uid"
)
Integer
uid
);
/**
* id获取用户信息
* @param id
* @return
*/
@RequestMapping
(
value
=
"/public/app/userinfo-by-id"
)
public
ObjectRestResponse
<
AppUserDTO
>
userDetailById
(
@RequestParam
(
"id"
)
Integer
id
);
/**
*status:0-判断是否认证过,1-认证成功后修改用户认证状态
...
...
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/vo/WalletCathDetailVo.java
0 → 100644
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/15 9:55
*/
@Data
public
class
WalletCathDetailVo
{
/**
* 订单状态:0-未提现,待审核,1-已审核
*/
@ApiModelProperty
(
value
=
"订单状态:0-未提现,待审核,1-已审核"
)
private
Integer
stauts
;
/**
* 提现日期
*/
@ApiModelProperty
(
value
=
"提现日期"
,
hidden
=
true
)
private
Long
crtTime
;
/**
* 审核日期
*/
@ApiModelProperty
(
value
=
"审核日期"
)
private
Long
finishTime
;
}
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/vo/WalletCathVo.java
View file @
fbee8634
...
...
@@ -14,6 +14,7 @@ import java.math.BigDecimal;
@Data
public
class
WalletCathVo
{
private
Long
id
;
/**
* 用户iD
*/
...
...
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/vo/WalletDetailPageVo.java
0 → 100644
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/15 9:22
*/
@Data
public
class
WalletDetailPageVo
{
@ApiModelProperty
(
"主键ID"
)
private
Integer
id
;
/**
* 来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买
*/
@ApiModelProperty
(
value
=
"来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买"
)
private
Integer
source
;
/**
* 收入/支出:0-收入,1-支出
*/
@ApiModelProperty
(
value
=
"收入/支出:0-收入,1-支出"
)
private
Integer
itype
;
/**
* 收入/支出的金额(分)
*/
@ApiModelProperty
(
value
=
"收入/支出的金额(分)"
)
private
BigDecimal
amount
;
/**
* 操作时间
*/
@ApiModelProperty
(
value
=
"操作时间"
,
hidden
=
true
)
private
Long
crtTime
;
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/MyWalletCathBiz.java
View file @
fbee8634
...
...
@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.biz;
import
com.github.wxiaoqi.security.admin.entity.MyWalletCath
;
import
com.github.wxiaoqi.security.admin.mapper.MyWalletCathMapper
;
import
com.github.wxiaoqi.security.admin.vo.WalletCathDetailVo
;
import
com.github.wxiaoqi.security.admin.vo.WalletCathPageVo
;
import
com.github.wxiaoqi.security.admin.vo.WalletCathVo
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
...
...
@@ -15,6 +16,7 @@ import tk.mybatis.mapper.entity.Example;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author libin
...
...
@@ -59,4 +61,14 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
return
walletCathPageVo
;
}
public
WalletCathDetailVo
getWalletCathDetailById
(
Long
id
)
{
WalletCathDetailVo
walletCathDetailVo
=
new
WalletCathDetailVo
();
MyWalletCath
myWalletCath
=
new
MyWalletCath
();
myWalletCath
.
setId
(
id
);
MyWalletCath
walletCath
=
mapper
.
selectByPrimaryKey
(
myWalletCath
);
Optional
.
ofNullable
(
walletCath
).
ifPresent
(
wc
->{
BeanUtils
.
copyProperties
(
wc
,
walletCathDetailVo
);
});
return
walletCathDetailVo
;
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/MyWalletDetailBiz.java
View file @
fbee8634
...
...
@@ -2,9 +2,17 @@ package com.github.wxiaoqi.security.admin.biz;
import
com.github.wxiaoqi.security.admin.entity.MyWalletDetail
;
import
com.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper
;
import
com.github.wxiaoqi.security.admin.vo.WalletDetailPageVo
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -18,4 +26,31 @@ import org.springframework.transaction.annotation.Transactional;
public
class
MyWalletDetailBiz
extends
BaseBiz
<
MyWalletDetailMapper
,
MyWalletDetail
>
{
public
PageDataVO
<
WalletDetailPageVo
>
findWalletDetailPage
(
Integer
userId
,
Integer
pageNo
,
Integer
pageSize
){
PageDataVO
<
WalletDetailPageVo
>
walletDetailPageVo
=
new
PageDataVO
<>();
Example
example
=
new
Example
(
MyWalletDetail
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andEqualTo
(
"userId"
,
userId
);
PageDataVO
<
WalletDetailPageVo
>
walletDetailPageVoPageDataVO
=
PageDataVO
.
pageInfo
(
pageNo
,
pageSize
,
()
->
mapper
.
selectByExample
(
example
));
List
<
WalletDetailPageVo
>
walletDetails
=
walletDetailPageVoPageDataVO
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
walletDetails
)){
return
walletDetailPageVo
;
}
List
<
WalletDetailPageVo
>
walletDetailPageVoList
=
new
ArrayList
<>();
WalletDetailPageVo
walletDetail
;
for
(
WalletDetailPageVo
walletDetailPage
:
walletDetails
)
{
walletDetail
=
new
WalletDetailPageVo
();
BeanUtils
.
copyProperties
(
walletDetailPage
,
walletDetail
);
walletDetailPageVoList
.
add
(
walletDetail
);
}
walletDetailPageVo
.
setTotalPage
(
walletDetailPageVoPageDataVO
.
getTotalPage
());
walletDetailPageVo
.
setTotalCount
(
walletDetailPageVoPageDataVO
.
getTotalCount
());
walletDetailPageVo
.
setPageSize
(
walletDetailPageVoPageDataVO
.
getPageSize
());
walletDetailPageVo
.
setPageNum
(
walletDetailPageVoPageDataVO
.
getPageNum
());
walletDetailPageVo
.
setData
(
walletDetailPageVoList
);
return
walletDetailPageVo
;
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rest/MyWalletDetailController.java
0 → 100644
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
rest
;
import
com.github.wxiaoqi.security.admin.biz.MyWalletDetailBiz
;
import
com.github.wxiaoqi.security.admin.vo.WalletDetailPageVo
;
import
com.github.wxiaoqi.security.auth.client.config.UserAuthConfig
;
import
com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil
;
import
com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/15 9:45
*/
@RestController
@RequestMapping
(
"/walletDetail"
)
public
class
MyWalletDetailController
{
@Autowired
private
MyWalletDetailBiz
myWalletDetailBiz
;
@Autowired
private
UserAuthUtil
userAuthUtil
;
@Autowired
private
UserAuthConfig
userAuthConfig
;
@GetMapping
(
"/page"
)
public
ObjectRestResponse
<
PageDataVO
<
WalletDetailPageVo
>>
findWalletDetailPage
(
@RequestParam
(
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
HttpServletRequest
request
)
{
try
{
IJWTInfo
infoFromToken
=
userAuthUtil
.
getInfoFromToken
(
userAuthConfig
.
getToken
(
request
));
PageDataVO
<
WalletDetailPageVo
>
walletDetailPage
=
myWalletDetailBiz
.
findWalletDetailPage
(
Integer
.
valueOf
(
infoFromToken
.
getId
()),
pageNo
,
pageSize
);
return
ObjectRestResponse
.
succ
(
walletDetailPage
);
}
catch
(
Exception
e
)
{
throw
new
BaseException
(
e
);
}
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rest/PublicController.java
View file @
fbee8634
...
...
@@ -22,10 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.*
;
/**
* ${DESCRIPTION}
...
...
@@ -70,14 +68,30 @@ public class PublicController {
ObjectRestResponse
userDetailByToken
(
String
token
)
throws
Exception
{
String
username
=
userAuthUtil
.
getInfoFromToken
(
token
).
getId
();
if
(
username
==
null
)
{
throw
new
BaseException
(
ResultCode
.
NOTEXIST_CODE
);
throw
new
BaseException
(
ResultCode
.
NOTEXIST_CODE
,
new
HashSet
<
String
>()
{{
add
(
"用户名不存在!"
);}});
}
AppUserDTO
userDTO
=
new
AppUserDTO
();
Integer
userid
=
Integer
.
parseInt
(
username
);
return
ObjectRestResponse
.
succ
(
getAppUserInfoById
(
userid
));
}
@RequestMapping
(
value
=
"/app/userinfo-by-id"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
ObjectRestResponse
<
AppUserDTO
>
userDetailById
(
Integer
id
)
throws
Exception
{
if
(
id
==
null
)
{
throw
new
BaseException
(
ResultCode
.
NOTEXIST_CODE
,
new
HashSet
<
String
>()
{{
add
(
"用户名不存在!"
);}});
}
return
ObjectRestResponse
.
succ
(
getAppUserInfoById
(
id
));
}
private
AppUserDTO
getAppUserInfoById
(
Integer
userid
)
throws
IllegalAccessException
,
InvocationTargetException
{
AppUserDTO
userDTO
=
new
AppUserDTO
();
//获取用户基础信息
AppUserVo
userVo
=
detailBiz
.
getUserInfoById
(
userid
);
if
(
userVo
==
null
)
{
throw
new
BaseException
(
ResultCode
.
NOTEXIST_CODE
);
throw
new
BaseException
(
ResultCode
.
NOTEXIST_CODE
,
new
HashSet
<
String
>()
{{
add
(
"用户不存在!"
);}});
}
Integer
id
=
userVo
.
getId
();
Integer
positionId
=
userVo
.
getPositionId
();
...
...
@@ -94,7 +108,7 @@ public class PublicController {
userDTO
.
setPositionName
(
userPosition
.
getName
());
}
userDTO
.
setId
(
id
);
return
new
ObjectRestResponse
<
AppUserDetail
>().
rel
(
true
).
data
(
userDTO
)
;
return
userDTO
;
}
@RequestMapping
(
value
=
"/userinfo-by-uid"
,
method
=
RequestMethod
.
GET
)
...
...
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rest/WalletCathController.java
View file @
fbee8634
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
rest
;
import
com.github.wxiaoqi.security.admin.biz.MyWalletCathBiz
;
import
com.github.wxiaoqi.security.admin.vo.WalletCathDetailVo
;
import
com.github.wxiaoqi.security.admin.vo.WalletCathPageVo
;
import
com.github.wxiaoqi.security.auth.client.config.UserAuthConfig
;
import
com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil
;
import
com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -34,7 +33,8 @@ public class WalletCathController {
@Autowired
private
UserAuthConfig
userAuthConfig
;
@GetMapping
@ApiOperation
(
"提现记录列表"
)
@GetMapping
(
"/page"
)
public
ObjectRestResponse
<
WalletCathPageVo
>
findWatchCatchByWithdrawalState
(
@RequestParam
(
"state"
)
Integer
state
,
@RequestParam
(
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
...
...
@@ -47,4 +47,11 @@ public class WalletCathController {
throw
new
BaseException
(
e
);
}
}
@ApiOperation
(
"提现详情"
)
@GetMapping
(
"/detail/{id}"
)
public
ObjectRestResponse
<
WalletCathDetailVo
>
getWalletCathDetailById
(
@PathVariable
(
value
=
"id"
)
Long
id
)
{
WalletCathDetailVo
walletCathDetailVo
=
myWalletCathBiz
.
getWalletCathDetailById
(
id
);
return
ObjectRestResponse
.
succ
(
walletCathDetailVo
);
}
}
xx-activity/xx-activity-server/src/main/resources/bootstrap.yml
View file @
fbee8634
...
...
@@ -24,7 +24,8 @@ spring:
nacos
:
config
:
server-addr
:
127.0.0.1:8848
#共用配置,暂定一个
shared-dataids
:
common-dev.yaml,mongodb-log-dev.yaml
---
spring
:
profiles
:
pro
...
...
xx-app/xx-app-server/src/main/java/com/xxfc/platform/app/AppApplication.java
View file @
fbee8634
...
...
@@ -11,7 +11,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
(
scanBasePackages
=
{
"com.xxfc.platform"
,
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler"
,
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableScheduling
...
...
xx-app/xx-app-server/src/main/resources/bootstrap.yml
View file @
fbee8634
...
...
@@ -24,7 +24,8 @@ spring:
nacos
:
config
:
server-addr
:
127.0.0.1:8848
#共用配置,暂定一个
shared-dataids
:
common-dev.yaml,mongodb-log-dev.yaml
---
spring
:
profiles
:
pro
...
...
xx-campsite/xx-campsite-server/src/main/java/com/xxfc/platform/campsite/CampSiteApplication.java
View file @
fbee8634
...
...
@@ -19,7 +19,8 @@ import tk.mybatis.spring.annotation.MapperScan;
*/
@SpringBootApplication
(
scanBasePackages
=
{
"com.xxfc.platform"
,
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler"
,
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableAceAuthClient
...
...
xx-campsite/xx-campsite-server/src/main/resources/bootstrap.yml
View file @
fbee8634
...
...
@@ -14,6 +14,8 @@ spring:
nacos
:
config
:
server-addr
:
127.0.0.1:8848
#共用配置,暂定一个
shared-dataids
:
common-dev.yaml,mongodb-log-dev.yaml
---
spring
:
...
...
xx-common/xx-common-platform-web/pom.xml
View file @
fbee8634
...
...
@@ -123,6 +123,13 @@
<artifactId>
swagger-spring-boot-starter
</artifactId>
<version>
1.8.0.RELEASE
</version>
</dependency>
<!-- mongodb -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-mongodb
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
xx-im/xx-im-server/pom.xml
View file @
fbee8634
...
...
@@ -49,10 +49,6 @@
</dependency>
<!--mongodb-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-mongodb
</artifactId>
</dependency>
<dependency>
<groupId>
org.mongodb.morphia
</groupId>
<artifactId>
morphia
</artifactId>
...
...
xx-im/xx-im-server/src/main/java/com/xxfc/platform/im/ImApplication.java
View file @
fbee8634
...
...
@@ -13,7 +13,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
(
scanBasePackages
=
{
"com.xxfc.platform"
,
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler"
,
"com.github.wxiaoqi.security.common.log"
},
exclude
=
DataSourceAutoConfiguration
.
class
)
@EnableDiscoveryClient
@EnableScheduling
...
...
xx-order/xx-order-api/src/main/java/com/xxfc/platform/order/contant/enumerate/OrderTypeEnum.java
View file @
fbee8634
...
...
@@ -17,7 +17,14 @@ public enum OrderTypeEnum {
*/
private
String
desc
;
private
static
Map
<
Integer
,
String
>
codeAndDesc
=
new
HashMap
<
Integer
,
String
>();
public
static
Map
<
Integer
,
OrderTypeEnum
>
codeAndDesc
=
new
HashMap
<
Integer
,
OrderTypeEnum
>();
//Maps.newHashMap();
static
{
for
(
OrderTypeEnum
enumE
:
OrderTypeEnum
.
values
()){
codeAndDesc
.
put
(
enumE
.
getCode
(),
enumE
);
}
}
OrderTypeEnum
(
Integer
code
,
String
desc
){
this
.
code
=
code
;
...
...
xx-order/xx-order-api/src/main/java/com/xxfc/platform/order/contant/enumerate/RefundTypeEnum.java
View file @
fbee8634
...
...
@@ -19,11 +19,11 @@ public enum RefundTypeEnum {
private
static
Map
<
Integer
,
String
>
codeAndDesc
=
new
HashMap
<
Integer
,
String
>();
//Maps.newHashMap();
//
static{
// for(VehicleBookRecordStatus constantType : VehicleBookRecordStatus
.values()){
// codeAndDesc.put(constantType.getCode(),constantType
.getDesc());
//
}
//
}
static
{
for
(
RefundTypeEnum
enumE
:
RefundTypeEnum
.
values
()){
codeAndDesc
.
put
(
enumE
.
getCode
(),
enumE
.
getDesc
());
}
}
RefundTypeEnum
(
Integer
code
,
String
desc
){
this
.
code
=
code
;
...
...
xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/OrderApplication.java
View file @
fbee8634
...
...
@@ -13,7 +13,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
(
scanBasePackages
=
{
"com.xxfc.platform"
,
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler"
,
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableScheduling
...
...
xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/biz/BaseOrderBiz.java
View file @
fbee8634
package
com
.
xxfc
.
platform
.
order
.
biz
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.wxiaoqi.security.admin.dto.UserMemberDTO
;
import
com.github.wxiaoqi.security.admin.feign.UserFeign
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
...
...
@@ -19,6 +21,7 @@ import com.xxfc.platform.order.pojo.order.OrderListVo;
import
com.xxfc.platform.order.pojo.order.OrderPageVO
;
import
com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto
;
import
com.xxfc.platform.tour.feign.TourFeign
;
import
com.xxfc.platform.universal.dto.SmsTemplateDTO
;
import
com.xxfc.platform.universal.feign.ThirdFeign
;
import
com.xxfc.platform.universal.vo.OrderRefundVo
;
import
com.xxfc.platform.vehicle.common.RestResponse
;
...
...
@@ -387,7 +390,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
* @param orderNo
* @param tradeNo
*/
@Transactional
public
void
payNotifyHandle
(
String
orderNo
,
String
tradeNo
,
Integer
type
)
{
OrderRentVehicleDetail
orvd
=
new
OrderRentVehicleDetail
();
OrderMemberDetail
omd
=
new
OrderMemberDetail
();
BaseOrder
baseOrder
=
this
.
selectOne
(
new
BaseOrder
()
{{
setNo
(
orderNo
);
}});
...
...
@@ -406,23 +412,25 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
if
(
OrderTypeEnum
.
MEMBER
.
getCode
().
equals
(
baseOrder
.
getType
()))
{
//直接设置订单完成
updateOrder
.
setStatus
(
OrderStatusEnum
.
ORDER_FINISH
.
getCode
());
OrderMemberDetail
omd
=
orderMemberDetailBiz
.
selectOne
(
new
OrderMemberDetail
(){{
omd
=
orderMemberDetailBiz
.
selectOne
(
new
OrderMemberDetail
(){{
setOrderId
(
baseOrder
.
getId
());
}});
//触发会员效益
ObjectRestResponse
orr
=
userFeign
.
buyMember
(
new
UserMemberDTO
()
{{
UserMemberDTO
userMemberDTO
=
new
UserMemberDTO
()
{{
setUserId
(
baseOrder
.
getUserId
());
setDiscount
(
omd
.
getRebate
());
setIsBind
(
ISBIND_BIND
);
setMemberLevel
(
omd
.
getMemberLevel
());
setRentFreeDays
(
omd
.
getRentFreeNum
());
setTotalNumber
(
omd
.
getRentFreeNum
());
}});
}};
userMemberDTO
.
setMemberLevel
(
omd
.
getMemberLevel
());
userMemberDTO
.
setRentFreeDays
(
omd
.
getRentFreeNum
());
userMemberDTO
.
setTotalNumber
(
omd
.
getRentFreeNum
());
userMemberDTO
.
setDiscount
(
omd
.
getRebate
());
ObjectRestResponse
orr
=
userFeign
.
buyMember
(
userMemberDTO
);
log
.
info
(
"orr.getStatus() : "
+
orr
.
getStatus
()
);
}
else
if
(
OrderTypeEnum
.
RENT_VEHICLE
.
getCode
().
equals
(
baseOrder
.
getType
()))
{
updateOrder
.
setStatus
(
OrderStatusEnum
.
ORDER_TOSTART
.
getCode
());
OrderRentVehicleDetail
orvd
=
orderRentVehicleBiz
.
selectOne
(
new
OrderRentVehicleDetail
(){{
orvd
=
orderRentVehicleBiz
.
selectOne
(
new
OrderRentVehicleDetail
(){{
setOrderId
(
baseOrder
.
getId
());
}});
//车辆预定审核通过
...
...
@@ -441,7 +449,49 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//站点总人数添加
tourFeign
.
updateTourGoodPersonNum
(
otd
.
getVerificationId
(),
TourFeign
.
TOTAL_PERSON
,
otd
.
getTotalNumber
());
}
this
.
updateSelectiveByIdRe
(
updateOrder
);
try
{
this
.
updateSelectiveByIdRe
(
updateOrder
);
}
finally
{
OrderTypeEnum
orderTypeEnum
=
OrderTypeEnum
.
codeAndDesc
.
get
(
baseOrder
.
getType
());
AppUserDTO
appUserDTO
=
userFeign
.
userDetailById
(
baseOrder
.
getUserId
()).
getData
();
Integer
smstype
;
List
<
String
>
smsParams
=
new
ArrayList
<
String
>();
smsParams
.
add
(
baseOrder
.
getRealAmount
().
toString
());
switch
(
orderTypeEnum
)
{
case
RENT_VEHICLE:
if
(
orvd
.
getFreeDays
()
>
0
)
{
smstype
=
SmsTemplateDTO
.
RENT_MEMENT
;
smsParams
.
add
(
orvd
.
getFreeDays
().
toString
());
smsParams
.
add
(
appUserDTO
.
getRentFreeDays
().
toString
());
}
else
{
smstype
=
SmsTemplateDTO
.
RENT_NORMAL
;
}
thirdFeign
.
sendTemplate
(
new
SmsTemplateDTO
(){{
setPhoneNumbers
(
appUserDTO
.
getUsername
());
setType
(
smstype
);
setParams
(
smsParams
.
toArray
(
new
String
[
smsParams
.
size
()]));
}});
break
;
case
TOUR:
thirdFeign
.
sendTemplate
(
new
SmsTemplateDTO
(){{
setPhoneNumbers
(
appUserDTO
.
getUsername
());
setType
(
SmsTemplateDTO
.
TOUR
);
setParams
(
smsParams
.
toArray
(
new
String
[
smsParams
.
size
()]));
}});
break
;
case
MEMBER:
smsParams
.
add
(
omd
.
getRentFreeNum
().
toString
());
smsParams
.
add
(
appUserDTO
.
getRentFreeDays
().
toString
());
thirdFeign
.
sendTemplate
(
new
SmsTemplateDTO
(){{
setPhoneNumbers
(
appUserDTO
.
getUsername
());
setType
(
SmsTemplateDTO
.
MEMENT
);
setParams
(
smsParams
.
toArray
(
new
String
[
smsParams
.
size
()]));
}});
break
;
default
:
break
;
}
}
}
else
{
log
.
error
(
" order has payed , orderNo:{}, tradeNo:{} "
,
orderNo
,
tradeNo
);
}
...
...
xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/service/OrderRentVehicleService.java
View file @
fbee8634
...
...
@@ -207,7 +207,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}
//商品价格
goodsAmount
=
goodsAmount
.
add
(
vehicleAmount
).
add
(
driverAmount
);
goodsAmount
=
goodsAmount
.
add
(
vehicleAmount
).
add
(
driverAmount
)
.
add
(
damageSafeAmount
)
;
//总价格(包含押金)
orderAmount
=
orderAmount
.
add
(
goodsAmount
).
add
(
vehicleModel
.
getDeposit
());
...
...
xx-order/xx-order-server/src/main/resources/bootstrap.yml
View file @
fbee8634
...
...
@@ -14,8 +14,8 @@ spring:
nacos
:
config
:
server-addr
:
127.0.0.1:8848
#共用配置,
暂定一个
shared-dataids
:
common
aaa
-dev.yaml
#共用配置,
+ mongodb日志配置
shared-dataids
:
common
-dev.yaml,mongodb-log
-dev.yaml
#---
#spring:
...
...
xx-tour/xx-tour-server/src/main/resources/bootstrap.yml
View file @
fbee8634
#spring:
# application:
# name: vehicle
# cloud:
# nacos:
# config:
# server-addr: 127.0.0.1:8848
# file-extension: yaml
# profiles:
# active: dev
spring
:
profiles
:
active
:
dev
application
:
name
:
xx-tour
cloud
:
nacos
:
config
:
file-extension
:
yaml
debug
:
true
feign
:
compression
:
response
:
enabled
:
true
request
:
enabled
:
true
logging
:
level
:
com.github.wxiaoqi
:
debug
com.xxfc
:
debug
---
spring
:
profiles
:
dev
cloud
:
nacos
:
config
:
server-addr
:
127.0.0.1:8848
---
spring
:
profiles
:
pro
cloud
:
nacos
:
config
:
#spring:
# application:
# name: vehicle
# cloud:
# nacos:
# config:
# server-addr: 127.0.0.1:8848
# file-extension: yaml
# profiles:
# active: dev
spring
:
profiles
:
active
:
dev
application
:
name
:
xx-tour
cloud
:
nacos
:
config
:
file-extension
:
yaml
debug
:
true
feign
:
compression
:
response
:
enabled
:
true
request
:
enabled
:
true
logging
:
level
:
com.github.wxiaoqi
:
debug
com.xxfc
:
debug
---
spring
:
profiles
:
dev
cloud
:
nacos
:
config
:
server-addr
:
127.0.0.1:8848
#共用配置,暂定一个
shared-dataids
:
common-dev.yaml,mongodb-log-dev.yaml
---
spring
:
profiles
:
pro
cloud
:
nacos
:
config
:
server-addr
:
10.5.52.2:8848
\ No newline at end of file
xx-tour/xx-tour-server/src/main/resources/mapper/TourGoodMapper.xml
View file @
fbee8634
...
...
@@ -88,7 +88,7 @@
from tour_good g
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id
where g.recommend=1 and g.status=1 and g.is_del=0
where g.recommend=1 and g.status=1 and g.is_del=0
and t.is_del=0
GROUP BY g.id
ORDER BY g.rank DESC ,g.id DESC
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
...
...
@@ -104,7 +104,7 @@
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id
<where>
g.is_del=0
g.is_del=0
and t.is_del=0
<if
test=
"params.name != null and params.name != ''"
>
and (g.`name` like CONCAT('%',#{params.name},'%') or g.introduce like CONCAT('%',#{params.name},'%'))
</if>
...
...
xx-universal/xx-universal-api/pom.xml
View file @
fbee8634
...
...
@@ -50,6 +50,16 @@
<artifactId>
httpclient
</artifactId>
<version>
4.5
</version>
</dependency>
<!-- 短信机-->
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.8.5
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
</dependency>
</dependencies>
...
...
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/dto/SmsTemplateDTO.java
0 → 100644
View file @
fbee8634
package
com
.
xxfc
.
platform
.
universal
.
dto
;
import
lombok.Data
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/3 17:51
*/
@Data
public
class
SmsTemplateDTO
{
public
static
final
int
RENT_NORMAL
=
1
;
public
static
final
int
RENT_MEMENT
=
2
;
public
static
final
int
TOUR
=
3
;
public
static
final
int
MEMENT
=
4
;
//类型:1-租车订单通知(普通用户),2-租车订单短信(会员权益),3-旅游订单短信,4-加入会员通知
private
Integer
type
;
//手机号码(多个短信逗号隔开)
private
String
phoneNumbers
;
//参数
private
String
[]
params
;
}
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/feign/ThirdFeign.java
View file @
fbee8634
...
...
@@ -3,6 +3,7 @@ package com.xxfc.platform.universal.feign;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.universal.dto.RegionDTO
;
import
com.xxfc.platform.universal.dto.SmsTemplateDTO
;
import
com.xxfc.platform.universal.entity.Dictionary
;
import
com.xxfc.platform.universal.entity.OrderRefund
;
import
com.xxfc.platform.universal.vo.*
;
...
...
@@ -29,6 +30,9 @@ public interface ThirdFeign {
@RequestMapping
(
value
=
"/sms/app/unauth/sendCode"
,
method
=
RequestMethod
.
GET
)
//发送短信模板消息
public
JSONObject
sendCode
(
@RequestParam
(
"phone"
)
String
phone
,
@RequestParam
(
"code"
)
String
code
,
@RequestParam
(
"templateCode"
)
String
templateCode
);
//云通讯短信机
@RequestMapping
(
value
=
"/sms/app/unauth/sendTemplate"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
sendTemplate
(
SmsTemplateDTO
smsTemplateDTO
);
@RequestMapping
(
value
=
"/file/app/unauth/uploadFiles"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
uploadFiles
(
@RequestParam
(
value
=
"files"
)
MultipartFile
[]
files
);
@RequestMapping
(
value
=
"/pay/app/wx"
,
method
=
RequestMethod
.
POST
)
...
...
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/utils/CCPRestSDK.java
0 → 100644
View file @
fbee8634
/*
* Copyright (c) 2014 The CCP project authors. All Rights Reserved.
*
* Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
* that can be found in the LICENSE file in the root of the web site.
*
* http://www.yuntongxun.com
*
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package
com
.
xxfc
.
platform
.
universal
.
utils
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.google.gson.JsonArray
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.methods.HttpRequestBase
;
import
org.apache.http.entity.BasicHttpEntity
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.message.AbstractHttpMessage
;
import
org.apache.http.util.EntityUtils
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.Element
;
import
java.io.ByteArrayInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.Date
;
@Slf4j
public
class
CCPRestSDK
{
int
status
;
private
static
final
int
Request_Get
=
0
;
private
static
final
int
Request_Post
=
1
;
private
static
final
String
Account_Info
=
"AccountInfo"
;
private
static
final
String
Create_SubAccount
=
"SubAccounts"
;
private
static
final
String
Get_SubAccounts
=
"GetSubAccounts"
;
private
static
final
String
Query_SubAccountByName
=
"QuerySubAccountByName"
;
private
static
final
String
SMSMessages
=
"SMS/Messages"
;
private
static
final
String
TemplateSMS
=
"SMS/TemplateSMS"
;
private
static
final
String
Query_SMSTemplate
=
"SMS/QuerySMSTemplate"
;
private
static
final
String
LandingCalls
=
"Calls/LandingCalls"
;
private
static
final
String
VoiceVerify
=
"Calls/VoiceVerify"
;
private
static
final
String
IvrDial
=
"ivr/dial"
;
private
static
final
String
BillRecords
=
"BillRecords"
;
private
static
final
String
queryCallState
=
"ivr/call"
;
private
static
final
String
callResult
=
"CallResult"
;
private
static
final
String
mediaFileUpload
=
"Calls/MediaFileUpload"
;
private
String
SERVER_IP
;
private
String
SERVER_PORT
;
private
String
ACCOUNT_SID
;
private
String
ACCOUNT_TOKEN
;
private
String
SUBACCOUNT_SID
;
private
String
SUBACCOUNT_Token
;
public
String
App_ID
;
private
BodyType
BODY_TYPE
=
BodyType
.
Type_XML
;
public
String
Callsid
;
public
enum
BodyType
{
Type_XML
,
Type_JSON
;
}
public
enum
AccountType
{
Accounts
,
SubAccounts
;
}
/**
* 初始化服务地址和端口
*
* @param serverIP
* 必选参数 服务器地址
* @param serverPort
* 必选参数 服务器端口
*/
public
void
init
(
String
serverIP
,
String
serverPort
)
{
if
(
isEmpty
(
serverIP
)
||
isEmpty
(
serverPort
))
{
log
.
error
(
"初始化异常:serverIP或serverPort为空"
);
throw
new
IllegalArgumentException
(
"必选参数:"
+
(
isEmpty
(
serverIP
)
?
" 服务器地址 "
:
""
)
+
(
isEmpty
(
serverPort
)
?
" 服务器端口 "
:
""
)
+
"为空"
);
}
SERVER_IP
=
serverIP
;
SERVER_PORT
=
serverPort
;
}
/**
* 初始化主帐号信息
*
* @param accountSid
* 必选参数 主帐号
* @param accountToken
* 必选参数 主帐号TOKEN
*/
public
void
setAccount
(
String
accountSid
,
String
accountToken
)
{
if
(
isEmpty
(
accountSid
)
||
isEmpty
(
accountToken
))
{
log
.
error
(
"初始化异常:accountSid或accountToken为空"
);
throw
new
IllegalArgumentException
(
"必选参数:"
+
(
isEmpty
(
accountSid
)
?
" 主帐号"
:
""
)
+
(
isEmpty
(
accountToken
)
?
" 主帐号TOKEN "
:
""
)
+
"为空"
);
}
ACCOUNT_SID
=
accountSid
;
ACCOUNT_TOKEN
=
accountToken
;
}
/**
* 初始化子帐号信息
*
* @param subAccountSid
* 必选参数 子帐号
* @param subAccountToken
* 必选参数 子帐号TOKEN
*/
public
void
setSubAccount
(
String
subAccountSid
,
String
subAccountToken
)
{
if
(
isEmpty
(
subAccountSid
)
||
isEmpty
(
subAccountToken
))
{
log
.
error
(
"初始化异常:subAccountSid或subAccountToken为空"
);
throw
new
IllegalArgumentException
(
"必选参数:"
+
(
isEmpty
(
subAccountSid
)
?
" 子帐号"
:
""
)
+
(
isEmpty
(
subAccountToken
)
?
" 子帐号TOKEN "
:
""
)
+
"为空"
);
}
SUBACCOUNT_SID
=
subAccountSid
;
SUBACCOUNT_Token
=
subAccountToken
;
}
/**
* 初始化应用Id
*
* @param appId
* 必选参数 应用Id
*/
public
void
setAppId
(
String
appId
)
{
if
(
isEmpty
(
appId
))
{
log
.
error
(
"初始化异常:appId为空"
);
throw
new
IllegalArgumentException
(
"必选参数: 应用Id 为空"
);
}
App_ID
=
appId
;
}
/**
* 话单下载
*
* @param date
* 必选参数 day 代表前一天的数据(从00:00 – 23:59)
* @param keywords
* 可选参数 客户的查询条件,由客户自行定义并提供给云通讯平台。默认不填忽略此参数
* @return
*/
public
HashMap
<
String
,
Object
>
billRecords
(
String
date
,
String
keywords
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
{
return
validate
;
}
if
((
isEmpty
(
date
)))
{
log
.
error
(
"必选参数: 日期 为空"
);
throw
new
IllegalArgumentException
(
"必选参数: 日期 为空"
);
}
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
//e1.printStackTrace();
log
.
error
(
e1
.
getMessage
());
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
BillRecords
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
json
.
addProperty
(
"appId"
,
App_ID
);
json
.
addProperty
(
"date"
,
date
);
if
(!(
isEmpty
(
keywords
)))
json
.
addProperty
(
"keywords"
,
keywords
);
requsetbody
=
json
.
toString
();
}
else
{
StringBuilder
sb
=
new
StringBuilder
(
"<?xml version='1.0' encoding='utf-8'?><BillRecords>"
);
sb
.
append
(
"<appId>"
).
append
(
App_ID
).
append
(
"</appId>"
)
.
append
(
"<date>"
).
append
(
date
).
append
(
"</date>"
);
if
(!(
isEmpty
(
keywords
)))
sb
.
append
(
"<keywords>"
).
append
(
keywords
)
.
append
(
"</keywords>"
);
sb
.
append
(
"</BillRecords>"
).
toString
();
requsetbody
=
sb
.
toString
();
}
log
.
info
(
"billRecords Request body = : "
+
requsetbody
);
//打印包体
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"billRecords response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 发起IVR外呼请求
*
* @param number
* 必选参数 待呼叫号码,为Dial节点的属性
* @param userdata
* 可选参数 用户数据,在<startservice>通知中返回,只允许填写数字字符,为Dial节点的属性
* @param record
* 可选参数 是否录音,可填项为true和false,默认值为false不录音,为Dial节点的属性
* @param disnumber
* 可选参数 用户方的显号号码,根据平台侧显号规则控制。
* @return
*/
public
HashMap
<
String
,
Object
>
ivrDial
(
String
number
,
String
userdata
,
boolean
record
,
String
disnumber
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
if
(
isEmpty
(
number
))
{
log
.
error
(
"必选参数: 待呼叫号码 为空"
);
throw
new
IllegalArgumentException
(
"必选参数: 待呼叫号码 为空"
);
}
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
IvrDial
);
String
requsetbody
=
""
;
StringBuilder
sb
=
new
StringBuilder
(
"<?xml version='1.0' encoding='utf-8'?><Request>"
);
sb
.
append
(
"<Appid>"
).
append
(
App_ID
).
append
(
"</Appid>"
)
.
append
(
"<Dial number="
).
append
(
"\""
).
append
(
number
)
.
append
(
"\""
);
if
(
record
)
{
sb
.
append
(
" record="
).
append
(
"\""
).
append
(
record
).
append
(
"\""
);
}
if
(
userdata
!=
null
)
{
sb
.
append
(
" userdata="
).
append
(
"\""
).
append
(
userdata
)
.
append
(
"\""
);
}
if
(
disnumber
!=
null
)
{
sb
.
append
(
" disnumber="
).
append
(
"\""
).
append
(
disnumber
)
.
append
(
"\""
);
}
sb
.
append
(
"></Dial></Request>"
).
toString
();
requsetbody
=
sb
.
toString
();
log
.
info
(
"ivrDial Request body = : "
+
requsetbody
);
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"ivrDial response body = "
+
result
);
try
{
return
xmlToMap
(
result
);
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 发起语音验证码请求
*
* @param verifyCode
* 必选参数 验证码内容,为数字和英文字母,不区分大小写,长度4-8位
* @param to
* 必选参数 接收号码
* @param displayNum
* 可选参数 显示主叫号码,显示权限由服务侧控制
* @param playTimes
* 可选参数 循环播放次数,1-3次,默认播放1次
* @param respUrl
* 可选参数 语音验证码状态通知回调地址,云通讯平台将向该Url地址发送呼叫结果通知
* @param lang
* 可选参数 语言类型
* @param userData
* 可选参数 第三方私有数据
* @param welcomePrompt
* 可选参数 wav格式的文件名,欢迎提示音,在播放验证码语音前播放此内容,配合verifyCode使用,默认值空,当playVerifyCode为空有效。
* @param playVerifyCode
* 可选参数 wav格式的文件名,语音验证码的内容全部播放此节点下的全部语音文件,也就是实现了语音验证码功能播放用户自己的语音文件,该参数和verifyCode二者不能同时为空,当二者都不为空时优先使用playVerifyCode。
* @param maxCallTime
* 可选参数 最大通话时长
* @return
*/
public
HashMap
<
String
,
Object
>
voiceVerify
(
String
verifyCode
,
String
to
,
String
displayNum
,
String
playTimes
,
String
respUrl
,
String
lang
,
String
userData
,
String
welcomePrompt
,
String
playVerifyCode
,
String
maxCallTime
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
if
((
isEmpty
(
verifyCode
))
||
(
isEmpty
(
to
)))
throw
new
IllegalArgumentException
(
"必选参数:"
+
(
isEmpty
(
verifyCode
)
?
" 验证码内容 "
:
""
)
+
(
isEmpty
(
to
)
?
" 接收号码 "
:
""
)
+
"为空"
);
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
VoiceVerify
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
json
.
addProperty
(
"appId"
,
App_ID
);
json
.
addProperty
(
"verifyCode"
,
verifyCode
);
json
.
addProperty
(
"to"
,
to
);
if
(!(
isEmpty
(
displayNum
)))
json
.
addProperty
(
"displayNum"
,
displayNum
);
if
(!(
isEmpty
(
playTimes
)))
json
.
addProperty
(
"playTimes"
,
playTimes
);
if
(!(
isEmpty
(
respUrl
)))
json
.
addProperty
(
"respUrl"
,
respUrl
);
if
(!(
isEmpty
(
lang
)))
json
.
addProperty
(
"lang"
,
lang
);
if
(!(
isEmpty
(
userData
)))
json
.
addProperty
(
"userData"
,
userData
);
if
(!(
isEmpty
(
welcomePrompt
)))
json
.
addProperty
(
"welcomePrompt"
,
welcomePrompt
);
if
(!(
isEmpty
(
playVerifyCode
)))
json
.
addProperty
(
"playVerifyCode"
,
playVerifyCode
);
if
(!(
isEmpty
(
maxCallTime
)))
json
.
addProperty
(
"maxCallTime"
,
maxCallTime
);
requsetbody
=
json
.
toString
();
}
else
{
StringBuilder
sb
=
new
StringBuilder
(
"<?xml version='1.0' encoding='utf-8'?><VoiceVerify>"
);
sb
.
append
(
"<appId>"
).
append
(
App_ID
).
append
(
"</appId>"
)
.
append
(
"<verifyCode>"
).
append
(
verifyCode
)
.
append
(
"</verifyCode>"
).
append
(
"<to>"
).
append
(
to
)
.
append
(
"</to>"
);
if
(!(
isEmpty
(
displayNum
)))
sb
.
append
(
"<displayNum>"
).
append
(
displayNum
)
.
append
(
"</displayNum>"
);
if
(!(
isEmpty
(
playTimes
)))
sb
.
append
(
"<playTimes>"
).
append
(
playTimes
)
.
append
(
"</playTimes>"
);
if
(!(
isEmpty
(
respUrl
)))
sb
.
append
(
"<respUrl>"
).
append
(
respUrl
).
append
(
"</respUrl>"
);
if
(!(
isEmpty
(
lang
)))
sb
.
append
(
"<lang>"
).
append
(
lang
).
append
(
"</lang>"
);
if
(!(
isEmpty
(
userData
)))
sb
.
append
(
"<userData>"
).
append
(
userData
)
.
append
(
"</userData>"
);
if
(!(
isEmpty
(
welcomePrompt
)))
sb
.
append
(
"<welcomePrompt>"
).
append
(
welcomePrompt
)
.
append
(
"</welcomePrompt>"
);
if
(!(
isEmpty
(
playVerifyCode
)))
sb
.
append
(
"<playVerifyCode>"
).
append
(
playVerifyCode
)
.
append
(
"</playVerifyCode>"
);
if
(!(
isEmpty
(
maxCallTime
)))
sb
.
append
(
"<maxCallTime>"
).
append
(
maxCallTime
)
.
append
(
"</maxCallTime>"
);
sb
.
append
(
"</VoiceVerify>"
).
toString
();
requsetbody
=
sb
.
toString
();
}
log
.
info
(
"voiceVerify Request body = : "
+
requsetbody
);
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"voiceVerify response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 发送外呼通知请求
*
* @param to
* 必选参数 被叫号码
* @param mediaName
* 可选参数 语音文件名称,格式 wav。与mediaTxt不能同时为空,不为空时mediaTxt属性失效
* @param mediaTxt
* 可选参数 文本内容,默认值为空
* @param displayNum
* 可选参数 显示的主叫号码,显示权限由服务侧控制
* @param playTimes
* 可选参数 循环播放次数,1-3次,默认播放1次
* @param respUrl
* 可选参数 外呼通知状态通知回调地址,云通讯平台将向该Url地址发送呼叫结果通知
* @param userData
* 可选参数 用户私有数据
* @param txtSpeed
* 可选参数 文本转语音后的发音速度,取值范围:-500至500,当mediaTxt有效才生效,默认值为0。
* @param txtVolume
* 可选参数 文本转语音后的音量大小,取值范围:-20至20,当mediaTxt有效才生效,默认值为0。
* @param txtPitch
* 可选参数 文本转语音后的音调,取值范围:-500至500,当mediaTxt有效才生效,默认值为0。
* @param txtBgsound
* 可选参数 文本转语音后的背景音编号,目前云通讯平台支持6种背景音,1到6的六种背景音编码,0为不需要背景音。暂时不支持第三方自定义背景音。当mediaTxt有效才生效。
* @param playMode
* 可选参数 是否同时播放文本和语音文件 , 0、否 1、是,默认0。优先播放文本。
* @return
*/
public
HashMap
<
String
,
Object
>
landingCall
(
String
to
,
String
mediaName
,
String
mediaTxt
,
String
displayNum
,
String
playTimes
,
String
respUrl
,
String
userData
,
String
txtSpeed
,
String
txtVolume
,
String
txtPitch
,
String
txtBgsound
,
String
playMode
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
if
(
isEmpty
(
to
))
throw
new
IllegalArgumentException
(
"必选参数:"
+
(
isEmpty
(
to
)
?
" 被叫号码 "
:
""
)
+
"为空"
);
if
((
isEmpty
(
mediaName
))
&&
(
isEmpty
(
mediaTxt
)))
throw
new
IllegalArgumentException
(
"参数语音文件名称和参数语音文本内容不能同时为空"
);
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
LandingCalls
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
json
.
addProperty
(
"appId"
,
App_ID
);
json
.
addProperty
(
"to"
,
to
);
if
(!(
isEmpty
(
mediaName
)))
{
json
.
addProperty
(
"mediaName"
,
mediaName
);
}
if
(!(
isEmpty
(
mediaTxt
)))
{
json
.
addProperty
(
"mediaTxt"
,
mediaTxt
);
}
if
(!(
isEmpty
(
displayNum
)))
{
json
.
addProperty
(
"displayNum"
,
displayNum
);
}
if
(!(
isEmpty
(
playTimes
)))
{
json
.
addProperty
(
"playTimes"
,
playTimes
);
}
if
(!(
isEmpty
(
respUrl
)))
{
json
.
addProperty
(
"respUrl"
,
respUrl
);
}
if
(!(
isEmpty
(
userData
)))
{
json
.
addProperty
(
"userData"
,
userData
);
}
if
(!(
isEmpty
(
txtSpeed
)))
{
json
.
addProperty
(
"txtSpeed"
,
txtSpeed
);
}
if
(!(
isEmpty
(
txtVolume
)))
{
json
.
addProperty
(
"txtVolume"
,
txtVolume
);
}
if
(!(
isEmpty
(
txtPitch
)))
{
json
.
addProperty
(
"txtPitch"
,
txtPitch
);
}
if
(!(
isEmpty
(
txtBgsound
)))
{
json
.
addProperty
(
"txtBgsound"
,
txtBgsound
);
}
if
(!(
isEmpty
(
playMode
)))
{
json
.
addProperty
(
"playMode"
,
playMode
);
}
requsetbody
=
json
.
toString
();
}
else
{
StringBuilder
sb
=
new
StringBuilder
(
"<?xml version='1.0' encoding='utf-8'?><LandingCall>"
);
sb
.
append
(
"<appId>"
).
append
(
App_ID
).
append
(
"</appId>"
)
.
append
(
"<to>"
).
append
(
to
).
append
(
"</to>"
);
if
(!(
isEmpty
(
mediaName
)))
sb
.
append
(
"<mediaName>"
).
append
(
mediaName
)
.
append
(
"</mediaName>"
);
else
if
(!(
isEmpty
(
mediaName
)))
sb
.
append
(
"<mediaName>"
).
append
(
mediaName
)
.
append
(
"</mediaName>"
);
if
(!(
isEmpty
(
mediaTxt
)))
sb
.
append
(
"<mediaTxt>"
).
append
(
mediaTxt
)
.
append
(
"</mediaTxt>"
);
if
(!(
isEmpty
(
displayNum
)))
sb
.
append
(
"<displayNum>"
).
append
(
displayNum
)
.
append
(
"</displayNum>"
);
if
(!(
isEmpty
(
playTimes
)))
sb
.
append
(
"<playTimes>"
).
append
(
playTimes
)
.
append
(
"</playTimes>"
);
if
(!(
isEmpty
(
respUrl
)))
sb
.
append
(
"<respUrl>"
).
append
(
respUrl
).
append
(
"</respUrl>"
);
if
(!(
isEmpty
(
userData
)))
sb
.
append
(
"<userData>"
).
append
(
userData
).
append
(
"</userData>"
);
if
(!(
isEmpty
(
txtSpeed
)))
sb
.
append
(
"<txtSpeed>"
).
append
(
txtSpeed
).
append
(
"</txtSpeed>"
);
if
(!(
isEmpty
(
txtVolume
)))
sb
.
append
(
"<txtVolume>"
).
append
(
txtVolume
).
append
(
"</txtVolume>"
);
if
(!(
isEmpty
(
txtPitch
)))
sb
.
append
(
"<txtPitch>"
).
append
(
txtPitch
).
append
(
"</txtPitch>"
);
if
(!(
isEmpty
(
txtBgsound
)))
sb
.
append
(
"<txtBgsound>"
).
append
(
txtBgsound
).
append
(
"</txtBgsound>"
);
if
(!(
isEmpty
(
playMode
)))
sb
.
append
(
"<playMode>"
).
append
(
playMode
).
append
(
"</playMode>"
);
sb
.
append
(
"</LandingCall>"
).
toString
();
requsetbody
=
sb
.
toString
();
}
log
.
info
(
"landingCalls Request body = : "
+
requsetbody
);
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"landingCall response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 发送短信模板请求
*
* @param to
* 必选参数 短信接收端手机号码集合,用英文逗号分开,每批发送的手机号数量不得超过100个
* @param templateId
* 必选参数 模板Id
* @param datas
* 可选参数 内容数据,用于替换模板中{序号}
* @return
*/
public
HashMap
<
String
,
Object
>
sendTemplateSMS
(
String
to
,
String
templateId
,
String
[]
datas
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
if
((
isEmpty
(
to
))
||
(
isEmpty
(
App_ID
))
||
(
isEmpty
(
templateId
)))
throw
new
IllegalArgumentException
(
"必选参数:"
+
(
isEmpty
(
to
)
?
" 手机号码 "
:
""
)
+
(
isEmpty
(
templateId
)
?
" 模板Id "
:
""
)
+
"为空"
);
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
TemplateSMS
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
json
.
addProperty
(
"appId"
,
App_ID
);
json
.
addProperty
(
"to"
,
to
);
json
.
addProperty
(
"templateId"
,
templateId
);
if
(
datas
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
(
"["
);
for
(
String
s
:
datas
)
{
sb
.
append
(
"\""
+
s
+
"\""
+
","
);
}
sb
.
replace
(
sb
.
length
()
-
1
,
sb
.
length
(),
"]"
);
JsonParser
parser
=
new
JsonParser
();
JsonArray
Jarray
=
parser
.
parse
(
sb
.
toString
())
.
getAsJsonArray
();
json
.
add
(
"datas"
,
Jarray
);
}
requsetbody
=
json
.
toString
();
}
else
{
StringBuilder
sb
=
new
StringBuilder
(
"<?xml version='1.0' encoding='utf-8'?><TemplateSMS>"
);
sb
.
append
(
"<appId>"
).
append
(
App_ID
).
append
(
"</appId>"
)
.
append
(
"<to>"
).
append
(
to
).
append
(
"</to>"
)
.
append
(
"<templateId>"
).
append
(
templateId
)
.
append
(
"</templateId>"
);
if
(
datas
!=
null
)
{
sb
.
append
(
"<datas>"
);
for
(
String
s
:
datas
)
{
sb
.
append
(
"<data>"
).
append
(
s
).
append
(
"</data>"
);
}
sb
.
append
(
"</datas>"
);
}
sb
.
append
(
"</TemplateSMS>"
).
toString
();
requsetbody
=
sb
.
toString
();
}
//打印包体
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
log
.
info
(
"sendTemplateSMS Request body = "
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
//获取响应码
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
+
"Https请求返回码:"
+
status
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"sendTemplateSMS response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 获取子帐号信息
*
* @param
*
* @param friendlyName
* 必选参数 子帐号名称
* @return
*/
public
HashMap
<
String
,
Object
>
querySubAccount
(
String
friendlyName
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
{
return
validate
;
}
if
((
isEmpty
(
friendlyName
)))
{
log
.
error
(
"必选参数: 子帐号名称 为空"
);
throw
new
IllegalArgumentException
(
"必选参数: 子帐号名称 为空"
);
}
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
Query_SubAccountByName
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
json
.
addProperty
(
"appId"
,
App_ID
);
json
.
addProperty
(
"friendlyName"
,
friendlyName
);
requsetbody
=
json
.
toString
();
}
else
{
requsetbody
=
"<?xml version='1.0' encoding='utf-8'?><SubAccount>"
+
"<appId>"
+
App_ID
+
"</appId>"
+
"<friendlyName>"
+
friendlyName
+
"</friendlyName>"
+
"</SubAccount>"
;
}
log
.
info
(
"querySubAccountByName Request body = "
+
requsetbody
);
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"querySubAccount result "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 获取子帐号
*
* @param startNo
* 可选参数 开始的序号,默认从0开始
* @param offset
* 可选参数 一次查询的最大条数,最小是1条,最大是100条
* @return
*/
public
HashMap
<
String
,
Object
>
getSubAccounts
(
String
startNo
,
String
offset
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
Get_SubAccounts
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
json
.
addProperty
(
"appId"
,
App_ID
);
if
(!(
isEmpty
(
startNo
)))
json
.
addProperty
(
"startNo"
,
startNo
);
if
(!(
isEmpty
(
offset
)))
json
.
addProperty
(
"offset"
,
offset
);
requsetbody
=
json
.
toString
();
}
else
{
StringBuilder
sb
=
new
StringBuilder
(
"<?xml version='1.0' encoding='utf-8'?><SubAccount>"
);
sb
.
append
(
"<appId>"
).
append
(
App_ID
).
append
(
"</appId>"
);
if
(!(
isEmpty
(
startNo
)))
sb
.
append
(
"<startNo>"
).
append
(
startNo
).
append
(
"</startNo>"
);
if
(!(
isEmpty
(
offset
)))
sb
.
append
(
"<offset>"
).
append
(
offset
).
append
(
"</offset>"
);
sb
.
append
(
"</SubAccount>"
).
toString
();
requsetbody
=
sb
.
toString
();
}
log
.
info
(
"GetSubAccounts Request body = "
+
requsetbody
);
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"getSubAccounts result "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 获取主帐号信息查询
*
* @return
*/
public
HashMap
<
String
,
Object
>
queryAccountInfo
()
{
if
((
isEmpty
(
SERVER_IP
)))
{
return
getMyError
(
"172004"
,
"IP为空"
);
}
if
((
isEmpty
(
SERVER_PORT
)))
{
return
getMyError
(
"172005"
,
"端口错误"
);
}
if
((
isEmpty
(
ACCOUNT_SID
)))
{
return
getMyError
(
"172006"
,
"主帐号为空"
);
}
if
((
isEmpty
(
ACCOUNT_TOKEN
)))
{
return
getMyError
(
"172007"
,
"主帐号TOKEN为空"
);
}
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
log
.
error
(
e1
.
getMessage
());
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpGet
httpGet
=
(
HttpGet
)
getHttpRequestBase
(
0
,
Account_Info
);
HttpResponse
response
=
httpclient
.
execute
(
httpGet
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"queryAccountInfo response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 创建子帐号
*
* @param friendlyName
* 必选参数 子帐号名称。可由英文字母和阿拉伯数字组成子帐号唯一名称,推荐使用电子邮箱地址
* @return
*/
public
HashMap
<
String
,
Object
>
createSubAccount
(
String
friendlyName
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
if
(
isEmpty
(
friendlyName
))
{
log
.
error
(
"必选参数: 子帐号名称 为空"
);
throw
new
IllegalArgumentException
(
"必选参数: 子帐号名称 为空"
);
}
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
log
.
error
(
e1
.
getMessage
());
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
Create_SubAccount
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
json
.
addProperty
(
"appId"
,
App_ID
);
json
.
addProperty
(
"friendlyName"
,
friendlyName
);
requsetbody
=
json
.
toString
();
}
else
{
requsetbody
=
"<?xml version='1.0' encoding='utf-8'?><SubAccount>"
+
"<appId>"
+
App_ID
+
"</appId>"
+
"<friendlyName>"
+
friendlyName
+
"</friendlyName>"
+
"</SubAccount>"
;
}
log
.
info
(
"CreateSubAccount Request body = "
+
requsetbody
);
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
}
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"createSubAccount response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 短信模板查询
*
* @param templateId
* 可选参数 模板Id,不带此参数查询全部可用模板
* @return
*/
public
HashMap
<
String
,
Object
>
QuerySMSTemplate
(
String
templateId
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
log
.
error
(
e1
.
getMessage
());
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
Query_SMSTemplate
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
json
.
addProperty
(
"appId"
,
App_ID
);
json
.
addProperty
(
"templateId"
,
templateId
);
requsetbody
=
json
.
toString
();
}
else
{
requsetbody
=
"<?xml version='1.0' encoding='utf-8'?><Request>"
+
"<appId>"
+
App_ID
+
"</appId>"
+
"<templateId>"
+
templateId
+
"</templateId>"
+
"</Request>"
;
}
log
.
info
(
"QuerySMSTemplate Request body = "
+
requsetbody
);
//打印包体
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
//获取响应码
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
}
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"QuerySMSTemplate response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 呼叫状态查询
*
* @param callid
* 必选参数 呼叫Id
* @param action
* 可选参数 查询结果通知的回调url地址
* @return
*/
public
HashMap
<
String
,
Object
>
QueryCallState
(
String
callid
,
String
action
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
if
((
isEmpty
(
callid
)))
{
log
.
error
(
"必选参数: callid 为空"
);
throw
new
IllegalArgumentException
(
"必选参数: callid 为空"
);
}
Callsid
=
callid
;
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
log
.
error
(
e1
.
getMessage
());
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
queryCallState
);
String
requsetbody
=
""
;
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
JsonObject
json
=
new
JsonObject
();
JsonObject
json2
=
new
JsonObject
();
json
.
addProperty
(
"Appid"
,
App_ID
);
json2
.
addProperty
(
"callid"
,
callid
);
if
(!(
isEmpty
(
action
)))
json2
.
addProperty
(
"action"
,
action
);
json
.
addProperty
(
"QueryCallState"
,
json2
.
toString
());
requsetbody
=
json
.
toString
();
}
else
{
StringBuilder
sb
=
new
StringBuilder
(
"<?xml version='1.0' encoding='utf-8'?><Request>"
);
sb
.
append
(
"<Appid>"
).
append
(
App_ID
).
append
(
"</Appid>"
)
.
append
(
"<QueryCallState callid="
).
append
(
"\""
).
append
(
callid
)
.
append
(
"\""
);
if
(
action
!=
null
)
{
sb
.
append
(
" action="
).
append
(
"\""
).
append
(
action
)
.
append
(
"\""
).
append
(
"/"
);
}
sb
.
append
(
"></Request>"
).
toString
();
requsetbody
=
sb
.
toString
();
}
log
.
info
(
"queryCallState Request body = : "
+
requsetbody
);
System
.
out
.
println
(
"请求的包体:"
+
requsetbody
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
new
ByteArrayInputStream
(
requsetbody
.
getBytes
(
"UTF-8"
)));
requestBody
.
setContentLength
(
requsetbody
.
getBytes
(
"UTF-8"
).
length
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"billRecords response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 呼叫结果查询
*
* @param callSid
* 必选参数 呼叫Id
* @return
*/
public
HashMap
<
String
,
Object
>
CallResult
(
String
callSid
)
{
if
((
isEmpty
(
SERVER_IP
)))
{
return
getMyError
(
"172004"
,
"IP为空"
);
}
if
((
isEmpty
(
SERVER_PORT
)))
{
return
getMyError
(
"172005"
,
"端口错误"
);
}
if
((
isEmpty
(
ACCOUNT_SID
)))
{
return
getMyError
(
"172006"
,
"主帐号为空"
);
}
if
((
isEmpty
(
ACCOUNT_TOKEN
)))
{
return
getMyError
(
"172007"
,
"主帐号TOKEN为空"
);
}
Callsid
=
callSid
;
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
null
;
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
log
.
error
(
e1
.
getMessage
());
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpGet
httpGet
=
(
HttpGet
)
getHttpRequestBase
(
0
,
callResult
);
HttpResponse
response
=
httpclient
.
execute
(
httpGet
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"queryAccountInfo response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
/**
* 语音文件上传
*
* @param filename
* 必选参数 文件名
* @param fis
* 必选参数 二进制数据流
* @return
*/
public
String
Filename
;
public
HashMap
<
String
,
Object
>
MediaFileUpload
(
String
filename
,
FileInputStream
fis
)
{
HashMap
<
String
,
Object
>
validate
=
accountValidate
();
if
(
validate
!=
null
)
return
validate
;
if
((
isEmpty
(
filename
)))
{
log
.
error
(
"必选参数: filename 为空"
);
throw
new
IllegalArgumentException
(
"必选参数: filename 为空"
);
}
if
(
fis
==
null
){
log
.
error
(
"必选参数: fis 为空"
);
throw
new
IllegalArgumentException
(
"请检查设置的文件"
);
}
Filename
=
filename
;
CcopHttpClient
chc
=
new
CcopHttpClient
();
DefaultHttpClient
httpclient
=
new
DefaultHttpClient
();
try
{
httpclient
=
chc
.
registerSSL
(
SERVER_IP
,
"TLS"
,
Integer
.
parseInt
(
SERVER_PORT
),
"https"
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
log
.
error
(
e1
.
getMessage
());
throw
new
RuntimeException
(
"初始化httpclient异常"
+
e1
.
getMessage
());
}
String
result
=
""
;
try
{
HttpPost
httppost
=
(
HttpPost
)
getHttpRequestBase
(
1
,
mediaFileUpload
);
log
.
info
(
"MediaFileUpload Request body = : "
+
fis
);
BasicHttpEntity
requestBody
=
new
BasicHttpEntity
();
requestBody
.
setContent
(
fis
);
requestBody
.
setContentLength
(
fis
.
available
());
System
.
out
.
println
(
"请求的包体:"
+
requestBody
);
httppost
.
setEntity
(
requestBody
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
status
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
"Https请求返回状态码:"
+
status
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
result
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172001"
,
"网络错误"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
return
getMyError
(
"172002"
,
"无返回"
);
}
finally
{
if
(
httpclient
!=
null
)
httpclient
.
getConnectionManager
().
shutdown
();
}
log
.
info
(
"billRecords response body = "
+
result
);
try
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
return
jsonToMap
(
result
);
}
else
{
return
xmlToMap
(
result
);
}
}
catch
(
Exception
e
)
{
return
getMyError
(
"172003"
,
"返回包体错误"
);
}
}
private
HashMap
<
String
,
Object
>
jsonToMap
(
String
result
)
{
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<
String
,
Object
>();
JsonParser
parser
=
new
JsonParser
();
JsonObject
asJsonObject
=
parser
.
parse
(
result
).
getAsJsonObject
();
Set
<
Entry
<
String
,
JsonElement
>>
entrySet
=
asJsonObject
.
entrySet
();
HashMap
<
String
,
Object
>
hashMap2
=
new
HashMap
<
String
,
Object
>();
for
(
Entry
<
String
,
JsonElement
>
m
:
entrySet
)
{
if
(
"statusCode"
.
equals
(
m
.
getKey
())
||
"statusMsg"
.
equals
(
m
.
getKey
()))
hashMap
.
put
(
m
.
getKey
(),
m
.
getValue
().
getAsString
());
else
{
if
(
"SubAccount"
.
equals
(
m
.
getKey
())
||
"totalCount"
.
equals
(
m
.
getKey
())
||
"smsTemplateList"
.
equals
(
m
.
getKey
())
||
"token"
.
equals
(
m
.
getKey
())
||
"callSid"
.
equals
(
m
.
getKey
())
||
"state"
.
equals
(
m
.
getKey
())
||
"downUrl"
.
equals
(
m
.
getKey
()))
{
if
(!
"SubAccount"
.
equals
(
m
.
getKey
())
&&
!
"smsTemplateList"
.
equals
(
m
.
getKey
()))
hashMap2
.
put
(
m
.
getKey
(),
m
.
getValue
().
getAsString
());
else
{
try
{
if
((
m
.
getValue
().
toString
().
trim
().
length
()
<=
2
)
&&
!
m
.
getValue
().
toString
().
contains
(
"["
))
{
hashMap2
.
put
(
m
.
getKey
(),
m
.
getValue
()
.
getAsString
());
hashMap
.
put
(
"data"
,
hashMap2
);
break
;
}
if
(
m
.
getValue
().
toString
().
contains
(
"[]"
))
{
hashMap2
.
put
(
m
.
getKey
(),
new
JsonArray
());
hashMap
.
put
(
"data"
,
hashMap2
);
continue
;
}
JsonArray
asJsonArray
=
parser
.
parse
(
m
.
getValue
().
toString
()).
getAsJsonArray
();
ArrayList
<
HashMap
<
String
,
Object
>>
arrayList
=
new
ArrayList
<
HashMap
<
String
,
Object
>>();
for
(
JsonElement
j
:
asJsonArray
)
{
Set
<
Entry
<
String
,
JsonElement
>>
entrySet2
=
j
.
getAsJsonObject
().
entrySet
();
HashMap
<
String
,
Object
>
hashMap3
=
new
HashMap
<
String
,
Object
>();
for
(
Entry
<
String
,
JsonElement
>
m2
:
entrySet2
)
{
hashMap3
.
put
(
m2
.
getKey
(),
m2
.
getValue
()
.
getAsString
());
}
arrayList
.
add
(
hashMap3
);
}
hashMap2
.
put
(
m
.
getKey
(),
arrayList
);
}
catch
(
Exception
e
)
{
JsonObject
asJsonObject2
=
parser
.
parse
(
m
.
getValue
().
toString
()).
getAsJsonObject
();
Set
<
Entry
<
String
,
JsonElement
>>
entrySet2
=
asJsonObject2
.
entrySet
();
HashMap
<
String
,
Object
>
hashMap3
=
new
HashMap
<
String
,
Object
>();
for
(
Entry
<
String
,
JsonElement
>
m2
:
entrySet2
)
{
hashMap3
.
put
(
m2
.
getKey
(),
m2
.
getValue
()
.
getAsString
());
}
hashMap2
.
put
(
m
.
getKey
(),
hashMap3
);
hashMap
.
put
(
"data"
,
hashMap2
);
}
}
hashMap
.
put
(
"data"
,
hashMap2
);
}
else
{
JsonObject
asJsonObject2
=
parser
.
parse
(
m
.
getValue
().
toString
()).
getAsJsonObject
();
Set
<
Entry
<
String
,
JsonElement
>>
entrySet2
=
asJsonObject2
.
entrySet
();
HashMap
<
String
,
Object
>
hashMap3
=
new
HashMap
<
String
,
Object
>();
for
(
Entry
<
String
,
JsonElement
>
m2
:
entrySet2
)
{
hashMap3
.
put
(
m2
.
getKey
(),
m2
.
getValue
().
getAsString
());
}
if
(
hashMap3
.
size
()
!=
0
)
{
hashMap2
.
put
(
m
.
getKey
(),
hashMap3
);
}
else
{
hashMap2
.
put
(
m
.
getKey
(),
m
.
getValue
().
getAsString
());
}
hashMap
.
put
(
"data"
,
hashMap2
);
}
}
}
return
hashMap
;
}
/**
* @description 将xml字符串转换成map
* @param xml
* @return Map
*/
private
HashMap
<
String
,
Object
>
xmlToMap
(
String
xml
)
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Document
doc
=
null
;
try
{
doc
=
DocumentHelper
.
parseText
(
xml
);
// 将字符串转为XML
Element
rootElt
=
doc
.
getRootElement
();
// 获取根节点
HashMap
<
String
,
Object
>
hashMap2
=
new
HashMap
<
String
,
Object
>();
ArrayList
<
HashMap
<
String
,
Object
>>
arrayList
=
new
ArrayList
<
HashMap
<
String
,
Object
>>();
for
(
Iterator
i
=
rootElt
.
elementIterator
();
i
.
hasNext
();)
{
Element
e
=
(
Element
)
i
.
next
();
if
(
"statusCode"
.
equals
(
e
.
getName
())
||
"statusMsg"
.
equals
(
e
.
getName
()))
map
.
put
(
e
.
getName
(),
e
.
getText
());
else
{
if
(
"SubAccount"
.
equals
(
e
.
getName
())
||
"TemplateSMS"
.
equals
(
e
.
getName
())
||
"totalCount"
.
equals
(
e
.
getName
())
||
"token"
.
equals
(
e
.
getName
())
||
"callSid"
.
equals
(
e
.
getName
())
||
"state"
.
equals
(
e
.
getName
())
||
"downUrl"
.
equals
(
e
.
getName
()))
{
if
(!
"SubAccount"
.
equals
(
e
.
getName
())&&!
"TemplateSMS"
.
equals
(
e
.
getName
()))
{
hashMap2
.
put
(
e
.
getName
(),
e
.
getText
());
}
else
if
(
"SubAccount"
.
equals
(
e
.
getName
())){
HashMap
<
String
,
Object
>
hashMap3
=
new
HashMap
<
String
,
Object
>();
for
(
Iterator
i2
=
e
.
elementIterator
();
i2
.
hasNext
();)
{
Element
e2
=
(
Element
)
i2
.
next
();
hashMap3
.
put
(
e2
.
getName
(),
e2
.
getText
());
}
arrayList
.
add
(
hashMap3
);
hashMap2
.
put
(
"SubAccount"
,
arrayList
);
}
else
if
(
"TemplateSMS"
.
equals
(
e
.
getName
())){
HashMap
<
String
,
Object
>
hashMap3
=
new
HashMap
<
String
,
Object
>();
for
(
Iterator
i2
=
e
.
elementIterator
();
i2
.
hasNext
();)
{
Element
e2
=
(
Element
)
i2
.
next
();
hashMap3
.
put
(
e2
.
getName
(),
e2
.
getText
());
}
arrayList
.
add
(
hashMap3
);
hashMap2
.
put
(
"TemplateSMS"
,
arrayList
);
}
map
.
put
(
"data"
,
hashMap2
);
}
else
{
HashMap
<
String
,
Object
>
hashMap3
=
new
HashMap
<
String
,
Object
>();
for
(
Iterator
i2
=
e
.
elementIterator
();
i2
.
hasNext
();)
{
Element
e2
=
(
Element
)
i2
.
next
();
// hashMap2.put(e2.getName(),e2.getText());
hashMap3
.
put
(
e2
.
getName
(),
e2
.
getText
());
}
if
(
hashMap3
.
size
()
!=
0
)
{
hashMap2
.
put
(
e
.
getName
(),
hashMap3
);
}
else
{
hashMap2
.
put
(
e
.
getName
(),
e
.
getText
());
}
map
.
put
(
"data"
,
hashMap2
);
}
}
}
}
catch
(
DocumentException
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
e
.
printStackTrace
();
}
return
map
;
}
private
HttpRequestBase
getHttpRequestBase
(
int
get
,
String
action
)
throws
NoSuchAlgorithmException
,
UnsupportedEncodingException
{
return
getHttpRequestBase
(
get
,
action
,
AccountType
.
Accounts
);
}
private
HttpRequestBase
getHttpRequestBase
(
int
get
,
String
action
,
AccountType
mAccountType
)
throws
NoSuchAlgorithmException
,
UnsupportedEncodingException
{
String
timestamp
=
DateUtil
.
dateToStr
(
new
Date
(),
DateUtil
.
DATE_TIME_NO_SLASH
);
EncryptUtil
eu
=
new
EncryptUtil
();
String
sig
=
""
;
String
acountName
=
""
;
String
acountType
=
""
;
if
(
mAccountType
==
AccountType
.
Accounts
)
{
acountName
=
ACCOUNT_SID
;
sig
=
ACCOUNT_SID
+
ACCOUNT_TOKEN
+
timestamp
;
acountType
=
"Accounts"
;
}
else
{
acountName
=
SUBACCOUNT_SID
;
sig
=
SUBACCOUNT_SID
+
SUBACCOUNT_Token
+
timestamp
;
acountType
=
"SubAccounts"
;
}
String
signature
=
eu
.
md5Digest
(
sig
);
String
url
=
getBaseUrl
().
append
(
"/"
+
acountType
+
"/"
)
.
append
(
acountName
).
append
(
"/"
+
action
+
"?sig="
)
.
append
(
signature
).
toString
();
if
(
callResult
.
equals
(
action
))
{
url
=
url
+
"&callsid="
+
Callsid
;
}
if
(
queryCallState
.
equals
(
action
))
{
url
=
url
+
"&callid="
+
Callsid
;
}
if
(
mediaFileUpload
.
equals
(
action
))
{
url
=
url
+
"&appid="
+
App_ID
+
"&filename="
+
Filename
;
}
log
.
info
(
getmethodName
(
action
)
+
" url = "
+
url
);
//System.out.println(getmethodName(action) + " url = " + url);
HttpRequestBase
mHttpRequestBase
=
null
;
if
(
get
==
Request_Get
)
mHttpRequestBase
=
new
HttpGet
(
url
);
else
if
(
get
==
Request_Post
)
mHttpRequestBase
=
new
HttpPost
(
url
);
if
(
IvrDial
.
equals
(
action
))
{
setHttpHeaderXML
(
mHttpRequestBase
);
}
else
if
(
mediaFileUpload
.
equals
(
action
))
{
setHttpHeaderMedia
(
mHttpRequestBase
);
}
else
{
setHttpHeader
(
mHttpRequestBase
);
}
String
src
=
acountName
+
":"
+
timestamp
;
String
auth
=
eu
.
base64Encoder
(
src
);
mHttpRequestBase
.
setHeader
(
"Authorization"
,
auth
);
System
.
out
.
println
(
"请求的Url:"
+
mHttpRequestBase
);
//打印Url
return
mHttpRequestBase
;
}
private
String
getmethodName
(
String
action
)
{
if
(
action
.
equals
(
Account_Info
))
{
return
"queryAccountInfo"
;
}
else
if
(
action
.
equals
(
Create_SubAccount
))
{
return
"createSubAccount"
;
}
else
if
(
action
.
equals
(
Get_SubAccounts
))
{
return
"getSubAccounts"
;
}
else
if
(
action
.
equals
(
Query_SubAccountByName
))
{
return
"querySubAccount"
;
}
else
if
(
action
.
equals
(
SMSMessages
))
{
return
"sendSMS"
;
}
else
if
(
action
.
equals
(
TemplateSMS
))
{
return
"sendTemplateSMS"
;
}
else
if
(
action
.
equals
(
LandingCalls
))
{
return
"landingCalls"
;
}
else
if
(
action
.
equals
(
VoiceVerify
))
{
return
"voiceVerify"
;
}
else
if
(
action
.
equals
(
IvrDial
))
{
return
"ivrDial"
;
}
else
if
(
action
.
equals
(
BillRecords
))
{
return
"billRecords"
;
}
else
{
return
""
;
}
}
private
void
setHttpHeaderXML
(
AbstractHttpMessage
httpMessage
)
{
httpMessage
.
setHeader
(
"Accept"
,
"application/xml"
);
httpMessage
.
setHeader
(
"Content-Type"
,
"application/xml;charset=utf-8"
);
}
private
void
setHttpHeaderMedia
(
AbstractHttpMessage
httpMessage
)
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
httpMessage
.
setHeader
(
"Accept"
,
"application/json"
);
httpMessage
.
setHeader
(
"Content-Type"
,
"application/octet-stream;charset=utf-8;"
);
}
else
{
httpMessage
.
setHeader
(
"Accept"
,
"application/xml"
);
httpMessage
.
setHeader
(
"Content-Type"
,
"application/octet-stream;charset=utf-8;"
);
}
}
private
void
setHttpHeader
(
AbstractHttpMessage
httpMessage
)
{
if
(
BODY_TYPE
==
BodyType
.
Type_JSON
)
{
httpMessage
.
setHeader
(
"Accept"
,
"application/json"
);
httpMessage
.
setHeader
(
"Content-Type"
,
"application/json;charset=utf-8"
);
}
else
{
httpMessage
.
setHeader
(
"Accept"
,
"application/xml"
);
httpMessage
.
setHeader
(
"Content-Type"
,
"application/xml;charset=utf-8"
);
}
}
private
StringBuffer
getBaseUrl
()
{
StringBuffer
sb
=
new
StringBuffer
(
"https://"
);
sb
.
append
(
SERVER_IP
).
append
(
":"
).
append
(
SERVER_PORT
);
sb
.
append
(
"/2013-12-26"
);
return
sb
;
}
private
boolean
isEmpty
(
String
str
)
{
return
((
""
.
equals
(
str
))
||
(
str
==
null
));
}
private
HashMap
<
String
,
Object
>
getMyError
(
String
code
,
String
msg
)
{
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<
String
,
Object
>();
hashMap
.
put
(
"statusCode"
,
code
);
hashMap
.
put
(
"statusMsg"
,
msg
);
return
hashMap
;
}
private
HashMap
<
String
,
Object
>
subAccountValidate
()
{
if
((
isEmpty
(
SERVER_IP
)))
{
return
getMyError
(
"172004"
,
"IP为空"
);
}
if
((
isEmpty
(
SERVER_PORT
)))
{
return
getMyError
(
"172005"
,
"端口错误"
);
}
if
(
isEmpty
(
SUBACCOUNT_SID
))
return
getMyError
(
"172008"
,
"子帐号空"
);
if
(
isEmpty
(
SUBACCOUNT_Token
))
return
getMyError
(
"172009"
,
"子帐号TOKEN空"
);
return
null
;
}
private
HashMap
<
String
,
Object
>
accountValidate
()
{
if
((
isEmpty
(
SERVER_IP
)))
{
return
getMyError
(
"172004"
,
"IP为空"
);
}
if
((
isEmpty
(
SERVER_PORT
)))
{
return
getMyError
(
"172005"
,
"端口错误"
);
}
if
((
isEmpty
(
ACCOUNT_SID
)))
{
return
getMyError
(
"172006"
,
"主帐号为空"
);
}
if
((
isEmpty
(
ACCOUNT_TOKEN
)))
{
return
getMyError
(
"172007"
,
"主帐号TOKEN为空"
);
}
if
((
isEmpty
(
App_ID
)))
{
return
getMyError
(
"172012"
,
"应用ID为空"
);
}
return
null
;
}
private
void
setBodyType
(
BodyType
bodyType
)
{
BODY_TYPE
=
bodyType
;
}
}
\ No newline at end of file
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/utils/CCPRestSmsUtils.java
0 → 100644
View file @
fbee8634
package
com
.
xxfc
.
platform
.
universal
.
utils
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
public
class
CCPRestSmsUtils
{
public
static
CCPRestSDK
restAPI
;
static
{
restAPI
=
new
CCPRestSDK
();
restAPI
.
init
(
"app.cloopen.com"
,
"8883"
);
restAPI
.
setAccount
(
"8aaf070865e6b6eb0165ecd776700559"
,
"3fe5e2f053674f23b029a9a9fc9503f0"
);
restAPI
.
setAppId
(
"8a216da86812593601684bec10581ab5"
);
}
public
static
Map
<
String
,
Object
>
sendTemplateSMS
(
String
phoneNumbers
,
String
[]
params
,
String
templateId
)
{
HashMap
<
String
,
Object
>
result
=
null
;
result
=
restAPI
.
sendTemplateSMS
(
phoneNumbers
,
templateId
,
params
);
System
.
out
.
println
(
"SDKTestGetSubAccounts result="
+
result
);
if
(
"000000"
.
equals
(
result
.
get
(
"statusCode"
)))
{
// 正常返回输出data包体信息(map)
HashMap
<
String
,
Object
>
data
=
(
HashMap
<
String
,
Object
>)
result
.
get
(
"data"
);
Set
<
String
>
keySet
=
data
.
keySet
();
for
(
String
key
:
keySet
)
{
Object
object
=
data
.
get
(
key
);
System
.
out
.
println
(
key
+
" = "
+
object
);
}
}
else
{
// 异常返回输出错误码和错误信息
System
.
out
.
println
(
"错误码="
+
result
.
get
(
"statusCode"
)
+
" 错误信息= "
+
result
.
get
(
"statusMsg"
));
}
return
result
;
}
}
\ No newline at end of file
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/utils/CcopHttpClient.java
0 → 100644
View file @
fbee8634
package
com
.
xxfc
.
platform
.
universal
.
utils
;
import
java.security.KeyManagementException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.Principal
;
import
java.security.SecureRandom
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
org.apache.http.conn.scheme.Scheme
;
import
org.apache.http.conn.ssl.SSLSocketFactory
;
import
org.apache.http.impl.client.DefaultHttpClient
;
public
class
CcopHttpClient
{
public
DefaultHttpClient
registerSSL
(
String
hostname
,
String
protocol
,
int
port
,
String
scheme
)
throws
NoSuchAlgorithmException
,
KeyManagementException
{
DefaultHttpClient
httpclient
=
new
DefaultHttpClient
();
SSLContext
ctx
=
SSLContext
.
getInstance
(
protocol
);
X509TrustManager
tm
=
new
X509TrustManager
()
{
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
if
((
chain
==
null
)
||
(
chain
.
length
==
0
))
throw
new
IllegalArgumentException
(
"null or zero-length certificate chain"
);
if
((
authType
==
null
)
||
(
authType
.
length
()
==
0
))
throw
new
IllegalArgumentException
(
"null or zero-length authentication type"
);
boolean
br
=
false
;
Principal
principal
=
null
;
for
(
X509Certificate
x509Certificate
:
chain
)
{
principal
=
x509Certificate
.
getSubjectX500Principal
();
if
(
principal
!=
null
)
{
br
=
true
;
return
;
}
}
if
(!(
br
))
throw
new
CertificateException
(
"服务端证书验证失败!"
);
}
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
new
X509Certificate
[
0
];
}
};
ctx
.
init
(
null
,
new
TrustManager
[]
{
tm
},
new
SecureRandom
());
SSLSocketFactory
socketFactory
=
new
SSLSocketFactory
(
ctx
,
SSLSocketFactory
.
ALLOW_ALL_HOSTNAME_VERIFIER
);
Scheme
sch
=
new
Scheme
(
scheme
,
port
,
socketFactory
);
httpclient
.
getConnectionManager
().
getSchemeRegistry
().
register
(
sch
);
return
httpclient
;
}
}
\ No newline at end of file
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/utils/DateUtil.java
0 → 100644
View file @
fbee8634
/*
* Copyright (c) 2014 The CCP project authors. All Rights Reserved.
*
* Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
* that can be found in the LICENSE file in the root of the web site.
*
* http://www.yuntongxun.com
*
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package
com
.
xxfc
.
platform
.
universal
.
utils
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
public
class
DateUtil
{
public
static
final
int
DEFAULT
=
0
;
public
static
final
int
YM
=
1
;
public
static
final
int
YMR_SLASH
=
11
;
public
static
final
int
NO_SLASH
=
2
;
public
static
final
int
YM_NO_SLASH
=
3
;
public
static
final
int
DATE_TIME
=
4
;
public
static
final
int
DATE_TIME_NO_SLASH
=
5
;
public
static
final
int
DATE_HM
=
6
;
public
static
final
int
TIME
=
7
;
public
static
final
int
HM
=
8
;
public
static
final
int
LONG_TIME
=
9
;
public
static
final
int
SHORT_TIME
=
10
;
public
static
final
int
DATE_TIME_LINE
=
12
;
public
static
String
dateToStr
(
Date
date
,
String
pattern
)
{
if
((
date
==
null
)
||
(
date
.
equals
(
""
)))
return
null
;
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
pattern
);
return
formatter
.
format
(
date
);
}
public
static
String
dateToStr
(
Date
date
)
{
return
dateToStr
(
date
,
"yyyy/MM/dd"
);
}
public
static
String
dateToStr
(
Date
date
,
int
type
)
{
switch
(
type
)
{
case
0
:
return
dateToStr
(
date
);
case
1
:
return
dateToStr
(
date
,
"yyyy/MM"
);
case
2
:
return
dateToStr
(
date
,
"yyyyMMdd"
);
case
11
:
return
dateToStr
(
date
,
"yyyy-MM-dd"
);
case
3
:
return
dateToStr
(
date
,
"yyyyMM"
);
case
4
:
return
dateToStr
(
date
,
"yyyy/MM/dd HH:mm:ss"
);
case
5
:
return
dateToStr
(
date
,
"yyyyMMddHHmmss"
);
case
6
:
return
dateToStr
(
date
,
"yyyy/MM/dd HH:mm"
);
case
7
:
return
dateToStr
(
date
,
"HH:mm:ss"
);
case
8
:
return
dateToStr
(
date
,
"HH:mm"
);
case
9
:
return
dateToStr
(
date
,
"HHmmss"
);
case
10
:
return
dateToStr
(
date
,
"HHmm"
);
case
12
:
return
dateToStr
(
date
,
"yyyy-MM-dd HH:mm:ss"
);
}
throw
new
IllegalArgumentException
(
"Type undefined : "
+
type
);
}
}
\ No newline at end of file
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/utils/EncryptUtil.java
0 → 100644
View file @
fbee8634
/*
* Copyright (c) 2014 The CCP project authors. All Rights Reserved.
*
* Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
* that can be found in the LICENSE file in the root of the web site.
*
* http://www.yuntongxun.com
*
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package
com
.
xxfc
.
platform
.
universal
.
utils
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
cn.hutool.core.codec.Base64
;
public
class
EncryptUtil
{
private
static
final
String
UTF8
=
"utf-8"
;
public
String
md5Digest
(
String
src
)
throws
NoSuchAlgorithmException
,
UnsupportedEncodingException
{
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
byte
[]
b
=
md
.
digest
(
src
.
getBytes
(
"utf-8"
));
return
byte2HexStr
(
b
);
}
public
String
base64Encoder
(
String
src
)
throws
UnsupportedEncodingException
{
// BASE64Encoder encoder = new BASE64Encoder();
return
Base64
.
encode
(
src
.
getBytes
(
"utf-8"
));
}
public
String
base64Decoder
(
String
dest
)
throws
NoSuchAlgorithmException
,
IOException
{
// BASE64Decoder decoder = new BASE64Decoder();
return
new
String
(
Base64
.
decode
(
dest
),
"utf-8"
);
}
private
String
byte2HexStr
(
byte
[]
b
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
b
.
length
;
++
i
)
{
String
s
=
Integer
.
toHexString
(
b
[
i
]
&
0xFF
);
if
(
s
.
length
()
==
1
)
{
sb
.
append
(
"0"
);
}
sb
.
append
(
s
.
toUpperCase
());
}
return
sb
.
toString
();
}
}
\ No newline at end of file
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/utils/PublicMsg.java
0 → 100644
View file @
fbee8634
package
com
.
xxfc
.
platform
.
universal
.
utils
;
public
class
PublicMsg
{
public
final
static
String
UEDITOR_CONFIG
=
"{\n"
+
" \"imageActionName\": \"uploadimage\",\n"
+
" \"imageFieldName\": \"upfile\",\n"
+
" \"imageMaxSize\": 2048000,\n"
+
" \"imageAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n"
+
" \"imageCompressEnable\": true,\n"
+
" \"imageCompressBorder\": 1600,\n"
+
" \"imageInsertAlign\": \"none\",\n"
+
" \"imageUrlPrefix\": \"\",\n"
+
" \"imagePathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n"
+
"\n"
+
" \"scrawlActionName\": \"uploadscrawl\",\n"
+
" \"scrawlFieldName\": \"upfile\",\n"
+
" \"scrawlPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n"
+
" \"scrawlMaxSize\": 2048000,\n"
+
" \"scrawlUrlPrefix\": \"\",\n"
+
" \"scrawlInsertAlign\": \"none\",\n"
+
"\n"
+
" \"snapscreenActionName\": \"uploadimage\",\n"
+
" \"snapscreenPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n"
+
" \"snapscreenUrlPrefix\": \"\",\n"
+
" \"snapscreenInsertAlign\": \"none\",\n"
+
"\n"
+
" \"catcherLocalDomain\": [\"127.0.0.1\", \"localhost\", \"img.baidu.com\"],\n"
+
" \"catcherActionName\": \"catchimage\",\n"
+
" \"catcherFieldName\": \"source\",\n"
+
" \"catcherPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n"
+
" \"catcherUrlPrefix\": \"\",\n"
+
" \"catcherMaxSize\": 2048000,\n"
+
" \"catcherAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n"
+
"\n"
+
" \"videoActionName\": \"uploadvideo\",\n"
+
" \"videoFieldName\": \"upfile\",\n"
+
" \"videoPathFormat\": \"/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}\",\n"
+
" \"videoUrlPrefix\": \"\",\n"
+
" \"videoMaxSize\": 102400000,\n"
+
" \"videoAllowFiles\": [\n"
+
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n"
+
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\"],\n"
+
"\n"
+
" \"fileActionName\": \"uploadfile\",\n"
+
" \"fileFieldName\": \"upfile\",\n"
+
" \"filePathFormat\": \"/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}\",\n"
+
" \"fileUrlPrefix\": \"\",\n"
+
" \"fileMaxSize\": 51200000,\n"
+
" \"fileAllowFiles\": [\n"
+
" \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\",\n"
+
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n"
+
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\",\n"
+
" \".rar\", \".zip\", \".tar\", \".gz\", \".7z\", \".bz2\", \".cab\", \".iso\",\n"
+
" \".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".txt\", \".md\", \".xml\"\n"
+
" ],\n"
+
"\n"
+
" \"imageManagerActionName\": \"listimage\",\n"
+
" \"imageManagerListPath\": \"/ueditor/jsp/upload/image/\",\n"
+
" \"imageManagerListSize\": 20,\n"
+
" \"imageManagerUrlPrefix\": \"\",\n"
+
" \"imageManagerInsertAlign\": \"none\",\n"
+
" \"imageManagerAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n"
+
"\n"
+
" \"fileManagerActionName\": \"listfile\",\n"
+
" \"fileManagerListPath\": \"/ueditor/jsp/upload/file/\",\n"
+
" \"fileManagerUrlPrefix\": \"\",\n"
+
" \"fileManagerListSize\": 20,\n"
+
" \"fileManagerAllowFiles\": [\n"
+
" \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\",\n"
+
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n"
+
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\",\n"
+
" \".rar\", \".zip\", \".tar\", \".gz\", \".7z\", \".bz2\", \".cab\", \".iso\",\n"
+
" \".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".txt\", \".md\", \".xml\"\n"
+
" ] \n"
+
"\n"
+
"}"
;
/**
* Ueditor的返回状态类型
*/
public
enum
UeditorMsg
{
SUCCESS
(
"SUCCESS"
),
ERROR
(
"上传失败"
);
private
String
v
;
UeditorMsg
(
String
v
){
this
.
v
=
v
;
}
public
String
get
(){
return
this
.
v
;
}
}
}
\ No newline at end of file
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/vo/Ueditor.java
0 → 100644
View file @
fbee8634
package
com
.
xxfc
.
platform
.
universal
.
vo
;
import
lombok.Data
;
@Data
public
class
Ueditor
{
private
String
url
;
private
String
original
;
private
String
state
;
private
String
title
;
}
xx-universal/xx-universal-server/pom.xml
View file @
fbee8634
...
...
@@ -27,6 +27,12 @@
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
</exclusion>
</exclusions>
<version>
4.4.2
</version>
</dependency>
<dependency>
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/UniversalApplication.java
View file @
fbee8634
...
...
@@ -13,7 +13,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
(
scanBasePackages
=
{
"com.xxfc.platform"
,
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler"
,
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableAceAuthClient
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/CCPRestSmsBiz.java
0 → 100644
View file @
fbee8634
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
CCPRestSmsBiz
{
//租车订单通知(普通用户)1
public
static
final
String
TEMPLATE_ID_ORDER
=
"457270"
;
//租车订单短信(会员权益)2
public
static
final
String
TEMPLATE_ID_ORDER_MEMBER
=
"457271"
;
//旅游订单短信3
public
static
final
String
TEMPLATE_ID_ORDER_TOUR
=
"457272"
;
//加入会员通知4
public
static
final
String
TEMPLATE_ID_MEMBER
=
"457273"
;
//发送模板消息
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
;
}
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/SmsController.java
View file @
fbee8634
...
...
@@ -3,15 +3,15 @@ package com.xxfc.platform.universal.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.result.JsonResultUtil
;
import
com.xxfc.platform.universal.biz.CCPRestSmsBiz
;
import
com.xxfc.platform.universal.dto.SmsTemplateDTO
;
import
com.xxfc.platform.universal.service.SmsService
;
import
com.xxfc.platform.universal.service.UploadService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
...
...
@@ -29,6 +29,9 @@ public class SmsController {
@Autowired
SmsService
smsService
;
@Autowired
CCPRestSmsBiz
smsBiz
;
@RequestMapping
(
value
=
"/app/unauth/send"
,
method
=
RequestMethod
.
GET
)
//匹配的是href中的download请求
public
JSONObject
sendSms
(
@RequestParam
(
"phone"
)
String
phone
)
throws
Exception
{
return
smsService
.
smsCode
(
phone
);
...
...
@@ -40,5 +43,17 @@ public class SmsController {
@RequestParam
(
"templateCode"
)
String
templateCode
)
throws
Exception
{
return
smsService
.
smsByCode
(
phone
,
code
,
templateCode
);
}
@RequestMapping
(
value
=
"/app/unauth/sendTemplate"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
sendTemplate
(
@RequestBody
SmsTemplateDTO
smsTemplateDTO
)
throws
Exception
{
if
(
smsTemplateDTO
==
null
){
return
ObjectRestResponse
.
createDefaultFail
();
}
Integer
type
=
smsTemplateDTO
.
getType
();
String
[]
params
=
smsTemplateDTO
.
getParams
();
String
phoneNumbers
=
smsTemplateDTO
.
getPhoneNumbers
();
smsBiz
.
sendTemplateSMS
(
type
,
phoneNumbers
,
params
);
return
ObjectRestResponse
.
succ
();
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/UploadController.java
View file @
fbee8634
...
...
@@ -4,16 +4,17 @@ import com.alibaba.fastjson.JSONObject;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.util.result.JsonResultUtil
;
import
com.xxfc.platform.universal.service.UploadService
;
import
com.xxfc.platform.universal.utils.PublicMsg
;
import
com.xxfc.platform.universal.vo.Ueditor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
/**
* 图片上传
...
...
@@ -96,5 +97,24 @@ public class UploadController{
return
JsonResultUtil
.
createDefaultFail
();
}
//以下是图片上传的方法
@RequestMapping
(
value
=
"/app/unauth/ueditor"
)
@ResponseBody
public
String
ueditor
(
HttpServletRequest
request
)
{
return
PublicMsg
.
UEDITOR_CONFIG
;
}
@RequestMapping
(
value
=
"/app/unauth/ueditor"
,
method
=
RequestMethod
.
POST
)
public
Ueditor
imgUpload
(
MultipartFile
upfile
)
throws
Exception
{
Ueditor
ueditor
=
new
Ueditor
();
ueditor
.
setUrl
(
uploadService
.
uploadFile
(
upfile
,
"admin"
));
ueditor
.
setOriginal
(
upfile
.
getOriginalFilename
());
ueditor
.
setState
(
"SUCCESS"
);
ueditor
.
setTitle
(
upfile
.
getOriginalFilename
());
return
ueditor
;
}
}
xx-universal/xx-universal-server/src/main/resources/bootstrap.yml
View file @
fbee8634
...
...
@@ -25,7 +25,8 @@ spring:
nacos
:
config
:
server-addr
:
127.0.0.1:8848
#共用配置,暂定一个
shared-dataids
:
common-dev.yaml,mongodb-log-dev.yaml
---
spring
:
profiles
:
pro
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/VehicleApplication.java
View file @
fbee8634
...
...
@@ -11,7 +11,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
(
scanBasePackages
=
{
"com.xxfc.platform"
,
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler"
,
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableScheduling
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/config/WebConfiguration.java
View file @
fbee8634
...
...
@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.auth.client.interceptor.ServiceAuthRestInterc
import
com.github.wxiaoqi.security.auth.client.interceptor.UserAuthRestInterceptor
;
import
com.github.wxiaoqi.security.common.handler.GlobalExceptionHandler
;
import
com.github.wxiaoqi.security.common.interceptor.CorsInterceptor
;
import
com.github.wxiaoqi.security.common.log.XxLogInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
...
...
@@ -33,7 +34,6 @@ public class WebConfiguration implements WebMvcConfigurer {
*/
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
getCorsInterceptor
()).
addPathPatterns
(
"/**"
);
registry
.
addInterceptor
(
getServiceAuthRestInterceptor
()).
addPathPatterns
(
getIncludePathPatterns
());
...
...
@@ -41,6 +41,13 @@ public class WebConfiguration implements WebMvcConfigurer {
addPathPatterns
(
getIncludePathPatterns
());
}
// @Bean
// XxLogInterceptor getXxLogInterceptor() {
// return new XxLogInterceptor();
// }
@Bean
ServiceAuthRestInterceptor
getServiceAuthRestInterceptor
()
{
return
new
ServiceAuthRestInterceptor
();
...
...
xx-vehicle/xx-vehicle-server/src/main/resources/bootstrap.yml
View file @
fbee8634
...
...
@@ -25,7 +25,7 @@ spring:
config
:
server-addr
:
127.0.0.1:8848
#共用配置,暂定一个
shared-dataids
:
common-dev.yaml
shared-dataids
:
common-dev.yaml
,mongodb-log-dev.yaml
---
spring
:
...
...
xx-vehicle/xx-vehicle-server/src/main/resources/mapper/VehicleMapper.xml
View file @
fbee8634
...
...
@@ -365,7 +365,7 @@
</if>
<!-- yearNo4Where 标识时间参数不用于where条件,用于select部分 -->
<if
test=
" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true"
>
,(
,
max
(
<foreach
collection=
"yearMonthAndParam"
index=
"yearMonth"
item=
"andOperation"
separator=
"and"
>
<include
refid=
"yearMonthAndParamSql"
></include>
</foreach>
...
...
@@ -380,7 +380,7 @@
and bc.id is not null
GROUP BY model_id, company_id
<if
test=
"lon != null and lat != null"
>
, distance
</if>
<
if
test=
" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true"
>
, hasVehicle
</if
>
<
!--<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">, hasVehicle</if>--
>
<!-- 循环 相同父级 数据做并集, 不同父级做或集 -->
<if
test=
" catas != null "
>
...
...
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