mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
Compare commits
7
Commits
59b3ada695
...
5dee928321
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5dee928321 | ||
|
|
f272122918 | ||
|
|
1b06aa6bcc | ||
|
|
1f4ea2074a | ||
|
|
5795eab75c | ||
|
|
f4de5d8fd0 | ||
|
|
c24051aa04 |
@@ -1,8 +1,6 @@
|
||||
---
|
||||
description: 通用企业级开发规范:分层、边界、可维护性;动手前先定结构
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# 企业级开发规范
|
||||
|
||||
先想清楚再写代码。优先可维护、可扩展,不为「先跑通」牺牲结构。
|
||||
|
||||
@@ -29,7 +29,7 @@ deploy/ # 部署 TUI(原 ecom-deploy),流程见 deploy/MANU
|
||||
## 前端(apps/web)
|
||||
|
||||
- 只允许 pnpm;先 `pnpm install`(postinstall 会跑 `stub` 构建)
|
||||
- 开发 `pnpm dev:antd`,构建 `pnpm build:antd`;类型检查 `pnpm -F @vben/web-antd typecheck`
|
||||
- 开发 `pnpm dev`(等同原 `dev:antd`),构建 `pnpm build`;类型检查 `pnpm -F @vben/web-antd typecheck`
|
||||
- lefthook 钩子会对暂存文件跑 `pnpm lint`(oxfmt/oxlint 等)与 `check:type`,commitlint 强制 conventional commit,不要绕过
|
||||
- 代码内 `#/` 别名 = `src/`
|
||||
- **UI 选型**:Vben 应用层 → Ant Design Vue → 可复用封装 → 自研;清单见 `apps/web/docs/agent-ui-components.md`(规则 `.cursor/rules/frontend-ui-priority.mdc`)
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
-- 拼多多发布工作台表设计(供文档查阅,与 migration 终态一致)
|
||||
-- V20260912__channel_pdd_goods_publish_desk.sql 建表
|
||||
-- V20260915c__pdd_publish_draft_platform_commit.sql 平台草稿关联字段
|
||||
-- V20260918__pdd_publish_draft_reject.sql 审核驳回字段与索引
|
||||
-- V20260915c / V20260918 平台绑定与驳回字段(已由 V20261014b 废止)
|
||||
-- V20261014__pdd_publish_draft_shop_stat.sql 草稿×店铺成功次数
|
||||
-- V20261014b__pdd_publish_draft_unbind_platform.sql 草稿解绑平台 ID / 驳回字段
|
||||
--
|
||||
-- 表:
|
||||
-- channel_pdd_goods_publish_draft 系统草稿(唯一工作区)
|
||||
-- channel_pdd_goods_publish_job 批量发布任务
|
||||
-- channel_pdd_goods_publish_job_item 任务明细
|
||||
-- channel_pdd_goods_publish_draft 系统草稿(编辑工作区,不绑平台 commit/goods)
|
||||
-- channel_pdd_goods_publish_draft_shop_stat 草稿在各店「成功推草稿 / 成功发布」累计次数
|
||||
-- channel_pdd_goods_publish_job 批量投递任务(推草稿或正式发布)
|
||||
-- channel_pdd_goods_publish_job_item 任务明细(一行 = 草稿 × 目标店,一次成功则对应 stat +1)
|
||||
--
|
||||
-- 约定:
|
||||
-- 1) 系统草稿为主;拼多多草稿箱是导出结果(pdd_goods_commit_id 等)
|
||||
-- 2) payload_json = { editorState, publishPayload? }
|
||||
-- 3) 跨店克隆不复制 pdd_goods_commit_id / pdd_goods_id / pdd_draft_pushed_at / 驳回字段
|
||||
-- 4) 正式上架仍走 pdd.goods.add(返回 goods_commit_id,须回写系统草稿);推平台草稿走 edit/submit.goods.commit
|
||||
-- 5) 审核驳回消息按 commitId/goodsId 匹配系统草稿;无匹配则忽略(纯平台草稿)
|
||||
-- 1) 系统草稿不保存平台 commitId/goodsId,不做覆盖推送
|
||||
-- 2) 同一草稿可多次批量投递,目标店可重叠:
|
||||
-- 第1次发布 → 店1、店2;第2次发布 → 店2、店3
|
||||
-- 则 stat:店1 publish=1,店2 publish=2,店3 publish=1
|
||||
-- 3) 列表「成功发布次数」= SUM(publish_success_count);「涉及店铺数」= COUNT(publish_success_count>0)
|
||||
-- 4) 失败不写入本表(仅 job_item / last_error)
|
||||
-- 5) 审核驳回不回写系统草稿
|
||||
-- ========================================
|
||||
|
||||
-- ========================================
|
||||
@@ -22,36 +26,51 @@
|
||||
CREATE TABLE IF NOT EXISTS `channel_pdd_goods_publish_draft` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`pdd_shop_id` bigint UNSIGNED NULL COMMENT '渠道店铺ID(可空=未分配)',
|
||||
`pdd_shop_id` bigint UNSIGNED NULL COMMENT '编辑默认渠道店铺(可空;批量目标以 job_item 为准)',
|
||||
`title` varchar(500) NOT NULL DEFAULT '' COMMENT '草稿标题(展示用)',
|
||||
`cat_id` bigint UNSIGNED NULL COMMENT '叶子类目',
|
||||
`sku_count` int NOT NULL DEFAULT 0 COMMENT 'SKU 组合数快照',
|
||||
`status` varchar(32) NOT NULL DEFAULT 'EDITING' COMMENT 'EDITING/NEED_CHECK/READY/PUBLISHING/FAILED/PUBLISHED/REJECTED',
|
||||
`status` varchar(32) NOT NULL DEFAULT 'EDITING' COMMENT 'EDITING/NEED_CHECK/READY/PUBLISHING/FAILED',
|
||||
`payload_json` json NULL COMMENT '编辑器状态+可选 publishPayload',
|
||||
`source_draft_id` bigint UNSIGNED NULL COMMENT '克隆来源草稿',
|
||||
`last_error` varchar(1000) NULL COMMENT '最近发布/推送失败原因',
|
||||
`pdd_goods_commit_id` bigint UNSIGNED NULL COMMENT '拼多多草稿 goods_commit_id(推送或发布)',
|
||||
`pdd_goods_id` bigint UNSIGNED NULL COMMENT '拼多多商品 goods_id(草稿阶段可能为空)',
|
||||
`pdd_draft_pushed_at` datetime NULL COMMENT '最近推送到平台草稿箱时间',
|
||||
`reject_comment` varchar(1000) NULL COMMENT '拼多多审核驳回原因',
|
||||
`reject_time` datetime NULL COMMENT '拼多多审核驳回时间',
|
||||
`last_error` varchar(1000) NULL COMMENT '最近投递失败原因摘要',
|
||||
`created_by` bigint UNSIGNED NULL COMMENT '创建人',
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_pdd_pub_draft_company_shop` (`company_id`, `pdd_shop_id`, `status`),
|
||||
KEY `idx_pdd_pub_draft_company_status` (`company_id`, `status`),
|
||||
KEY `idx_pdd_pub_draft_commit` (`pdd_goods_commit_id`),
|
||||
KEY `idx_pdd_pub_draft_goods` (`company_id`, `pdd_shop_id`, `pdd_goods_id`),
|
||||
CONSTRAINT `fk_pdd_pub_draft_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='拼多多商品发布系统草稿';
|
||||
|
||||
-- ========================================
|
||||
-- 批量发布任务
|
||||
-- 草稿 × 店铺:成功推草稿 / 成功发布累计次数
|
||||
-- ========================================
|
||||
CREATE TABLE IF NOT EXISTS `channel_pdd_goods_publish_draft_shop_stat` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`draft_id` bigint UNSIGNED NOT NULL COMMENT '系统草稿ID',
|
||||
`pdd_shop_id` bigint UNSIGNED NOT NULL COMMENT '目标渠道店铺ID',
|
||||
`push_success_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '成功推送到该店平台草稿箱的次数',
|
||||
`publish_success_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '成功正式发布到该店的次数',
|
||||
`last_push_at` datetime NULL COMMENT '最近一次成功推草稿时间',
|
||||
`last_publish_at` datetime NULL COMMENT '最近一次成功发布时间',
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_pdd_pub_draft_shop_stat` (`draft_id`, `pdd_shop_id`),
|
||||
KEY `idx_pdd_pub_draft_shop_stat_company` (`company_id`, `draft_id`),
|
||||
CONSTRAINT `fk_pdd_pub_draft_shop_stat_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_pdd_pub_draft_shop_stat_draft` FOREIGN KEY (`draft_id`) REFERENCES `channel_pdd_goods_publish_draft` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统草稿在各拼多多店铺的成功投递次数';
|
||||
|
||||
-- ========================================
|
||||
-- 批量投递任务
|
||||
-- ========================================
|
||||
CREATE TABLE IF NOT EXISTS `channel_pdd_goods_publish_job` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`company_id` bigint UNSIGNED NOT NULL,
|
||||
`action` varchar(32) NOT NULL DEFAULT 'PUBLISH' COMMENT 'PUSH_DRAFT/PUBLISH',
|
||||
`status` varchar(32) NOT NULL DEFAULT 'PENDING' COMMENT 'PENDING/RUNNING/SUCCESS/PARTIAL/FAILED',
|
||||
`total_count` int NOT NULL DEFAULT 0,
|
||||
`success_count` int NOT NULL DEFAULT 0,
|
||||
@@ -65,20 +84,20 @@ CREATE TABLE IF NOT EXISTS `channel_pdd_goods_publish_job` (
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_pdd_pub_job_company` (`company_id`, `create_time`),
|
||||
CONSTRAINT `fk_pdd_pub_job_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='拼多多商品批量发布任务';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='拼多多商品批量投递任务';
|
||||
|
||||
-- ========================================
|
||||
-- 批量发布任务明细
|
||||
-- 批量投递任务明细
|
||||
-- ========================================
|
||||
CREATE TABLE IF NOT EXISTS `channel_pdd_goods_publish_job_item` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`job_id` bigint UNSIGNED NOT NULL,
|
||||
`company_id` bigint UNSIGNED NOT NULL,
|
||||
`draft_id` bigint UNSIGNED NOT NULL,
|
||||
`pdd_shop_id` bigint UNSIGNED NULL,
|
||||
`pdd_shop_id` bigint UNSIGNED NULL COMMENT '目标渠道店铺',
|
||||
`title` varchar(500) NOT NULL DEFAULT '',
|
||||
`status` varchar(32) NOT NULL DEFAULT 'PENDING' COMMENT 'PENDING/RUNNING/SUCCESS/FAILED',
|
||||
`goods_id` varchar(64) NULL COMMENT '发布成功后的拼多多 goodsId',
|
||||
`goods_id` varchar(64) NULL COMMENT '正式发布成功后的拼多多 goodsId(当次快照,可选)',
|
||||
`error_message` varchar(1000) NULL,
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
@@ -87,4 +106,4 @@ CREATE TABLE IF NOT EXISTS `channel_pdd_goods_publish_job_item` (
|
||||
KEY `idx_pdd_pub_job_item_draft` (`draft_id`),
|
||||
CONSTRAINT `fk_pdd_pub_job_item_job` FOREIGN KEY (`job_id`) REFERENCES `channel_pdd_goods_publish_job` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_pdd_pub_job_item_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='拼多多商品批量发布任务明细';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='拼多多商品批量投递任务明细';
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
-- 发布工作台:草稿×店铺成功次数表 + 批量任务区分推草稿/正式发布
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `channel_pdd_goods_publish_draft_shop_stat` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`draft_id` bigint UNSIGNED NOT NULL COMMENT '系统草稿ID',
|
||||
`pdd_shop_id` bigint UNSIGNED NOT NULL COMMENT '目标渠道店铺ID',
|
||||
`push_success_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '成功推送到该店平台草稿箱的次数',
|
||||
`publish_success_count` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '成功正式发布到该店的次数',
|
||||
`last_push_at` datetime NULL COMMENT '最近一次成功推草稿时间',
|
||||
`last_publish_at` datetime NULL COMMENT '最近一次成功发布时间',
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_pdd_pub_draft_shop_stat` (`draft_id`, `pdd_shop_id`),
|
||||
KEY `idx_pdd_pub_draft_shop_stat_company` (`company_id`, `draft_id`),
|
||||
CONSTRAINT `fk_pdd_pub_draft_shop_stat_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_pdd_pub_draft_shop_stat_draft` FOREIGN KEY (`draft_id`) REFERENCES `channel_pdd_goods_publish_draft` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统草稿在各拼多多店铺的成功投递次数';
|
||||
|
||||
ALTER TABLE `channel_pdd_goods_publish_job`
|
||||
ADD COLUMN `action` varchar(32) NOT NULL DEFAULT 'PUBLISH' COMMENT 'PUSH_DRAFT/PUBLISH' AFTER `company_id`;
|
||||
@@ -0,0 +1,64 @@
|
||||
-- 系统草稿解绑平台 commit/goods 与驳回字段;历史成功记录灌入店铺次数表后删列
|
||||
|
||||
-- 1) 历史:有店铺且有平台 ID → 记 1 次成功
|
||||
-- 有 goods_id → publish_success_count=1;否则仅有 commit_id → push_success_count=1
|
||||
INSERT INTO `channel_pdd_goods_publish_draft_shop_stat` (
|
||||
`company_id`,
|
||||
`draft_id`,
|
||||
`pdd_shop_id`,
|
||||
`push_success_count`,
|
||||
`publish_success_count`,
|
||||
`last_push_at`,
|
||||
`last_publish_at`
|
||||
)
|
||||
SELECT
|
||||
d.`company_id`,
|
||||
d.`id`,
|
||||
d.`pdd_shop_id`,
|
||||
CASE WHEN d.`pdd_goods_id` IS NULL AND d.`pdd_goods_commit_id` IS NOT NULL THEN 1 ELSE 0 END,
|
||||
CASE WHEN d.`pdd_goods_id` IS NOT NULL THEN 1 ELSE 0 END,
|
||||
CASE
|
||||
WHEN d.`pdd_goods_id` IS NULL AND d.`pdd_goods_commit_id` IS NOT NULL
|
||||
THEN COALESCE(d.`pdd_draft_pushed_at`, d.`update_time`)
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN d.`pdd_goods_id` IS NOT NULL
|
||||
THEN COALESCE(d.`pdd_draft_pushed_at`, d.`update_time`)
|
||||
ELSE NULL
|
||||
END
|
||||
FROM `channel_pdd_goods_publish_draft` d
|
||||
WHERE d.`pdd_shop_id` IS NOT NULL
|
||||
AND (d.`pdd_goods_commit_id` IS NOT NULL OR d.`pdd_goods_id` IS NOT NULL)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`push_success_count` = GREATEST(
|
||||
`channel_pdd_goods_publish_draft_shop_stat`.`push_success_count`,
|
||||
VALUES(`push_success_count`)
|
||||
),
|
||||
`publish_success_count` = GREATEST(
|
||||
`channel_pdd_goods_publish_draft_shop_stat`.`publish_success_count`,
|
||||
VALUES(`publish_success_count`)
|
||||
),
|
||||
`last_push_at` = COALESCE(
|
||||
VALUES(`last_push_at`),
|
||||
`channel_pdd_goods_publish_draft_shop_stat`.`last_push_at`
|
||||
),
|
||||
`last_publish_at` = COALESCE(
|
||||
VALUES(`last_publish_at`),
|
||||
`channel_pdd_goods_publish_draft_shop_stat`.`last_publish_at`
|
||||
);
|
||||
|
||||
-- 2) 终态收敛:已发布/驳回 → READY(仍可再批量投递)
|
||||
UPDATE `channel_pdd_goods_publish_draft`
|
||||
SET `status` = 'READY'
|
||||
WHERE `status` IN ('PUBLISHED', 'REJECTED');
|
||||
|
||||
-- 3) 删平台绑定与驳回列(索引名以 V20260918 为准)
|
||||
ALTER TABLE `channel_pdd_goods_publish_draft`
|
||||
DROP INDEX `idx_pdd_pub_draft_commit`,
|
||||
DROP INDEX `idx_pdd_pub_draft_goods`,
|
||||
DROP COLUMN `pdd_goods_commit_id`,
|
||||
DROP COLUMN `pdd_goods_id`,
|
||||
DROP COLUMN `pdd_draft_pushed_at`,
|
||||
DROP COLUMN `reject_comment`,
|
||||
DROP COLUMN `reject_time`;
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class PddGoodsPublishDTO {
|
||||
private Long pddShopId;
|
||||
|
||||
/**
|
||||
* 可选:关联的系统草稿 ID。发布成功后回写 goods_commit_id / goods_id,供审核驳回消息匹配。
|
||||
* 可选:关联的系统草稿 ID。正式发布成功后将该草稿标为 READY,并累加对应店铺的发布次数。
|
||||
*/
|
||||
private Long systemDraftId;
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public interface PddGoodsPublishDraftMapper extends BaseMapper<PddGoodsPublishDr
|
||||
SELECT pdd_shop_id AS pddShopId, COUNT(*) AS draftCount
|
||||
FROM channel_pdd_goods_publish_draft
|
||||
WHERE company_id = #{companyId}
|
||||
AND status IN ('EDITING', 'NEED_CHECK', 'READY', 'FAILED', 'PUBLISHING', 'REJECTED')
|
||||
AND status IN ('EDITING', 'NEED_CHECK', 'READY', 'FAILED', 'PUBLISHING')
|
||||
GROUP BY pdd_shop_id
|
||||
""")
|
||||
List<PddPublishDeskShopCountVO> countByShop(@Param("companyId") Long companyId);
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishDraftShopStatPO;
|
||||
|
||||
/**
|
||||
* 草稿×店铺成功次数 Mapper。
|
||||
*/
|
||||
@Mapper
|
||||
public interface PddGoodsPublishDraftShopStatMapper extends BaseMapper<PddGoodsPublishDraftShopStatPO> {
|
||||
|
||||
/** 推平台草稿成功 +1 */
|
||||
@Insert("""
|
||||
INSERT INTO channel_pdd_goods_publish_draft_shop_stat
|
||||
(company_id, draft_id, pdd_shop_id, push_success_count, publish_success_count, last_push_at)
|
||||
VALUES
|
||||
(#{companyId}, #{draftId}, #{pddShopId}, 1, 0, NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
push_success_count = push_success_count + 1,
|
||||
last_push_at = NOW()
|
||||
""")
|
||||
int incrPushSuccess(
|
||||
@Param("companyId") Long companyId,
|
||||
@Param("draftId") Long draftId,
|
||||
@Param("pddShopId") Long pddShopId);
|
||||
|
||||
/** 正式发布成功 +1 */
|
||||
@Insert("""
|
||||
INSERT INTO channel_pdd_goods_publish_draft_shop_stat
|
||||
(company_id, draft_id, pdd_shop_id, push_success_count, publish_success_count, last_publish_at)
|
||||
VALUES
|
||||
(#{companyId}, #{draftId}, #{pddShopId}, 0, 1, NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
publish_success_count = publish_success_count + 1,
|
||||
last_publish_at = NOW()
|
||||
""")
|
||||
int incrPublishSuccess(
|
||||
@Param("companyId") Long companyId,
|
||||
@Param("draftId") Long draftId,
|
||||
@Param("pddShopId") Long pddShopId);
|
||||
}
|
||||
+1
-23
@@ -9,7 +9,7 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 拼多多商品发布草稿。
|
||||
* 拼多多商品发布系统草稿(编辑工作区,不绑平台 commit/goods)。
|
||||
*/
|
||||
@Data
|
||||
@TableName("channel_pdd_goods_publish_draft")
|
||||
@@ -20,9 +20,6 @@ public class PddGoodsPublishDraftPO {
|
||||
public static final String STATUS_READY = "READY";
|
||||
public static final String STATUS_PUBLISHING = "PUBLISHING";
|
||||
public static final String STATUS_FAILED = "FAILED";
|
||||
public static final String STATUS_PUBLISHED = "PUBLISHED";
|
||||
/** 拼多多审核驳回(仅系统草稿有 commit/goods 关联时写入) */
|
||||
public static final String STATUS_REJECTED = "REJECTED";
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
@@ -54,25 +51,6 @@ public class PddGoodsPublishDraftPO {
|
||||
@TableField("last_error")
|
||||
private String lastError;
|
||||
|
||||
/** 最近一次推送到拼多多草稿箱的 commitId */
|
||||
@TableField("pdd_goods_commit_id")
|
||||
private Long pddGoodsCommitId;
|
||||
|
||||
/** 平台可能返回的 goodsId;草稿阶段常为空 */
|
||||
@TableField("pdd_goods_id")
|
||||
private Long pddGoodsId;
|
||||
|
||||
@TableField("pdd_draft_pushed_at")
|
||||
private LocalDateTime pddDraftPushedAt;
|
||||
|
||||
/** 拼多多审核驳回原因 */
|
||||
@TableField("reject_comment")
|
||||
private String rejectComment;
|
||||
|
||||
/** 拼多多审核驳回时间 */
|
||||
@TableField("reject_time")
|
||||
private LocalDateTime rejectTime;
|
||||
|
||||
@TableField("created_by")
|
||||
private Long createdBy;
|
||||
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 系统草稿在各拼多多店铺的成功投递次数。
|
||||
*/
|
||||
@Data
|
||||
@TableName("channel_pdd_goods_publish_draft_shop_stat")
|
||||
public class PddGoodsPublishDraftShopStatPO {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
@TableField("draft_id")
|
||||
private Long draftId;
|
||||
|
||||
@TableField("pdd_shop_id")
|
||||
private Long pddShopId;
|
||||
|
||||
@TableField("push_success_count")
|
||||
private Integer pushSuccessCount;
|
||||
|
||||
@TableField("publish_success_count")
|
||||
private Integer publishSuccessCount;
|
||||
|
||||
@TableField("last_push_at")
|
||||
private LocalDateTime lastPushAt;
|
||||
|
||||
@TableField("last_publish_at")
|
||||
private LocalDateTime lastPublishAt;
|
||||
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
+7
@@ -21,12 +21,19 @@ public class PddGoodsPublishJobPO {
|
||||
public static final String STATUS_PARTIAL = "PARTIAL";
|
||||
public static final String STATUS_FAILED = "FAILED";
|
||||
|
||||
public static final String ACTION_PUSH_DRAFT = "PUSH_DRAFT";
|
||||
public static final String ACTION_PUBLISH = "PUBLISH";
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
/** PUSH_DRAFT / PUBLISH */
|
||||
@TableField("action")
|
||||
private String action;
|
||||
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
|
||||
+8
-5
@@ -20,11 +20,14 @@ public class PddGoodsPublishDraftVO {
|
||||
private String payloadJson;
|
||||
private Long sourceDraftId;
|
||||
private String lastError;
|
||||
private Long pddGoodsCommitId;
|
||||
private Long pddGoodsId;
|
||||
private LocalDateTime pddDraftPushedAt;
|
||||
private String rejectComment;
|
||||
private LocalDateTime rejectTime;
|
||||
/** 成功推平台草稿累计次数(各店合计) */
|
||||
private Integer pushSuccessCount;
|
||||
/** 成功正式发布累计次数(各店合计) */
|
||||
private Integer publishSuccessCount;
|
||||
/** 成功推过草稿的店铺数 */
|
||||
private Integer pushShopCount;
|
||||
/** 成功发布过的店铺数 */
|
||||
private Integer publishShopCount;
|
||||
private Long createdBy;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
+2
-16
@@ -10,11 +10,10 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.vo.
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.vo.PddPublishDeskDraftPageVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.vo.PddPublishDeskShopCountVO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拼多多发布工作台:草稿 CRUD、一键克隆、批量发布任务。
|
||||
* 拼多多发布工作台:草稿 CRUD、克隆、推平台草稿、批量发布。
|
||||
*/
|
||||
public interface PddGoodsPublishDeskService {
|
||||
|
||||
@@ -40,19 +39,6 @@ public interface PddGoodsPublishDeskService {
|
||||
/** 重试任务中失败的明细 */
|
||||
PddGoodsPublishJobVO retryFailedItems(Long jobId);
|
||||
|
||||
/** 将系统草稿推送到拼多多草稿箱并回写 commitId */
|
||||
/** 将系统草稿推送到拼多多草稿箱(新建平台草稿),并累加店铺成功次数 */
|
||||
PddGoodsPublishDraftVO pushPlatformDraft(Long id);
|
||||
|
||||
/**
|
||||
* 审核驳回消息回写:按 commitId / goodsId 匹配系统草稿;无匹配则忽略(纯平台草稿)。
|
||||
*
|
||||
* @return 是否更新到系统草稿
|
||||
*/
|
||||
boolean applyGoodsCheckReject(
|
||||
Long companyId,
|
||||
Long pddShopId,
|
||||
Long goodsCommitId,
|
||||
Long goodsId,
|
||||
String rejectComment,
|
||||
LocalDateTime rejectTime);
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service;
|
||||
|
||||
/**
|
||||
* 系统草稿投递成功次数累加。
|
||||
*/
|
||||
public interface PddGoodsPublishDraftShopStatService {
|
||||
|
||||
/** 推平台草稿成功:该草稿在该店 push_success_count +1 */
|
||||
void incrPushSuccess(Long companyId, Long draftId, Long pddShopId);
|
||||
|
||||
/** 正式发布成功:该草稿在该店 publish_success_count +1 */
|
||||
void incrPublishSuccess(Long companyId, Long draftId, Long pddShopId);
|
||||
}
|
||||
+77
-83
@@ -14,9 +14,8 @@ import org.springframework.util.StringUtils;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddGoodsPublishResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsPublishService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.mapper.PddGoodsPublishDraftMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.mapper.PddGoodsPublishDraftShopStatMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.mapper.PddGoodsPublishJobItemMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.mapper.PddGoodsPublishJobMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.dto.PddPublishDeskCloneDTO;
|
||||
@@ -24,6 +23,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.dto
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.dto.PddPublishDeskDraftSaveDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.dto.PddPublishDeskJobCreateDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishDraftPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishDraftShopStatPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishJobItemPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishJobPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.vo.PddGoodsPublishDraftVO;
|
||||
@@ -32,12 +32,13 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.vo.
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.vo.PddPublishDeskDraftPageVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.vo.PddPublishDeskShopCountVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.PddGoodsPublishDeskService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.PddGoodsPublishDraftShopStatService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.PddGoodsPublishJobRunner;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsPublishService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.mapper.PddShopMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.model.po.PddShopPO;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -58,11 +59,12 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
PddGoodsPublishDraftPO.STATUS_NEED_CHECK,
|
||||
PddGoodsPublishDraftPO.STATUS_READY,
|
||||
PddGoodsPublishDraftPO.STATUS_FAILED,
|
||||
PddGoodsPublishDraftPO.STATUS_PUBLISHING,
|
||||
PddGoodsPublishDraftPO.STATUS_REJECTED
|
||||
PddGoodsPublishDraftPO.STATUS_PUBLISHING
|
||||
);
|
||||
|
||||
private final PddGoodsPublishDraftMapper draftMapper;
|
||||
private final PddGoodsPublishDraftShopStatMapper shopStatMapper;
|
||||
private final PddGoodsPublishDraftShopStatService shopStatService;
|
||||
private final PddGoodsPublishJobMapper jobMapper;
|
||||
private final PddGoodsPublishJobItemMapper jobItemMapper;
|
||||
private final PddShopMapper pddShopMapper;
|
||||
@@ -102,13 +104,16 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
.map(PddGoodsPublishDraftPO::getPddShopId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet()));
|
||||
Map<Long, int[]> statsByDraft = loadStatSums(companyId, page.getRecords().stream()
|
||||
.map(PddGoodsPublishDraftPO::getId)
|
||||
.collect(Collectors.toSet()));
|
||||
|
||||
PddPublishDeskDraftPageVO vo = new PddPublishDeskDraftPageVO();
|
||||
vo.setTotal(page.getTotal());
|
||||
vo.setPage((long) query.getPage());
|
||||
vo.setPageSize((long) query.getPageSize());
|
||||
vo.setRecords(page.getRecords().stream()
|
||||
.map(po -> toDraftVo(po, shopNames))
|
||||
.map(po -> toDraftVo(po, shopNames, statsByDraft.get(po.getId())))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
List<PddPublishDeskShopCountVO> counts = draftMapper.countByShop(companyId);
|
||||
@@ -137,7 +142,8 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
@Override
|
||||
public PddGoodsPublishDraftVO getDraft(Long id) {
|
||||
PddGoodsPublishDraftPO po = requireDraft(id);
|
||||
return toDraftVo(po, loadShopNamesForOne(po));
|
||||
Map<Long, int[]> stats = loadStatSums(po.getCompanyId(), Set.of(po.getId()));
|
||||
return toDraftVo(po, loadShopNamesForOne(po), stats.get(po.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +163,7 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
po.setPayloadJson(dto.getPayloadJson());
|
||||
po.setCreatedBy(currentUserContext.getCurrentUserId());
|
||||
draftMapper.insert(po);
|
||||
return toDraftVo(po, loadShopNamesForOne(po));
|
||||
return toDraftVo(po, loadShopNamesForOne(po), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,9 +171,8 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
public PddGoodsPublishDraftVO updateDraft(Long id, PddPublishDeskDraftSaveDTO dto) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
PddGoodsPublishDraftPO po = requireDraft(id);
|
||||
if (PddGoodsPublishDraftPO.STATUS_PUBLISHING.equals(po.getStatus())
|
||||
|| PddGoodsPublishDraftPO.STATUS_PUBLISHED.equals(po.getStatus())) {
|
||||
throw new BusinessException("发布中或已发布的草稿不可编辑");
|
||||
if (PddGoodsPublishDraftPO.STATUS_PUBLISHING.equals(po.getStatus())) {
|
||||
throw new BusinessException("发布中的草稿不可编辑");
|
||||
}
|
||||
if (dto.getPddShopId() != null) {
|
||||
requireOwnedShop(dto.getPddShopId(), companyId);
|
||||
@@ -180,8 +185,6 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
po.setStatus(normalizeStatus(dto.getStatus(), po.getStatus()));
|
||||
}
|
||||
po.setPayloadJson(dto.getPayloadJson());
|
||||
po.setLastError(null);
|
||||
// 用户再次编辑时清掉驳回信息(null 需 UpdateWrapper)
|
||||
draftMapper.update(null, new LambdaUpdateWrapper<PddGoodsPublishDraftPO>()
|
||||
.eq(PddGoodsPublishDraftPO::getId, po.getId())
|
||||
.set(PddGoodsPublishDraftPO::getPddShopId, po.getPddShopId())
|
||||
@@ -190,11 +193,10 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
.set(PddGoodsPublishDraftPO::getSkuCount, po.getSkuCount())
|
||||
.set(PddGoodsPublishDraftPO::getStatus, po.getStatus())
|
||||
.set(PddGoodsPublishDraftPO::getPayloadJson, po.getPayloadJson())
|
||||
.set(PddGoodsPublishDraftPO::getLastError, null)
|
||||
.set(PddGoodsPublishDraftPO::getRejectComment, null)
|
||||
.set(PddGoodsPublishDraftPO::getRejectTime, null));
|
||||
.set(PddGoodsPublishDraftPO::getLastError, null));
|
||||
PddGoodsPublishDraftPO refreshed = draftMapper.selectById(po.getId());
|
||||
return toDraftVo(refreshed != null ? refreshed : po, loadShopNamesForOne(po));
|
||||
Map<Long, int[]> stats = loadStatSums(companyId, Set.of(po.getId()));
|
||||
return toDraftVo(refreshed != null ? refreshed : po, loadShopNamesForOne(po), stats.get(po.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -235,9 +237,11 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
? source.getStatus()
|
||||
: PddGoodsPublishDraftPO.STATUS_EDITING)
|
||||
: PddGoodsPublishDraftPO.STATUS_NEED_CHECK;
|
||||
if (PddGoodsPublishDraftPO.STATUS_PUBLISHED.equals(status)
|
||||
|| PddGoodsPublishDraftPO.STATUS_PUBLISHING.equals(status)
|
||||
|| PddGoodsPublishDraftPO.STATUS_REJECTED.equals(status)) {
|
||||
if (PddGoodsPublishDraftPO.STATUS_PUBLISHING.equals(status)) {
|
||||
status = PddGoodsPublishDraftPO.STATUS_EDITING;
|
||||
}
|
||||
// 历史脏状态
|
||||
if ("PUBLISHED".equals(status) || "REJECTED".equals(status)) {
|
||||
status = PddGoodsPublishDraftPO.STATUS_EDITING;
|
||||
}
|
||||
po.setStatus(status);
|
||||
@@ -245,7 +249,7 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
po.setSourceDraftId(source.getId());
|
||||
po.setCreatedBy(userId);
|
||||
draftMapper.insert(po);
|
||||
created.add(toDraftVo(po, loadShopNamesForOne(po)));
|
||||
created.add(toDraftVo(po, loadShopNamesForOne(po), null));
|
||||
}
|
||||
}
|
||||
return created;
|
||||
@@ -271,9 +275,8 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
if (PddGoodsPublishDraftPO.STATUS_NEED_CHECK.equals(d.getStatus())) {
|
||||
throw new BusinessException("草稿「" + d.getTitle() + "」待校验(跨店克隆后请核对类目/运费)");
|
||||
}
|
||||
if (PddGoodsPublishDraftPO.STATUS_PUBLISHING.equals(d.getStatus())
|
||||
|| PddGoodsPublishDraftPO.STATUS_PUBLISHED.equals(d.getStatus())) {
|
||||
throw new BusinessException("草稿「" + d.getTitle() + "」正在发布或已发布");
|
||||
if (PddGoodsPublishDraftPO.STATUS_PUBLISHING.equals(d.getStatus())) {
|
||||
throw new BusinessException("草稿「" + d.getTitle() + "」正在发布中");
|
||||
}
|
||||
if (!StringUtils.hasText(d.getPayloadJson()) || !d.getPayloadJson().contains("publishPayload")) {
|
||||
throw new BusinessException("草稿「" + d.getTitle() + "」缺少可发布数据,请先在编辑器保存");
|
||||
@@ -282,6 +285,7 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
|
||||
PddGoodsPublishJobPO job = new PddGoodsPublishJobPO();
|
||||
job.setCompanyId(companyId);
|
||||
job.setAction(PddGoodsPublishJobPO.ACTION_PUBLISH);
|
||||
job.setStatus(PddGoodsPublishJobPO.STATUS_PENDING);
|
||||
job.setTotalCount(drafts.size());
|
||||
job.setSuccessCount(0);
|
||||
@@ -346,6 +350,7 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public PddGoodsPublishDraftVO pushPlatformDraft(Long id) {
|
||||
PddGoodsPublishDraftPO po = requireDraft(id);
|
||||
if (po.getPddShopId() == null) {
|
||||
@@ -367,14 +372,13 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
}
|
||||
payload.setPddShopId(po.getPddShopId());
|
||||
try {
|
||||
PddGoodsPublishResultVO result = publishService.pushPlatformDraft(
|
||||
payload, po.getPddGoodsCommitId(), po.getPddGoodsId());
|
||||
po.setPddGoodsCommitId(result.getGoodsCommitId());
|
||||
po.setPddGoodsId(result.getGoodsId());
|
||||
po.setPddDraftPushedAt(LocalDateTime.now());
|
||||
po.setLastError(null);
|
||||
draftMapper.updateById(po);
|
||||
return toDraftVo(po, loadShopNamesForOne(po));
|
||||
// 一律新建平台草稿,不依赖本地历史 commitId
|
||||
publishService.pushPlatformDraft(payload);
|
||||
shopStatService.incrPushSuccess(po.getCompanyId(), po.getId(), po.getPddShopId());
|
||||
draftMapper.update(null, new LambdaUpdateWrapper<PddGoodsPublishDraftPO>()
|
||||
.eq(PddGoodsPublishDraftPO::getId, po.getId())
|
||||
.set(PddGoodsPublishDraftPO::getLastError, null));
|
||||
return getDraft(po.getId());
|
||||
} catch (BusinessException e) {
|
||||
po.setLastError(trimError(e.getMessage()));
|
||||
draftMapper.updateById(po);
|
||||
@@ -386,51 +390,6 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean applyGoodsCheckReject(
|
||||
Long companyId,
|
||||
Long pddShopId,
|
||||
Long goodsCommitId,
|
||||
Long goodsId,
|
||||
String rejectComment,
|
||||
LocalDateTime rejectTime) {
|
||||
if (companyId == null || pddShopId == null) {
|
||||
return false;
|
||||
}
|
||||
PddGoodsPublishDraftPO draft = null;
|
||||
if (goodsCommitId != null) {
|
||||
draft = draftMapper.selectOne(new LambdaQueryWrapper<PddGoodsPublishDraftPO>()
|
||||
.eq(PddGoodsPublishDraftPO::getCompanyId, companyId)
|
||||
.eq(PddGoodsPublishDraftPO::getPddShopId, pddShopId)
|
||||
.eq(PddGoodsPublishDraftPO::getPddGoodsCommitId, goodsCommitId)
|
||||
.orderByDesc(PddGoodsPublishDraftPO::getUpdateTime)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
if (draft == null && goodsId != null) {
|
||||
draft = draftMapper.selectOne(new LambdaQueryWrapper<PddGoodsPublishDraftPO>()
|
||||
.eq(PddGoodsPublishDraftPO::getCompanyId, companyId)
|
||||
.eq(PddGoodsPublishDraftPO::getPddShopId, pddShopId)
|
||||
.eq(PddGoodsPublishDraftPO::getPddGoodsId, goodsId)
|
||||
.orderByDesc(PddGoodsPublishDraftPO::getUpdateTime)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
if (draft == null) {
|
||||
return false;
|
||||
}
|
||||
String comment = rejectComment;
|
||||
if (StringUtils.hasText(comment) && comment.length() > 1000) {
|
||||
comment = comment.substring(0, 1000);
|
||||
}
|
||||
draftMapper.update(null, new LambdaUpdateWrapper<PddGoodsPublishDraftPO>()
|
||||
.eq(PddGoodsPublishDraftPO::getId, draft.getId())
|
||||
.set(PddGoodsPublishDraftPO::getStatus, PddGoodsPublishDraftPO.STATUS_REJECTED)
|
||||
.set(PddGoodsPublishDraftPO::getRejectComment, comment)
|
||||
.set(PddGoodsPublishDraftPO::getRejectTime, rejectTime)
|
||||
.set(PddGoodsPublishDraftPO::getLastError, comment));
|
||||
return true;
|
||||
}
|
||||
|
||||
private String trimError(String msg) {
|
||||
if (!StringUtils.hasText(msg)) {
|
||||
return "推送到拼多多草稿箱失败";
|
||||
@@ -530,7 +489,36 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
return map;
|
||||
}
|
||||
|
||||
private PddGoodsPublishDraftVO toDraftVo(PddGoodsPublishDraftPO po, Map<Long, String> shopNames) {
|
||||
/**
|
||||
* @return draftId → [pushSum, publishSum, pushShopCount, publishShopCount]
|
||||
*/
|
||||
private Map<Long, int[]> loadStatSums(Long companyId, Set<Long> draftIds) {
|
||||
Map<Long, int[]> map = new HashMap<>();
|
||||
if (draftIds == null || draftIds.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
List<PddGoodsPublishDraftShopStatPO> rows = shopStatMapper.selectList(
|
||||
new LambdaQueryWrapper<PddGoodsPublishDraftShopStatPO>()
|
||||
.eq(PddGoodsPublishDraftShopStatPO::getCompanyId, companyId)
|
||||
.in(PddGoodsPublishDraftShopStatPO::getDraftId, draftIds));
|
||||
for (PddGoodsPublishDraftShopStatPO row : rows) {
|
||||
int[] agg = map.computeIfAbsent(row.getDraftId(), k -> new int[4]);
|
||||
int push = row.getPushSuccessCount() == null ? 0 : row.getPushSuccessCount();
|
||||
int pub = row.getPublishSuccessCount() == null ? 0 : row.getPublishSuccessCount();
|
||||
agg[0] += push;
|
||||
agg[1] += pub;
|
||||
if (push > 0) {
|
||||
agg[2]++;
|
||||
}
|
||||
if (pub > 0) {
|
||||
agg[3]++;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private PddGoodsPublishDraftVO toDraftVo(
|
||||
PddGoodsPublishDraftPO po, Map<Long, String> shopNames, int[] stat) {
|
||||
PddGoodsPublishDraftVO vo = new PddGoodsPublishDraftVO();
|
||||
vo.setId(po.getId());
|
||||
vo.setCompanyId(po.getCompanyId());
|
||||
@@ -545,11 +533,17 @@ public class PddGoodsPublishDeskServiceImpl implements PddGoodsPublishDeskServic
|
||||
vo.setPayloadJson(po.getPayloadJson());
|
||||
vo.setSourceDraftId(po.getSourceDraftId());
|
||||
vo.setLastError(po.getLastError());
|
||||
vo.setPddGoodsCommitId(po.getPddGoodsCommitId());
|
||||
vo.setPddGoodsId(po.getPddGoodsId());
|
||||
vo.setPddDraftPushedAt(po.getPddDraftPushedAt());
|
||||
vo.setRejectComment(po.getRejectComment());
|
||||
vo.setRejectTime(po.getRejectTime());
|
||||
if (stat != null) {
|
||||
vo.setPushSuccessCount(stat[0]);
|
||||
vo.setPublishSuccessCount(stat[1]);
|
||||
vo.setPushShopCount(stat[2]);
|
||||
vo.setPublishShopCount(stat[3]);
|
||||
} else {
|
||||
vo.setPushSuccessCount(0);
|
||||
vo.setPublishSuccessCount(0);
|
||||
vo.setPushShopCount(0);
|
||||
vo.setPublishShopCount(0);
|
||||
}
|
||||
vo.setCreatedBy(po.getCreatedBy());
|
||||
vo.setCreateTime(po.getCreateTime());
|
||||
vo.setUpdateTime(po.getUpdateTime());
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.mapper.PddGoodsPublishDraftShopStatMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.PddGoodsPublishDraftShopStatService;
|
||||
|
||||
/**
|
||||
* 按草稿×店铺 UPSERT 累加成功次数。
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PddGoodsPublishDraftShopStatServiceImpl implements PddGoodsPublishDraftShopStatService {
|
||||
|
||||
private final PddGoodsPublishDraftShopStatMapper shopStatMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void incrPushSuccess(Long companyId, Long draftId, Long pddShopId) {
|
||||
if (companyId == null || draftId == null || pddShopId == null) {
|
||||
return;
|
||||
}
|
||||
shopStatMapper.incrPushSuccess(companyId, draftId, pddShopId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void incrPublishSuccess(Long companyId, Long draftId, Long pddShopId) {
|
||||
if (companyId == null || draftId == null || pddShopId == null) {
|
||||
return;
|
||||
}
|
||||
shopStatMapper.incrPublishSuccess(companyId, draftId, pddShopId);
|
||||
}
|
||||
}
|
||||
+38
-14
@@ -16,6 +16,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.mapper.Pd
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishDraftPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishJobItemPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishJobPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.PddGoodsPublishDraftShopStatService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.PddGoodsPublishJobRunner;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsPublishService;
|
||||
|
||||
@@ -23,7 +24,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量发布执行器:逐条调用现有单店 publish。
|
||||
* 批量投递执行器:按 job.action 逐条推平台草稿或正式发布。
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -34,6 +35,7 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
||||
private final PddGoodsPublishJobItemMapper jobItemMapper;
|
||||
private final PddGoodsPublishDraftMapper draftMapper;
|
||||
private final PddGoodsPublishService publishService;
|
||||
private final PddGoodsPublishDraftShopStatService shopStatService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
@@ -69,6 +71,7 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
||||
PddGoodsPublishJobItemPO.STATUS_FAILED);
|
||||
}
|
||||
List<PddGoodsPublishJobItemPO> items = jobItemMapper.selectList(qw);
|
||||
boolean pushOnly = PddGoodsPublishJobPO.ACTION_PUSH_DRAFT.equals(job.getAction());
|
||||
|
||||
for (PddGoodsPublishJobItemPO item : items) {
|
||||
item.setStatus(PddGoodsPublishJobItemPO.STATUS_RUNNING);
|
||||
@@ -80,9 +83,11 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
||||
markItemFailed(item, "草稿不存在");
|
||||
continue;
|
||||
}
|
||||
draft.setStatus(PddGoodsPublishDraftPO.STATUS_PUBLISHING);
|
||||
draft.setLastError(null);
|
||||
draftMapper.updateById(draft);
|
||||
if (!pushOnly) {
|
||||
draft.setStatus(PddGoodsPublishDraftPO.STATUS_PUBLISHING);
|
||||
draft.setLastError(null);
|
||||
draftMapper.updateById(draft);
|
||||
}
|
||||
|
||||
try {
|
||||
PddGoodsPublishDTO dto = extractPublishPayload(draft);
|
||||
@@ -90,22 +95,40 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
||||
dto.setPddShopId(draft.getPddShopId());
|
||||
}
|
||||
dto.setSystemDraftId(draft.getId());
|
||||
PddGoodsPublishResultVO result = publishService.publish(dto);
|
||||
item.setStatus(PddGoodsPublishJobItemPO.STATUS_SUCCESS);
|
||||
item.setGoodsId(result.getGoodsId() == null ? null : String.valueOf(result.getGoodsId()));
|
||||
item.setErrorMessage(null);
|
||||
jobItemMapper.updateById(item);
|
||||
// status / commitId / goodsId 由 publish(systemDraftId) 回写
|
||||
// 任务明细目标店优先(支持一草稿多店)
|
||||
if (item.getPddShopId() != null) {
|
||||
dto.setPddShopId(item.getPddShopId());
|
||||
}
|
||||
Long targetShopId = dto.getPddShopId();
|
||||
if (pushOnly) {
|
||||
publishService.pushPlatformDraft(dto);
|
||||
shopStatService.incrPushSuccess(companyId, draft.getId(), targetShopId);
|
||||
item.setStatus(PddGoodsPublishJobItemPO.STATUS_SUCCESS);
|
||||
item.setErrorMessage(null);
|
||||
jobItemMapper.updateById(item);
|
||||
draft.setLastError(null);
|
||||
draftMapper.updateById(draft);
|
||||
} else {
|
||||
// publish 内会 READY + 累加发布次数
|
||||
PddGoodsPublishResultVO result = publishService.publish(dto);
|
||||
item.setStatus(PddGoodsPublishJobItemPO.STATUS_SUCCESS);
|
||||
item.setGoodsId(result.getGoodsId() == null ? null : String.valueOf(result.getGoodsId()));
|
||||
item.setErrorMessage(null);
|
||||
jobItemMapper.updateById(item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage() == null ? "发布失败" : e.getMessage();
|
||||
String msg = e.getMessage() == null ? (pushOnly ? "推草稿失败" : "发布失败") : e.getMessage();
|
||||
if (msg.length() > 900) {
|
||||
msg = msg.substring(0, 900);
|
||||
}
|
||||
markItemFailed(item, msg);
|
||||
draft.setStatus(PddGoodsPublishDraftPO.STATUS_FAILED);
|
||||
if (!pushOnly) {
|
||||
draft.setStatus(PddGoodsPublishDraftPO.STATUS_FAILED);
|
||||
}
|
||||
draft.setLastError(msg);
|
||||
draftMapper.updateById(draft);
|
||||
log.warn("publish desk job item failed jobId={} draftId={}", jobId, item.getDraftId(), e);
|
||||
log.warn("publish desk job item failed jobId={} draftId={} action={}",
|
||||
jobId, item.getDraftId(), job.getAction(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,9 +142,10 @@ public class PddGoodsPublishJobRunnerImpl implements PddGoodsPublishJobRunner {
|
||||
job.setSuccessCount((int) ok);
|
||||
job.setFailCount((int) bad);
|
||||
job.setFinishedAt(LocalDateTime.now());
|
||||
String verb = pushOnly ? "推草稿" : "发布";
|
||||
if (bad == 0) {
|
||||
job.setStatus(PddGoodsPublishJobPO.STATUS_SUCCESS);
|
||||
job.setMessage("全部发布成功");
|
||||
job.setMessage("全部" + verb + "成功");
|
||||
} else if (ok == 0) {
|
||||
job.setStatus(PddGoodsPublishJobPO.STATUS_FAILED);
|
||||
job.setMessage("全部失败");
|
||||
|
||||
+2
-6
@@ -45,11 +45,7 @@ public interface PddGoodsPublishService {
|
||||
PddGoodsPublishResultVO publish(PddGoodsPublishDTO dto);
|
||||
|
||||
/**
|
||||
* 推送到拼多多草稿箱:图转传 + commit,不入库渠道商品。
|
||||
*
|
||||
* @param existingCommitId 系统草稿上已挂的平台 commitId,可空
|
||||
* @param existingGoodsId 已挂的平台 goodsId,可空;与 commitId 同时有效时走覆盖保存
|
||||
* 推送到拼多多草稿箱:图转传 + 新建平台草稿,不入库渠道商品、不覆盖历史 commit。
|
||||
*/
|
||||
PddGoodsPublishResultVO pushPlatformDraft(
|
||||
PddGoodsPublishDTO dto, Long existingCommitId, Long existingGoodsId);
|
||||
PddGoodsPublishResultVO pushPlatformDraft(PddGoodsPublishDTO dto);
|
||||
}
|
||||
|
||||
+15
-21
@@ -38,6 +38,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddP
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishSpecIdVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.mapper.PddGoodsPublishDraftMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.model.po.PddGoodsPublishDraftPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.PddGoodsPublishDraftShopStatService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsPublishService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service.PddGoodsService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.support.PddGoodsImageTransfer;
|
||||
@@ -74,6 +75,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
private final PddGoodsService pddGoodsService;
|
||||
private final PddGoodsMapper pddGoodsMapper;
|
||||
private final PddGoodsPublishDraftMapper publishDraftMapper;
|
||||
private final PddGoodsPublishDraftShopStatService draftShopStatService;
|
||||
|
||||
public PddGoodsPublishServiceImpl(CurrentUserContext currentUserContext,
|
||||
PddShopMapper pddShopMapper,
|
||||
@@ -84,7 +86,8 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
ProductSkuService productSkuService,
|
||||
PddGoodsService pddGoodsService,
|
||||
PddGoodsMapper pddGoodsMapper,
|
||||
PddGoodsPublishDraftMapper publishDraftMapper) {
|
||||
PddGoodsPublishDraftMapper publishDraftMapper,
|
||||
PddGoodsPublishDraftShopStatService draftShopStatService) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.pddShopMapper = pddShopMapper;
|
||||
this.authTokenService = authTokenService;
|
||||
@@ -95,6 +98,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
this.pddGoodsService = pddGoodsService;
|
||||
this.pddGoodsMapper = pddGoodsMapper;
|
||||
this.publishDraftMapper = publishDraftMapper;
|
||||
this.draftShopStatService = draftShopStatService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,8 +304,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
result.setGoodsCommitId(addResult.goodsCommitId());
|
||||
result.setMatchedSpuId(addResult.matchedSpuId());
|
||||
result.setGoods(goodsVo);
|
||||
bindSystemDraftAfterPublish(companyId, dto.getSystemDraftId(),
|
||||
addResult.goodsCommitId(), addResult.goodsId());
|
||||
markSystemDraftAfterPublish(companyId, dto.getSystemDraftId(), ctx.shop().getId());
|
||||
log.info("拼多多商品发布成功 companyId={} shopId={} goodsId={}",
|
||||
companyId, ctx.shop().getId(), addResult.goodsId());
|
||||
return result;
|
||||
@@ -313,8 +316,7 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PddGoodsPublishResultVO pushPlatformDraft(
|
||||
PddGoodsPublishDTO dto, Long existingCommitId, Long existingGoodsId) {
|
||||
public PddGoodsPublishResultVO pushPlatformDraft(PddGoodsPublishDTO dto) {
|
||||
if (dto == null || dto.getCatId() == null) {
|
||||
throw new BusinessException("叶子类目不能为空");
|
||||
}
|
||||
@@ -323,13 +325,8 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
try {
|
||||
PddGoodsPublishPopApiClient.GoodsAddCommand command =
|
||||
assembleAddCommand(dto, companyId, ctx, false);
|
||||
PddGoodsPublishPopApiClient.GoodsAddResult popResult;
|
||||
if (existingCommitId != null && existingGoodsId != null && existingGoodsId > 0) {
|
||||
popResult = publishPopApiClient.submitGoodsCommitSave(
|
||||
ctx.mallId(), ctx.accessToken(), command, existingCommitId, existingGoodsId);
|
||||
} else {
|
||||
popResult = publishPopApiClient.editGoodsCommit(ctx.mallId(), ctx.accessToken(), command);
|
||||
}
|
||||
PddGoodsPublishPopApiClient.GoodsAddResult popResult =
|
||||
publishPopApiClient.editGoodsCommit(ctx.mallId(), ctx.accessToken(), command);
|
||||
PddGoodsPublishResultVO result = new PddGoodsPublishResultVO();
|
||||
result.setGoodsCommitId(popResult.goodsCommitId());
|
||||
Long goodsId = popResult.goodsId();
|
||||
@@ -746,9 +743,8 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
return new ShopAuth(shop, shop.getMallId(), auth.getAccessToken());
|
||||
}
|
||||
|
||||
/** 发布成功后把平台 commitId/goodsId 写回系统草稿,供审核驳回消息匹配 */
|
||||
private void bindSystemDraftAfterPublish(
|
||||
Long companyId, Long systemDraftId, Long goodsCommitId, Long goodsId) {
|
||||
/** 发布成功:系统草稿回到 READY,并累加该店发布成功次数(不绑平台 ID) */
|
||||
private void markSystemDraftAfterPublish(Long companyId, Long systemDraftId, Long pddShopId) {
|
||||
if (systemDraftId == null) {
|
||||
return;
|
||||
}
|
||||
@@ -759,12 +755,10 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
}
|
||||
publishDraftMapper.update(null, new LambdaUpdateWrapper<PddGoodsPublishDraftPO>()
|
||||
.eq(PddGoodsPublishDraftPO::getId, draft.getId())
|
||||
.set(PddGoodsPublishDraftPO::getStatus, PddGoodsPublishDraftPO.STATUS_PUBLISHED)
|
||||
.set(PddGoodsPublishDraftPO::getLastError, null)
|
||||
.set(PddGoodsPublishDraftPO::getPddGoodsCommitId, goodsCommitId)
|
||||
.set(PddGoodsPublishDraftPO::getPddGoodsId, goodsId)
|
||||
.set(PddGoodsPublishDraftPO::getRejectComment, null)
|
||||
.set(PddGoodsPublishDraftPO::getRejectTime, null));
|
||||
.set(PddGoodsPublishDraftPO::getStatus, PddGoodsPublishDraftPO.STATUS_READY)
|
||||
.set(PddGoodsPublishDraftPO::getLastError, null));
|
||||
Long shopId = pddShopId != null ? pddShopId : draft.getPddShopId();
|
||||
draftShopStatService.incrPublishSuccess(companyId, draft.getId(), shopId);
|
||||
}
|
||||
|
||||
private BusinessException wrapPop(String prefix, Exception e) {
|
||||
|
||||
+4
-30
@@ -5,17 +5,12 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.publishdesk.service.PddGoodsPublishDeskService;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.msg.dispatch.PddMsgHandler;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.msg.inbox.model.po.PddMsgInboxPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.msg.support.PddMsgContentSupport;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
||||
/**
|
||||
* 商品审核驳回:仅当系统草稿挂有对应 commitId/goodsId 时回写驳回状态;纯平台草稿忽略。
|
||||
* 商品审核驳回:系统草稿已不再绑定平台 commit/goods,本处理器仅记日志(驳回看消息中心/渠道商品)。
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -24,7 +19,6 @@ public class PddGoodsCheckRejectMsgHandler implements PddMsgHandler {
|
||||
|
||||
public static final String TYPE = "pdd_goods_GoodsCheckReject";
|
||||
|
||||
private final PddGoodsPublishDeskService deskService;
|
||||
private final PddMsgContentSupport contentSupport;
|
||||
|
||||
@Override
|
||||
@@ -34,9 +28,6 @@ public class PddGoodsCheckRejectMsgHandler implements PddMsgHandler {
|
||||
|
||||
@Override
|
||||
public void handle(PddMsgInboxPO inbox) {
|
||||
if (inbox.getCompanyId() == null || inbox.getChannelShopId() == null) {
|
||||
throw new IllegalStateException("驳回消息未绑定店铺 inboxId=" + inbox.getId());
|
||||
}
|
||||
JsonNode content = contentSupport.parseContent(inbox.getContentJson());
|
||||
Long commitId = readLong(content, "goods_commit_id");
|
||||
Long goodsId = readLong(content, "goods_id");
|
||||
@@ -47,29 +38,13 @@ public class PddGoodsCheckRejectMsgHandler implements PddMsgHandler {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
// 文档类型写成 LONG,示例为文案;按字符串兼容
|
||||
String rejectComment = readText(content, "reject_comment");
|
||||
Long rejectTimeMs = readLong(content, "reject_time");
|
||||
LocalDateTime rejectTime = null;
|
||||
if (rejectTimeMs != null && rejectTimeMs > 0) {
|
||||
rejectTime = LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(rejectTimeMs), ZoneId.systemDefault());
|
||||
}
|
||||
|
||||
boolean updated = deskService.applyGoodsCheckReject(
|
||||
inbox.getCompanyId(),
|
||||
log.info(
|
||||
"拼多多商品审核驳回(不回写系统草稿) shopId={} commitId={} goodsId={} comment={}",
|
||||
inbox.getChannelShopId(),
|
||||
commitId,
|
||||
goodsId,
|
||||
rejectComment,
|
||||
rejectTime);
|
||||
if (updated) {
|
||||
log.info("系统草稿已标记审核驳回 shopId={} commitId={} goodsId={}",
|
||||
inbox.getChannelShopId(), commitId, goodsId);
|
||||
} else {
|
||||
log.info("驳回消息无匹配系统草稿,忽略 shopId={} commitId={} goodsId={}",
|
||||
inbox.getChannelShopId(), commitId, goodsId);
|
||||
}
|
||||
rejectComment);
|
||||
}
|
||||
|
||||
private static Long readLong(JsonNode content, String field) {
|
||||
@@ -105,7 +80,6 @@ public class PddGoodsCheckRejectMsgHandler implements PddMsgHandler {
|
||||
if (node.isTextual()) {
|
||||
return node.asText();
|
||||
}
|
||||
// 兼容错误标注为数字的驳回原因
|
||||
return node.asText(null);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
```bash
|
||||
cd ecom-dmb-frontend
|
||||
pnpm install
|
||||
pnpm run dev:antd
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
访问:http://localhost:5666
|
||||
|
||||
@@ -49,11 +49,14 @@ export namespace PddPublishDeskVO {
|
||||
payloadJson?: string;
|
||||
sourceDraftId?: number;
|
||||
lastError?: string;
|
||||
pddGoodsCommitId?: number;
|
||||
pddGoodsId?: number;
|
||||
pddDraftPushedAt?: string;
|
||||
rejectComment?: string;
|
||||
rejectTime?: string;
|
||||
/** 成功推平台草稿累计次数 */
|
||||
pushSuccessCount?: number;
|
||||
/** 成功正式发布累计次数 */
|
||||
publishSuccessCount?: number;
|
||||
/** 成功推过草稿的店铺数 */
|
||||
pushShopCount?: number;
|
||||
/** 成功发布过的店铺数 */
|
||||
publishShopCount?: number;
|
||||
createdBy?: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
|
||||
@@ -56,11 +56,23 @@ export const useColSidebarLayoutStore = defineStore(
|
||||
}
|
||||
|
||||
function setWidth(kind: ColSidebarKind, width: number) {
|
||||
layoutOf(kind).width = clampWidth(width);
|
||||
const next = clampWidth(width);
|
||||
const prev = layoutOf(kind);
|
||||
if (prev.width === next) return;
|
||||
// 整对象替换,确保 pinia persist 能稳定序列化
|
||||
layouts.value = {
|
||||
...layouts.value,
|
||||
[kind]: { ...prev, width: next },
|
||||
};
|
||||
}
|
||||
|
||||
function setCollapsed(kind: ColSidebarKind, collapsed: boolean) {
|
||||
layoutOf(kind).collapsed = collapsed;
|
||||
const prev = layoutOf(kind);
|
||||
if (prev.collapsed === collapsed) return;
|
||||
layouts.value = {
|
||||
...layouts.value,
|
||||
[kind]: { ...prev, collapsed },
|
||||
};
|
||||
}
|
||||
|
||||
function $reset() {
|
||||
|
||||
@@ -84,7 +84,7 @@ const { width: leftWidth, collapsed: leftCollapsed } =
|
||||
>
|
||||
<PddShopSidebarList
|
||||
fluid
|
||||
:collapsed="isCollapsed"
|
||||
:collapsed="!!isCollapsed"
|
||||
show-collapse-action
|
||||
:selected-shop-id="selectedShopId"
|
||||
:show-add-action="showAddAction"
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { Alert, Card, DatePicker, Input, message } from 'ant-design-vue';
|
||||
import { DatePicker, Input, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getPddGoodsAdFeePageApi } from '#/api/channel/pdd/goods-ad-fee';
|
||||
@@ -154,7 +154,7 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
||||
@select="onShopSelect"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
@@ -197,15 +197,6 @@ const formatAmount = (amount: number) => `¥${Number(amount || 0).toFixed(2)}`;
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="px-2 pt-2 sm:px-3">
|
||||
<Alert
|
||||
type="info"
|
||||
show-icon
|
||||
message="手动维护已关闭"
|
||||
description="请通过浏览器扩展批量导入推广费;导入与转换进度可在「店铺管理」推广费管线查看。"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-2 sm:px-3 sm:pb-3"
|
||||
>
|
||||
|
||||
@@ -291,7 +291,7 @@ onMounted(async () => {
|
||||
<template>
|
||||
<PddShopColPage :selected-shop-id="selectedShopId" @select="onShopSelect">
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
|
||||
+3
-7
@@ -753,12 +753,8 @@ export function usePublishDraft(options: {
|
||||
}
|
||||
const hide = message.loading('推送到拼多多草稿箱…', 0);
|
||||
try {
|
||||
const vo = await pushPddPublishDeskDraftApi(saved.id);
|
||||
message.success(
|
||||
vo.pddGoodsCommitId
|
||||
? `已推送到拼多多草稿箱(ID ${vo.pddGoodsCommitId})`
|
||||
: '已推送到拼多多草稿箱',
|
||||
);
|
||||
await pushPddPublishDeskDraftApi(saved.id);
|
||||
message.success('已推送到拼多多草稿箱');
|
||||
} finally {
|
||||
hide();
|
||||
}
|
||||
@@ -774,7 +770,7 @@ export function usePublishDraft(options: {
|
||||
submitting.value = true;
|
||||
const hide = message.loading('正在保存并发布…', 0);
|
||||
try {
|
||||
// 先落/更新系统草稿(含 publishPayload),再发布以便回写 goods_commit_id / goods_id
|
||||
// 先落/更新系统草稿(含 publishPayload),再发布;成功后后端累加发布次数并标 READY
|
||||
const saved = await saveDeskDraft(true, { silentSuccess: true });
|
||||
if (!saved?.id) return;
|
||||
|
||||
|
||||
@@ -68,8 +68,6 @@ const statusLabel: Record<string, { text: string; color: string }> = {
|
||||
READY: { text: '可发布', color: 'blue' },
|
||||
PUBLISHING: { text: '发布中', color: 'processing' },
|
||||
FAILED: { text: '失败', color: 'error' },
|
||||
PUBLISHED: { text: '已发布', color: 'success' },
|
||||
REJECTED: { text: '审核驳回', color: 'error' },
|
||||
};
|
||||
|
||||
const countByShopId = computed(() => {
|
||||
@@ -103,7 +101,7 @@ const columns = [
|
||||
{ title: '店铺', dataIndex: 'shopName', key: 'shopName', width: 140 },
|
||||
{ title: 'SKU数', dataIndex: 'skuCount', key: 'skuCount', width: 88 },
|
||||
{ title: '状态', key: 'status', width: 140 },
|
||||
{ title: '拼多多草稿', key: 'platformDraft', width: 148 },
|
||||
{ title: '投递统计', key: 'deliveryStat', width: 160 },
|
||||
{ title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', width: 170 },
|
||||
{ title: '操作', key: 'actions', width: 280 },
|
||||
];
|
||||
@@ -244,12 +242,8 @@ async function pushPlatform(draft: {
|
||||
pushingDraftId.value = draft.id;
|
||||
const hide = message.loading('推送到拼多多草稿箱…', 0);
|
||||
try {
|
||||
const vo = await pushPddPublishDeskDraftApi(draft.id);
|
||||
message.success(
|
||||
vo.pddGoodsCommitId
|
||||
? `已推送到拼多多草稿箱(ID ${vo.pddGoodsCommitId})`
|
||||
: '已推送到拼多多草稿箱',
|
||||
);
|
||||
await pushPddPublishDeskDraftApi(draft.id);
|
||||
message.success('已推送到拼多多草稿箱');
|
||||
await loadDrafts();
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '推送失败');
|
||||
@@ -485,7 +479,7 @@ onUnmounted(() => stopJobPoll());
|
||||
@select-unassigned="selectUnassigned"
|
||||
>
|
||||
<Card
|
||||
class="publish-desk-card ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden sm:ml-2"
|
||||
class="publish-desk-card flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden"
|
||||
:body-style="{
|
||||
flex: 1,
|
||||
minHeight: 0,
|
||||
@@ -585,31 +579,26 @@ onUnmounted(() => stopJobPoll());
|
||||
</Popover>
|
||||
<span v-else>{{ record.skuCount ?? 0 }}</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'platformDraft'">
|
||||
<div v-if="record.pddGoodsCommitId">
|
||||
<Tag color="green">已推送</Tag>
|
||||
<div
|
||||
class="text-muted-foreground mt-1 max-w-[130px] truncate text-xs"
|
||||
:title="String(record.pddGoodsCommitId)"
|
||||
>
|
||||
{{ record.pddGoodsCommitId }}
|
||||
<template v-else-if="column.key === 'deliveryStat'">
|
||||
<div class="text-xs leading-5">
|
||||
<div>
|
||||
推草稿
|
||||
{{ record.pushSuccessCount ?? 0 }} 次 /
|
||||
{{ record.pushShopCount ?? 0 }} 店
|
||||
</div>
|
||||
<div>
|
||||
已发布
|
||||
{{ record.publishSuccessCount ?? 0 }} 次 /
|
||||
{{ record.publishShopCount ?? 0 }} 店
|
||||
</div>
|
||||
</div>
|
||||
<span v-else class="text-muted-foreground text-xs">未推送</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'status'">
|
||||
<Tag :color="statusLabel[record.status]?.color || 'default'">
|
||||
{{ statusLabel[record.status]?.text || record.status }}
|
||||
</Tag>
|
||||
<div
|
||||
v-if="record.status === 'REJECTED' && record.rejectComment"
|
||||
class="mt-1 max-w-[160px] truncate text-xs text-red-500"
|
||||
:title="record.rejectComment"
|
||||
>
|
||||
{{ record.rejectComment }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="record.lastError"
|
||||
v-if="record.lastError"
|
||||
class="mt-1 max-w-[160px] truncate text-xs text-red-500"
|
||||
:title="record.lastError"
|
||||
>
|
||||
|
||||
@@ -344,7 +344,7 @@ function openDetail(row: PddOrderVO.Info) {
|
||||
@select="onShopSelect"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
|
||||
@@ -8,11 +8,16 @@ import CompanySidebarList from '#/views/company/components/CompanySidebarList.vu
|
||||
|
||||
defineOptions({ name: 'CompanyColPage' });
|
||||
|
||||
/** 公司侧栏:展开/宽度走全局持久化,跨页面共用 */
|
||||
/** 公司侧栏:展开/宽度走全局持久化,菜单/权限/账户等跨页共用 */
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
selectedCompanyId?: number;
|
||||
showAllOption?: boolean;
|
||||
allOptionLabel?: string;
|
||||
allOptionHint?: string;
|
||||
showAddAction?: boolean;
|
||||
addPermissionCode?: string;
|
||||
autoContentHeight?: boolean;
|
||||
leftMinWidth?: number;
|
||||
leftMaxWidth?: number;
|
||||
@@ -23,6 +28,11 @@ withDefaults(
|
||||
splitLine?: boolean;
|
||||
}>(),
|
||||
{
|
||||
showAllOption: false,
|
||||
allOptionLabel: '全部公司',
|
||||
allOptionHint: '全部记录',
|
||||
showAddAction: false,
|
||||
addPermissionCode: undefined,
|
||||
autoContentHeight: true,
|
||||
leftMinWidth: 16,
|
||||
leftMaxWidth: 36,
|
||||
@@ -36,7 +46,8 @@ withDefaults(
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:selectedCompanyId': [id: number | undefined];
|
||||
select: [company: CompanyVO.CompanyInfoVO];
|
||||
select: [company: CompanyVO.CompanyInfoVO | null];
|
||||
addForCompany: [company: CompanyVO.CompanyInfoVO];
|
||||
}>();
|
||||
|
||||
const { width: leftWidth, collapsed: leftCollapsed } =
|
||||
@@ -70,13 +81,19 @@ const { width: leftWidth, collapsed: leftCollapsed } =
|
||||
>
|
||||
<CompanySidebarList
|
||||
fluid
|
||||
:collapsed="isCollapsed"
|
||||
:collapsed="!!isCollapsed"
|
||||
show-collapse-action
|
||||
:selected-company-id="selectedCompanyId"
|
||||
:show-all-option="showAllOption"
|
||||
:all-option-label="allOptionLabel"
|
||||
:all-option-hint="allOptionHint"
|
||||
:show-add-action="showAddAction"
|
||||
:add-permission-code="addPermissionCode"
|
||||
@collapse="collapse"
|
||||
@expand="expand"
|
||||
@update:selected-company-id="emit('update:selectedCompanyId', $event)"
|
||||
@select="emit('select', $event)"
|
||||
@add-for-company="emit('addForCompany', $event)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -18,12 +18,14 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getCompanyPageApi } from '#/api/company';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import CompanyLogoAvatar from '#/views/company/components/CompanyLogoAvatar.vue';
|
||||
|
||||
defineOptions({ name: 'CompanySidebarList' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** undefined = 未选 / 全部(需 showAllOption) */
|
||||
selectedCompanyId?: number;
|
||||
/** 填满父容器宽度(ColPage 左栏);默认固定 320px */
|
||||
fluid?: boolean;
|
||||
@@ -31,23 +33,39 @@ const props = withDefaults(
|
||||
showCollapseAction?: boolean;
|
||||
/** 窄栏模式:仅展示 logo 列表(ColPage 收起态) */
|
||||
collapsed?: boolean;
|
||||
/** 展示「全部」筛选项(如账户页) */
|
||||
showAllOption?: boolean;
|
||||
allOptionLabel?: string;
|
||||
allOptionHint?: string;
|
||||
/** 行内「添加」快捷按钮 */
|
||||
showAddAction?: boolean;
|
||||
/** 添加按钮权限码;不传则仅看 showAddAction */
|
||||
addPermissionCode?: string;
|
||||
}>(),
|
||||
{
|
||||
selectedCompanyId: undefined,
|
||||
fluid: false,
|
||||
showCollapseAction: false,
|
||||
collapsed: false,
|
||||
showAllOption: false,
|
||||
allOptionLabel: '全部公司',
|
||||
allOptionHint: '全部记录',
|
||||
showAddAction: false,
|
||||
addPermissionCode: undefined,
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:selectedCompanyId': [id: number | undefined];
|
||||
select: [company: CompanyVO.CompanyInfoVO];
|
||||
/** 选中公司;null 表示「全部」 */
|
||||
select: [company: CompanyVO.CompanyInfoVO | null];
|
||||
addForCompany: [company: CompanyVO.CompanyInfoVO];
|
||||
collapse: [];
|
||||
expand: [];
|
||||
}>();
|
||||
|
||||
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const PanelCloseIcon = createIconifyIcon('lucide:panel-left-close');
|
||||
const PanelOpenIcon = createIconifyIcon('lucide:panel-left-open');
|
||||
const ChevronUpIcon = createIconifyIcon('lucide:chevron-up');
|
||||
@@ -67,6 +85,10 @@ const companyTotalPages = computed(() => {
|
||||
return Math.max(1, Math.ceil(total / pageSize) || 1);
|
||||
});
|
||||
|
||||
const allSelected = computed(
|
||||
() => props.showAllOption && props.selectedCompanyId === undefined,
|
||||
);
|
||||
|
||||
async function searchCompanies(resetPage = false) {
|
||||
if (resetPage) {
|
||||
companyPagination.value.current = 1;
|
||||
@@ -103,11 +125,22 @@ function goCompanyPage(page: number) {
|
||||
void searchCompanies();
|
||||
}
|
||||
|
||||
function selectAll() {
|
||||
emit('update:selectedCompanyId', undefined);
|
||||
emit('select', null);
|
||||
}
|
||||
|
||||
function selectCompany(company: CompanyVO.CompanyInfoVO) {
|
||||
emit('update:selectedCompanyId', company.id);
|
||||
emit('select', company);
|
||||
}
|
||||
|
||||
function onAddForCompany(company: CompanyVO.CompanyInfoVO, event: Event) {
|
||||
event.stopPropagation();
|
||||
selectCompany(company);
|
||||
emit('addForCompany', company);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void searchCompanies();
|
||||
});
|
||||
@@ -127,13 +160,36 @@ onMounted(() => {
|
||||
<div
|
||||
class="flex min-h-0 w-full flex-1 flex-col items-center gap-1.5 overflow-y-auto px-1.5 pb-1 pt-2"
|
||||
>
|
||||
<Tooltip v-if="showAllOption" :title="allOptionLabel">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||
:class="
|
||||
allSelected
|
||||
? 'ring-2 ring-primary ring-offset-1 ring-offset-background'
|
||||
: undefined
|
||||
"
|
||||
@click="selectAll"
|
||||
>
|
||||
<div
|
||||
class="flex h-9 w-9 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||
>
|
||||
<BuildingIcon class="h-4 w-4 text-muted-foreground" />
|
||||
</div>
|
||||
</button>
|
||||
</Tooltip>
|
||||
|
||||
<Spin
|
||||
:spinning="companiesLoading"
|
||||
size="small"
|
||||
wrapper-class-name="company-sidebar-collapsed-spin"
|
||||
>
|
||||
<div class="flex w-full flex-col items-center gap-1.5">
|
||||
<Tooltip v-for="company in companies" :key="company.id" :title="company.name">
|
||||
<Tooltip
|
||||
v-for="company in companies"
|
||||
:key="company.id"
|
||||
:title="company.name"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||
@@ -175,7 +231,9 @@ onMounted(() => {
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-6 !px-1"
|
||||
:disabled="companyPagination.current >= companyTotalPages || companiesLoading"
|
||||
:disabled="
|
||||
companyPagination.current >= companyTotalPages || companiesLoading
|
||||
"
|
||||
@click="goCompanyPage(companyPagination.current + 1)"
|
||||
>
|
||||
<ChevronDownIcon class="h-3.5 w-3.5" />
|
||||
@@ -240,20 +298,50 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||
<Spin :spinning="companiesLoading">
|
||||
<div class="flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto">
|
||||
<Card
|
||||
v-if="showAllOption"
|
||||
size="small"
|
||||
:body-style="{ padding: '10px 12px' }"
|
||||
class="cursor-pointer !shadow-none hover:border-primary"
|
||||
:class="allSelected ? 'border-primary bg-primary/5' : undefined"
|
||||
@click="selectAll"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<div
|
||||
class="flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||
>
|
||||
<BuildingIcon class="h-4 w-4 text-muted-foreground" />
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<span class="min-w-0 truncate text-sm font-medium">
|
||||
{{ allOptionLabel }}
|
||||
</span>
|
||||
<span class="shrink-0 text-xs text-muted-foreground">
|
||||
{{ allOptionHint }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Spin
|
||||
:spinning="companiesLoading"
|
||||
wrapper-class-name="company-sidebar-list-spin"
|
||||
>
|
||||
<Empty
|
||||
v-if="!companiesLoading && companies.length === 0"
|
||||
class="py-8"
|
||||
description="暂无公司"
|
||||
/>
|
||||
<template v-else>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<Card
|
||||
v-for="company in companies"
|
||||
:key="company.id"
|
||||
size="small"
|
||||
:body-style="{ padding: '10px 12px' }"
|
||||
class="mb-2 cursor-pointer !shadow-none last:mb-0 hover:border-primary"
|
||||
class="group cursor-pointer !shadow-none hover:border-primary"
|
||||
:class="
|
||||
selectedCompanyId === company.id
|
||||
? 'border-primary bg-primary/5'
|
||||
@@ -267,20 +355,50 @@ onMounted(() => {
|
||||
:name="company.name"
|
||||
:size="36"
|
||||
/>
|
||||
<div class="flex min-w-0 flex-1 items-center justify-between gap-2">
|
||||
<div
|
||||
class="flex min-w-0 flex-1 items-center justify-between gap-2"
|
||||
>
|
||||
<span class="min-w-0 truncate text-sm font-medium">
|
||||
{{ company.name }}
|
||||
</span>
|
||||
<Tag
|
||||
class="m-0 shrink-0"
|
||||
:color="company.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<Tag
|
||||
class="m-0"
|
||||
:color="company.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
<template v-if="showAddAction">
|
||||
<PermissionGate
|
||||
v-if="addPermissionCode"
|
||||
:code="addPermissionCode"
|
||||
>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click="onAddForCompany(company, $event)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<Button
|
||||
v-else
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click="onAddForCompany(company, $event)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
</div>
|
||||
</Spin>
|
||||
</div>
|
||||
|
||||
@@ -332,4 +450,12 @@ onMounted(() => {
|
||||
align-items: center;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
:deep(.company-sidebar-list-spin),
|
||||
:deep(.company-sidebar-list-spin .ant-spin-container) {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -67,7 +67,8 @@ const stats = computed(() => ({
|
||||
changed: selectedMenuIds.value.length !== companyMenuIds.value.length,
|
||||
}));
|
||||
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO) {
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO | null) {
|
||||
if (!company) return;
|
||||
currentCompany.value = company;
|
||||
selectedCompanyId.value = company.id;
|
||||
void loadCompanyMenus();
|
||||
@@ -175,7 +176,7 @@ async function handleSave() {
|
||||
@select="onCompanySelect"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
|
||||
@@ -102,7 +102,8 @@ function collectExpandableKeys(nodes: PermissionVO.PermissionInfoVO[]): number[]
|
||||
return keys;
|
||||
}
|
||||
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO) {
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO | null) {
|
||||
if (!company) return;
|
||||
currentCompany.value = company;
|
||||
selectedCompanyId.value = company.id;
|
||||
void loadCompanyPermissions();
|
||||
@@ -196,7 +197,7 @@ onMounted(() => {
|
||||
@select="onCompanySelect"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
|
||||
@@ -74,7 +74,7 @@ const { width: leftWidth, collapsed: leftCollapsed } =
|
||||
>
|
||||
<ShopSidebarList
|
||||
fluid
|
||||
:collapsed="isCollapsed"
|
||||
:collapsed="!!isCollapsed"
|
||||
show-collapse-action
|
||||
:selected-shop-id="selectedShopId"
|
||||
:show-add-action="showAddAction"
|
||||
|
||||
@@ -671,7 +671,7 @@ onMounted(async () => {
|
||||
@add-for-shop="handleAddForShop"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
|
||||
@@ -197,13 +197,7 @@ function handleModalSuccess() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="商品类目配置" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理商品类目,支持多级分类
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<Page auto-content-height>
|
||||
<Grid :loading="loading">
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
|
||||
@@ -227,7 +227,7 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
||||
@add-for-shop="handleAddForShop"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
|
||||
@@ -317,7 +317,7 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
||||
@add-for-shop="handleAddForShop"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
|
||||
@@ -229,7 +229,7 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
||||
@add-for-shop="handleAddForShop"
|
||||
>
|
||||
<Card
|
||||
class="ml-1 flex h-full min-h-0 min-w-0 flex-1 flex-col sm:ml-2"
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
|
||||
@@ -7,65 +7,43 @@ import type {
|
||||
} from '#/api/sys/account';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Empty,
|
||||
Flex,
|
||||
Input,
|
||||
message,
|
||||
Pagination,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getCompanyPageApi } from '#/api/company';
|
||||
import {
|
||||
super_deleteAccountApi,
|
||||
super_getAccountPageApi,
|
||||
} from '#/api/sys/account';
|
||||
|
||||
import AccountFormModal from './components/AccountFormModal.vue';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
import {
|
||||
SIDEBAR_LIST_SHELL_CLASS,
|
||||
sidebarListRowClass,
|
||||
} from '#/utils/sidebar-list-styles';
|
||||
import CompanyColPage from '#/views/company/components/CompanyColPage.vue';
|
||||
|
||||
import AccountFormModal from './components/AccountFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'SysAccountManagement' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
||||
|
||||
const loading = ref(false);
|
||||
const accountFormModalRef = ref();
|
||||
|
||||
const companySearchForm = ref({
|
||||
name: '',
|
||||
status: undefined as number | undefined,
|
||||
});
|
||||
|
||||
const companyList = ref<CompanyVO.CompanyInfoVO[]>([]);
|
||||
const companyLoading = ref(false);
|
||||
const companyPagination = ref({
|
||||
current: 1,
|
||||
pageSize: 20,
|
||||
total: 0,
|
||||
});
|
||||
|
||||
const selectedCompanyId = ref<number | undefined>(undefined);
|
||||
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
@@ -246,44 +224,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
syncVxeGridColumns(gridApi, accountTableColumns);
|
||||
|
||||
async function searchCompanies() {
|
||||
companyLoading.value = true;
|
||||
try {
|
||||
const result = await getCompanyPageApi({
|
||||
page: companyPagination.value.current,
|
||||
pageSize: companyPagination.value.pageSize,
|
||||
filters: {
|
||||
name: companySearchForm.value.name || undefined,
|
||||
status: companySearchForm.value.status,
|
||||
},
|
||||
});
|
||||
companyList.value = result.records;
|
||||
companyPagination.value.total = result.total;
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '获取公司列表失败');
|
||||
} finally {
|
||||
companyLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function resetCompanySearch() {
|
||||
companySearchForm.value = { name: '', status: undefined };
|
||||
companyPagination.value.current = 1;
|
||||
searchCompanies();
|
||||
}
|
||||
|
||||
function handleCompanyPageChange(page: number, pageSize: number) {
|
||||
companyPagination.value.current = page;
|
||||
companyPagination.value.pageSize = pageSize;
|
||||
searchCompanies();
|
||||
}
|
||||
|
||||
function selectCompanyAll() {
|
||||
currentCompany.value = null;
|
||||
}
|
||||
|
||||
function selectCompany(company: CompanyVO.CompanyInfoVO) {
|
||||
function onCompanySelect(company: CompanyVO.CompanyInfoVO | null) {
|
||||
currentCompany.value = company;
|
||||
selectedCompanyId.value = company?.id;
|
||||
}
|
||||
|
||||
function refreshTable() {
|
||||
@@ -299,7 +242,8 @@ function handleAdd() {
|
||||
}
|
||||
|
||||
function handleAddForCompany(company: CompanyVO.CompanyInfoVO) {
|
||||
selectCompany(company);
|
||||
currentCompany.value = company;
|
||||
selectedCompanyId.value = company.id;
|
||||
accountFormModalRef.value?.open(undefined, company);
|
||||
}
|
||||
|
||||
@@ -339,251 +283,125 @@ function getStatusColor(status: number) {
|
||||
return colorMap[status] || 'default';
|
||||
}
|
||||
|
||||
function companyRowClass(id: number | 'all') {
|
||||
const active =
|
||||
id === 'all'
|
||||
? currentCompany.value === null
|
||||
: currentCompany.value?.id === id;
|
||||
const layout =
|
||||
id === 'all'
|
||||
? 'mb-1.5 flex w-full cursor-pointer items-center gap-2 text-left'
|
||||
: 'group flex w-full cursor-pointer items-center gap-2';
|
||||
return sidebarListRowClass(active, layout);
|
||||
}
|
||||
|
||||
watch(currentCompany, () => {
|
||||
gridApi.reload();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
searchCompanies();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="系统账户管理" :auto-content-height="true">
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
左侧选择公司筛选右侧账户;首项「全部账户」展示所有账户,可在公司行快捷新增。
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<Flex gap="middle" class="h-full min-h-0">
|
||||
<Card
|
||||
class="flex h-full w-[420px] shrink-0 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
minHeight: 0,
|
||||
padding: '12px',
|
||||
}"
|
||||
>
|
||||
<template #title>
|
||||
<span class="flex items-center gap-2 text-base font-semibold">
|
||||
<BuildingIcon class="h-4 w-4" />
|
||||
公司
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<Flex wrap="wrap" align="center" class="shrink-0 gap-2">
|
||||
<CompanyColPage
|
||||
:selected-company-id="selectedCompanyId"
|
||||
show-all-option
|
||||
all-option-label="全部账户"
|
||||
all-option-hint="全部记录"
|
||||
show-add-action
|
||||
add-permission-code="sys:account:create"
|
||||
@select="onCompanySelect"
|
||||
@add-for-company="handleAddForCompany"
|
||||
>
|
||||
<Card
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}"
|
||||
>
|
||||
<template #title>
|
||||
<span class="text-base font-semibold">账户列表</span>
|
||||
</template>
|
||||
<template #extra>
|
||||
<Space wrap size="small" class="max-w-[min(100%,48rem)]">
|
||||
<Input
|
||||
v-model:value="companySearchForm.name"
|
||||
placeholder="公司名称"
|
||||
v-model:value="searchForm.username"
|
||||
allow-clear
|
||||
class="min-w-[140px] flex-1"
|
||||
@press-enter="searchCompanies"
|
||||
placeholder="登录用户名"
|
||||
class="w-[120px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="searchForm.realName"
|
||||
allow-clear
|
||||
placeholder="姓名"
|
||||
class="w-[100px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="searchForm.phone"
|
||||
allow-clear
|
||||
placeholder="手机号"
|
||||
class="w-[120px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="companySearchForm.status"
|
||||
placeholder="状态"
|
||||
v-model:value="searchForm.status"
|
||||
allow-clear
|
||||
class="w-[88px]"
|
||||
:options="[
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 },
|
||||
]"
|
||||
placeholder="状态"
|
||||
class="min-w-[88px]"
|
||||
:options="statusOptions"
|
||||
@change="refreshTable"
|
||||
/>
|
||||
<Button type="primary" size="small" @click="searchCompanies">
|
||||
搜索
|
||||
</Button>
|
||||
<Button size="small" @click="resetCompanySearch">重置</Button>
|
||||
</Flex>
|
||||
<Button size="small" @click="refreshTable">查询</Button>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button type="primary" size="small" @click="handleAdd">
|
||||
<PlusIcon class="mr-1 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<Spin :spinning="companyLoading" class="flex min-h-0 flex-1 flex-col">
|
||||
<div :class="SIDEBAR_LIST_SHELL_CLASS">
|
||||
<button
|
||||
type="button"
|
||||
:class="companyRowClass('all')"
|
||||
@click="selectCompanyAll"
|
||||
>
|
||||
<span class="min-w-0 flex-1 truncate">全部账户</span>
|
||||
<span class="shrink-0 text-xs font-normal text-muted-foreground">
|
||||
全部记录
|
||||
</span>
|
||||
</button>
|
||||
<Empty
|
||||
v-if="!companyLoading && companyList.length === 0"
|
||||
class="py-8"
|
||||
description="暂无公司"
|
||||
/>
|
||||
<div v-else class="space-y-1">
|
||||
<div
|
||||
v-for="company in companyList"
|
||||
:key="company.id"
|
||||
:class="companyRowClass(company.id)"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="min-w-0 flex-1 truncate text-left"
|
||||
@click="selectCompany(company)"
|
||||
>
|
||||
<span class="block truncate">{{ company.name }}</span>
|
||||
<span
|
||||
class="mt-0.5 block truncate text-xs font-normal text-muted-foreground"
|
||||
>
|
||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||
</span>
|
||||
</button>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 shrink-0 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click.stop="handleAddForCompany(company)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Flex justify="center" class="mt-2 shrink-0 pt-1">
|
||||
<Pagination
|
||||
v-model:current="companyPagination.current"
|
||||
v-model:page-size="companyPagination.pageSize"
|
||||
:total="companyPagination.total"
|
||||
size="small"
|
||||
:show-size-changer="true"
|
||||
:show-quick-jumper="true"
|
||||
@change="handleCompanyPageChange"
|
||||
/>
|
||||
</Flex>
|
||||
</Spin>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||
:body-style="{
|
||||
height: '100%',
|
||||
minHeight: 0,
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}"
|
||||
<div
|
||||
class="text-muted-foreground shrink-0 border-t border-border px-4 py-2 text-xs"
|
||||
>
|
||||
<template #title>
|
||||
<span class="text-base font-semibold">账户列表</span>
|
||||
</template>
|
||||
<template #extra>
|
||||
<Space wrap size="small" class="max-w-[min(100%,42rem)]">
|
||||
<Input
|
||||
v-model:value="searchForm.username"
|
||||
allow-clear
|
||||
placeholder="登录用户名"
|
||||
class="w-[120px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="searchForm.realName"
|
||||
allow-clear
|
||||
placeholder="姓名"
|
||||
class="w-[100px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="searchForm.phone"
|
||||
allow-clear
|
||||
placeholder="手机号"
|
||||
class="w-[120px]"
|
||||
@press-enter="refreshTable"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="searchForm.status"
|
||||
allow-clear
|
||||
placeholder="状态"
|
||||
class="min-w-[88px]"
|
||||
:options="statusOptions"
|
||||
@change="refreshTable"
|
||||
/>
|
||||
<Button size="small" @click="refreshTable">查询</Button>
|
||||
</Space>
|
||||
当前:{{ selectedCompanyLabel }}
|
||||
<template v-if="currentCompany">
|
||||
<Tag
|
||||
class="ml-2"
|
||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="shrink-0 border-t border-border px-4 py-2 text-xs text-muted-foreground"
|
||||
>
|
||||
当前:{{ selectedCompanyLabel }}
|
||||
<template v-if="currentCompany">
|
||||
<Tag
|
||||
class="ml-2"
|
||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-0 sm:px-3 sm:pb-3"
|
||||
>
|
||||
<Grid :loading="loading" class="h-full min-h-0">
|
||||
<template #toolbar-tools>
|
||||
<span class="text-muted-foreground text-xs">
|
||||
左侧筛选公司;表格在区域内滚动
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
<Tag :color="getStatusColor(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-0 sm:px-3 sm:pb-3"
|
||||
>
|
||||
<Grid :loading="loading" class="h-full min-h-0">
|
||||
<template #toolbar-tools>
|
||||
<span class="text-xs text-muted-foreground">
|
||||
使用上方筛选条件查询;表格在区域内滚动
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
<Tag :color="getStatusColor(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="sys:account:update">
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="sys:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</Card>
|
||||
</Flex>
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="sys:account:update">
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="sys:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<AccountFormModal ref="accountFormModalRef" @success="handleModalSuccess" />
|
||||
</Page>
|
||||
</CompanyColPage>
|
||||
</template>
|
||||
|
||||
+7
-16
@@ -26,15 +26,11 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"bootstrap": "pnpm install",
|
||||
"build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 turbo build",
|
||||
"build:analyze": "turbo build:analyze",
|
||||
"build:antd": "pnpm run build --filter=@vben/web-antd",
|
||||
"build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 turbo build --filter=@vben/web-antd",
|
||||
"build:analyze": "pnpm -F @vben/web-antd run build:analyze",
|
||||
"build:antd": "pnpm run build",
|
||||
"build:docker": "./scripts/deploy/build-local-docker-image.sh",
|
||||
"build:docs": "pnpm run build --filter=@vben/docs",
|
||||
"build:ele": "pnpm run build --filter=@vben/web-ele",
|
||||
"build:naive": "pnpm run build --filter=@vben/web-naive",
|
||||
"build:tdesign": "pnpm run build --filter=@vben/web-tdesign",
|
||||
"build:play": "pnpm run build --filter=@vben/playground",
|
||||
"build:play": "turbo build --filter=@vben/playground",
|
||||
"changeset": "pnpm exec changeset",
|
||||
"check": "pnpm run check:circular && pnpm run check:dep && pnpm run check:type && pnpm check:cspell",
|
||||
"check:circular": "vsh check-circular",
|
||||
@@ -43,20 +39,15 @@
|
||||
"check:type": "turbo run typecheck",
|
||||
"clean": "node ./scripts/clean.mjs",
|
||||
"commit": "czg",
|
||||
"dev": "turbo-run dev",
|
||||
"dev:antd": "pnpm -F @vben/web-antd run dev",
|
||||
"dev:antdv-next": "pnpm -F @vben/web-antdv-next run dev",
|
||||
"dev:docs": "pnpm -F @vben/docs run dev",
|
||||
"dev:ele": "pnpm -F @vben/web-ele run dev",
|
||||
"dev:naive": "pnpm -F @vben/web-naive run dev",
|
||||
"dev:tdesign": "pnpm -F @vben/web-tdesign run dev",
|
||||
"dev": "pnpm -F @vben/web-antd run dev",
|
||||
"dev:antd": "pnpm run dev",
|
||||
"dev:play": "pnpm -F @vben/playground run dev",
|
||||
"format": "vsh lint --format",
|
||||
"lint": "vsh lint",
|
||||
"postinstall": "pnpm -r run stub --if-present",
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
"prepare": "is-ci || pnpm exec lefthook install",
|
||||
"preview": "turbo-run preview",
|
||||
"preview": "pnpm -F @vben/web-antd run preview",
|
||||
"publint": "vsh publint",
|
||||
"reinstall": "pnpm clean --del-lock && pnpm install",
|
||||
"test:unit": "vitest run --dom",
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ColPageProps } from './types';
|
||||
|
||||
import { computed, ref, useSlots } from 'vue';
|
||||
import {
|
||||
computed,
|
||||
nextTick,
|
||||
onMounted,
|
||||
ref,
|
||||
toValue,
|
||||
useSlots,
|
||||
watch,
|
||||
} from 'vue';
|
||||
|
||||
import {
|
||||
ResizableHandle,
|
||||
@@ -20,10 +28,21 @@ const props = withDefaults(defineProps<ColPageProps>(), {
|
||||
leftWidth: 30,
|
||||
rightWidth: 70,
|
||||
resizable: true,
|
||||
leftCollapsed: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:leftWidth': [width: number];
|
||||
'update:leftCollapsed': [collapsed: boolean];
|
||||
}>();
|
||||
|
||||
const delegatedProps = computed(() => {
|
||||
const { leftWidth: _, ...delegated } = props;
|
||||
const {
|
||||
leftWidth: _lw,
|
||||
leftCollapsed: _lc,
|
||||
rightWidth: _rw,
|
||||
...delegated
|
||||
} = props;
|
||||
return delegated;
|
||||
});
|
||||
|
||||
@@ -40,7 +59,32 @@ const delegatedSlots = computed(() => {
|
||||
return resultSlots;
|
||||
});
|
||||
|
||||
const leftPanelRef = ref<InstanceType<typeof ResizablePanel>>();
|
||||
type LeftPanelExpose = {
|
||||
collapse: () => void;
|
||||
expand: () => void;
|
||||
getSize?: () => number;
|
||||
resize?: (size: number) => void;
|
||||
isCollapsed?: boolean | { value: boolean };
|
||||
};
|
||||
|
||||
const leftPanelRef = ref<LeftPanelExpose | null>(null);
|
||||
|
||||
/** 拖拽/程序化同步时跳过写回,避免回环 */
|
||||
let syncingFromProp = false;
|
||||
/**
|
||||
* Panel 首次 layout 会在 lastSize=null 时误抛 expand,
|
||||
* 若立刻写回会把持久化的 collapsed=true 冲掉。就绪后再接受用户操作。
|
||||
*/
|
||||
let layoutReady = false;
|
||||
|
||||
function isLeftPanelCollapsed() {
|
||||
const flag = leftPanelRef.value?.isCollapsed;
|
||||
if (typeof flag === 'boolean') return flag;
|
||||
if (flag && typeof flag === 'object' && 'value' in flag) {
|
||||
return !!flag.value;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function expandLeft() {
|
||||
leftPanelRef.value?.expand();
|
||||
@@ -50,6 +94,114 @@ function collapseLeft() {
|
||||
leftPanelRef.value?.collapse();
|
||||
}
|
||||
|
||||
function isCollapsedSize(size: number) {
|
||||
const collapsedSize = props.leftCollapsedWidth ?? 0;
|
||||
return props.leftCollapsible && size <= collapsedSize + 0.5;
|
||||
}
|
||||
|
||||
/** 把展开宽度写回父级(忽略收起态的小宽度) */
|
||||
function commitLeftWidth(size: number) {
|
||||
if (!layoutReady || syncingFromProp) return;
|
||||
if (!Number.isFinite(size) || isCollapsedSize(size)) return;
|
||||
if (Math.abs(size - props.leftWidth) < 0.05) return;
|
||||
emit('update:leftWidth', size);
|
||||
}
|
||||
|
||||
/** Group layout 比单 Panel resize 更稳(拖拽过程/结束都会来) */
|
||||
function onLayout(sizes: number[]) {
|
||||
const left = sizes[0];
|
||||
if (left == null) return;
|
||||
commitLeftWidth(left);
|
||||
}
|
||||
|
||||
function onLeftCollapse() {
|
||||
if (!layoutReady || syncingFromProp) return;
|
||||
if (props.leftCollapsed) return;
|
||||
emit('update:leftCollapsed', true);
|
||||
}
|
||||
|
||||
function onLeftExpand() {
|
||||
if (!layoutReady || syncingFromProp) return;
|
||||
if (!props.leftCollapsed) return;
|
||||
emit('update:leftCollapsed', false);
|
||||
}
|
||||
|
||||
function syncCollapsedFromProp(collapsed: boolean) {
|
||||
if (!leftPanelRef.value) return;
|
||||
const current = isLeftPanelCollapsed();
|
||||
if (collapsed && !current) {
|
||||
syncingFromProp = true;
|
||||
try {
|
||||
collapseLeft();
|
||||
} finally {
|
||||
void nextTick(() => {
|
||||
syncingFromProp = false;
|
||||
});
|
||||
}
|
||||
} else if (!collapsed && current) {
|
||||
syncingFromProp = true;
|
||||
try {
|
||||
expandLeft();
|
||||
} finally {
|
||||
void nextTick(() => {
|
||||
syncingFromProp = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 按持久化宽度强制套到 Panel(default-size 仅注册时生效一次) */
|
||||
function applyWidthFromProp() {
|
||||
const panel = leftPanelRef.value;
|
||||
if (!panel?.resize) return;
|
||||
if (props.leftCollapsed || isLeftPanelCollapsed()) return;
|
||||
const current = panel.getSize?.();
|
||||
if (typeof current === 'number' && Math.abs(current - props.leftWidth) < 0.05) {
|
||||
return;
|
||||
}
|
||||
syncingFromProp = true;
|
||||
try {
|
||||
panel.resize(props.leftWidth);
|
||||
} finally {
|
||||
void nextTick(() => {
|
||||
syncingFromProp = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function hydrateLayoutFromProps() {
|
||||
await nextTick();
|
||||
if (props.leftCollapsed) {
|
||||
syncCollapsedFromProp(true);
|
||||
} else {
|
||||
applyWidthFromProp();
|
||||
}
|
||||
// 再等一拍,吞掉首帧误报的 expand/collapse
|
||||
await nextTick();
|
||||
layoutReady = true;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void hydrateLayoutFromProps();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.leftCollapsed,
|
||||
(collapsed) => {
|
||||
if (!layoutReady) return;
|
||||
syncCollapsedFromProp(!!collapsed);
|
||||
},
|
||||
);
|
||||
|
||||
/** 其它页面改了 store 宽度时,keep-alive 缓存页也跟着套 */
|
||||
watch(
|
||||
() => props.leftWidth,
|
||||
() => {
|
||||
if (!layoutReady) return;
|
||||
void nextTick(applyWidthFromProp);
|
||||
},
|
||||
);
|
||||
|
||||
defineExpose({
|
||||
expandLeft,
|
||||
collapseLeft,
|
||||
@@ -66,7 +218,11 @@ defineExpose({
|
||||
<slot :name="slotName" v-bind="slotProps"></slot>
|
||||
</template>
|
||||
|
||||
<ResizablePanelGroup class="w-full" direction="horizontal">
|
||||
<ResizablePanelGroup
|
||||
class="w-full"
|
||||
direction="horizontal"
|
||||
@layout="onLayout"
|
||||
>
|
||||
<ResizablePanel
|
||||
ref="leftPanelRef"
|
||||
:collapsed-size="leftCollapsedWidth"
|
||||
@@ -74,20 +230,33 @@ defineExpose({
|
||||
:default-size="leftWidth"
|
||||
:max-size="leftMaxWidth"
|
||||
:min-size="leftMinWidth"
|
||||
@collapse="onLeftCollapse"
|
||||
@expand="onLeftExpand"
|
||||
>
|
||||
<template #default="slotProps">
|
||||
<slot
|
||||
name="left"
|
||||
v-bind="{
|
||||
...slotProps,
|
||||
expand: expandLeft,
|
||||
collapse: collapseLeft,
|
||||
}"
|
||||
></slot>
|
||||
<!-- 显式解包 isCollapsed,避免二次转发 slot 时 Ref 一直为真、收起标记锁死宽度 -->
|
||||
<template
|
||||
#default="{
|
||||
isCollapsed: panelCollapsed,
|
||||
isExpanded: panelExpanded,
|
||||
resize,
|
||||
}"
|
||||
>
|
||||
<div class="box-border h-full min-h-0 min-w-0">
|
||||
<slot
|
||||
name="left"
|
||||
:is-collapsed="!!toValue(panelCollapsed)"
|
||||
:is-expanded="!!toValue(panelExpanded)"
|
||||
:expand="expandLeft"
|
||||
:collapse="collapseLeft"
|
||||
:resize="resize"
|
||||
></slot>
|
||||
</div>
|
||||
</template>
|
||||
</ResizablePanel>
|
||||
<!-- 拖拽热区兼中缝,略留空隙即可 -->
|
||||
<ResizableHandle
|
||||
v-if="resizable"
|
||||
class="w-1.5 !bg-transparent after:w-1.5"
|
||||
:style="{ backgroundColor: splitLine ? undefined : 'transparent' }"
|
||||
:with-handle="splitHandle"
|
||||
/>
|
||||
@@ -99,7 +268,9 @@ defineExpose({
|
||||
:min-size="rightMinWidth"
|
||||
>
|
||||
<template #default>
|
||||
<slot></slot>
|
||||
<div class="box-border h-full min-h-0 min-w-0 pl-1 sm:pl-1.5">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
</ResizablePanel>
|
||||
</ResizablePanelGroup>
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { PageProps } from '../page/types';
|
||||
|
||||
export interface ColPageProps extends PageProps {
|
||||
/**
|
||||
* 左侧宽度
|
||||
* 左侧宽度(百分比);配合 update:leftWidth 可跨页记忆
|
||||
* @default 30
|
||||
*/
|
||||
leftWidth?: number;
|
||||
@@ -10,6 +10,11 @@ export interface ColPageProps extends PageProps {
|
||||
leftMaxWidth?: number;
|
||||
leftCollapsedWidth?: number;
|
||||
leftCollapsible?: boolean;
|
||||
/**
|
||||
* 左侧是否收起;配合 update:leftCollapsed 可跨页记忆
|
||||
* @default false
|
||||
*/
|
||||
leftCollapsed?: boolean;
|
||||
/**
|
||||
* 右侧宽度
|
||||
* @default 70
|
||||
|
||||
Reference in New Issue
Block a user