feat(商城管理): 客户商品库后台一期
新增 /customers/mall 卡片管理、Excel 导入、上下架/描述/收藏/移出;复用客户销售价接口;修复共享报价单并发改价、i18n、迁移空 schema、并发计数。
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const read = (rel: string) => readFileSync(new URL(`../${rel}`, import.meta.url), 'utf8');
|
||||
const migration = read('../migrations/20261088_customer_skus_mall_fields.sql');
|
||||
const svc = read('src/services/customerMallAdminService.ts');
|
||||
const route = read('src/modules/workflow/routes/customerRoutes.ts');
|
||||
const page = readFileSync(new URL('../../src/pages/customers/MallManagement.tsx', import.meta.url), 'utf8');
|
||||
|
||||
describe('商城管理一期', () => {
|
||||
it('迁移幂等:is_listed/default true、description', () => {
|
||||
expect(migration).toContain('ADD COLUMN IF NOT EXISTS is_listed BOOLEAN NOT NULL DEFAULT true');
|
||||
expect(migration).toContain('ADD COLUMN IF NOT EXISTS description TEXT');
|
||||
const mapping = read('src/services/importMappingMemoryService.ts');
|
||||
expect(mapping).toContain("'mall_product'");
|
||||
});
|
||||
|
||||
it('列表价格复用录单取价;只读 customer_skus/skus/categories', () => {
|
||||
expect(svc).toContain('enrichOrderItemsWithPrices');
|
||||
expect(svc).toContain('branch_code = $4');
|
||||
expect(svc).toContain('FROM customer_skus cs');
|
||||
expect(svc).toContain('sale_price');
|
||||
expect(svc).not.toMatch(/INSERT INTO orders|UPDATE orders|inventory|settlement/i);
|
||||
});
|
||||
|
||||
it('添加/导入只新增不覆盖;已存在/停用/不存在计数', () => {
|
||||
expect(svc).toContain('ON CONFLICT (customer_code, sku_code) DO NOTHING');
|
||||
expect(svc).toContain('already');
|
||||
expect(svc).toContain('unknown');
|
||||
expect(svc).toContain('sku_disabled');
|
||||
expect(svc).toContain('will_skip');
|
||||
});
|
||||
|
||||
it('更新展示字段/上下架/收藏;删除二次确认页面', () => {
|
||||
expect(svc).toContain('customer_sku_name');
|
||||
expect(svc).toContain('is_listed');
|
||||
expect(svc).toContain("operationType: 'customer_mall_sku_update'");
|
||||
expect(svc).toContain("operationType: 'customer_mall_sku_remove'");
|
||||
expect(page).toContain('confirmDialog');
|
||||
});
|
||||
|
||||
it('6 个 workflow 路由 + customer_manage', () => {
|
||||
for (const path of ['mall-products', 'mall-catalog']) {
|
||||
expect(route).toContain(path);
|
||||
}
|
||||
expect(route).toContain("requireWorkflowPermission(ctx, ['customer_manage'])");
|
||||
expect(route).toContain("dry_run");
|
||||
});
|
||||
|
||||
it('前端价格复用 setCustomerSkuSalePriceApi、原位编辑、导入预览', () => {
|
||||
expect(page).toContain('setCustomerSkuSalePriceApi');
|
||||
expect(page).toContain('onBlur');
|
||||
expect(page).toContain('BulkImportModal');
|
||||
expect(page).toContain('mapMallImportRows');
|
||||
expect(page).toContain('resolveSkuImageUrl');
|
||||
expect(page).toContain('TablePaginationBar');
|
||||
expect(page).toContain('removeMallLibrarySkuApi');
|
||||
});
|
||||
});
|
||||
@@ -26,6 +26,9 @@ describe('客户 SKU 销售价二期', () => {
|
||||
it('接口:报价单优先,否则 customer_skus;审计;不写订单/库存/结算', () => {
|
||||
expect(svc).toContain("target = 'quote_sheet'");
|
||||
expect(svc).toContain('sale_price_manual = true');
|
||||
// 自动选择报价单也必须校验共享单,避免商城/排行改价串改其他客户价格
|
||||
expect(svc).toContain('先锁报价单条目');
|
||||
expect(svc).toContain('customer_quote_sheet_customers');
|
||||
expect(svc).toContain('INSERT INTO customer_skus');
|
||||
expect(svc).toContain('customer_sku_sale_price_update');
|
||||
expect(svc).not.toMatch(/UPDATE orders|INSERT INTO order_items|inventory|settlement/i);
|
||||
|
||||
Reference in New Issue
Block a user