砍价下单验证是否达标,不达标不允许下单购买
This commit is contained in:
parent
2af8bc966a
commit
3d31e4cd74
@ -171,7 +171,7 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
|
||||
* @param productId 商品ID
|
||||
* @return boolean true表示禁止退货,false表示允许退货
|
||||
*/
|
||||
boolean ifOrderItemDenyReturn(String orderId, Long productId);
|
||||
boolean isOrderItemDenyReturn(String orderId, Long productId);
|
||||
|
||||
/**
|
||||
* 判断订单是否禁止退货
|
||||
|
||||
@ -9070,13 +9070,22 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
order.setOrder_pickup_num_str(StringUtils.fmtPickNum(order.getOrder_pickup_num()));
|
||||
|
||||
// 订单是否禁止退款
|
||||
int isOrderDenyReturn = shopOrderReturnService.isOrderDenyReturn(order.getOrder_id()) ? 1 : 2;
|
||||
order.setIs_deny_return(isOrderDenyReturn);
|
||||
boolean isOrderDenyReturn = shopOrderReturnService.isOrderDenyReturn(order.getOrder_id());
|
||||
order.setIs_deny_return(isOrderDenyReturn ? CommonConstant.Enable : CommonConstant.Disable2);
|
||||
|
||||
// 订单商品列表是否禁止退款
|
||||
order.getOrder_items().forEach(item -> {
|
||||
item.setIs_deny_return(isOrderDenyReturn);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(order.getOrder_items())) {
|
||||
if (!isOrderDenyReturn) { // 允许退款的订单,再进一步检查每个商品是否不能退款
|
||||
// 订单商品列表是否禁止退款
|
||||
order.getOrder_items().forEach(item -> {
|
||||
// 注意:应该使用 order_item_id 而不是 product_id
|
||||
boolean isOrderItemDenyReturn = shopOrderReturnService.isOrderItemDenyReturn(order.getOrder_id(), item.getProduct_id());
|
||||
item.setIs_deny_return(isOrderItemDenyReturn ? CommonConstant.Enable : CommonConstant.Disable2);
|
||||
});
|
||||
} else {
|
||||
// 如果整个订单都禁止退款,则所有商品都禁止退款
|
||||
order.getOrder_items().forEach(item -> item.setIs_deny_return(CommonConstant.Enable));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@ -9177,13 +9186,22 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
orderDetail.setOrder_pickup_num_str(StringUtils.fmtPickNum(orderDetail.getOrder_pickup_num()));
|
||||
|
||||
// 订单是否禁止退款
|
||||
int isOrderDenyReturn = shopOrderReturnService.isOrderDenyReturn(orderId) ? 1 : 2;
|
||||
orderDetail.setIs_deny_return(isOrderDenyReturn);
|
||||
boolean isOrderDenyReturn = shopOrderReturnService.isOrderDenyReturn(orderId);
|
||||
orderDetail.setIs_deny_return(isOrderDenyReturn ? CommonConstant.Enable : CommonConstant.Disable2);
|
||||
|
||||
// 订单商品列表是否禁止退款
|
||||
orderDetail.getOrder_items().forEach(item -> {
|
||||
item.setIs_deny_return(isOrderDenyReturn);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(orderDetail.getOrder_items())) {
|
||||
if (!isOrderDenyReturn) { // 允许退款的订单,再进一步检查每个商品是否不能退款
|
||||
// 订单商品列表是否禁止退款
|
||||
orderDetail.getOrder_items().forEach(item -> {
|
||||
// 注意:应该使用 order_item_id 而不是 product_id
|
||||
boolean isOrderItemDenyReturn = shopOrderReturnService.isOrderItemDenyReturn(orderId, item.getProduct_id());
|
||||
item.setIs_deny_return(isOrderItemDenyReturn ? CommonConstant.Enable : CommonConstant.Disable2);
|
||||
});
|
||||
} else {
|
||||
// 如果整个订单都禁止退款,则所有商品都禁止退款
|
||||
orderDetail.getOrder_items().forEach(item -> item.setIs_deny_return(CommonConstant.Enable));
|
||||
}
|
||||
}
|
||||
|
||||
return orderDetail;
|
||||
}
|
||||
|
||||
@ -1512,7 +1512,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
if (lestFrozenQuantity.compareTo(0) < 0) {
|
||||
lestFrozenQuantity = 0;
|
||||
}
|
||||
ShopProductItem upadteShopProductItem=new ShopProductItem();
|
||||
ShopProductItem upadteShopProductItem = new ShopProductItem();
|
||||
upadteShopProductItem.setItem_id(shopOrderItem.getItem_id());
|
||||
upadteShopProductItem.setItem_quantity(productItem.getItem_quantity() + returnNum);
|
||||
upadteShopProductItem.setItem_quantity_frozen(lestFrozenQuantity);
|
||||
@ -2112,32 +2112,27 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
* 如果订单状态为"已收货"或"已完成",并且当前时间超过允许提现时间,则标记为不可退货。
|
||||
*
|
||||
* @param shopOrderInfo 订单信息
|
||||
* @param shopOrderItem 订单商品项
|
||||
* @param shopProductIndex 商品索引信息
|
||||
* @param shopOrderItem 订单商品项(可选)
|
||||
* @param shopProductIndex 商品索引信息(可选,如果shopOrderItem存在则可以为空)
|
||||
* @return boolean true表示禁止退货,false表示允许退货
|
||||
*/
|
||||
public boolean ifDenyReturn(ShopOrderInfo shopOrderInfo, ShopOrderItem shopOrderItem, ShopProductIndex shopProductIndex) {
|
||||
// 1. 参数校验
|
||||
if (shopOrderItem == null) {
|
||||
log.debug("[是否禁止退货] 订单商品数据为空,不允许退货");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (shopOrderInfo == null) {
|
||||
log.debug("[是否禁止退货] 订单信息为空,不允许退货");
|
||||
log.debug("[是否禁止退货] 订单信息为空,禁止退货");
|
||||
return true;
|
||||
}
|
||||
|
||||
String orderId = shopOrderInfo.getOrder_id();
|
||||
Integer orderStateId = shopOrderInfo.getOrder_state_id();
|
||||
if (StrUtil.isBlank(orderId) || CheckUtil.isEmpty(orderStateId)) {
|
||||
log.debug("[是否禁止退货] 订单ID或订单状态为空,不允许退货");
|
||||
log.debug("[是否禁止退货] 订单ID或订单状态为空,禁止退货");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (orderStateId.intValue() == StateCode.ORDER_STATE_CANCEL ||
|
||||
orderStateId.intValue() == StateCode.ORDER_STATE_WAIT_PAY) {
|
||||
log.debug("[是否禁止退货] 订单已取消或未支付,不允许退货 order_id: {}", orderId);
|
||||
log.debug("[是否禁止退货] 订单状态为已取消或未支付,禁止退货,order_id: {}, orderStateId: {}", orderId, orderStateId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2152,11 +2147,13 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
|
||||
// 检查是否超过退货期限
|
||||
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
||||
log.debug("[是否禁止退货] 订单已超过退货期限,不允许退货,order_id: {}", orderId);
|
||||
log.debug("[是否禁止退货] 订单已超过退货期限,禁止退货,order_id: {}, orderDealTime: {}, withdrawTime: {}",
|
||||
orderId, orderDealTime, withdrawTime);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[是否禁止退货] 检查订单退货期限时发生异常,不允许退货,order_id: {}", orderId, e);
|
||||
log.error("[是否禁止退货] 检查订单退货期限时发生异常,禁止退货,order_id: {}", orderId, e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2165,32 +2162,40 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
if (lklOrderSeparateService != null && lklOrderDrawService != null) {
|
||||
boolean isSeparated = lklOrderSeparateService.isOrderSeparated(orderId);
|
||||
boolean isDrawn = lklOrderDrawService.isOrderDrawed(orderId);
|
||||
boolean isLklProcessed = isSeparated && isDrawn;
|
||||
|
||||
if (isSeparated && isDrawn) {
|
||||
log.debug("[是否禁止退货] 拉卡拉分账订单已提现,不允许退货,order_id: {}", orderId);
|
||||
if (isLklProcessed) {
|
||||
log.debug("[是否禁止退货] 拉卡拉分账订单已提现,禁止退货,order_id: {}, separated: {}, drawed: {}",
|
||||
orderId, isSeparated, isDrawn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[是否禁止退货] 检查拉卡拉分账状态时发生异常,不允许退货,order_id: {}", orderId, e);
|
||||
log.error("[是否禁止退货] 检查拉卡拉分账状态时发生异常,禁止退货,order_id: {}", orderId, e);
|
||||
return true;
|
||||
}
|
||||
|
||||
Long productId = shopOrderItem.getProduct_id();
|
||||
if (CheckUtil.isEmpty(productId)) {
|
||||
log.debug("[是否禁止退货] 商品ID为空,不允许退货");
|
||||
return true;
|
||||
// 如果没有商品相关信息,则只检查订单级别
|
||||
if (shopOrderItem == null && shopProductIndex == null) {
|
||||
log.debug("[是否禁止退货] 无商品信息,仅检查订单级别,允许退货,order_id: {}", orderId);
|
||||
return false;
|
||||
}
|
||||
|
||||
Long productId = null;
|
||||
if (shopOrderItem != null) {
|
||||
productId = shopOrderItem.getProduct_id();
|
||||
}
|
||||
|
||||
// 3. 再判断具体商品是否可以退货(商品级别检查)
|
||||
// 获取商品索引信息
|
||||
ShopProductIndex productIndex = shopProductIndex;
|
||||
if (productIndex == null) {
|
||||
if (productIndex == null && productId != null) {
|
||||
productIndex = shopProductIndexService.get(productId);
|
||||
}
|
||||
|
||||
if (productIndex == null) {
|
||||
log.debug("[是否禁止退货] 商品索引信息不存在,不允许退货,product_id: {}", productId);
|
||||
return true;
|
||||
log.debug("[是否禁止退货] 商品索引信息不存在,允许退货,order_id: {}", orderId);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 3.1 检查商品是否设置了禁止退货标识
|
||||
@ -2199,17 +2204,17 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
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, productId);
|
||||
log.debug("[是否禁止退货] 商品设置了禁止退货标识,禁止退货,order_id: {}, product_id: {}", orderId, productIndex.getProduct_id());
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[是否禁止退货] 解析商品保障类型失败,不允许退货,order_id: {}, product_id: {}", orderId, productId, e);
|
||||
return true;
|
||||
log.error("[是否禁止退货] 解析商品保障类型失败,允许退货,order_id: {}, product_id: {}", orderId, productIndex.getProduct_id(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 默认允许退货
|
||||
log.debug("[是否禁止退货] 允许退货}");
|
||||
log.debug("[是否禁止退货] 商品允许退货,order_id: {}, product_id: {}", orderId, productIndex.getProduct_id());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2226,7 +2231,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
* @param productId 商品ID
|
||||
* @return boolean true表示禁止退货,false表示允许退货
|
||||
*/
|
||||
public boolean ifOrderItemDenyReturn(String orderId, Long productId) {
|
||||
public boolean isOrderItemDenyReturn(String orderId, Long productId) {
|
||||
// 复用已有的方法逻辑,避免重复代码
|
||||
return ifDenyReturn(
|
||||
shopOrderInfoService.get(orderId),
|
||||
@ -2235,7 +2240,6 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断订单是否禁止退货
|
||||
*
|
||||
@ -2246,7 +2250,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
public boolean isOrderDenyReturn(String orderId) {
|
||||
// 参数校验
|
||||
if (StrUtil.isBlank(orderId)) {
|
||||
log.warn("[订单是否禁止退货] 订单ID为空,不允许退货,无法判断退货状态");
|
||||
log.debug("[订单是否禁止退货] 订单ID为空,禁止退货,orderId: {}", orderId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2254,20 +2258,20 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
// 获取订单信息
|
||||
ShopOrderInfo shopOrderInfo = shopOrderInfoService.get(orderId);
|
||||
if (shopOrderInfo == null) {
|
||||
log.error("[订单是否禁止退货] 订单信息不存在,不允许退货,订单ID: {}", orderId);
|
||||
log.debug("[订单是否禁止退货] 订单信息不存在,禁止退货,orderId: {}", orderId);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查订单状态是否已收货或已完成
|
||||
Integer orderStateId = shopOrderInfo.getOrder_state_id();
|
||||
if (CheckUtil.isEmpty(orderStateId)) {
|
||||
log.warn("[订单是否禁止退货] 订单状态为空,不允许退货");
|
||||
log.debug("[订单是否禁止退货] 订单状态为空,禁止退货,orderId: {}", orderId);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (orderStateId.intValue() == StateCode.ORDER_STATE_CANCEL ||
|
||||
orderStateId.intValue() == StateCode.ORDER_STATE_WAIT_PAY) {
|
||||
log.debug("[是否禁止退货] 订单已取消或未支付,不允许退货, order_id: {}", orderId);
|
||||
log.debug("[订单是否禁止退货] 订单状态为已取消或未支付,禁止退货,orderId: {}, orderStateId: {}", orderId, orderStateId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2277,27 +2281,32 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
// 获取可提现时间戳
|
||||
Long withdrawTime = shopOrderBaseService.getWithdrawTime();
|
||||
Long orderDealTime = shopOrderInfo.getOrder_deal_time();
|
||||
log.debug("[订单是否禁止退货] 订单:{} 可提现时间戳: {},确认收货时间:{}", orderId, withdrawTime, orderDealTime);
|
||||
|
||||
// 如果订单成交时间早于可提现时间,说明已过退货期
|
||||
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
||||
log.debug("[订单是否禁止退货] 订单:{} 已过退货期,不允许退货", orderId);
|
||||
log.debug("[订单是否禁止退货] 订单已超过退货期限,禁止退货,orderId: {}, orderDealTime: {}, withdrawTime: {}",
|
||||
orderId, orderDealTime, withdrawTime);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 检查拉卡拉分账和提现状态
|
||||
if (lklOrderSeparateService.isOrderSeparated(orderId) &&
|
||||
lklOrderDrawService.isOrderDrawed(orderId)) {
|
||||
log.debug("[订单是否禁止退货] 订单[{}]已提现,不允许退货", orderId);
|
||||
boolean isLklSeparated = lklOrderSeparateService.isOrderSeparated(orderId);
|
||||
boolean isLklDrawed = lklOrderDrawService.isOrderDrawed(orderId);
|
||||
boolean isLklProcessed = isLklSeparated && isLklDrawed;
|
||||
|
||||
if (isLklProcessed) {
|
||||
log.debug("[订单是否禁止退货] 拉卡拉分账订单已提现,禁止退货,orderId: {}, separated: {}, drawed: {}",
|
||||
orderId, isLklSeparated, isLklDrawed);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 默认允许退货
|
||||
// 允许退货
|
||||
log.debug("[订单是否禁止退货] 订单允许退货,orderId: {}", orderId);
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[订单是否禁止退货] 查询订单{}退货状态异常,不允许退货", orderId, e);
|
||||
log.error("[订单是否禁止退货] 查询订单退货状态异常,禁止退货,orderId: {}", orderId, e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user