Commit 29710b8d by 周晓航

Merge branch 'KA-20210702-非码发版日售后单时间推迟-周晓航'

parents 9cfd5745 b381413d
package com.freemud.sdk.api.assortment.order.constant;
import java.util.Arrays;
import java.util.List;
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2021/7/5 下午4:17
* @description :
*/
public class CommonConstant {
/**
* 2:星期二
* 4:星期四
*/
public static List<Integer> weekDay = Arrays.asList(2, 4);
}
......@@ -33,7 +33,6 @@ import com.freemud.application.sdk.api.ordercenter.enums.*;
import com.freemud.application.sdk.api.ordercenter.request.*;
import com.freemud.application.sdk.api.ordercenter.request.create.*;
import com.freemud.application.sdk.api.ordercenter.response.*;
import com.freemud.application.sdk.api.ordercenter.response.AfterSalesListResp;
import com.freemud.application.sdk.api.ordercenter.response.orderInfo.AfterSalesOrderResp;
import com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderInfoReqs;
import com.freemud.application.sdk.api.ordercenter.response.orderInfo.QueryByCodeResponse;
......@@ -60,6 +59,7 @@ import com.freemud.application.sdk.api.structure.MessageCenterType;
import com.freemud.application.sdk.api.structure.request.PushMessageNoticeDto;
import com.freemud.application.sdk.api.structure.service.MessageCenterClient;
import com.freemud.sdk.api.assortment.order.adapter.*;
import com.freemud.sdk.api.assortment.order.constant.CommonConstant;
import com.freemud.sdk.api.assortment.order.domain.ResponseCodeConstant;
import com.freemud.sdk.api.assortment.order.entities.OrderEditInfo;
import com.freemud.sdk.api.assortment.order.enums.*;
......@@ -77,8 +77,10 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
......@@ -124,6 +126,15 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
@Autowired
private OfflineCouponSdkService offlineCouponSdkService;
/**
* 规避 发版时间配置的双虎
*/
@Value("${avoid.version.upgrade.config:}")
private String avoidVersionUpgradeConfig;
@Value("${version.upgrade.weekDay:}")
private List<Integer> weekDay;
@Override
public CreateOrderResponse createOrderFlow(CreateOrderRequest config) {
com.freemud.application.sdk.api.ordercenter.request.create.CreateOrderRequest request = orderSdkAdapter.convent2NEWCreateOrderRequest(config.getBaseCreateOrderRequest());
......@@ -544,7 +555,7 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
&& !ObjectUtils.equals("0", configuration.getAutoChargebackOrderTime())) {
request.setTimeOut(AutoOrderConfigTime.getTime(configuration.getAutoChargebackOrderTime()));
}
OrderTaskReq orderTask = setAfterSalesOrderTimeOutTask(configuration);
OrderTaskReq orderTask = setAfterSalesOrderTimeOutTask(configuration,orderRefundRequest.getPartnerId());
request.setOrderTask(orderTask);
com.freemud.application.sdk.api.ordercenter.response.BaseResponse response = orderSdkService.createAfterSalesOrder(request, orderRefundRequest.getTrackingNo());
return orderSdkAdapter.convent2BaseOrderResponse(response);
......@@ -557,13 +568,24 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
* 为了防止同一时刻的退款量太大,需要将退款的订单分散到指定的时间后半小时内
*/
private OrderTaskReq setAfterSalesOrderTimeOutTask(StoreResponse.Configuration configuration) {
OrderTaskReq orderTaskReq = setAfterSalesOrderTimeOutTask(configuration, null);
return orderTaskReq;
}
/**
* 设置申请退款时间
* 如果时间的类型是2表示采用原来的48小时逻辑
* 如果时间的类型是1表示在指定的时间之后进行退款
* 为了防止同一时刻的退款量太大,需要将退款的订单分散到指定的时间后半小时内
*/
public OrderTaskReq setAfterSalesOrderTimeOutTask(StoreResponse.Configuration configuration, String partnerId) {
if(configuration == null ){
return null;
}
OrderTaskReq orderTask;
if((configuration.getTimeTypeOfRefund() != null && 2 == configuration.getTimeTypeOfRefund().intValue()) || configuration.getTimeTypeOfRefund() == null){// 48小时之后
OrderTaskReq orderTask = new OrderTaskReq();
if((configuration.getTimeTypeOfRefund() != null && configuration.getTimeTypeOfRefund().compareTo(2) == 0 ) || configuration.getTimeTypeOfRefund() == null){// 48小时之后
orderTask = new OrderTaskReq();
orderTask.setTaskType(4);
orderTask.setTimeout(1);
//1000*60*60*24*2 毫秒(48小时)
......@@ -574,10 +596,8 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
orderTask.setTaskTime(DateUtil.convert2String(taskTime, DateUtil.FORMAT_YYYY_MM_DD_HHMMSS));
//处理时间,当前时间加48小时减1分钟
orderTask.setProcessingTime(DateUtil.convert2String(processingDate, DateUtil.FORMAT_YYYY_MM_DD_HHMMSS));
return orderTask;
}else if(configuration.getTimeTypeOfRefund() != null && 1 == configuration.getTimeTypeOfRefund().intValue()){// 指定时间
OrderTaskReq orderTask = new OrderTaskReq();
}else if(configuration.getTimeTypeOfRefund() != null && configuration.getTimeTypeOfRefund().compareTo(1) == 0 ){// 指定时间
orderTask = new OrderTaskReq();
orderTask.setTaskType(4);
orderTask.setTimeout(1);
// 获取门店配置的当天指定的退款时间
......@@ -597,10 +617,84 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
String processingStr = DateUtil.convert2String(processingDate, DateUtil.FORMAT_YYYY_MM_DD_HHMMSS);
orderTask.setTaskTime(processingStr);
orderTask.setProcessingTime(processingStr);
} else {
orderTask = null;
}
return orderTask;
// fisherman [KA-20210702] 规避版本升级
if (orderTask != null) {
avoidVersionUpgrade(orderTask,partnerId);
}
return null;
return orderTask;
}
/**
* fisherman 规避版本升级
* 周二周四晚 23:00开始发版, 服务器会存在宕机, 延迟定时器处理时间
* 1.校验时间
* 2.校验 apollo配置商户
* @param orderTask
*/
private void avoidVersionUpgrade(OrderTaskReq orderTask, String partnerId) {
if (Objects.isNull(partnerId)) {
return;
}
// 时间校验
boolean checkResult = checkDate(orderTask);
if (checkResult && StringUtils.isNotBlank(avoidVersionUpgradeConfig)) {
// 读取 是否商户配置
Map<String,Integer> map = JSON.parseObject(avoidVersionUpgradeConfig, Map.class);
if (map.containsKey(partnerId)) {
Integer addHours = map.get(partnerId);
// 增加 时间
String processingTime = orderTask.getProcessingTime();
Date datet = DateUtil.convert2Date(processingTime, DateUtil.FORMAT_YYYY_MM_DD_HHMMSS);
Date date = DateUtil.addHours(datet, addHours);
String resultTime = DateUtil.convert2String(date, DateUtil.FORMAT_YYYY_MM_DD_HHMMSS);
orderTask.setProcessingTime(resultTime);
// 显示时间一起设置
processingTime = orderTask.getProcessingTime();
datet = DateUtil.convert2Date(processingTime, DateUtil.FORMAT_YYYY_MM_DD_HHMMSS);
date = DateUtil.addHours(datet, addHours);
resultTime = DateUtil.convert2String(date, DateUtil.FORMAT_YYYY_MM_DD_HHMMSS);
orderTask.setTaskTime(resultTime);
}
}
}
private boolean checkDate(OrderTaskReq orderTask) {
// 校验 是否 周二 周四
String processingTime = orderTask.getProcessingTime();
Calendar cal = Calendar.getInstance();
Date datet = DateUtil.convert2Date(processingTime, DateUtil.FORMAT_YYYY_MM_DD_HHMMSS);
if (datet == null) {
return false;
}
cal.setTime(datet);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
// 增加一个发版开关
if (CollectionUtils.isNotEmpty(weekDay) && weekDay.size()>0) {
if (weekDay.contains(w)) {
// 校验时间 是否是 23:00 之后
int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
if (hourOfDay >= 23){
// 表示 设置时间为23点之后
return true;
}
}
}else {
if (CommonConstant.weekDay.contains(w)) {
// 校验时间 是否是 23:00 之后
int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
if (hourOfDay >= 23){
// 表示 设置时间为23点之后
return true;
}
}
}
return false;
}
/**
......@@ -739,7 +833,7 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
&& !ObjectUtils.equals("0", configuration.getAutoChargebackOrderTime())) {
request.setTimeOut(AutoOrderConfigTime.getTime(configuration.getAutoChargebackOrderTime()));
}
OrderTaskReq orderTask = setAfterSalesOrderTimeOutTask(configuration);
OrderTaskReq orderTask = setAfterSalesOrderTimeOutTask(configuration,cancelOrderRequest.getPartnerId());
request.setOrderTask(orderTask);
}
request.setRefundDeliveryAmount(cancelOrderRequest.isRefundDeliveryAmount());
......
......@@ -410,5 +410,6 @@ public class OrderController {
orderReportJobHandler.sendYesterDayStoreMsg();
return ResponseUtil.success();
}
}
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