Commit 8158e367 by 刘鹏飞

订单、订单详情查询使用es

parent e8ac2bb5
......@@ -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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment