feat: 调整权限点

This commit is contained in:
2026-08-24 14:16:44 +08:00
parent d57745effb
commit 25a6911600
43 changed files with 1176 additions and 769 deletions
@@ -44,14 +44,14 @@ public class BiOrderStatCalcController {
}
@GetMapping("/inc/status")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "bi:order-stat:calc:read", description = "查询BI计算状态", allowSuper = true)
public ApiResponse<BiOrderStatIncCalcStatusVO> incStatus(@RequestParam Long shopId) {
ShopPO shop = requireOwnedShop(shopId);
return ApiResponse.success(toIncVo(shop.getId(), calcTaskService.findIncState(shop.getId())));
}
@PostMapping("/inc/resume")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "bi:order-stat:calc:update", description = "恢复BI增量计算", allowSuper = true)
public ApiResponse<BiOrderStatIncCalcStatusVO> resumeInc(@RequestParam Long shopId) {
ShopPO shop = requireOwnedShop(shopId);
BiOrderStatIncCalcPO state = calcTaskService.resumeInc(shop.getCompanyId(), shop.getId());
@@ -59,7 +59,7 @@ public class BiOrderStatCalcController {
}
@PostMapping("/full-task")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "bi:order-stat:calc:create", description = "创建BI全量计算任务", allowSuper = true)
public ApiResponse<BiOrderStatFullCalcTaskVO> createFullTask(
@Valid @RequestBody BiOrderStatFullCalcTaskCreateDTO dto) {
ShopPO shop = requireOwnedShop(dto.getShopId());
@@ -73,7 +73,7 @@ public class BiOrderStatCalcController {
}
@GetMapping("/full-task/list")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "bi:order-stat:calc:read", description = "查询BI全量计算任务", allowSuper = true)
public ApiResponse<List<BiOrderStatFullCalcTaskVO>> listFullTasks(
@RequestParam Long shopId,
@RequestParam(required = false, defaultValue = "20") Integer limit) {
@@ -22,7 +22,7 @@ public class BiProductOverviewController {
}
@PostMapping("/overview")
@RequirePermission(value = "ecom:product:read", description = "查询商品概览", allowSuper = true)
@RequirePermission(value = "bi:product:overview", description = "查询商品概览", allowSuper = true)
public ApiResponse<ProductOverviewVO> overview(@Valid @RequestBody ProductOverviewQueryDTO queryDTO) {
return ApiResponse.success("获取商品总览成功", biProductOverviewService.getProductOverview(queryDTO));
}
@@ -22,7 +22,7 @@ public class BiShopOverviewController {
}
@PostMapping("/overview")
@RequirePermission(value = "ecom:shop:read", description = "查询店铺概览", allowSuper = true)
@RequirePermission(value = "bi:shop:overview", description = "查询店铺概览", allowSuper = true)
public ApiResponse<ShopOverviewStatisticsVO> overview(@Valid @RequestBody ShopOverviewQueryDTO queryDTO) {
return ApiResponse.success("获取店铺概览成功", biShopOverviewService.getShopOverview(queryDTO));
}
@@ -27,25 +27,25 @@ public class BiWorkbenchController {
}
@PostMapping("/finance")
@RequirePermission(value = "ecom:shop:read", description = "查询工作台经营概览", allowSuper = true)
@RequirePermission(value = "bi:workbench:read", description = "查询工作台经营概览", allowSuper = true)
public ApiResponse<WorkbenchFinanceSliceVO> finance(@Valid @RequestBody WorkbenchQueryDTO queryDTO) {
return ApiResponse.success("获取经营概览成功", biWorkbenchService.financeSlice(queryDTO));
}
@PostMapping("/multi-analysis")
@RequirePermission(value = "ecom:shop:read", description = "查询工作台多维分析", allowSuper = true)
@RequirePermission(value = "bi:workbench:read", description = "查询工作台多维分析", allowSuper = true)
public ApiResponse<WorkbenchMultiAnalysisPanelVO> multiAnalysis(@Valid @RequestBody WorkbenchQueryDTO queryDTO) {
return ApiResponse.success("获取多维分析成功", biWorkbenchService.multiAnalysis(queryDTO));
}
@PostMapping("/sales-rank")
@RequirePermission(value = "ecom:shop:read", description = "查询工作台销售额排行", allowSuper = true)
@RequirePermission(value = "bi:workbench:read", description = "查询工作台销售额排行", allowSuper = true)
public ApiResponse<WorkbenchMultiAnalysisPanelVO> salesRank(@Valid @RequestBody WorkbenchQueryDTO queryDTO) {
return ApiResponse.success("获取销售额排行成功", biWorkbenchService.salesRank(queryDTO));
}
@PostMapping("/period-compare/slice")
@RequirePermission(value = "ecom:shop:read", description = "查询工作台区间对比", allowSuper = true)
@RequirePermission(value = "bi:workbench:read", description = "查询工作台区间对比", allowSuper = true)
public ApiResponse<WorkbenchPeriodCompareSliceVO> periodCompareSlice(
@Valid @RequestBody WorkbenchQueryDTO queryDTO) {
return ApiResponse.success("获取区间对比数据成功", biWorkbenchService.periodCompareSlice(queryDTO));
@@ -31,13 +31,13 @@ public class PddGoodsAdFeeController {
private final PddGoodsAdFeeService pddGoodsAdFeeService;
@PostMapping("/create")
@RequirePermission(value = "biz:pdd:ad-fee:manage", description = "创建拼多多商品广告费", allowSuper = true)
@RequirePermission(value = "channel:pdd:ad-fee:create", description = "创建拼多多商品广告费", allowSuper = true)
public ApiResponse<PddGoodsAdFeeVO> create(@Valid @RequestBody CreatePddGoodsAdFeeDTO dto) {
return ApiResponse.success("创建成功", pddGoodsAdFeeService.create(dto));
}
@PutMapping("/update/{id}")
@RequirePermission(value = "biz:pdd:ad-fee:manage", description = "更新拼多多商品广告费", allowSuper = true)
@RequirePermission(value = "channel:pdd:ad-fee:update", description = "更新拼多多商品广告费", allowSuper = true)
public ApiResponse<PddGoodsAdFeeVO> update(
@PathVariable Long id,
@Valid @RequestBody UpdatePddGoodsAdFeeDTO dto) {
@@ -45,20 +45,20 @@ public class PddGoodsAdFeeController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "biz:pdd:ad-fee:manage", description = "删除拼多多商品广告费", allowSuper = true)
@RequirePermission(value = "channel:pdd:ad-fee:delete", description = "删除拼多多商品广告费", allowSuper = true)
public ApiResponse<Void> delete(@PathVariable Long id) {
pddGoodsAdFeeService.delete(id);
return ApiResponse.success("删除成功");
}
@GetMapping("/detail/{id}")
@RequirePermission(value = "biz:pdd:ad-fee:read", description = "查询拼多多商品广告费详情", allowSuper = true)
@RequirePermission(value = "channel:pdd:ad-fee:read", description = "查询拼多多商品广告费详情", allowSuper = true)
public ApiResponse<PddGoodsAdFeeVO> detail(@PathVariable Long id) {
return ApiResponse.success("获取成功", pddGoodsAdFeeService.getDetail(id));
}
@PostMapping("/list")
@RequirePermission(value = "biz:pdd:ad-fee:read", description = "查询拼多多商品广告费列表", allowSuper = true)
@RequirePermission(value = "channel:pdd:ad-fee:read", description = "查询拼多多商品广告费列表", allowSuper = true)
public ApiResponse<PageResultVO<PddGoodsAdFeeVO>> list(
@Valid @RequestBody PageQueryDTO<PddGoodsAdFeeFilterDTO> pageQueryDTO) {
return ApiResponse.success("获取成功", pddGoodsAdFeeService.getPage(pageQueryDTO));
@@ -28,20 +28,20 @@ public class PddGoodsAdFeeImportController {
private final PddGoodsAdFeeImportService importService;
@PostMapping("/create")
@RequirePermission(value = "biz:pdd:ad-fee:manage", description = "创建拼多多商品广告费导入任务", allowSuper = true)
@RequirePermission(value = "channel:pdd:ad-fee:import", description = "创建拼多多商品广告费导入任务", allowSuper = true)
public ApiResponse<PddGoodsAdFeeImportTaskVO> create(
@Valid @RequestBody BatchImportPddGoodsAdFeeDTO dto) {
return ApiResponse.success("已创建导入任务", importService.createAndEnqueue(dto));
}
@GetMapping("/detail/{id}")
@RequirePermission(value = "biz:pdd:ad-fee:read", description = "查询拼多多商品广告费导入任务", allowSuper = true)
@RequirePermission(value = "channel:pdd:ad-fee:read", description = "查询拼多多商品广告费导入任务", allowSuper = true)
public ApiResponse<PddGoodsAdFeeImportTaskVO> detail(@PathVariable Long id) {
return ApiResponse.success("获取成功", importService.getDetail(id));
}
@PostMapping("/list")
@RequirePermission(value = "biz:pdd:ad-fee:read", description = "查询拼多多商品广告费导入任务列表", allowSuper = true)
@RequirePermission(value = "channel:pdd:ad-fee:read", description = "查询拼多多商品广告费导入任务列表", allowSuper = true)
public ApiResponse<PageResultVO<PddGoodsAdFeeImportTaskVO>> list(
@Valid @RequestBody PageQueryDTO<PddGoodsAdFeeImportTaskFilterDTO> pageQueryDTO) {
return ApiResponse.success("获取成功", importService.getPage(pageQueryDTO));
@@ -25,7 +25,7 @@ public class PddAuthController {
}
@GetMapping("/authorize-url")
@RequirePermission(value = "channel:pdd:auth:manage", description = "拼多多授权管理", allowSuper = true)
@RequirePermission(value = "channel:pdd:shop:authorize", description = "拼多多店铺授权", allowSuper = true)
public ApiResponse<PddAuthorizeUrlVO> authorizeUrl(
@RequestParam("shopId") Long shopId) {
return ApiResponse.success(pddAuthService.buildAuthorizeUrl(shopId));
@@ -24,14 +24,14 @@ public class PddGoodsController {
}
@PostMapping("/create")
@RequirePermission(value = "channel:pdd:goods:manage", description = "创建拼多多商品", allowSuper = true)
@RequirePermission(value = "channel:pdd:goods:create", description = "创建拼多多商品", allowSuper = true)
public ApiResponse<PddGoodsVO> createPddGoods(@Valid @RequestBody CreatePddGoodsDTO createPddGoodsDTO) {
PddGoodsVO vo = pddGoodsService.createPddGoods(createPddGoodsDTO);
return ApiResponse.success("创建成功", vo);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "channel:pdd:goods:manage", description = "更新拼多多商品", allowSuper = true)
@RequirePermission(value = "channel:pdd:goods:update", description = "更新拼多多商品", allowSuper = true)
public ApiResponse<PddGoodsVO> updatePddGoods(@Valid @RequestBody UpdatePddGoodsDTO updatePddGoodsDTO,
@PathVariable Long id) {
PddGoodsVO vo = pddGoodsService.updatePddGoods(updatePddGoodsDTO, id);
@@ -39,7 +39,7 @@ public class PddGoodsController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "channel:pdd:goods:manage", description = "删除拼多多商品", allowSuper = true)
@RequirePermission(value = "channel:pdd:goods:delete", description = "删除拼多多商品", allowSuper = true)
public ApiResponse<Void> deletePddGoods(@PathVariable Long id) {
pddGoodsService.deletePddGoods(id);
return ApiResponse.success("删除成功");
@@ -61,7 +61,7 @@ public class PddGoodsController {
}
@PostMapping("/sync/{pddShopId}")
@RequirePermission(value = "channel:pdd:goods:manage", description = "同步拼多多商品", allowSuper = true)
@RequirePermission(value = "channel:pdd:goods:sync", description = "同步拼多多商品", allowSuper = true)
public ApiResponse<PddGoodsSyncResultVO> syncGoodsByPddShop(
@PathVariable Long pddShopId) {
PddGoodsSyncResultVO result = pddGoodsService.syncGoodsByPddShop(pddShopId);
@@ -23,14 +23,14 @@ public class PddOrderController {
}
@PostMapping("/create")
@RequirePermission(value = "channel:pdd:order:manage", description = "创建拼多多订单", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:create", description = "创建拼多多订单", allowSuper = true)
public ApiResponse<PddOrderVO> createPddOrder(@Valid @RequestBody CreatePddOrderDTO createPddOrderDTO) {
PddOrderVO vo = pddOrderService.createPddOrder(createPddOrderDTO);
return ApiResponse.success("创建成功", vo);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "channel:pdd:order:manage", description = "更新拼多多订单", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:update", description = "更新拼多多订单", allowSuper = true)
public ApiResponse<PddOrderVO> updatePddOrder(@Valid @RequestBody UpdatePddOrderDTO updatePddOrderDTO,
@PathVariable Long id) {
PddOrderVO vo = pddOrderService.updatePddOrder(updatePddOrderDTO, id);
@@ -38,7 +38,7 @@ public class PddOrderController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "channel:pdd:order:manage", description = "删除拼多多订单", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:delete", description = "删除拼多多订单", allowSuper = true)
public ApiResponse<Void> deletePddOrder(@PathVariable Long id) {
pddOrderService.deletePddOrder(id);
return ApiResponse.success("删除成功");
@@ -38,7 +38,7 @@ public class PddOrderConvertController {
}
@GetMapping("/inc/status")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:convert:read", description = "查询订单转换状态", allowSuper = true)
public ApiResponse<PddOrderConvertIncStatusVO> incStatus(@RequestParam Long shopId) {
PddOrderSyncShopContext ctx = contextResolver.resolveForCurrentCompany(shopId);
return ApiResponse.success(toIncVo(ctx.getInternalShopId(),
@@ -46,7 +46,7 @@ public class PddOrderConvertController {
}
@PostMapping("/inc/resume")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:convert:update", description = "恢复订单转换", allowSuper = true)
public ApiResponse<PddOrderConvertIncStatusVO> resumeInc(@RequestParam Long shopId) {
PddOrderSyncShopContext ctx = contextResolver.resolveForCurrentCompany(shopId);
PddOrderIncConvertPO state = convertTaskService.resumeInc(ctx.getShopId(), ctx.getCompanyId());
@@ -54,7 +54,7 @@ public class PddOrderConvertController {
}
@PostMapping("/full-task")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:convert:create", description = "创建全量转换任务", allowSuper = true)
public ApiResponse<PddOrderFullConvertTaskVO> createFullTask(
@Valid @RequestBody PddOrderFullConvertTaskCreateDTO dto) {
PddOrderSyncShopContext ctx = contextResolver.resolveForCurrentCompany(dto.getShopId());
@@ -63,7 +63,7 @@ public class PddOrderConvertController {
}
@GetMapping("/full-task/list")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:convert:read", description = "查询全量转换任务", allowSuper = true)
public ApiResponse<List<PddOrderFullConvertTaskVO>> listFullTasks(
@RequestParam Long shopId,
@RequestParam(required = false, defaultValue = "20") Integer limit) {
@@ -47,7 +47,7 @@ public class PddOrderSyncController {
}
@PostMapping("/day")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderFullSyncTaskVO> syncDay(@Valid @RequestBody PddOrderSyncDayDTO dto) {
PddOrderFullSyncTaskCreateDTO create = new PddOrderFullSyncTaskCreateDTO();
create.setShopId(dto.getShopId());
@@ -57,7 +57,7 @@ public class PddOrderSyncController {
}
@PostMapping("/bootstrap")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderFullSyncTaskVO> bootstrap(
@RequestParam Long shopId,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
@@ -70,7 +70,7 @@ public class PddOrderSyncController {
}
@PostMapping("/incremental")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderSyncResultVO> incremental(
@RequestParam Long shopId) {
PddOrderSyncShopContext ctx = contextResolver.resolveForCurrentCompany(shopId);
@@ -86,27 +86,27 @@ public class PddOrderSyncController {
}
@PostMapping("/repair")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderSyncResultVO> repair(@Valid @RequestBody PddOrderRepairDTO dto) {
return ApiResponse.success("补单完成", pddOrderSyncService.repair(dto));
}
@PostMapping("/full-task")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderFullSyncTaskVO> createFullTask(
@Valid @RequestBody PddOrderFullSyncTaskCreateDTO dto) {
return ApiResponse.success("任务已入队", fullSyncTaskService.createTask(dto));
}
@GetMapping("/full-task/latest")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderFullSyncTaskVO> latestFullTask(
@RequestParam Long shopId) {
return ApiResponse.success(fullSyncTaskService.latestTask(shopId));
}
@GetMapping("/full-task/list")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<List<PddOrderFullSyncTaskVO>> listFullTasks(
@RequestParam Long shopId,
@RequestParam(required = false, defaultValue = "20") Integer limit) {
@@ -114,39 +114,39 @@ public class PddOrderSyncController {
}
@GetMapping("/full-task/{taskId}")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderFullSyncTaskVO> getFullTask(@PathVariable Long taskId) {
return ApiResponse.success(fullSyncTaskService.getTask(taskId));
}
@PostMapping("/full-task/{taskId}/cancel")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderFullSyncTaskVO> cancelFullTask(@PathVariable Long taskId) {
return ApiResponse.success("已取消", fullSyncTaskService.cancelTask(taskId));
}
@PostMapping("/full-task/{taskId}/resume")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderFullSyncTaskVO> resumeFullTask(@PathVariable Long taskId) {
return ApiResponse.success("已续跑入队", fullSyncTaskService.resumeTask(taskId));
}
@PostMapping("/status/batch")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<List<PddOrderSyncShopStatusVO>> batchStatus(
@Valid @RequestBody PddOrderSyncStatusBatchDTO dto) {
return ApiResponse.success(fullSyncTaskService.batchStatus(dto.getShopIds()));
}
@PostMapping("/incremental/toggle")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderIncrementalStatusVO> toggleIncremental(
@Valid @RequestBody PddOrderIncrementalToggleDTO dto) {
return ApiResponse.success(fullSyncTaskService.toggleIncremental(dto));
}
@GetMapping("/incremental/status")
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
@RequirePermission(value = "channel:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
public ApiResponse<PddOrderIncrementalStatusVO> incrementalStatus(
@RequestParam Long shopId) {
return ApiResponse.success(fullSyncTaskService.incrementalStatus(shopId));
@@ -23,21 +23,21 @@ public class PddShopController {
}
@PostMapping("/create")
@RequirePermission(value = "channel:pdd:shop:manage", description = "创建拼多多店铺", allowSuper = true)
@RequirePermission(value = "channel:pdd:shop:create", description = "创建拼多多店铺", allowSuper = true)
public ApiResponse<PddShopVO> createPddShop(@Valid @RequestBody CreatePddShopDTO createPddShopDTO) {
PddShopVO vo = pddShopService.createPddShop(createPddShopDTO);
return ApiResponse.success("创建成功", vo);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "channel:pdd:shop:manage", description = "更新拼多多店铺", allowSuper = true)
@RequirePermission(value = "channel:pdd:shop:update", description = "更新拼多多店铺", allowSuper = true)
public ApiResponse<PddShopVO> updatePddShop(@Valid @RequestBody UpdatePddShopDTO updatePddShopDTO, @PathVariable Long id) {
PddShopVO vo = pddShopService.updatePddShop(updatePddShopDTO, id);
return ApiResponse.success("更新成功", vo);
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "channel:pdd:shop:manage", description = "删除拼多多店铺", allowSuper = true)
@RequirePermission(value = "channel:pdd:shop:delete", description = "删除拼多多店铺", allowSuper = true)
public ApiResponse<Void> deletePddShop(@PathVariable Long id) {
pddShopService.deletePddShop(id);
return ApiResponse.success("删除成功");
@@ -26,14 +26,14 @@ public class ImportMappingController {
}
@PostMapping("/create")
@RequirePermission(value = "data:import", description = "创建导入映射模板", allowSuper = true)
@RequirePermission(value = "data:import-mapping:create", description = "创建导入映射模板", allowSuper = true)
public ApiResponse<ImportMappingVO> createImportMapping(@Valid @RequestBody CreateImportMappingDTO createImportMappingDTO) {
ImportMappingVO importMappingVO = importMappingService.createImportMapping(createImportMappingDTO);
return ApiResponse.success("导入映射模板创建成功", importMappingVO);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "data:import", description = "更新导入映射模板", allowSuper = true)
@RequirePermission(value = "data:import-mapping:update", description = "更新导入映射模板", allowSuper = true)
public ApiResponse<ImportMappingVO> updateImportMapping(
@Valid @RequestBody UpdateImportMappingDTO updateImportMappingDTO,
@PathVariable Long id) {
@@ -42,7 +42,7 @@ public class ImportMappingController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "data:import", description = "删除导入映射模板", allowSuper = true)
@RequirePermission(value = "data:import-mapping:delete", description = "删除导入映射模板", allowSuper = true)
public ApiResponse<Void> deleteImportMapping(
@PathVariable Long id) {
importMappingService.deleteImportMapping(id);
@@ -50,7 +50,7 @@ public class ImportMappingController {
}
@PostMapping("/list")
@RequirePermission(value = "data:import", description = "查询导入映射模板列表", allowSuper = true)
@RequirePermission(value = "data:import-mapping:read", description = "查询导入映射模板列表", allowSuper = true)
public ApiResponse<PageResultVO<ImportMappingVO>> getImportMappingPage(
@Valid @RequestBody PageQueryDTO<ImportMappingFilterDTO> pageQueryDTO) {
PageResultVO<ImportMappingVO> result = importMappingService.getImportMappingPage(pageQueryDTO);
@@ -25,14 +25,14 @@ public class ImportTaskController {
}
@PostMapping("/create")
@RequirePermission(value = "data:import", description = "创建导入任务", allowSuper = true)
@RequirePermission(value = "data:import:create", description = "创建导入任务", allowSuper = true)
public ApiResponse<ImportTaskVO> createImportTask(@Valid @RequestBody CreateImportTaskDTO createImportTaskDTO) {
ImportTaskVO importTaskVO = importTaskService.createImportTask(createImportTaskDTO);
return ApiResponse.success("导入任务创建成功", importTaskVO);
}
@PostMapping("/list")
@RequirePermission(value = "data:import", description = "查询导入任务列表", allowSuper = true)
@RequirePermission(value = "data:import:read", description = "查询导入任务列表", allowSuper = true)
public ApiResponse<PageResultVO<ImportTaskVO>> getImportTaskPage(
@Valid @RequestBody PageQueryDTO<ImportTaskFilterDTO> pageQueryDTO) {
PageResultVO<ImportTaskVO> result = importTaskService.getImportTaskPage(pageQueryDTO);
@@ -28,14 +28,14 @@ public class CategoryController {
}
@PostMapping("/create")
@RequirePermission(value = "ec:product:category:manage", description = "创建类目", allowSuper = true)
@RequirePermission(value = "ec:product:category:create", description = "创建类目", allowSuper = true)
public ApiResponse<CategoryVO> createCategory(@Valid @RequestBody CreateCategoryDTO createCategoryDTO) {
CategoryVO categoryVO = categoryService.createCategory(createCategoryDTO);
return ApiResponse.success("类目创建成功", categoryVO);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "ec:product:category:manage", description = "更新类目", allowSuper = true)
@RequirePermission(value = "ec:product:category:update", description = "更新类目", allowSuper = true)
public ApiResponse<CategoryVO> updateCategory(@Valid @RequestBody UpdateCategoryDTO updateCategoryDTO,
@PathVariable Long id) {
CategoryVO categoryVO = categoryService.updateCategory(updateCategoryDTO, id);
@@ -43,7 +43,7 @@ public class CategoryController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "ec:product:category:manage", description = "删除类目", allowSuper = true)
@RequirePermission(value = "ec:product:category:delete", description = "删除类目", allowSuper = true)
public ApiResponse<Void> deleteCategory(
@PathVariable Long id) {
categoryService.deleteCategory(id);
@@ -32,14 +32,14 @@ public class ShopController {
}
@PostMapping("/create")
@RequirePermission(value = "ec:shop:manage", description = "创建店铺", allowSuper = true)
@RequirePermission(value = "ec:shop:create", description = "创建店铺", allowSuper = true)
public ApiResponse<ShopVO> createShop(@Valid @RequestBody CreateShopDTO createShopDTO) {
ShopVO shopVO = shopService.createShop(createShopDTO);
return ApiResponse.success("店铺创建成功", shopVO);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "ec:shop:manage", description = "更新店铺", allowSuper = true)
@RequirePermission(value = "ec:shop:update", description = "更新店铺", allowSuper = true)
public ApiResponse<ShopVO> updateShop(@Valid @RequestBody UpdateShopDTO updateShopDTO,
@PathVariable Long id) {
ShopVO shopVO = shopService.updateShop(updateShopDTO, id);
@@ -47,7 +47,7 @@ public class ShopController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "ec:shop:manage", description = "删除店铺", allowSuper = true)
@RequirePermission(value = "ec:shop:delete", description = "删除店铺", allowSuper = true)
public ApiResponse<Void> deleteShop(
@PathVariable Long id) {
shopService.deleteShop(id);
@@ -70,7 +70,7 @@ public class ShopController {
}
@PostMapping("/upload-logo")
@RequirePermission(value = "ec:shop:manage", description = "上传店铺Logo", allowSuper = true)
@RequirePermission(value = "ec:shop:create", description = "上传店铺Logo", allowSuper = true)
public ApiResponse<SysFileUploadVO> uploadLogo(@RequestParam("file") MultipartFile file) {
// 检查是否为图片文件
if (!FileUploadUtils.isImageFile(file.getOriginalFilename())) {
@@ -26,14 +26,14 @@ public class ShopMonthlyTargetController {
}
@PostMapping("/create")
@RequirePermission(value = "ec:shop:manage", description = "创建店铺月销量目标", allowSuper = true)
@RequirePermission(value = "ec:shop:create", description = "创建店铺月销量目标", allowSuper = true)
public ApiResponse<ShopMonthlyTargetVO> createShopMonthlyTarget(@Valid @RequestBody CreateShopMonthlyTargetDTO createDTO) {
ShopMonthlyTargetVO vo = shopMonthlyTargetService.createShopMonthlyTarget(createDTO);
return ApiResponse.success("店铺月销量目标创建成功", vo);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "ec:shop:manage", description = "更新店铺月销量目标", allowSuper = true)
@RequirePermission(value = "ec:shop:update", description = "更新店铺月销量目标", allowSuper = true)
public ApiResponse<ShopMonthlyTargetVO> updateShopMonthlyTarget(@Valid @RequestBody UpdateShopMonthlyTargetDTO updateDTO,
@PathVariable Long id) {
ShopMonthlyTargetVO vo = shopMonthlyTargetService.updateShopMonthlyTarget(updateDTO, id);
@@ -41,7 +41,7 @@ public class ShopMonthlyTargetController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "ec:shop:manage", description = "删除店铺月销量目标", allowSuper = true)
@RequirePermission(value = "ec:shop:delete", description = "删除店铺月销量目标", allowSuper = true)
public ApiResponse<Void> deleteShopMonthlyTarget(
@PathVariable Long id) {
shopMonthlyTargetService.deleteShopMonthlyTarget(id);
@@ -25,14 +25,14 @@ public class OpenApiKeyController {
private final OpenApiKeyService openApiKeyService;
@PostMapping("/create")
@RequirePermission(value = "open:api-key:manage", description = "创建 API Key", allowSuper = true)
@RequirePermission(value = "open:api-key:create", description = "创建 API Key", allowSuper = true)
public ApiResponse<CreateOpenApiKeyResultVO> createKey(@Valid @RequestBody CreateOpenApiKeyDTO dto) {
CreateOpenApiKeyResultVO result = openApiKeyService.createKey(dto);
return ApiResponse.success("API Key 创建成功", result);
}
@GetMapping("/list")
@RequirePermission(value = "open:api-key:manage", description = "查询 API Key 列表", allowSuper = true)
@RequirePermission(value = "open:api-key:read", description = "查询 API Key 列表", allowSuper = true)
public ApiResponse<List<OpenApiKeyVO>> listKeys(OpenApiKeyFilterDTO filter) {
List<OpenApiKeyVO> list = openApiKeyService.listKeys(filter);
return ApiResponse.success("获取 API Key 列表成功", list);
@@ -40,27 +40,27 @@ public class OpenApiKeyController {
/** 当前公司开放域权限树(排除 api-key 管理;仅 api 叶子可绑定) */
@GetMapping("/available-permissions")
@RequirePermission(value = "open:api-key:manage", description = "查询可绑定开放权限", allowSuper = true)
@RequirePermission(value = "open:api-key:read", description = "查询可绑定开放权限", allowSuper = true)
public ApiResponse<List<OpenApiAvailablePermissionVO>> getAvailablePermissions() {
return ApiResponse.success("获取可绑定权限成功", openApiKeyService.getAvailablePermissions());
}
@PutMapping("/{id}/disable")
@RequirePermission(value = "open:api-key:manage", description = "停用 API Key", allowSuper = true)
@RequirePermission(value = "open:api-key:update", description = "停用 API Key", allowSuper = true)
public ApiResponse<Void> disableKey(@PathVariable Long id) {
openApiKeyService.disableKey(id);
return ApiResponse.success("API Key 已停用");
}
@PutMapping("/{id}/enable")
@RequirePermission(value = "open:api-key:manage", description = "启用 API Key", allowSuper = true)
@RequirePermission(value = "open:api-key:update", description = "启用 API Key", allowSuper = true)
public ApiResponse<Void> enableKey(@PathVariable Long id) {
openApiKeyService.enableKey(id);
return ApiResponse.success("API Key 已启用");
}
@DeleteMapping("/{id}")
@RequirePermission(value = "open:api-key:manage", description = "删除 API Key", allowSuper = true)
@RequirePermission(value = "open:api-key:delete", description = "删除 API Key", allowSuper = true)
public ApiResponse<Void> deleteKey(@PathVariable Long id) {
openApiKeyService.deleteKey(id);
return ApiResponse.success("API Key 已删除");
@@ -15,7 +15,7 @@ import top.xyquan.ecomdmbbackend.modules.org.company.account.service.AccountServ
/**
* 公司账户管理控制器
* <p>
* 供公司拥有者管理本公司成员账户;需 org:company:manage 权限,超管可访问全部接口。
* 供公司拥有者管理本公司成员账户;需 org:account:* 权限,超管可访问全部接口。
*/
@RestController
@RequestMapping("/api/company/account")
@@ -29,7 +29,7 @@ public class AccountController {
/** 创建账户:手机号已注册则拉入公司,未注册则新建用户(密码必填) */
@PostMapping("/create")
@RequirePermission(value = "org:company:manage", description = "创建账户", allowSuper = true)
@RequirePermission(value = "org:account:create", description = "创建账户", allowSuper = true)
public ApiResponse<CompanyAccountVO> createAccountForCompany(@Valid @RequestBody CreateAccountDTO createAccountDTO) {
CompanyAccountVO accountVO = accountService.createAccountForCompany(createAccountDTO);
return ApiResponse.success("账户创建成功", accountVO);
@@ -37,7 +37,7 @@ public class AccountController {
/** 分页查询当前公司成员对应的账户列表 */
@PostMapping("/list")
@RequirePermission(value = "org:company:manage", description = "查询账户列表", allowSuper = true)
@RequirePermission(value = "org:account:read", description = "查询账户列表", allowSuper = true)
public ApiResponse<PageResultVO<CompanyAccountVO>> getAccountPageForCompany(@Valid @RequestBody PageQueryDTO<AccountFilterDTO> pageQuery) {
PageResultVO<CompanyAccountVO> pageResult = accountService.getAccountPageForCompany(pageQuery);
return ApiResponse.success("获取账户列表成功", pageResult);
@@ -45,7 +45,7 @@ public class AccountController {
/** 更新账户基本信息及职位、部门关联 */
@PutMapping("/update/{accountId}")
@RequirePermission(value = "org:company:manage", description = "更新账户", allowSuper = true)
@RequirePermission(value = "org:account:update", description = "更新账户", allowSuper = true)
public ApiResponse<CompanyAccountVO> updateAccount(
@PathVariable Long accountId,
@Valid @RequestBody UpdateAccountDTO updateAccountDTO) {
@@ -55,7 +55,7 @@ public class AccountController {
/** 逻辑删除:停用 sys_user 并移除公司/部门成员关系 */
@DeleteMapping("/delete/{accountId}")
@RequirePermission(value = "org:company:manage", description = "删除账户", allowSuper = true)
@RequirePermission(value = "org:account:delete", description = "删除账户", allowSuper = true)
public ApiResponse<Void> deleteAccount(
@PathVariable Long accountId) {
accountService.deleteAccount(accountId);
@@ -63,7 +63,7 @@ public class AccountController {
}
@GetMapping("/detail/{accountId}")
@RequirePermission(value = "org:company:manage", description = "获取账户详情", allowSuper = true)
@RequirePermission(value = "org:account:read", description = "获取账户详情", allowSuper = true)
public ApiResponse<CompanyAccountVO> getAccountDetail(
@PathVariable Long accountId) {
CompanyAccountVO accountVO = accountService.getAccountDetail(accountId);
@@ -26,21 +26,21 @@ public class SuperAccountController {
}
@PostMapping("/create")
@RequirePermission(value = "org:company:manage", description = "创建账户", allowSuper = true)
@RequirePermission(value = "org:account:create", description = "创建账户", allowSuper = true)
public ApiResponse<CompanyAccountVO> createAccount(@Valid @RequestBody SuperCreateAccountDTO superCreateAccountDTO) {
CompanyAccountVO accountVO = superAccountService.createAccount(superCreateAccountDTO);
return ApiResponse.success("账户创建成功", accountVO);
}
@PostMapping("/list")
@RequirePermission(value = "org:company:manage", description = "查询账户列表", allowSuper = true)
@RequirePermission(value = "org:account:read", description = "查询账户列表", allowSuper = true)
public ApiResponse<PageResultVO<CompanyAccountVO>> getAccountPage(@Valid @RequestBody PageQueryDTO<AccountFilterDTO> pageQuery) {
PageResultVO<CompanyAccountVO> pageResult = superAccountService.getAccountPage(pageQuery);
return ApiResponse.success("获取账户列表成功", pageResult);
}
@PutMapping("/update/{accountId}")
@RequirePermission(value = "org:company:manage", description = "更新账户", allowSuper = true)
@RequirePermission(value = "org:account:update", description = "更新账户", allowSuper = true)
public ApiResponse<CompanyAccountVO> updateAccount(
@PathVariable Long accountId,
@Valid @RequestBody SuperUpdateAccountDTO superUpdateAccountDTO) {
@@ -49,7 +49,7 @@ public class SuperAccountController {
}
@DeleteMapping("/delete/{accountId}")
@RequirePermission(value = "org:company:manage", description = "删除账户", allowSuper = true)
@RequirePermission(value = "org:account:delete", description = "删除账户", allowSuper = true)
public ApiResponse<Void> deleteAccount(
@PathVariable Long accountId) {
superAccountService.deleteAccount(accountId);
@@ -57,7 +57,7 @@ public class SuperAccountController {
}
@GetMapping("/detail/{accountId}")
@RequirePermission(value = "org:company:manage", description = "查询账户详情", allowSuper = true)
@RequirePermission(value = "org:account:read", description = "查询账户详情", allowSuper = true)
public ApiResponse<CompanyAccountVO> getAccountDetail(
@PathVariable Long accountId) {
CompanyAccountVO accountVO = superAccountService.getAccountDetail(accountId);
@@ -29,14 +29,14 @@ public class CompanyMemberController {
}
@PostMapping("/create")
@RequirePermission(value = "org:member:manage", description = "创建公司成员", allowSuper = true)
@RequirePermission(value = "org:member:create", description = "创建公司成员", allowSuper = true)
public ApiResponse<CompanyMemberVO> create(@Valid @RequestBody CreateCompanyMemberDTO dto) {
CompanyMemberVO vo = companyMemberService.create(dto);
return ApiResponse.success("公司成员创建成功", vo);
}
@PutMapping("/update-position/{memberId}")
@RequirePermission(value = "org:member:manage", description = "更新成员职位", allowSuper = true)
@RequirePermission(value = "org:member:update", description = "更新成员职位", allowSuper = true)
public ApiResponse<CompanyMemberVO> updatePosition(
@PathVariable Long memberId,
@RequestParam Long positionId) {
@@ -45,7 +45,7 @@ public class CompanyMemberController {
}
@PutMapping("/change-role/{memberId}")
@RequirePermission(value = "org:member:manage", description = "变更成员角色", allowSuper = true)
@RequirePermission(value = "org:member:update", description = "变更成员角色", allowSuper = true)
public ApiResponse<CompanyMemberVO> changeRole(
@PathVariable Long memberId,
@RequestParam String role) {
@@ -54,7 +54,7 @@ public class CompanyMemberController {
}
@DeleteMapping("/remove/{memberId}")
@RequirePermission(value = "org:member:manage", description = "移除成员", allowSuper = true)
@RequirePermission(value = "org:member:delete", description = "移除成员", allowSuper = true)
public ApiResponse<Void> remove(@PathVariable Long memberId) {
companyMemberService.remove(memberId);
return ApiResponse.success("成员移除成功");
@@ -28,14 +28,14 @@ public class DepartmentController {
}
@PostMapping("/create")
@RequirePermission(value = "org:department:manage", description = "创建部门", allowSuper = true)
@RequirePermission(value = "org:department:create", description = "创建部门", allowSuper = true)
public ApiResponse<DepartmentVO> createDepartment(@Valid @RequestBody CreateDepartmentDTO createDepartmentDTO) {
DepartmentVO departmentVO = departmentService.createDepartment(createDepartmentDTO);
return ApiResponse.success("部门创建成功", departmentVO);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "org:department:manage", description = "更新部门", allowSuper = true)
@RequirePermission(value = "org:department:update", description = "更新部门", allowSuper = true)
public ApiResponse<DepartmentVO> updateDepartment(@Valid @RequestBody UpdateDepartmentDTO updateDepartmentDTO,
@PathVariable Long id) {
DepartmentVO departmentVO = departmentService.updateDepartment(updateDepartmentDTO, id);
@@ -43,7 +43,7 @@ public class DepartmentController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "org:department:manage", description = "删除部门", allowSuper = true)
@RequirePermission(value = "org:department:delete", description = "删除部门", allowSuper = true)
public ApiResponse<Void> deleteDepartment(
@PathVariable Long id) {
departmentService.deleteDepartment(id);
@@ -25,14 +25,14 @@ public class DepartmentMemberController {
}
@PostMapping("/add")
@RequirePermission(value = "org:department:manage", description = "添加部门成员", allowSuper = true)
@RequirePermission(value = "org:department:update", description = "添加部门成员", allowSuper = true)
public ApiResponse<DepartmentMemberVO> addMember(@Valid @RequestBody AddDepartmentMemberDTO dto) {
DepartmentMemberVO vo = departmentMemberService.addMember(dto);
return ApiResponse.success("部门成员添加成功", vo);
}
@PostMapping("/remove")
@RequirePermission(value = "org:department:manage", description = "移除部门成员", allowSuper = true)
@RequirePermission(value = "org:department:update", description = "移除部门成员", allowSuper = true)
public ApiResponse<Void> removeMember(@Valid @RequestBody RemoveDepartmentMemberDTO dto) {
departmentMemberService.removeMember(dto.getDepartmentId(), dto.getUserId());
return ApiResponse.success("部门成员移除成功");
@@ -26,14 +26,14 @@ public class PositionController {
}
@PostMapping("/create")
@RequirePermission(value = "org:position:manage", description = "创建岗位", allowSuper = true)
@RequirePermission(value = "org:position:create", description = "创建岗位", allowSuper = true)
public ApiResponse<PositionVO> createPosition(@Valid @RequestBody CreatePositionDTO createPositionDTO) {
PositionVO positionVO = positionService.createPosition(createPositionDTO);
return ApiResponse.success("岗位创建成功", positionVO);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "org:position:manage", description = "更新岗位", allowSuper = true)
@RequirePermission(value = "org:position:update", description = "更新岗位", allowSuper = true)
public ApiResponse<PositionVO> updatePosition(@Valid @RequestBody UpdatePositionDTO updatePositionDTO,
@PathVariable Long id) {
PositionVO positionVO = positionService.updatePosition(updatePositionDTO, id);
@@ -41,7 +41,7 @@ public class PositionController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "org:position:manage", description = "删除岗位", allowSuper = true)
@RequirePermission(value = "org:position:delete", description = "删除岗位", allowSuper = true)
public ApiResponse<Void> deletePosition(
@PathVariable Long id) {
positionService.deletePosition(id);
@@ -27,14 +27,14 @@ public class PlanController {
}
@PostMapping("/create")
@RequirePermission(value = "sys:company:manage", description = "创建套餐", allowSuper = true)
@RequirePermission(value = "sys:plan:create", description = "创建套餐", allowSuper = true)
public ApiResponse<PlanVO> createPlan(@Valid @RequestBody CreatePlanDTO createPlanDTO) {
PlanVO planVO = planService.createPlan(createPlanDTO);
return ApiResponse.success("套餐创建成功", planVO);
}
@PutMapping("/update/{planId}")
@RequirePermission(value = "sys:company:manage", description = "更新套餐", allowSuper = true)
@RequirePermission(value = "sys:plan:update", description = "更新套餐", allowSuper = true)
public ApiResponse<PlanVO> updatePlan(@Valid @RequestBody UpdatePlanDTO updatePlanDTO,
@PathVariable Long planId) {
PlanVO planVO = planService.updatePlan(updatePlanDTO, planId);
@@ -42,7 +42,7 @@ public class PlanController {
}
@DeleteMapping("/delete/{planId}")
@RequirePermission(value = "sys:company:manage", description = "删除套餐", allowSuper = true)
@RequirePermission(value = "sys:plan:delete", description = "删除套餐", allowSuper = true)
public ApiResponse<Void> deletePlan(
@PathVariable Long planId) {
planService.deletePlan(planId);
@@ -50,7 +50,7 @@ public class PlanController {
}
@PostMapping("/list")
@RequirePermission(value = "sys:company:manage", description = "查询套餐列表", allowSuper = true)
@RequirePermission(value = "sys:plan:read", description = "查询套餐列表", allowSuper = true)
public ApiResponse<PageResultVO<PlanListVO>> getPlanPage(
@Valid @RequestBody PageQueryDTO<PlanFilterDTO> pageQueryDTO) {
PageResultVO<PlanListVO> result = planService.getPlanPage(pageQueryDTO);
@@ -27,14 +27,14 @@ public class PlanPricingController {
}
@PostMapping("/create")
@RequirePermission(value = "system:company:manage", description = "创建定价", allowSuper = true)
@RequirePermission(value = "sys:plan-pricing:create", description = "创建定价", allowSuper = true)
public ApiResponse<PlanPricingVO> createPlanPricing(@Valid @RequestBody CreatePlanPricingDTO createPlanPricingDTO) {
PlanPricingVO planPricingVO = planPricingService.createPlanPricing(createPlanPricingDTO);
return ApiResponse.success("套餐定价创建成功", planPricingVO);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "system:company:manage", description = "更新定价", allowSuper = true)
@RequirePermission(value = "sys:plan-pricing:update", description = "更新定价", allowSuper = true)
public ApiResponse<PlanPricingVO> updatePlanPricing(@Valid @RequestBody UpdatePlanPricingDTO updatePlanPricingDTO,
@PathVariable Long id) {
PlanPricingVO planPricingVO = planPricingService.updatePlanPricing(updatePlanPricingDTO, id);
@@ -42,7 +42,7 @@ public class PlanPricingController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "system:company:manage", description = "删除定价", allowSuper = true)
@RequirePermission(value = "sys:plan-pricing:delete", description = "删除定价", allowSuper = true)
public ApiResponse<Void> deletePlanPricing(
@PathVariable Long id) {
planPricingService.deletePlanPricing(id);
@@ -50,7 +50,7 @@ public class PlanPricingController {
}
@PostMapping("/list")
@RequirePermission(value = "system:company:manage", description = "查询定价列表", allowSuper = true)
@RequirePermission(value = "sys:plan-pricing:read", description = "查询定价列表", allowSuper = true)
public ApiResponse<PageResultVO<PlanPricingListVO>> getPlanPricingPage(
@Valid @RequestBody PageQueryDTO<PlanPricingFilterDTO> pageQueryDTO) {
PageResultVO<PlanPricingListVO> result = planPricingService.getPlanPricingPage(pageQueryDTO);
@@ -27,7 +27,7 @@ public class SubscriptionController {
}
@PostMapping("/create")
@RequirePermission(value = "sys:company:manage", description = "创建订阅", allowSuper = true)
@RequirePermission(value = "sys:subscription:create", description = "创建订阅", allowSuper = true)
public ApiResponse<SubscriptionVO> createSubscription(
@Valid @RequestBody CreateSubscriptionDTO createSubscriptionDTO) {
SubscriptionVO subscriptionVO = subscriptionService.createSubscription(createSubscriptionDTO);
@@ -35,7 +35,7 @@ public class SubscriptionController {
}
@PutMapping("/update/{id}")
@RequirePermission(value = "sys:company:manage", description = "更新订阅", allowSuper = true)
@RequirePermission(value = "sys:subscription:update", description = "更新订阅", allowSuper = true)
public ApiResponse<SubscriptionVO> updateSubscription(
@Valid @RequestBody UpdateSubscriptionDTO updateSubscriptionDTO,
@PathVariable Long id) {
@@ -44,7 +44,7 @@ public class SubscriptionController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "sys:company:manage", description = "删除订阅", allowSuper = true)
@RequirePermission(value = "sys:subscription:delete", description = "删除订阅", allowSuper = true)
public ApiResponse<Void> deleteSubscription(
@PathVariable Long id) {
subscriptionService.deleteSubscription(id);
@@ -52,7 +52,7 @@ public class SubscriptionController {
}
@PostMapping("/list")
@RequirePermission(value = "sys:company:manage", description = "查询订阅列表", allowSuper = true)
@RequirePermission(value = "sys:subscription:read", description = "查询订阅列表", allowSuper = true)
public ApiResponse<PageResultVO<SubscriptionListVO>> getSubscriptionPage(
@Valid @RequestBody PageQueryDTO<SubscriptionFilterDTO> pageQueryDTO) {
PageResultVO<SubscriptionListVO> result = subscriptionService.getSubscriptionPage(pageQueryDTO);
@@ -35,14 +35,14 @@ public class SystemLicenseController {
}
@PutMapping("/license")
@RequirePermission(value = "sys:license:manage", description = "激活或更新授权")
@RequirePermission(value = "sys:license:update", description = "激活或更新授权")
public ApiResponse<LicenseSummaryVO> updateLicense(@Valid @RequestBody ActivateLicenseDTO dto) {
LicenseSummaryVO summary = licenseService.updateLicense(dto);
return ApiResponse.success("授权更新成功", summary);
}
@PostMapping("/license/activate")
@RequirePermission(value = "sys:license:manage", description = "激活授权")
@RequirePermission(value = "sys:license:update", description = "激活授权")
public ApiResponse<LicenseSummaryVO> activateLicense(@Valid @RequestBody ActivateLicenseDTO dto) {
LicenseSummaryVO summary = licenseService.updateLicense(dto);
return ApiResponse.success("授权激活成功", summary);
@@ -23,14 +23,14 @@ public class MenuPermissionController {
}
@PostMapping("/add")
@RequirePermission(value = "system:menu:update", description = "添加菜单权限映射", allowSuper = true)
@RequirePermission(value = "sys:menu:update", description = "添加菜单权限映射", allowSuper = true)
public ApiResponse<MenuPermissionVO> addMenuPermission(@Valid @RequestBody AddMenuPermissionDTO addMenuPermissionDTO) {
MenuPermissionVO menuPermissionVO = menuPermissionService.addMenuPermission(addMenuPermissionDTO);
return ApiResponse.success("菜单权限映射添加成功", menuPermissionVO);
}
@PostMapping("/remove")
@RequirePermission(value = "system:menu:update", description = "删除菜单权限映射", allowSuper = true)
@RequirePermission(value = "sys:menu:update", description = "删除菜单权限映射", allowSuper = true)
public ApiResponse<Void> removeMenuPermission(@Valid @RequestBody RemoveMenuPermissionDTO removeMenuPermissionDTO) {
menuPermissionService.removeMenuPermission(removeMenuPermissionDTO);
return ApiResponse.success("菜单权限映射删除成功");
@@ -32,14 +32,14 @@ public class PermissionController {
}
@PostMapping("/create")
@RequirePermission(value = "sys:permission:manage", description = "创建权限", allowSuper = true)
@RequirePermission(value = "sys:permission:create", description = "创建权限", allowSuper = true)
public ApiResponse<PermissionVO> createPermission(@Valid @RequestBody CreatePermissionDTO createPermissionDTO) {
PermissionVO permissionVO = permissionService.createPermission(createPermissionDTO);
return ApiResponse.success("权限创建成功", permissionVO);
}
@PutMapping("/update/{id}")
@RequirePermission(value = "sys:permission:manage", description = "更新权限", allowSuper = true)
@RequirePermission(value = "sys:permission:update", description = "更新权限", allowSuper = true)
public ApiResponse<PermissionVO> updatePermission(@Valid @RequestBody UpdatePermissionDTO updatePermissionDTO,
@PathVariable Long id) {
PermissionVO permissionVO = permissionService.updatePermission(updatePermissionDTO, id);
@@ -47,7 +47,7 @@ public class PermissionController {
}
@DeleteMapping("/delete/{id}")
@RequirePermission(value = "sys:permission:manage", description = "删除权限", allowSuper = true)
@RequirePermission(value = "sys:permission:delete", description = "删除权限", allowSuper = true)
public ApiResponse<Void> deletePermission(
@PathVariable Long id) {
permissionService.deletePermission(id);
@@ -108,7 +108,7 @@ public class PermissionController {
}
@PutMapping("/sort")
@RequirePermission(value = "sys:permission:manage", description = "批量更新权限排序与父级", allowSuper = true)
@RequirePermission(value = "sys:permission:update", description = "批量更新权限排序与父级", allowSuper = true)
public ApiResponse<Void> batchSortPermission(
@RequestBody @Valid BatchSortPermissionDTO dto) {
permissionService.batchSortPermission(dto);
File diff suppressed because it is too large Load Diff
@@ -13,12 +13,17 @@ export const overridesPreferences = defineOverridesPreferences({
enableRefreshToken: true, // 启用token自动刷新功能 🔄
defaultHomePath: '/welcome', // 设置默认首页路由
defaultAvatar: '/cd-logo.png',
layout: 'sidebar-mixed-nav',
},
copyright: {
enable: false,
companyName: '',
companySiteLink: '',
},
sidebar: {
collapsed: true,
expandOnHover: false,
},
navigation: {
accordion: false, // 关闭手风琴模式,允许多个菜单同时展开
},
@@ -581,13 +581,6 @@ async function handleManualRefresh() {
const activeTab = ref('finance');
function handleShopNavigate(shopId: number) {
router.push({
path: `/ec/shop/overview/${shopId}`,
query: buildOverviewRouteQuery(dateRange.value),
});
}
function handleProductNavigate(productId: number) {
const shopId = parseSelectedShopId();
router.push({
@@ -913,7 +906,6 @@ onUnmounted(() => {
:finance="financePanel"
:multi-analysis="EMPTY_MULTI"
:summary-tables="summaryTablesPanel"
@navigate="handleShopNavigate"
@navigate-product="handleProductNavigate"
/>
</Spin>
@@ -30,7 +30,6 @@ const props = withDefaults(
},
);
const emit = defineEmits<{
(e: 'navigate', shopId: number): void;
(e: 'navigate-product', productId: number): void;
}>();
const activeMode = ref<'category' | 'platform' | 'product' | 'shop'>('shop');
@@ -194,7 +193,6 @@ async function handleProductExport() {
@update:selected-export-shop-ids="selectedExportShopIds = $event"
@toggle-shop-export-mode="shopExportMode = $event"
@export="handleShopExport"
@navigate="(id: number) => emit('navigate', id)"
/>
<PlatformSummaryCard
@@ -1,7 +1,6 @@
<script lang="ts" setup>
import type { CompanyOverviewVO } from '#/api/bi/overview';
import { createIconifyIcon } from '@vben/icons';
import { computed } from 'vue';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
@@ -15,8 +14,6 @@ import {
import { FINANCE_PANEL_SHELL } from '../constants/finance-ui';
const JumpIcon = createIconifyIcon('tdesign:jump');
defineOptions({ name: 'WorkbenchShopSummaryTable' });
interface Props {
@@ -34,7 +31,6 @@ interface Emits {
(e: 'update:selectedExportShopIds', ids: number[]): void;
(e: 'toggleShopExportMode', enabled: boolean): void;
(e: 'export'): void;
(e: 'navigate', shopId: number): void;
}
const props = withDefaults(defineProps<Props>(), {
@@ -288,11 +284,9 @@ const cellRoi = (v: number | null | undefined) =>
:class="shopExportMode ? 'border-l-0' : ''"
>
<span
class="inline-flex cursor-pointer items-center gap-1 rounded-full bg-blue-50 dark:bg-blue-900/30 px-3 py-1 text-sm font-bold text-blue-600 dark:text-blue-400 transition-colors hover:text-blue-300 hover:underline"
@click="emit('navigate', shop.shopId as number)"
class="inline-flex items-center rounded-full bg-blue-50 px-3 py-1 text-sm font-bold text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"
>
{{ shop.shopName }}
<JumpIcon class="text-xs" />
</span>
</td>
<!-- 目标 -->
@@ -25,7 +25,6 @@ import {
defineOptions({ name: 'WorkbenchFinanceTab' });
const emit = defineEmits<{
(e: 'navigate', shopId: number): void;
(e: 'navigate-product', productId: number): void;
}>();
@@ -167,7 +166,6 @@ defineExpose({ redraw });
:platform-summary="platformOverview"
:category-summary="categoryOverview"
:product-summary="productOverview"
@navigate="(id: number) => emit('navigate', id)"
@navigate-product="(id: number) => emit('navigate-product', id)"
/>
</div>
@@ -4,6 +4,8 @@ import type { EchartsUIType } from '@vben/plugins/echarts';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import dayjs from 'dayjs';
import { FINANCE_PANEL_SHELL } from '#/views/bi/workbench/tabs/finance/constants/finance-ui';
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
interface Props {
@@ -205,12 +207,21 @@ defineExpose({ renderChart });
</script>
<template>
<div class="rounded-[20px] border border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8 shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px] xl:col-span-2">
<h3 class="mb-6 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
销售额与单量趋势分析
</h3>
<div class="h-[380px] w-full">
<EchartsUI ref="trendChartRef" />
<div :class="[FINANCE_PANEL_SHELL, 'xl:col-span-2']">
<div
class="border-b border-slate-100 px-5 pb-3.5 pt-5 md:px-6 md:pt-5 dark:border-b-[hsl(240deg_3.7%_22%)]"
>
<h3 class="text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
销售额与单量趋势
</h3>
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
双轴展示销售额与订单量,与上方 KPI 同一时间范围
</p>
</div>
<div class="px-5 py-4 md:px-6 md:py-5">
<div class="h-[320px] w-full">
<EchartsUI ref="trendChartRef" />
</div>
</div>
</div>
</template>
@@ -1,4 +1,6 @@
<script lang="ts" setup>
import { FINANCE_PANEL_SHELL } from '#/views/bi/workbench/tabs/finance/constants/finance-ui';
interface SkuSalesRankItem {
skuId?: number;
skuName?: string;
@@ -15,72 +17,80 @@ defineProps<Props>();
const formatAmount = (amount: number | undefined) => {
if (amount === undefined || amount === null) return '-';
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
return `¥${amount.toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}`;
};
function rankBadgeClass(idx: number) {
if (idx === 0) return 'bg-amber-50 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300';
if (idx === 1) return 'bg-slate-100 text-slate-600 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-slate-300';
if (idx === 2) return 'bg-orange-50 text-orange-700 dark:bg-orange-950/40 dark:text-orange-300';
return 'bg-slate-50 text-slate-500 dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]';
}
</script>
<template>
<div
class="flex flex-col rounded-[20px] border border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8 shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px]"
>
<h3 class="mb-1 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
各 SKU 销量 Top10
</h3>
<p class="mb-5 text-xs font-medium text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
按单量排序,与上方时间范围一致
</p>
<div :class="FINANCE_PANEL_SHELL">
<div
class="border-b border-slate-100 px-5 pb-3.5 pt-5 md:px-6 md:pt-5 dark:border-b-[hsl(240deg_3.7%_22%)]"
>
<h3 class="text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
各 SKU 销量 Top10
</h3>
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
按单量排序,与当前筛选时间范围一致
</p>
</div>
<div class="max-h-[380px] flex-1 space-y-2 overflow-y-auto pr-1">
<template v-if="data?.length">
<div
v-for="(row, idx) in data"
:key="row.skuId ?? `rank-${idx}`"
class="flex items-center gap-3 rounded-xl border border-slate-100/90 bg-slate-50/60 px-3 py-2.5 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/50%)]"
>
<span
class="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-sm font-black tabular-nums"
:class="
idx === 0
? 'bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-200'
: idx === 1
? 'bg-slate-200 text-slate-700 dark:bg-slate-600 dark:text-slate-100'
: idx === 2
? 'bg-orange-100 text-orange-900 dark:bg-orange-900/30 dark:text-orange-200'
: 'bg-slate-100 text-slate-500 dark:bg-slate-700 dark:text-slate-300'
"
<div class="px-5 py-4 md:px-6 md:py-5">
<div class="max-h-[320px] space-y-2 overflow-y-auto pr-1">
<template v-if="data?.length">
<div
v-for="(row, idx) in data"
:key="row.skuId ?? `rank-${idx}`"
class="flex items-center gap-3 rounded-[10px] border border-slate-200/90 bg-white px-3 py-2.5 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
>
{{ idx + 1 }}
</span>
<div class="min-w-0 flex-1">
<div
class="truncate text-sm font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
:title="row.skuName"
<span
class="flex h-7 w-7 shrink-0 items-center justify-center rounded-lg text-xs font-bold tabular-nums"
:class="rankBadgeClass(idx)"
>
{{ row.skuName || '-' }}
{{ idx + 1 }}
</span>
<div class="min-w-0 flex-1">
<div
class="truncate text-sm font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
:title="row.skuName"
>
{{ row.skuName || '-' }}
</div>
<div
v-if="row.skuCode"
class="truncate text-[11px] text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
>
{{ row.skuCode }}
</div>
</div>
<div
v-if="row.skuCode"
class="truncate text-[11px] text-slate-400 dark:text-[hsl(240deg_5%_55%)]"
>
{{ row.skuCode }}
</div>
</div>
<div class="shrink-0 text-right">
<div class="text-sm font-black tabular-nums text-indigo-600 dark:text-indigo-400">
{{ row.orderCount != null ? row.orderCount.toLocaleString('zh-CN') : '-' }}
<span class="text-[10px] font-semibold text-slate-400 dark:text-[hsl(240deg_5%_55%)]">单</span>
</div>
<div class="text-[11px] font-semibold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{ formatAmount(row.salesAmount) }}
<div class="shrink-0 text-right">
<div class="text-sm font-bold tabular-nums text-blue-600 dark:text-blue-400">
{{ row.orderCount != null ? row.orderCount.toLocaleString('zh-CN') : '-' }}
<span class="text-[10px] font-medium text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
单
</span>
</div>
<div class="text-[11px] font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{ formatAmount(row.salesAmount) }}
</div>
</div>
</div>
</template>
<div
v-else
class="flex h-[280px] items-center justify-center text-sm text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
>
暂无 SKU 数据
</div>
</template>
<div
v-else
class="flex flex-1 items-center justify-center py-16 text-sm text-slate-400 dark:text-[hsl(240deg_5%_55%)]"
>
暂无 SKU 数据
</div>
</div>
</div>
@@ -7,8 +7,12 @@ import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
import {
overviewTableHints,
salesTaxColumnHint,
storeOverviewHints,
} from '#/utils/overview-table-hints';
import { formatNumberCell } from '#/utils/overview-table-cells';
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
import { FINANCE_PANEL_SHELL } from '#/views/bi/workbench/tabs/finance/constants/finance-ui';
interface SkuData {
skuId: number;
@@ -33,7 +37,6 @@ interface SkuData {
interface Props {
data: SkuData[];
/** 后端合计行(含 orderCost),优先展示 */
footerTotal?: ProductOverviewVO.SkuSummaryTotal | null;
taxRate?: number;
}
@@ -49,9 +52,7 @@ const formatAmount = (amount: number | undefined) => {
};
const cellMoney = (v: number | null | undefined) =>
formatNumberCell(v, (n) =>
`¥${n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`,
);
formatNumberCell(v, formatAmount);
const cellRoi = (v: number | null | undefined) =>
formatNumberCell(v, (n) => n.toFixed(2));
@@ -60,12 +61,6 @@ const formatPercent = (value: number | undefined) => {
return `${value.toFixed(1)}%`;
};
const formatCount = (value: number | undefined) => {
if (value === undefined || value === null) return '-';
return value.toLocaleString('zh-CN');
};
/** 无后端合计时由行数据汇总(兼容旧数据) */
const computedFooter = computed(() => {
if (!props.data || props.data.length === 0) return null;
const total: SkuData = {
@@ -106,8 +101,9 @@ const computedFooter = computed(() => {
});
if (total.salesAmount > 0) {
total.averageOrderValue = total.salesAmount / total.orderCount;
total.feeRatio = (total.promotionFee / total.salesAmount) * 100;
const costBase = total.orderCost ?? total.productCost + total.shippingCost + total.otherCost;
total.feeRatio = total.promotionFee / total.salesAmount;
const costBase =
total.orderCost ?? total.productCost + total.shippingCost + total.otherCost;
total.roi =
costBase + total.promotionFee > 0
? (total.profitAfterTax / (costBase + total.promotionFee)) * 100
@@ -120,16 +116,16 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
</script>
<template>
<div
class="overflow-hidden rounded-[20px] border border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px]"
>
<div :class="FINANCE_PANEL_SHELL">
<div
class="flex items-center justify-between border-b border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white/40 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6"
class="flex flex-col items-start justify-between gap-4 border-b border-slate-100 p-5 md:flex-row md:items-center md:px-6 dark:border-b-[hsl(240deg_3.7%_22%)]"
>
<div>
<h3 class="text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">商品 SKU 销售汇总</h3>
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
各 SKU 经营明细:规模、成本及最终损益
<h3 class="text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
商品 SKU 销售汇总
</h3>
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
各 SKU 经营明细:规模、成本及最终损益(列序与工作台店铺汇总表对齐)
</p>
</div>
</div>
@@ -142,81 +138,105 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
<tr>
<th
rowspan="2"
class="sticky-col border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-5 text-base font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)] shadow-sm dark:shadow-none"
class="sticky-col border-b border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 text-base font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)] shadow-sm dark:shadow-none"
>
SKU 名称
SKU
</th>
<th
colspan="3"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] bg-blue-50/50 dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)] p-3 text-center text-blue-700 dark:text-blue-400"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
>
经营规模
经营规模维度
</th>
<th
colspan="7"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] bg-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400"
>
成本费用
成本费用维度
</th>
<th
colspan="5"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] bg-emerald-50/50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-3 text-center text-emerald-700 dark:text-emerald-400"
colspan="4"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] bg-emerald-50/50 dark:bg-[hsl(142deg_71.8%_29%)] p-3 text-center text-emerald-700 dark:text-emerald-200"
>
盈利分析
盈利分析维度
</th>
</tr>
<tr class="bg-slate-50/80 dark:bg-[hsl(240deg_3.7%_15.9%/80)] text-sm">
<tr class="bg-slate-50 dark:bg-[hsl(240deg_3.7%_15.9%)] text-sm">
<!-- 规模 -->
<th class="border-b border-l px-5 py-3 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<OverviewColumnHint :title="overviewTableHints.salesAmountShort">
销售额
<th
class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]"
>
<OverviewColumnHint :title="storeOverviewHints.salesAmount">
实际销售额
</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3">
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="overviewTableHints.orderCountSku">
订单量
单量
</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3">
<OverviewColumnHint :title="overviewTableHints.averageOrderValue">客单价</OverviewColumnHint>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.averageOrderValue">
客单价
</OverviewColumnHint>
</th>
<!-- 成本 -->
<th class="border-b border-l px-5 py-3">
<OverviewColumnHint :title="overviewTableHints.productCost">商品成本</OverviewColumnHint>
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.productCost">
商品成本
</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3">
<OverviewColumnHint :title="overviewTableHints.shippingCost">运费</OverviewColumnHint>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.shippingCost">
运费
</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3">
<OverviewColumnHint :title="overviewTableHints.otherCost">其他成本</OverviewColumnHint>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.otherCost">
其他成本
</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3 font-bold text-orange-800 dark:text-orange-300">
<OverviewColumnHint :title="overviewTableHints.orderCost">订单成本</OverviewColumnHint>
<th class="border-b px-6 py-4 font-bold text-orange-800 dark:text-orange-300">
<OverviewColumnHint :title="storeOverviewHints.orderCost">
订单成本
</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3 font-bold text-rose-600 dark:text-rose-400">
<OverviewColumnHint :title="overviewTableHints.refundAmount">退款金额</OverviewColumnHint>
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
<OverviewColumnHint :title="storeOverviewHints.refundAmount">
退款金额
</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3">
<OverviewColumnHint :title="overviewTableHints.promotionFeeSku">推广费</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
<OverviewColumnHint :title="overviewTableHints.feeRatioSku">费比 %</OverviewColumnHint>
</th>
<!-- 盈利 -->
<th class="border-b border-l px-5 py-3 font-bold">
<OverviewColumnHint :title="overviewTableHints.profitBeforeTaxSku">税前盈亏</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
<th class="border-b px-6 py-4 italic text-rose-500 dark:text-rose-400">
<OverviewColumnHint :title="salesTaxColumnHint(taxRate)">
{{ (taxRate * 100).toFixed(0) }}%税额
</OverviewColumnHint>
</th>
<th class="border-b px-5 py-3 font-black text-indigo-700 dark:text-indigo-400">
<OverviewColumnHint :title="overviewTableHints.roi">ROI</OverviewColumnHint>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="overviewTableHints.promotionFeeSku">
推广费
</OverviewColumnHint>
</th>
<th class="border-b bg-emerald-600 dark:bg-emerald-600 px-5 py-3 font-black text-white">
<OverviewColumnHint light :title="overviewTableHints.profitAfterTax">
税后盈亏
<!-- 盈利 -->
<th
class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold"
>
<OverviewColumnHint :title="overviewTableHints.profitBeforeTaxSku">
税前净利
</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
<OverviewColumnHint :title="storeOverviewHints.feeRatioShopRow">
费比%
</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 font-black text-indigo-700 dark:text-indigo-400">
<OverviewColumnHint :title="storeOverviewHints.roi">ROI</OverviewColumnHint>
</th>
<th
class="border-b bg-emerald-600 dark:bg-emerald-600 px-6 py-4 font-black text-white"
>
<OverviewColumnHint light :title="storeOverviewHints.profitAfterTax">
税后净利
</OverviewColumnHint>
</th>
</tr>
@@ -225,69 +245,124 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
<tr
v-for="item in data"
:key="item.skuId"
class="transition-colors hover:bg-slate-50/50 dark:hover:bg-[hsl(240deg_3.7%_15.9%/30%)]"
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)]"
>
<!-- SKU 名称 -->
<td class="sticky-col border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-5 shadow-sm dark:shadow-none">
<span class="inline-block rounded-full bg-blue-50 dark:bg-blue-900/30 px-3 py-1 text-sm font-bold text-blue-600 dark:text-blue-400">{{ item.skuName }}</span>
<td
class="sticky-col border-r-2 border-slate-100 dark:border-r-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 font-bold shadow-sm dark:shadow-none"
>
<span
class="inline-flex items-center rounded-full bg-blue-50 px-3 py-1 text-sm font-bold text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"
>
{{ item.skuName }}
</span>
</td>
<!-- 规模 -->
<td class="p-5 font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">{{ formatAmount(item.salesAmount) }}</td>
<td class="p-5 font-medium">
<span>{{ formatCount(item.orderCount) }}</span>
<span class="ml-1 text-xs text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">单</span>
<span class="ml-2 text-xs text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">({{ formatCount(item.quantity) }}件)</span>
<td class="p-6 font-black">
{{ formatAmount(item.salesAmount) }}
</td>
<td class="p-6 font-medium">
{{ formatIntCell(item.orderCount) }}
<span class="ml-1 text-xs text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
({{ formatIntCell(item.quantity) }}件)
</span>
</td>
<td class="p-6 font-medium">
{{ cellMoney(item.averageOrderValue) }}
</td>
<td class="p-5 font-medium">{{ formatAmount(item.averageOrderValue) }}</td>
<!-- 成本 -->
<td class="p-5">{{ cellMoney(item.productCost) }}</td>
<td class="p-5">{{ cellMoney(item.shippingCost) }}</td>
<td class="p-5">{{ cellMoney(item.otherCost) }}</td>
<td class="p-5 font-bold text-orange-800 dark:text-orange-300">
<td class="p-6">{{ cellMoney(item.productCost) }}</td>
<td class="p-6">{{ cellMoney(item.shippingCost) }}</td>
<td class="p-6">{{ cellMoney(item.otherCost) }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
{{ cellMoney(item.orderCost) }}
</td>
<td class="p-5 font-bold text-rose-600 dark:text-rose-400">
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
{{ cellMoney(item.refundAmount) }}
</td>
<td class="p-5">{{ cellMoney(item.promotionFee) }}</td>
<td class="p-5 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatPercent(item.feeRatio) }}</td>
<!-- 盈利 -->
<td class="p-5 font-bold" :class="item.profitBeforeTax >= 0 ? 'text-slate-800 dark:text-[hsl(0deg_0%_95%)]' : 'text-rose-600 dark:text-rose-400'">
{{ formatAmount(item.profitBeforeTax) }}
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ cellMoney(item.salesTaxAmount) }}
</td>
<td class="p-5 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(item.salesTaxAmount) }}</td>
<td class="p-5 font-black text-indigo-700 dark:text-indigo-400">{{ cellRoi(item.roi) }}</td>
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-5 text-base font-black" :class="item.profitAfterTax >= 0 ? 'text-emerald-600 dark:text-emerald-400' : 'text-rose-600 dark:text-rose-400'">
{{ formatAmount(item.profitAfterTax) }}
<td class="p-6">{{ cellMoney(item.promotionFee) }}</td>
<!-- 盈利 -->
<td class="p-6 font-bold">
{{ cellMoney(item.profitBeforeTax) }}
</td>
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ formatFeeRatioPercent(item.feeRatio) }}
</td>
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">
{{ cellRoi(item.roi) }}
</td>
<td
class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%)] p-6 text-base font-black text-emerald-600 dark:text-emerald-300"
>
{{ cellMoney(item.profitAfterTax) }}
</td>
</tr>
<tr v-if="!data || data.length === 0">
<td colspan="16" class="p-8 text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">暂无 SKU 数据</td>
<td
colspan="15"
class="p-8 text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
>
暂无 SKU 数据
</td>
</tr>
</tbody>
<tfoot v-if="footerRow" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<td class="border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] p-5 text-base">合计</td>
<td class="p-5">{{ formatAmount(footerRow.salesAmount) }}</td>
<td class="p-5">
<span>{{ formatCount(footerRow.orderCount) }}</span>
<span class="ml-1 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">单</span>
<span class="ml-2 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">({{ formatCount(footerRow.quantity) }}件)</span>
<td class="sticky-col bg-slate-100 p-6 text-base dark:bg-[hsl(240deg_3.7%_22%)]">
合计
</td>
<td class="p-5">{{ formatAmount(footerRow.averageOrderValue) }}</td>
<td class="p-5">{{ formatAmount(footerRow.productCost) }}</td>
<td class="p-5">{{ formatAmount(footerRow.shippingCost) }}</td>
<td class="p-5">{{ formatAmount(footerRow.otherCost) }}</td>
<td class="p-5 font-bold text-orange-800 dark:text-orange-300">
{{ footerRow.orderCost != null ? formatAmount(footerRow.orderCost) : formatAmount((footerRow.productCost || 0) + (footerRow.shippingCost || 0) + (footerRow.otherCost || 0)) }}
<td class="p-6">{{ cellMoney(footerRow.salesAmount) }}</td>
<td class="p-6">
{{ formatIntCell(footerRow.orderCount) }}
<span class="ml-1 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
({{ formatIntCell(footerRow.quantity) }}件)
</span>
</td>
<td class="p-6">{{ cellMoney(footerRow.averageOrderValue) }}</td>
<td class="p-6">{{ cellMoney(footerRow.productCost) }}</td>
<td class="p-6">{{ cellMoney(footerRow.shippingCost) }}</td>
<td class="p-6">{{ cellMoney(footerRow.otherCost) }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
{{
footerRow.orderCost != null
? cellMoney(footerRow.orderCost)
: cellMoney(
(footerRow.productCost || 0) +
(footerRow.shippingCost || 0) +
(footerRow.otherCost || 0),
)
}}
</td>
<td class="p-6 text-rose-600 dark:text-rose-400">
{{ cellMoney(footerRow.refundAmount) }}
</td>
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{ cellMoney(footerRow.salesTaxAmount) }}
</td>
<td class="p-6">{{ cellMoney(footerRow.promotionFee) }}</td>
<td class="p-6">{{ cellMoney(footerRow.profitBeforeTax) }}</td>
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{
footerRow.feeRatio !== undefined
? formatFeeRatioPercent(footerRow.feeRatio)
: '-'
}}
</td>
<td class="p-6 text-indigo-700 dark:text-indigo-400">
{{ cellRoi(footerRow.roi) }}
</td>
<td
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
:class="
(footerRow.profitAfterTax ?? 0) < 0
? 'text-rose-600 dark:text-rose-400'
: 'text-emerald-700 dark:text-emerald-300'
"
>
{{ cellMoney(footerRow.profitAfterTax) }}
</td>
<td class="p-5 text-rose-600 dark:text-rose-400">{{ formatAmount(footerRow.refundAmount) }}</td>
<td class="p-5">{{ formatAmount(footerRow.promotionFee) }}</td>
<td class="p-5 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatPercent(footerRow.feeRatio) }}</td>
<td class="p-5">{{ formatAmount(footerRow.profitBeforeTax) }}</td>
<td class="p-5 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatAmount(footerRow.salesTaxAmount) }}</td>
<td class="p-5 text-indigo-700 dark:text-indigo-400">{{ cellRoi(footerRow.roi) }}</td>
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-5 text-base text-emerald-600 dark:text-emerald-400">{{ formatAmount(footerRow.profitAfterTax) }}</td>
</tr>
</tfoot>
</table>
@@ -303,7 +378,22 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
}
.table-container {
overflow-x: auto;
max-height: 1000px;
overflow: auto;
}
thead {
position: sticky;
top: 0;
z-index: 20;
}
thead tr:last-child th:last-child,
tbody td:last-child:not([colspan]),
tfoot td:last-child:not([colspan]) {
position: sticky;
right: 0;
z-index: 10;
}
.table-container::-webkit-scrollbar {
@@ -1,4 +1,17 @@
<script lang="ts" setup>
import { createIconifyIcon } from '@vben/icons';
import {
FINANCE_KPI_CARD_SHELL,
FINANCE_TONE_ICON,
} from '#/views/bi/workbench/tabs/finance/constants/finance-ui';
const IconSales = createIconifyIcon('lucide:wallet');
const IconOrders = createIconifyIcon('lucide:shopping-bag');
const IconRoi = createIconifyIcon('lucide:target');
const IconNet = createIconifyIcon('lucide:badge-dollar-sign');
const IconTax = createIconifyIcon('lucide:landmark');
interface Props {
data: {
productName?: string;
@@ -17,9 +30,43 @@ interface Props {
defineProps<Props>();
const cards = [
{
key: 'sales',
label: '实际销售额',
tone: 'blue' as const,
icon: IconSales,
},
{
key: 'orders',
label: '销售单量',
tone: 'blue' as const,
icon: IconOrders,
},
{
key: 'roi',
label: '广告 ROI',
tone: 'purple' as const,
icon: IconRoi,
},
{
key: 'profit',
label: '净利润',
tone: 'green' as const,
icon: IconNet,
},
];
function toneClass(tone: string) {
return FINANCE_TONE_ICON[tone] ?? FINANCE_TONE_ICON.blue;
}
const formatAmount = (amount: number | undefined) => {
if (amount === undefined) return '-';
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
return `¥${amount.toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}`;
};
const toNumber = (value: unknown): number | undefined => {
@@ -33,110 +80,120 @@ const formatPercentPlain = (value: number | undefined | null) => {
return `${value.toFixed(1)}%`;
};
const formatPercent = (value: number | undefined) => {
if (value === undefined) return '-';
const formatGrowth = (value: number | undefined) => {
if (value === undefined) return '';
return `${value > 0 ? '+' : ''}${value.toFixed(1)}%`;
};
</script>
<template>
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 xl:grid-cols-4">
<!-- 销售额 -->
<div
class="flex flex-col justify-between rounded-[20px] border border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px]"
>
<div class="mb-4 flex items-start justify-between">
<span class="text-xs font-black uppercase tracking-widest text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
商品销售总额
</span>
<span
v-if="data?.monthOverMonthGrowth !== undefined"
class="rounded bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] px-2 py-1 text-xs font-bold text-emerald-600 dark:text-emerald-400"
>
增长率 {{ formatPercent(data.monthOverMonthGrowth) }}
</span>
<div class="grid grid-cols-1 gap-3.5 sm:grid-cols-2 xl:grid-cols-4">
<div
v-for="meta in cards"
:key="meta.key"
:class="FINANCE_KPI_CARD_SHELL"
>
<div class="flex items-start justify-between gap-2">
<span
class="min-w-0 truncate text-[16px] font-semibold leading-snug text-slate-800 dark:text-[hsl(0deg_0%_90%)]"
>
{{ meta.label }}
</span>
<div
class="grid size-9 shrink-0 place-items-center rounded-[10px]"
:class="toneClass(meta.tone)"
>
<component :is="meta.icon" class="size-4" />
</div>
<div class="text-4xl font-black leading-none text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
</div>
<!-- 销售额 -->
<template v-if="meta.key === 'sales'">
<div class="mt-3 tabular-nums text-[26px] font-bold leading-none tracking-tight text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
{{ data?.totalSalesAmount ? formatAmount(data.totalSalesAmount) : '-' }}
</div>
<div
v-if="data?.salesAmountAchievementRate !== undefined"
class="mt-6 flex items-center justify-between border-t border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] pt-4 text-xs font-bold"
class="mt-2.5 flex min-h-[1.25rem] flex-wrap items-center justify-between gap-x-2 gap-y-1 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
>
<span class="text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">销售额目标达成</span>
<span class="font-black text-blue-600 dark:text-blue-400">
{{ formatPercentPlain(data.salesAmountAchievementRate) }}
<span v-if="data?.salesAmountAchievementRate !== undefined">
目标达成
<span class="ml-1 font-semibold text-blue-600 dark:text-blue-400">
{{ formatPercentPlain(data.salesAmountAchievementRate) }}
</span>
</span>
<span
v-if="data?.monthOverMonthGrowth !== undefined"
:class="
data.monthOverMonthGrowth >= 0
? 'font-semibold text-emerald-500 dark:text-emerald-400'
: 'font-semibold text-rose-500 dark:text-rose-400'
"
>
环比 {{ formatGrowth(data.monthOverMonthGrowth) }}
</span>
</div>
</div>
</template>
<!-- 订单达成 -->
<div
class="flex flex-col justify-between rounded-[20px] border border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px]"
>
<div class="mb-4 text-xs font-black uppercase tracking-widest text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
订单总量与达成
<!-- 单量 -->
<template v-else-if="meta.key === 'orders'">
<div class="mt-3 inline-flex items-baseline gap-1 tabular-nums">
<span class="text-[26px] font-bold leading-none tracking-tight text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
{{ data?.totalOrderCount?.toLocaleString('zh-CN') || '-' }}
</span>
<span class="text-sm font-semibold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
单
</span>
</div>
<div class="text-4xl font-black leading-none text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ data?.totalOrderCount?.toLocaleString('zh-CN') || '-' }}
<span class="ml-1 text-sm font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">单</span>
</div>
<div v-if="data?.orderCountAchievementRate !== undefined" class="mt-6">
<div class="mb-2 flex justify-between text-[10px] font-black text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
<div
v-if="data?.orderCountAchievementRate !== undefined"
class="mt-2.5 space-y-2"
>
<div class="flex justify-between text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
<span>目标达成率</span>
<span>
<span class="font-semibold text-blue-600 dark:text-blue-400">
{{ formatPercentPlain(data.orderCountAchievementRate) }}
</span>
</div>
<div class="h-2 w-full overflow-hidden rounded-full bg-slate-100">
<div class="h-1.5 w-full overflow-hidden rounded-full bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
<div
class="h-full bg-indigo-500 transition-all duration-1000"
:style="{ width: `${Math.min(data.orderCountAchievementRate || 0, 100)}%` }"
></div>
class="h-full rounded-full bg-blue-500 transition-all duration-700"
:style="{
width: `${Math.min(data.orderCountAchievementRate || 0, 100)}%`,
}"
/>
</div>
</div>
</div>
</template>
<!-- 推广效率 -->
<div
class="flex flex-col justify-between rounded-[20px] border border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px]"
>
<div class="mb-4 text-xs font-black uppercase tracking-widest text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
投资回报率 (ROI)
</div>
<div class="text-4xl font-black leading-none text-indigo-600 dark:text-indigo-400">
{{ toNumber(data?.totalROI)?.toFixed(2) || '-' }}
<!-- ROI -->
<template v-else-if="meta.key === 'roi'">
<div class="mt-3 tabular-nums text-[26px] font-bold leading-none tracking-tight text-indigo-600 dark:text-indigo-400">
{{ toNumber(data?.totalROI)?.toFixed(2) ?? '-' }}
</div>
<div
v-if="data?.averageFeeRatio !== undefined"
class="mt-6 space-y-2 border-t border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] pt-4"
class="mt-2.5 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
>
<div class="flex justify-between text-xs font-bold">
<span class="text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">平均费比</span>
<span class="text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
{{ formatPercentPlain(data.averageFeeRatio) }}
</span>
</div>
平均费比
<span class="ml-1 font-semibold text-slate-700 dark:text-[hsl(0deg_0%_90%)]">
{{ formatPercentPlain(data.averageFeeRatio) }}
</span>
</div>
</div>
</template>
<!-- 利润汇总 -->
<div
class="flex flex-col justify-between rounded-[20px] border-l-4 border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] border-l-emerald-500 dark:border-l-emerald-500 bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px]"
>
<div class="mb-4 text-xs font-black uppercase tracking-widest text-emerald-600 dark:text-emerald-400">
商品净利润 (税后)
</div>
<div class="text-4xl font-black leading-none text-emerald-600 dark:text-emerald-400">
<!-- 净利润 -->
<template v-else-if="meta.key === 'profit'">
<div class="mt-3 tabular-nums text-[26px] font-bold leading-none tracking-tight text-emerald-600 dark:text-emerald-400">
{{ data?.totalNetProfitAfterTax ? formatAmount(data.totalNetProfitAfterTax) : '-' }}
</div>
<div
v-if="data?.totalTaxAmount !== undefined"
class="mt-6 flex justify-between border-t border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] pt-4 text-[11px] font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
class="mt-2.5 flex items-center gap-1.5 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
>
<span>已扣除税额</span>
<span>{{ formatAmount(data.totalTaxAmount) }}</span>
<IconTax class="size-3.5 shrink-0 opacity-70" />
<span>已扣税额 {{ formatAmount(data.totalTaxAmount) }}</span>
</div>
</div>
</template>
</div>
</template>
</div>
</template>
@@ -3,15 +3,20 @@ import { computed, ref } from 'vue';
import { createIconifyIcon } from '@vben/icons';
import { DatePicker, InputNumber, Popover, Select, Spin } from 'ant-design-vue';
import {
DatePicker,
InputNumber,
Popover,
Segmented,
Select,
Spin,
} from 'ant-design-vue';
import type { Dayjs } from 'dayjs';
import dayjs from 'dayjs';
import { normalizeOverviewRangePickerChange } from '#/utils/overview-date-range';
import {
overviewTimeRangeBtnClass,
overviewTimeRangeBtnState,
overviewToolbarPanelClass,
overviewToolbarShellClass,
} from '../../../styles/overview-toolbar-classes';
@@ -34,11 +39,9 @@ interface Props {
customDateRange: [Dayjs, Dayjs] | undefined;
dateRange: [Dayjs, Dayjs];
};
/** 路由 query.shopId,未选店铺时为 undefined */
shopId?: number;
shopOptions?: SelectOption[];
shopListLoading?: boolean;
/** 当前商品 ID(与路由 params.id 一致) */
productId?: number;
productOptions?: SelectOption[];
productListLoading?: boolean;
@@ -75,26 +78,47 @@ function handlePopoverOpen(name: string, open: boolean) {
}
const ReceiptIcon = createIconifyIcon('lucide:receipt');
const FilterIcon = createIconifyIcon('lucide:sliders-horizontal');
const ToolbarToggleIcon = createIconifyIcon('lucide:sliders-horizontal');
const CalendarIcon = createIconifyIcon('lucide:calendar');
const collapsedFilterLabel = computed(() => {
const shopName = props.shopId != null && props.shopId > 0
? (props.shopOptions?.find((o) => o.value === String(props.shopId))?.label ?? `店铺 #${props.shopId}`)
: '全部';
const productName = props.productId != null && props.productId > 0
? (props.productOptions?.find((o) => o.value === String(props.productId))?.label ?? `商品 #${props.productId}`)
: '选择商品';
type TimeRangeKey =
| '7days'
| '30days'
| 'custom'
| 'thisMonth'
| 'today'
| 'yesterday';
const timeRangeSegmentOptions: {
label: string;
value: Exclude<TimeRangeKey, 'custom'>;
}[] = [
{ label: '今日', value: 'today' },
{ label: '昨日', value: 'yesterday' },
{ label: '近7日', value: '7days' },
{ label: '近30日', value: '30days' },
{ label: '本月', value: 'thisMonth' },
];
const filterTriggerLabel = computed(() => {
const shopName =
props.shopId != null && props.shopId > 0
? (props.shopOptions?.find((o) => o.value === String(props.shopId))?.label ??
`店铺 #${props.shopId}`)
: '全部';
const productName =
props.productId != null && props.productId > 0
? (props.productOptions?.find((o) => o.value === String(props.productId))?.label ??
`商品 #${props.productId}`)
: '选择商品';
return `${shopName}/${productName}`;
});
const timeRangeLabel = computed(() => {
const t = props.modelValue.activeTimeRange;
if (t === 'today') return '今日';
if (t === 'yesterday') return '昨日';
if (t === '7days') return '近7日';
if (t === '30days') return '近30日';
if (t === 'thisMonth') return '本月';
const hit = timeRangeSegmentOptions.find(
(o) => o.value === props.modelValue.activeTimeRange,
);
if (hit) return hit.label;
if (props.modelValue.customDateRange) {
return `${props.modelValue.customDateRange[0].format('M/D')}-${props.modelValue.customDateRange[1].format('M/D')}`;
}
@@ -136,12 +160,10 @@ const formatTaxRate = (value: null | number | string | undefined) => {
const parseTaxRate = (value: string | undefined) => {
if (!value) return 0;
const num = Number(value.replace('%', '').trim());
return Number.isFinite(num) ? num / 100 : 0;
return Number.isFinite(num) ? Math.round((num / 100) * 1e12) / 1e12 : 0;
};
const switchTimeRange = (
type: '7days' | '30days' | 'thisMonth' | 'custom' | 'today' | 'yesterday',
) => {
const switchTimeRange = (type: TimeRangeKey) => {
let startDate: Dayjs;
let endDate: Dayjs = dayjs();
@@ -152,10 +174,6 @@ const switchTimeRange = (
case '30days':
startDate = dayjs().subtract(30, 'day');
break;
case 'thisMonth':
startDate = dayjs().startOf('month');
endDate = dayjs();
break;
case 'custom':
if (props.modelValue.customDateRange) {
emit('update:modelValue', {
@@ -165,6 +183,10 @@ const switchTimeRange = (
});
}
return;
case 'thisMonth':
startDate = dayjs().startOf('month');
endDate = dayjs();
break;
case 'today':
startDate = dayjs();
endDate = dayjs();
@@ -184,6 +206,10 @@ const switchTimeRange = (
});
};
function onTimeRangeSegmentChange(value: string | number) {
switchTimeRange(String(value) as Exclude<TimeRangeKey, 'custom'>);
}
const handleCustomDateRangeChange = (
value: [Dayjs, Dayjs] | [string, string] | null,
dateStrings?: [string, string],
@@ -198,8 +224,9 @@ const handleCustomDateRangeChange = (
});
};
const handleTaxRateChange = (val: number | string | undefined) => {
const num = typeof val === 'string' ? parseTaxRate(val) : val ?? 0.04;
const handleTaxRateChange = (val: number | string | null | undefined) => {
const num =
typeof val === 'string' ? parseTaxRate(val) : (val ?? props.modelValue.taxRate);
localStorage.setItem(TAX_RATE_KEY, String(num));
emit('update:modelValue', {
...props.modelValue,
@@ -210,29 +237,23 @@ const handleTaxRateChange = (val: number | string | undefined) => {
<template>
<div
class="overview-header-extra flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-2"
class="workbench-header-extra flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-2"
>
<!-- 税率 -->
<Popover
trigger="click"
:open="openPopover === 'taxRate'"
placement="bottom"
placement="bottomRight"
@update:open="(val: boolean) => handlePopoverOpen('taxRate', val)"
overlay-class-name="workbench-toolbar-popover"
>
<template #content>
<div class="flex items-center gap-2 whitespace-nowrap">
<span class="shrink-0 text-xs font-bold text-slate-700 dark:text-slate-300">
税率
</span>
<div class="flex items-center gap-2 py-1">
<span class="text-sm text-slate-600 dark:text-slate-300">税率</span>
<InputNumber
:value="props.modelValue.taxRate"
:min="0"
:max="1"
:step="0.01"
:precision="2"
size="small"
class="tax-rate-input !h-8 !w-20 !rounded-lg !border-none !bg-transparent !text-center !text-sm !font-bold !text-slate-800 !shadow-none dark:!text-slate-100"
class="w-28"
:formatter="formatTaxRate"
:parser="parseTaxRate"
@change="handleTaxRateChange"
@@ -244,32 +265,29 @@ const handleTaxRateChange = (val: number | string | undefined) => {
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
>
<ReceiptIcon class="h-4 w-4 shrink-0" />
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">税率{{ formatTaxRate(props.modelValue.taxRate) }}</span>
<span
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
>
税率{{ formatTaxRate(props.modelValue.taxRate) }}
</span>
</div>
</div>
</Popover>
<!-- 店铺/商品 -->
<Popover
trigger="click"
:open="openPopover === 'filter'"
placement="bottom"
placement="bottomRight"
@update:open="(val: boolean) => handlePopoverOpen('filter', val)"
overlay-class-name="workbench-toolbar-popover"
>
<template #content>
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-0">
<div
class="flex min-w-0 items-center gap-2 px-2 py-0.5 sm:w-[11.5rem] sm:flex-none sm:shrink-0 sm:py-0"
>
<span
class="w-9 shrink-0 text-right text-xs font-bold text-slate-700 dark:text-slate-300"
>
<div class="flex w-[17.5rem] flex-col gap-3 py-1 sm:w-[22rem]">
<div class="flex items-center gap-2">
<span class="w-9 shrink-0 text-sm text-slate-600 dark:text-slate-300">
店铺
</span>
<Select
:value="shopSelectValue"
size="small"
show-search
allow-clear
:filter-option="false"
@@ -277,7 +295,7 @@ const handleTaxRateChange = (val: number | string | undefined) => {
:options="props.shopOptions"
placeholder="全部店铺"
:dropdown-match-select-width="false"
class="overview-header-select overview-shop-select min-w-0 flex-1"
class="min-w-0 flex-1"
@change="handleShopSelectChange"
@search="(kw: string) => emit('shop-search', kw)"
@popup-scroll="(e: Event) => emit('shop-popup-scroll', e)"
@@ -288,18 +306,16 @@ const handleTaxRateChange = (val: number | string | undefined) => {
<template #notFoundContent>
<div v-if="props.shopListLoading" class="py-3 text-center">
<Spin size="small" />
<div class="mt-1 text-xs text-slate-600">加载中...</div>
<div class="mt-1 text-xs text-slate-500">加载中...</div>
</div>
<div v-else class="py-3 text-center text-xs text-slate-500">
暂无店铺
</div>
<div v-else class="py-3 text-center text-xs text-slate-600">暂无店铺</div>
</template>
</Select>
</div>
<div
class="flex min-w-0 flex-1 items-center gap-2 border-t border-slate-200/80 px-2 pt-2 sm:min-w-[16rem] sm:border-t-0 sm:py-0 sm:pt-0 dark:border-[hsl(240deg_3.7%_22%)]"
>
<span
class="w-9 shrink-0 text-right text-xs font-bold text-slate-700 dark:text-slate-300"
>
<div class="flex items-center gap-2">
<span class="w-9 shrink-0 text-sm text-slate-600 dark:text-slate-300">
商品
</span>
<Select
@@ -308,14 +324,13 @@ const handleTaxRateChange = (val: number | string | undefined) => {
? String(props.productId)
: undefined
"
size="small"
show-search
:filter-option="false"
:loading="props.productListLoading"
:options="props.productOptions"
placeholder="选择商品"
:dropdown-match-select-width="false"
class="overview-header-select overview-product-select min-w-0 flex-1"
class="min-w-0 flex-1"
@change="handleProductSelectChange"
@search="(kw: string) => emit('product-search', kw)"
@popup-scroll="(e: Event) => emit('product-popup-scroll', e)"
@@ -326,9 +341,11 @@ const handleTaxRateChange = (val: number | string | undefined) => {
<template #notFoundContent>
<div v-if="props.productListLoading" class="py-3 text-center">
<Spin size="small" />
<div class="mt-1 text-xs text-slate-600">加载中...</div>
<div class="mt-1 text-xs text-slate-500">加载中...</div>
</div>
<div v-else class="py-3 text-center text-xs text-slate-500">
暂无商品
</div>
<div v-else class="py-3 text-center text-xs text-slate-600">暂无商品</div>
</template>
</Select>
</div>
@@ -338,87 +355,40 @@ const handleTaxRateChange = (val: number | string | undefined) => {
<div
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
>
<FilterIcon class="h-4 w-4 shrink-0" />
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">{{ collapsedFilterLabel }}</span>
<ToolbarToggleIcon class="h-4 w-4 shrink-0" />
<span
class="max-w-[10rem] truncate whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
>
{{ filterTriggerLabel }}
</span>
</div>
</div>
</Popover>
<!-- 时间范围 -->
<Popover
trigger="click"
:open="openPopover === 'timeRange'"
placement="bottom"
placement="bottomRight"
@update:open="(val: boolean) => handlePopoverOpen('timeRange', val)"
overlay-class-name="workbench-toolbar-popover"
>
<template #content>
<div class="flex flex-col gap-2 px-1 py-0.5">
<div class="flex items-center gap-1 overflow-x-auto whitespace-nowrap">
<button
type="button"
:class="[
overviewTimeRangeBtnClass,
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'today'),
]"
@click="switchTimeRange('today')"
>
今日
</button>
<button
type="button"
:class="[
overviewTimeRangeBtnClass,
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'yesterday'),
]"
@click="switchTimeRange('yesterday')"
>
昨日
</button>
<button
type="button"
:class="[
overviewTimeRangeBtnClass,
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '7days'),
]"
@click="switchTimeRange('7days')"
>
近7日
</button>
<button
type="button"
:class="[
overviewTimeRangeBtnClass,
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '30days'),
]"
@click="switchTimeRange('30days')"
>
近30日
</button>
<button
type="button"
:class="[
overviewTimeRangeBtnClass,
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'thisMonth'),
]"
@click="switchTimeRange('thisMonth')"
>
本月
</button>
</div>
<div class="flex w-[20rem] flex-col gap-3 py-1 sm:w-[26rem]">
<Segmented
:value="props.modelValue.activeTimeRange"
:options="timeRangeSegmentOptions"
block
@change="onTimeRangeSegmentChange"
/>
<div class="flex items-center gap-2">
<span
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
>
自定义日期
<span class="shrink-0 text-sm text-slate-600 dark:text-slate-300">
自定义
</span>
<DatePicker.RangePicker
:value="props.modelValue.customDateRange"
size="small"
format="YYYY-MM-DD"
:allow-clear="false"
:placeholder="['开始', '结束']"
class="overview-header-range-picker !h-8 !w-full !border-none !bg-transparent !text-sm !font-bold !text-slate-800 sm:!w-[220px] dark:!text-slate-200"
class="min-w-0 flex-1"
@change="handleCustomDateRangeChange"
/>
</div>
@@ -429,12 +399,13 @@ const handleTaxRateChange = (val: number | string | undefined) => {
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
>
<CalendarIcon class="h-4 w-4 shrink-0" />
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">{{ timeRangeLabel }}</span>
<span
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
>
{{ timeRangeLabel }}
</span>
</div>
</div>
</Popover>
</div>
</template>
<style src="../../../styles/overview-toolbar.css"></style>
<style src="../../../styles/overview-header-select.css"></style>
@@ -437,6 +437,7 @@ onUnmounted(() => {
<Page
auto-content-height
class="bg-[#f8fafc] dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
content-padding-class="px-4 pb-4"
header-class="product-overview-page-header"
>
<template #title>
@@ -448,7 +449,9 @@ onUnmounted(() => {
</template>
<template #extra>
<div class="w-full max-w-full sm:w-auto">
<div
class="workbench-header-extra flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-2"
>
<TimeRangeBar
:model-value="timeRangeState"
:shop-id="contextShopId"
@@ -471,12 +474,19 @@ onUnmounted(() => {
</template>
<Spin :spinning="loading">
<div v-if="overviewData" class="mx-auto w-full space-y-6">
<!-- 第一层:核心统计卡片 -->
<div v-if="overviewData" class="product-overview-body mx-auto w-full min-w-0 space-y-4 pt-4">
<div>
<h2 class="text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
经营概览
</h2>
<p class="mt-0.5 text-xs text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
商品核心 KPI · 与当前筛选时间范围一致
</p>
</div>
<StatCards :data="overviewData" :loading="loading" />
<!-- 第二层:趋势与财务拆解 -->
<div class="grid grid-cols-1 gap-6 xl:grid-cols-3">
<div class="grid grid-cols-1 gap-3.5 xl:grid-cols-3">
<SalesTrendChart :data="overviewData" />
<SkuSalesTop10Panel :data="overviewData?.specSalesTop10 ?? []" />
</div>
@@ -509,46 +519,23 @@ onUnmounted(() => {
}
}
:deep(.product-overview-page-header > div:first-child),
:deep(.product-overview-page-header > div:first-child) {
width: 100%;
}
@media (min-width: 640px) {
:deep(.product-overview-page-header > div:first-child) {
width: auto;
}
}
:deep(.product-overview-page-header > div:last-child) {
width: 100%;
}
@media (min-width: 640px) {
:deep(.product-overview-page-header > div:first-child),
:deep(.product-overview-page-header > div:last-child) {
width: auto;
}
}
/* 表格滚动条优化 */
.table-container::-webkit-scrollbar {
height: 6px;
}
.table-container::-webkit-scrollbar-thumb {
background: #e2e8f0;
border-radius: 10px;
}
</style>
<style>
html.dark .product-overview-thead table thead th {
background-color: hsl(240deg 3.7% 15.9% / 80%) !important;
}
html.dark .product-overview-thead table thead th {
border-color: hsl(240deg 3.7% 22%) !important;
}
html.dark .table-container table tbody tr:hover td {
background-color: hsl(217.2deg 32.6% 17.5% / 30%) !important;
}
html.dark .table-container::-webkit-scrollbar-thumb {
background: hsl(240deg 3.7% 22%);
}
html.dark .table-container::-webkit-scrollbar-track {
background: hsl(240deg 3.7% 15.9%);
}
</style>
@@ -3,7 +3,7 @@ export const overviewToolbarShellClass =
'flex w-full flex-col gap-2 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5 sm:w-auto sm:flex-row sm:items-center sm:gap-2 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)]';
export const overviewToolbarPanelClass =
'overview-toolbar-panel rounded-xl bg-white dark:bg-[hsl(222.34deg_10.43%_14%)]';
'rounded-xl bg-white dark:bg-[hsl(222.34deg_10.43%_14%)]';
export const overviewToolbarLabelClass =
'text-xs font-bold text-slate-700 dark:text-slate-300';