优化禁止退货的方法
This commit is contained in:
parent
986e8acb00
commit
12523f13da
@ -91,6 +91,6 @@ public class MchOrderInfoDTO implements Serializable {
|
|||||||
private BigDecimal order_income_amount;
|
private BigDecimal order_income_amount;
|
||||||
@ApiModelProperty(value = "两点距离,单位米")
|
@ApiModelProperty(value = "两点距离,单位米")
|
||||||
private Integer distance;
|
private Integer distance;
|
||||||
|
@ApiModelProperty(value = "是否禁止退款:1-是;2-否;")
|
||||||
// 快递鸟物流信息
|
private Integer is_deny_return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,4 +61,7 @@ public class MchOrderItemDTO implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "退款金额:同意额度")
|
@ApiModelProperty(value = "退款金额:同意额度")
|
||||||
private BigDecimal order_item_return_agree_amount;
|
private BigDecimal order_item_return_agree_amount;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否禁止退款:1-是;2-否;")
|
||||||
|
private Integer is_deny_return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -159,6 +159,28 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
|
|||||||
*/
|
*/
|
||||||
boolean ifDenyReturn(Long order_item_id);
|
boolean ifDenyReturn(Long order_item_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断订单中某个商品是否禁止退货
|
||||||
|
* <p>
|
||||||
|
* 该方法用于检查指定订单中的特定商品是否允许退货,主要检查以下几种情况:
|
||||||
|
* 1. 商品是否设置了"禁止退货"的消费者保障标识
|
||||||
|
* 2. 订单是否已超过退货期限(已收货或已完成状态,且超过可提现时间)
|
||||||
|
* 3. 拉卡拉分账订单是否已完成提现
|
||||||
|
*
|
||||||
|
* @param orderId 订单ID
|
||||||
|
* @param productId 商品ID
|
||||||
|
* @return boolean true表示禁止退货,false表示允许退货
|
||||||
|
*/
|
||||||
|
boolean ifOrderItemDenyReturn(String orderId, Long productId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断订单是否禁止退货
|
||||||
|
*
|
||||||
|
* @param orderId 订单ID
|
||||||
|
* @return 如果订单禁止退货返回true,否则返回false
|
||||||
|
*/
|
||||||
|
boolean isOrderDenyReturn(String orderId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 该方法用于处理整单退货申请,具体功能如下:
|
* 该方法用于处理整单退货申请,具体功能如下:
|
||||||
* 根据订单ID获取订单信息,若为空则抛异常。
|
* 根据订单ID获取订单信息,若为空则抛异常。
|
||||||
@ -201,4 +223,6 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
CommonResult doRefundForMch(JSONObject params);
|
CommonResult doRefundForMch(JSONObject params);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8947,6 +8947,16 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
|
|
||||||
// 格式化取货号
|
// 格式化取货号
|
||||||
order.setOrder_pickup_num_str(fmtPickNum(order.getOrder_pickup_num()));
|
order.setOrder_pickup_num_str(fmtPickNum(order.getOrder_pickup_num()));
|
||||||
|
|
||||||
|
// 订单是否禁止退款
|
||||||
|
int isOrderDenyReturn = shopOrderReturnService.isOrderDenyReturn(order.getOrder_id()) ? 1 : 2;
|
||||||
|
order.setIs_deny_return(isOrderDenyReturn);
|
||||||
|
|
||||||
|
// 订单商品列表是否禁止退款
|
||||||
|
order.getOrder_items().forEach(item -> {
|
||||||
|
item.setIs_deny_return(isOrderDenyReturn);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return pageList;
|
return pageList;
|
||||||
|
|||||||
@ -2119,7 +2119,6 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
|
|
||||||
// 2. 先判断整个订单是否可以退货(订单级别检查)
|
// 2. 先判断整个订单是否可以退货(订单级别检查)
|
||||||
// 2.1 检查订单状态是否为已收货或已完成
|
// 2.1 检查订单状态是否为已收货或已完成
|
||||||
|
|
||||||
if (orderStateId.intValue() == StateCode.ORDER_STATE_RECEIVED ||
|
if (orderStateId.intValue() == StateCode.ORDER_STATE_RECEIVED ||
|
||||||
orderStateId.intValue() == StateCode.ORDER_STATE_FINISH) {
|
orderStateId.intValue() == StateCode.ORDER_STATE_FINISH) {
|
||||||
try {
|
try {
|
||||||
@ -2152,15 +2151,21 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
log.error("[是否禁止退货] 检查拉卡拉分账状态时发生异常,order_id: {}", orderId, e);
|
log.error("[是否禁止退货] 检查拉卡拉分账状态时发生异常,order_id: {}", orderId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long productId = shopOrderItem.getProduct_id();
|
||||||
|
if (CheckUtil.isEmpty(productId)) {
|
||||||
|
log.warn("[是否禁止退货] 商品ID为空");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 3. 再判断具体商品是否可以退货(商品级别检查)
|
// 3. 再判断具体商品是否可以退货(商品级别检查)
|
||||||
// 获取商品索引信息
|
// 获取商品索引信息
|
||||||
ShopProductIndex productIndex = shopProductIndex;
|
ShopProductIndex productIndex = shopProductIndex;
|
||||||
if (productIndex == null) {
|
if (productIndex == null) {
|
||||||
productIndex = shopProductIndexService.get(shopOrderItem.getProduct_id());
|
productIndex = shopProductIndexService.get(productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (productIndex == null) {
|
if (productIndex == null) {
|
||||||
log.warn("[是否禁止退货] 商品索引信息不存在,product_id: {}", shopOrderItem.getProduct_id());
|
log.warn("[是否禁止退货] 商品索引信息不存在,product_id: {}", productId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2170,11 +2175,11 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
try {
|
try {
|
||||||
List<Integer> contractTypeIds = Convert.toList(Integer.class, contractTypeIdsStr);
|
List<Integer> contractTypeIds = Convert.toList(Integer.class, contractTypeIdsStr);
|
||||||
if (contractTypeIds != null && contractTypeIds.contains(StateCode.CONTRACT_TYPE_DENY_RETURN)) {
|
if (contractTypeIds != null && contractTypeIds.contains(StateCode.CONTRACT_TYPE_DENY_RETURN)) {
|
||||||
log.debug("[是否禁止退货] 商品设置了禁止退货标识,order_id: {}, product_id: {}", orderId, shopOrderItem.getProduct_id());
|
log.debug("[是否禁止退货] 商品设置了禁止退货标识,order_id: {}, product_id: {}", orderId, productId);
|
||||||
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: {}, product_id: {}", orderId, productId, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2211,10 +2216,11 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
* @param orderId 订单ID
|
* @param orderId 订单ID
|
||||||
* @return 如果订单禁止退货返回true,否则返回false
|
* @return 如果订单禁止退货返回true,否则返回false
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2222,22 +2228,28 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查订单状态是否已收货或已完成
|
// 检查订单状态是否已收货或已完成
|
||||||
Integer orderStateId = shopOrderInfo.getOrder_state_id();
|
Integer orderStateId = shopOrderInfo.getOrder_state_id();
|
||||||
if (ObjectUtil.equal(orderStateId, StateCode.ORDER_STATE_RECEIVED) ||
|
if (CheckUtil.isEmpty(orderStateId)) {
|
||||||
ObjectUtil.equal(orderStateId, StateCode.ORDER_STATE_FINISH)) {
|
log.warn("[订单是否禁止退货] 订单状态为空");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orderStateId.intValue() == StateCode.ORDER_STATE_RECEIVED ||
|
||||||
|
orderStateId.intValue() == StateCode.ORDER_STATE_FINISH) {
|
||||||
|
|
||||||
// 获取可提现时间戳
|
// 获取可提现时间戳
|
||||||
Long withdrawTime = shopOrderBaseService.getWithdrawTime();
|
Long withdrawTime = shopOrderBaseService.getWithdrawTime();
|
||||||
Long orderDealTime = shopOrderInfo.getOrder_deal_time();
|
Long orderDealTime = shopOrderInfo.getOrder_deal_time();
|
||||||
|
log.debug("[订单是否禁止退货] 订单:{} 可提现时间戳: {},确认收货时间:{}", orderId, withdrawTime, orderDealTime);
|
||||||
|
|
||||||
// 如果订单成交时间早于可提现时间,说明已过退货期
|
// 如果订单成交时间早于可提现时间,说明已过退货期
|
||||||
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
||||||
log.debug("[订单是否禁止退货]订单[{}]已过退货期,不允许退货", orderId);
|
log.debug("[订单是否禁止退货] 订单:{} 已过退货期,不允许退货", orderId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2245,7 +2257,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2253,7 +2265,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2321,7 +2333,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (StrUtil.isBlank(remark)) {
|
if (StrUtil.isBlank(remark)) {
|
||||||
remark = "整单退!";
|
remark = "整单退款";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断此订单商品是否已有退款单。
|
// 判断此订单商品是否已有退款单。
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user