优化禁止退货的方法
This commit is contained in:
parent
66498ff82d
commit
2471d2b4c2
@ -2099,49 +2099,29 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
* @return boolean true表示禁止退货,false表示允许退货
|
* @return boolean true表示禁止退货,false表示允许退货
|
||||||
*/
|
*/
|
||||||
public boolean ifDenyReturn(ShopOrderInfo shopOrderInfo, ShopOrderItem shopOrderItem, ShopProductIndex shopProductIndex) {
|
public boolean ifDenyReturn(ShopOrderInfo shopOrderInfo, ShopOrderItem shopOrderItem, ShopProductIndex shopProductIndex) {
|
||||||
// 参数校验
|
// 1. 参数校验
|
||||||
if (shopOrderItem == null) {
|
if (shopOrderItem == null) {
|
||||||
log.warn("订单商品数据为空");
|
log.warn("[是否禁止退货] 订单商品数据为空");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shopOrderInfo == null) {
|
if (shopOrderInfo == null) {
|
||||||
log.warn("订单信息为空");
|
log.warn("[是否禁止退货] 订单信息为空");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取商品索引信息
|
|
||||||
ShopProductIndex productIndex = shopProductIndex;
|
|
||||||
if (productIndex == null) {
|
|
||||||
productIndex = shopProductIndexService.get(shopOrderItem.getProduct_id());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (productIndex == null) {
|
|
||||||
log.warn("商品索引信息不存在,product_id: {}", shopOrderItem.getProduct_id());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String orderId = shopOrderInfo.getOrder_id();
|
String orderId = shopOrderInfo.getOrder_id();
|
||||||
|
Integer orderStateId = shopOrderInfo.getOrder_state_id();
|
||||||
// 1. 检查商品是否设置了禁止退货标识
|
if (StrUtil.isBlank(orderId) || CheckUtil.isEmpty(orderStateId)) {
|
||||||
String contractTypeIdsStr = productIndex.getContract_type_ids();
|
log.warn("[是否禁止退货] 订单ID或订单状态为空");
|
||||||
if (StrUtil.isNotBlank(contractTypeIdsStr)) {
|
|
||||||
try {
|
|
||||||
List<Integer> contractTypeIds = Convert.toList(Integer.class, contractTypeIdsStr);
|
|
||||||
if (contractTypeIds != null && contractTypeIds.contains(StateCode.CONTRACT_TYPE_DENY_RETURN)) {
|
|
||||||
log.debug("商品设置了禁止退货标识,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("解析商品保障类型失败,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 检查订单状态是否为已收货或已完成
|
// 2. 先判断整个订单是否可以退货(订单级别检查)
|
||||||
Integer orderStateId = shopOrderInfo.getOrder_state_id();
|
// 2.1 检查订单状态是否为已收货或已完成
|
||||||
if (ObjectUtil.equal(orderStateId, StateCode.ORDER_STATE_RECEIVED) ||
|
|
||||||
ObjectUtil.equal(orderStateId, StateCode.ORDER_STATE_FINISH)) {
|
|
||||||
|
|
||||||
|
if (orderStateId.intValue() == StateCode.ORDER_STATE_RECEIVED ||
|
||||||
|
orderStateId.intValue() == StateCode.ORDER_STATE_FINISH) {
|
||||||
try {
|
try {
|
||||||
// 获取可提现时间戳
|
// 获取可提现时间戳
|
||||||
Long withdrawTime = shopOrderBaseService.getWithdrawTime();
|
Long withdrawTime = shopOrderBaseService.getWithdrawTime();
|
||||||
@ -2149,33 +2129,60 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
|
|
||||||
// 检查是否超过退货期限
|
// 检查是否超过退货期限
|
||||||
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
||||||
log.debug("订单已超过退货期限,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id());
|
log.debug("[是否禁止退货] 订单已超过退货期限,order_id: {}", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("检查订单退货期限时发生异常,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id(), e);
|
log.error("[是否禁止退货] 检查订单退货期限时发生异常,order_id: {}", orderId, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检查拉卡拉分账订单是否已提现
|
// 2.2 检查拉卡拉分账订单是否已提现
|
||||||
try {
|
try {
|
||||||
if (lklOrderSeparateService != null && lklOrderDrawService != null) {
|
if (lklOrderSeparateService != null && lklOrderDrawService != null) {
|
||||||
boolean isSeparated = lklOrderSeparateService.isOrderSeparated(orderId);
|
boolean isSeparated = lklOrderSeparateService.isOrderSeparated(orderId);
|
||||||
boolean isDrawn = lklOrderDrawService.isOrderDrawed(orderId);
|
boolean isDrawn = lklOrderDrawService.isOrderDrawed(orderId);
|
||||||
|
|
||||||
if (isSeparated && isDrawn) {
|
if (isSeparated && isDrawn) {
|
||||||
log.debug("拉卡拉分账订单已提现,不允许退货,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id());
|
log.debug("[是否禁止退货] 拉卡拉分账订单已提现,不允许退货,order_id: {}", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("检查拉卡拉分账状态时发生异常,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id(), e);
|
log.error("[是否禁止退货] 检查拉卡拉分账状态时发生异常,order_id: {}", orderId, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 再判断具体商品是否可以退货(商品级别检查)
|
||||||
|
// 获取商品索引信息
|
||||||
|
ShopProductIndex productIndex = shopProductIndex;
|
||||||
|
if (productIndex == null) {
|
||||||
|
productIndex = shopProductIndexService.get(shopOrderItem.getProduct_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (productIndex == null) {
|
||||||
|
log.warn("[是否禁止退货] 商品索引信息不存在,product_id: {}", shopOrderItem.getProduct_id());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.1 检查商品是否设置了禁止退货标识
|
||||||
|
String contractTypeIdsStr = productIndex.getContract_type_ids();
|
||||||
|
if (StrUtil.isNotBlank(contractTypeIdsStr)) {
|
||||||
|
try {
|
||||||
|
List<Integer> contractTypeIds = Convert.toList(Integer.class, contractTypeIdsStr);
|
||||||
|
if (contractTypeIds != null && contractTypeIds.contains(StateCode.CONTRACT_TYPE_DENY_RETURN)) {
|
||||||
|
log.debug("[是否禁止退货] 商品设置了禁止退货标识,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[是否禁止退货] 解析商品保障类型失败,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 默认允许退货
|
// 默认允许退货
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断订单中某个商品是否禁止退货
|
* 判断订单中某个商品是否禁止退货
|
||||||
* <p>
|
* <p>
|
||||||
@ -2207,7 +2214,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
public boolean isOrderDenyReturn(String orderId) {
|
public boolean isOrderDenyReturn(String orderId) {
|
||||||
// 参数校验
|
// 参数校验
|
||||||
if (StrUtil.isBlank(orderId)) {
|
if (StrUtil.isBlank(orderId)) {
|
||||||
log.warn("订单ID为空,无法判断退货状态");
|
log.warn("[订单是否禁止退货]订单ID为空,无法判断退货状态");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2215,7 +2222,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
// 获取订单信息
|
// 获取订单信息
|
||||||
ShopOrderInfo shopOrderInfo = shopOrderInfoService.get(orderId);
|
ShopOrderInfo shopOrderInfo = shopOrderInfoService.get(orderId);
|
||||||
if (shopOrderInfo == null) {
|
if (shopOrderInfo == null) {
|
||||||
log.error("订单信息不存在,订单ID: {}", orderId);
|
log.error("[订单是否禁止退货]订单信息不存在,订单ID: {}", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2230,7 +2237,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
|
|
||||||
// 如果订单成交时间早于可提现时间,说明已过退货期
|
// 如果订单成交时间早于可提现时间,说明已过退货期
|
||||||
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
||||||
log.debug("订单[{}]已过退货期,不允许退货", orderId);
|
log.debug("[订单是否禁止退货]订单[{}]已过退货期,不允许退货", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2238,7 +2245,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
// 检查拉卡拉分账和提现状态
|
// 检查拉卡拉分账和提现状态
|
||||||
if (lklOrderSeparateService.isOrderSeparated(orderId) &&
|
if (lklOrderSeparateService.isOrderSeparated(orderId) &&
|
||||||
lklOrderDrawService.isOrderDrawed(orderId)) {
|
lklOrderDrawService.isOrderDrawed(orderId)) {
|
||||||
log.debug("订单[{}]已提现,不允许退货", orderId);
|
log.debug("[订单是否禁止退货]订单[{}]已提现,不允许退货", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2246,7 +2253,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("查询订单[{}]退货状态异常", orderId, e);
|
log.error("[订单是否禁止退货]查询订单[{}]退货状态异常", orderId, e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user