From daf9f8dbb7ba36eb283221d2c6022039aefaf97d Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期日, 25 十月 2026 00:40:38 +0800
Subject: [PATCH] feat(aftersales): 售后退货单同步MES批次信息并优化工单处理流程
---
yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmRegularizeApplicationServiceImpl.java | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmRegularizeApplicationServiceImpl.java b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmRegularizeApplicationServiceImpl.java
index da24153..ef59c7a 100644
--- a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmRegularizeApplicationServiceImpl.java
+++ b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmRegularizeApplicationServiceImpl.java
@@ -98,17 +98,13 @@
if (userId == null) {
userId = getCurrentUserId();
}
+ AdminUserRespDTO user = validateApplicant(userId);
HrmRegularizeApplicationDO existing = regularizeApplicationMapper.selectByUserIdAndStatusNot(userId,
HrmAuditStatusEnum.CANCEL.getStatus());
if (existing != null) {
throw exception(REGULARIZE_APPLICATION_EXISTS);
}
String no = generateUniqueNo();
- AdminUserRespDTO user = adminUserApi.getUser(userId);
- if (user == null) {
- userId = getCurrentUserId();
- user = adminUserApi.getUser(userId);
- }
HrmRegularizeApplicationDO application = BeanUtils.toBean(createReqVO, HrmRegularizeApplicationDO.class);
application.setNo(no);
application.setUserId(userId);
@@ -121,6 +117,17 @@
private Long getCurrentUserId() {
return SecurityFrameworkUtils.getLoginUserId();
+ }
+
+ private AdminUserRespDTO validateApplicant(Long userId) {
+ AdminUserRespDTO user = userId == null ? null : adminUserApi.getUser(userId);
+ if (user == null) {
+ throw exception(REGULARIZE_APPLICANT_NOT_EXISTS);
+ }
+ if (employeeMapper.selectByUserId(userId) == null) {
+ throw exception(REGULARIZE_EMPLOYEE_LINK_REQUIRED);
+ }
+ return user;
}
private String generateUniqueNo() {
@@ -137,6 +144,9 @@
if (!Objects.equals(application.getStatus(), HrmAuditStatusEnum.DRAFT.getStatus())
&& !Objects.equals(application.getStatus(), HrmAuditStatusEnum.REJECT.getStatus())) {
throw exception(REGULARIZE_APPLICATION_UPDATE_FAIL_NOT_DRAFT);
+ }
+ if (updateReqVO.getUserId() != null) {
+ validateApplicant(updateReqVO.getUserId());
}
HrmRegularizeApplicationDO updateObj = BeanUtils.toBean(updateReqVO, HrmRegularizeApplicationDO.class);
regularizeApplicationMapper.updateById(updateObj);
@@ -248,6 +258,7 @@
&& !Objects.equals(application.getStatus(), HrmAuditStatusEnum.REJECT.getStatus())) {
throw exception(REGULARIZE_APPLICATION_SUBMIT_FAIL_NOT_EDITABLE);
}
+ validateApplicant(application.getUserId());
// 2. 鏍¢獙瀹℃壒閰嶇疆宸插惎鐢ㄤ笖閰嶇疆浜嗘湁鏁堝鎵逛汉锛堟湭閰嶇疆鏃舵姏鍑哄甫鏄庣‘鎻愮ず鐨勪笟鍔″紓甯革級
approvalConfigApi.validateApprovalEnabledAndGetApprovers(REGULARIZE_APPROVE_BIZ_TYPE);
@@ -310,8 +321,7 @@
private void writeBackEmployee(HrmRegularizeApplicationDO application) {
HrmEmployeeDO employee = employeeMapper.selectByUserId(application.getUserId());
if (employee == null) {
- log.warn("[writeBackEmployee] 杞鐢宠({}) 鐢ㄦ埛({}) 鏈壘鍒板憳宸ユ。妗堬紝璺宠繃鍥炲啓", application.getId(), application.getUserId());
- return;
+ throw exception(REGULARIZE_EMPLOYEE_LINK_REQUIRED);
}
LocalDate regularDate = application.getExpectedDate() != null ? application.getExpectedDate() : LocalDate.now();
employeeMapper.updateById(HrmEmployeeDO.builder()
@@ -361,4 +371,4 @@
return user == null ? null : user.getNickname();
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3