Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jenkins
order-group
Commits
9c8277c8
Commit
9c8277c8
authored
Dec 03, 2019
by
姜海波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新最新master代码
parent
5fc4c4d2
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
0 additions
and
1678 deletions
+0
-1678
platform-order-service/pom.xml
+0
-197
platform-order-service/src/main/java/com/freemud/platform/amp/constant/QueueMetadata.java
+0
-92
platform-order-service/src/main/java/com/freemud/platform/amp/order/OrderAmpConfig.java
+0
-94
platform-order-service/src/main/java/com/freemud/platform/amp/order/OrderAmpService.java
+0
-93
platform-order-service/src/main/java/com/freemud/platform/amp/order/OrderAutomaticBody.java
+0
-54
platform-order-service/src/main/java/com/freemud/platform/amp/order/OrderStatusChangePushConfig.java
+0
-74
platform-order-service/src/main/java/com/freemud/platform/common/annotations/PlatformRequestBody.java
+0
-13
platform-order-service/src/main/java/com/freemud/platform/common/code/PlatformStatusCode.java
+0
-92
platform-order-service/src/main/java/com/freemud/platform/common/constant/VersionNum.java
+0
-22
platform-order-service/src/main/java/com/freemud/platform/common/entity/PaginationRequest.java
+0
-26
platform-order-service/src/main/java/com/freemud/platform/common/entity/PaginationResponse.java
+0
-30
platform-order-service/src/main/java/com/freemud/platform/common/entity/PlatformBaseRequest.java
+0
-49
platform-order-service/src/main/java/com/freemud/platform/common/entity/PlatformBaseResponse.java
+0
-47
platform-order-service/src/main/java/com/freemud/platform/common/entity/ResponseBuilder.java
+0
-137
platform-order-service/src/main/java/com/freemud/platform/common/util/DateTimeUtil.java
+0
-283
platform-order-service/src/main/java/com/freemud/platform/common/util/MapBeanConvertUtil.java
+0
-374
pom.xml
+0
-1
No files found.
platform-order-service/pom.xml
deleted
100644 → 0
View file @
5fc4c4d2
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.1.3.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
platform-order-service
</artifactId>
<dependencies>
<dependency>
<groupId>
javax.validation
</groupId>
<artifactId>
validation-api
</artifactId>
<version>
2.0.1.Final
</version>
</dependency>
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
sdk-common-base
</artifactId>
<version>
1.3.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.freemud.sdk.api.assortment
</groupId>
<artifactId>
assortment-data-manager
</artifactId>
<version>
3.2.RELEASE
</version>
</dependency>
<!--引入eureka-->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<artifactId>
membercenter-sdk
</artifactId>
<groupId>
com.freemud.application.service.sdk
</groupId>
<version>
2.2.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
membercenter-sdk
</artifactId>
<version>
2.3.6-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
storecenter-sdk
</artifactId>
<version>
1.4.RELEASE
</version>
</dependency>
<!-- 聚合订单sdk -->
<dependency>
<artifactId>
assortment-ordercenter-sdk
</artifactId>
<groupId>
cn.freemud
</groupId>
<version>
1.0.0
</version>
</dependency>
<!-- 邮件sdk -->
<!--<dependency>-->
<!--<artifactId>commons-amqp</artifactId>-->
<!--<groupId>cn.freemud.commons</groupId>-->
<!--<version>1.4.12-release</version>-->
<!--</dependency>-->
<dependency>
<groupId>
com.freemud.sdk.api.assortment
</groupId>
<artifactId>
assortment-orderdistributor-sdk
</artifactId>
<version>
2.1.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.freemud.sdk.api.assortment
</groupId>
<artifactId>
assortment-payment-sdk
</artifactId>
<version>
2.3.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
paymentcenter-sdk
</artifactId>
<version>
2.2.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
tk.mybatis
</groupId>
<artifactId>
mapper-spring-boot-starter
</artifactId>
<version>
2.0.2
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.8.0
</version>
</dependency>
<!--健康检查-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
promotioncenter-sdk
</artifactId>
<version>
2.0.RELEASE
</version>
</dependency>
<!--<dependency>-->
<!--<groupId>com.freemud.sdk.components</groupId>-->
<!--<artifactId>common-components-sdk</artifactId>-->
<!--<version>1.0.0-SNAPSHOT</version>-->
<!--</dependency>-->
<dependency>
<groupId>
com.freemud.sdk.api.assortment
</groupId>
<artifactId>
assortment-messagepush-sdk
</artifactId>
<version>
2.1.RELEASE
</version>
</dependency>
<dependency>
<groupId>
cn.freemud
</groupId>
<artifactId>
monitor-tools
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-client
</artifactId>
<version>
1.4.0
</version>
</dependency>
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
membercenter-sdk
</artifactId>
<version>
2.9.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
stockcenter-sdk
</artifactId>
<version>
1.2.1.RELEASE
</version>
</dependency>
<dependency>
<artifactId>
structure-center-sdk
</artifactId>
<groupId>
com.freemud.application.service.sdk
</groupId>
<version>
1.2-SNAPSHOT
</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
Finchley.RELEASE
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>
src/main/java
</directory>
<includes>
<include>
**/*.xml
</include>
</includes>
</resource>
<resource>
<directory>
src/main/resources
</directory>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>
public
</id>
<name>
public Repository
</name>
<url>
http://115.159.2.190:7654/nexus/content/groups/public/
</url>
</repository>
<repository>
<id>
freemud-hosted-release
</id>
<name>
freemud-hosted-release
</name>
<url>
http://115.159.2.190:7654/nexus/content/repositories/freemud-hosted-release/
</url>
</repository>
<repository>
<id>
spring-libs-release
</id>
<name>
Spring Releases
</name>
<url>
https://repo.spring.io/libs-release
</url>
<snapshots>
<enabled>
false
</enabled>
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
platform-order-service/src/main/java/com/freemud/platform/amp/constant/QueueMetadata.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
amp
.
constant
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: ${FILE_NAME}
* @Package com.freemud.mail.core
* @Description: ${TODO}(用一句话描述该文件做什么)
* @author: aiqi.gong
* @date: 2019/3/21 15:16
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public
class
QueueMetadata
{
public
static
final
String
EXCHANGE_NAME
=
"topic-Exchange"
;
public
static
class
Email
{
public
static
final
String
EMAIL_QUEUE_NAME
=
"mail-alert-queue"
;
public
static
final
String
EMAIL_QUEUE_NAME_ROUTING_KEY
=
"mail-alert-queue-routing-key"
;
}
public
static
class
Order
{
public
static
final
String
QUEUE_NAME
=
"push-order-queue"
;
public
static
final
String
QUEUE_NAME_ROUTING_KEY
=
"push-order-queue-routing-key"
;
public
static
final
String
OPEN_QUEUE_NAME
=
"open-push-order-queue"
;
public
static
final
String
OPEN_QUEUE_NAME_ROUTING_KEY
=
"open-push-order-queue-routing-key"
;
//开放平台
public
static
final
String
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_QUEUE_NAME
=
"open-platform-order-status-change-push-queue"
;
public
static
final
String
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_ROUTING_KEY
=
"open-platform-order-status-change-routing-key"
;
public
static
final
String
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_DL_QUEUE_NAME
=
"open-platform-order-status-change-push-dl-queue"
;
public
static
final
String
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_DL_ROUTING_KEY
=
"open-platform-order-status-change-dl-routing-key"
;
public
static
final
String
OPEN_PLATFORM_ORDER_DIVER_PUSH_QUEUE_NAME
=
"open-platform-order-diver-push-queue"
;
public
static
final
String
OPEN_PLATFORM_ORDER_DIVER_PUSH_ROUTING_KEY
=
"open-platform-order-diver-routing-key"
;
}
public
static
class
Member
{
public
static
final
String
MEMBER_QUEUE
=
"push-member-queue"
;
public
static
final
String
MEMBER_NAME_ROUTING_KEY
=
"push-member-queue-routing-key"
;
public
static
final
String
MEMBER_DL_QUEUE
=
"push-member-dead-letter-queue"
;
public
static
final
String
MEMBER_DL_NAME_ROUTING_KEY
=
"push-member-dead-letter-queue-routing-key"
;
}
public
static
class
Score
{
public
static
final
String
SCORE_QUEUE_NAME
=
"send_score_queue"
;
public
static
final
String
SCORE_QUEUE_NAME_ROUTING_KEY
=
"send_score_key"
;
}
public
static
class
WechatPush
{
public
static
final
String
WECHAT_QUEUE_NAME
=
"wechat_queue"
;
public
static
final
String
WECHAT_QUEUE_NAME_ROUTING_KEY
=
"wechat_key"
;
}
public
static
class
SendExperience
{
public
static
final
String
EXPERIENCE_QUEUE_NAME
=
"send_experience_queue"
;
public
static
final
String
EXPERIENCE_QUEUE_NAME_ROUTING_KEY
=
"send_experience_key"
;
}
/**
* 本地调试使用
*/
public
static
class
LocalSendScore
{
public
static
final
String
QUEUE_NAME
=
"local-send-score-queue"
;
public
static
final
String
QUEUE_NAME_ROUTING_KEY
=
"local-send-score-queue-routing-key"
;
}
/**
* 自动屡单业务队列
*/
public
static
class
OrderAutomaticExecute
{
public
static
final
String
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME
=
"order_automatic_execute"
;
public
static
final
String
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME_ROUTING_KEY
=
"order_automatic_execute_routing_key"
;
public
static
class
OrderAutomaticMakeFinishedAutomaticExecuteLetterQueue
{
public
static
final
String
ORDER_MAKE_FINISHED_DEAD_LETTER_QUEUE_NAME
=
"order_automatic_make_finished_dead_letter_queue_name"
;
public
static
final
String
ORDER_MAKE_FINISHED_DEAD_LETTER_QUEUE_NAME_ROUTING_KEY
=
"order_automatic_make_finished_dead_letter_routing_key"
;
}
public
static
class
OrderAutomaticCompleteAutomaticExecuteLetterQueue
{
public
static
final
String
ORDER_COMPLETE_DEAD_LETTER_QUEUE_NAME
=
"order_automatic_complete_dead_letter_queue_name"
;
public
static
final
String
ORDER_COMPLETE_DEAD_LETTER_QUEUE_NAME_ROUTING_KEY
=
"order_automatic_complete_dead_letter_routing_key"
;
}
}
}
platform-order-service/src/main/java/com/freemud/platform/amp/order/OrderAmpConfig.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
amp
.
order
;
import
cn.freemud.amqp.config.MQConfig
;
import
com.freemud.platform.amp.constant.QueueMetadata
;
import
org.springframework.amqp.core.*
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.context.annotation.Bean
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: ${FILE_NAME}
* @Package com.freemud.mail.core
* @Description: ${TODO}(用一句话描述该文件做什么)
* @author: aiqi.gong
* @date: 2019/5/23 15:18
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@AutoConfigureAfter
(
MQConfig
.
class
)
public
class
OrderAmpConfig
{
// /**
// * 定义基于Fanout 的Exchange。
// * 基于这个代码,也可以非常方便的定义其他的Exchange类型。
// *
// * @return Fanout Exchange
// */
// @ConditionalOnMissingBean
// @Bean
// public Exchange topicExchange() {
// return ExchangeBuilder.topicExchange(QueueMetadata.EXCHANGE_NAME).durable(true).build();
// }
/**
* 写入RabbitMQ使用的默认队列
*
* @return
*/
@Bean
(
"orderAutomaticExecute"
)
public
Queue
orderAutomaticExecute
()
{
return
QueueBuilder
.
durable
(
QueueMetadata
.
OrderAutomaticExecute
.
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME
).
build
();
}
/**
* 绑定消息队列
*
* @param queue 消息队列
* @param topicExchange RabbitMQ Fanout Exchange
* @return 消息队列绑定
*/
@Bean
(
"bindingOrderAutomaticExecute"
)
Binding
bindingOrderAutomaticExecute
(
@Qualifier
(
"orderAutomaticExecute"
)
Queue
queue
,
@Qualifier
(
"orderPushTopicExchange"
)
Exchange
topicExchange
)
{
return
BindingBuilder
.
bind
(
queue
).
to
(
topicExchange
).
with
(
QueueMetadata
.
OrderAutomaticExecute
.
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME_ROUTING_KEY
).
noargs
();
}
@Bean
(
"makeFinishedDeadLetterQueue"
)
public
Queue
makeFinishedDeadLetterQueue
()
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>(
2
);
args
.
put
(
"x-dead-letter-exchange"
,
QueueMetadata
.
EXCHANGE_NAME
);
args
.
put
(
"x-dead-letter-routing-key"
,
QueueMetadata
.
OrderAutomaticExecute
.
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME_ROUTING_KEY
);
return
QueueBuilder
.
durable
(
QueueMetadata
.
OrderAutomaticExecute
.
OrderAutomaticMakeFinishedAutomaticExecuteLetterQueue
.
ORDER_MAKE_FINISHED_DEAD_LETTER_QUEUE_NAME
).
withArguments
(
args
).
build
();
}
@Bean
(
"makeFinishedDeadLetterToOrderAutomaticExecute"
)
public
Binding
makeFinishedDeadLetterToOrderAutomaticExecute
(
@Qualifier
(
"makeFinishedDeadLetterQueue"
)
Queue
queue
,
@Qualifier
(
"orderPushTopicExchange"
)
Exchange
topicExchange
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>(
2
);
args
.
put
(
"x-dead-letter-exchange"
,
QueueMetadata
.
EXCHANGE_NAME
);
args
.
put
(
"x-dead-letter-routing-key"
,
QueueMetadata
.
OrderAutomaticExecute
.
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME_ROUTING_KEY
);
return
BindingBuilder
.
bind
(
queue
).
to
(
topicExchange
).
with
(
QueueMetadata
.
OrderAutomaticExecute
.
OrderAutomaticMakeFinishedAutomaticExecuteLetterQueue
.
ORDER_MAKE_FINISHED_DEAD_LETTER_QUEUE_NAME_ROUTING_KEY
).
and
(
args
);
}
@Bean
(
"completeDeadLetterQueue"
)
public
Queue
completeDeadLetterQueue
()
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>(
2
);
args
.
put
(
"x-dead-letter-exchange"
,
QueueMetadata
.
EXCHANGE_NAME
);
args
.
put
(
"x-dead-letter-routing-key"
,
QueueMetadata
.
OrderAutomaticExecute
.
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME_ROUTING_KEY
);
return
QueueBuilder
.
durable
(
QueueMetadata
.
OrderAutomaticExecute
.
OrderAutomaticCompleteAutomaticExecuteLetterQueue
.
ORDER_COMPLETE_DEAD_LETTER_QUEUE_NAME
).
withArguments
(
args
).
build
();
}
@Bean
(
"completeDeadLetterToOrderAutomaticExecute"
)
public
Binding
completeDeadLetterToOrderAutomaticExecute
(
@Qualifier
(
"completeDeadLetterQueue"
)
Queue
queue
,
@Qualifier
(
"orderPushTopicExchange"
)
Exchange
topicExchange
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>(
2
);
args
.
put
(
"x-dead-letter-exchange"
,
QueueMetadata
.
EXCHANGE_NAME
);
args
.
put
(
"x-dead-letter-routing-key"
,
QueueMetadata
.
OrderAutomaticExecute
.
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME_ROUTING_KEY
);
return
BindingBuilder
.
bind
(
queue
).
to
(
topicExchange
).
with
(
QueueMetadata
.
OrderAutomaticExecute
.
OrderAutomaticCompleteAutomaticExecuteLetterQueue
.
ORDER_COMPLETE_DEAD_LETTER_QUEUE_NAME_ROUTING_KEY
).
and
(
args
);
}
}
platform-order-service/src/main/java/com/freemud/platform/amp/order/OrderAmpService.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
amp
.
order
;
import
cn.freemud.amqp.MQMessage
;
import
com.alibaba.fastjson.JSON
;
import
com.freemud.platform.amp.constant.QueueMetadata
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.core.MessagePostProcessor
;
import
org.springframework.amqp.core.MessageProperties
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.ImportAutoConfiguration
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: ${FILE_NAME}
* @Package com.freemud.mail.core
* @Description: ${TODO}(用一句话描述该文件做什么)
* @author: aiqi.gong
* @date: 2019/5/23 16:21
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@ImportAutoConfiguration
(
classes
=
{
OrderAmpConfig
.
class
})
public
class
OrderAmpService
{
@Autowired
private
RabbitTemplate
rabbitTemplate
;
// @Autowired
// private OrderDistributionService orderDistributionService;
public
void
convertAndSend
(
String
orderCode
)
{
MQMessage
<
OrderAutomaticBody
>
mqMessage
=
buildOrderBody
(
orderCode
);
rabbitTemplate
.
convertAndSend
(
QueueMetadata
.
EXCHANGE_NAME
,
QueueMetadata
.
OrderAutomaticExecute
.
ORDER_AUTOMATIC_EXECUTE_QUEUE_NAME_ROUTING_KEY
,
mqMessage
);
}
public
void
convertAndSendToMake
(
String
partnerId
,
String
orderCode
,
long
ttl
)
{
MQMessage
<
OrderAutomaticBody
>
mqMessage
=
buildOrderBody
(
orderCode
);
mqMessage
.
getBody
().
setOrderStatus
(
OrderAutomaticBody
.
OpOrderStatus
.
COMPLETE_MAKE
.
getCode
());
mqMessage
.
getBody
().
setPartnerId
(
partnerId
);
rabbitTemplate
.
convertAndSend
(
QueueMetadata
.
EXCHANGE_NAME
,
QueueMetadata
.
OrderAutomaticExecute
.
OrderAutomaticMakeFinishedAutomaticExecuteLetterQueue
.
ORDER_MAKE_FINISHED_DEAD_LETTER_QUEUE_NAME_ROUTING_KEY
,
mqMessage
,
buildOrderMessagePostProcessor
(
ttl
));
}
public
void
convertAndSendToComplete
(
String
partnerId
,
String
orderCode
,
long
ttl
)
{
MQMessage
<
OrderAutomaticBody
>
mqMessage
=
buildOrderBody
(
orderCode
);
mqMessage
.
getBody
().
setOrderStatus
(
OrderAutomaticBody
.
OpOrderStatus
.
COMPLETE
.
getCode
());
mqMessage
.
getBody
().
setPartnerId
(
partnerId
);
rabbitTemplate
.
convertAndSend
(
QueueMetadata
.
EXCHANGE_NAME
,
QueueMetadata
.
OrderAutomaticExecute
.
OrderAutomaticCompleteAutomaticExecuteLetterQueue
.
ORDER_COMPLETE_DEAD_LETTER_QUEUE_NAME_ROUTING_KEY
,
mqMessage
,
buildOrderMessagePostProcessor
(
ttl
));
}
private
MQMessage
<
OrderAutomaticBody
>
buildOrderBody
(
String
orderCode
)
{
MQMessage
<
OrderAutomaticBody
>
mqMessage
=
new
MQMessage
<>();
OrderAutomaticBody
messageBode
=
new
OrderAutomaticBody
();
messageBode
.
setOrderCode
(
orderCode
);
mqMessage
.
setBody
(
messageBode
);
return
mqMessage
;
}
// public void messageDistribute(SendScoreDistributeOrderBody sendScoreDistributeOrderBody){
// DisRequest disRequest = new DisRequest();
// disRequest.setPartnerId(sendScoreDistributeOrderBody.getOrderBean().getCompanyId());
// disRequest.setStatus(sendScoreDistributeOrderBody.getOrderBean().getStatus().toString());
// disRequest.setVer("1");
// disRequest.setExtJson(JSONObject.toJSONString(sendScoreDistributeOrderBody));
// orderDistributionService.pushOrder(disRequest);
// }
/**
* 单位秒
*
* @param expiration
*/
private
MessagePostProcessor
buildOrderMessagePostProcessor
(
long
expiration
)
{
MessagePostProcessor
messagePostProcessor
=
message
->
{
MessageProperties
messageProperties
=
message
.
getMessageProperties
();
// 设置编码
messageProperties
.
setContentEncoding
(
"utf-8"
);
// 设置过期时间10*1000毫秒(最终过期时间取x-message-ttl和messageProperties.setExpiration的最小值
messageProperties
.
setExpiration
(
String
.
valueOf
(
expiration
*
1000
));
return
message
;
};
return
messagePostProcessor
;
}
public
void
sendOrderStatusChangeDelayNotifyMsg
(
MQMessage
notifyMsg
,
String
expire
,
String
delayKey
)
{
byte
[]
notifyMsgBytes
=
JSON
.
toJSONString
(
notifyMsg
).
getBytes
();
MessageProperties
messageProperties
=
new
MessageProperties
();
messageProperties
.
setExpiration
(
expire
);
messageProperties
.
setContentType
(
MessageProperties
.
CONTENT_TYPE_JSON
);
Message
message
=
new
Message
(
notifyMsgBytes
,
messageProperties
);
rabbitTemplate
.
convertAndSend
(
QueueMetadata
.
EXCHANGE_NAME
,
delayKey
,
message
);
}
}
platform-order-service/src/main/java/com/freemud/platform/amp/order/OrderAutomaticBody.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
amp
.
order
;
import
lombok.Data
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: ${FILE_NAME}
* @Package com.freemud.mail.core
* @Description: ${TODO}(用一句话描述该文件做什么)
* @author: aiqi.gong
* @date: 2019/5/23 16:10
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public
class
OrderAutomaticBody
{
/**
* 订单号
*/
private
String
orderCode
;
private
Integer
orderStatus
;
private
String
partnerId
;
public
enum
OpOrderStatus
{
COMPLETE
(
5
,
"完成"
),
COMPLETE_MAKE
(
31
,
"制作完成"
);
private
Integer
code
;
private
String
desc
;
OpOrderStatus
(
Integer
code
,
String
desc
)
{
this
.
code
=
code
;
this
.
desc
=
desc
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getDesc
()
{
return
desc
;
}
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
}
}
platform-order-service/src/main/java/com/freemud/platform/amp/order/OrderStatusChangePushConfig.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
amp
.
order
;
import
cn.freemud.amqp.config.MQConfig
;
import
com.freemud.platform.amp.constant.QueueMetadata
;
import
org.springframework.amqp.core.*
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.context.annotation.Bean
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* All rights Reserved, Designed By www.freemud.com
*
* @version V1.0
* @Title:
* @Package: com.freemud.platform.amp.order
* @Descripttion:
* @author: shuhu.hou
* @date: 2019/7/7
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目.
*/
@AutoConfigureAfter
(
MQConfig
.
class
)
public
class
OrderStatusChangePushConfig
{
@Bean
(
"orderStatusChangeTopicExchange"
)
public
Exchange
orderStatusChangeTopicExchange
()
{
return
ExchangeBuilder
.
topicExchange
(
QueueMetadata
.
EXCHANGE_NAME
).
durable
(
true
).
build
();
}
/**
* 写入RabbitMQ使用的默认队列
*
* @return
*/
@Bean
(
"orderStatusChangeQueue"
)
public
Queue
orderStatusChangeQueue
()
{
return
QueueBuilder
.
durable
(
QueueMetadata
.
Order
.
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_QUEUE_NAME
).
build
();
}
@Bean
(
"orderStatusChangeDlQueue"
)
public
Queue
orderStatusChangeDlQueue
()
{
Map
<
String
,
Object
>
delayQueueParams
=
new
HashMap
<>(
2
);
// DLX,dead letter发送到的exchange
delayQueueParams
.
put
(
"x-dead-letter-exchange"
,
QueueMetadata
.
EXCHANGE_NAME
);
// dead letter携带的routing key
delayQueueParams
.
put
(
"x-dead-letter-routing-key"
,
QueueMetadata
.
Order
.
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_ROUTING_KEY
);
return
QueueBuilder
.
durable
(
QueueMetadata
.
Order
.
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_DL_QUEUE_NAME
).
withArguments
(
delayQueueParams
).
build
();
}
/**
* 绑定消息队列
*
* @param queue 消息队列
* @param topicExchange RabbitMQ Fanout Exchange
* @return 消息队列绑定
*/
@Bean
(
"bindingOrderStatusChange"
)
Binding
bindingOrderStatusChange
(
@Qualifier
(
"orderStatusChangeQueue"
)
Queue
queue
,
@Qualifier
(
"orderStatusChangeTopicExchange"
)
Exchange
topicExchange
)
{
return
BindingBuilder
.
bind
(
queue
).
to
(
topicExchange
).
with
(
QueueMetadata
.
Order
.
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_ROUTING_KEY
).
noargs
();
}
@Bean
(
"bindingOrderStatusDlChange"
)
Binding
bindingOrderStatusDlChange
(
@Qualifier
(
"orderStatusChangeDlQueue"
)
Queue
queue
,
@Qualifier
(
"orderStatusChangeTopicExchange"
)
Exchange
topicExchange
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>(
2
);
args
.
put
(
"x-dead-letter-exchange"
,
QueueMetadata
.
EXCHANGE_NAME
);
args
.
put
(
"x-dead-letter-routing-key"
,
QueueMetadata
.
Order
.
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_ROUTING_KEY
);
return
BindingBuilder
.
bind
(
queue
).
to
(
topicExchange
).
with
(
QueueMetadata
.
Order
.
OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_DL_ROUTING_KEY
).
and
(
args
);
}
}
platform-order-service/src/main/java/com/freemud/platform/common/annotations/PlatformRequestBody.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
annotations
;
import
java.lang.annotation.*
;
/**
* @author sunjiajie
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
,
ElementType
.
PARAMETER
})
@Documented
public
@interface
PlatformRequestBody
{
Class
value
();
}
platform-order-service/src/main/java/com/freemud/platform/common/code/PlatformStatusCode.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
code
;
/**
* All rights Reserved, Designed By www.freemud.com
*
* @version V1.0
* @Title:
* @Package: cn.freemud.base.open.code
* @Descripttion:
* @author: genyou.cui
* @date: 2019/4/19 16:33
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目.
*/
public
enum
PlatformStatusCode
{
/**
* 开放平台适配器返回响应状态码
* 100成功, 小于100的定义开个店系统级别返回码
*/
MISSING_PARAMS
(
"21"
,
"缺少必要参数"
),
SIGN_ERROR
(
"22"
,
"签名错误"
),
NOT_SUPPORT
(
"23"
,
"操作不支持"
),
API_ERROR
(
"24"
,
"API调用失败"
),
SUCCESS
(
"100"
,
"成功"
),
/**
* 500系统错误全局唯一
*/
SYSTEM_ERROR
(
"500"
,
"系统错误"
),
/**
* 业务码由4位组成
* 1001 支付
* 2001 订单
* 3001 商品
* 4001 券码
* 5001 门店
* 6001 会员
* 7001 兑换码
*
* 业务错误信息,如果基础服务有返回准确的错误消息需要拼接到以下msg后面
* 例如("创建预支付订单失败"+"原因:"+基础服务返回msg)
*/
PAYMENT_STATUS_1001
(
"1001"
,
"创建预支付订单失败"
),
ORDER_STATUS_2001
(
"2001"
,
"创建订单失败"
),
ORDER_STATUS_2002
(
"2002"
,
"该售后已再审核中,请勿重复操作"
),
GOODS_STATUS_3001
(
"3001"
,
"根绝门店id查询商品失败"
),
GOODS_STATUS_3002
(
"3002"
,
"商品沽清失败"
),
GOODS_STATUS_3003
(
"3003"
,
"商品撤销沽清失败"
),
GOODS_STATUS_3100
(
"3100"
,
"商品信息不能为空"
),
COUPON_STATUS_4001
(
"4001"
,
"查询券码失败"
),
COUPON_STATUS_4002
(
"4002"
,
"核销券码失败"
),
COUPON_STATUS_4003
(
"4003"
,
"冲正券码失败"
),
MEMBER_STATUS_6001
(
"6001"
,
"查询会员失败"
),
MEMBER_STATUS_6002
(
"6002"
,
"会员不存在"
),
MEMBER_STATUS_6003
(
"6003"
,
"暂无数据"
),
STORE_STATUS_5001
(
"5001"
,
"门店信息不存在"
),
STORE_STATUS_5002
(
"5002"
,
"门店信息修改失败"
),
OUT_OF_LENGTH
(
"5003"
,
"列表长度不能超过300"
),
REDEEM_STATUS_7001
(
"7001"
,
"兑换码批量上传失败"
),
REDEEM_STATUS_7002
(
"7002"
,
"兑换码批量作废失败"
),
UPDATE_SCORE_ERROR_7003
(
"7003"
,
"更新积分失败"
),
SEND_SCORE_ERROR_7004
(
"7004"
,
"发送积分失败"
),
REFUND_SCORE_ERROR_7005
(
"7005"
,
"回退积分失败"
),
GET_DYNAMIC_CODE_ERROR_7006
(
"7006"
,
"解密动态码失败"
),
ANALYZE_DYNAMIC_CODE_ERROR_7007
(
"7007"
,
"解析动态码失败"
),
;
private
String
statusCode
;
private
String
message
;
PlatformStatusCode
(
String
statusCode
,
String
message
)
{
this
.
statusCode
=
statusCode
;
this
.
message
=
message
;
}
public
String
getStatusCode
()
{
return
statusCode
;
}
public
String
getMessage
()
{
return
message
;
}
public
static
PlatformStatusCode
getInfoByCode
(
String
statusCode
)
{
for
(
PlatformStatusCode
adapterStatusCode
:
values
())
{
if
(
adapterStatusCode
.
getStatusCode
().
equals
(
statusCode
))
{
return
adapterStatusCode
;
}
}
return
null
;
}
}
platform-order-service/src/main/java/com/freemud/platform/common/constant/VersionNum.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
constant
;
/**
* All rights Reserved, Designed By www.freemud.com
*
* @version V1.0
* @Title:
* @Package: cn.freemud.base.constant
* @Descripttion:
* @author: genyou.cui
* @date: 2019/4/19 16:45
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目.
*/
public
class
VersionNum
{
public
static
final
String
VERSION_ONE
=
"1"
;
public
static
final
String
VERSION_TWO
=
"2"
;
public
static
final
int
VERSION_1
=
1
;
}
platform-order-service/src/main/java/com/freemud/platform/common/entity/PaginationRequest.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
entity
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: PaginationRequest
* @Package com.freemud.platform.common.entity
* @Description: 简单描述下这个类是做什么用的
* @author: bingnan.zhang
* @date: 2019/7/9 11:15
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public
class
PaginationRequest
implements
Serializable
{
private
Integer
pageNum
;
private
Integer
pageSize
;
}
platform-order-service/src/main/java/com/freemud/platform/common/entity/PaginationResponse.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
entity
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: PaginationRequest
* @Package com.freemud.platform.common.entity
* @Description: 简单描述下这个类是做什么用的
* @author: bingnan.zhang
* @date: 2019/7/9 11:15
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public
class
PaginationResponse
implements
Serializable
{
private
Integer
pageNum
;
private
Integer
pageSize
;
private
Integer
totalCount
;
private
Integer
totalPages
;
}
platform-order-service/src/main/java/com/freemud/platform/common/entity/PlatformBaseRequest.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
entity
;
import
lombok.Data
;
import
javax.validation.constraints.NotEmpty
;
/**
* All rights Reserved, Designed By www.freemud.com
*
* @version V1.0
* @Title:
* @Package: cn.freemud.base.entity
* @Descripttion:
* @author: genyou.cui
* @date: 2019/4/19 15:11
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目.
*/
@Data
public
class
PlatformBaseRequest
{
/**
* 版本号
*/
@NotEmpty
(
message
=
"ver不能为空"
)
private
String
ver
;
/**
* 由非码颁发商户唯一标识
*/
@NotEmpty
(
message
=
"partnerId不能为空"
)
private
String
partnerId
;
/**
* 由非码颁发平台唯一标识
*/
@NotEmpty
(
message
=
"appId不能为空"
)
private
String
appId
;
/**
* 业务请求参数json格式字符串
*/
@NotEmpty
(
message
=
"requestBody不能为空"
)
private
String
requestBody
;
/**
* SHA256WithRSA 加密签名
*/
@NotEmpty
(
message
=
"sign不能为空"
)
private
String
sign
;
}
platform-order-service/src/main/java/com/freemud/platform/common/entity/PlatformBaseResponse.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
entity
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* All rights Reserved, Designed By www.freemud.com
*
* @version V1.0
* @Title:
* @Package: cn.freemud.base.entity
* @Descripttion:
* @author: genyou.cui
* @date: 2019/4/19 15:14
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
PlatformBaseResponse
{
/**
* 版本号
*/
private
String
ver
;
/**
* 返回状态码
*/
private
String
statusCode
;
/**
* 返回信息
*/
private
String
message
;
/**
* 业务响应参数
*/
private
String
responseBody
;
/**
* 返回签名
*/
private
String
sign
;
}
platform-order-service/src/main/java/com/freemud/platform/common/entity/ResponseBuilder.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
entity
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.platform.common.code.PlatformStatusCode
;
import
com.freemud.platform.common.constant.VersionNum
;
/**
* All rights Reserved, Designed By www.freemud.com
*
* @version V1.0
* @Title:
* @Package: cn.freemud.base.entity
* @Descripttion:
* @author: genyou.cui
* @date: 2019/4/19 16:31
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目.
*/
public
class
ResponseBuilder
{
/**
* 无业务响应参数成功返回
* @return
*/
public
static
PlatformBaseResponse
success
()
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
PlatformStatusCode
.
SUCCESS
.
getStatusCode
())
.
message
(
PlatformStatusCode
.
SUCCESS
.
getMessage
())
.
build
();
}
/**
* 带有业务响应参数成功返回
* @return
*/
public
static
PlatformBaseResponse
success
(
String
result
)
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
PlatformStatusCode
.
SUCCESS
.
getStatusCode
())
.
message
(
PlatformStatusCode
.
SUCCESS
.
getMessage
())
.
responseBody
(
result
)
.
build
();
}
/**
* 带有复杂业务响应参数成功返回
* @return
*/
public
static
PlatformBaseResponse
success
(
Object
obj
)
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
PlatformStatusCode
.
SUCCESS
.
getStatusCode
())
.
message
(
PlatformStatusCode
.
SUCCESS
.
getMessage
())
.
responseBody
(
JSONObject
.
toJSONString
(
obj
))
.
build
();
}
/**
* 指定版本,带有复杂业务响应参数成功返回
* @return
*/
public
static
PlatformBaseResponse
success
(
String
ver
,
Object
obj
)
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
ver
)
.
statusCode
(
PlatformStatusCode
.
SUCCESS
.
getStatusCode
())
.
message
(
PlatformStatusCode
.
SUCCESS
.
getMessage
())
.
responseBody
(
JSONObject
.
toJSONString
(
obj
))
.
build
();
}
public
static
PlatformBaseResponse
error
(
PlatformStatusCode
platformStatusCode
)
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
platformStatusCode
.
getStatusCode
())
.
message
(
platformStatusCode
.
getMessage
())
.
build
();
}
public
static
PlatformBaseResponse
error
(
PlatformStatusCode
platformStatusCode
,
String
message
)
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
platformStatusCode
.
getStatusCode
())
.
message
(
message
)
.
build
();
}
public
static
PlatformBaseResponse
error
(
PlatformStatusCode
platformStatusCode
,
Object
object
)
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
platformStatusCode
.
getStatusCode
())
.
message
(
platformStatusCode
.
getMessage
())
.
responseBody
(
JSONObject
.
toJSONString
(
object
))
.
build
();
}
public
static
PlatformBaseResponse
buildError
(
PlatformStatusCode
platformStatusCode
,
String
message
)
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
platformStatusCode
.
getStatusCode
())
.
message
(
platformStatusCode
.
getMessage
()
+
": "
+
message
)
.
build
();
}
public
static
PlatformBaseResponse
apiError
(
String
code
,
String
message
)
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
code
)
.
message
(
message
)
.
build
();
}
public
static
PlatformBaseResponse
resultEmpty
()
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
PlatformStatusCode
.
API_ERROR
.
getStatusCode
())
.
message
(
PlatformStatusCode
.
API_ERROR
.
getMessage
())
.
build
();
}
public
static
PlatformBaseResponse
outOfLength
()
{
return
PlatformBaseResponse
.
builder
()
.
ver
(
VersionNum
.
VERSION_ONE
)
.
statusCode
(
PlatformStatusCode
.
OUT_OF_LENGTH
.
getStatusCode
())
.
message
(
PlatformStatusCode
.
OUT_OF_LENGTH
.
getMessage
())
.
build
();
}
public
static
boolean
isSuccess
(
PlatformBaseResponse
response
)
{
return
response
.
getStatusCode
().
equals
(
PlatformStatusCode
.
SUCCESS
.
getStatusCode
());
}
}
platform-order-service/src/main/java/com/freemud/platform/common/util/DateTimeUtil.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
util
;
import
java.time.*
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeParseException
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.Temporal
;
import
java.time.temporal.TemporalAdjusters
;
import
java.util.Date
;
/**
* @author sunjiajie
*/
public
class
DateTimeUtil
{
public
static
final
String
YYYY_MM_DD_HH_MM_SS
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
DateTimeFormatter
DATETIME_FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
public
static
final
DateTimeFormatter
DATE_FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
public
static
final
DateTimeFormatter
FORMAT_YYYY_DD_23_59_59
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd 23:59:59"
);
public
static
final
DateTimeFormatter
TIME_FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"HH:mm:ss"
);
/**
* 返回当前的日期
*
* @return
*/
public
static
LocalDate
getCurrentLocalDate
()
{
return
LocalDate
.
now
();
}
/**
* 返回当前日期时间
*
* @return
*/
public
static
LocalDateTime
getCurrentLocalDateTime
()
{
return
LocalDateTime
.
now
();
}
/**
* 返回当前日期字符串 yyyyMMdd
*
* @return
*/
public
static
String
getCurrentDateStr
()
{
return
LocalDate
.
now
().
format
(
DATE_FORMATTER
);
}
/**
* 返回当前时间字符串 HHmmss
*
* @return
*/
public
static
String
getCurrentTimeStr
()
{
return
LocalDateTime
.
now
().
format
(
TIME_FORMATTER
);
}
/**
* 返回当前日期时间字符串 yyyyMMddHHmmss
*
* @return
*/
public
static
String
getCurrentDateTimeStr
()
{
return
LocalDateTime
.
now
().
format
(
DATETIME_FORMATTER
);
}
/**
* 将date转为string类型
* @param date
* @param pattern
* @return
*/
public
static
String
getDateStr
(
Date
date
,
String
pattern
)
{
Instant
instant
=
date
.
toInstant
();
ZoneId
zoneId
=
ZoneId
.
systemDefault
();
LocalDateTime
localDateTime
=
instant
.
atZone
(
zoneId
).
toLocalDateTime
();
DateTimeFormatter
timeFormatter
=
DateTimeFormatter
.
ofPattern
(
pattern
);
return
localDateTime
.
format
(
timeFormatter
);
}
/**
* 将date转为string类型
* @param date
* @param dateTimeFormatter
* @return
*/
public
static
String
getDateStr
(
Date
date
,
DateTimeFormatter
dateTimeFormatter
)
{
Instant
instant
=
date
.
toInstant
();
ZoneId
zoneId
=
ZoneId
.
systemDefault
();
LocalDateTime
localDateTime
=
instant
.
atZone
(
zoneId
).
toLocalDateTime
();
return
localDateTime
.
format
(
dateTimeFormatter
);
}
/**
* 返回当前日期
* @param dateStr
* @param pattern
* @return
*/
public
static
Date
parseDate
(
String
dateStr
,
String
pattern
)
{
ZoneId
zoneId
=
ZoneId
.
systemDefault
();
try
{
// 默认先尝试解析成带时间的date
return
parseDateTime
(
dateStr
,
pattern
);
}
catch
(
DateTimeParseException
e
)
{
LocalDate
localDate
=
LocalDate
.
parse
(
dateStr
,
DateTimeFormatter
.
ofPattern
(
pattern
));
ZonedDateTime
zdt
=
localDate
.
atStartOfDay
(
zoneId
);
return
Date
.
from
(
zdt
.
toInstant
());
}
}
/**
* 返回当前日期(包含时间)
* @param dateTimeStr
* @param pattern
* @return
*/
private
static
Date
parseDateTime
(
String
dateTimeStr
,
String
pattern
)
{
ZoneId
zoneId
=
ZoneId
.
systemDefault
();
LocalDateTime
localDateTime
=
LocalDateTime
.
parse
(
dateTimeStr
,
DateTimeFormatter
.
ofPattern
(
pattern
));
ZonedDateTime
zdt
=
localDateTime
.
atZone
(
zoneId
);
return
Date
.
from
(
zdt
.
toInstant
());
}
public
static
LocalDate
parseLocalDate
(
String
dateStr
,
String
pattern
)
{
return
LocalDate
.
parse
(
dateStr
,
DateTimeFormatter
.
ofPattern
(
pattern
));
}
public
static
LocalDateTime
parseLocalDateTime
(
String
dateTimeStr
,
String
pattern
)
{
return
LocalDateTime
.
parse
(
dateTimeStr
,
DateTimeFormatter
.
ofPattern
(
pattern
));
}
/**
* 日期相隔天数
*
* @param startDateInclusive
* @param endDateExclusive
* @return
*/
public
static
int
periodDays
(
LocalDate
startDateInclusive
,
LocalDate
endDateExclusive
)
{
return
Period
.
between
(
startDateInclusive
,
endDateExclusive
).
getDays
();
}
/**
* 日期相隔小时
*
* @param startInclusive
* @param endExclusive
* @return
*/
public
static
long
durationHours
(
Temporal
startInclusive
,
Temporal
endExclusive
)
{
return
Duration
.
between
(
startInclusive
,
endExclusive
).
toHours
();
}
/**
* 日期相隔分钟
*
* @param startInclusive
* @param endExclusive
* @return
*/
public
static
long
durationMinutes
(
Temporal
startInclusive
,
Temporal
endExclusive
)
{
return
Duration
.
between
(
startInclusive
,
endExclusive
).
toMinutes
();
}
/**
* 日期相隔毫秒数
*
* @param startInclusive
* @param endExclusive
* @return
*/
public
static
long
durationMillis
(
Temporal
startInclusive
,
Temporal
endExclusive
)
{
return
Duration
.
between
(
startInclusive
,
endExclusive
).
toMillis
();
}
/**
* 是否当天
*
* @param date
* @return
*/
public
static
boolean
isToday
(
LocalDate
date
)
{
return
getCurrentLocalDate
().
equals
(
date
);
}
/**
* 获取本月的第一天
*
* @return
*/
public
static
String
getFirstDayOfThisMonth
()
{
return
getCurrentLocalDate
().
with
(
TemporalAdjusters
.
firstDayOfMonth
()).
format
(
DATE_FORMATTER
);
}
/**
* 获取本月的最后一天
*
* @return
*/
public
static
String
getLastDayOfThisMonth
()
{
return
getCurrentLocalDate
().
with
(
TemporalAdjusters
.
lastDayOfMonth
()).
format
(
DATE_FORMATTER
);
}
/**
* 获取2017-01的第一个周一
*
* @return
*/
public
static
String
getFirstMonday
()
{
return
LocalDate
.
parse
(
"2017-01-01"
).
with
(
TemporalAdjusters
.
firstInMonth
(
DayOfWeek
.
MONDAY
))
.
format
(
DATE_FORMATTER
);
}
/**
* 获取当前日期的后两周
*
* @return
*/
public
static
String
getCurDateAfterTwoWeek
()
{
return
getCurrentLocalDate
().
plus
(
2
,
ChronoUnit
.
WEEKS
).
format
(
DATE_FORMATTER
);
}
/**
* 获取当前日期的6个月后的日期
*
* @return
*/
public
static
String
getCurDateAfterSixMonth
()
{
return
getCurrentLocalDate
().
plus
(
6
,
ChronoUnit
.
MONTHS
).
format
(
DATE_FORMATTER
);
}
/**
* 获取当前日期的5年后的日期
*
* @return
*/
public
static
String
getCurDateAfterFiveYear
()
{
return
getCurrentLocalDate
().
plus
(
5
,
ChronoUnit
.
YEARS
).
format
(
DATE_FORMATTER
);
}
/**
* 对当前日期增加天数
* @param date
* @param day
* @return localDateTime
*/
public
static
LocalDateTime
addDays
(
Date
date
,
int
day
)
{
Instant
instant
=
date
.
toInstant
();
ZoneId
zone
=
ZoneId
.
systemDefault
();
LocalDateTime
localDateTime
=
LocalDateTime
.
ofInstant
(
instant
,
zone
);
return
localDateTime
.
plus
(
day
,
ChronoUnit
.
DAYS
);
}
/**
* 对当前日期增加天数并返回字符串
* @param date
* @param day
* @param dateTimeFormatter
* @return 日期的字符串
*/
public
static
String
getAddDaysStr
(
Date
date
,
int
day
,
DateTimeFormatter
dateTimeFormatter
)
{
return
addDays
(
date
,
day
).
format
(
dateTimeFormatter
);
}
/**
* 获取当前日期的20年后的日期
*
* @return
*/
public
static
String
getCurDateAfterTwentyYear
()
{
return
getCurrentLocalDate
().
plus
(
2
,
ChronoUnit
.
DECADES
).
format
(
DATE_FORMATTER
);
}
}
platform-order-service/src/main/java/com/freemud/platform/common/util/MapBeanConvertUtil.java
deleted
100644 → 0
View file @
5fc4c4d2
package
com
.
freemud
.
platform
.
common
.
util
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.beans.BeanInfo
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Method
;
import
java.math.BigDecimal
;
import
java.util.*
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: MapBeanConvertUtil
* @Package com.freemud.base.util
* @Description: Map和Bean互转
* @author: aiqi.gong
* @date: 2017/5/16 10:44
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public
class
MapBeanConvertUtil
{
public
final
static
char
SIGN
=
'&'
;
private
PropertyDescriptor
property
;
/**
* Map --> Bean
*
* @param map
* @param obj
*/
public
static
void
transMap2Bean
(
Map
<
String
,
Object
>
map
,
Object
obj
)
{
try
{
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
if
(
map
.
containsKey
(
key
))
{
Object
value
=
map
.
get
(
key
);
// 得到property对应的setter方法
Method
setter
=
property
.
getWriteMethod
();
setter
.
invoke
(
obj
,
value
);
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"transMap2Bean Error "
+
e
);
}
return
;
}
/**
* Bean --> Map
*
* @param obj
* @return
*/
public
static
Map
<
String
,
Object
>
transBean2Map
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
null
;
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
try
{
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
// 过滤class属性
if
(!
"class"
.
equals
(
key
))
{
// 得到property对应的getter方法
Method
getter
=
property
.
getReadMethod
();
Object
value
=
getter
.
invoke
(
obj
);
map
.
put
(
key
,
value
);
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"transBean2Map Error "
+
e
);
}
return
map
;
}
/**
* @param obj
* @param isboolean 为null或者为""的值是否不添加到map
* @return
*/
public
static
Map
<
String
,
Object
>
transBean2Map
(
Object
obj
,
boolean
isboolean
)
{
if
(
obj
==
null
)
{
return
null
;
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
try
{
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
// 过滤class属性
if
(!
"class"
.
equals
(
key
))
{
// 得到property对应的getter方法
Method
getter
=
property
.
getReadMethod
();
if
(
getter
!=
null
)
{
Object
value
=
getter
.
invoke
(
obj
);
if
(
isboolean
&&
(
value
==
null
))
{
continue
;
}
map
.
put
(
key
,
value
);
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
map
;
}
public
static
String
sortDataByAcss
(
Map
<
String
,
Object
>
params
,
char
sign
)
{
StringBuilder
paramsStr
=
new
StringBuilder
();
Collection
<
String
>
keyset
=
params
.
keySet
();
List
<
String
>
list
=
new
ArrayList
<>(
keyset
);
Collections
.
sort
(
list
);
for
(
String
s
:
list
)
{
paramsStr
.
append
(
sign
);
paramsStr
.
append
(
params
.
get
(
s
));
}
if
(
paramsStr
.
length
()
>
0
)
{
paramsStr
.
deleteCharAt
(
0
);
}
return
paramsStr
.
toString
();
}
/**
* 按照ASCII 排序
* @param obj 排序类
* @param sign 拼接字符
* @param containSymbols 是否拼接 =
* @return
*/
public
static
String
sortObjWithoutSign
(
Object
obj
,
char
sign
,
boolean
containSymbols
)
{
Map
<
String
,
Object
>
stringObjectMap
=
transBean2Map
(
obj
);
return
sortMapWithoutSign
(
stringObjectMap
,
sign
,
containSymbols
);
}
/**
* 按照ASCII 排序
* @param obj 排序类
* @param sign 拼接字符
* @return
*/
public
static
String
sortObjWithoutSign
(
Object
obj
,
char
sign
)
{
Map
<
String
,
Object
>
stringObjectMap
=
transBean2Map
(
obj
);
return
sortMapWithoutSign
(
stringObjectMap
,
sign
,
true
);
}
/**
* 按照ASCII 排序
* @param obj 排序类
* @return
*/
public
static
String
sortObjWithoutSign
(
Object
obj
)
{
Map
<
String
,
Object
>
stringObjectMap
=
transBean2Map
(
obj
);
return
sortMapWithoutSign
(
stringObjectMap
,
SIGN
,
true
);
}
public
static
String
sortMapWithoutSign
(
Map
<
String
,
Object
>
params
,
char
sign
,
boolean
containSymbols
)
{
if
(
CollectionUtils
.
isEmpty
(
params
))
{
return
null
;
}
params
.
remove
(
"sign"
);
String
buff
=
""
;
try
{
List
<
Map
.
Entry
<
String
,
Object
>>
infoIds
=
new
ArrayList
<>(
params
.
entrySet
());
// 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序)
infoIds
.
sort
(
Comparator
.
comparing
(
o
->
(
o
.
getKey
())));
// 构造URL 键值对的格式
StringBuilder
buf
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
Object
>
item
:
infoIds
)
{
if
(!
StringUtils
.
isEmpty
(
item
.
getKey
()))
{
String
key
=
item
.
getKey
();
String
val
=
null
;
if
(
item
.
getValue
()
==
null
)
{
continue
;
}
else
{
val
=
String
.
valueOf
(
item
.
getValue
());
}
buf
.
append
(
key
).
append
(
containSymbols
?
"="
:
""
).
append
(
val
);
buf
.
append
(
sign
);
}
}
buff
=
buf
.
toString
();
if
(
buff
.
isEmpty
()
==
false
&&
containSymbols
)
{
buff
=
buff
.
substring
(
0
,
buff
.
length
()
-
1
);
}
}
catch
(
Exception
e
)
{
return
null
;
}
return
buff
;
}
public
static
String
sortDataByAcssForJson
(
Map
<
String
,
Object
>
params
,
char
sign
)
{
StringBuilder
paramsStr
=
new
StringBuilder
();
Collection
<
String
>
keyset
=
params
.
keySet
();
List
list
=
new
ArrayList
<
String
>(
keyset
);
Collections
.
sort
(
list
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Object
obj
=
params
.
get
(
list
.
get
(
i
));
if
(
obj
instanceof
String
||
obj
instanceof
Integer
||
obj
instanceof
BigDecimal
||
obj
instanceof
Date
||
obj
instanceof
Long
||
obj
instanceof
Short
)
{
paramsStr
.
append
(
sign
);
paramsStr
.
append
(
params
.
get
(
list
.
get
(
i
)));
}
}
if
(
paramsStr
.
length
()
>
0
)
{
paramsStr
.
deleteCharAt
(
0
);
}
return
paramsStr
.
toString
();
}
public
static
String
sortDataByASCII
(
Object
object
)
{
Map
<
String
,
Object
>
params
=
transBean2Map
(
object
);
StringBuilder
paramsStr
=
new
StringBuilder
();
Collection
<
String
>
keyset
=
params
.
keySet
();
List
list
=
new
ArrayList
<
String
>(
keyset
);
Collections
.
sort
(
list
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
paramsStr
.
append
(
SIGN
);
paramsStr
.
append
(
params
.
get
(
list
.
get
(
i
)));
}
if
(
paramsStr
.
length
()
>
0
)
{
paramsStr
.
deleteCharAt
(
0
);
}
return
paramsStr
.
toString
();
}
/**
* Bean --> Map
*
* @param obj
* @return
*/
public
static
Map
<
String
,
String
>
transBeanStringMap
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
null
;
}
Map
<
String
,
String
>
map
=
new
HashMap
<>();
try
{
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
// 过滤class属性
if
(!
"class"
.
equals
(
key
))
{
// 得到property对应的getter方法
Method
getter
=
property
.
getReadMethod
();
Object
value
=
getter
.
invoke
(
obj
);
map
.
put
(
key
,
value
!=
null
?
value
.
toString
()
:
null
);
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"transBean2Map Error "
+
e
);
}
return
map
;
}
/**
* @param isBasic 是否只有基础类型才转换。
* @return
*/
public
static
Map
<
String
,
String
>
transBeanStringMap
(
Object
obj
,
boolean
isBasic
)
{
if
(
obj
==
null
)
{
return
null
;
}
Map
<
String
,
String
>
map
=
new
HashMap
<>();
try
{
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
// 过滤class属性
if
(!
"class"
.
equals
(
key
))
{
// 得到property对应的getter方法
Method
getter
=
property
.
getReadMethod
();
Object
value
=
getter
.
invoke
(
obj
);
if
(
isBasic
&&
(
value
instanceof
String
||
value
instanceof
Integer
||
value
instanceof
BigDecimal
||
value
instanceof
Date
||
value
instanceof
Long
||
value
instanceof
Short
))
{
map
.
put
(
key
,
value
.
toString
());
}
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"transBean2Map Error "
+
e
);
}
return
map
;
}
/**
* Bean --> Map
*
* @param obj
* @return
*/
public
static
Map
<
String
,
String
>
transBean2StringMap
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
null
;
}
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
try
{
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
// 过滤class属性
if
(!
"class"
.
equals
(
key
))
{
// 得到property对应的getter方法
Method
getter
=
property
.
getReadMethod
();
Object
value
=
getter
.
invoke
(
obj
);
map
.
put
(
key
,
String
.
valueOf
(
value
));
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"transBean2Map Error "
+
e
);
}
return
map
;
}
/**
* 将bean转换为Map<String, String> value 为对象则转换为json
*
* @param obj
* @return
*/
public
static
Map
<
String
,
String
>
transBean2MapJson
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
null
;
}
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
try
{
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
// 过滤class属性
if
(!
"class"
.
equals
(
key
))
{
// 得到property对应的getter方法
Method
getter
=
property
.
getReadMethod
();
Object
value
=
getter
.
invoke
(
obj
);
if
(
value
==
null
)
{
continue
;
}
if
(
value
instanceof
String
||
value
instanceof
Integer
||
value
instanceof
BigDecimal
||
value
instanceof
Date
||
value
instanceof
Long
||
value
instanceof
Short
)
{
map
.
put
(
key
,
value
.
toString
());
}
else
{
map
.
put
(
key
,
JSONObject
.
toJSONString
(
value
));
}
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"transBean2Map Error "
+
e
);
}
return
map
;
}
}
pom.xml
View file @
9c8277c8
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
<module>
call-back-service
</module>
<module>
call-back-service
</module>
<module>
push-order-service
</module>
<module>
push-order-service
</module>
<module>
platform-sdk
</module>
<module>
platform-sdk
</module>
<module>
platform-order-service
</module>
</modules>
</modules>
<parent>
<parent>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
...
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