@@ -1,10 +1,11 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import {
|
||||
Button, Input, InputNumber, Radio, Select, Space, Switch, Table, Typography, message,
|
||||
Button, Image, Input, InputNumber, Modal, Radio, Select, Space, Switch, Table, Typography, message,
|
||||
} from 'antd';
|
||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import { EditOutlined, MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import { request } from '../lib/api';
|
||||
import { PRODUCT_STATUS_LABELS } from '../lib/constants';
|
||||
import OssUpload from './OssUpload';
|
||||
|
||||
type SpecValue = { id?: string; name: string; sortOrder?: number };
|
||||
type SpecAttr = { id?: string; name: string; sortOrder?: number; values: SpecValue[] };
|
||||
@@ -24,6 +25,7 @@ type SkuRow = {
|
||||
isDefault: boolean;
|
||||
sortOrder?: number;
|
||||
specText?: string;
|
||||
imageUrl?: string | null;
|
||||
};
|
||||
|
||||
function cartesian(attrs: SpecAttr[]): string[][] {
|
||||
@@ -73,6 +75,7 @@ export default function ProductSpecsEditor({ productId, initialAttrs, initialSku
|
||||
saleUnit: s.saleUnit === 'BOX' ? 'BOX' : 'BOTTLE',
|
||||
bottlesPerUnit: s.bottlesPerUnit || (s.saleUnit === 'BOX' ? 6 : 1),
|
||||
isDefault: !!s.isDefault,
|
||||
imageUrl: s.imageUrl ?? '',
|
||||
}))
|
||||
: [
|
||||
{
|
||||
@@ -86,10 +89,12 @@ export default function ProductSpecsEditor({ productId, initialAttrs, initialSku
|
||||
saleUnit: 'BOTTLE',
|
||||
bottlesPerUnit: 1,
|
||||
isDefault: true,
|
||||
imageUrl: '',
|
||||
},
|
||||
],
|
||||
);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [editIndex, setEditIndex] = useState<number | null>(null);
|
||||
|
||||
const combos = useMemo(() => cartesian(attrs.filter((a) => a.name.trim() && a.values.some((v) => v.name.trim()))), [attrs]);
|
||||
|
||||
@@ -111,12 +116,21 @@ export default function ProductSpecsEditor({ productId, initialAttrs, initialSku
|
||||
bottlesPerUnit: 1,
|
||||
isDefault: i === 0,
|
||||
sortOrder: i,
|
||||
imageUrl: '',
|
||||
};
|
||||
});
|
||||
if (next.length && !next.some((s) => s.isDefault)) next[0].isDefault = true;
|
||||
setSkus(next.length ? next : skus);
|
||||
}
|
||||
|
||||
function patchSku(index: number, patch: Partial<SkuRow>) {
|
||||
setSkus((prev) => {
|
||||
const next = [...prev];
|
||||
next[index] = { ...next[index], ...patch };
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
setSaving(true);
|
||||
try {
|
||||
@@ -168,6 +182,7 @@ export default function ProductSpecsEditor({ productId, initialAttrs, initialSku
|
||||
bottlesPerUnit: s.saleUnit === 'BOX' ? s.bottlesPerUnit || 6 : 1,
|
||||
isDefault: !!s.isDefault,
|
||||
sortOrder: i,
|
||||
imageUrl: s.imageUrl?.trim() || null,
|
||||
}));
|
||||
|
||||
const barcodes = payloadSkus.map((row) => row.barcode69);
|
||||
@@ -189,11 +204,13 @@ export default function ProductSpecsEditor({ productId, initialAttrs, initialSku
|
||||
}
|
||||
}
|
||||
|
||||
const editing = editIndex != null ? skus[editIndex] : null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Typography.Paragraph type="secondary">
|
||||
SKU 码由系统自动生成(DK 开头),无需填写。每个规格必须填写<strong>互不相同</strong>的 69 码。
|
||||
先配置销售规格轴(如「包装」),再生成 SKU 矩阵;未配置规格时仅保留默认一行。
|
||||
SKU 码由系统自动生成(DK 开头),无需填写。每个规格必须填写<strong>互不相同</strong>的 69 码,并可单独上传主图。
|
||||
点「填写」在弹窗中编辑。先配置销售规格轴(如「包装」),再生成 SKU 矩阵。
|
||||
</Typography.Paragraph>
|
||||
|
||||
<Typography.Title level={5}>规格轴</Typography.Title>
|
||||
@@ -446,12 +463,154 @@ export default function ProductSpecsEditor({ productId, initialAttrs, initialSku
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '主图',
|
||||
width: 72,
|
||||
render: (_, row) =>
|
||||
row.imageUrl ? (
|
||||
<Image src={row.imageUrl} width={40} height={40} style={{ objectFit: 'cover', borderRadius: 4 }} />
|
||||
) : (
|
||||
<Typography.Text type="secondary">无</Typography.Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '编辑',
|
||||
width: 80,
|
||||
fixed: 'right',
|
||||
render: (_, row, index) => (
|
||||
<Button type="link" size="small" icon={<EditOutlined />} onClick={() => setEditIndex(index)}>
|
||||
填写
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
<Button type="primary" loading={saving} style={{ marginTop: 16 }} onClick={() => void handleSave()}>
|
||||
保存规格与 SKU
|
||||
</Button>
|
||||
|
||||
<Modal
|
||||
title={`编辑规格${editing?.specText ? ` · ${editing.specText}` : editing?.skuCode ? ` · ${editing.skuCode}` : ''}`}
|
||||
open={editIndex != null}
|
||||
onCancel={() => setEditIndex(null)}
|
||||
onOk={() => setEditIndex(null)}
|
||||
okText="完成"
|
||||
width={560}
|
||||
destroyOnClose
|
||||
>
|
||||
{editing && editIndex != null ? (
|
||||
<Space direction="vertical" size={14} style={{ width: '100%' }}>
|
||||
<div>
|
||||
<Typography.Text type="secondary">SKU</Typography.Text>
|
||||
<div>{editing.skuCode || '保存后自动生成'}</div>
|
||||
</div>
|
||||
<div>
|
||||
<Typography.Text>69 码 <Typography.Text type="danger">*</Typography.Text></Typography.Text>
|
||||
<Input
|
||||
placeholder="本规格独立 69 码"
|
||||
value={editing.barcode69}
|
||||
onChange={(e) => patchSku(editIndex, { barcode69: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Typography.Text>主图</Typography.Text>
|
||||
<OssUpload
|
||||
bizType="COVER"
|
||||
value={editing.imageUrl || ''}
|
||||
onChange={(url) => patchSku(editIndex, { imageUrl: url })}
|
||||
/>
|
||||
</div>
|
||||
<Space>
|
||||
<div>
|
||||
<Typography.Text>售价</Typography.Text>
|
||||
<InputNumber
|
||||
min={0}
|
||||
style={{ width: 140 }}
|
||||
value={editing.price}
|
||||
onChange={(v) => patchSku(editIndex, { price: Number(v) || 0 })}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Typography.Text>权益</Typography.Text>
|
||||
<InputNumber
|
||||
min={0}
|
||||
style={{ width: 140 }}
|
||||
value={editing.benefitAmount}
|
||||
onChange={(v) => patchSku(editIndex, { benefitAmount: v == null ? undefined : Number(v) })}
|
||||
/>
|
||||
</div>
|
||||
</Space>
|
||||
<div>
|
||||
<Typography.Text>状态</Typography.Text>
|
||||
<Select
|
||||
style={{ width: '100%' }}
|
||||
value={editing.status}
|
||||
options={Object.entries(PRODUCT_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
||||
onChange={(status) => patchSku(editIndex, { status })}
|
||||
/>
|
||||
</div>
|
||||
<Space>
|
||||
<Select
|
||||
style={{ width: 100 }}
|
||||
value={editing.saleUnit}
|
||||
options={[
|
||||
{ value: 'BOTTLE', label: '瓶' },
|
||||
{ value: 'BOX', label: '箱' },
|
||||
]}
|
||||
onChange={(saleUnit) =>
|
||||
patchSku(editIndex, {
|
||||
saleUnit,
|
||||
bottlesPerUnit: saleUnit === 'BOX' ? editing.bottlesPerUnit || 6 : 1,
|
||||
})
|
||||
}
|
||||
/>
|
||||
{editing.saleUnit === 'BOX' ? (
|
||||
<InputNumber
|
||||
min={1}
|
||||
value={editing.bottlesPerUnit}
|
||||
onChange={(v) => patchSku(editIndex, { bottlesPerUnit: Number(v) || 6 })}
|
||||
/>
|
||||
) : null}
|
||||
</Space>
|
||||
<Space>
|
||||
<Switch
|
||||
checkedChildren="线上"
|
||||
unCheckedChildren="线上"
|
||||
checked={editing.allowOnlinePurchase}
|
||||
onChange={(checked) =>
|
||||
patchSku(editIndex, {
|
||||
allowOnlinePurchase: checked,
|
||||
allowCrossCityDelivery: checked ? editing.allowCrossCityDelivery : false,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Switch
|
||||
checkedChildren="跨城"
|
||||
unCheckedChildren="跨城"
|
||||
disabled={!editing.allowOnlinePurchase}
|
||||
checked={editing.allowCrossCityDelivery}
|
||||
onChange={(checked) => patchSku(editIndex, { allowCrossCityDelivery: checked })}
|
||||
/>
|
||||
<Switch
|
||||
checkedChildren="现场"
|
||||
unCheckedChildren="现场"
|
||||
checked={editing.allowOnSitePickup}
|
||||
onChange={(checked) => patchSku(editIndex, { allowOnSitePickup: checked })}
|
||||
/>
|
||||
<Switch
|
||||
checkedChildren="默认"
|
||||
unCheckedChildren="默认"
|
||||
checked={editing.isDefault}
|
||||
onChange={(checked) => {
|
||||
if (!checked) return;
|
||||
setSkus((prev) => prev.map((s, i) => ({ ...s, isDefault: i === editIndex })));
|
||||
}}
|
||||
/>
|
||||
</Space>
|
||||
</Space>
|
||||
) : null}
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ export default function ProductsPage() {
|
||||
</Form>
|
||||
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1320 }}
|
||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||
<Drawer title="编辑商品" width={720} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||
<Drawer title="编辑商品" width={1100} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||
extra={detail && (
|
||||
<Button type="primary" onClick={async () => {
|
||||
const v = await editForm.validateFields();
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
@@ -16,10 +16,10 @@ import {
|
||||
saveWechatLoginResult,
|
||||
} from '../../lib/pay-wechat';
|
||||
import { applyWechatLoginResult } from '../../lib/wechat-auth';
|
||||
import { getBrandAssetsSync, loadBrandAssets } from '../../lib/brand-assets';
|
||||
import { isWechatEnv } from '../../lib/weixin';
|
||||
import { goLogin } from '../../lib/auth-nav';
|
||||
import { request, toast } from '../../lib/api';
|
||||
import payLogo from '../../assets/logo2.png';
|
||||
|
||||
export default function PayPage() {
|
||||
const router = useRouter();
|
||||
@@ -31,7 +31,6 @@ export default function PayPage() {
|
||||
const [orderNo, setOrderNo] = useState('');
|
||||
const [payAmount, setPayAmount] = useState('—');
|
||||
const [deliveryType, setDeliveryType] = useState('');
|
||||
const [brandMarkUrl, setBrandMarkUrl] = useState(() => getBrandAssetsSync().brandLogoMarkUrl);
|
||||
|
||||
const returnPath = orderId
|
||||
? `/pages/pay/index?orderId=${orderId}`
|
||||
@@ -51,10 +50,6 @@ export default function PayPage() {
|
||||
void refreshPayReadiness();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
void loadBrandAssets().then((brand) => setBrandMarkUrl(brand.brandLogoMarkUrl));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!orderId) return;
|
||||
if (process.env.TARO_ENV === 'weapp') {
|
||||
@@ -178,7 +173,7 @@ export default function PayPage() {
|
||||
<View className="sub-page-body">
|
||||
<View className="pay-status">
|
||||
<View className="pay-status-icon">
|
||||
<Image className="pay-status-brand" src={brandMarkUrl} mode="aspectFit" />
|
||||
<Image className="pay-status-brand" src={payLogo} mode="aspectFit" />
|
||||
</View>
|
||||
<Text className="pay-status-title">
|
||||
{needsWechatAuth ? '需完成微信授权' : '待支付'}
|
||||
|
||||
@@ -165,6 +165,12 @@ export default function ProductDetailPage() {
|
||||
allowOnSitePickup: activeSku.allowOnSitePickup,
|
||||
}
|
||||
: product;
|
||||
const carouselImages = (() => {
|
||||
const base = getProductCarouselImages(product);
|
||||
const skuImg = activeSku?.imageUrl?.trim();
|
||||
if (!skuImg) return base;
|
||||
return [skuImg, ...base.filter((url) => url !== skuImg)];
|
||||
})();
|
||||
|
||||
const sharePayload = useMemo(
|
||||
() =>
|
||||
@@ -172,9 +178,9 @@ export default function ProductDetailPage() {
|
||||
path: `/pages/product-detail/index?id=${productId}`,
|
||||
dynamicTitle: product?.name,
|
||||
dynamicDesc: product?.subtitle,
|
||||
dynamicImageUrl: product ? getProductMainImage(product) : undefined,
|
||||
dynamicImageUrl: (activeSku?.imageUrl?.trim() || (product ? getProductMainImage(product) : undefined)),
|
||||
}),
|
||||
[product, productId],
|
||||
[product, productId, activeSku],
|
||||
);
|
||||
|
||||
useShareAppMessage(() => toWeappShareMessage(sharePayload));
|
||||
@@ -249,7 +255,6 @@ export default function ProductDetailPage() {
|
||||
|
||||
const allowOnline = canBuyOnline(fulfillment ?? {});
|
||||
const allowOnSite = canPickupOnSite(fulfillment ?? {});
|
||||
const carouselImages = getProductCarouselImages(product);
|
||||
const detailImages = getProductDetailImages(product);
|
||||
const detail = product.detailContent ?? {};
|
||||
const features = detail.features ?? [];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { View, Text, Image } from '@tarojs/components';
|
||||
import { View, Text, Image, ScrollView } from '@tarojs/components';
|
||||
import '../../styles/store-detail.css';
|
||||
import Taro, {
|
||||
useDidShow,
|
||||
@@ -444,17 +444,19 @@ export default function StoreDetailPage() {
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{intro ? (
|
||||
{benefitRule ? (
|
||||
<View className="store-detail-section">
|
||||
<Text className="store-detail-section-title">门店详情</Text>
|
||||
<Text className="store-detail-intro">{intro}</Text>
|
||||
<Text className="store-detail-section-title store-detail-section-title--rule">使用规则</Text>
|
||||
<Text className="store-detail-intro">{benefitRule}</Text>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{benefitRule ? (
|
||||
{intro ? (
|
||||
<View className="store-detail-section">
|
||||
<Text className="store-detail-section-title">好客权益使用规则</Text>
|
||||
<Text className="store-detail-intro">{benefitRule}</Text>
|
||||
<Text className="store-detail-section-title">门店详情</Text>
|
||||
<ScrollView className="store-detail-intro-scroll" scrollY showScrollbar>
|
||||
<Text className="store-detail-intro">{intro}</Text>
|
||||
</ScrollView>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -488,12 +488,10 @@
|
||||
}
|
||||
|
||||
.pay-status-icon {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
border-radius: 50%;
|
||||
background: rgba(166, 29, 36, 0.08);
|
||||
color: var(--color-heritage-red);
|
||||
font-size: 36px;
|
||||
background: #f7f4ee;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -502,8 +500,8 @@
|
||||
}
|
||||
|
||||
.pay-status-brand {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
}
|
||||
|
||||
.pay-status-title {
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
|
||||
.product-detail-promo {
|
||||
position: relative;
|
||||
margin-top: 8px;
|
||||
padding: 16px;
|
||||
border-radius: var(--radius-lg);
|
||||
background: linear-gradient(135deg, #fff9e6 0%, #fff0c2 100%);
|
||||
@@ -377,7 +378,7 @@
|
||||
}
|
||||
|
||||
.product-detail-specs {
|
||||
margin: 12px 0 4px;
|
||||
margin: 16px 0 28px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
|
||||
@@ -211,6 +211,17 @@
|
||||
color: var(--color-on-surface);
|
||||
}
|
||||
|
||||
.store-detail-section-title--rule {
|
||||
color: var(--color-heritage-red, #a61d24);
|
||||
}
|
||||
|
||||
.store-detail-intro-scroll {
|
||||
max-height: 168px;
|
||||
height: 168px;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.store-detail-env-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
+55
-16
@@ -10,26 +10,51 @@
|
||||
| 1 | 数据模型 | `common_product_item` 升级为 SPU;新增 `spec_attr` / `spec_value` / `sku` / `sku_spec`;订单快照 `sku_id` / `sale_unit` / `bottles_per_unit` |
|
||||
| 2 | 存量迁移 | 每商品 1 个默认瓶装 SKU;SQL:`prisma/migrate-product-sku-v354.sql`;脚本:`prisma/backfill-product-skus.ts` |
|
||||
| 3 | Catalog | 列表附加 `specEnabled`/`saleUnit`;详情附加 `specAttrs`/`skus`/`defaultSkuId`;旧字段拍平保留 |
|
||||
| 4 | Trade | preview/create 可选 `skuId`;单可售 SKU 自动回落;起购按瓶当量 |
|
||||
| 5 | Admin | `PUT /admin/products/:id/specs`、`PUT .../skus`;商品抽屉「规格与 SKU」 |
|
||||
| 6 | mini-user | 详情规格 chips;确认页带 `skuId`;箱装数量文案 |
|
||||
| 4 | Trade | preview/create 可选 `skuId`;无 SKU 回落 SPU;有可售 SKU 用默认/唯一 |
|
||||
| 5 | Admin | `PUT /admin/products/:id/specs`、`PUT .../skus`;商品抽屉加宽;规格弹窗填写;每规格主图 |
|
||||
| 6 | mini-user | 详情规格 chips;选规格切主图;确认页带 `skuId`;箱装数量文案 |
|
||||
| 7 | 代下单 | HQ / 合伙人可选规格 SKU |
|
||||
| 8 | 权益文案 | 「好客权益券」→「好客权益」;首页角标「享{amount}好客权益」(去掉门店 icon) |
|
||||
| 9 | SKU 码 | 系统生成 `DK` + 6 位数字,后台不可填;每规格独立 69 码 |
|
||||
| 10 | 规格主图 | `common_product_sku.image_url` 可选;空则 C 端回落商品封面 |
|
||||
|
||||
**不做**:SKU 规格图、库存、把现有酒祖 10/15/20 合并为一个 SPU。
|
||||
**不做**:库存、把现有酒祖 10/15/20 合并为一个 SPU。
|
||||
|
||||
## 兼容规则(线上)
|
||||
|
||||
- 不改 `/api/v1` 前缀;**只增字段,不删旧字段语义**。
|
||||
- 旧客户端不传 `skuId`:若该 SPU **恰好 1 个可售 SKU** → 自动使用(现网行为);多个可售 → `400 请选择规格`。
|
||||
- 旧 admin `PUT /admin/products/:id` 不传规格时:仅同步**唯一**默认 SKU(多规格时不同步,防误改)。
|
||||
- 旧客户端不传 `skuId`:
|
||||
- 有 ≥1 个可售 SKU → 用默认(或第一个)可售 SKU
|
||||
- **没有任何可售 SKU(未回填)→ 回落 SPU 字段,照常下单**(禁止再报「商品暂无可售规格」)
|
||||
- 传入 `skuId`(新客户端选规格)→ 按该 SKU 校验。
|
||||
- 旧 admin `PUT /admin/products/:id` 不传规格时:仅同步**唯一**默认 SKU(多规格时不同步,防误改);不同步覆盖已生成的 DK 码。
|
||||
- SPU 上 `sku_code` / `barcode_69` 去掉唯一约束,唯一下沉到 `common_product_sku`;SPU 列保留为默认 SKU 冗余。
|
||||
- 订单 `sku_id` 可空;无规格快照走商品 69 码 / 价格。
|
||||
|
||||
## 发版顺序
|
||||
## 发版一并执行
|
||||
|
||||
1. API + DB 迁移(每商品仅默认 SKU)。**此时不要给任何商品加第二 SKU。**
|
||||
2. 发布新 mini-user + admin 规格页 + 代下单 SKU 选择。
|
||||
3. 运营再配置「单瓶 / 整箱」等第二规格。
|
||||
按顺序在**目标环境库**执行(先测试后生产)。本机 `npx ts-node …` 只改本地 `.env` 库,不会自动打线上。
|
||||
|
||||
1. **规格表** `server/dukang-api/prisma/migrate-product-sku-v354.sql`
|
||||
建 spec/sku 表,订单加 `sku_id` / `sale_unit` / `bottles_per_unit`。
|
||||
2. **回填默认 SKU**
|
||||
`cd server/dukang-api && npx ts-node prisma/backfill-product-skus.ts`
|
||||
尚无 SKU 的商品各建 1 条默认瓶装 SKU(码用 DK)。
|
||||
3. **SKU 主图列** `server/dukang-api/prisma/migrate-sku-image.sql`
|
||||
```sql
|
||||
ALTER TABLE `common_product_sku`
|
||||
ADD COLUMN `image_url` VARCHAR(512) NULL AFTER `sort_order`;
|
||||
```
|
||||
4. **SKU 码改 DK**(生产须在服务器用 `.env.production` 的 `DATABASE_URL`)
|
||||
`npx dotenv -e .env.production -- npx ts-node prisma/rewrite-sku-codes-dk.ts`
|
||||
已是 `DK`+数字的不动;`JZ-10` / `QX-001` 等会改。**不改 69 码、订单、价格。**
|
||||
5. **发票品类列**(同批次)`server/dukang-api/prisma/migrate-invoice-category.sql`
|
||||
```sql
|
||||
ALTER TABLE `user_invoice`
|
||||
ADD COLUMN `invoice_category` VARCHAR(16) NOT NULL DEFAULT 'LIQUOR' AFTER `invoice_kind`;
|
||||
```
|
||||
6. 发布 API + mini-user + admin-web。
|
||||
**此时不要给商品加第二规格**,等新小程序上线后再配「单瓶 / 整箱」。
|
||||
|
||||
## 起购与物流
|
||||
|
||||
@@ -40,23 +65,37 @@
|
||||
## 关键表摘要
|
||||
|
||||
- `common_product_spec_attr` / `common_product_spec_value`
|
||||
- `common_product_sku`(`sale_unit`=`BOTTLE|BOX`,`bottles_per_unit`)
|
||||
- `common_product_sku`(`sale_unit`=`BOTTLE|BOX`,`bottles_per_unit`,`image_url` 可选)
|
||||
- `common_product_sku_spec`
|
||||
- `user_order.sku_id` / `sale_unit` / `bottles_per_unit`
|
||||
- `user_invoice.invoice_category`:`LIQUOR` 酒水类 / `CATERING` 餐饮类;票种 C 端固定增值税普通发票
|
||||
|
||||
## 权益文案(mini-user)
|
||||
## SKU 码与 69 码
|
||||
|
||||
- SKU 码:服务端生成 `DK000001` 起,后台只展示。
|
||||
- 每个规格必须填写**互不相同**的 69 码(全局不可与其它商品 SKU 冲突)。
|
||||
- 总部「规格与 SKU」点「填写」弹窗编辑 69 码 / 价 / 履约 / 主图。
|
||||
|
||||
## 权益与小程序 UI(同批次)
|
||||
|
||||
| 位置 | 变更 |
|
||||
|------|------|
|
||||
| 门店详情等 | 「好客权益券」→「好客权益」(如「好客权益使用规则」) |
|
||||
| 首页商品角标 `CouponBadge` | 由「享 + 门店 icon + 金额 + 好客权益」改为纯文案 **「享{amount}好客权益」** |
|
||||
| 门店详情等 | 「好客权益券」→「好客权益」 |
|
||||
| 首页商品角标 `CouponBadge` | 纯文案 **「享{amount}好客权益」**,无门店 icon |
|
||||
| 商品详情 | 规格区与「好客权益」说明之间加大间距 |
|
||||
| 待支付 / 收银台 | 顶部 logo 使用 `public/images/logo2.png`(杜康印章) |
|
||||
| 门店详情 | 「使用规则」四字红色,放在「门店详情」**上面**;门店详情正文限高,超出上下滚动 |
|
||||
| 发票申请 | 票种写死增值税普通发票;类型选酒水类/餐饮类;申请备注;抬头邮箱必填打 `*` |
|
||||
|
||||
其它页 `BenefitFigure`(我的/权益/核销等)仍保留门店核销图标,仅首页角标去 icon。
|
||||
|
||||
## 验收
|
||||
|
||||
- [ ] 未配规格:旧小程序/H5/代下单路径与现网一致
|
||||
- [ ] 多规格:详情选规格后价格/权益/履约变化;漏选下单 400
|
||||
- [ ] 未配规格:旧小程序/H5/代下单路径与现网一致(无 SKU 也能下单)
|
||||
- [ ] 多规格:详情选规格后价格/权益/履约/主图变化
|
||||
- [ ] 整箱 SKU:数量 1 过起购;订单快照 `bottles_per_unit=6`
|
||||
- [ ] `GET /catalog/products/:id` 仍含 `id/name/price/spec/skuCode/...`
|
||||
- [ ] 小程序无「好客权益券」字样;首页角标为「享{金额}好客权益」且无门店 icon
|
||||
- [ ] 后台 SKU 码为 DK 开头且不可手填;每规格独立 69 码与主图
|
||||
- [ ] 门店详情「使用规则」红色且在门店详情上方;门店详情超长可滚动
|
||||
- [ ] 待支付页顶部为 logo2 印章
|
||||
|
||||
@@ -35,6 +35,8 @@ export interface ProductSkuDto {
|
||||
saleUnit: ProductSaleUnit;
|
||||
bottlesPerUnit: number;
|
||||
isDefault: boolean;
|
||||
/** 规格主图;无则详情页回落商品封面/轮播 */
|
||||
imageUrl?: string | null;
|
||||
}
|
||||
|
||||
export interface ProductDto {
|
||||
@@ -142,4 +144,5 @@ export interface AdminProductSkuInput {
|
||||
bottlesPerUnit?: number;
|
||||
isDefault?: boolean;
|
||||
sortOrder?: number;
|
||||
imageUrl?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
-- SKU 规格主图(可选;空则 C 端回落商品封面)
|
||||
ALTER TABLE `common_product_sku`
|
||||
ADD COLUMN `image_url` VARCHAR(512) NULL AFTER `sort_order`;
|
||||
@@ -894,6 +894,8 @@ model CommonProductSku {
|
||||
bottlesPerUnit Int @default(1) @map("bottles_per_unit")
|
||||
isDefault Boolean @default(false) @map("is_default")
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
/// 规格主图;空则回落商品封面
|
||||
imageUrl String? @map("image_url") @db.VarChar(512)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
|
||||
|
||||
@@ -188,6 +188,7 @@ export function mapSkuDto(sku: SkuWithSpecs) {
|
||||
isDefault: sku.isDefault,
|
||||
skuCode: sku.skuCode,
|
||||
barcode69: sku.barcode69,
|
||||
imageUrl: (sku as { imageUrl?: string | null }).imageUrl || undefined,
|
||||
sortOrder: sku.sortOrder,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -555,7 +555,8 @@ export class AdminProductsService {
|
||||
bottlesPerUnit,
|
||||
isDefault: !!row.isDefault,
|
||||
sortOrder: row.sortOrder ?? i,
|
||||
},
|
||||
imageUrl: row.imageUrl?.trim() || null,
|
||||
} as never,
|
||||
});
|
||||
await tx.commonProductSkuSpec.deleteMany({ where: { skuId } });
|
||||
} else {
|
||||
@@ -574,7 +575,8 @@ export class AdminProductsService {
|
||||
bottlesPerUnit,
|
||||
isDefault: !!row.isDefault,
|
||||
sortOrder: row.sortOrder ?? i,
|
||||
},
|
||||
imageUrl: row.imageUrl?.trim() || null,
|
||||
} as never,
|
||||
});
|
||||
skuId = created.id;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
IsObject,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
Min,
|
||||
Max,
|
||||
MinLength,
|
||||
@@ -1400,6 +1401,12 @@ class AdminSkuRowDto {
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
sortOrder?: number;
|
||||
|
||||
/** 规格主图 URL;空则回落商品封面 */
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(512)
|
||||
imageUrl?: string | null;
|
||||
}
|
||||
|
||||
export class SaveProductSkusDto {
|
||||
|
||||
Reference in New Issue
Block a user