20 Commits

Author SHA1 Message Date
jacy 6a5c0cb090 Merge pull request 'Dev' (#53) from dev into main
CI / verify (push) Waiting to run
Reviewed-on: https://git.yqidian.com/jacy/dukang/pulls/53
2026-08-26 09:56:50 +08:00
jacy 448b9983d3 Merge pull request 'Dev jacy v3.5.11 企业微信通知调整' (#52) from dev_jacy into dev
CI / verify (pull_request) Waiting to run
Reviewed-on: https://git.yqidian.com/jacy/dukang/pulls/52
2026-08-26 09:56:36 +08:00
jacy 3afbdfe6b9 v3.5.11企业微信通知调整
CI / verify (pull_request) Waiting to run
2026-08-26 09:55:19 +08:00
jacy 632539e8dc 增加现场提货的配置 2026-08-26 09:22:29 +08:00
jacy c7cd0f6cf2 C端SKU数量小于等于1不展示chip
后端修复规格轴数据错乱显示问题
2026-08-26 07:43:26 +08:00
jacy 00bb6a2227 Merge pull request 'Dev' (#51) from dev into main
CI / verify (push) Waiting to run
Reviewed-on: https://git.yqidian.com/jacy/dukang/pulls/51
2026-08-26 07:16:04 +08:00
jacy 1f06530894 Merge pull request '小程序版本号' (#50) from dev_jacy into dev
CI / verify (pull_request) Waiting to run
Reviewed-on: https://git.yqidian.com/jacy/dukang/pulls/50
2026-08-26 07:15:52 +08:00
jacy 1f4506f60b 小程序版本号
CI / verify (pull_request) Waiting to run
2026-08-26 07:13:54 +08:00
jacy 93390ccf75 merge(dev): 同城运费路由与配送单信息
CI / verify (push) Waiting to run
2026-08-25 21:13:05 +08:00
jacy a2976cdc8f merge(dev_jacy): 同城运费路由与配送单信息 2026-08-25 21:12:53 +08:00
jacy cc0c0a6ef8 feat(fulfillment): 同城运费与路由修复,配送单展示商品用户地址
同城 MANUAL/ZZXFX 按小飞侠价规计费,路由查询回退仓配凭证;HQ 配送单补商品、用户和收货地址。门店核销回跳与小程序核销码一并带上。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 21:12:36 +08:00
jacy 8f2ebbfef4 merge(dev): 补承运商删除操作常量
CI / verify (push) Waiting to run
2026-08-25 14:32:32 +08:00
jacy ee1a3f4b6c merge(dev_jacy): 补承运商删除操作常量 2026-08-25 14:32:27 +08:00
jacy 52a7d3789d fix(ops): 补承运商删除操作常量以便生产构建
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 14:32:08 +08:00
jacy f2fbf95c53 merge(dev): v3.5.10 同城配送提示与企微客服
CI / verify (push) Waiting to run
2026-08-25 14:30:43 +08:00
jacy 98d52ff173 merge(dev_jacy): v3.5.10 同城配送提示与企微客服 2026-08-25 14:30:10 +08:00
jacy 797b20979d feat(mini-user): v3.5.10 同城配送提示可配置并支持换行
承运商 HTML 按收货市下发;textarea 回车在 C 端转成换行。含门店去掉分享按钮与小程序企微客服。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 14:29:48 +08:00
jacy 43de361e61 merge(dev): 列设置靠右与订单状态多选
CI / verify (push) Waiting to run
2026-08-25 14:20:39 +08:00
jacy b1511ecb92 merge(dev_jacy): 列设置靠右与订单状态多选 2026-08-25 14:20:13 +08:00
jacy fed8ff3d3a fix(admin): 列设置靠右并支持订单状态多选
HQ 列表主操作居右、列设置贴最右侧;订单筛选状态可多选,导出同步过滤。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 14:19:49 +08:00
149 changed files with 3507 additions and 865 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ await this.prisma.order.update({ ... });
```typescript ```typescript
const benefitAmount = product.benefitAmount ?? product.price; const benefitAmount = product.benefitAmount ?? product.price;
// 核销:直接核销按全部 ACTIVE 权益总余额;带单据核销按该单据可用金额 // 核销:直接核销按全部 ACTIVE 权益总余额;带单据核销按该单据可用金额
// 同城 min 2 瓶 / 跨城 min 6 瓶 // 起购:提货/同城 min 2 瓶 / 跨城 min 6 瓶(城市配置,非承运商)
// 支付成功 → log_third_party + user_order.pay_status=PAID // 支付成功 → log_third_party + user_order.pay_status=PAID
// → user_benefit_coupon + common_event(BENEFIT_LEDGER, GRANT) // → user_benefit_coupon + common_event(BENEFIT_LEDGER, GRANT)
+1 -1
View File
@@ -37,7 +37,7 @@ disable-model-invocation: true
``` ```
权益额 = 订单实付 1:1(永久) 权益额 = 订单实付 1:1(永久)
同城起购 2 瓶 / 跨城 1 箱(6瓶) 起购:现场提货 2 瓶 / 同城 2 瓶 / 跨城 1 箱(6瓶);属城市,非承运商
门店结算 = 核销额 × 60% 门店结算 = 核销额 × 60%
单合伙人:订单佣金 + 核销佣金 ≤ 5%(默认 0% + 3%) 单合伙人:订单佣金 + 核销佣金 ≤ 5%(默认 0% + 3%)
核销码 TTL = 3 分钟;试核销固定 ¥100 核销码 TTL = 3 分钟;试核销固定 ¥100
@@ -12,9 +12,9 @@
| REQ-U-004 | 定位 | 右上角市区;默认 IP;可授权精确定位 | | REQ-U-004 | 定位 | 右上角市区;默认 IP;可授权精确定位 |
| REQ-U-005 | 首页商品 | 4 款酒祖杜康;大图、标题加粗、价格标红、权益金额 | | REQ-U-005 | 首页商品 | 4 款酒祖杜康;大图、标题加粗、价格标红、权益金额 |
| REQ-U-006 | 商品详情 | 规格瓶/箱、度数、价格、权益、详情图 | | REQ-U-006 | 商品详情 | 规格瓶/箱、度数、价格、权益、详情图 |
| REQ-U-007 | 同城 | 小飞侠;≥2 瓶免运费;物流节点+拍照;24h 自动完成 | | REQ-U-007 | 同城 | 小飞侠;起购 ≥2 瓶(城市 `localMinQty`);≥2 瓶免运费;物流节点+拍照;24h 自动完成 |
| REQ-U-008 | 现场提货 | 隐藏入口;支付即完成;强提示在现场 | | REQ-U-008 | 现场提货 | 隐藏入口;起购 ≥2 瓶(城市 `pickupMinQty`);支付即完成;强提示在现场 |
| REQ-U-009 | 跨城 | 未开通城市;≥1 箱;总部物流到付 | | REQ-U-009 | 跨城 | 未开通城市;起购 ≥1 箱(城市 `crossMinQty`=6 瓶当量);总部物流到付 |
| REQ-U-010 | 锁单 | 待付款 30 分钟取消 | | REQ-U-010 | 锁单 | 待付款 30 分钟取消 |
| REQ-U-011 | 权益 | 支付成功 1:1 永久 | | REQ-U-011 | 权益 | 支付成功 1:1 永久 |
| REQ-U-012 | 客服 | 已付款起电话/微信客服 | | REQ-U-012 | 客服 | 已付款起电话/微信客服 |
+1
View File
@@ -26,3 +26,4 @@ server/dukang-api/assets/fonts/*.ttc
server/dukang-api/assets/fonts/*.otf server/dukang-api/assets/fonts/*.otf
deploy/auto-release.env deploy/auto-release.env
deploy/backups/ deploy/backups/
.playwright-mcp/
+1 -1
View File
@@ -35,7 +35,7 @@
``` ```
权益额 = benefit_amount ?? price 权益额 = benefit_amount ?? price
同城起购 2 瓶 / 跨城 6 瓶 起购:现场提货 2 瓶 / 同城 2 瓶 / 跨城 6 瓶(1 箱);属城市,非承运商
核销:直接核销 0 < amount ≤ 全部 ACTIVE 权益总余额;带单据核销 0 < amount ≤ 该单据可用金额;Redis 码 3 分钟 核销:直接核销 0 < amount ≤ 全部 ACTIVE 权益总余额;带单据核销 0 < amount ≤ 该单据可用金额;Redis 码 3 分钟
C 端门店仅 status=OPEN C 端门店仅 status=OPEN
订单 Tab:待付款 | 已付款 | 已完成 订单 Tab:待付款 | 已付款 | 已完成
+1 -1
View File
@@ -92,7 +92,7 @@
```text ```text
权益发放额 = common_product_item.benefit_amount ?? price 权益发放额 = common_product_item.benefit_amount ?? price
同城起购 2 瓶 / 跨城 6 瓶 起购:现场提货 2 瓶 / 同城 2 瓶 / 跨城 6 瓶(1 箱);属城市,非承运商
核销:直接核销 0 < amount ≤ 全部 ACTIVE 权益总余额;带单据核销 0 < amount ≤ 该单据可用金额 核销:直接核销 0 < amount ≤ 全部 ACTIVE 权益总余额;带单据核销 0 < amount ≤ 该单据可用金额
C 端门店列表仅 status=OPEN C 端门店列表仅 status=OPEN
订单 Taball | pending_pay | pending_ship | pending_receive | completed 订单 Taball | pending_pay | pending_ship | pending_receive | completed
+44
View File
@@ -74,6 +74,50 @@ body.admin-col-resizing * {
user-select: none !important; user-select: none !important;
} }
/* 列表页顶栏:标题左、主操作右、列设置最右 */
.admin-list-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 16px;
}
.admin-list-header-left {
min-width: 0;
}
.admin-list-header-desc {
margin-top: 4px;
color: rgba(0, 0, 0, 0.45);
line-height: 1.5;
}
.admin-list-header-right {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 8px;
flex-shrink: 0;
margin-left: auto;
}
.admin-list-settings-slot {
display: inline-flex;
margin-left: auto;
order: 99;
flex-shrink: 0;
}
.admin-list-settings-btn.ant-btn {
color: rgba(0, 0, 0, 0.55);
padding-inline: 8px;
}
.admin-list-settings-btn.ant-btn:hover {
color: rgba(0, 0, 0, 0.88);
}
/* 操作列保持可见 */ /* 操作列保持可见 */
.admin-layout .ant-table-cell:has(.ant-btn), .admin-layout .ant-table-cell:has(.ant-btn),
.ant-drawer .ant-table-cell:has(.ant-btn), .ant-drawer .ant-table-cell:has(.ant-btn),
@@ -0,0 +1,36 @@
import type { ReactNode } from 'react';
import { Space, Typography } from 'antd';
/** 列表页顶栏:标题在左,主操作在右,列设置永远最右 */
export function AdminListHeader({
title,
description,
actions,
settings,
}: {
title?: ReactNode;
description?: ReactNode;
actions?: ReactNode;
settings?: ReactNode;
}) {
return (
<div className="admin-list-header">
<div className="admin-list-header-left">
{title == null || title === '' ? null : typeof title === 'string' || typeof title === 'number' ? (
<Typography.Title level={4} style={{ margin: 0 }}>
{title}
</Typography.Title>
) : (
title
)}
{description ? (
<div className="admin-list-header-desc">{description}</div>
) : null}
</div>
<div className="admin-list-header-right">
{actions ? <Space wrap>{actions}</Space> : null}
{settings}
</div>
</div>
);
}
@@ -11,10 +11,23 @@ import PackageImagesUpload from './PackageImagesUpload';
type PackageRow = StorePackageItemDto; type PackageRow = StorePackageItemDto;
export type AdminStorePackagesHandle = { export type AdminStorePackagesHandle = {
/** 套餐已加载时写入;加载中则跳过,避免空数据覆盖线上套餐 */ /** 仅在用户改过套餐时写入;加载中或未改动则跳过,避免空表单覆盖刚审核通过的线上套餐 */
saveIfLoaded: (opts?: { quiet?: boolean }) => Promise<{ skipped: boolean }>; saveIfLoaded: (opts?: { quiet?: boolean }) => Promise<{ skipped: boolean }>;
}; };
function mapLiveRows(live: StorePackagesResponse['live']): PackageRow[] {
return (live ?? []).map((p, i) => {
const imageUrls = normalizeStorePackageImageUrls(p);
return {
...p,
price: String(p.price),
imageUrl: imageUrls[0] ?? '',
imageUrls,
sortOrder: i,
};
});
}
function emptyRow(index = 0): PackageRow { function emptyRow(index = 0): PackageRow {
return { return {
name: '', name: '',
@@ -37,6 +50,7 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
const [pendingRequest, setPendingRequest] = useState<StorePackagesResponse['pendingRequest']>(null); const [pendingRequest, setPendingRequest] = useState<StorePackagesResponse['pendingRequest']>(null);
const itemsRef = useRef(items); const itemsRef = useRef(items);
const loadingRef = useRef(loading); const loadingRef = useRef(loading);
const dirtyRef = useRef(false);
const navigate = useNavigate(); const navigate = useNavigate();
useEffect(() => { useEffect(() => {
@@ -47,36 +61,33 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
loadingRef.current = loading; loadingRef.current = loading;
}, [loading]); }, [loading]);
function applyServerPackages(data: StorePackagesResponse) {
dirtyRef.current = false;
setPendingRequest(data.pendingRequest ?? null);
setItems(mapLiveRows(data.live));
}
useEffect(() => { useEffect(() => {
setLoading(true); setLoading(true);
setPendingRequest(null); setPendingRequest(null);
dirtyRef.current = false;
request<StorePackagesResponse>(`/admin/stores/${storeId}/packages`) request<StorePackagesResponse>(`/admin/stores/${storeId}/packages`)
.then((data) => { .then((data) => applyServerPackages(data))
setPendingRequest(data.pendingRequest ?? null);
setItems(
data.live?.length
? data.live.map((p, i) => {
const imageUrls = normalizeStorePackageImageUrls(p);
return {
...p,
price: String(p.price),
imageUrl: imageUrls[0] ?? '',
imageUrls,
sortOrder: i,
};
})
: [],
);
})
.catch((e) => message.error(e instanceof Error ? e.message : '加载套餐失败')) .catch((e) => message.error(e instanceof Error ? e.message : '加载套餐失败'))
.finally(() => setLoading(false)); .finally(() => setLoading(false));
}, [storeId]); }, [storeId]);
// 审核页完成审核后,自动刷新本页「有待审核套餐」提醒 // 审核通过/驳回后刷新提醒;用户未改套餐时同步线上结果,避免抽屉里仍显示空套餐
useEffect(() => { useEffect(() => {
const onChanged = () => { const onChanged = () => {
request<StorePackagesResponse>(`/admin/stores/${storeId}/packages`) request<StorePackagesResponse>(`/admin/stores/${storeId}/packages`)
.then((data) => setPendingRequest(data.pendingRequest ?? null)) .then((data) => {
setPendingRequest(data.pendingRequest ?? null);
if (!dirtyRef.current) {
dirtyRef.current = false;
setItems(mapLiveRows(data.live));
}
})
.catch(() => undefined); .catch(() => undefined);
}; };
window.addEventListener(PACKAGE_AUDIT_CHANGED_EVENT, onChanged); window.addEventListener(PACKAGE_AUDIT_CHANGED_EVENT, onChanged);
@@ -108,16 +119,19 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
) : null; ) : null;
function updateAt(index: number, patch: Partial<PackageRow>) { function updateAt(index: number, patch: Partial<PackageRow>) {
dirtyRef.current = true;
setItems((prev) => prev.map((item, i) => (i === index ? { ...item, ...patch } : item))); setItems((prev) => prev.map((item, i) => (i === index ? { ...item, ...patch } : item)));
} }
function addRow() { function addRow() {
if (items.length >= STORE_PACKAGE_MAX_COUNT) return; if (items.length >= STORE_PACKAGE_MAX_COUNT) return;
dirtyRef.current = true;
setItems((prev) => [...prev, emptyRow(prev.length)]); setItems((prev) => [...prev, emptyRow(prev.length)]);
} }
function removeAt(index: number) { function removeAt(index: number) {
const run = () => { const run = () => {
dirtyRef.current = true;
setItems((prev) => { setItems((prev) => {
const next = prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i })); const next = prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i }));
return next.length ? next : []; return next.length ? next : [];
@@ -203,20 +217,8 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
}), }),
}); });
if (!opts?.quiet) message.success('套餐已保存并生效'); if (!opts?.quiet) message.success('套餐已保存并生效');
setItems( dirtyRef.current = false;
data.live?.length setItems(mapLiveRows(data.live));
? data.live.map((p, i) => {
const imageUrls = normalizeStorePackageImageUrls(p);
return {
...p,
price: String(p.price),
imageUrl: imageUrls[0] ?? '',
imageUrls,
sortOrder: i,
};
})
: [],
);
} catch (e) { } catch (e) {
if (!opts?.quiet) message.error(e instanceof Error ? e.message : '保存失败'); if (!opts?.quiet) message.error(e instanceof Error ? e.message : '保存失败');
throw e; throw e;
@@ -227,7 +229,7 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
saveIfLoaded: async (opts) => { saveIfLoaded: async (opts) => {
if (loadingRef.current) return { skipped: true }; if (loadingRef.current || !dirtyRef.current) return { skipped: true };
await save(opts); await save(opts);
return { skipped: false }; return { skipped: false };
}, },
@@ -173,7 +173,9 @@ export default function OrderTrackDrawer({
<Empty <Empty
image={Empty.PRESENTED_IMAGE_SIMPLE} image={Empty.PRESENTED_IMAGE_SIMPLE}
description={ description={
track?.manualQueryUrl track?.queryError
? track.queryError
: track?.manualQueryUrl
? '暂无实时路由节点,可使用上方物流查询链接' ? '暂无实时路由节点,可使用上方物流查询链接'
: '暂无路由信息,请稍后刷新' : '暂无路由信息,请稍后刷新'
} }
@@ -1,4 +1,4 @@
import { useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { import {
Button, Image, Input, InputNumber, Modal, Radio, Select, Space, Switch, Table, Typography, message, Button, Image, Input, InputNumber, Modal, Radio, Select, Space, Switch, Table, Typography, message,
} from 'antd'; } from 'antd';
@@ -50,34 +50,9 @@ function keyOf(ids: string[]) {
return [...ids].sort().join('_'); return [...ids].sort().join('_');
} }
type Props = { function normalizeSkuRows(initialSkus: SkuRow[]): SkuRow[] {
productId: string; if (!initialSkus.length) {
initialAttrs: SpecAttr[]; return [
initialSkus: SkuRow[];
onSaved: () => void;
};
export default function ProductSpecsEditor({ productId, initialAttrs, initialSkus, onSaved }: Props) {
const [attrs, setAttrs] = useState<SpecAttr[]>(
initialAttrs.length
? initialAttrs
: [],
);
const [skus, setSkus] = useState<SkuRow[]>(
initialSkus.length
? initialSkus.map((s) => ({
...s,
specValueIds: s.specValueIds ?? [],
status: s.status || 'ON_SALE',
allowOnlinePurchase: s.allowOnlinePurchase !== false,
allowCrossCityDelivery: s.allowCrossCityDelivery !== false,
allowOnSitePickup: !!s.allowOnSitePickup,
saleUnit: s.saleUnit === 'BOX' ? 'BOX' : 'BOTTLE',
bottlesPerUnit: s.bottlesPerUnit || (s.saleUnit === 'BOX' ? 6 : 1),
isDefault: !!s.isDefault,
imageUrl: s.imageUrl ?? '',
}))
: [
{ {
specValueIds: [], specValueIds: [],
barcode69: '', barcode69: '',
@@ -91,11 +66,43 @@ export default function ProductSpecsEditor({ productId, initialAttrs, initialSku
isDefault: true, isDefault: true,
imageUrl: '', imageUrl: '',
}, },
], ];
); }
return initialSkus.map((s) => ({
...s,
specValueIds: s.specValueIds ?? [],
status: s.status || 'ON_SALE',
allowOnlinePurchase: s.allowOnlinePurchase !== false,
allowCrossCityDelivery: s.allowCrossCityDelivery !== false,
allowOnSitePickup: !!s.allowOnSitePickup,
saleUnit: s.saleUnit === 'BOX' ? 'BOX' : 'BOTTLE',
bottlesPerUnit: s.bottlesPerUnit || (s.saleUnit === 'BOX' ? 6 : 1),
isDefault: !!s.isDefault,
imageUrl: s.imageUrl ?? '',
}));
}
type Props = {
productId: string;
initialAttrs: SpecAttr[];
initialSkus: SkuRow[];
onSaved: () => void;
};
export default function ProductSpecsEditor({ productId, initialAttrs, initialSkus, onSaved }: Props) {
const [attrs, setAttrs] = useState<SpecAttr[]>(() => (initialAttrs.length ? initialAttrs : []));
const [skus, setSkus] = useState<SkuRow[]>(() => normalizeSkuRows(initialSkus));
const [saving, setSaving] = useState(false); const [saving, setSaving] = useState(false);
const [editIndex, setEditIndex] = useState<number | null>(null); const [editIndex, setEditIndex] = useState<number | null>(null);
useEffect(() => {
setAttrs(initialAttrs.length ? initialAttrs : []);
setSkus(normalizeSkuRows(initialSkus));
setEditIndex(null);
// 仅切商品时重载,避免父组件重渲染冲掉编辑中内容
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [productId]);
const combos = useMemo(() => cartesian(attrs.filter((a) => a.name.trim() && a.values.some((v) => v.name.trim()))), [attrs]); const combos = useMemo(() => cartesian(attrs.filter((a) => a.name.trim() && a.values.some((v) => v.name.trim()))), [attrs]);
function regenerateMatrix() { function regenerateMatrix() {
+12 -2
View File
@@ -20,7 +20,11 @@ import {
AccountBookOutlined, AccountBookOutlined,
ProjectOutlined, ProjectOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { hasAnySystemSettingsPermission, hasAnyStoreMenuPermission } from '@dukang/shared-types'; import {
hasAnySystemSettingsPermission,
hasAnyStoreMenuPermission,
HQ_ADMIN_ROLES,
} from '@dukang/shared-types';
import { clearAuth, request, type HqProfile } from '../lib/api'; import { clearAuth, request, type HqProfile } from '../lib/api';
import { bindAdminEllipsisTitle } from '../lib/ellipsis-title'; import { bindAdminEllipsisTitle } from '../lib/ellipsis-title';
import { AUDIT_NOTICE_CHANGED_EVENT, PACKAGE_AUDIT_CHANGED_EVENT } from '../lib/admin-events'; import { AUDIT_NOTICE_CHANGED_EVENT, PACKAGE_AUDIT_CHANGED_EVENT } from '../lib/admin-events';
@@ -28,6 +32,10 @@ import { ListColumnPrefsProvider } from '../lib/ListColumnPrefsContext';
const { Header, Sider, Content } = Layout; const { Header, Sider, Content } = Layout;
const HQ_ROLE_LABELS: Record<string, string> = Object.fromEntries(
HQ_ADMIN_ROLES.map((r) => [r.value, r.label]),
);
type MenuItem = NonNullable<MenuProps['items']>[number]; type MenuItem = NonNullable<MenuProps['items']>[number];
const MENU_ITEMS: MenuProps['items'] = [ const MENU_ITEMS: MenuProps['items'] = [
@@ -405,7 +413,9 @@ export default function AdminLayout() {
</Typography.Title> </Typography.Title>
<Space> <Space>
<span>{profile?.name || '—'}</span> <span>{profile?.name || '—'}</span>
<span style={{ color: '#999' }}>{profile?.adminRole}</span> <span style={{ color: '#999' }}>
{HQ_ROLE_LABELS[profile?.adminRole ?? ''] || profile?.adminRole || ''}
</span>
<Button type="text" icon={<LogoutOutlined />} onClick={logout}> <Button type="text" icon={<LogoutOutlined />} onClick={logout}>
退 退
</Button> </Button>
+2
View File
@@ -236,5 +236,7 @@ export type AdminOrderRow = {
providerOrderNo: string | null; providerOrderNo: string | null;
logisticsCompany?: string | null; logisticsCompany?: string | null;
manualQueryUrl?: string | null; manualQueryUrl?: string | null;
/** 当次应付物流费(按瓶当量 × 承运商计价) */
logisticsFee?: number | null;
}; };
}; };
@@ -153,9 +153,11 @@ export function useAdminListColumns<T>(
}, [configured, serialCol, pref?.widths, localWidths, persistWidth]); }, [configured, serialCol, pref?.widths, localWidths, persistWidth]);
const settingsButton = ( const settingsButton = (
<Button icon={<SettingOutlined />} onClick={() => setOpen(true)}> <span className="admin-list-settings-slot">
<Button type="text" icon={<SettingOutlined />} className="admin-list-settings-btn" onClick={() => setOpen(true)}>
</Button> </Button>
</span>
); );
const settingsModal = ( const settingsModal = (
@@ -23,6 +23,7 @@ import { COUPON_STATUS_LABELS, DELIVERY_TYPE_LABELS, fmtTime } from '../lib/cons
import RedeemRecordDetailDescriptions from '../components/RedeemRecordDetailDescriptions'; import RedeemRecordDetailDescriptions from '../components/RedeemRecordDetailDescriptions';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
type CouponOrder = { type CouponOrder = {
@@ -248,17 +249,15 @@ export default function BenefitCouponsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="好客权益券"
settings={settingsButton}
</Typography.Title> actions={
<Space>
{settingsButton}
<Button type="primary" onClick={() => setGrantOpen(true)}> <Button type="primary" onClick={() => setGrantOpen(true)}>
</Button> </Button>
</Space> }
</div> />
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="couponNo" label="券号"> <Form.Item name="couponNo" label="券号">
@@ -4,6 +4,7 @@ import type { ColumnsType } from 'antd/es/table';
import { LEDGER_TYPE_LABELS, fmtTime } from '../lib/constants'; import { LEDGER_TYPE_LABELS, fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
type Row = { type Row = {
@@ -41,8 +42,7 @@ export default function BenefitLedgersPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader title="权益流水" settings={settingsButton} />
{settingsButton}
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="userId" label="用户ID"><Input allowClear /></Form.Item> <Form.Item name="userId" label="用户ID"><Input allowClear /></Form.Item>
<Form.Item name="couponId" label="券ID"><Input allowClear /></Form.Item> <Form.Item name="couponId" label="券ID"><Input allowClear /></Form.Item>
+29 -7
View File
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
import { import {
Button, Button,
Descriptions, Descriptions,
Divider,
Drawer, Drawer,
Form, Form,
Input, Input,
@@ -25,6 +26,7 @@ import { useAdminList } from '../lib/useAdminList';
import CityPartnersPanel from '../components/CityPartnersPanel'; import CityPartnersPanel from '../components/CityPartnersPanel';
import ChinaProvinceCityCascader from '../components/ChinaProvinceCityCascader'; import ChinaProvinceCityCascader from '../components/ChinaProvinceCityCascader';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -326,11 +328,11 @@ export default function CitiesPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> title="城市"
{settingsButton} settings={settingsButton}
<Button type="primary" onClick={openCreateModal}></Button> actions={<Button type="primary" onClick={openCreateModal}></Button>}
</Space> />
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="name" label="城市"><Input allowClear /></Form.Item> <Form.Item name="name" label="城市"><Input allowClear /></Form.Item>
<Form.Item name="code" label="编码"><Input allowClear /></Form.Item> <Form.Item name="code" label="编码"><Input allowClear /></Form.Item>
@@ -361,8 +363,28 @@ export default function CitiesPage() {
<Form.Item name="status" label="状态"> <Form.Item name="status" label="状态">
<Select options={Object.entries(CITY_STATUS_LABELS).map(([value, label]) => ({ value, label }))} /> <Select options={Object.entries(CITY_STATUS_LABELS).map(([value, label]) => ({ value, label }))} />
</Form.Item> </Form.Item>
<Form.Item name="localMinQty" label="同城起购"><InputNumber min={1} style={{ width: '100%' }} /></Form.Item> <Divider orientation="left"></Divider>
<Form.Item name="crossMinQty" label="跨城起购"><InputNumber min={1} style={{ width: '100%' }} /></Form.Item> <Form.Item
name="pickupMinQty"
label="现场提货"
extra="按瓶当量;箱装 1 箱即可过。默认 2 瓶。"
>
<InputNumber min={1} style={{ width: '100%' }} />
</Form.Item>
<Form.Item
name="localMinQty"
label="同城配送"
extra="按瓶当量;箱装 1 箱即可过。默认 2 瓶。"
>
<InputNumber min={1} style={{ width: '100%' }} />
</Form.Item>
<Form.Item
name="crossMinQty"
label="跨城配送"
extra="按瓶当量。当前箱规 6 瓶/箱时,填 6 = 最少 1 箱。"
>
<InputNumber min={1} style={{ width: '100%' }} />
</Form.Item>
<Form.Item <Form.Item
name="maxPartnerCommissionPercent" name="maxPartnerCommissionPercent"
label="合伙人佣金合计上限 %" label="合伙人佣金合计上限 %"
@@ -37,6 +37,7 @@ import { useAdminList } from '../lib/useAdminList';
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect'; import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
import PartnerSubAccountList, { type PartnerSubAccountRow } from '../components/PartnerSubAccountList'; import PartnerSubAccountList, { type PartnerSubAccountRow } from '../components/PartnerSubAccountList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -350,11 +351,10 @@ export default function CityPartnersPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="城市合伙人"
settings={settingsButton}
</Typography.Title> actions={
{settingsButton}
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={() => {
@@ -372,7 +372,8 @@ export default function CityPartnersPage() {
> >
</Button> </Button>
</Space> }
/>
<Alert <Alert
type="info" type="info"
@@ -14,7 +14,6 @@ import {
Switch, Switch,
Table, Table,
Tag, Tag,
Typography,
message, message,
} from 'antd'; } from 'antd';
import type { ColumnsType } from 'antd/es/table'; import type { ColumnsType } from 'antd/es/table';
@@ -31,6 +30,7 @@ import { request, type Paginated } from '../lib/api';
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants'; import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -316,9 +316,10 @@ export default function CityWarehousesPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> title="仓库"
{settingsButton} settings={settingsButton}
actions={
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={() => {
@@ -336,7 +337,8 @@ export default function CityWarehousesPage() {
> >
</Button> </Button>
</Space> }
/>
<Alert <Alert
type="info" type="info"
+217 -34
View File
@@ -1,15 +1,43 @@
import { useState } from 'react'; import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { import {
Button, Descriptions, Drawer, Form, Input, Space, Table, Typography, message, Button, Descriptions, Drawer, Form, Input, Space, Table, Typography, message,
} from 'antd'; } from 'antd';
import type { ColumnsType } from 'antd/es/table'; import type { ColumnsType } from 'antd/es/table';
import OrderTrackDrawer from '../components/OrderTrackDrawer'; import OrderTrackDrawer from '../components/OrderTrackDrawer';
import { request } from '../lib/api'; import { request } from '../lib/api';
import { ORDER_STATUS_LABELS, fmtTime } from '../lib/constants'; import {
DELIVERY_PROVIDER_LABELS,
DELIVERY_TYPE_LABELS,
ORDER_STATUS_LABELS,
fmtTime,
} from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
type DeliveryOrder = {
id: string;
orderNo: string;
status: string;
deliveryType: string;
productName: string;
productSpec?: string | null;
barcode69?: string | null;
quantity: number;
saleUnit?: string;
bottlesPerUnit?: number;
payAmount?: number;
receiverName: string;
receiverPhone: string;
receiverAddress?: string;
receiverProvince?: string;
receiverCity?: string;
receiverDistrict?: string;
user?: { id: string; userNo: string; phone: string | null; nickname: string | null };
imageResource?: { url: string } | null;
};
type Row = { type Row = {
id: string; id: string;
@@ -18,17 +46,34 @@ type Row = {
trackingNo: string | null; trackingNo: string | null;
providerOrderNo: string | null; providerOrderNo: string | null;
updatedAt: string; updatedAt: string;
order?: { logisticsFee?: number | null;
id: string; order?: DeliveryOrder;
orderNo: string;
status: string;
receiverName: string;
receiverPhone: string;
deliveryType: string;
};
}; };
function formatQty(order?: DeliveryOrder | null) {
if (!order || order.quantity == null) return '—';
const unit = order.saleUnit === 'BOX' ? '箱' : '瓶';
const bottles =
order.saleUnit === 'BOX' && order.bottlesPerUnit && order.bottlesPerUnit > 1
? `${order.quantity * order.bottlesPerUnit}瓶)`
: '';
return `${order.quantity}${unit}${bottles}`;
}
function formatAddress(order?: DeliveryOrder | null) {
if (!order) return '—';
if (order.deliveryType === 'ON_SITE_PICKUP') return '现场取货';
const region = [order.receiverProvince, order.receiverCity, order.receiverDistrict]
.filter(Boolean)
.join('');
const detail = (order.receiverAddress || '').trim();
if (!region) return detail || '—';
if (!detail || detail.startsWith(region)) return detail || region;
return `${region}${detail}`;
}
export default function DeliveriesPage() { export default function DeliveriesPage() {
const navigate = useNavigate();
const [form] = Form.useForm(); const [form] = Form.useForm();
const [editForm] = Form.useForm(); const [editForm] = Form.useForm();
const [filters, setFilters] = useState<Record<string, string>>({}); const [filters, setFilters] = useState<Record<string, string>>({});
@@ -62,41 +107,126 @@ export default function DeliveriesPage() {
setTrackOpen(true); setTrackOpen(true);
} }
async function openDetail(row: Row) {
const d = await request<Row>(`/admin/deliveries/${row.id}`);
setDetail(d);
editForm.setFieldsValue({
provider: d.provider,
trackingNo: d.trackingNo,
providerOrderNo: d.providerOrderNo,
});
setDrawerOpen(true);
}
const baseColumns: ColumnsType<Row> = [ const baseColumns: ColumnsType<Row> = [
{ {
title: '订单号', title: '订单号',
dataIndex: ['order', 'orderNo'], dataIndex: ['order', 'orderNo'],
width: 170, width: 170,
render: (v, row) => ( render: (v, row) => (
<AdminPrimaryLink <AdminPrimaryLink onClick={() => void openDetail(row)}>{v}</AdminPrimaryLink>
onClick={async () => {
const d = await request<Row>(`/admin/deliveries/${row.id}`);
setDetail(d);
editForm.setFieldsValue({ provider: d.provider, trackingNo: d.trackingNo, providerOrderNo: d.providerOrderNo });
setDrawerOpen(true);
}}
>
{v}
</AdminPrimaryLink>
), ),
}, },
{ title: 'provider', dataIndex: 'provider', width: 90 }, {
title: '用户',
key: 'user',
width: 140,
render: (_, row) => {
const user = row.order?.user;
if (!user) return '—';
const label = user.userNo || user.phone || '—';
return (
<div>
{user.id ? (
<AdminPrimaryLink
onClick={() => navigate('/users', { state: { openUserId: String(user.id) } })}
>
{label}
</AdminPrimaryLink>
) : (
label
)}
{user.phone && user.userNo ? (
<Typography.Text type="secondary" style={{ display: 'block', fontSize: 12 }}>
{user.phone}
</Typography.Text>
) : null}
</div>
);
},
},
{
title: '商品',
key: 'product',
width: 200,
render: (_, row) => {
const order = row.order;
if (!order?.productName) return '—';
return (
<div>
<span>{order.productName}</span>
{order.productSpec ? (
<Typography.Text type="secondary" style={{ display: 'block', fontSize: 12 }}>
{order.productSpec}
</Typography.Text>
) : null}
</div>
);
},
},
{
title: '数量',
key: 'quantity',
width: 90,
render: (_, row) => formatQty(row.order),
},
{
title: '配送方式',
dataIndex: ['order', 'deliveryType'],
width: 90,
render: (v: string | undefined) => DELIVERY_TYPE_LABELS[v ?? ''] || v || '—',
},
{
title: '承运商',
dataIndex: 'provider',
width: 90,
render: (v: string) => DELIVERY_PROVIDER_LABELS[v] || v || '—',
},
{ title: '运单号', dataIndex: 'trackingNo', width: 140, render: (v) => v || '—' }, { title: '运单号', dataIndex: 'trackingNo', width: 140, render: (v) => v || '—' },
{
title: '运费',
dataIndex: 'logisticsFee',
width: 90,
render: (v: number | null | undefined) => (v == null ? '—' : `¥${Number(v).toFixed(2)}`),
},
{ title: '第三方单号', dataIndex: 'providerOrderNo', width: 140, render: (v) => v || '—' }, { title: '第三方单号', dataIndex: 'providerOrderNo', width: 140, render: (v) => v || '—' },
{ title: '订单状态', dataIndex: ['order', 'status'], width: 100, render: (s) => ORDER_STATUS_LABELS[s] || s }, {
title: '订单状态',
dataIndex: ['order', 'status'],
width: 100,
render: (s) => ORDER_STATUS_LABELS[s] || s,
},
{ title: '收货人', dataIndex: ['order', 'receiverName'], width: 90 }, { title: '收货人', dataIndex: ['order', 'receiverName'], width: 90 },
{
title: '收货电话',
dataIndex: ['order', 'receiverPhone'],
width: 120,
render: (v) => v || '—',
},
{
title: '配送地址',
key: 'address',
width: 280,
ellipsis: true,
render: (_, row) => formatAddress(row.order),
},
{ title: '更新', dataIndex: 'updatedAt', width: 160, render: fmtTime }, { title: '更新', dataIndex: 'updatedAt', width: 160, render: fmtTime },
{ {
title: '操作', width: 140, title: '操作', width: 140,
render: (_, row) => ( render: (_, row) => (
<Space size={0}> <Space size={0}>
<Button type="link" size="small" onClick={() => openTrack(row)}></Button> <Button type="link" size="small" onClick={() => openTrack(row)}></Button>
<Button type="link" size="small" onClick={async () => { <Button type="link" size="small" onClick={() => void openDetail(row)}></Button>
const d = await request<Row>(`/admin/deliveries/${row.id}`);
setDetail(d);
editForm.setFieldsValue({ provider: d.provider, trackingNo: d.trackingNo, providerOrderNo: d.providerOrderNo });
setDrawerOpen(true);
}}></Button>
</Space> </Space>
), ),
}, },
@@ -104,20 +234,21 @@ export default function DeliveriesPage() {
const { columns, settingsButton, settingsModal } = useAdminListColumns('deliveries', baseColumns, { page, pageSize }); const { columns, settingsButton, settingsModal } = useAdminListColumns('deliveries', baseColumns, { page, pageSize });
const order = detail?.order;
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}>/</Typography.Title> <AdminListHeader title="快递/配送单" settings={settingsButton} />
{settingsButton}
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="orderNo" label="订单号"><Input allowClear /></Form.Item> <Form.Item name="orderNo" label="订单号"><Input allowClear /></Form.Item>
<Form.Item name="provider" label="provider"><Input allowClear placeholder="MOCK" /></Form.Item> <Form.Item name="provider" label="承运商"><Input allowClear placeholder="XFX" /></Form.Item>
<Form.Item name="trackingNo" label="运单号"><Input allowClear /></Form.Item> <Form.Item name="trackingNo" label="运单号"><Input allowClear /></Form.Item>
<Form.Item><Button type="primary" htmlType="submit"></Button></Form.Item> <Form.Item><Button type="primary" htmlType="submit"></Button></Form.Item>
</Form> </Form>
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 'max-content' }} <Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 'max-content' }}
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} /> pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
<Drawer title="配送单编辑" width={480} open={drawerOpen} onClose={() => setDrawerOpen(false)} <Drawer title="配送单编辑" width={560} open={drawerOpen} onClose={() => setDrawerOpen(false)}
extra={ extra={
<Space> <Space>
<Button onClick={() => setDrawerOpen(false)}></Button> <Button onClick={() => setDrawerOpen(false)}></Button>
@@ -134,11 +265,63 @@ export default function DeliveriesPage() {
{detail && ( {detail && (
<> <>
<Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}> <Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}>
<Descriptions.Item label="订单">{detail.order?.orderNo}</Descriptions.Item> <Descriptions.Item label="订单">{order?.orderNo || '—'}</Descriptions.Item>
<Descriptions.Item label="收货">{detail.order?.receiverName} {detail.order?.receiverPhone}</Descriptions.Item> <Descriptions.Item label="用户">
{order?.user ? (
<Space size={8} wrap>
{order.user.id ? (
<AdminPrimaryLink
onClick={() => navigate('/users', { state: { openUserId: String(order.user!.id) } })}
>
{order.user.userNo}
</AdminPrimaryLink>
) : (
order.user.userNo || '—'
)}
<Typography.Text type="secondary">
{[order.user.nickname, order.user.phone].filter(Boolean).join(' / ') || ''}
</Typography.Text>
</Space>
) : '—'}
</Descriptions.Item>
<Descriptions.Item label="商品">
<Space align="start">
{order?.imageResource?.url ? (
<img
src={order.imageResource.url}
alt=""
style={{ width: 48, height: 48, objectFit: 'cover', borderRadius: 4 }}
/>
) : null}
<span>
{order?.productName || '—'}
{order?.productSpec ? (
<Typography.Text type="secondary" style={{ display: 'block', fontSize: 12 }}>
{order.productSpec}
</Typography.Text>
) : null}
{order?.barcode69 ? (
<Typography.Text type="secondary" style={{ display: 'block', fontSize: 12 }}>
{order.barcode69}
</Typography.Text>
) : null}
</span>
</Space>
</Descriptions.Item>
<Descriptions.Item label="数量">{formatQty(order)}</Descriptions.Item>
<Descriptions.Item label="配送方式">
{DELIVERY_TYPE_LABELS[order?.deliveryType ?? ''] || order?.deliveryType || '—'}
</Descriptions.Item>
<Descriptions.Item label="收货人">
{[order?.receiverName, order?.receiverPhone].filter(Boolean).join(' ') || '—'}
</Descriptions.Item>
<Descriptions.Item label="配送地址">{formatAddress(order)}</Descriptions.Item>
<Descriptions.Item label="运费">
{detail.logisticsFee == null ? '—' : `¥${Number(detail.logisticsFee).toFixed(2)}`}
</Descriptions.Item>
</Descriptions> </Descriptions>
<Form form={editForm} layout="vertical"> <Form form={editForm} layout="vertical">
<Form.Item name="provider" label="provider" rules={[{ required: true }]}><Input /></Form.Item> <Form.Item name="provider" label="承运商" rules={[{ required: true }]}><Input /></Form.Item>
<Form.Item name="providerOrderNo" label="第三方单号"><Input /></Form.Item> <Form.Item name="providerOrderNo" label="第三方单号"><Input /></Form.Item>
<Form.Item name="trackingNo" label="运单号"><Input /></Form.Item> <Form.Item name="trackingNo" label="运单号"><Input /></Form.Item>
</Form> </Form>
@@ -31,6 +31,7 @@ import { downloadBase64File } from '../lib/exportExcel';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import OssUpload from '../components/OssUpload'; import OssUpload from '../components/OssUpload';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -309,12 +310,11 @@ export default function DevPlanTasksPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="开发计划 · 任务列表"
· settings={settingsButton}
</Typography.Title> actions={
{settingsButton} <>
<Space wrap>
<Select <Select
value={exportFormat} value={exportFormat}
style={{ width: 120 }} style={{ width: 120 }}
@@ -341,8 +341,9 @@ export default function DevPlanTasksPage() {
<Button type="primary" onClick={openCreate}> <Button type="primary" onClick={openCreate}>
</Button> </Button>
</Space> </>
</div> }
/>
<Form <Form
layout="inline" layout="inline"
@@ -9,7 +9,6 @@ import {
Space, Space,
Table, Table,
Tag, Tag,
Typography,
message, message,
} from 'antd'; } from 'antd';
import type { ColumnsType } from 'antd/es/table'; import type { ColumnsType } from 'antd/es/table';
@@ -23,6 +22,7 @@ import { request } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -168,15 +168,15 @@ export default function DevPlanVersionsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="开发计划 · 版本列表"
· settings={settingsButton}
</Typography.Title> actions={
{settingsButton}
<Button type="primary" onClick={openCreate}> <Button type="primary" onClick={openCreate}>
</Button> </Button>
</div> }
/>
<Form <Form
layout="inline" layout="inline"
@@ -7,11 +7,11 @@ import {
Input, Input,
InputNumber, InputNumber,
Modal, Modal,
Popconfirm,
Select, Select,
Space, Space,
Table, Table,
Tag, Tag,
Typography,
message, message,
} from 'antd'; } from 'antd';
import type { ColumnsType } from 'antd/es/table'; import type { ColumnsType } from 'antd/es/table';
@@ -29,6 +29,7 @@ import {
import { request } from '../lib/api'; import { request } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -68,7 +69,10 @@ export default function FulfillmentProvidersPage() {
setLoading(true); setLoading(true);
try { try {
const res = await request<FulfillmentProviderDto[]>('/admin/fulfillment-providers'); const res = await request<FulfillmentProviderDto[]>('/admin/fulfillment-providers');
setRows(res); setRows(Array.isArray(res) ? res : []);
} catch (e) {
setRows([]);
message.error(e instanceof Error ? e.message : '加载承运商失败');
} finally { } finally {
setLoading(false); setLoading(false);
} }
@@ -94,6 +98,7 @@ export default function FulfillmentProvidersPage() {
extraBottleFee: DEFAULT_XFX_LOGISTICS_PRICING.extraBottleFee, extraBottleFee: DEFAULT_XFX_LOGISTICS_PRICING.extraBottleFee,
boxBottles: DEFAULT_XFX_LOGISTICS_PRICING.boxBottles, boxBottles: DEFAULT_XFX_LOGISTICS_PRICING.boxBottles,
boxFee: DEFAULT_XFX_LOGISTICS_PRICING.boxFee, boxFee: DEFAULT_XFX_LOGISTICS_PRICING.boxFee,
deliveryHintHtml: '',
}); });
setOpen(true); setOpen(true);
} }
@@ -122,6 +127,7 @@ export default function FulfillmentProvidersPage() {
extraBottleFee: pricing?.extraBottleFee ?? DEFAULT_XFX_LOGISTICS_PRICING.extraBottleFee, extraBottleFee: pricing?.extraBottleFee ?? DEFAULT_XFX_LOGISTICS_PRICING.extraBottleFee,
boxBottles: pricing?.boxBottles ?? DEFAULT_XFX_LOGISTICS_PRICING.boxBottles, boxBottles: pricing?.boxBottles ?? DEFAULT_XFX_LOGISTICS_PRICING.boxBottles,
boxFee: pricing?.boxFee ?? DEFAULT_XFX_LOGISTICS_PRICING.boxFee, boxFee: pricing?.boxFee ?? DEFAULT_XFX_LOGISTICS_PRICING.boxFee,
deliveryHintHtml: row.deliveryHintHtml || '',
}); });
setOpen(true); setOpen(true);
} }
@@ -144,6 +150,7 @@ export default function FulfillmentProvidersPage() {
boxBottles: v.boxBottles != null ? Number(v.boxBottles) : undefined, boxBottles: v.boxBottles != null ? Number(v.boxBottles) : undefined,
boxFee: v.boxFee != null ? Number(v.boxFee) : undefined, boxFee: v.boxFee != null ? Number(v.boxFee) : undefined,
}, },
deliveryHintHtml: v.deliveryHintHtml?.trim() || null,
}; };
if (isXfxProviderCode(String(v.code)) && v.type === FulfillmentProviderType.API) { if (isXfxProviderCode(String(v.code)) && v.type === FulfillmentProviderType.API) {
@@ -176,6 +183,16 @@ export default function FulfillmentProvidersPage() {
void load(); void load();
} }
async function remove(row: FulfillmentProviderDto) {
try {
await request(`/admin/fulfillment-providers/${row.id}`, { method: 'DELETE' });
message.success('已删除');
void load();
} catch (e) {
message.error(e instanceof Error ? e.message : '删除失败');
}
}
const baseColumns: ColumnsType<FulfillmentProviderDto> = [ const baseColumns: ColumnsType<FulfillmentProviderDto> = [
{ title: '编码', dataIndex: 'code', width: 100 }, { title: '编码', dataIndex: 'code', width: 100 },
{ {
@@ -230,11 +247,23 @@ export default function FulfillmentProvidersPage() {
{ title: '更新时间', dataIndex: 'updatedAt', width: 170, render: fmtTime }, { title: '更新时间', dataIndex: 'updatedAt', width: 170, render: fmtTime },
{ {
title: '操作', title: '操作',
width: 80, width: 140,
render: (_, row) => ( render: (_, row) => (
<Space size={0}>
<Button type="link" size="small" onClick={() => openEdit(row)}> <Button type="link" size="small" onClick={() => openEdit(row)}>
</Button> </Button>
<Popconfirm
title={`确认删除承运商「${row.name}」?`}
okText="删除"
okButtonProps={{ danger: true }}
onConfirm={() => void remove(row)}
>
<Button type="link" size="small" danger>
</Button>
</Popconfirm>
</Space>
), ),
}, },
]; ];
@@ -247,20 +276,16 @@ export default function FulfillmentProvidersPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<div> title="仓配管理"
<Typography.Title level={4} style={{ margin: 0 }}> description="注册承运商接口凭证,并配置物流对账用的银行账户、结算方式与计价标准"
settings={settingsButton}
</Typography.Title> actions={
{settingsButton}
<Typography.Text type="secondary">
</Typography.Text>
</div>
<Button type="primary" onClick={openCreate}> <Button type="primary" onClick={openCreate}>
</Button> </Button>
</Space> }
/>
<Alert <Alert
type="info" type="info"
@@ -292,6 +317,17 @@ export default function FulfillmentProvidersPage() {
<Form.Item name="status" label="状态" rules={[{ required: true }]}> <Form.Item name="status" label="状态" rules={[{ required: true }]}>
<Select options={STATUS_OPTIONS} /> <Select options={STATUS_OPTIONS} />
</Form.Item> </Form.Item>
<Form.Item
name="deliveryHintHtml"
label="配送信息提示"
extra="C 端同城送展示。支持 HTMLspan/p/br/b/strong/i/em/fontstyle 可用 color、font-weight、font-size、font-style。回车换行会原样显示。空则回退「同城配送,预计24小时内送到」。"
>
<Input.TextArea
rows={3}
maxLength={2000}
placeholder='<span style="color:#A61D24;font-weight:700;font-size:13px">同城配送,预计24小时内送到</span>'
/>
</Form.Item>
<Divider orientation="left"></Divider> <Divider orientation="left"></Divider>
<Form.Item name="settlementMethod" label="结算方式" rules={[{ required: true }]}> <Form.Item name="settlementMethod" label="结算方式" rules={[{ required: true }]}>
@@ -313,6 +349,7 @@ export default function FulfillmentProvidersPage() {
<Form.Item <Form.Item
name="baseBottles" name="baseBottles"
label="起送瓶数" label="起送瓶数"
extra="物流计价起步瓶数,不影响用户起购(起购在城市管理)"
rules={[{ required: true }]} rules={[{ required: true }]}
style={{ marginBottom: 12 }} style={{ marginBottom: 12 }}
> >
+9 -6
View File
@@ -8,6 +8,7 @@ import { request, type HqProfile, type Paginated } from '../lib/api';
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants'; import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -145,10 +146,11 @@ export default function HqAccountsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}>HQ </Typography.Title> title="HQ 账户"
{settingsButton} settings={settingsButton}
{isSuperAdmin && ( actions={
isSuperAdmin ? (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={() => {
@@ -159,8 +161,9 @@ export default function HqAccountsPage() {
> >
</Button> </Button>
)} ) : null
</Space> }
/>
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="phone" label="手机"><Input allowClear /></Form.Item> <Form.Item name="phone" label="手机"><Input allowClear /></Form.Item>
<Form.Item name="adminRole" label="角色"> <Form.Item name="adminRole" label="角色">
+6 -5
View File
@@ -10,6 +10,7 @@ import { fmtTime } from '../lib/constants';
import { HQ_OPERATION_ACTION_OPTIONS, resolveHqOperationLabel } from '../lib/hq-log'; import { HQ_OPERATION_ACTION_OPTIONS, resolveHqOperationLabel } from '../lib/hq-log';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -109,11 +110,11 @@ export default function HqLogsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}>HQ </Typography.Title> <AdminListHeader
{settingsButton} title="HQ 操作日志"
<Typography.Paragraph type="secondary"> settings={settingsButton}
description="记录总部后台写操作(开城、订单、用户、权限、合伙人等),仅追加不删除。"
</Typography.Paragraph> />
<Form <Form
form={form} form={form}
+7 -14
View File
@@ -11,7 +11,6 @@ import {
Space, Space,
Table, Table,
Tag, Tag,
Typography,
Upload, Upload,
message, message,
} from 'antd'; } from 'antd';
@@ -31,6 +30,7 @@ import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { uploadFileToOss } from '../lib/upload'; import { uploadFileToOss } from '../lib/upload';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -241,18 +241,10 @@ export default function InvoicesPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<div <AdminListHeader
style={{ title="发票管理"
display: 'flex', settings={settingsButton}
justifyContent: 'space-between', actions={
alignItems: 'center',
marginBottom: 16,
}}
>
<Typography.Title level={4} style={{ margin: 0 }}>
</Typography.Title>
{settingsButton}
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={() => {
@@ -266,7 +258,8 @@ export default function InvoicesPage() {
> >
</Button> </Button>
</div> }
/>
<Form <Form
form={filterForm} form={filterForm}
layout="inline" layout="inline"
@@ -26,6 +26,7 @@ import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { uploadFileToOss } from '../lib/upload'; import { uploadFileToOss } from '../lib/upload';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -264,15 +265,11 @@ export default function KnowledgeBasesPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16 }} wrap> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="知识库"
settings={settingsButton}
</Typography.Title> description="支持粘贴文本或上传 .txt/.md;可绑定到企微机器人供 AI 检索"
{settingsButton} />
<Typography.Text type="secondary">
.txt/.md AI
</Typography.Text>
</Space>
<Form <Form
form={filterForm} form={filterForm}
+6 -9
View File
@@ -26,6 +26,7 @@ import { request } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -271,15 +272,11 @@ export default function LlmConfigsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16 }} wrap> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="语言模型配置"
settings={settingsButton}
</Typography.Title> description="非超管仅可见自己创建的配置,且创建后只能改是否生效"
{settingsButton} />
<Typography.Text type="secondary">
</Typography.Text>
</Space>
<Form <Form
form={filterForm} form={filterForm}
@@ -30,6 +30,7 @@ import { downloadExcelCsv } from '../lib/exportExcel';
import { request } from '../lib/api'; import { request } from '../lib/api';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
type BillRow = { type BillRow = {
@@ -405,15 +406,11 @@ export default function LogisticsBillsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="物流对账"
settings={settingsButton}
</Typography.Title> description="按快递承运商汇总月度物流费;计价与银行账户在「仓配管理」配置。前期充值扣款,后期可切挂账月结。"
{settingsButton} />
<Typography.Text type="secondary">
</Typography.Text>
</Space>
<Tabs <Tabs
items={[ items={[
+34 -10
View File
@@ -27,6 +27,7 @@ import dayjs, { type Dayjs } from 'dayjs';
import { ORDER_TYPE_LABELS } from '@dukang/shared-types'; import { ORDER_TYPE_LABELS } from '@dukang/shared-types';
import { request, type AdminOrderItem, type AdminOrderRow, type HqProfile, type Paginated } from '../lib/api'; import { request, type AdminOrderItem, type AdminOrderRow, type HqProfile, type Paginated } from '../lib/api';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
import { downloadBase64File } from '../lib/exportExcel'; import { downloadBase64File } from '../lib/exportExcel';
import { import {
@@ -144,7 +145,7 @@ type OrderExportFormat = 'xlsx' | 'pdf';
type OrderExportFilters = { type OrderExportFilters = {
orderNo?: string; orderNo?: string;
status?: string; status?: string | string[];
orderType?: string; orderType?: string;
cityId?: string; cityId?: string;
receiverPhone?: string; receiverPhone?: string;
@@ -219,6 +220,12 @@ function formatBenefitBrief(row: AdminOrderRow) {
return '—'; return '—';
} }
function selectedStatuses(status: unknown): string[] {
if (Array.isArray(status)) return status.filter((s): s is string => Boolean(s));
if (typeof status === 'string' && status) return [status];
return [];
}
function buildExportPayload( function buildExportPayload(
scope: OrderExportScope, scope: OrderExportScope,
format: OrderExportFormat, format: OrderExportFormat,
@@ -231,7 +238,8 @@ function buildExportPayload(
return payload; return payload;
} }
if (filters.orderNo) payload.orderNo = filters.orderNo; if (filters.orderNo) payload.orderNo = filters.orderNo;
if (filters.status) payload.status = filters.status; const statuses = selectedStatuses(filters.status);
if (statuses.length) payload.status = statuses;
if (filters.orderType) payload.orderType = filters.orderType; if (filters.orderType) payload.orderType = filters.orderType;
if (filters.cityId) payload.cityId = filters.cityId; if (filters.cityId) payload.cityId = filters.cityId;
if (filters.receiverPhone) payload.receiverPhone = filters.receiverPhone; if (filters.receiverPhone) payload.receiverPhone = filters.receiverPhone;
@@ -357,7 +365,7 @@ export default function OrdersPage() {
const qs = new URLSearchParams({ page: String(page), pageSize: String(pageSize) }); const qs = new URLSearchParams({ page: String(page), pageSize: String(pageSize) });
if (initialOrderNo) qs.set('orderNo', initialOrderNo); if (initialOrderNo) qs.set('orderNo', initialOrderNo);
if (values.orderNo) qs.set('orderNo', values.orderNo); if (values.orderNo) qs.set('orderNo', values.orderNo);
if (values.status) qs.set('status', values.status); for (const status of selectedStatuses(values.status)) qs.append('status', status);
if (values.orderType) qs.set('orderType', values.orderType); if (values.orderType) qs.set('orderType', values.orderType);
if (values.cityId) qs.set('cityId', values.cityId); if (values.cityId) qs.set('cityId', values.cityId);
if (values.receiverPhone) qs.set('receiverPhone', values.receiverPhone); if (values.receiverPhone) qs.set('receiverPhone', values.receiverPhone);
@@ -666,6 +674,13 @@ export default function OrdersPage() {
width: 90, width: 90,
render: (v: number) => `¥${v}`, render: (v: number) => `¥${v}`,
}, },
{
title: '运费',
key: 'logisticsFee',
width: 90,
render: (_, row) =>
row.delivery?.logisticsFee == null ? '—' : `¥${Number(row.delivery.logisticsFee).toFixed(2)}`,
},
{ {
title: '好客权益', title: '好客权益',
width: 200, width: 200,
@@ -733,18 +748,20 @@ export default function OrdersPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 20, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> title="订单监控"
<Space size={12}> settings={settingsButton}
{settingsButton} actions={
<>
<Button onClick={() => window.open('/orders/big-screen', 'dukang-big-screen')}></Button> <Button onClick={() => window.open('/orders/big-screen', 'dukang-big-screen')}></Button>
{canProxyOrder ? ( {canProxyOrder ? (
<Button type="primary" onClick={() => setProxyOpen(true)}> <Button type="primary" onClick={() => setProxyOpen(true)}>
</Button> </Button>
) : null} ) : null}
</Space> </>
</Space> }
/>
{!canDeleteOrders && profile ? ( {!canDeleteOrders && profile ? (
<Alert <Alert
@@ -782,10 +799,12 @@ export default function OrdersPage() {
</Space> </Space>
</Form.Item> </Form.Item>
</Col> </Col>
<Col xs={12} sm={6} md={5} lg={3}> <Col xs={24} sm={12} md={8} lg={6}>
<Form.Item name="status" label="状态" style={{ marginBottom: 12 }}> <Form.Item name="status" label="状态" style={{ marginBottom: 12 }}>
<Select <Select
mode="multiple"
allowClear allowClear
maxTagCount="responsive"
placeholder="全部" placeholder="全部"
options={Object.entries(ORDER_STATUS_LABELS).map(([value, label]) => ({ value, label }))} options={Object.entries(ORDER_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
/> />
@@ -1146,6 +1165,11 @@ export default function OrdersPage() {
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="运单号">{detail.delivery.trackingNo || '—'}</Descriptions.Item> <Descriptions.Item label="运单号">{detail.delivery.trackingNo || '—'}</Descriptions.Item>
<Descriptions.Item label="三方单号">{detail.delivery.providerOrderNo || '—'}</Descriptions.Item> <Descriptions.Item label="三方单号">{detail.delivery.providerOrderNo || '—'}</Descriptions.Item>
<Descriptions.Item label="运费">
{detail.delivery.logisticsFee == null
? '—'
: `¥${Number(detail.delivery.logisticsFee).toFixed(2)}`}
</Descriptions.Item>
{detail.delivery.manualQueryUrl && ( {detail.delivery.manualQueryUrl && (
<Descriptions.Item label="查询链接"> <Descriptions.Item label="查询链接">
<a href={detail.delivery.manualQueryUrl} target="_blank" rel="noreferrer"> <a href={detail.delivery.manualQueryUrl} target="_blank" rel="noreferrer">
@@ -8,6 +8,7 @@ import { request, type Paginated } from '../lib/api';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, ORDER_STATUS_LABELS, PARTNER_BILL_STATUS_LABELS, fmtTime } from '../lib/constants'; import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, ORDER_STATUS_LABELS, PARTNER_BILL_STATUS_LABELS, fmtTime } from '../lib/constants';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
type PartnerOption = { id: string; companyName: string }; type PartnerOption = { id: string; companyName: string };
@@ -261,15 +262,11 @@ export default function PartnerAccountsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<div> title="合伙人子账号"
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> settings={settingsButton}
{settingsButton} description="主账号在「开城合伙人」创建;此处仅管理子账号树与权限"
<Typography.Text type="secondary"> />
</Typography.Text>
</div>
</Space>
<Form <Form
form={form} form={form}
layout="inline" layout="inline"
@@ -23,6 +23,7 @@ import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
import { downloadExcelCsv } from '../lib/exportExcel'; import { downloadExcelCsv } from '../lib/exportExcel';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -349,15 +350,11 @@ export default function PartnerBillsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="合伙人账单"
settings={settingsButton}
</Typography.Title> description="每月 1 日 8:00 自动生成上月账单(待审核)→ 发送合伙人确认 → 未打款 → 已打款"
{settingsButton} />
<Typography.Text type="secondary">
1 8:00
</Typography.Text>
</Space>
{summary && ( {summary && (
<Card size="small" style={{ marginBottom: 16 }}> <Card size="small" style={{ marginBottom: 16 }}>
+2 -4
View File
@@ -15,6 +15,7 @@ import { AdminCellLine } from '../components/AdminCellLine';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -156,10 +157,7 @@ export default function PartnerLogsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4} style={{ marginBottom: 16 }}> <AdminListHeader title="合伙人日志" settings={settingsButton} />
</Typography.Title>
{settingsButton}
<Segmented <Segmented
options={PARTNER_LOG_CATEGORY_OPTIONS.map((o) => ({ value: o.value, label: o.label }))} options={PARTNER_LOG_CATEGORY_OPTIONS.map((o) => ({ value: o.value, label: o.label }))}
value={category} value={category}
+7 -4
View File
@@ -28,6 +28,7 @@ import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect'; import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -218,13 +219,15 @@ export default function PartnersPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> title="开城合伙人"
{settingsButton} settings={settingsButton}
actions={
<Button type="primary" onClick={() => { setCreateOpen(true); createForm.resetFields(); setCreateScopeType(CityPartnerScopeType.CITY_WIDE); }}> <Button type="primary" onClick={() => { setCreateOpen(true); createForm.resetFields(); setCreateScopeType(CityPartnerScopeType.CITY_WIDE); }}>
</Button> </Button>
</Space> }
/>
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="companyName" label="公司"><Input allowClear /></Form.Item> <Form.Item name="companyName" label="公司"><Input allowClear /></Form.Item>
<Form.Item name="contactPhone" label="电话"><Input allowClear /></Form.Item> <Form.Item name="contactPhone" label="电话"><Input allowClear /></Form.Item>
@@ -24,6 +24,7 @@ import { request } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -146,8 +147,7 @@ export default function PendingRedeemPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader title="待处理核销(弱网兜底)" settings={settingsButton} />
{settingsButton}
<Form <Form
form={form} form={form}
layout="inline" layout="inline"
+7 -5
View File
@@ -15,6 +15,7 @@ import ProductDetailTemplatePicker from '../components/ProductDetailTemplatePick
import ProductSpecsEditor from '../components/ProductSpecsEditor'; import ProductSpecsEditor from '../components/ProductSpecsEditor';
import type { FormInstance } from 'antd/es/form'; import type { FormInstance } from 'antd/es/form';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -510,11 +511,11 @@ export default function ProductsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> title="商品管理"
{settingsButton} settings={settingsButton}
<Button type="primary" onClick={() => setCreateOpen(true)}></Button> actions={<Button type="primary" onClick={() => setCreateOpen(true)}></Button>}
</Space> />
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="name" label="名称"> <Form.Item name="name" label="名称">
<Input allowClear placeholder="名称 / SKU / 69 码" style={{ width: 200 }} /> <Input allowClear placeholder="名称 / SKU / 69 码" style={{ width: 200 }} />
@@ -609,6 +610,7 @@ export default function ProductsPage() {
label: '规格与 SKU', label: '规格与 SKU',
children: ( children: (
<ProductSpecsEditor <ProductSpecsEditor
key={String(detail.id)}
productId={String(detail.id)} productId={String(detail.id)}
initialAttrs={(detail.specAttrs as never) ?? []} initialAttrs={(detail.specAttrs as never) ?? []}
initialSkus={(detail.skus as never) ?? []} initialSkus={(detail.skus as never) ?? []}
+6 -5
View File
@@ -15,6 +15,7 @@ import { request } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -175,11 +176,11 @@ export default function PromoCodesPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}>广</Typography.Title> title="推广码管理"
{settingsButton} settings={settingsButton}
<Button type="primary" onClick={() => setCreateOpen(true)}>广</Button> actions={<Button type="primary" onClick={() => setCreateOpen(true)}>广</Button>}
</div> />
<Form <Form
form={filterForm} form={filterForm}
@@ -8,6 +8,7 @@ import { request } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -141,8 +142,7 @@ export default function RedeemRecordsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader title="核销记录" settings={settingsButton} />
{settingsButton}
<Form <Form
form={form} form={form}
layout="inline" layout="inline"
+6 -9
View File
@@ -13,6 +13,7 @@ import {
} from '../lib/constants'; } from '../lib/constants';
import OssUpload from '../components/OssUpload'; import OssUpload from '../components/OssUpload';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
type Row = { type Row = {
@@ -121,15 +122,11 @@ export default function ResourcesPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="OSS 资源库"
OSS settings={settingsButton}
</Typography.Title> actions={<Button type="primary" onClick={() => setCreateOpen(true)}></Button>}
{settingsButton} />
<Button type="primary" onClick={() => setCreateOpen(true)}>
</Button>
</Space>
<Form <Form
form={form} form={form}
layout="inline" layout="inline"
@@ -7,6 +7,7 @@ import { request, type Paginated } from '../lib/api';
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, STORE_STATUS_LABELS, fmtTime } from '../lib/constants'; import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, STORE_STATUS_LABELS, fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -153,14 +154,11 @@ export default function StoreAccountsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Space direction="vertical" size={0}> title="门店账户"
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> settings={settingsButton}
{settingsButton} description="主账号可绑定多家门店;收款信息挂在主账号;「新建账户」用于补录无主账号门店"
<Typography.Text type="secondary"> actions={
</Typography.Text>
</Space>
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={() => {
@@ -170,7 +168,8 @@ export default function StoreAccountsPage() {
> >
</Button> </Button>
</Space> }
/>
<Form <Form
form={form} form={form}
layout="inline" layout="inline"
+11 -8
View File
@@ -31,6 +31,7 @@ import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
import { downloadExcelCsv } from '../lib/exportExcel'; import { downloadExcelCsv } from '../lib/exportExcel';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -381,21 +382,23 @@ export default function StoreBillsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}> title="门店账单"
settings={settingsButton}
</Typography.Title> description={
{settingsButton} <>
<Typography.Text type="secondary">
T+1 沿 T+1 沿
= T+1 = = T+1 =
</Typography.Text>
{overdueSummary && overdueSummary.overdueCount > 0 ? ( {overdueSummary && overdueSummary.overdueCount > 0 ? (
<div>
<Typography.Text type="danger"> <Typography.Text type="danger">
{overdueSummary.overdueCount} {overdueSummary.pendingCount} {overdueSummary.overdueCount} {overdueSummary.pendingCount}
</Typography.Text> </Typography.Text>
</div>
) : null} ) : null}
</Space> </>
}
/>
{summary && ( {summary && (
<Card size="small" style={{ marginBottom: 16 }}> <Card size="small" style={{ marginBottom: 16 }}>
@@ -5,6 +5,7 @@ import {
import type { ColumnsType } from 'antd/es/table'; import type { ColumnsType } from 'antd/es/table';
import { request, type HqProfile } from '../lib/api'; import { request, type HqProfile } from '../lib/api';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -179,13 +180,12 @@ export default function StoreCategoriesPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Space direction="vertical" size={0}> title="门店分类"
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> settings={settingsButton}
{settingsButton} description="两级分类:一级(餐饮/住宿/娱乐)→ 二级业态,供合伙人开店选择"
<Typography.Text type="secondary">/宿/ </Typography.Text> actions={
</Space> <>
<Space>
{canDelete ? ( {canDelete ? (
<Button <Button
onClick={async () => { onClick={async () => {
@@ -198,8 +198,9 @@ export default function StoreCategoriesPage() {
</Button> </Button>
) : null} ) : null}
<Button type="primary" onClick={() => openCreate()}></Button> <Button type="primary" onClick={() => openCreate()}></Button>
</Space> </>
</Space> }
/>
<Table <Table
rowKey="id" rowKey="id"
+6 -5
View File
@@ -13,6 +13,7 @@ import { AdminCellLine } from '../components/AdminCellLine';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -151,11 +152,11 @@ export default function StoreLogsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader
{settingsButton} title="商户日志"
<Typography.Paragraph type="secondary" style={{ marginTop: -8 }}> settings={settingsButton}
/ description="门店登录、微信授权、核销、打款与营业状态等操作记录;历史核销/打款数据来自业务表归档。"
</Typography.Paragraph> />
<Segmented <Segmented
style={{ marginBottom: 16 }} style={{ marginBottom: 16 }}
options={STORE_LOG_CATEGORY_OPTIONS.map((o) => ({ value: o.value, label: o.label }))} options={STORE_LOG_CATEGORY_OPTIONS.map((o) => ({ value: o.value, label: o.label }))}
+6 -5
View File
@@ -8,6 +8,7 @@ import { ADMIN_OPTIONS_PAGE_SIZE, MEDIA_TYPE_LABELS, fmtTime } from '../lib/cons
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import OssUpload from '../components/OssUpload'; import OssUpload from '../components/OssUpload';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -96,11 +97,11 @@ export default function StoreMediaPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> title="门店资源"
{settingsButton} settings={settingsButton}
<Button type="primary" onClick={() => { void loadStores(); setCreateOpen(true); }}></Button> actions={<Button type="primary" onClick={() => { void loadStores(); setCreateOpen(true); }}></Button>}
</Space> />
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="storeId" label="门店ID"><Input allowClear /></Form.Item> <Form.Item name="storeId" label="门店ID"><Input allowClear /></Form.Item>
<Form.Item name="mediaType" label="类型"> <Form.Item name="mediaType" label="类型">
@@ -33,6 +33,7 @@ import { notifyPackageAuditChanged } from '../lib/admin-events';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import StorePackageAuditPanel from '../components/StorePackageAuditPanel'; import StorePackageAuditPanel from '../components/StorePackageAuditPanel';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
const HQ_PACKAGE_STATUS_LABELS: Record<StorePackageChangeStatus, string> = { const HQ_PACKAGE_STATUS_LABELS: Record<StorePackageChangeStatus, string> = {
@@ -545,8 +546,7 @@ export default function StorePackageAuditsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader title="审核通知" settings={settingsButton} />
{settingsButton}
<Tabs <Tabs
activeKey={activeTab} activeKey={activeTab}
onChange={setActiveTab} onChange={setActiveTab}
@@ -6,6 +6,7 @@ import { fmtTime, ADMIN_OPTIONS_PAGE_SIZE } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { request, type Paginated } from '../lib/api'; import { request, type Paginated } from '../lib/api';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
type Row = { type Row = {
@@ -69,10 +70,7 @@ export default function StoreRatingsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4} style={{ marginTop: 0 }}> <AdminListHeader title="门店评价" settings={settingsButton} />
</Typography.Title>
{settingsButton}
<Form <Form
form={form} form={form}
layout="inline" layout="inline"
@@ -21,6 +21,7 @@ import { request, type Paginated } from '../lib/api';
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants'; import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -237,10 +238,7 @@ export default function StoreWithdrawalsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4} style={{ marginTop: 0 }}> <AdminListHeader title="门店提现审" settings={settingsButton} />
</Typography.Title>
{settingsButton}
{overdueSummary ? ( {overdueSummary ? (
<Typography.Paragraph type="secondary"> <Typography.Paragraph type="secondary">
{overdueSummary.pendingCount} {overdueSummary.pendingCount}
+8 -9
View File
@@ -40,6 +40,7 @@ import {
} from '../lib/storeCreate'; } from '../lib/storeCreate';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
import { resolveRegionBinding } from '../lib/china-region'; import { resolveRegionBinding } from '../lib/china-region';
import ChinaRegionCascader from '../components/ChinaRegionCascader'; import ChinaRegionCascader from '../components/ChinaRegionCascader';
@@ -873,16 +874,14 @@ export default function StoresPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Space direction="vertical" size={0}> title="门店"
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> settings={settingsButton}
<Typography.Text type="secondary"> {data?.total ?? 0} </Typography.Text> description={`${data?.total ?? 0} 家门店(含合伙人录入)`}
</Space> actions={
<Space>
{settingsButton}
<Button type="primary" onClick={openCreateModal}></Button> <Button type="primary" onClick={openCreateModal}></Button>
</Space> }
</Space> />
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="name" label="名称"><Input allowClear /></Form.Item> <Form.Item name="name" label="名称"><Input allowClear /></Form.Item>
<Form.Item name="phone" label="电话"><Input allowClear /></Form.Item> <Form.Item name="phone" label="电话"><Input allowClear /></Form.Item>
@@ -21,6 +21,7 @@ import type { ColumnsType } from 'antd/es/table';
import { request, type Paginated } from '../lib/api'; import { request, type Paginated } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
const MOCK_KEYS = ['MOCK_SMS', 'MOCK_WECHAT', 'MOCK_PAY'] as const; const MOCK_KEYS = ['MOCK_SMS', 'MOCK_WECHAT', 'MOCK_PAY'] as const;
@@ -410,10 +411,7 @@ export default function TestWhitelistPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4} style={{ marginTop: 0 }}> <AdminListHeader title="白名单管理" settings={settingsButton} />
</Typography.Title>
{settingsButton}
<Card size="small" loading={mockLoading} style={{ marginBottom: 16 }}> <Card size="small" loading={mockLoading} style={{ marginBottom: 16 }}>
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}> <Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}>
@@ -5,6 +5,7 @@ import { request } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -137,8 +138,7 @@ export default function ThirdPartyLogsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader title="第三方日志" settings={settingsButton} />
{settingsButton}
<Form <Form
layout="inline" layout="inline"
style={{ marginBottom: 16 }} style={{ marginBottom: 16 }}
+2 -2
View File
@@ -8,6 +8,7 @@ import { AdminCellLine } from '../components/AdminCellLine';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -120,8 +121,7 @@ export default function UserLogsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader title="用户日志" settings={settingsButton} />
{settingsButton}
<Segmented <Segmented
style={{ marginBottom: 16 }} style={{ marginBottom: 16 }}
options={USER_LOG_CATEGORY_OPTIONS.map((o) => ({ value: o.value, label: o.label }))} options={USER_LOG_CATEGORY_OPTIONS.map((o) => ({ value: o.value, label: o.label }))}
+9 -8
View File
@@ -20,6 +20,7 @@ import type { ColumnsType } from 'antd/es/table';
import { USER_SOURCE_TYPE_LABELS, resolveUserLogCategory, type UserSourceType } from '@dukang/shared-types'; import { USER_SOURCE_TYPE_LABELS, resolveUserLogCategory, type UserSourceType } from '@dukang/shared-types';
import { request, type AdminUserRow, type HqProfile, type Paginated } from '../lib/api'; import { request, type AdminUserRow, type HqProfile, type Paginated } from '../lib/api';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
import { ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants'; import { ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
@@ -481,11 +482,11 @@ export default function UsersPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}> <AdminListHeader
<Typography.Title level={4} style={{ margin: 0 }}></Typography.Title> title="用户监控"
<Space> settings={settingsButton}
{settingsButton} actions={
{canDeleteUsers ? ( canDeleteUsers ? (
<Button <Button
danger danger
disabled={!selectedRowKeys.length} disabled={!selectedRowKeys.length}
@@ -493,9 +494,9 @@ export default function UsersPage() {
> >
{selectedRowKeys.length ? ` (${selectedRowKeys.length})` : ''} {selectedRowKeys.length ? ` (${selectedRowKeys.length})` : ''}
</Button> </Button>
) : null} ) : null
</Space> }
</Space> />
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={() => { setPage(1); void load(); }}> <Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={() => { setPage(1); void load(); }}>
<Form.Item name="phone" label="手机号"> <Form.Item name="phone" label="手机号">
<Input placeholder="模糊搜索" allowClear /> <Input placeholder="模糊搜索" allowClear />
@@ -8,6 +8,7 @@ import { AdminCellLine } from '../components/AdminCellLine';
import { fmtTime, maskPhone } from '../lib/constants'; import { fmtTime, maskPhone } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -210,11 +211,11 @@ export default function WechatBindingsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader
{settingsButton} title="微信绑定总览"
<Typography.Paragraph type="secondary"> settings={settingsButton}
unionId C HQ unionId description="按 unionId 聚合展示已绑定微信的 C 端用户、门店账号、合伙人账号与 HQ 账号;无 unionId 时按单账号分组。"
</Typography.Paragraph> />
<Form <Form
form={form} form={form}
@@ -6,6 +6,7 @@ import { request } from '../lib/api';
import { fmtTime } from '../lib/constants'; import { fmtTime } from '../lib/constants';
import type { WecomBotLogDto } from '@dukang/shared-types'; import type { WecomBotLogDto } from '@dukang/shared-types';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -64,11 +65,11 @@ export default function WecomBotLogsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<Typography.Title level={4}></Typography.Title> <AdminListHeader
{settingsButton} title="企微机器人日志"
<Typography.Paragraph type="secondary"> settings={settingsButton}
description="记录机器人在企微内的查询与审批操作,含权限点、耗时与成败。"
</Typography.Paragraph> />
<Form <Form
form={form} form={form}
@@ -35,6 +35,7 @@ import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import OssUpload from '../components/OssUpload'; import OssUpload from '../components/OssUpload';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -272,9 +273,15 @@ function PushRoutesTab() {
return ( return (
<> <>
{settingsModal} {settingsModal}
<Typography.Paragraph type="secondary"> <AdminListHeader
Webhook / .env Webhook URL settings={settingsButton}
</Typography.Paragraph> description="配置群机器人 Webhook:按推送条件订阅业务通知 / 告警。运行时不再读取 .env 中的 Webhook URL。"
actions={
<Button type="primary" onClick={openCreate}>
</Button>
}
/>
<Form <Form
form={filterForm} form={filterForm}
@@ -309,10 +316,6 @@ function PushRoutesTab() {
> >
</Button> </Button>
<Button type="primary" onClick={openCreate}>
</Button>
{settingsButton}
</Space> </Space>
</Form.Item> </Form.Item>
</Form> </Form>
+10 -22
View File
@@ -27,6 +27,7 @@ import { downloadExcelCsv } from '../lib/exportExcel';
import { request, type HqProfile } from '../lib/api'; import { request, type HqProfile } from '../lib/api';
import { useAdminList } from '../lib/useAdminList'; import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns'; import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
@@ -305,31 +306,18 @@ export default function WineryBillsPage() {
return ( return (
<div> <div>
{settingsModal} {settingsModal}
<div <AdminListHeader
style={{ title="酒厂对账单"
display: 'flex', settings={settingsButton}
justifyContent: 'space-between', description={`T+3:每日 8:00 汇总 3 天前(自然日)已完成的同城/跨城订单(实付 × ${ratePct}%);未打款红色、已打款绿色、应付为 0 无需打款(灰),可展开订单明细`}
alignItems: 'flex-start', actions={
marginBottom: 16, canEditWineryBank ? (
gap: 16,
}}
>
<Space direction="vertical" size={0}>
<Typography.Title level={4} style={{ margin: 0 }}>
</Typography.Title>
{settingsButton}
<Typography.Text type="secondary">
T+3 8:00 3 / × {ratePct}%绿 0
</Typography.Text>
</Space>
{canEditWineryBank ? (
<Button type="default" onClick={() => void openBankModal()}> <Button type="default" onClick={() => void openBankModal()}>
</Button> </Button>
) : null} ) : null
</div> }
/>
{summary && ( {summary && (
<Card size="small" style={{ marginBottom: 16 }}> <Card size="small" style={{ marginBottom: 16 }}>
@@ -11,6 +11,7 @@ import { useAdminList } from '../../lib/useAdminList';
import type { PromoCodeDetailContext } from './PromoCodeDetailLayout'; import type { PromoCodeDetailContext } from './PromoCodeDetailLayout';
import { useAdminListColumns } from '../../lib/useAdminListColumns'; import { useAdminListColumns } from '../../lib/useAdminListColumns';
import { AdminPrimaryLink } from '../../components/AdminPrimaryLink'; import { AdminPrimaryLink } from '../../components/AdminPrimaryLink';
import { AdminListHeader } from '../../components/AdminListHeader';
export default function PromoCodeUsersPage() { export default function PromoCodeUsersPage() {
@@ -84,6 +85,9 @@ export default function PromoCodeUsersPage() {
const { columns, settingsButton, settingsModal } = useAdminListColumns('promo-code-users', baseColumns, { page, pageSize }); const { columns, settingsButton, settingsModal } = useAdminListColumns('promo-code-users', baseColumns, { page, pageSize });
return ( return (
<>
{settingsModal}
<AdminListHeader settings={settingsButton} />
<Table <Table
rowKey="id" rowKey="id"
className="admin-table-nowrap" className="admin-table-nowrap"
@@ -99,5 +103,6 @@ export default function PromoCodeUsersPage() {
onChange: (p, ps) => { setPage(p); setPageSize(ps); }, onChange: (p, ps) => { setPage(p); setPageSize(ps); },
}} }}
/> />
</>
); );
} }
+5 -1
View File
@@ -1,6 +1,7 @@
import { Navigate, useLocation } from 'react-router-dom'; import { Navigate, useLocation } from 'react-router-dom';
import { getStoreProfile, hasShopWxSession } from '../lib/api'; import { getStoreProfile, hasShopWxSession } from '../lib/api';
import { useStoreSession } from '../contexts/StoreSessionContext'; import { useStoreSession } from '../contexts/StoreSessionContext';
import { peekShopReturnTo, rememberShopReturnPath } from '../lib/shop-redeem-return';
const PUBLIC_PATHS = new Set(['/login', '/legal/user-agreement', '/legal/privacy-policy']); const PUBLIC_PATHS = new Set(['/login', '/legal/user-agreement', '/legal/privacy-policy']);
const SELECT_STORE_PATH = '/select-store'; const SELECT_STORE_PATH = '/select-store';
@@ -18,14 +19,17 @@ export default function AuthGate({ children }: { children: React.ReactNode }) {
} }
if (authenticated && location.pathname === '/login') { if (authenticated && location.pathname === '/login') {
return <Navigate to={needsSelectStore ? SELECT_STORE_PATH : '/'} replace />; const next = needsSelectStore ? SELECT_STORE_PATH : (peekShopReturnTo() || '/');
return <Navigate to={next} replace />;
} }
if (authenticated && needsSelectStore && location.pathname !== SELECT_STORE_PATH) { if (authenticated && needsSelectStore && location.pathname !== SELECT_STORE_PATH) {
rememberShopReturnPath(location);
return <Navigate to={SELECT_STORE_PATH} replace />; return <Navigate to={SELECT_STORE_PATH} replace />;
} }
if (!authenticated && !PUBLIC_PATHS.has(location.pathname)) { if (!authenticated && !PUBLIC_PATHS.has(location.pathname)) {
rememberShopReturnPath(location);
const profile = getStoreProfile(); const profile = getStoreProfile();
if (profile && hasShopWxSession() && location.pathname !== '/login') { if (profile && hasShopWxSession() && location.pathname !== '/login') {
return <Navigate to="/login?quick=1" replace state={{ from: location }} />; return <Navigate to="/login?quick=1" replace state={{ from: location }} />;
+1 -22
View File
@@ -1,22 +1 @@
/** 从微信扫码结果解析核销 token32 位 hex 或带 token 参数的 URL */ export { parseRedeemTokenFromScan } from '@dukang/shared-types';
export function parseRedeemTokenFromScan(raw: string): string | null {
const trimmed = raw.trim();
if (!trimmed) return null;
if (/^[a-f0-9]{32}$/i.test(trimmed)) {
return trimmed.toLowerCase();
}
try {
const url = trimmed.startsWith('http') ? new URL(trimmed) : new URL(trimmed, 'https://local.invalid');
const fromQuery = url.searchParams.get('token');
if (fromQuery && /^[a-f0-9]{32}$/i.test(fromQuery)) {
return fromQuery.toLowerCase();
}
} catch {
/* not a URL */
}
const hexMatch = trimmed.match(/[a-f0-9]{32}/i);
return hexMatch ? hexMatch[0].toLowerCase() : null;
}
+14
View File
@@ -0,0 +1,14 @@
import { hardNavigateInWechat, shouldHardNavigateForJssdk } from '@dukang/weixin-sdk';
/** iOS 微信内用整页跳转,避免 JSSDK 入场 URL 与 SPA 路径不一致 */
export function goShopPath(
path: string,
navigate: (path: string, opts?: { replace?: boolean }) => void,
opts?: { replace?: boolean },
): void {
if (shouldHardNavigateForJssdk()) {
hardNavigateInWechat(path);
return;
}
navigate(path, { replace: opts?.replace ?? true });
}
@@ -0,0 +1,45 @@
/** 扫核销码落地 /redeem?token= 后未登录或需选店,记下回跳路径(OAuth 整页跳转会丢掉 location.state */
export const SHOP_REDEEM_RETURN_KEY = 'shop_redeem_return';
function isRedeemReturnPath(path: string): boolean {
if (!path.startsWith('/redeem')) return false;
if (path.startsWith('/redeem/')) return false;
try {
const url = new URL(path, 'https://local.invalid');
return !!url.searchParams.get('token')?.trim();
} catch {
return false;
}
}
export function rememberShopReturnTo(path: string): void {
if (!isRedeemReturnPath(path)) return;
try {
sessionStorage.setItem(SHOP_REDEEM_RETURN_KEY, path);
} catch {
/* ignore */
}
}
export function rememberShopReturnPath(location: { pathname: string; search: string }): void {
rememberShopReturnTo(`${location.pathname}${location.search}`);
}
export function peekShopReturnTo(): string | null {
try {
const path = sessionStorage.getItem(SHOP_REDEEM_RETURN_KEY);
return path && isRedeemReturnPath(path) ? path : null;
} catch {
return null;
}
}
export function consumeShopReturnTo(): string | null {
const path = peekShopReturnTo();
try {
sessionStorage.removeItem(SHOP_REDEEM_RETURN_KEY);
} catch {
/* ignore */
}
return path;
}
@@ -3,6 +3,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
import WeakNetFallbackPanel from '../components/WeakNetFallbackPanel'; import WeakNetFallbackPanel from '../components/WeakNetFallbackPanel';
import { request } from '../lib/api'; import { request } from '../lib/api';
import { reportRedeemFailure } from '../lib/redeem-failure'; import { reportRedeemFailure } from '../lib/redeem-failure';
import { consumeShopReturnTo } from '../lib/shop-redeem-return';
import { toastError } from '../lib/toast'; import { toastError } from '../lib/toast';
import { useStorePageView } from '../lib/usePageView'; import { useStorePageView } from '../lib/usePageView';
@@ -47,6 +48,7 @@ export default function RedeemConfirmPage() {
navigate('/', { replace: true }); navigate('/', { replace: true });
return; return;
} }
consumeShopReturnTo();
setToken(scanned); setToken(scanned);
}, [searchParams, navigate]); }, [searchParams, navigate]);
+6 -3
View File
@@ -1,5 +1,6 @@
import { useEffect, useMemo } from 'react'; import { useEffect, useMemo } from 'react';
import { useLocation, useNavigate } from 'react-router-dom'; import { useLocation, useNavigate } from 'react-router-dom';
import { goShopPath } from '../lib/shop-nav';
import { notifyRedeemSuccess } from '../lib/useRedeemSuccessBus'; import { notifyRedeemSuccess } from '../lib/useRedeemSuccessBus';
import { formatMoney, toMoneyNumber } from '../lib/money'; import { formatMoney, toMoneyNumber } from '../lib/money';
@@ -35,10 +36,12 @@ export default function RedeemSuccessPage() {
}); });
}, [redeemNo, amount]); }, [redeemNo, amount]);
const goHome = () => goShopPath('/', navigate, { replace: true });
return ( return (
<div className="shop-success-page"> <div className="shop-success-page">
<header className="shop-success-header"> <header className="shop-success-header">
<button type="button" className="shop-redeem-back" onClick={() => navigate('/')} aria-label="返回"> <button type="button" className="shop-redeem-back" onClick={goHome} aria-label="返回">
<span className="material-symbols-outlined">arrow_back</span> <span className="material-symbols-outlined">arrow_back</span>
</button> </button>
<h1 className="app-page-title"></h1> <h1 className="app-page-title"></h1>
@@ -85,11 +88,11 @@ export default function RedeemSuccessPage() {
</div> </div>
<div className="shop-success-actions"> <div className="shop-success-actions">
<button type="button" className="shop-success-primary-btn" onClick={() => navigate('/')}> <button type="button" className="shop-success-primary-btn" onClick={goHome}>
<span></span> <span></span>
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>qr_code_scanner</span> <span className="material-symbols-outlined" style={{ fontSize: 20 }}>qr_code_scanner</span>
</button> </button>
<button type="button" className="shop-success-outline-btn" onClick={() => navigate('/')}> <button type="button" className="shop-success-outline-btn" onClick={goHome}>
<span></span> <span></span>
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>home</span> <span className="material-symbols-outlined" style={{ fontSize: 20 }}>home</span>
</button> </button>
+10 -15
View File
@@ -1,7 +1,6 @@
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import PullToRefresh from '@dukang/shared-ui/PullToRefresh'; import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
import { hardNavigateInWechat, shouldHardNavigateForJssdk } from '@dukang/weixin-sdk';
import { useStoreSession } from '../contexts/StoreSessionContext'; import { useStoreSession } from '../contexts/StoreSessionContext';
import { import {
needsStoreSelection, needsStoreSelection,
@@ -10,13 +9,11 @@ import {
type ShopSessionPayload, type ShopSessionPayload,
type ShopStoreOption, type ShopStoreOption,
} from '../lib/api'; } from '../lib/api';
import { goShopPath } from '../lib/shop-nav';
import { consumeShopReturnTo, peekShopReturnTo } from '../lib/shop-redeem-return';
function goShopHome(navigate: (path: string, opts?: { replace?: boolean }) => void) { function goAfterSelectStore(navigate: (path: string, opts?: { replace?: boolean }) => void) {
if (shouldHardNavigateForJssdk()) { goShopPath(consumeShopReturnTo() || '/', navigate);
hardNavigateInWechat('/');
return;
}
navigate('/', { replace: true });
} }
export default function SelectStorePage() { export default function SelectStorePage() {
@@ -46,7 +43,7 @@ export default function SelectStorePage() {
async function onSelect(storeId: string) { async function onSelect(storeId: string) {
if (loadingId) return; if (loadingId) return;
if (storeId === currentStoreId) { if (storeId === currentStoreId) {
goShopHome(navigate); goAfterSelectStore(navigate);
return; return;
} }
setLoadingId(storeId); setLoadingId(storeId);
@@ -54,7 +51,7 @@ export default function SelectStorePage() {
try { try {
const session = await selectStore(storeId); const session = await selectStore(storeId);
applySession(session); applySession(session);
goShopHome(navigate); goAfterSelectStore(navigate);
} catch (e) { } catch (e) {
setMsg(e instanceof Error ? e.message : '选店失败'); setMsg(e instanceof Error ? e.message : '选店失败');
} finally { } finally {
@@ -170,16 +167,14 @@ export default function SelectStorePage() {
); );
} }
/** After login/wechat: route to select-store or home */ /** After login/wechat: route to select-store, redeem return, or home */
export function routeAfterShopLogin( export function routeAfterShopLogin(
session: ShopSessionPayload, session: ShopSessionPayload,
navigate: (path: string, opts?: { replace?: boolean }) => void, navigate: (path: string, opts?: { replace?: boolean }) => void,
) { ) {
const path = needsStoreSelection(session) ? '/select-store' : '/'; if (needsStoreSelection(session)) {
// iOS 微信:必须整页跳转,让业务页成为 JSSDK 新入场 URL,否则扫码验签必挂 goShopPath('/select-store', navigate);
if (shouldHardNavigateForJssdk()) {
hardNavigateInWechat(path);
return; return;
} }
navigate(path, { replace: true }); goShopPath(peekShopReturnTo() || '/', navigate);
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@dukang/mini-user", "name": "@dukang/mini-user",
"version": "3.5.4", "version": "3.5.10",
"private": true, "private": true,
"description": "杜康好客 · C 端用户微信小程序(Taro)", "description": "杜康好客 · C 端用户微信小程序(Taro)",
"scripts": { "scripts": {
@@ -1,5 +1,9 @@
import { useEffect, useState } from 'react';
import { Button, Text } from '@tarojs/components'; import { Button, Text } from '@tarojs/components';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { toast } from '../lib/api';
import { getBrandAssetsSync, loadBrandAssets } from '../lib/brand-assets';
import { formatOpenCsError, openWecomCustomerServiceChat } from '../lib/wecom-cs';
export type ContactCsSessionContext = { export type ContactCsSessionContext = {
orderId?: string; orderId?: string;
@@ -16,7 +20,7 @@ type ContactCsButtonProps = {
const isWeapp = process.env.TARO_ENV === 'weapp'; const isWeapp = process.env.TARO_ENV === 'weapp';
/** 组装 session-from(微信限制约 1000 字符) */ /** 组装 session-from(微信限制约 1000 字符;原生小程序客服兜底用 */
export function buildCsSessionFrom(session?: ContactCsSessionContext): string { export function buildCsSessionFrom(session?: ContactCsSessionContext): string {
if (!session) return 'dukang|from=mini-user'; if (!session) return 'dukang|from=mini-user';
const parts = ['dukang']; const parts = ['dukang'];
@@ -26,16 +30,61 @@ export function buildCsSessionFrom(session?: ContactCsSessionContext): string {
return parts.join('|'); return parts.join('|');
} }
function canOpenWecom(url: string, corpId: string) {
return !!url.trim() && !!corpId.trim();
}
/** /**
* open-type=contact * C 线
* weapp * - weapp CorpID + kfid
* - weapp CorpID退 open-type=contact
* - H5 kfid
*/ */
export default function ContactCsButton({ export default function ContactCsButton({
className = '', className = '',
children = '联系在线客服', children = '联系在线客服',
session, session,
}: ContactCsButtonProps) { }: ContactCsButtonProps) {
if (!isWeapp) return null; const [cs, setCs] = useState(() => getBrandAssetsSync());
useEffect(() => {
void loadBrandAssets().then(setCs);
}, []);
const wecomChatReady = canOpenWecom(cs.customerServiceWecomUrl, cs.wecomCorpId);
const wecomWebReady = !!cs.customerServiceWecomUrl.trim();
if (!isWeapp && !wecomWebReady) return null;
async function openWecom() {
try {
if (isWeapp && wecomChatReady) {
await openWecomCustomerServiceChat({
url: cs.customerServiceWecomUrl,
corpId: cs.wecomCorpId,
session,
});
return;
}
if (typeof window !== 'undefined' && cs.customerServiceWecomUrl) {
window.location.href = cs.customerServiceWecomUrl;
return;
}
toast('请在微信内打开后联系客服');
} catch (e) {
console.error('[wecom-cs] open failed', e);
const msg = formatOpenCsError(e);
if (msg) toast(msg);
}
}
if (wecomChatReady || (!isWeapp && wecomWebReady)) {
return (
<Button className={className} hoverClass="none" onClick={() => void openWecom()}>
{typeof children === 'string' ? <Text>{children}</Text> : children}
</Button>
);
}
return ( return (
<Button <Button
@@ -0,0 +1,22 @@
import { RichText, Text } from '@tarojs/components';
import { deliveryHintHtmlToRichNodes } from '@dukang/shared-types';
import { DEFAULT_LOCAL_DELIVERY_HINT } from '../lib/local-delivery';
type DeliveryHintHtmlProps = {
html?: string | null;
className?: string;
};
/** 承运商配送提示:HTML 用 RichTexttextarea 里的换行转成 br */
export default function DeliveryHintHtml({
html,
className = '',
}: DeliveryHintHtmlProps) {
const raw = (html || '').trim() || DEFAULT_LOCAL_DELIVERY_HINT;
const nodes = deliveryHintHtmlToRichNodes(raw);
const looksHtml = /<[a-z][\s\S]*>/i.test(nodes);
if (!looksHtml) {
return <Text className={className}>{nodes}</Text>;
}
return <RichText className={className} nodes={nodes} />;
}
@@ -10,10 +10,11 @@ import {
const CANVAS_ID = 'redeem-qr-canvas'; const CANVAS_ID = 'redeem-qr-canvas';
type RedeemQrCodeProps = { type RedeemQrCodeProps = {
token: string; /** 二维码内容:门店 H5 落地 URL,缺省回退 token */
payload: string;
}; };
function drawOnWeappCanvas(token: string) { function drawOnWeappCanvas(payload: string) {
const page = Taro.getCurrentInstance().page; const page = Taro.getCurrentInstance().page;
const query = page ? Taro.createSelectorQuery().in(page) : Taro.createSelectorQuery(); const query = page ? Taro.createSelectorQuery().in(page) : Taro.createSelectorQuery();
query query
@@ -33,33 +34,33 @@ function drawOnWeappCanvas(token: string) {
canvas.width = layoutW * dpr; canvas.width = layoutW * dpr;
canvas.height = layoutH * dpr; canvas.height = layoutH * dpr;
ctx.scale(dpr, dpr); ctx.scale(dpr, dpr);
drawRedeemQrOnCanvas(ctx, token, drawSize); drawRedeemQrOnCanvas(ctx, payload, drawSize);
}); });
} }
export default function RedeemQrCode({ token }: RedeemQrCodeProps) { export default function RedeemQrCode({ payload }: RedeemQrCodeProps) {
const [imgSrc, setImgSrc] = useState(''); const [imgSrc, setImgSrc] = useState('');
const isWeapp = process.env.TARO_ENV === 'weapp'; const isWeapp = process.env.TARO_ENV === 'weapp';
useEffect(() => { useEffect(() => {
if (!token) { if (!payload) {
setImgSrc(''); setImgSrc('');
return; return;
} }
if (isWeapp) { if (isWeapp) {
const timer = setTimeout(() => drawOnWeappCanvas(token), 120); const timer = setTimeout(() => drawOnWeappCanvas(payload), 120);
return () => clearTimeout(timer); return () => clearTimeout(timer);
} }
let cancelled = false; let cancelled = false;
void buildRedeemQrDataUrl(token).then((url) => { void buildRedeemQrDataUrl(payload).then((url) => {
if (!cancelled) setImgSrc(url); if (!cancelled) setImgSrc(url);
}); });
return () => { return () => {
cancelled = true; cancelled = true;
}; };
}, [token, isWeapp]); }, [payload, isWeapp]);
return ( return (
<View className="redeem-qr-box"> <View className="redeem-qr-box">
+8
View File
@@ -3,6 +3,7 @@ import {
BRAND_LOGO_URL, BRAND_LOGO_URL,
BRAND_LOGO_WIDE_URL, BRAND_LOGO_WIDE_URL,
CUSTOMER_SERVICE_PHONE, CUSTOMER_SERVICE_PHONE,
CUSTOMER_SERVICE_WECOM_URL,
QUALIFICATION_DISCLOSURE_URL, QUALIFICATION_DISCLOSURE_URL,
type ClientRuntimeConfig, type ClientRuntimeConfig,
} from '@dukang/shared-types'; } from '@dukang/shared-types';
@@ -14,6 +15,8 @@ export type BrandAssets = {
brandLogoMarkUrl: string; brandLogoMarkUrl: string;
qualificationDisclosureUrl: string; qualificationDisclosureUrl: string;
customerServicePhone: string; customerServicePhone: string;
customerServiceWecomUrl: string;
wecomCorpId: string;
}; };
const FALLBACK: BrandAssets = { const FALLBACK: BrandAssets = {
@@ -22,6 +25,8 @@ const FALLBACK: BrandAssets = {
brandLogoMarkUrl: BRAND_LOGO_MARK_URL, brandLogoMarkUrl: BRAND_LOGO_MARK_URL,
qualificationDisclosureUrl: QUALIFICATION_DISCLOSURE_URL, qualificationDisclosureUrl: QUALIFICATION_DISCLOSURE_URL,
customerServicePhone: CUSTOMER_SERVICE_PHONE, customerServicePhone: CUSTOMER_SERVICE_PHONE,
customerServiceWecomUrl: CUSTOMER_SERVICE_WECOM_URL,
wecomCorpId: '',
}; };
let cached: BrandAssets | null = null; let cached: BrandAssets | null = null;
@@ -35,6 +40,9 @@ function fromConfig(config: ClientRuntimeConfig | null | undefined): BrandAssets
qualificationDisclosureUrl: qualificationDisclosureUrl:
config?.qualificationDisclosureUrl?.trim() || FALLBACK.qualificationDisclosureUrl, config?.qualificationDisclosureUrl?.trim() || FALLBACK.qualificationDisclosureUrl,
customerServicePhone: config?.customerServicePhone?.trim() || FALLBACK.customerServicePhone, customerServicePhone: config?.customerServicePhone?.trim() || FALLBACK.customerServicePhone,
customerServiceWecomUrl:
config?.customerServiceWecomUrl?.trim() || FALLBACK.customerServiceWecomUrl,
wecomCorpId: config?.wecomCorpId?.trim() || FALLBACK.wecomCorpId,
}; };
} }
+1 -1
View File
@@ -2,7 +2,7 @@ import Taro from '@tarojs/taro';
import { fetchClientConfig } from './pay-wechat'; import { fetchClientConfig } from './pay-wechat';
/** 与 package.json version 同步,供服务端 minClientVersion 比对 */ /** 与 package.json version 同步,供服务端 minClientVersion 比对 */
export const APP_VERSION = '3.5.4'; export const APP_VERSION = '3.5.10';
export const APP_VERSION_LABEL = `v${APP_VERSION}`; export const APP_VERSION_LABEL = `v${APP_VERSION}`;
+57
View File
@@ -0,0 +1,57 @@
import type { LocalDeliveryDto } from '@dukang/shared-types';
import { DEFAULT_LOCAL_DELIVERY_HINT } from '@dukang/shared-types';
import { request } from './api';
export { DEFAULT_LOCAL_DELIVERY_HINT };
const CACHE_TTL_MS = 60_000;
let cached: LocalDeliveryDto[] | null = null;
let cachedAt = 0;
let inflight: Promise<LocalDeliveryDto[]> | null = null;
function cityAliases(name: string): string[] {
const raw = name.trim();
if (!raw) return [];
const noSuffix = raw.replace(/市$/, '');
const withSuffix = raw.endsWith('市') ? raw : `${raw}`;
return [raw, noSuffix, withSuffix];
}
export async function loadLocalDeliveries(force = false): Promise<LocalDeliveryDto[]> {
if (!force && cached && Date.now() - cachedAt < CACHE_TTL_MS) return cached;
if (!force && inflight) return inflight;
inflight = request<LocalDeliveryDto[]>('/catalog/local-deliveries')
.then((list) => {
cached = Array.isArray(list) ? list : [];
cachedAt = Date.now();
return cached;
})
.catch(() => {
cached = cached ?? [];
return cached;
})
.finally(() => {
inflight = null;
});
return inflight;
}
export function matchLocalDelivery(
list: LocalDeliveryDto[],
opts: { cityCode?: string | null; cityName?: string | null },
): LocalDeliveryDto | null {
const code = String(opts.cityCode || '').trim();
if (code) {
const byCode = list.find((row) => row.city.code === code);
if (byCode) return byCode;
}
const names = new Set(cityAliases(String(opts.cityName || '')));
if (!names.size) return null;
return list.find((row) => cityAliases(row.city.name).some((n) => names.has(n))) ?? null;
}
export function resolveLocalDeliveryHintHtml(row: LocalDeliveryDto | null): string {
const html = row?.hintHtml?.trim();
if (html) return html;
return DEFAULT_LOCAL_DELIVERY_HINT;
}
@@ -1,3 +1,8 @@
import { DEFAULT_LOCAL_DELIVERY_HINT } from '@dukang/shared-types';
/** @deprecated 使用 DEFAULT_LOCAL_DELIVERY_HINT;空配置回退 */
export const LOCAL_DELIVERY_ETA_HINT = DEFAULT_LOCAL_DELIVERY_HINT;
/** 商品履约能力(与 HQ / 交易硬闸一致) */ /** 商品履约能力(与 HQ / 交易硬闸一致) */
export type FulfillmentFlags = { export type FulfillmentFlags = {
+6 -6
View File
@@ -8,13 +8,13 @@ const QR_OPTIONS = {
color: { dark: '#1f1a17', light: '#ffffff' }, color: { dark: '#1f1a17', light: '#ffffff' },
} as const; } as const;
/** 在 2d Canvas 上绘制二维码(小程序 / H5 通用) */ /** 在 2d Canvas 上绘制二维码(小程序 / H5 通用payload 为落地 URL 或纯 token */
export function drawRedeemQrOnCanvas( export function drawRedeemQrOnCanvas(
ctx: CanvasRenderingContext2D, ctx: CanvasRenderingContext2D,
token: string, payload: string,
sizePx = QR_SIZE, sizePx = QR_SIZE,
) { ) {
const qr = QRCode.create(token, { errorCorrectionLevel: 'M' }); const qr = QRCode.create(payload, { errorCorrectionLevel: 'M' });
const count = qr.modules.size; const count = qr.modules.size;
const cell = sizePx / count; const cell = sizePx / count;
@@ -31,11 +31,11 @@ export function drawRedeemQrOnCanvas(
} }
/** H5Data URL;失败时回退到与 h5-user 相同的外部 QR 服务 */ /** H5Data URL;失败时回退到与 h5-user 相同的外部 QR 服务 */
export async function buildRedeemQrDataUrl(token: string): Promise<string> { export async function buildRedeemQrDataUrl(payload: string): Promise<string> {
try { try {
return await QRCode.toDataURL(token, QR_OPTIONS); return await QRCode.toDataURL(payload, QR_OPTIONS);
} catch { } catch {
return `https://api.qrserver.com/v1/create-qr-code/?size=${QR_SIZE * 2}x${QR_SIZE * 2}&data=${encodeURIComponent(token)}`; return `https://api.qrserver.com/v1/create-qr-code/?size=${QR_SIZE * 2}x${QR_SIZE * 2}&data=${encodeURIComponent(payload)}`;
} }
} }
+118
View File
@@ -0,0 +1,118 @@
export type WecomCsSessionContext = {
orderId?: string;
orderNo?: string;
from?: string;
};
type OpenCsChatOption = {
extInfo: { url: string };
corpId: string;
showMessageCard?: boolean;
sendMessageTitle?: string;
sendMessagePath?: string;
};
type WxCsFail = { errMsg?: string; errCode?: number };
type WxCsChat = {
openCustomerServiceChat?: (
option: OpenCsChatOption & {
success?: () => void;
fail?: (err: WxCsFail) => void;
},
) => void;
};
/**
* wx.openCustomerServiceChat
* Promise Taro wx
*/
function getWxOpenCsChat(): WxCsChat['openCustomerServiceChat'] | null {
if (process.env.TARO_ENV !== 'weapp') return null;
const candidates: Array<WxCsChat | null | undefined> = [];
try {
// eslint-disable-next-line no-undef
if (typeof wx !== 'undefined') candidates.push(wx as WxCsChat);
} catch {
/* ignore */
}
candidates.push((globalThis as typeof globalThis & { wx?: WxCsChat }).wx);
try {
const fromRuntime = new Function(
'return typeof wx !== "undefined" ? wx : null',
)() as WxCsChat | null;
candidates.push(fromRuntime);
} catch {
/* ignore */
}
for (const api of candidates) {
if (api && typeof api.openCustomerServiceChat === 'function') {
return api.openCustomerServiceChat.bind(api);
}
}
return null;
}
function rawCsError(err: unknown): string {
if (err instanceof Error) return err.message;
if (typeof err === 'string') return err;
if (err && typeof err === 'object' && 'errMsg' in err) {
return String((err as WxCsFail).errMsg || '');
}
return '';
}
/** 把微信 fail 转成可读提示;用户取消返回空串,调用方不 toast */
export function formatOpenCsError(err: unknown): string {
const raw = rawCsError(err);
if (/cancel/i.test(raw)) return '';
if (/not bind|not bound/i.test(raw)) {
return '企业ID未绑定当前小程序。请到微信公众平台「功能 → 客服 → 微信客服」填写同一企业ID';
}
if (!raw || /openCustomerServiceChat:fail$/i.test(raw.trim())) {
return '无法打开微信客服。开发者工具模拟器通常不可用,请用真机预览';
}
return raw;
}
/** 小程序调起企业微信「微信客服」会话 */
export async function openWecomCustomerServiceChat(params: {
url: string;
corpId: string;
session?: WecomCsSessionContext;
}): Promise<void> {
const url = params.url.trim();
const corpId = params.corpId.trim();
if (!url || !corpId) {
throw new Error('企微客服未配置');
}
const wxApi = getWxOpenCsChat();
if (!wxApi) {
throw new Error('当前微信版本不支持企业微信客服');
}
const option: OpenCsChatOption = {
extInfo: { url },
corpId,
};
if (params.session?.orderNo || params.session?.orderId) {
option.showMessageCard = true;
option.sendMessageTitle = params.session.orderNo
? `订单 ${params.session.orderNo}`
: '订单咨询';
if (params.session.orderId) {
option.sendMessagePath = `pages/order-detail/index?id=${params.session.orderId}`;
}
}
await new Promise<void>((resolve, reject) => {
wxApi({
...option,
success: () => resolve(),
fail: (err) => reject(err),
});
});
}
@@ -16,35 +16,43 @@ function dialPhone(phone: string) {
} }
export default function CustomerServicePage() { export default function CustomerServicePage() {
const [phone, setPhone] = useState(() => getBrandAssetsSync().customerServicePhone); const [brand, setBrand] = useState(() => getBrandAssetsSync());
useEffect(() => { useEffect(() => {
void loadBrandAssets().then((b) => setPhone(b.customerServicePhone)); void loadBrandAssets().then(setBrand);
}, []); }, []);
const phone = brand.customerServicePhone;
const wecomReady = !!brand.customerServiceWecomUrl.trim() && !!brand.wecomCorpId.trim();
const wecomUrlReady = !!brand.customerServiceWecomUrl.trim();
const hint = isWeapp
? wecomReady
? '点击下方按钮,进入企业微信客服会话'
: '点击下方按钮,进入在线客服会话'
: wecomUrlReady
? '点击下方按钮进入企业微信客服,或拨打客服电话'
: '请在微信小程序内打开以使用在线客服,或拨打客服电话';
return ( return (
<PageShell variant="sub" className="cs-page"> <PageShell variant="sub" className="cs-page">
<SubPageHeader title="联系客服" /> <SubPageHeader title="联系客服" />
<View className="sub-page-body inset-page cs-body"> <View className="sub-page-body inset-page cs-body">
<Text className="cs-brand"></Text> <Text className="cs-brand"></Text>
<Text className="cs-hint"> <Text className="cs-hint">{hint}</Text>
{isWeapp
? '点击下方按钮,进入小程序在线客服会话'
: '请在微信小程序内打开以使用在线客服,或拨打客服电话'}
</Text>
<Text className="cs-hours">9:00 - 21:00</Text> <Text className="cs-hours">9:00 - 21:00</Text>
{isWeapp ? ( {isWeapp || wecomUrlReady ? (
<ContactCsButton className="cs-online-btn" session={{ from: 'customer-service' }} /> <ContactCsButton className="cs-online-btn" session={{ from: 'customer-service' }} />
) : null} ) : null}
<View className={isWeapp ? 'cs-phone-link' : 'cs-call-btn'} onClick={() => dialPhone(phone)}> <View className={isWeapp || wecomUrlReady ? 'cs-phone-link' : 'cs-call-btn'} onClick={() => dialPhone(phone)}>
<Text> <Text>
{isWeapp ? `或拨打客服电话 ${phone}` : '拨打客服电话'} {isWeapp || wecomUrlReady ? `或拨打客服电话 ${phone}` : '拨打客服电话'}
</Text> </Text>
</View> </View>
{!isWeapp ? ( {!isWeapp && !wecomUrlReady ? (
<Text className="cs-phone-display">{phone}</Text> <Text className="cs-phone-display">{phone}</Text>
) : null} ) : null}
</View> </View>
+1 -1
View File
@@ -185,7 +185,7 @@ export default function HomePage() {
} }
async function goOnSitePickup(productId: string) { async function goOnSitePickup(productId: string) {
const returnPath = `/pages/order-confirm-pickup/index?productId=${productId}&qty=1`; const returnPath = `/pages/order-confirm-pickup/index?productId=${productId}&qty=2`;
if (!isLoggedIn()) { if (!isLoggedIn()) {
goLogin(returnPath); goLogin(returnPath);
return; return;
@@ -56,6 +56,11 @@ export default function OrderConfirmPickupPage() {
}) })
.then((data) => { .then((data) => {
if (!cancelled) { if (!cancelled) {
const floor = data.minQty ?? 2;
if (quantity < floor) {
setQuantity(floor);
return;
}
setPreview(data); setPreview(data);
setMsg(data.quantityOk === false ? data.quantityMessage || '' : ''); setMsg(data.quantityOk === false ? data.quantityMessage || '' : '');
} }
@@ -109,7 +114,7 @@ export default function OrderConfirmPickupPage() {
async function submit() { async function submit() {
if (!canSubmit) { if (!canSubmit) {
if (!quantityOk) { if (!quantityOk) {
const tip = `现场提货至少购买 ${minQty}`; const tip = `现场提货至少购买 ${minQty}${unitLabel}`;
setMsg(tip); setMsg(tip);
toast(tip); toast(tip);
return; return;
@@ -170,7 +175,7 @@ export default function OrderConfirmPickupPage() {
const submitLabel = loading const submitLabel = loading
? '提交中…' ? '提交中…'
: !quantityOk : !quantityOk
? `至少购买 ${minQty}` ? `至少购买 ${minQty}${unitLabel}`
: '提交订单'; : '提交订单';
return ( return (
@@ -223,7 +228,7 @@ export default function OrderConfirmPickupPage() {
</View> </View>
{!quantityOk ? ( {!quantityOk ? (
<Text className="order-qty-hint"> <Text className="order-qty-hint">
{`现场提货至少购买 ${minQty},请调整数量`} {`现场提货至少购买 ${minQty}${unitLabel},请调整数量`}
</Text> </Text>
) : null} ) : null}
</View> </View>
@@ -11,7 +11,9 @@ import { maskPhone } from '../../lib/phone';
import { ensurePayReady } from '../../lib/pay-ready'; import { ensurePayReady } from '../../lib/pay-ready';
import { fetchUserProfile } from '../../lib/pay-wechat'; import { fetchUserProfile } from '../../lib/pay-wechat';
import { request, toast } from '../../lib/api'; import { request, toast } from '../../lib/api';
import DeliveryHintHtml from '../../components/DeliveryHintHtml';
import { canCrossCity, isCrossCityAddress } from '../../lib/product-fulfillment'; import { canCrossCity, isCrossCityAddress } from '../../lib/product-fulfillment';
import { loadLocalDeliveries, matchLocalDelivery, resolveLocalDeliveryHintHtml } from '../../lib/local-delivery';
import { getProductMainImage } from '../../lib/product-images'; import { getProductMainImage } from '../../lib/product-images';
import BenefitFigure from '../../components/BenefitFigure'; import BenefitFigure from '../../components/BenefitFigure';
@@ -75,6 +77,7 @@ export default function OrderConfirmPage() {
const [addresses, setAddresses] = useState<Address[]>([]); const [addresses, setAddresses] = useState<Address[]>([]);
const [addressId, setAddressId] = useState(checkoutCtx.addressId || ''); const [addressId, setAddressId] = useState(checkoutCtx.addressId || '');
const [preview, setPreview] = useState<OrderPreview | null>(null); const [preview, setPreview] = useState<OrderPreview | null>(null);
const [localHintHtml, setLocalHintHtml] = useState('');
const [previewLoading, setPreviewLoading] = useState(false); const [previewLoading, setPreviewLoading] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [msg, setMsg] = useState(''); const [msg, setMsg] = useState('');
@@ -151,6 +154,18 @@ export default function OrderConfirmPage() {
[addresses, addressId], [addresses, addressId],
); );
useEffect(() => {
const cityName = selectedAddress?.city;
if (!cityName) {
setLocalHintHtml('');
return;
}
void loadLocalDeliveries().then((list) => {
const row = matchLocalDelivery(list, { cityName });
setLocalHintHtml(row ? resolveLocalDeliveryHintHtml(row) : '');
});
}, [selectedAddress?.city]);
const allowCross = const allowCross =
preview?.allowCrossCityDelivery !== undefined preview?.allowCrossCityDelivery !== undefined
? canCrossCity({ allowCrossCityDelivery: preview.allowCrossCityDelivery }) ? canCrossCity({ allowCrossCityDelivery: preview.allowCrossCityDelivery })
@@ -289,7 +304,7 @@ export default function OrderConfirmPage() {
: !addressOk : !addressOk
? '请更换地址' ? '请更换地址'
: !quantityOk : !quantityOk
? `至少购买 ${minQty}` ? `至少购买 ${minQty}${unitLabel}`
: '提交订单'; : '提交订单';
const displayMsg = msg || addressHint; const displayMsg = msg || addressHint;
@@ -334,11 +349,17 @@ export default function OrderConfirmPage() {
<View className="order-card"> <View className="order-card">
<Text className="u-muted"> <Text className="u-muted">
{quantity < minQty ? `;跨城至少购买 ${minQty} 瓶(1箱)` : ''} {quantity < minQty ? `;跨城至少购买 ${minQty}${unitLabel}` : ''}
</Text> </Text>
</View> </View>
) : null} ) : null}
{!isCross && addressOk && addressId && localHintHtml ? (
<View className="order-card">
<DeliveryHintHtml className="u-muted" html={localHintHtml} />
</View>
) : null}
{preview ? ( {preview ? (
<> <>
<View className="order-card"> <View className="order-card">
@@ -10,6 +10,8 @@ import ContactCsButton from '../../components/ContactCsButton';
import LogisticsRichText from '../../components/LogisticsRichText'; import LogisticsRichText from '../../components/LogisticsRichText';
import { request, toast } from '../../lib/api'; import { request, toast } from '../../lib/api';
import { buildPayUrl } from '../../lib/checkout-nav'; import { buildPayUrl } from '../../lib/checkout-nav';
import DeliveryHintHtml from '../../components/DeliveryHintHtml';
import { loadLocalDeliveries, matchLocalDelivery, resolveLocalDeliveryHintHtml } from '../../lib/local-delivery';
import { import {
formatEstimatedArrival, formatEstimatedArrival,
isLogisticsNotArrived, isLogisticsNotArrived,
@@ -83,6 +85,22 @@ const STATUS_LABELS: Record<string, string> = {
REFUNDED: '已退款', REFUNDED: '已退款',
}; };
function applyLocalDeliveryHint(
data: OrderDetail,
setLocalHintHtml: (html: string) => void,
) {
if (data.deliveryType !== 'LOCAL') {
setLocalHintHtml('');
return;
}
void loadLocalDeliveries().then((list) => {
const row = data.receiverCity
? matchLocalDelivery(list, { cityName: data.receiverCity })
: null;
setLocalHintHtml(resolveLocalDeliveryHintHtml(row));
});
}
function fullReceiverAddress(order: OrderDetail) { function fullReceiverAddress(order: OrderDetail) {
const detail = (order.receiverAddress || '').trim(); const detail = (order.receiverAddress || '').trim();
const region = [order.receiverProvince, order.receiverCity, order.receiverDistrict] const region = [order.receiverProvince, order.receiverCity, order.receiverDistrict]
@@ -102,6 +120,7 @@ export default function OrderDetailPage() {
const [latestTrack, setLatestTrack] = useState<OrderTrackNode | null>(null); const [latestTrack, setLatestTrack] = useState<OrderTrackNode | null>(null);
const [estimatedArrival, setEstimatedArrival] = useState<OrderTrackEstimatedArrival | null>(null); const [estimatedArrival, setEstimatedArrival] = useState<OrderTrackEstimatedArrival | null>(null);
const [trackLoading, setTrackLoading] = useState(false); const [trackLoading, setTrackLoading] = useState(false);
const [localHintHtml, setLocalHintHtml] = useState('');
async function loadOrderTrack(delivery: OrderDetail['delivery'], orderStatus?: string) { async function loadOrderTrack(delivery: OrderDetail['delivery'], orderStatus?: string) {
if (!orderId || !shouldLoadOrderTrack(delivery)) { if (!orderId || !shouldLoadOrderTrack(delivery)) {
@@ -133,6 +152,7 @@ export default function OrderDetailPage() {
.then((data) => { .then((data) => {
setOrder(data); setOrder(data);
void loadOrderTrack(data.delivery, data.status); void loadOrderTrack(data.delivery, data.status);
applyLocalDeliveryHint(data, setLocalHintHtml);
}) })
.catch((e) => toast(e instanceof Error ? e.message : '加载失败')); .catch((e) => toast(e instanceof Error ? e.message : '加载失败'));
}, [orderId]); }, [orderId]);
@@ -144,6 +164,7 @@ export default function OrderDetailPage() {
.then((data) => { .then((data) => {
setOrder(data); setOrder(data);
void loadOrderTrack(data.delivery, data.status); void loadOrderTrack(data.delivery, data.status);
applyLocalDeliveryHint(data, setLocalHintHtml);
}) })
.catch(() => {}); .catch(() => {});
}); });
@@ -361,6 +382,12 @@ export default function OrderDetailPage() {
{order.createdAt ? String(order.createdAt).slice(0, 19).replace('T', ' ') : '-'} {order.createdAt ? String(order.createdAt).slice(0, 19).replace('T', ' ') : '-'}
</Text> </Text>
</View> </View>
{order.deliveryType === 'LOCAL' && localHintHtml ? (
<View className="order-row">
<Text className="order-row-label"></Text>
<DeliveryHintHtml className="order-row-value" html={localHintHtml} />
</View>
) : null}
</View> </View>
</> </>
)} )}
@@ -140,7 +140,8 @@ export default function ProductDetailPage() {
const attrs = product?.specAttrs ?? []; const attrs = product?.specAttrs ?? [];
const skus = product?.skus ?? []; const skus = product?.skus ?? [];
const specEnabled = !!(product?.specEnabled && attrs.length > 0); const onSaleSkuCount = skus.filter((s) => s.status === 'ON_SALE').length;
const specEnabled = onSaleSkuCount > 1 && attrs.length > 0;
const activeSku = useMemo(() => { const activeSku = useMemo(() => {
if (!product) return undefined; if (!product) return undefined;
if (!specEnabled) { if (!specEnabled) {
@@ -231,7 +232,7 @@ export default function ProductDetailPage() {
if (!productId) return; if (!productId) return;
const skuId = ensureSkuSelected(); const skuId = ensureSkuSelected();
if (specEnabled && !skuId) return; if (specEnabled && !skuId) return;
const qty = activeSku?.saleUnit === 'BOX' ? 1 : 1; const qty = activeSku?.saleUnit === 'BOX' ? 1 : 2;
const qs = [`productId=${productId}`, `qty=${qty}`]; const qs = [`productId=${productId}`, `qty=${qty}`];
if (skuId) qs.push(`skuId=${skuId}`); if (skuId) qs.push(`skuId=${skuId}`);
const returnPath = `/pages/order-confirm-pickup/index?${qs.join('&')}`; const returnPath = `/pages/order-confirm-pickup/index?${qs.join('&')}`;
@@ -39,6 +39,10 @@ export default function RedeemCodePage() {
const router = useRouter(); const router = useRouter();
const token = decodeURIComponent(router.params.token ?? ''); const token = decodeURIComponent(router.params.token ?? '');
const amount = Number(router.params.amount ?? 0); const amount = Number(router.params.amount ?? 0);
const landingUrl = router.params.landingUrl
? decodeURIComponent(router.params.landingUrl)
: '';
const qrPayload = landingUrl || token;
const [timerSec, setTimerSec] = useState(REDEEM_TOKEN_TTL_SECONDS); const [timerSec, setTimerSec] = useState(REDEEM_TOKEN_TTL_SECONDS);
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null); const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
@@ -148,7 +152,7 @@ export default function RedeemCodePage() {
<View className="redeem-code-panel"> <View className="redeem-code-panel">
<Text className="redeem-code-head"></Text> <Text className="redeem-code-head"></Text>
<View className="redeem-qr-wrap"> <View className="redeem-qr-wrap">
<RedeemQrCode token={token} /> <RedeemQrCode payload={qrPayload} />
</View> </View>
<View className={`redeem-timer${timerSec > 0 && timerSec < REDEEM_TOKEN_TTL_SECONDS ? ' redeem-timer--active' : ''}`}> <View className={`redeem-timer${timerSec > 0 && timerSec < REDEEM_TOKEN_TTL_SECONDS ? ' redeem-timer--active' : ''}`}>
<Text className="redeem-timer-value">{formatTimer(timerSec)}</Text> <Text className="redeem-timer-value">{formatTimer(timerSec)}</Text>
+5 -2
View File
@@ -113,12 +113,15 @@ export default function RedeemPage() {
const body: { amount: number; couponId?: string } = { amount: value }; const body: { amount: number; couponId?: string } = { amount: value };
if (couponId) body.couponId = couponId; if (couponId) body.couponId = couponId;
const data = await request<{ token: string; amount: number }>('/redeem/tokens', { const data = await request<{ token: string; amount: number; landingUrl?: string }>('/redeem/tokens', {
method: 'POST', method: 'POST',
data: body, data: body,
}); });
const landingQs = data.landingUrl
? `&landingUrl=${encodeURIComponent(data.landingUrl)}`
: '';
Taro.navigateTo({ Taro.navigateTo({
url: `/pages/redeem-code/index?token=${encodeURIComponent(data.token)}&amount=${data.amount}`, url: `/pages/redeem-code/index?token=${encodeURIComponent(data.token)}&amount=${data.amount}${landingQs}`,
}); });
} catch (e) { } catch (e) {
toast(e instanceof Error ? e.message : '生成失败'); toast(e instanceof Error ? e.message : '生成失败');
@@ -12,7 +12,6 @@ import Taro, {
import PageShell from '../../components/PageShell'; import PageShell from '../../components/PageShell';
import PageNavBar from '../../components/PageNavBar'; import PageNavBar from '../../components/PageNavBar';
import ProductCarousel from '../../components/ProductCarousel'; import ProductCarousel from '../../components/ProductCarousel';
import ShareNavButton from '../../components/ShareNavButton';
import StoreRedeemMarquee from '../../components/StoreRedeemMarquee'; import StoreRedeemMarquee from '../../components/StoreRedeemMarquee';
import WechatShareReady from '../../components/WechatShareReady'; import WechatShareReady from '../../components/WechatShareReady';
import { request, toast } from '../../lib/api'; import { request, toast } from '../../lib/api';
@@ -356,7 +355,6 @@ export default function StoreDetailPage() {
solid={headerSolid} solid={headerSolid}
titleVisible={headerSolid} titleVisible={headerSolid}
onBack={goBack} onBack={goBack}
right={<ShareNavButton payload={sharePayload} />}
/> />
<View className="store-detail-hero full-bleed"> <View className="store-detail-hero full-bleed">
@@ -407,13 +405,11 @@ export default function StoreDetailPage() {
</View> </View>
) : null} ) : null}
<View className="store-detail-tags">
{store.category?.name ? ( {store.category?.name ? (
<View className="store-detail-tags">
<Text className="store-detail-tag">{store.category.name}</Text> <Text className="store-detail-tag">{store.category.name}</Text>
) : null}
<Text className="store-detail-tag"></Text>
<Text className="store-detail-tag"></Text>
</View> </View>
) : null}
</View> </View>
{marqueeLines.length > 0 ? ( {marqueeLines.length > 0 ? (
+5 -1
View File
@@ -29,6 +29,8 @@
| 3.5.7 | 08-23 | 门店端核销记录时间显示秒;首页「今日核销金额」文案 | [`v3.5.7`](./杜康好客-v3.5.7-开发文档.md) | | 3.5.7 | 08-23 | 门店端核销记录时间显示秒;首页「今日核销金额」文案 | [`v3.5.7`](./杜康好客-v3.5.7-开发文档.md) |
| 3.5.8 | 08-24 | HQ 单账号追加/撤销权限;运营改客服修复;城市门店服务+城市范围 | [`v3.5.8`](./杜康好客-v3.5.8-开发文档.md) | | 3.5.8 | 08-24 | HQ 单账号追加/撤销权限;运营改客服修复;城市门店服务+城市范围 | [`v3.5.8`](./杜康好客-v3.5.8-开发文档.md) |
| 3.5.9 | 08-25 | 门店累计核销好客权益;HQ 表格去省略号;序号列 + 列设置 + 拖表头改列宽;用户备注 / 手机号不脱敏 | [`v3.5.9`](./杜康好客-v3.5.9-开发文档.md) | | 3.5.9 | 08-25 | 门店累计核销好客权益;HQ 表格去省略号;序号列 + 列设置 + 拖表头改列宽;用户备注 / 手机号不脱敏 | [`v3.5.9`](./杜康好客-v3.5.9-开发文档.md) |
| 3.5.10 | 08-25 | C 端门店详情去掉分享按钮;同城送提示改承运商 HTML;小程序客服接通企微微信客服 | [`v3.5.10`](./杜康好客-v3.5.10-开发文档.md) |
| 3.5.11 | 08-26 | 城市三种履约起购;企微通知补提交人/规格物流/核销用户;结算任务失败通知 + 提现通过/四账单 | [`v3.5.11`](./杜康好客-v3.5.11-开发文档.md) |
--- ---
@@ -82,9 +84,11 @@
`待付款 → 已付款 → 已完成`;30min 未付取消。同城自动推小飞侠(有仓+API);**≥10箱(60瓶)** 大单待 HQ 确认。跨城总部物流到付。现场提货支付即完成。 `待付款 → 已付款 → 已完成`;30min 未付取消。同城自动推小飞侠(有仓+API);**≥10箱(60瓶)** 大单待 HQ 确认。跨城总部物流到付。现场提货支付即完成。
**履约起购**(城市 `common_city` 配置,按**瓶当量**;箱装 `quantity × bottlesPerUnit`):现场提货默认 **≥2 瓶**;同城配送默认 **≥2 瓶**;跨城配送默认 **≥6 瓶(1 箱)**。起购属销售策略,不放承运商。承运商「起送瓶数」只用于物流计价/对账,不拦下单。
**HQ 订单导出**`admin-web` 订单监控): **HQ 订单导出**`admin-web` 订单监控):
- 支持按筛选(下单日期、状态、类型、城市、配送、收货手机等)或勾选订单导出 - 支持按筛选(下单日期、状态可多选、类型、城市、配送、收货手机等)或勾选订单导出
- 格式:Excel`.xlsx`/ PDF`.pdf` - 格式:Excel`.xlsx`/ PDF`.pdf`
- 单次上限 5000 条;按筛选且未指定日期时默认近 30 天 - 单次上限 5000 条;按筛选且未指定日期时默认近 30 天
- 权限:`orders`;操作审计 `ORDER_EXPORT` - 权限:`orders`;操作审计 `ORDER_EXPORT`
+5 -1
View File
@@ -64,10 +64,14 @@
| 3.5.7 | [`门店核销记录时间秒 + 今日核销金额文案`](./杜康好客-v3.5.7-开发文档.md) | 🔶 开发完成 | | 3.5.7 | [`门店核销记录时间秒 + 今日核销金额文案`](./杜康好客-v3.5.7-开发文档.md) | 🔶 开发完成 |
| 3.5.8 | [`HQ 追加/撤销权限 + 运营改客服 + 城市门店服务`](./杜康好客-v3.5.8-开发文档.md) | 🔶 开发完成 | | 3.5.8 | [`HQ 追加/撤销权限 + 运营改客服 + 城市门店服务`](./杜康好客-v3.5.8-开发文档.md) | 🔶 开发完成 |
| 3.5.9 | [`门店累计核销 + HQ 去截断 + 列设置`](./杜康好客-v3.5.9-开发文档.md) | 🔶 开发完成 | | 3.5.9 | [`门店累计核销 + HQ 去截断 + 列设置`](./杜康好客-v3.5.9-开发文档.md) | 🔶 开发完成 |
| 3.5.10 | [`门店详情去分享按钮 + 同城提示改承运商 HTML + 小程序客服接企微`](./杜康好客-v3.5.10-开发文档.md) | 🔶 开发完成 |
| 3.5.11 | [`城市履约起购 + 企微通知字段与结算通知`](./杜康好客-v3.5.11-开发文档.md) | 🔶 开发完成 |
| 日期 | 说明 | | 日期 | 说明 |
|------|------| |------|------|
| 2026-08-25 | v3.5.9:门店列表累计核销好客权益;HQ 表格去省略号;主列表序号 + 列设置/列宽存 HQ 账号;用户列表备注(不改昵称)、手机号不脱敏 | | 2026-08-26 | v3.5.11:城市三种履约起购;企微补提交人/订单规格物流收货/核销用户;`alert.settlement` 改名「结算任务失败通知」归入系统监控;补提现通过与四账单 |
| 2026-08-25 | v3.5.10:门店详情去掉分享按钮;同城送提示改承运商 HTML(`GET /catalog/local-deliveries`);小程序客服接通企微(需填 CorpID) |
| 2026-08-25 | v3.5.9:门店列表累计核销好客权益;HQ 表格去省略号;主列表序号 + 列设置/列宽存 HQ 账号;用户列表备注(不改昵称)、手机号不脱敏;订单列表状态可多选 |
| 2026-08-24 | v3.5.8HQ 单账号追加/撤销权限;运营改客服;城市门店服务与城市范围;分类删除权限与概览按权限/城市裁剪 | | 2026-08-24 | v3.5.8HQ 单账号追加/撤销权限;运营改客服;城市门店服务与城市范围;分类删除权限与概览按权限/城市裁剪 |
| 2026-08-23 | v3.5.7:门店核销记录时间显示秒;首页「今日到账金额」→「今日核销金额」 | | 2026-08-23 | v3.5.7:门店核销记录时间显示秒;首页「今日到账金额」→「今日核销金额」 |
| 2026-08-23 | v3.5.6:开发计划任务导出;核销/财务银行信息与打款凭证;工单图片入任务;运营去调试;门店审核全屏 | | 2026-08-23 | v3.5.6:开发计划任务导出;核销/财务银行信息与打款凭证;工单图片入任务;运营去调试;门店审核全屏 |
+121
View File
@@ -0,0 +1,121 @@
# 杜康好客 · v3.5.10 开发文档
> **2026-08-25** · mini-user / API
> **主题**:门店详情去掉分享按钮;同城配送提示 24 小时内送到;小程序客服接通企业微信
---
## 1. 版本目标
| # | 任务 | 类型 | 交付 |
|---|------|------|------|
| 1 | DPT-20260824-896 | BUG | C 端门店详情去掉顶栏「分享」按钮 |
| 2 | DPT-20260824-601 | 优化 | 同城送提示改承运商「配送信息提示」(HTML);C 端 `GET /catalog/local-deliveries` |
| 3 | DPT-20260822-651 | 需求 | 小程序在线客服调起企业微信「微信客服」 |
**不做**:改配送规则 / 改 SLA 计算;合伙人/门店端客服;禁用微信右上角「···」分享菜单。
---
## 2. 门店详情去掉分享按钮
`pages/store-detail` 顶栏不再渲染 `ShareNavButton`
右上角微信原生菜单仍可分享(`enableShareAppMessage` / `WechatShareReady` 保留)。只要去掉页面上的分享按钮。
---
## 3. 同城送提示(承运商 HTML)
不再写死文案。以用户**收货地址城市**为准:该市 `common_city.status=ACTIVE`(已开城)→ 同城,展示对应仓配承运商的「配送信息提示」;未开城 → 跨城,只展示「总部物流、运费到付」。
```
收货市 → 开城仓库(ACTIVE,优先 API_AUTO 且已绑承运商)→ 承运商.delivery_hint_html
```
空字段时 C 端回退纯文本 `同城配送,预计24小时内送到`。不改下单 / 推单 / 起购。
### 3.1 承运商字段
`common_fulfillment_provider.delivery_hint_html` TEXT NULL。允许 `span/p/br/b/strong/i/em/font`style 仅 `color` / `font-weight` / `font-size` / `font-style`。保存与下发前消毒。HQ 文本框里的回车在 C 端转成换行(不必手写 `<br/>`)。
HQ「仓配管理 → 承运商」多行输入,例如:
```html
<span style="color:#A61D24;font-weight:700;font-size:13px">同城配送,预计24小时内送到</span>
```
### 3.2 API
`GET /catalog/local-deliveries`(公开)。可选 `cityCode` / `cityName`
每项:`city` · `warehouse` · `provider` · `hintHtml`。未开城 / 无仓 / 无承运商返回空列表或 `hintHtml=null`,不报错。
### 3.3 C 端
| 页面 | 何时展示 |
|------|----------|
| 商品详情 | 可线上购;用当前选城预览 |
| 确认订单 | 收货市已开城且地址校验通过;`RichText` |
| 订单详情 | `deliveryType === LOCAL`;按收货市匹配 |
---
---
## 4. 小程序客服接通企业微信
原先 `open-type=contact` 进入**小程序原生客服**。本版在已配置企微参数时改为 `wx.openCustomerServiceChat`,进入企业微信「微信客服」(与 H5 kfid 同一套)。
### 配置(HQ → 系统设置 → 微信小程序配置)
| 键 | 说明 |
|----|------|
| `CUSTOMER_SERVICE_WECOM_URL` | 微信客服 kfid 链接;缺省用代码常量 |
| `WECOM_CORP_ID` | 企业 ID`ww` 开头)。企微「我的企业」可查 |
`GET /common/client-config` 下发 `customerServiceWecomUrl``wecomCorpId`
### 行为
| 环境 | 条件 | 行为 |
|------|------|------|
| 小程序 | 链接 + CorpID 都有 | `openCustomerServiceChat`;订单详情可带订单卡片 |
| 小程序 | 未填 CorpID | 回退 `open-type=contact` |
| H5 | 有 kfid 链接 | 打开企微客服网页 |
### 企微侧前置(运营)
1. 开通企业微信「微信客服」,拿到 kfid 链接。
2. 把 C 端小程序关联到该企业的微信客服。
3. 把 CorpID 填进系统设置。未填则用户仍走小程序原生客服。
---
## 4.1 Prisma
`common_fulfillment_provider.delivery_hint_html` TEXT NULL。脚本:[`migrate-fulfillment-delivery-hint-v3510.sql`](../server/dukang-api/prisma/migrate-fulfillment-delivery-hint-v3510.sql)。
## 5. 验收清单
- [ ] 门店详情顶栏没有分享按钮;返回/导航/拨打不受影响
- [ ] HQ 承运商可编辑「配送信息提示」HTML(颜色/粗细/字号);非法标签被去掉
- [ ] `GET /catalog/local-deliveries` 按开城列出仓库+承运商+hintHtml;`cityName` 可筛收货市
- [ ] 商品详情(可线上购)按当前选城展示承运商提示(空则回退「同城配送,预计24小时内送到」)
- [ ] 确认订单:收货市已开城显示 HTML 提示;未开城只显示「总部物流、运费到付」
- [ ] 同城订单详情「配送时效」为该市承运商提示
- [ ] 系统设置可改客服链接与 CorpID;保存后 `client-config` 立即带出
- [ ] 小程序已填 CorpID:联系客服进入企微微信客服(非小程序原生客服后台)
- [ ] 未填 CorpID:小程序仍能打开原生客服,不白屏
---
## 6. 关键路径
| 域 | 路径 |
|----|------|
| 门店详情 | `apps/mini-user/src/pages/store-detail/index.tsx` |
| 同城提示 | `fulfillment-provider.service.ts` · `GET /catalog/local-deliveries` · `DeliveryHintHtml` |
| 客服按钮 | `apps/mini-user/src/components/ContactCsButton.tsx` · `lib/wecom-cs.ts` |
| 下发 | `client-config.controller.ts` · `packages/shared-types` `config.ts` / `wechat.ts` |
| HQ 配置 | `system-config.registry.ts` |
+102
View File
@@ -0,0 +1,102 @@
# 杜康好客 · v3.5.11 开发文档
> **2026-08-26** · catalog / trade / mini-user / admin-web / API
> **主题**:三种履约起购挂城市;企微通知补字段;结算通知(提现通过 + 四账单)
---
## 1. 版本目标
| # | 任务 | 类型 | 交付 |
|---|------|------|------|
| 1 | 履约起购 | 需求 | 城市三字段:提货 / 同城 / 跨城(瓶当量) |
| 2 | 现场提货 | 体验 | 默认数量对齐起购;文案用销售单位 |
| 3 | 承运商 | 文案 | 「起送瓶数」标明不影响用户起购 |
| 4 | 企微提交人 | 优化 | 门店新建/信息变更/套餐待审显示提交人名称 |
| 5 | 成交播报 | 优化 | 支付成功补规格/物流/收货;核销成功补用户 |
| 6 | 结算通知 | 需求 | `alert.settlement` 改名为「结算任务失败通知」并归入系统监控;提现通过 + 财务四账单(含收款账户) |
**不做**:起购迁到承运商;多城按地址匹配起购(仍读当前 ACTIVE 城市);HQ 直改已营业门店不发待审通知。
---
## 2. 规则
起购属销售策略,存在 `common_city`
| 履约 | 字段 | 默认 | 口径 |
|------|------|------|------|
| 现场提货 | `pickup_min_qty` | 2 | 瓶当量 |
| 同城配送 | `local_min_qty` | 2 | 瓶当量 |
| 跨城配送 | `cross_min_qty` | 6 | 瓶当量;箱规 6 瓶/箱 = 最少 1 箱 |
箱装:`quantity × bottlesPerUnit`。承运商 `pricingRules.baseBottles` 只用于物流对账。
---
## 3. 变更面
- Domain`validateMinPurchase` 接收 `{ pickupMinQty, localMinQty, crossMinQty }`
- Tradepreview / create / 代下单读 `pickupMinQty`
- HQ 城市管理:三字段分组;承运商起送 extra
- mini-user:提货入口瓶装默认 2;确认页 `unitLabel`
- SQL[`migrate-city-pickup-min-qty-v3511.sql`](../server/dukang-api/prisma/migrate-city-pickup-min-qty-v3511.sql)
---
## 4. 企微通知字段
### 4.1 提交人
| 角色 | 文案 |
|------|------|
| 合伙人 | `{企业} · {姓名}`(企业空则只姓名) |
| HQ | `HqAccount.name` |
| 门店端 | `门店 · {StoreAccount.name}` |
覆盖:`store.audit_pending`(含 HQ 新建)、`store.info_change_pending``store.package_audit_pending`
入库模板若仍是上一版默认 body,启动时升级;HQ 手改过的不覆盖(可「恢复默认」)。
### 4.2 订单支付成功 `order.paid`
- 商品:`{名称} {规格} {瓶\|箱}×{数量}`
- 物流:现场提货 / 同城 / 跨城
- 收货:提货=姓名+手机;同城/跨城=姓名+手机+详细地址
- 测试单不推
### 4.3 核销成功 `redeem.success`
`userName``userPhone`(脱敏,与支付播报一致)。
---
## 5. 结算通知
条件 key 仍为 `alert.settlement`HQ 展示 **「结算任务失败通知」**(原「结算任务告警」),放在 **系统监控** 组。提现通过 / 四账单为独立条件,仍在「结算通知」组。
| key | 触发 | 收款账户 |
|-----|------|----------|
| `alert.settlement` | 结算任务失败通知(系统监控组):账单定时任务失败、提现超时未审 | — |
| `store.withdraw_approved` | 门店手动提现审核通过 | 门店主账号卡 |
| `finance.store_bill` | 门店日账单 `created>0` | 各店主账号卡 |
| `finance.partner_bill` | 合伙人月账单生成成功 | 合伙人卡 |
| `finance.winery_bill` | 酒厂日账单未 skip | 系统配置酒厂账户 |
| `finance.logistics_bill` | 物流月账成功且未 skip | 承运商卡 |
账单一次摘要(多店多行,最多 15 行);缺卡写「未登记收款账户」;内部群账号不脱敏。`created=0` / `skipped` 不推。
启动 upsert「结算通知群」(占位 webhook + 禁用)。已有「运营告警」若勾了 `alert.settlement`,会收到任务失败/超时,**不会**自动勾上 5 个新业务事件。
---
## 6. 验收
- [ ] 城市三字段起购;提货默认数量对齐;承运商起送不影响下单
- [ ] 合伙人新建/信息变更/套餐:企微可见「企业 · 姓名」
- [ ] HQ 新建门店:企微可见 HQ 名称
- [ ] 支付成功:规格单位、物流方式、收货信息按提货/配送分支正确
- [ ] 核销成功:有用户昵称与脱敏手机
- [ ] HQ 推送条件展示「结算任务失败通知」,在系统监控组
- [ ] 账单任务失败 / 提现超时出现在勾了「结算任务失败通知」的群
- [ ] 提现通过、四类账单生成含收款账户;无账单不刷屏
+7
View File
@@ -120,6 +120,7 @@
- [ ] 用户列表昵称只读;双击「备注」可改,离开编辑后 `user_user.hq_remark` 已更新;C 端看不到该字段 - [ ] 用户列表昵称只读;双击「备注」可改,离开编辑后 `user_user.hq_remark` 已更新;C 端看不到该字段
- [ ] 用户列表手机号完整可见(详情仍脱敏) - [ ] 用户列表手机号完整可见(详情仍脱敏)
- [ ] 权益券列表:用户编号、订单号可点进对应用户/订单详情;来源含商品名、规格、数量、配送方式、实付金额 - [ ] 权益券列表:用户编号、订单号可点进对应用户/订单详情;来源含商品名、规格、数量、配送方式、实付金额
- [ ] 订单列表「状态」可多选;导出按所选状态过滤;不选即全部
--- ---
@@ -128,3 +129,9 @@
- **用户**、**订单**列(及券详情)用主列下划线,分别打开用户详情抽屉、订单详情抽屉。 - **用户**、**订单**列(及券详情)用主列下划线,分别打开用户详情抽屉、订单详情抽屉。
- **来源**:关联订单时拼 `商品名 / 规格 / 数量(瓶或箱) / 配送方式 / ¥实付`;无订单仍用 `sourceProduct`(如总部手动发放)。 - **来源**:关联订单时拼 `商品名 / 规格 / 数量(瓶或箱) / 配送方式 / ¥实付`;无订单仍用 `sourceProduct`(如总部手动发放)。
- 列表接口 `order` 增补 `productName``productSpec``quantity``saleUnit``deliveryType``payAmount` - 列表接口 `order` 增补 `productName``productSpec``quantity``saleUnit``deliveryType``payAmount`
---
## 11. 订单列表状态多选
`GET /admin/orders``POST /admin/orders/export``status` 支持多值(重复 query、逗号串、JSON 数组均可)。列表筛选为多选;空 = 全部。单值旧链接仍可用。
+5 -1
View File
@@ -36,7 +36,7 @@ C 端购酒核销 · 门店扫码核销+打款 · 合伙人拓店履约 · WebAd
| 链路 | 关键节点 | | 链路 | 关键节点 |
|------|----------| |------|----------|
| C 购酒 | 登录→开城商品→起购(同城2/跨城6)→支付→权益1:1→出码/核销→评价 | | C 购酒 | 登录→开城商品→起购(提货2/同城2/跨城6=1箱,城市配置)→支付→权益1:1→出码/核销→评价 |
| 门店 | 登录→扫码确认→记录→store_payout T+1 | | 门店 | 登录→扫码确认→记录→store_payout T+1 |
| 合伙人 | 拓店三步→HQ审核→辖区订单/账单 | | 合伙人 | 拓店三步→HQ审核→辖区订单/账单 |
| HQ | 开城/商品/审核/订单/权益/核销/结算/工单 | | HQ | 开城/商品/审核/订单/权益/核销/结算/工单 |
@@ -45,6 +45,10 @@ C 端购酒核销 · 门店扫码核销+打款 · 合伙人拓店履约 · WebAd
**HQ 列表(v3.5.9)**:主表不省略号、可横滑;最左序号;列设置(显隐/顺序)与列宽(拖表头)存 `hq_account.list_column_prefs`。主展示列下划线,点击进编辑或详情。门店列表「累计核销好客权益」= 该店 `RedeemRecord.amount` 合计。用户列表昵称只读(点击进详情);双击「备注」离开即保存(`hq_remark`);列表手机号不脱敏。 **HQ 列表(v3.5.9)**:主表不省略号、可横滑;最左序号;列设置(显隐/顺序)与列宽(拖表头)存 `hq_account.list_column_prefs`。主展示列下划线,点击进编辑或详情。门店列表「累计核销好客权益」= 该店 `RedeemRecord.amount` 合计。用户列表昵称只读(点击进详情);双击「备注」离开即保存(`hq_remark`);列表手机号不脱敏。
**C 端(v3.5.10)**:门店详情无顶栏分享按钮。同城送提示取开城仓库绑定承运商的 `delivery_hint_html``GET /catalog/local-deliveries`,按收货市是否开城);空则回退「同城配送,预计24小时内送到」。在线客服优先 `wx.openCustomerServiceChat``CUSTOMER_SERVICE_WECOM_URL` + `WECOM_CORP_ID`);未配 CorpID 回退小程序原生客服。
**起购(v3.5.11)**:现场提货 / 同城 / 跨城阈值在城市 `pickup_min_qty` / `local_min_qty` / `cross_min_qty`(瓶当量)。承运商「起送瓶数」只用于物流计价,不拦下单。
## 5. 验收用例(必过) ## 5. 验收用例(必过)
**主链路 15 项**:登录、4 SKU、起购、支付+权益、双通道核销、payout、关店不可见、拓店审核、配送完成、退款、T+1/T+30… **主链路 15 项**:登录、4 SKU、起购、支付+权益、双通道核销、payout、关店不可见、拓店审核、配送完成、退款、T+1/T+30…
+6 -3
View File
@@ -22,10 +22,11 @@
- 四 Tab:首页/权益/门店/我的;微信登录+7天会话 - 四 Tab:首页/权益/门店/我的;微信登录+7天会话
- 下单:选城→商品→地址→起购校验→微信支付→权益1:1 - 下单:选城→商品→地址→起购校验→微信支付→权益1:1
- 权益:直接核销(≤总余额) / 单据核销(≤单据);出码3分钟 - 权益:直接核销(≤总余额) / 单据核销(≤单据);出码3分钟。二维码内容为门店 H5 URL`{SHOP_H5_URL}/redeem?token=`),微信扫一扫直达核销确认页
- 门店:仅 OPEN;详情含套餐/电话(脱敏可拨打)/两段营业时间 - 门店:仅 OPEN;详情含套餐/电话(脱敏可拨打)/两段营业时间
- 订单 Tab:待付款/已付款/已完成;物流详情(签收照/拨号/ETA) - 订单 Tab:待付款/已付款/已完成;物流详情(签收照/拨号/ETA)
- 售后:客服入口;发票/四类型工单按 PRD Wave 进度 - 售后:客服入口(小程序优先企微微信客服,未配 CorpID 回退原生客服);发票/四类型工单按 PRD Wave 进度
- 同城送:收货市已开城则展示承运商「配送信息提示」(HTML);未开城走跨城到付;门店详情无顶栏分享按钮
- 版本:`minClientVersion` 过低强制更新或退出 - 版本:`minClientVersion` 过低强制更新或退出
- 「我的」头像昵称:`chooseAvatar` + `input type=nickname`(见下「踩坑」) - 「我的」头像昵称:`chooseAvatar` + `input type=nickname`(见下「踩坑」)
@@ -47,7 +48,7 @@
## 3. 门店端(h5-shop ## 3. 门店端(h5-shop
- 登录绑定门店;首页扫码核销(微信 JSSDK) - 登录绑定门店;首页扫码核销(微信 JSSDK);也可微信扫一扫用户核销码直达确认页(仍需点「确认核销」)
- 核销记录;今日汇总;到账金额×60%展示 - 核销记录;今日汇总;到账金额×60%展示
- 营业状态开关;Mine 门店信息 - 营业状态开关;Mine 门店信息
- 套餐:列表编辑→提交 HQ 审核(v3.4.10) - 套餐:列表编辑→提交 HQ 审核(v3.4.10)
@@ -68,6 +69,7 @@
| 规则 | 说明 | | 规则 | 说明 |
|------|------| |------|------|
| iOS 登录/选店后 | 用 `location.replace(path)``hardNavigateInWechat`),禁止仅 React Router navigate | | iOS 登录/选店后 | 用 `location.replace(path)``hardNavigateInWechat`),禁止仅 React Router navigate |
| 微信扫一扫落地核销页 | 成功后须 `hardNavigateInWechat('/')` 回首页,否则入场 URL 仍是 `/redeem?token=`,下次首页扫码验签失败 |
| iOS 签名 URL | `getJssdkSignUrl()` = 入场 URL**保留** OAuth `code/state`;后端 `jssdk-config` 勿剔除 | | iOS 签名 URL | `getJssdkSignUrl()` = 入场 URL**保留** OAuth `code/state`;后端 `jssdk-config` 勿剔除 |
| 已绑定微信 | 短信登录后**不要**再强制 OAuth(避免反复重置入场 URL) | | 已绑定微信 | 短信登录后**不要**再强制 OAuth(避免反复重置入场 URL) |
| 扫码仍失败 | 弹窗引导「刷新页面」/「重新授权微信」,勿只提示再点一次 | | 扫码仍失败 | 弹窗引导「刷新页面」/「重新授权微信」,勿只提示再点一次 |
@@ -150,6 +152,7 @@ HQ 账号/角色(`hq-permissions`,生效=(角色∪追加)−撤销;可绑
| 智能机器人 | `/wecom/bots` 长连接指令 | | 智能机器人 | `/wecom/bots` 长连接指令 |
| 消息推送 | `/wecom/pushes` Webhook+eventKey | | 消息推送 | `/wecom/pushes` Webhook+eventKey |
| 日志 | `/logs/wecom-bots` | | 日志 | `/logs/wecom-bots` |
| C 端微信客服 | 系统设置 `CUSTOMER_SERVICE_WECOM_URL` + `WECOM_CORP_ID`;小程序须已关联该企业微信客服 |
eventKey`alert.ops` · `support_ticket.created` · `dev_plan.task_dispatch` · 支付/核销/结算告警。 eventKey`alert.ops` · `support_ticket.created` · `dev_plan.task_dispatch` · 支付/核销/结算告警。
+32 -13
View File
@@ -7,6 +7,7 @@ import {
calcOrderBoxCount, calcOrderBoxCount,
shouldHoldAutoCourierDispatch, shouldHoldAutoCourierDispatch,
validateMinPurchase, validateMinPurchase,
minBottleQtyForDelivery,
toBottleQuantity, toBottleQuantity,
toMinSaleQuantity, toMinSaleQuantity,
validateBusinessHours, validateBusinessHours,
@@ -34,36 +35,54 @@ describe('calcBenefitAmount', () => {
}); });
describe('validateMinPurchase', () => { describe('validateMinPurchase', () => {
const mins = { pickupMinQty: 2, localMinQty: 2, crossMinQty: 6 };
it('local requires 2 bottles', () => { it('local requires 2 bottles', () => {
expect(validateMinPurchase('LOCAL', 1, 2, 6).ok).toBe(false); expect(validateMinPurchase('LOCAL', 1, mins).ok).toBe(false);
expect(validateMinPurchase('LOCAL', 2, 2, 6).ok).toBe(true); expect(validateMinPurchase('LOCAL', 2, mins).ok).toBe(true);
}); });
it('cross city requires 6 bottles', () => { it('cross city requires 6 bottles', () => {
expect(validateMinPurchase('CROSS_CITY', 5, 2, 6).ok).toBe(false); expect(validateMinPurchase('CROSS_CITY', 5, mins).ok).toBe(false);
expect(validateMinPurchase('CROSS_CITY', 6, 2, 6).ok).toBe(true); expect(validateMinPurchase('CROSS_CITY', 6, mins).ok).toBe(true);
}); });
it('on-site pickup requires at least local min (2 bottles)', () => { it('on-site pickup requires pickup min (default 2 bottles)', () => {
expect(validateMinPurchase('ON_SITE_PICKUP', 0, 2, 6).ok).toBe(false); expect(validateMinPurchase('ON_SITE_PICKUP', 0, mins).ok).toBe(false);
expect(validateMinPurchase('ON_SITE_PICKUP', 1, 2, 6).ok).toBe(false); expect(validateMinPurchase('ON_SITE_PICKUP', 1, mins).ok).toBe(false);
expect(validateMinPurchase('ON_SITE_PICKUP', 2, 2, 6).ok).toBe(true); expect(validateMinPurchase('ON_SITE_PICKUP', 2, mins).ok).toBe(true);
}); });
it('box SKU: 1 box (6 bottles) satisfies local and cross mins', () => { it('on-site pickup uses pickupMinQty independently of localMinQty', () => {
const split = { pickupMinQty: 3, localMinQty: 2, crossMinQty: 6 };
expect(validateMinPurchase('ON_SITE_PICKUP', 2, split).ok).toBe(false);
expect(validateMinPurchase('ON_SITE_PICKUP', 3, split).ok).toBe(true);
expect(validateMinPurchase('LOCAL', 2, split).ok).toBe(true);
});
it('box SKU: 1 box (6 bottles) satisfies local, cross and pickup mins', () => {
const opts = { bottlesPerUnit: 6, saleUnit: 'BOX' as const }; const opts = { bottlesPerUnit: 6, saleUnit: 'BOX' as const };
expect(validateMinPurchase('LOCAL', 1, 2, 6, opts).ok).toBe(true); expect(validateMinPurchase('LOCAL', 1, mins, opts).ok).toBe(true);
expect(validateMinPurchase('CROSS_CITY', 1, 2, 6, opts).ok).toBe(true); expect(validateMinPurchase('CROSS_CITY', 1, mins, opts).ok).toBe(true);
expect(validateMinPurchase('ON_SITE_PICKUP', 1, 2, 6, opts).ok).toBe(true); expect(validateMinPurchase('ON_SITE_PICKUP', 1, mins, opts).ok).toBe(true);
}); });
it('box SKU message uses 箱', () => { it('box SKU message uses 箱', () => {
const r = validateMinPurchase('LOCAL', 0, 2, 6, { bottlesPerUnit: 6, saleUnit: 'BOX' }); const r = validateMinPurchase('LOCAL', 0, mins, { bottlesPerUnit: 6, saleUnit: 'BOX' });
expect(r.ok).toBe(false); expect(r.ok).toBe(false);
expect(r.message).toContain('箱'); expect(r.message).toContain('箱');
}); });
}); });
describe('minBottleQtyForDelivery', () => {
it('picks pickup / local / cross independently', () => {
const mins = { pickupMinQty: 2, localMinQty: 3, crossMinQty: 6 };
expect(minBottleQtyForDelivery('ON_SITE_PICKUP', mins)).toBe(2);
expect(minBottleQtyForDelivery('LOCAL', mins)).toBe(3);
expect(minBottleQtyForDelivery('CROSS_CITY', mins)).toBe(6);
});
});
describe('toBottleQuantity / toMinSaleQuantity', () => { describe('toBottleQuantity / toMinSaleQuantity', () => {
it('converts sale qty to bottles', () => { it('converts sale qty to bottles', () => {
expect(toBottleQuantity(2, 1)).toBe(2); expect(toBottleQuantity(2, 1)).toBe(2);
+31 -19
View File
@@ -33,36 +33,48 @@ export function saleUnitLabel(saleUnit: ProductSaleUnit | string | null | undefi
return saleUnit === 'BOX' ? '箱' : '瓶'; return saleUnit === 'BOX' ? '箱' : '瓶';
} }
export type DeliveryFulfillmentType = 'LOCAL' | 'CROSS_CITY' | 'ON_SITE_PICKUP';
/** 城市履约起购(瓶当量) */
export type MinPurchaseMins = {
pickupMinQty: number;
localMinQty: number;
crossMinQty: number;
};
export function minBottleQtyForDelivery(
deliveryType: DeliveryFulfillmentType,
mins: MinPurchaseMins,
): number {
if (deliveryType === 'ON_SITE_PICKUP') {
return mins.pickupMinQty > 0 ? mins.pickupMinQty : 2;
}
if (deliveryType === 'LOCAL') {
return mins.localMinQty;
}
return mins.crossMinQty;
}
export function validateMinPurchase( export function validateMinPurchase(
deliveryType: 'LOCAL' | 'CROSS_CITY' | 'ON_SITE_PICKUP', deliveryType: DeliveryFulfillmentType,
quantity: number, quantity: number,
localMinQty: number, mins: MinPurchaseMins,
crossMinQty: number,
options?: { bottlesPerUnit?: number; saleUnit?: ProductSaleUnit }, options?: { bottlesPerUnit?: number; saleUnit?: ProductSaleUnit },
): { ok: boolean; message?: string } { ): { ok: boolean; message?: string } {
const bottlesPerUnit = options?.bottlesPerUnit ?? 1; const bottlesPerUnit = options?.bottlesPerUnit ?? 1;
const saleUnit = options?.saleUnit ?? (bottlesPerUnit > 1 ? 'BOX' : 'BOTTLE'); const saleUnit = options?.saleUnit ?? (bottlesPerUnit > 1 ? 'BOX' : 'BOTTLE');
const bottleQty = toBottleQuantity(quantity, bottlesPerUnit); const bottleQty = toBottleQuantity(quantity, bottlesPerUnit);
const unit = saleUnitLabel(saleUnit); const unit = saleUnitLabel(saleUnit);
const minBottles = minBottleQtyForDelivery(deliveryType, mins);
if (deliveryType === 'ON_SITE_PICKUP') {
const minBottles = localMinQty > 0 ? localMinQty : 2;
if (bottleQty < minBottles) { if (bottleQty < minBottles) {
const minSale = toMinSaleQuantity(minBottles, bottlesPerUnit); const minSale = toMinSaleQuantity(minBottles, bottlesPerUnit);
return { ok: false, message: `现场提货至少购买 ${minSale}${unit}` }; const message =
} deliveryType === 'ON_SITE_PICKUP'
return { ok: true }; ? `现场提货至少购买 ${minSale}${unit}`
} : deliveryType === 'LOCAL'
const minBottles = deliveryType === 'LOCAL' ? localMinQty : crossMinQty;
if (bottleQty < minBottles) {
const minSale = toMinSaleQuantity(minBottles, bottlesPerUnit);
return {
ok: false,
message:
deliveryType === 'LOCAL'
? `同城配送至少购买 ${minSale}${unit}` ? `同城配送至少购买 ${minSale}${unit}`
: `跨城配送至少购买 ${minSale}${unit}`, : `跨城配送至少购买 ${minSale}${unit}`;
}; return { ok: false, message };
} }
return { ok: true }; return { ok: true };
} }
+3 -1
View File
@@ -19,9 +19,11 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"dev": "tsc --watch", "dev": "tsc --watch",
"test": "vitest run",
"lint": "eslint src" "lint": "eslint src"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5.4.5" "typescript": "^5.4.5",
"vitest": "^1.6.1"
} }
} }
+1 -1
View File
@@ -65,7 +65,7 @@ export interface ProductDto {
allowOnlinePurchase?: boolean; allowOnlinePurchase?: boolean;
/** 是否允许跨城配送 */ /** 是否允许跨城配送 */
allowCrossCityDelivery?: boolean; allowCrossCityDelivery?: boolean;
/** v3.5.4:是否配置了销售规格(多 SKU */ /** C 端是否展示规格选择(可售 SKU > 1 且已配规格轴 */
specEnabled?: boolean; specEnabled?: boolean;
/** 列表轻量:展示 SKU 销售单位 */ /** 列表轻量:展示 SKU 销售单位 */
saleUnit?: ProductSaleUnit; saleUnit?: ProductSaleUnit;
+15 -2
View File
@@ -30,11 +30,16 @@ export interface AppConfig {
tencentLbsSecretKey: string; tencentLbsSecretKey: string;
/** C 端 H5 落地页(推广码二维码链接前缀) */ /** C 端 H5 落地页(推广码二维码链接前缀) */
userH5Url: string; userH5Url: string;
/** 门店 H5 落地页(用户核销码二维码链接前缀) */
shopH5Url: string;
} }
/** 推广码 / C 端 H5 默认落地页(系统设置 USER_H5_URL 未配时回退;HQ 可改) */ /** 推广码 / C 端 H5 默认落地页(系统设置 USER_H5_URL 未配时回退;HQ 可改) */
export const DEFAULT_USER_H5_URL = 'https://user.runxian.top/user'; export const DEFAULT_USER_H5_URL = 'https://user.runxian.top/user';
/** 门店 H5 默认落地页(系统设置 SHOP_H5_URL 未配时回退;HQ 可改) */
export const DEFAULT_SHOP_H5_URL = 'https://shop.dukanghaoke.com';
/** 品牌 Logo OSS 根路径(默认;系统设置 BRAND_LOGO_OSS_BASE 可覆盖) */ /** 品牌 Logo OSS 根路径(默认;系统设置 BRAND_LOGO_OSS_BASE 可覆盖) */
export const BRAND_LOGO_OSS_BASE = 'https://dukang-dev.oss-cn-beijing.aliyuncs.com/logo/'; export const BRAND_LOGO_OSS_BASE = 'https://dukang-dev.oss-cn-beijing.aliyuncs.com/logo/';
@@ -58,12 +63,15 @@ export const QUALIFICATION_DISCLOSURE_URL = `${MINI_USER_STATIC_OSS_BASE}qualifi
export const CUSTOMER_SERVICE_PHONE = '13203801799'; export const CUSTOMER_SERVICE_PHONE = '13203801799';
/** /**
* C 线 * C 线 / openCustomerServiceChat
* h5-user VITE_CS_WECOM_URL * CUSTOMER_SERVICE_WECOM_URL
*/ */
export const CUSTOMER_SERVICE_WECOM_URL = export const CUSTOMER_SERVICE_WECOM_URL =
'https://work.weixin.qq.com/kfid/kfc8b88659a1dffa8cd'; 'https://work.weixin.qq.com/kfid/kfc8b88659a1dffa8cd';
/** 企业微信 CorpID(小程序 wx.openCustomerServiceChat 必填;系统设置 WECOM_CORP_ID */
export const WECOM_CORP_ID = '';
/** 从 env / 系统设置解析的 C 端品牌与客服展示配置(缺省回退常量) */ /** 从 env / 系统设置解析的 C 端品牌与客服展示配置(缺省回退常量) */
export type ClientBrandRuntime = { export type ClientBrandRuntime = {
userH5Url: string; userH5Url: string;
@@ -74,6 +82,8 @@ export type ClientBrandRuntime = {
miniUserStaticOssBase: string; miniUserStaticOssBase: string;
qualificationDisclosureUrl: string; qualificationDisclosureUrl: string;
customerServicePhone: string; customerServicePhone: string;
customerServiceWecomUrl: string;
wecomCorpId: string;
}; };
export function resolveClientBrandRuntime( export function resolveClientBrandRuntime(
@@ -95,6 +105,8 @@ export function resolveClientBrandRuntime(
(e.QUALIFICATION_DISCLOSURE_URL || '').trim() || (e.QUALIFICATION_DISCLOSURE_URL || '').trim() ||
`${staticBase}qualification-disclosure.png`, `${staticBase}qualification-disclosure.png`,
customerServicePhone: (e.CUSTOMER_SERVICE_PHONE || CUSTOMER_SERVICE_PHONE).trim(), customerServicePhone: (e.CUSTOMER_SERVICE_PHONE || CUSTOMER_SERVICE_PHONE).trim(),
customerServiceWecomUrl: (e.CUSTOMER_SERVICE_WECOM_URL || CUSTOMER_SERVICE_WECOM_URL).trim(),
wecomCorpId: (e.WECOM_CORP_ID || WECOM_CORP_ID).trim(),
}; };
} }
@@ -265,6 +277,7 @@ export function loadAppConfig(env?: Record<string, string | undefined>): AppConf
tencentLbsKey: e.TENCENT_LBS_KEY ?? '', tencentLbsKey: e.TENCENT_LBS_KEY ?? '',
tencentLbsSecretKey: e.TENCENT_LBS_SECRET_KEY ?? '', tencentLbsSecretKey: e.TENCENT_LBS_SECRET_KEY ?? '',
userH5Url: (e.USER_H5_URL || DEFAULT_USER_H5_URL).replace(/\/$/, ''), userH5Url: (e.USER_H5_URL || DEFAULT_USER_H5_URL).replace(/\/$/, ''),
shopH5Url: (e.SHOP_H5_URL || DEFAULT_SHOP_H5_URL).replace(/\/$/, ''),
}; };
return { return {
...base, ...base,
@@ -0,0 +1,55 @@
import { describe, expect, it } from 'vitest';
import { isXfxProviderCode, sanitizeDeliveryHintHtml } from './fulfillment-provider';
describe('isXfxProviderCode', () => {
it('匹配标准编码与城市前缀', () => {
expect(isXfxProviderCode('XFX')).toBe(true);
expect(isXfxProviderCode('xiaofeixia')).toBe(true);
expect(isXfxProviderCode('ZZXFX')).toBe(true);
expect(isXfxProviderCode('XFX_ZZ')).toBe(true);
});
it('不匹配普通承运商', () => {
expect(isXfxProviderCode('')).toBe(false);
expect(isXfxProviderCode('LOGISTICS')).toBe(false);
expect(isXfxProviderCode('MANUAL')).toBe(false);
expect(isXfxProviderCode('SF')).toBe(false);
});
});
describe('sanitizeDeliveryHintHtml', () => {
const styled =
'<span style="color:#A61D24;font-weight:700;font-size:13px">同城配送,预计24小时内送到</span>';
it('保留允许的 style', () => {
expect(sanitizeDeliveryHintHtml(styled)).toBe(styled);
});
it('解码 &quot; 后保留 style', () => {
const raw =
'<span style=&quot;color:#A61D24;font-weight:700;font-size:13px&quot;>同城配送,预计24小时内送到</span><br />\n<span>13点之前下单,当日送达</span>';
expect(sanitizeDeliveryHintHtml(raw)).toBe(
`${styled}<br/>\n<span>13点之前下单,当日送达</span>`,
);
});
it('弯引号与无引号 style 也能保留', () => {
expect(
sanitizeDeliveryHintHtml(
'<span style=\u201Ccolor:#A61D24;font-weight:700;font-size:13px\u201D>同城配送,预计24小时内送到</span>',
),
).toBe(styled);
expect(
sanitizeDeliveryHintHtml(
'<span style=color:#A61D24;font-weight:700;font-size:13px>同城配送,预计24小时内送到</span>',
),
).toBe(styled);
});
it('仍去掉脚本与非法样式', () => {
expect(sanitizeDeliveryHintHtml('<span style="color:red;background:url(x)">x</span>')).toBe(
'<span style="color:red">x</span>',
);
expect(sanitizeDeliveryHintHtml('<script>alert(1)</script><span>ok</span>')).toBe('<span>ok</span>');
});
});
@@ -55,6 +55,8 @@ export interface FulfillmentProviderDto {
settlementMethod: LogisticsSettlementMethod; settlementMethod: LogisticsSettlementMethod;
pricingRules?: LogisticsPricingRuleDto | null; pricingRules?: LogisticsPricingRuleDto | null;
prepaidBalance: number; prepaidBalance: number;
/** C 端同城配送提示(已消毒 HTML) */
deliveryHintHtml?: string | null;
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
} }
@@ -74,6 +76,7 @@ export interface CreateFulfillmentProviderInput {
bankAccountNo?: string | null; bankAccountNo?: string | null;
settlementMethod?: LogisticsSettlementMethod; settlementMethod?: LogisticsSettlementMethod;
pricingRules?: LogisticsPricingRuleDto | null; pricingRules?: LogisticsPricingRuleDto | null;
deliveryHintHtml?: string | null;
} }
export interface UpdateFulfillmentProviderInput { export interface UpdateFulfillmentProviderInput {
@@ -89,6 +92,7 @@ export interface UpdateFulfillmentProviderInput {
bankAccountNo?: string | null; bankAccountNo?: string | null;
settlementMethod?: LogisticsSettlementMethod; settlementMethod?: LogisticsSettlementMethod;
pricingRules?: LogisticsPricingRuleDto | null; pricingRules?: LogisticsPricingRuleDto | null;
deliveryHintHtml?: string | null;
} }
export { DEFAULT_XFX_LOGISTICS_PRICING }; export { DEFAULT_XFX_LOGISTICS_PRICING };
@@ -110,6 +114,119 @@ export interface WarehouseFulfillmentConfig {
export const XFX_PROVIDER_CODES = ['XFX', 'XIAOFEIXIA'] as const; export const XFX_PROVIDER_CODES = ['XFX', 'XIAOFEIXIA'] as const;
/** 小飞侠承运商编码:精确 XFX/XIAOFEIXIA,以及城市前缀如 ZZXFX */
export function isXfxProviderCode(code: string): boolean { export function isXfxProviderCode(code: string): boolean {
return (XFX_PROVIDER_CODES as readonly string[]).includes(code.trim().toUpperCase()); const c = code.trim().toUpperCase();
if (!c) return false;
if ((XFX_PROVIDER_CODES as readonly string[]).includes(c)) return true;
if (c.includes('XIAOFEIXIA')) return true;
return c.endsWith('XFX') || c.startsWith('XFX');
}
/** 承运商未配置提示时 C 端回退文案 */
export const DEFAULT_LOCAL_DELIVERY_HINT = '同城配送,预计24小时内送到';
export const LOCAL_DELIVERY_HINT_MAX_LEN = 2000;
const HINT_ALLOWED_TAGS = new Set(['span', 'p', 'br', 'b', 'strong', 'i', 'em', 'font']);
const HINT_ALLOWED_STYLES = new Set(['color', 'font-weight', 'font-size', 'font-style']);
export type LocalDeliveryDto = {
city: { id: string; code: string; name: string };
warehouse: { id: string; name: string; fulfillmentMode: string } | null;
provider: { id: string; code: string; name: string } | null;
hintHtml: string | null;
};
/** 粘贴 HTML 源码时常带 &quot; / 弯引号;不解码则 style 正则匹配失败,整段样式被剥掉 */
function decodeHintHtmlEntities(html: string): string {
let prev = '';
let out = html;
for (let i = 0; i < 3 && out !== prev; i += 1) {
prev = out;
out = out
.replace(/&amp;/gi, '&')
.replace(/&quot;/gi, '"')
.replace(/&#0*34;/g, '"')
.replace(/&#x0*22;/gi, '"')
.replace(/&apos;/gi, "'")
.replace(/&#0*39;/g, "'")
.replace(/&#x0*27;/gi, "'")
.replace(/&lt;/gi, '<')
.replace(/&gt;/gi, '>')
.replace(/&nbsp;/gi, ' ');
}
return out
.replace(/[\u201c\u201d\u201e\u00ab\u00bb]/g, '"')
.replace(/[\u2018\u2019]/g, "'");
}
function sanitizeHintStyle(raw: string): string {
return raw
.split(';')
.map((part) => part.trim())
.filter(Boolean)
.map((part) => {
const idx = part.indexOf(':');
if (idx <= 0) return '';
const key = part.slice(0, idx).trim().toLowerCase();
const value = part.slice(idx + 1).trim();
if (!HINT_ALLOWED_STYLES.has(key)) return '';
if (/url\s*\(|expression\s*\(|javascript\s*:/i.test(value)) return '';
return `${key}:${value}`;
})
.filter(Boolean)
.join(';');
}
function extractHintAttr(attrs: string, name: string): string {
const re = new RegExp(
`\\s${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`,
'i',
);
const match = attrs.match(re);
if (!match) return '';
return (match[1] ?? match[2] ?? match[3] ?? '').trim();
}
/** 文本换行转成 br,供 C 端 RichText 使用(不改 HQ 存盘原文) */
export function deliveryHintHtmlToRichNodes(html: string): string {
return html
.replace(/\r\n|\r|\n/g, '<br/>')
.replace(/(?:<br\s*\/?>){3,}/gi, '<br/><br/>');
}
/** 承运商配送提示 HTML:去掉脚本/事件,只保留字号颜色粗细 */
export function sanitizeDeliveryHintHtml(raw?: string | null): string | null {
if (raw == null) return null;
let html = String(raw).trim();
if (!html) return null;
if (html.length > LOCAL_DELIVERY_HINT_MAX_LEN) {
html = html.slice(0, LOCAL_DELIVERY_HINT_MAX_LEN);
}
html = decodeHintHtmlEntities(html);
html = html.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '');
html = html.replace(/on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, '');
html = html.replace(/javascript\s*:/gi, '');
html = html.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b([^>]*)>/g, (_full, tag: string, attrs: string) => {
const name = String(tag).toLowerCase();
const closing = String(_full).startsWith('</');
if (!HINT_ALLOWED_TAGS.has(name)) return '';
if (name === 'br') return closing ? '' : '<br/>';
if (closing) return `</${name}>`;
const style = sanitizeHintStyle(extractHintAttr(String(attrs), 'style'));
let color = '';
let size = '';
if (name === 'font') {
color = extractHintAttr(String(attrs), 'color');
size = extractHintAttr(String(attrs), 'size');
}
const extra: string[] = [];
if (style) extra.push(`style="${style}"`);
if (color) extra.push(`color="${color.replace(/"/g, '')}"`);
if (size) extra.push(`size="${size.replace(/"/g, '')}"`);
return extra.length ? `<${name} ${extra.join(' ')}>` : `<${name}>`;
});
const cleaned = html.replace(/&nbsp;/g, ' ').trim();
return cleaned || null;
} }
+15
View File
@@ -3,6 +3,21 @@ export interface AdminListQuery {
pageSize?: number; pageSize?: number;
} }
/** HQ 订单列表 / 导出筛选。`status` 可多选(单值仍兼容) */
export interface AdminOrdersListQuery extends AdminListQuery {
orderNo?: string;
status?: string | string[];
orderType?: string;
userId?: string;
cityId?: string;
receiverPhone?: string;
fulfillmentHold?: string | boolean;
createdFrom?: string;
createdTo?: string;
excludeTest?: boolean;
deliveryType?: string;
}
export interface UpdateAdminUserRequest { export interface UpdateAdminUserRequest {
hqRemark: string; hqRemark: string;
} }
+39
View File
@@ -0,0 +1,39 @@
import { describe, expect, it } from 'vitest';
import { buildShopRedeemLandingUrl, parseRedeemTokenFromScan } from './redeem';
const TOKEN = 'a1b2c3d4e5f6789012345678901234ab';
describe('buildShopRedeemLandingUrl', () => {
it('joins shop H5 origin with /redeem?token=', () => {
expect(buildShopRedeemLandingUrl('https://shop.dukanghaoke.com', TOKEN)).toBe(
`https://shop.dukanghaoke.com/redeem?token=${TOKEN}`,
);
});
it('strips trailing slash on the base', () => {
expect(buildShopRedeemLandingUrl('https://shop-test.dukanghaoke.com/', TOKEN)).toBe(
`https://shop-test.dukanghaoke.com/redeem?token=${TOKEN}`,
);
});
});
describe('parseRedeemTokenFromScan', () => {
it('accepts a raw 32-hex token', () => {
expect(parseRedeemTokenFromScan(TOKEN.toUpperCase())).toBe(TOKEN);
});
it('extracts token from shop landing URL', () => {
const url = buildShopRedeemLandingUrl('https://shop.dukanghaoke.com', TOKEN);
expect(parseRedeemTokenFromScan(url)).toBe(TOKEN);
});
it('strips WeChat QR_CODE prefix before parsing URL', () => {
const url = buildShopRedeemLandingUrl('https://shop.dukanghaoke.com', TOKEN);
expect(parseRedeemTokenFromScan(`QR_CODE,${url}`)).toBe(TOKEN);
});
it('returns null for empty or unrelated content', () => {
expect(parseRedeemTokenFromScan('')).toBeNull();
expect(parseRedeemTokenFromScan('https://shop.dukanghaoke.com/records')).toBeNull();
});
});
+42
View File
@@ -9,6 +9,48 @@ export interface RedeemTokenResult {
expireAt: string; expireAt: string;
amount: number; amount: number;
boundStoreId?: string | null; boundStoreId?: string | null;
/** 门店 H5 核销确认页落地 URL(写入二维码,微信扫一扫可直达) */
landingUrl?: string;
}
const REDEEM_TOKEN_HEX = /^[a-f0-9]{32}$/i;
/** 门店核销确认页落地 URL,供用户端核销码使用 */
export function buildShopRedeemLandingUrl(shopH5Url: string, token: string): string {
const base = shopH5Url.replace(/\/$/, '');
return `${base}/redeem?token=${encodeURIComponent(token)}`;
}
/** 微信扫码偶发 `QR_CODE,payload` 前缀 */
function stripScanTypePrefix(raw: string): string {
const comma = raw.indexOf(',');
if (comma > 0 && comma < 24 && /^[A-Z0-9_]+$/.test(raw.slice(0, comma))) {
return raw.slice(comma + 1).trim();
}
return raw;
}
/** 从微信扫码结果解析核销 token32 位 hex 或带 token 参数的 URL */
export function parseRedeemTokenFromScan(raw: string): string | null {
const trimmed = stripScanTypePrefix(raw.trim());
if (!trimmed) return null;
if (REDEEM_TOKEN_HEX.test(trimmed)) {
return trimmed.toLowerCase();
}
try {
const url = trimmed.startsWith('http') ? new URL(trimmed) : new URL(trimmed, 'https://local.invalid');
const fromQuery = url.searchParams.get('token');
if (fromQuery && REDEEM_TOKEN_HEX.test(fromQuery)) {
return fromQuery.toLowerCase();
}
} catch {
/* not a URL */
}
const hexMatch = trimmed.match(/[a-f0-9]{32}/i);
return hexMatch ? hexMatch[0].toLowerCase() : null;
} }
export interface RedeemPreviewDto { export interface RedeemPreviewDto {

Some files were not shown because too many files have changed in this diff Show More