|
@@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
|
|
|
@Anonymous
|
|
@Anonymous
|
|
|
@RestController
|
|
@RestController
|
|
@@ -92,9 +93,7 @@ public class ShopDataImportController {
|
|
|
Map<String, Double> contributionData = shopAnalysisService.getChannelSalesContribution();
|
|
Map<String, Double> contributionData = shopAnalysisService.getChannelSalesContribution();
|
|
|
|
|
|
|
|
if (contributionData == null || contributionData.isEmpty()) {
|
|
if (contributionData == null || contributionData.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No sales data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", new HashMap<>()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -115,9 +114,7 @@ public class ShopDataImportController {
|
|
|
Map<String, Double> roiData = shopAnalysisService.getChannelRoiValue();
|
|
Map<String, Double> roiData = shopAnalysisService.getChannelRoiValue();
|
|
|
|
|
|
|
|
if (roiData == null || roiData.isEmpty()) {
|
|
if (roiData == null || roiData.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No sales data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", new HashMap<>()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -137,9 +134,7 @@ public class ShopDataImportController {
|
|
|
List<Map<String, Object>> data = shopAnalysisService.getUnitContribution();
|
|
List<Map<String, Object>> data = shopAnalysisService.getUnitContribution();
|
|
|
|
|
|
|
|
if (data == null || data.isEmpty()) {
|
|
if (data == null || data.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", Collections.emptyList()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -154,9 +149,7 @@ public class ShopDataImportController {
|
|
|
List<Map<String, Object>> data = shopAnalysisService.getChannelTotalContribution();
|
|
List<Map<String, Object>> data = shopAnalysisService.getChannelTotalContribution();
|
|
|
|
|
|
|
|
if (data == null || data.isEmpty()) {
|
|
if (data == null || data.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", Collections.emptyList()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -171,9 +164,7 @@ public class ShopDataImportController {
|
|
|
List<Map<String, Object>> data = shopAnalysisService.getPlatformTotalContribution();
|
|
List<Map<String, Object>> data = shopAnalysisService.getPlatformTotalContribution();
|
|
|
|
|
|
|
|
if (data == null || data.isEmpty()) {
|
|
if (data == null || data.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", Collections.emptyList()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -189,9 +180,7 @@ public class ShopDataImportController {
|
|
|
Map<String, Object> result = shopAnalysisService.getTopProductContribution();
|
|
Map<String, Object> result = shopAnalysisService.getTopProductContribution();
|
|
|
|
|
|
|
|
if (result == null || result.isEmpty()) {
|
|
if (result == null || result.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", new HashMap<>()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -212,9 +201,7 @@ public class ShopDataImportController {
|
|
|
List<Map<String, Object>> data = shopAnalysisService.getCrossSellingProducts();
|
|
List<Map<String, Object>> data = shopAnalysisService.getCrossSellingProducts();
|
|
|
|
|
|
|
|
if (data == null || data.isEmpty()) {
|
|
if (data == null || data.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", Collections.emptyList()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -235,9 +222,7 @@ public class ShopDataImportController {
|
|
|
Map<String, Double> data = shopAnalysisService.getDepartmentOperationalEfficiency();
|
|
Map<String, Double> data = shopAnalysisService.getDepartmentOperationalEfficiency();
|
|
|
|
|
|
|
|
if (data == null || data.isEmpty()) {
|
|
if (data == null || data.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", new HashMap<>()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -258,9 +243,7 @@ public class ShopDataImportController {
|
|
|
Map<String, Long> data = shopAnalysisService.getChannelProductDiversity();
|
|
Map<String, Long> data = shopAnalysisService.getChannelProductDiversity();
|
|
|
|
|
|
|
|
if (data == null || data.isEmpty()) {
|
|
if (data == null || data.isEmpty()) {
|
|
|
- response.put("success", false);
|
|
|
|
|
- response.put("message", "No data found.");
|
|
|
|
|
- return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
|
|
|
|
+ return ResponseEntity.ok(buildEmptyResponse("暂无店铺价值数据,请先上传销售文件。", new HashMap<>()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
response.put("success", true);
|
|
response.put("success", true);
|
|
@@ -273,4 +256,13 @@ public class ShopDataImportController {
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private Map<String, Object> buildEmptyResponse(String message, Object data) {
|
|
|
|
|
+ Map<String, Object> response = new HashMap<>();
|
|
|
|
|
+ response.put("success", true);
|
|
|
|
|
+ response.put("empty", true);
|
|
|
|
|
+ response.put("message", message);
|
|
|
|
|
+ response.put("data", data);
|
|
|
|
|
+ return response;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|