mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:59:20 +08:00
fix(order-import): 新公司无订单状态时自动创建默认状态
- getDefaultOrderStatusId() 改为在没有订单状态时自动创建待处理状态 - 而不是抛出异常需要用户先创建状态
This commit is contained in:
+15
-3
@@ -363,8 +363,8 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
fileInputStream = new java.io.BufferedInputStream(new java.io.FileInputStream(tempOssFile));
|
||||
}
|
||||
|
||||
// 获取默认订单状态ID(尝试查找"未知状态",如果不存在则使用第一个状态)
|
||||
Long defaultStatusId = getDefaultOrderStatusId(companyId);
|
||||
// 获取默认订单状态ID(尝试查找"未知状态",如果不存在则使用第一个状态,如果都没有则自动创建"待处理"状态)
|
||||
Long defaultStatusId = getDefaultOrderStatusId(companyId, task.getCreateBy());
|
||||
|
||||
long lastProgressNotifyAt = 0L;
|
||||
|
||||
@@ -1782,6 +1782,17 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
* @return 默认订单状态ID
|
||||
*/
|
||||
private Long getDefaultOrderStatusId(Long companyId) {
|
||||
return getDefaultOrderStatusId(companyId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认订单状态ID,如果没有则自动创建
|
||||
*
|
||||
* @param companyId 公司ID
|
||||
* @param createBy 创建人ID(可选)
|
||||
* @return 默认订单状态ID
|
||||
*/
|
||||
private Long getDefaultOrderStatusId(Long companyId, Long createBy) {
|
||||
// 首先尝试查找"未知状态"
|
||||
Long statusId = findOrderStatusIdByName(companyId, "未知状态");
|
||||
if (statusId != null) {
|
||||
@@ -1800,7 +1811,8 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
return firstStatus.getId();
|
||||
}
|
||||
|
||||
throw new BusinessException("公司中没有可用的订单状态,请先创建订单状态");
|
||||
// 公司没有任何订单状态,自动创建一个默认的"待处理"状态
|
||||
return createOrderStatusIfNotExists(companyId, "待处理", createBy, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user