Commit 6375078a by 章家宝

feat(store): 角色是admin可以审批

1 parent 8b224ca0
......@@ -169,7 +169,8 @@ youjia:
store:
approval:
level-role-codes:
- finance_manager
- business_manager # 第1级:商务经理
- finance_manager # 第2级:财务经理
partner-merchant:
# 审批通过后同步至 D+ 的主服务商(深圳优加)
id: ${PARTNER_MERCHANT_ID:}
......
......@@ -2,6 +2,7 @@ package com.youjia.store.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youjia.common.constant.CommonConstants;
import com.youjia.common.core.PageResult;
import com.youjia.common.core.ResultCode;
import com.youjia.common.enums.ApprovalActionEnum;
......@@ -64,11 +65,15 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
@Override
public PageResult<StoreApprovalTaskVO> pagePending(StoreApprovalTaskQueryDTO query) {
List<String> roleCodes = CurrentUserHolder.getRoleCodes();
boolean isAdmin = roleCodes.contains(CommonConstants.ROLE_SYS_ADMIN);
LambdaQueryWrapper<StoreListing> wrapper = buildWrapper(query)
.eq(StoreListing::getStatus, StoreStatusEnum.PENDING.getCode())
.in(roleCodes.isEmpty(), StoreListing::getLevelRoleCode, List.of("-1"))
.in(!roleCodes.isEmpty(), StoreListing::getLevelRoleCode, roleCodes)
.orderByDesc(StoreListing::getSubmitTime);
.eq(StoreListing::getStatus, StoreStatusEnum.PENDING.getCode());
// SYS_ADMIN 可看到所有待审批任务(充当所有角色),其他用户按角色匹配
if (!isAdmin) {
wrapper.in(roleCodes.isEmpty(), StoreListing::getLevelRoleCode, List.of("-1"))
.in(!roleCodes.isEmpty(), StoreListing::getLevelRoleCode, roleCodes);
}
wrapper.orderByDesc(StoreListing::getSubmitTime);
return pageTask(query, wrapper);
}
......@@ -133,7 +138,8 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
}
writeApprovalLog(listing.getListingId(), ApprovalActionEnum.PASS,
StoreStatusEnum.PENDING.getCode(), StoreStatusEnum.PENDING.getCode(),
"第 " + currentLevel + " 级审批通过,流转至第 " + nextLevel + " 级");
"第 " + currentLevel + " 级审批通过,流转至第 " + nextLevel + " 级",
listing.getLevelRoleCode());
log.info("门店上架审批升级:listingId={}, 第{}级→第{}级",
listing.getListingId(), currentLevel, nextLevel);
} else {
......@@ -160,7 +166,8 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
deactivateOldEffective(listing.getMerchantNo(), listing.getBusinessScene(), listing.getListingId());
writeChangeLogForApproval(listing, oldEffective, now);
writeApprovalLog(listing.getListingId(), ApprovalActionEnum.PASS,
StoreStatusEnum.PENDING.getCode(), StoreStatusEnum.APPROVED.getCode(), "审批通过");
StoreStatusEnum.PENDING.getCode(), StoreStatusEnum.APPROVED.getCode(), "审批通过",
listing.getLevelRoleCode());
log.info("门店上架审批通过:listingId={}, 门店={}, 场景={}",
listing.getListingId(), listing.getStoreName(), listing.getBusinessScene());
// 对账规则发布由「审核通过」事件监听器处理(publishByListingId),
......@@ -192,7 +199,8 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
storeListingMapper.updateById(update);
writeApprovalLog(listing.getListingId(), ApprovalActionEnum.REJECT,
StoreStatusEnum.PENDING.getCode(), StoreStatusEnum.REJECTED.getCode(), dto.getReason());
StoreStatusEnum.PENDING.getCode(), StoreStatusEnum.REJECTED.getCode(), dto.getReason(),
listing.getLevelRoleCode());
// TODO 接入企业微信通知发起人(携带打回原因)
}
......@@ -586,13 +594,26 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
private void writeApprovalLog(Long listingId, ApprovalActionEnum action,
String preStatus, String postStatus, String reason) {
writeApprovalLog(listingId, action, preStatus, postStatus, reason, null);
}
private void writeApprovalLog(Long listingId, ApprovalActionEnum action,
String preStatus, String postStatus, String reason,
String actingRoleCode) {
StoreApprovalLog entity = new StoreApprovalLog();
entity.setListingId(listingId);
entity.setAction(action.name());
entity.setOperatorId(CurrentUserHolder.getUserId());
entity.setOperatorName(CurrentUserHolder.getName());
List<String> roleCodes = CurrentUserHolder.getRoleCodes();
entity.setOperatorRole(roleCodes.isEmpty() ? null : String.join(",", roleCodes));
String operatorRole;
if (actingRoleCode != null && roleCodes.contains(CommonConstants.ROLE_SYS_ADMIN)) {
// SYS_ADMIN 代审批时,记录其充当的角色
operatorRole = CommonConstants.ROLE_SYS_ADMIN + "(代 " + actingRoleCode + ")";
} else {
operatorRole = roleCodes.isEmpty() ? null : String.join(",", roleCodes);
}
entity.setOperatorRole(operatorRole);
entity.setPreStatus(preStatus);
entity.setPostStatus(postStatus);
entity.setReason(reason);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!