fix: allow manager cancellation of random orders
This commit is contained in:
@@ -44,7 +44,9 @@ import com.starry.admin.modules.order.service.IPlayOrderInfoService;
|
||||
import com.starry.admin.modules.order.service.IPlayOrderRefundInfoService;
|
||||
import com.starry.admin.modules.order.service.support.ClerkRevenueCalculator;
|
||||
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelGroupInfoEntity;
|
||||
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelAdminInfoEntity;
|
||||
import com.starry.admin.modules.personnel.service.IPlayPersonnelGroupInfoService;
|
||||
import com.starry.admin.modules.personnel.service.IPlayPersonnelAdminInfoService;
|
||||
import com.starry.admin.modules.shop.module.constant.CouponUseState;
|
||||
import com.starry.admin.modules.shop.service.IPlayCouponDetailsService;
|
||||
import com.starry.admin.modules.weichat.entity.order.*;
|
||||
@@ -98,6 +100,9 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
|
||||
@Resource
|
||||
private IPlayPersonnelGroupInfoService playClerkGroupInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayPersonnelAdminInfoService playPersonnelAdminInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayCouponDetailsService playCouponDetailsService;
|
||||
|
||||
@@ -1057,7 +1062,9 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
|
||||
throw new CustomException("只能操作本人订单");
|
||||
}
|
||||
if ("1".equals(operatorByType) && !operatorBy.equals(orderInfo.getAcceptBy())) {
|
||||
throw new CustomException("只能操作本人订单");
|
||||
if (!isClerkManagementOperator(operatorBy)) {
|
||||
throw new CustomException("只能操作本人订单");
|
||||
}
|
||||
}
|
||||
// 取消订单(必须订单未接单或者为开始状态)
|
||||
if (!orderInfo.getOrderStatus().equals(OrderStatus.PENDING.getCode())
|
||||
@@ -1079,6 +1086,22 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
|
||||
notificationSender.sendOrderCancelMessageAsync(orderInfo, refundReason);
|
||||
}
|
||||
|
||||
private boolean isClerkManagementOperator(String clerkId) {
|
||||
if (StringUtils.isBlank(clerkId)) {
|
||||
return false;
|
||||
}
|
||||
PlayClerkUserInfoEntity clerkInfo = playClerkUserInfoService.selectById(clerkId);
|
||||
if (clerkInfo == null || StringUtils.isBlank(clerkInfo.getSysUserId())) {
|
||||
return false;
|
||||
}
|
||||
PlayPersonnelAdminInfoEntity adminInfo = playPersonnelAdminInfoService.selectByUserId(clerkInfo.getSysUserId());
|
||||
if (adminInfo != null) {
|
||||
return true;
|
||||
}
|
||||
PlayPersonnelGroupInfoEntity groupInfo = playClerkGroupInfoService.selectByUserId(clerkInfo.getSysUserId());
|
||||
return groupInfo != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已接单/服务中的订单强制取消,仅允许店员本人或管理员操作
|
||||
*/
|
||||
@@ -1087,7 +1110,9 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
|
||||
public void forceCancelOngoingOrder(String operatorByType, String operatorBy, String orderId, BigDecimal refundAmount,
|
||||
String refundReason, List<String> images) {
|
||||
if (!"2".equals(operatorByType)) {
|
||||
throw new CustomException("禁止操作");
|
||||
if (!("1".equals(operatorByType) && isClerkManagementOperator(operatorBy))) {
|
||||
throw new CustomException("禁止操作");
|
||||
}
|
||||
}
|
||||
PlayOrderInfoEntity orderInfo = this.selectOrderInfoById(orderId);
|
||||
if (!OrderStatus.ACCEPTED.getCode().equals(orderInfo.getOrderStatus())
|
||||
|
||||
Reference in New Issue
Block a user