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
order-group-application
order-group
Commits
8158e367
Commit
8158e367
authored
Jan 14, 2021
by
刘鹏飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单、订单详情查询使用es
parent
e8ac2bb5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
221 additions
and
0 deletions
+221
-0
order-application-service/src/main/java/cn/freemud/adapter/OrderAdapter.java
+162
-0
order-application-service/src/main/java/cn/freemud/service/impl/OrderServiceImpl.java
+59
-0
No files found.
order-application-service/src/main/java/cn/freemud/adapter/OrderAdapter.java
View file @
8158e367
...
...
@@ -15,6 +15,7 @@ package cn.freemud.adapter;
import
cn.freemud.base.log.LogTreadLocal
;
import
cn.freemud.base.util.DateUtil
;
import
cn.freemud.constant.CustomerScoreConstant
;
import
cn.freemud.constant.ResponseCodeConstant
;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.dto.activity.ShareDiscountActivityDto
;
import
cn.freemud.entities.dto.order.*
;
...
...
@@ -46,6 +47,7 @@ import cn.freemud.utils.*;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerWxappConfig
;
import
com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo
;
import
com.freemud.api.assortment.datamanager.enums.IappIdType
;
...
...
@@ -53,12 +55,16 @@ import com.freemud.api.assortment.datamanager.manager.cache.CacheOpenPlatformPar
import
com.freemud.application.sdk.api.log.LogThreadLocal
;
import
com.freemud.application.sdk.api.ordercenter.entities.PayItem
;
import
com.freemud.application.sdk.api.ordercenter.enums.*
;
import
com.freemud.application.sdk.api.ordercenter.request.OrderConditionsReq
;
import
com.freemud.application.sdk.api.ordercenter.request.OrderExtInfoDto
;
import
com.freemud.application.sdk.api.ordercenter.request.OrderExtendedReq
;
import
com.freemud.application.sdk.api.ordercenter.request.create.OrderPayItemCreateReq
;
import
com.freemud.application.sdk.api.ordercenter.response.BaseDownLoadResponse
;
import
com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderInfoReqs
;
import
com.freemud.application.sdk.api.promotioncenter.dto.promotion.GoodsStockDTO
;
import
com.freemud.application.sdk.api.promotioncenter.request.promotion.ActivityUpdateStockRequest
;
import
com.freemud.application.sdk.api.storecenter.response.StoreResponse
;
import
com.freemud.sdk.api.assortment.order.adapter.OrderSdkAdapter
;
import
com.freemud.sdk.api.assortment.order.enums.*
;
import
com.freemud.sdk.api.assortment.order.request.order.*
;
import
com.freemud.sdk.api.assortment.order.request.payment.CombPayRequest
;
...
...
@@ -140,6 +146,9 @@ public class OrderAdapter {
@Autowired
private
RedisCache
redisCache
;
@Autowired
private
OrderSdkAdapter
orderSdkAdapter
;
/**
* @param createOrderVo
* @param shoppingCartGoodsDto
...
...
@@ -3778,4 +3787,157 @@ public class OrderAdapter {
activityUpdateStockRequest
.
setActivityList
(
CollectionUtils
.
isNotEmpty
(
activityList
)
?
activityList
:
null
);
return
activityUpdateStockRequest
;
}
public
OrderConditionsReq
convent2QueryOrdersDtoES
(
OrderConditionsReq
query
,
String
memberId
,
String
channelType
,
Integer
queryOrderStatus
)
{
OrderConditionsReq
queryOrdersDto
=
new
OrderConditionsReq
();
queryOrdersDto
.
setUserId
(
memberId
);
queryOrdersDto
.
setPartnerId
(
query
.
getPartnerId
());
queryOrdersDto
.
setPageSize
(
query
.
getPageSize
()
!=
null
?
query
.
getPageSize
()
:
10
);
queryOrdersDto
.
setPageNum
(
query
.
getPageNum
()
!=
null
?
query
.
getPageNum
()
:
1
);
queryOrdersDto
.
setStartTimestamp
(
query
.
getStartTimestamp
());
queryOrdersDto
.
setEndTimestamp
(
query
.
getEndTimestamp
());
List
<
Integer
>
orderClients
=
new
ArrayList
<>();
if
(
OrderChannelType
.
IWC
.
getCode
().
equals
(
channelType
))
{
orderClients
.
add
(
com
.
freemud
.
sdk
.
api
.
assortment
.
order
.
enums
.
OrderSourceType
.
MEAL
.
getClientType
());
//queryOrdersDto.setOrderClients(new String[]{"meals"});
}
else
if
(
OrderChannelType
.
SAASMALL
.
getCode
().
equals
(
channelType
))
{
orderClients
.
add
(
com
.
freemud
.
sdk
.
api
.
assortment
.
order
.
enums
.
OrderSourceType
.
SAASMALL
.
getClientType
());
//queryOrdersDto.setOrderClients(new String[]{"saasmall"});
}
else
if
(
OrderChannelType
.
APP
.
getCode
().
equals
(
channelType
)){
orderClients
.
add
(
com
.
freemud
.
sdk
.
api
.
assortment
.
order
.
enums
.
OrderSourceType
.
APP
.
getClientType
());
//queryOrdersDto.setOrderClients(new String[]{"app"});
}
else
{
orderClients
.
add
(
com
.
freemud
.
sdk
.
api
.
assortment
.
order
.
enums
.
OrderSourceType
.
SAAS
.
getClientType
());
//queryOrdersDto.setOrderClients(new String[]{"saas"});
}
queryOrdersDto
.
setOrderClients
(
orderClients
);
List
<
Integer
>
payStatus
=
Arrays
.
asList
(
PayStatus
.
HAVE_PAID
.
getCode
(),
PayStatus
.
HAVE_REFUND
.
getCode
(),
PayStatus
.
COMPLETE
.
getCode
());
queryOrdersDto
.
setPayStatuses
(
payStatus
);
//queryOrdersDto.setPayStatus((Integer[]) payStatus.toArray());
//TODO 查询退款的待确定
if
(
queryOrderStatus
!=
null
)
{
if
(
QueryOrderStatus
.
ALL_BILL
.
getCode
().
equals
(
queryOrderStatus
))
{
List
<
Integer
>
orderStatuses
=
new
ArrayList
<>();
Collections
.
addAll
(
orderStatuses
,
OrderStatus
.
getAllCodes
());
queryOrdersDto
.
setOrderStatuses
(
orderStatuses
);
//queryOrdersDto.setStatus(OrderStatus.getAllCodes());
}
if
(
QueryOrderStatus
.
TAKE_MEAL
.
getCode
().
equals
(
queryOrderStatus
))
{
Integer
[]
statuses
=
new
Integer
[]{
OrderStatus
.
TAKE_ORDER
.
getCode
(),
OrderStatus
.
RECEIPT
.
getCode
(),
OrderStatus
.
DISTRIBUTION
.
getCode
(),
OrderStatus
.
COMPLETE_MAKE
.
getCode
()};
List
<
Integer
>
orderStatuses
=
new
ArrayList
<>();
Collections
.
addAll
(
orderStatuses
,
statuses
);
queryOrdersDto
.
setOrderStatuses
(
orderStatuses
);
//queryOrdersDto.setStatus(statuses);
}
if
(
QueryOrderStatus
.
FINISH
.
getCode
().
equals
(
queryOrderStatus
))
{
List
<
Integer
>
orderStatuses
=
new
ArrayList
<>();
orderStatuses
.
add
(
OrderStatus
.
COMPLETE
.
getCode
());
queryOrdersDto
.
setOrderStatuses
(
orderStatuses
);
//queryOrdersDto.setStatus(new Integer[]{OrderStatus.COMPLETE.getCode()});
}
if
(
QueryOrderStatus
.
REFUND_BILL
.
getCode
().
equals
(
queryOrderStatus
))
{
// 不走es
/* Integer[] statuses = new Integer[]{RefundStatus.APPLY_REFUND.getCode(), RefundStatus.AGREE_REFUND.getCode(), RefundStatus.COMPLETE_REFUND.getCode()};
List<Integer> orderStatuses = new ArrayList<>();
Collections.addAll(orderStatuses, statuses);
queryOrdersDto.setAfterSalesStatus(orderStatuses);*/
//queryOrdersDto.setRefundStatus(statuses);
}
if
(
QueryOrderStatus
.
NO_PAY
.
getCode
().
equals
(
queryOrderStatus
))
{
List
<
Integer
>
payStatuses
=
new
ArrayList
<>();
payStatuses
.
add
(
PayStatus
.
NOT_PAY
.
getCode
());
queryOrdersDto
.
setPayStatuses
(
payStatuses
);
//queryOrdersDto.setPayStatus(new Integer[]{PayStatus.NOT_PAY.getCode()});
}
if
(
QueryOrderStatus
.
ORDER_CANCEL
.
getCode
().
equals
(
queryOrderStatus
))
{
List
<
Integer
>
orderStatuses
=
new
ArrayList
<>();
orderStatuses
.
add
(
OrderStatus
.
CALCEL
.
getCode
());
queryOrdersDto
.
setOrderStatuses
(
orderStatuses
);
//queryOrdersDto.setStatus(new Integer[]{OrderStatus.CALCEL.getCode()});
}
if
(
QueryOrderStatus
.
ORDER_CANCEL_MIXUE
.
getCode
().
equals
(
queryOrderStatus
))
{
List
<
Integer
>
orderStatuses
=
new
ArrayList
<>();
orderStatuses
.
add
(
OrderStatus
.
CALCEL
.
getCode
());
queryOrdersDto
.
setOrderStatuses
(
orderStatuses
);
//queryOrdersDto.setStatus(new Integer[]{OrderStatus.CALCEL.getCode()});
List
<
Integer
>
payStatuses
=
new
ArrayList
<>();
payStatuses
.
add
(
PayStatus
.
NOT_PAY
.
getCode
());
queryOrdersDto
.
setPayStatuses
(
payStatuses
);
//queryOrdersDto.setPayStatus(new Integer[]{PayStatus.NOT_PAY.getCode()});
}
}
// 兼容历史版本,如果传参是4 查询拆程4和5
List
<
Integer
>
orderTypes
=
new
ArrayList
<>();
if
(
queryOrderStatus
!=
null
)
{
if
(
Objects
.
equals
(
queryOrderStatus
,
OrderType
.
COLLECT_GOODS
.
getCode
()))
{
orderTypes
.
add
(
OrderType
.
COLLECT_GOODS
.
getCode
());
orderTypes
.
add
(
OrderType
.
EAT_IN
.
getCode
());
//queryOrdersDto.setType(new Integer[]{OrderType.COLLECT_GOODS.getCode(), OrderType.EAT_IN.getCode()});
}
else
{
orderTypes
.
add
(
queryOrderStatus
);
//queryOrdersDto.setType(new Integer[]{queryOrderStatus});
}
}
queryOrdersDto
.
setOrderTypes
(
orderTypes
);
if
(
OrderChannelType
.
IWC
.
getCode
().
equals
(
channelType
))
{
Integer
[]
statuses
=
new
Integer
[]{
OrderStatus
.
COMPLETE
.
getCode
(),
OrderStatus
.
CALCEL
.
getCode
(),
OrderStatus
.
WAIT_PAY
.
getCode
()};
List
<
Integer
>
orderStatuses
=
new
ArrayList
<>();
Collections
.
addAll
(
orderStatuses
,
statuses
);
queryOrdersDto
.
setOrderStatuses
(
orderStatuses
);
//queryOrdersDto.setStatus(orderStatuses);
Integer
[]
payWCStatus
=
new
Integer
[]{
PayStatus
.
NOT_PAY
.
getCode
(),
PayStatus
.
HAVE_PAID
.
getCode
(),
PayStatus
.
HAVE_REFUND
.
getCode
(),
PayStatus
.
COMPLETE
.
getCode
()};
List
<
Integer
>
payStatuses
=
new
ArrayList
<>();
Collections
.
addAll
(
payStatuses
,
payWCStatus
);
queryOrdersDto
.
setPayStatuses
(
payStatuses
);
//queryOrdersDto.setPayStatus(payWCStatus);
}
if
(
OrderChannelType
.
SAASMALL
.
getCode
().
equals
(
channelType
))
{
// Integer[] statuses = new Integer[]{OrderStatus.COMPLETE.getCode(), OrderStatus.CALCEL.getCode()};
// queryOrdersDto.setStatus(statuses);
// queryOrdersDto.setType(new Integer[]{});
}
//商品订单和卖券订单
queryOrdersDto
.
setBizTypes
(
Arrays
.
asList
(
1
,
6
));
return
queryOrdersDto
;
}
public
QueryOrdersResponse
conventEs2queryOrderResponse
(
BaseDownLoadResponse
<
List
<
OrderInfoReqs
>>
response
)
{
QueryOrdersResponse
queryOrdersResponse
=
new
QueryOrdersResponse
();
if
(
null
==
response
||
null
==
response
.
getResult
())
{
queryOrdersResponse
.
setErrcode
(
ResponseCodeConstant
.
RESPONSE_SUCCESS
);
queryOrdersResponse
.
setErrmsg
(
ResponseResultEnum
.
ORDER_DATA_NOT_EXIST
.
getMessage
());
return
queryOrdersResponse
;
}
List
<
OrderInfoReqs
>
result
=
response
.
getResult
();
QueryOrdersResponse
.
DataBean
dataBean
=
new
QueryOrdersResponse
.
DataBean
();
List
<
QueryOrdersResponse
.
DataBean
.
OrderBean
>
orders
=
new
ArrayList
<>();
if
(
null
!=
result
&&
result
.
size
()
>
0
)
{
for
(
OrderInfoReqs
reqs
:
result
)
{
QueryOrdersResponse
.
DataBean
.
OrderBean
data
=
orderSdkAdapter
.
convent2NEWOrderInfo
(
reqs
);
orders
.
add
(
data
);
}
}
dataBean
.
setOrders
(
orders
);
dataBean
.
setCount
(
response
.
getTotalNum
());
queryOrdersResponse
.
setData
(
dataBean
);
queryOrdersResponse
.
setErrcode
(
ResponseCodeConstant
.
RESPONSE_SUCCESS
);
return
queryOrdersResponse
;
}
}
order-application-service/src/main/java/cn/freemud/service/impl/OrderServiceImpl.java
View file @
8158e367
...
...
@@ -197,6 +197,10 @@ public class OrderServiceImpl implements Orderservice {
*/
@Value
(
"#{'${coco.partnerId}'.split(',')}"
)
private
List
<
String
>
cocoPartnerId
;
@Value
(
"${query.order.es:true}"
)
private
Boolean
queryOrderEs
;
@Autowired
private
AssortmentCloudPrinterManager
cloudPrinterManager
;
// @Autowired
...
...
@@ -772,8 +776,13 @@ public class OrderServiceImpl implements Orderservice {
return
ResponseUtil
.
error
(
ResponseResult
.
NOT_LOGIN
);
}
if
(
StringUtils
.
isBlank
(
queryOrderVo
.
getStartDate
()))
{
if
(
isQueryEs
(
queryOrderVo
.
getQueryOrderStatus
())
&&
queryOrderEs
){
queryOrderVo
.
setStartDate
(
DateUtil
.
convert2String
(
DateUtil
.
addMonths
(
new
Date
(),
-
3
),
"yyyy-MM-dd"
));
}
else
{
queryOrderVo
.
setStartDate
(
DateUtil
.
convert2String
(
DateUtil
.
addMonths
(
new
Date
(),
-
1
),
"yyyy-MM-dd"
));
}
}
if
(
StringUtils
.
isBlank
(
queryOrderVo
.
getEndDate
()))
{
queryOrderVo
.
setEndDate
(
DateUtil
.
convert2String
(
new
Date
(),
"yyyy-MM-dd"
));
}
...
...
@@ -796,9 +805,18 @@ public class OrderServiceImpl implements Orderservice {
if
(
endDate
==
null
)
{
return
ResponseUtil
.
error
(
ResponseResult
.
ORDER_QUERYORDER_ERROR
.
getCode
(),
"查询订单结束时间格式不正确"
);
}
if
(
isQueryEs
(
queryOrderVo
.
getQueryOrderStatus
())
&&
queryOrderEs
){
Date
startDateEs
=
DateUtil
.
convert2Date
(
startDateStr
,
"yyyy-MM-dd"
);
Date
endDateEs
=
DateUtil
.
convert2Date
(
new
Date
(),
"yyyy-MM-dd"
);
if
(
startDateEs
.
getTime
()
<
DateUtil
.
addMonths
(
endDateEs
,
-
3
).
getTime
())
{
return
ResponseUtil
.
error
(
ResponseResult
.
ORDER_QUERYORDER_ERROR
.
getCode
(),
"只能查询3个月内的订单信息"
);
}
}
else
{
if
(
startDate
.
getTime
()
<
DateUtil
.
addMonths
(
new
Date
(),
-
3
).
getTime
())
{
return
ResponseUtil
.
error
(
ResponseResult
.
ORDER_QUERYORDER_ERROR
.
getCode
(),
"只能查询3个月内的订单信息"
);
}
}
String
userId
=
userLoginInfoDto
.
getMemberId
();
QueryOrderDto
queryOrderDto
=
BeanUtil
.
convertBean
(
queryOrderVo
,
QueryOrderDto:
:
new
);
queryOrderDto
.
setPartnerId
(
queryOrderVo
.
getPartnerId
());
...
...
@@ -811,7 +829,24 @@ public class OrderServiceImpl implements Orderservice {
QueryOrdersRequest
queryOrdersRequest2
=
new
QueryOrdersRequest
();
BeanUtil
.
convertBean
(
queryOrdersDto
,
queryOrdersRequest2
);
queryOrdersRequest2
.
setTrackingNo
(
LogTreadLocal
.
getTrackingNo
());
// 订单要查3个月的,如果查询的订单状态是待取餐、未支付,则查实时,否则,查es
if
(
isQueryEs
(
queryOrderVo
.
getQueryOrderStatus
())
&&
queryOrderEs
){
OrderConditionsReq
es
=
new
OrderConditionsReq
();
es
.
setPartnerId
(
queryOrderVo
.
getPartnerId
());
es
.
setUserId
(
userId
);
es
.
setStartTimestamp
(
DateTimeUtil
.
parseDate
(
startDateStr
,
DateTimeUtil
.
YYYY_MM_DD_HH_MM_SS
).
getTime
()/
1000
);
es
.
setEndTimestamp
(
DateTimeUtil
.
parseDate
(
endDateStr
,
DateTimeUtil
.
YYYY_MM_DD_HH_MM_SS
).
getTime
()/
1000
);
es
.
setPageNum
(
queryOrderVo
.
getPageNumber
());
es
.
setPageSize
(
queryOrderVo
.
getPageSize
());
OrderConditionsReq
queryEs
=
orderAdapter
.
convent2QueryOrdersDtoES
(
es
,
userId
,
channelType
,
queryOrderVo
.
getQueryOrderStatus
());
BaseDownLoadResponse
<
List
<
OrderInfoReqs
>>
response
=
orderDownLoadSdkService
.
queryOrderByConditions
(
queryEs
,
LogThreadLocal
.
getTrackingNo
());
queryOrderResponse
=
orderAdapter
.
conventEs2queryOrderResponse
(
response
);
}
else
{
queryOrderResponse
=
orderCenterSdkService
.
queryOrders
(
queryOrdersRequest2
);
}
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
"queryOrders_error"
,
gson
.
toJson
(
queryOrdersDto
),
e
);
return
ResponseUtil
.
error
(
ResponseResult
.
ORDER_QUERYORDER_ERROR
);
...
...
@@ -1385,7 +1420,21 @@ public class OrderServiceImpl implements Orderservice {
BaseQueryOrderRequest
baseQueryOrderRequest
=
new
BaseQueryOrderRequest
();
baseQueryOrderRequest
.
setOrderId
(
oid
);
baseQueryOrderRequest
.
setTrackingNo
(
LogTreadLocal
.
getTrackingNo
());
// 订单详情要查询3个月前的订单
// 先实时查询如果没有查询es
QueryOrderByIdResponse
response
=
orderCenterSdkService
.
queryOrderById
(
baseQueryOrderRequest
);
if
(!
RESPONSE_SUCCESS_CODE
.
equals
(
response
.
getErrcode
())){
ApiLog
.
info
(
"订单详情实时查询错误,baseQueryOrderRequest,"
,
baseQueryOrderRequest
,
""
);
return
ResponseUtil
.
error
(
ResponseResult
.
ORDER_QUERYORDER_ERROR
);
}
if
(
response
.
getData
()
==
null
&&
queryOrderEs
){
// 查询es
response
=
orderCenterSdkService
.
queryOrderByCodeES
(
partnerId
,
oid
,
LogThreadLocal
.
getTrackingNo
());
ApiLog
.
info
(
"订单详情实时查询没有数据,es查询,partnerId,oid"
,
partnerId
,
oid
);
}
if
(!
RESPONSE_SUCCESS_CODE
.
equals
(
response
.
getErrcode
())
||
response
.
getData
()
==
null
)
{
return
ResponseUtil
.
error
(
ResponseResult
.
ORDER_QUERYORDER_ERROR
);
}
...
...
@@ -3788,4 +3837,14 @@ public class OrderServiceImpl implements Orderservice {
}
}
private
Boolean
isQueryEs
(
Integer
queryOrderStatus
)
{
if
(
ObjectUtils
.
equals
(
QueryOrderStatus
.
TAKE_MEAL
.
getCode
(),
queryOrderStatus
)
||
ObjectUtils
.
equals
(
QueryOrderStatus
.
NO_PAY
.
getCode
(),
queryOrderStatus
)
||
ObjectUtils
.
equals
(
QueryOrderStatus
.
REFUND_BILL
.
getCode
(),
queryOrderStatus
)){
return
Boolean
.
FALSE
;
}
return
Boolean
.
TRUE
;
}
}
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