Commit 9e1d9004 by 周晓航

开发 售后单推迟

Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent d0634eb0
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);
}
......@@ -59,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.*;
......@@ -75,6 +76,7 @@ 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;
......@@ -123,6 +125,13 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
@Autowired
private OfflineCouponSdkService offlineCouponSdkService;
/**
* 规避 发版时间配置的双虎
*/
@Value("${avoid.version.upgrade.config:}")
private String avoidVersionUpgradeConfig;
@Override
public CreateOrderResponse createOrderFlow(CreateOrderRequest config) {
com.freemud.application.sdk.api.ordercenter.request.create.CreateOrderRequest request = orderSdkAdapter.convent2NEWCreateOrderRequest(config.getBaseCreateOrderRequest());
......@@ -543,7 +552,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);
......@@ -556,12 +565,23 @@ 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小时之后
if((configuration.getTimeTypeOfRefund() != null && configuration.getTimeTypeOfRefund().compareTo(2) == 0 ) || configuration.getTimeTypeOfRefund() == null){// 48小时之后
orderTask = new OrderTaskReq();
orderTask.setTaskType(4);
orderTask.setTimeout(1);
......@@ -573,7 +593,7 @@ 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));
}else if(configuration.getTimeTypeOfRefund() != null && 1 == configuration.getTimeTypeOfRefund().intValue()){// 指定时间
}else if(configuration.getTimeTypeOfRefund() != null && configuration.getTimeTypeOfRefund().compareTo(1) == 0 ){// 指定时间
orderTask = new OrderTaskReq();
orderTask.setTaskType(4);
orderTask.setTimeout(1);
......@@ -600,7 +620,7 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
// fisherman [KA-20210702] 规避版本升级
if (orderTask != null) {
avoidVersionUpgrade(orderTask);
avoidVersionUpgrade(orderTask,partnerId);
}
return null;
}
......@@ -612,8 +632,56 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
* 2.校验 apollo配置商户
* @param orderTask
*/
private void avoidVersionUpgrade(OrderTaskReq orderTask) {
private void avoidVersionUpgrade(OrderTaskReq orderTask, String partnerId) {
ApiLog.info("fisherman 发版时间 设置");
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 (CommonConstant.weekDay.contains(w)) {
// 校验时间 是否是 23:00 之后
int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
if (hourOfDay >= 23){
// 表示 设置时间为23点之后
return true;
}
}
return false;
}
/**
......@@ -752,7 +820,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());
......
......@@ -29,9 +29,7 @@ import cn.freemud.utils.ResponseUtil;
import cn.freemud.xxljob.OrderCountJobHandler;
import com.freemud.application.sdk.api.log.ApiAnnotation;
import com.freemud.application.sdk.api.log.LogParams;
import com.freemud.application.sdk.api.ordercenter.request.OrderCountReqs;
import com.freemud.application.sdk.api.ordercenter.response.OrderCountResp;
import com.freemud.application.sdk.api.ordercenter.service.OrderSdkService;
import com.freemud.sdk.api.assortment.order.service.order.OrderCenterSdkServiceImpl;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -411,5 +409,13 @@ public class OrderController {
orderReportJobHandler.sendYesterDayStoreMsg();
return ResponseUtil.success();
}
@Autowired
OrderCenterSdkServiceImpl orderCenterSdkService;
@GetMapping("/test")
public BaseResponse test() {
orderCenterSdkService.setAfterSalesOrderTimeOutTask(null,null);
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