debug:订单权限

This commit is contained in:
磷叶 2024-12-09 08:45:21 +08:00
parent 680147c5f5
commit 8070a2a7e6
4 changed files with 20 additions and 6 deletions

View File

@ -71,4 +71,9 @@ public interface TransactionBillValidator {
* 是否允许操作订单 * 是否允许操作订单
*/ */
boolean canOperaOrder(TransactionBillVO bill, Long userId); boolean canOperaOrder(TransactionBillVO bill, Long userId);
/**
* 是否允许查看订单
*/
boolean canViewOrder(TransactionBillVO bill, Long userId);
} }

View File

@ -2027,7 +2027,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
if (open) { if (open) {
if (SuitFeeType.timingList().contains(bill.getSuitFeeType())) { if (SuitFeeType.timingList().contains(bill.getSuitFeeType())) {
return iotService.open(device.getMac(), device.getModelProductId()) ? 1 : 0; return iotService.open(device) ? 1 : 0;
} else { } else {
// 计算设备剩余时长 // 计算设备剩余时长
LocalDateTime expireTime = device.getExpireTime(); LocalDateTime expireTime = device.getExpireTime();

View File

@ -246,9 +246,6 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
return error("参数错误billId与userId不允许为空"); return error("参数错误billId与userId不允许为空");
} }
if (!this.allowGet(billId, userId)) {
return error("您不允许访问该订单");
}
return success(); return success();
} }
@ -379,6 +376,15 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
return false; return false;
} }
return this.isMch(bill, userId) return this.isMch(bill, userId)
|| this.isAgent(bill, userId)
|| storeStaffValidator.hasStorePermission(bill.getStoreId(), userId, StoreStaffPermissions.ORDER_OPERA);
}
@Override
public boolean canViewOrder(TransactionBillVO bill, Long userId) {
return this.isMch(bill, userId)
|| this.isUser(bill, userId)
|| this.isAgent(bill, userId)
|| storeStaffValidator.hasStorePermission(bill.getStoreId(), userId, StoreStaffPermissions.ORDER_OPERA); || storeStaffValidator.hasStorePermission(bill.getStoreId(), userId, StoreStaffPermissions.ORDER_OPERA);
} }
} }

View File

@ -143,6 +143,9 @@ public class AppTransactionBillController extends BaseController
public AjaxResult detail(@PathVariable Long billId) { public AjaxResult detail(@PathVariable Long billId) {
ServiceUtil.assertion(transactionBillValidator.preGetDetailByApp(billId, getUserId())); ServiceUtil.assertion(transactionBillValidator.preGetDetailByApp(billId, getUserId()));
TransactionBillVO bill = transactionBillService.selectSmTransactionBillByBillId(billId); TransactionBillVO bill = transactionBillService.selectSmTransactionBillByBillId(billId);
if (!transactionBillValidator.canViewOrder(bill, getUserId())) {
return error("您不允许查看该订单");
}
List<TransactionBillVO> list = Collections.singletonList(bill); List<TransactionBillVO> list = Collections.singletonList(bill);
transactionAssembler.assembleChannelName(Collections.singletonList(bill)); transactionAssembler.assembleChannelName(Collections.singletonList(bill));
transactionAssembler.handleMchUserMobile(list); transactionAssembler.handleMchUserMobile(list);
@ -155,8 +158,8 @@ public class AppTransactionBillController extends BaseController
@JsonView(JsonViewProfile.AppUser.class) @JsonView(JsonViewProfile.AppUser.class)
public AjaxResult detail(@PathVariable String billNo) { public AjaxResult detail(@PathVariable String billNo) {
TransactionBillVO bill = transactionBillService.selectSmTransactionBillByBillNo(billNo); TransactionBillVO bill = transactionBillService.selectSmTransactionBillByBillNo(billNo);
if (!transactionBillValidator.isUser(bill, getUserId()) && !transactionBillValidator.isMch(bill, getUserId())) { if (!transactionBillValidator.canViewOrder(bill, getUserId())) {
return success(); return error("您不允许查看该订单");
} }
transactionAssembler.assembleChannelName(Collections.singletonList(bill)); transactionAssembler.assembleChannelName(Collections.singletonList(bill));
return success(bill); return success(bill);