Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e68eb4d38c | |||
| b375fab44a | |||
| 9c8d5f2cad | |||
| 3b669f7e38 | |||
| da19c39965 | |||
| b226af2adc | |||
| fccfd7abbe | |||
| 737efb89a3 | |||
| 3dbb73e428 | |||
| 58a8b47532 | |||
| 3afbdfe6b9 | |||
| 632539e8dc | |||
| c7cd0f6cf2 | |||
| 1f4506f60b | |||
| cc0c0a6ef8 | |||
| 52a7d3789d | |||
| 797b20979d |
@@ -89,7 +89,7 @@ await this.prisma.order.update({ ... });
|
||||
```typescript
|
||||
const benefitAmount = product.benefitAmount ?? product.price;
|
||||
// 核销:直接核销按全部 ACTIVE 权益总余额;带单据核销按该单据可用金额
|
||||
// 同城 min 2 瓶 / 跨城 min 6 瓶
|
||||
// 起购:提货/同城 min 2 瓶 / 跨城 min 6 瓶(城市配置,非承运商)
|
||||
|
||||
// 支付成功 → log_third_party + user_order.pay_status=PAID
|
||||
// → user_benefit_coupon + common_event(BENEFIT_LEDGER, GRANT)
|
||||
|
||||
@@ -37,7 +37,7 @@ disable-model-invocation: true
|
||||
|
||||
```
|
||||
权益额 = 订单实付 1:1(永久)
|
||||
同城起购 2 瓶 / 跨城 1 箱(6瓶)
|
||||
起购:现场提货 2 瓶 / 同城 2 瓶 / 跨城 1 箱(6瓶);属城市,非承运商
|
||||
门店结算 = 核销额 × 60%
|
||||
单合伙人:订单佣金 + 核销佣金 ≤ 5%(默认 0% + 3%)
|
||||
核销码 TTL = 3 分钟;试核销固定 ¥100
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
| REQ-U-004 | 定位 | 右上角市区;默认 IP;可授权精确定位 |
|
||||
| REQ-U-005 | 首页商品 | 4 款酒祖杜康;大图、标题加粗、价格标红、权益金额 |
|
||||
| REQ-U-006 | 商品详情 | 规格瓶/箱、度数、价格、权益、详情图 |
|
||||
| REQ-U-007 | 同城 | 小飞侠;≥2 瓶免运费;物流节点+拍照;24h 自动完成 |
|
||||
| REQ-U-008 | 现场提货 | 隐藏入口;支付即完成;强提示在现场 |
|
||||
| REQ-U-009 | 跨城 | 未开通城市;≥1 箱;总部物流到付 |
|
||||
| REQ-U-007 | 同城 | 小飞侠;起购 ≥2 瓶(城市 `localMinQty`);≥2 瓶免运费;物流节点+拍照;24h 自动完成 |
|
||||
| REQ-U-008 | 现场提货 | 隐藏入口;起购 ≥2 瓶(城市 `pickupMinQty`);支付即完成;强提示在现场 |
|
||||
| REQ-U-009 | 跨城 | 未开通城市;起购 ≥1 箱(城市 `crossMinQty`=6 瓶当量);总部物流到付 |
|
||||
| REQ-U-010 | 锁单 | 待付款 30 分钟取消 |
|
||||
| REQ-U-011 | 权益 | 支付成功 1:1 永久 |
|
||||
| REQ-U-012 | 客服 | 已付款起电话/微信客服 |
|
||||
|
||||
@@ -26,3 +26,4 @@ server/dukang-api/assets/fonts/*.ttc
|
||||
server/dukang-api/assets/fonts/*.otf
|
||||
deploy/auto-release.env
|
||||
deploy/backups/
|
||||
.playwright-mcp/
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
```
|
||||
权益额 = benefit_amount ?? price
|
||||
同城起购 2 瓶 / 跨城 6 瓶
|
||||
起购:现场提货 2 瓶 / 同城 2 瓶 / 跨城 6 瓶(1 箱);属城市,非承运商
|
||||
核销:直接核销 0 < amount ≤ 全部 ACTIVE 权益总余额;带单据核销 0 < amount ≤ 该单据可用金额;Redis 码 3 分钟
|
||||
C 端门店仅 status=OPEN
|
||||
订单 Tab:待付款 | 已付款 | 已完成
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
|
||||
```text
|
||||
权益发放额 = common_product_item.benefit_amount ?? price
|
||||
同城起购 2 瓶 / 跨城 6 瓶
|
||||
起购:现场提货 2 瓶 / 同城 2 瓶 / 跨城 6 瓶(1 箱);属城市,非承运商
|
||||
核销:直接核销 0 < amount ≤ 全部 ACTIVE 权益总余额;带单据核销 0 < amount ≤ 该单据可用金额
|
||||
C 端门店列表仅 status=OPEN
|
||||
订单 Tab:all | pending_pay | pending_ship | pending_receive | completed
|
||||
|
||||
@@ -74,6 +74,60 @@ body.admin-col-resizing * {
|
||||
user-select: none !important;
|
||||
}
|
||||
|
||||
/* 订单页筛选:第一行常驻,第二行起可收起 */
|
||||
.admin-orders-filter-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 16px;
|
||||
align-items: flex-end;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.admin-orders-filter-row--tools {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.admin-orders-filter-item {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.admin-orders-filter-item--sm {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.admin-orders-filter-item--md {
|
||||
width: 168px;
|
||||
}
|
||||
|
||||
.admin-orders-filter-item--search {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.admin-users-filter-item--keyword {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.admin-orders-filter-item--status {
|
||||
width: 220px;
|
||||
min-width: 180px;
|
||||
flex: 1 1 180px;
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.admin-orders-filter-item--date {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.admin-orders-filter-actions {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.admin-orders-date-picker {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
/* 列表页顶栏:标题左、主操作右、列设置最右 */
|
||||
.admin-list-header {
|
||||
display: flex;
|
||||
@@ -308,6 +362,40 @@ body:has(.big-screen-page),
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.big-screen-bgm {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-right: 8px;
|
||||
padding: 6px 14px 6px 12px;
|
||||
border: 1px solid rgba(105, 192, 255, 0.45);
|
||||
border-radius: 6px;
|
||||
background: rgba(8, 28, 56, 0.7);
|
||||
color: rgba(230, 244, 255, 0.92);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 1px;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.big-screen-bgm:hover {
|
||||
border-color: rgba(105, 192, 255, 0.85);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.big-screen-bgm.is-on {
|
||||
border-color: rgba(64, 169, 255, 0.85);
|
||||
box-shadow: 0 0 12px rgba(64, 169, 255, 0.28);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.big-screen-bgm-icon {
|
||||
display: inline-flex;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.big-screen-live-label {
|
||||
font-size: 18px;
|
||||
color: rgba(230, 244, 255, 0.88);
|
||||
|
||||
Binary file not shown.
@@ -11,10 +11,23 @@ import PackageImagesUpload from './PackageImagesUpload';
|
||||
type PackageRow = StorePackageItemDto;
|
||||
|
||||
export type AdminStorePackagesHandle = {
|
||||
/** 套餐已加载时写入;加载中则跳过,避免空数据覆盖线上套餐 */
|
||||
/** 仅在用户改过套餐时写入;加载中或未改动则跳过,避免空表单覆盖刚审核通过的线上套餐 */
|
||||
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 {
|
||||
return {
|
||||
name: '',
|
||||
@@ -37,6 +50,7 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
|
||||
const [pendingRequest, setPendingRequest] = useState<StorePackagesResponse['pendingRequest']>(null);
|
||||
const itemsRef = useRef(items);
|
||||
const loadingRef = useRef(loading);
|
||||
const dirtyRef = useRef(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -47,36 +61,33 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
|
||||
loadingRef.current = loading;
|
||||
}, [loading]);
|
||||
|
||||
function applyServerPackages(data: StorePackagesResponse) {
|
||||
dirtyRef.current = false;
|
||||
setPendingRequest(data.pendingRequest ?? null);
|
||||
setItems(mapLiveRows(data.live));
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
setPendingRequest(null);
|
||||
dirtyRef.current = false;
|
||||
request<StorePackagesResponse>(`/admin/stores/${storeId}/packages`)
|
||||
.then((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,
|
||||
};
|
||||
})
|
||||
: [],
|
||||
);
|
||||
})
|
||||
.then((data) => applyServerPackages(data))
|
||||
.catch((e) => message.error(e instanceof Error ? e.message : '加载套餐失败'))
|
||||
.finally(() => setLoading(false));
|
||||
}, [storeId]);
|
||||
|
||||
// 在审核页完成审核后,自动刷新本页「有待审核套餐」提醒
|
||||
// 审核通过/驳回后刷新提醒;用户未改套餐时同步线上结果,避免抽屉里仍显示空套餐
|
||||
useEffect(() => {
|
||||
const onChanged = () => {
|
||||
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);
|
||||
};
|
||||
window.addEventListener(PACKAGE_AUDIT_CHANGED_EVENT, onChanged);
|
||||
@@ -108,16 +119,19 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
|
||||
) : null;
|
||||
|
||||
function updateAt(index: number, patch: Partial<PackageRow>) {
|
||||
dirtyRef.current = true;
|
||||
setItems((prev) => prev.map((item, i) => (i === index ? { ...item, ...patch } : item)));
|
||||
}
|
||||
|
||||
function addRow() {
|
||||
if (items.length >= STORE_PACKAGE_MAX_COUNT) return;
|
||||
dirtyRef.current = true;
|
||||
setItems((prev) => [...prev, emptyRow(prev.length)]);
|
||||
}
|
||||
|
||||
function removeAt(index: number) {
|
||||
const run = () => {
|
||||
dirtyRef.current = true;
|
||||
setItems((prev) => {
|
||||
const next = prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i }));
|
||||
return next.length ? next : [];
|
||||
@@ -203,20 +217,8 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
|
||||
}),
|
||||
});
|
||||
if (!opts?.quiet) message.success('套餐已保存并生效');
|
||||
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,
|
||||
};
|
||||
})
|
||||
: [],
|
||||
);
|
||||
dirtyRef.current = false;
|
||||
setItems(mapLiveRows(data.live));
|
||||
} catch (e) {
|
||||
if (!opts?.quiet) message.error(e instanceof Error ? e.message : '保存失败');
|
||||
throw e;
|
||||
@@ -227,7 +229,7 @@ const AdminStorePackagesSection = forwardRef<AdminStorePackagesHandle, { storeId
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
saveIfLoaded: async (opts) => {
|
||||
if (loadingRef.current) return { skipped: true };
|
||||
if (loadingRef.current || !dirtyRef.current) return { skipped: true };
|
||||
await save(opts);
|
||||
return { skipped: false };
|
||||
},
|
||||
|
||||
@@ -26,10 +26,12 @@ import {
|
||||
type PartnerPermissionKey,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { omitNullFields } from '../lib/omit-null-fields';
|
||||
import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import CityDistrictMultiSelect from './CityDistrictMultiSelect';
|
||||
import PartnerSubAccountList from './PartnerSubAccountList';
|
||||
import PartnerAssocPanel from './PartnerAssocPanel';
|
||||
|
||||
type PartnerRow = {
|
||||
id: string;
|
||||
@@ -186,7 +188,7 @@ export default function CityPartnersPanel({
|
||||
await request(`/admin/partners/${detail.id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
...v,
|
||||
...omitNullFields(v),
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: editScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
@@ -345,6 +347,11 @@ export default function CityPartnersPanel({
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'assoc',
|
||||
label: '关联码',
|
||||
children: <PartnerAssocPanel partnerId={detail.id} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Image, Input, Modal, Space, Typography } from 'antd';
|
||||
import { PAYMENT_PROOF_IMAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||
import MultiImageUpload from './MultiImageUpload';
|
||||
|
||||
export function parsePaymentProofUrls(raw: unknown): string[] {
|
||||
if (!Array.isArray(raw)) return [];
|
||||
return raw.map((u) => String(u ?? '').trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
export function PaymentProofGallery({ urls }: { urls?: unknown }) {
|
||||
const list = parsePaymentProofUrls(urls);
|
||||
if (!list.length) return <>—</>;
|
||||
return (
|
||||
<Image.PreviewGroup>
|
||||
<Space wrap size={8}>
|
||||
{list.map((url, index) => (
|
||||
<Image
|
||||
key={`${url}-${index}`}
|
||||
src={url}
|
||||
width={72}
|
||||
height={72}
|
||||
style={{ objectFit: 'cover', borderRadius: 6, border: '1px solid #f0f0f0' }}
|
||||
/>
|
||||
))}
|
||||
</Space>
|
||||
</Image.PreviewGroup>
|
||||
);
|
||||
}
|
||||
|
||||
type FinancePayProofModalProps = {
|
||||
open: boolean;
|
||||
title: string;
|
||||
hint: string;
|
||||
okText: string;
|
||||
confirmLoading?: boolean;
|
||||
onCancel: () => void;
|
||||
onOk: (payload: { paymentRef?: string; paymentProofUrls?: string[] }) => Promise<void>;
|
||||
};
|
||||
|
||||
export function FinancePayProofModal({
|
||||
open,
|
||||
title,
|
||||
hint,
|
||||
okText,
|
||||
confirmLoading,
|
||||
onCancel,
|
||||
onOk,
|
||||
}: FinancePayProofModalProps) {
|
||||
const [paymentRef, setPaymentRef] = useState('');
|
||||
const [proofUrls, setProofUrls] = useState<string[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setPaymentRef('');
|
||||
setProofUrls([]);
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={title}
|
||||
open={open}
|
||||
okText={okText}
|
||||
cancelText="取消"
|
||||
confirmLoading={confirmLoading}
|
||||
destroyOnClose
|
||||
width={480}
|
||||
onCancel={onCancel}
|
||||
onOk={async () => {
|
||||
await onOk({
|
||||
paymentRef: paymentRef.trim() || undefined,
|
||||
paymentProofUrls: proofUrls.length ? proofUrls : undefined,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Typography.Paragraph style={{ marginBottom: 12 }}>{hint}</Typography.Paragraph>
|
||||
<Input
|
||||
placeholder="打款凭证号(可选)"
|
||||
value={paymentRef}
|
||||
onChange={(e) => setPaymentRef(e.target.value)}
|
||||
style={{ marginBottom: 12 }}
|
||||
/>
|
||||
<Typography.Text type="secondary">打款凭证照片(可选,银行转账回单等)</Typography.Text>
|
||||
<div style={{ marginTop: 8 }}>
|
||||
<MultiImageUpload
|
||||
bizType="PAYMENT_PROOF"
|
||||
value={proofUrls}
|
||||
onChange={setProofUrls}
|
||||
maxCount={PAYMENT_PROOF_IMAGE_MAX_COUNT}
|
||||
buttonText="上传凭证照片"
|
||||
tip={`最多 ${PAYMENT_PROOF_IMAGE_MAX_COUNT} 张,支持一次选择多张`}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -173,7 +173,9 @@ export default function OrderTrackDrawer({
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={
|
||||
track?.manualQueryUrl
|
||||
track?.queryError
|
||||
? track.queryError
|
||||
: track?.manualQueryUrl
|
||||
? '暂无实时路由节点,可使用上方物流查询链接'
|
||||
: '暂无路由信息,请稍后刷新'
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Button, Popconfirm, Space, Table, Typography, message } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type { PartnerAssocSummary, PartnerAssocUserItem } from '@dukang/shared-types';
|
||||
import { request, type HqProfile, type Paginated } from '../lib/api';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
|
||||
function formatNicknameWithRemark(row: PartnerAssocUserItem) {
|
||||
const name = row.nickname?.trim() || '—';
|
||||
const remark = row.hqRemark?.trim();
|
||||
return remark ? `${name}(${remark})` : name;
|
||||
}
|
||||
|
||||
type PartnerAssocPanelProps = {
|
||||
partnerId: string;
|
||||
};
|
||||
|
||||
export default function PartnerAssocPanel({ partnerId }: PartnerAssocPanelProps) {
|
||||
const [summary, setSummary] = useState<PartnerAssocSummary | null>(null);
|
||||
const [users, setUsers] = useState<PartnerAssocUserItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [page, setPage] = useState(1);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [issuing, setIssuing] = useState(false);
|
||||
const [canEditAssoc, setCanEditAssoc] = useState(false);
|
||||
|
||||
const loadSummary = useCallback(async () => {
|
||||
const data = await request<PartnerAssocSummary>(`/admin/partners/${partnerId}/assoc`);
|
||||
setSummary(data);
|
||||
}, [partnerId]);
|
||||
|
||||
const loadUsers = useCallback(async (p = 1) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await request<Paginated<PartnerAssocUserItem>>(
|
||||
`/admin/partners/${partnerId}/assoc/users?page=${p}&pageSize=20`,
|
||||
);
|
||||
setUsers(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
setPage(p);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [partnerId]);
|
||||
|
||||
useEffect(() => {
|
||||
void request<HqProfile>('/admin/auth/me')
|
||||
.then((p) => setCanEditAssoc((p.permissionKeys ?? []).includes('users_partner_assoc')))
|
||||
.catch(() => setCanEditAssoc(false));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void loadSummary().catch((e) => message.error(e instanceof Error ? e.message : '加载关联码失败'));
|
||||
void loadUsers(1).catch(() => undefined);
|
||||
}, [loadSummary, loadUsers]);
|
||||
|
||||
async function reissue() {
|
||||
setIssuing(true);
|
||||
try {
|
||||
await request(`/admin/partners/${partnerId}/assoc/qrcode`, { method: 'POST' });
|
||||
message.success('已重新生成关联码');
|
||||
await loadSummary();
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '生成失败');
|
||||
} finally {
|
||||
setIssuing(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function unbind(userId: string) {
|
||||
try {
|
||||
await request(`/admin/partners/${partnerId}/assoc/users/${userId}/unbind`, { method: 'POST' });
|
||||
message.success('已解绑');
|
||||
await Promise.all([loadSummary(), loadUsers(page)]);
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '解绑失败');
|
||||
}
|
||||
}
|
||||
|
||||
const columns: ColumnsType<PartnerAssocUserItem> = [
|
||||
{ title: '用户编号', dataIndex: 'userNo', width: 140 },
|
||||
{
|
||||
title: '用户',
|
||||
dataIndex: 'nickname',
|
||||
render: (_, row) => (
|
||||
<Link
|
||||
className="admin-primary-link"
|
||||
to={`/users?userId=${encodeURIComponent(row.id)}`}
|
||||
title="在用户列表中查看"
|
||||
>
|
||||
{formatNicknameWithRemark(row)}
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{ title: '手机', dataIndex: 'phone', render: (v) => v || '—' },
|
||||
{ title: '关联时间', dataIndex: 'boundAt', render: (v) => (v ? fmtTime(v) : '—') },
|
||||
{ title: '已付订单', dataIndex: 'orderCount', width: 90 },
|
||||
...(canEditAssoc
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 90,
|
||||
render: (_: unknown, row: PartnerAssocUserItem) => (
|
||||
<Popconfirm title="解绑后该用户新单不再计订单佣金" onConfirm={() => void unbind(row.id)}>
|
||||
<Button type="link" size="small" danger>
|
||||
解绑
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
),
|
||||
} satisfies ColumnsType<PartnerAssocUserItem>[number],
|
||||
]
|
||||
: []),
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Space align="start" style={{ marginBottom: 16 }} wrap>
|
||||
{summary?.qrcodeUrl ? (
|
||||
<img src={summary.qrcodeUrl} alt="关联码" style={{ width: 160, height: 160, background: '#fff' }} />
|
||||
) : (
|
||||
<Typography.Text type="secondary">尚未生成关联码</Typography.Text>
|
||||
)}
|
||||
<div>
|
||||
<Typography.Paragraph style={{ marginBottom: 8 }}>
|
||||
<Link to={`/users?assocPartnerAccountId=${encodeURIComponent(partnerId)}`}>
|
||||
关联用户 {summary?.userCount ?? 0} 人
|
||||
</Link>
|
||||
</Typography.Paragraph>
|
||||
<Button loading={issuing} onClick={() => void reissue()}>
|
||||
{summary?.qrcodeUrl ? '补发关联码' : '生成关联码'}
|
||||
</Button>
|
||||
</div>
|
||||
</Space>
|
||||
<Table
|
||||
rowKey="id"
|
||||
size="small"
|
||||
loading={loading}
|
||||
columns={columns}
|
||||
dataSource={users}
|
||||
pagination={{
|
||||
current: page,
|
||||
pageSize: 20,
|
||||
total,
|
||||
onChange: (p) => void loadUsers(p),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Button, Image, Input, InputNumber, Modal, Radio, Select, Space, Switch, Table, Typography, message,
|
||||
} from 'antd';
|
||||
@@ -50,6 +50,38 @@ function keyOf(ids: string[]) {
|
||||
return [...ids].sort().join('_');
|
||||
}
|
||||
|
||||
function normalizeSkuRows(initialSkus: SkuRow[]): SkuRow[] {
|
||||
if (!initialSkus.length) {
|
||||
return [
|
||||
{
|
||||
specValueIds: [],
|
||||
barcode69: '',
|
||||
price: 0,
|
||||
status: 'ON_SALE',
|
||||
allowOnlinePurchase: true,
|
||||
allowCrossCityDelivery: true,
|
||||
allowOnSitePickup: false,
|
||||
saleUnit: 'BOTTLE',
|
||||
bottlesPerUnit: 1,
|
||||
isDefault: true,
|
||||
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[];
|
||||
@@ -58,44 +90,19 @@ type Props = {
|
||||
};
|
||||
|
||||
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: [],
|
||||
barcode69: '',
|
||||
price: 0,
|
||||
status: 'ON_SALE',
|
||||
allowOnlinePurchase: true,
|
||||
allowCrossCityDelivery: true,
|
||||
allowOnSitePickup: false,
|
||||
saleUnit: 'BOTTLE',
|
||||
bottlesPerUnit: 1,
|
||||
isDefault: true,
|
||||
imageUrl: '',
|
||||
},
|
||||
],
|
||||
);
|
||||
const [attrs, setAttrs] = useState<SpecAttr[]>(() => (initialAttrs.length ? initialAttrs : []));
|
||||
const [skus, setSkus] = useState<SkuRow[]>(() => normalizeSkuRows(initialSkus));
|
||||
const [saving, setSaving] = useState(false);
|
||||
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]);
|
||||
|
||||
function regenerateMatrix() {
|
||||
|
||||
@@ -54,6 +54,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
||||
const [skuId, setSkuId] = useState<string>();
|
||||
const [quantity, setQuantity] = useState(2);
|
||||
const [promoCodeId, setPromoCodeId] = useState<string>();
|
||||
const [assocPartnerAccountId, setAssocPartnerAccountId] = useState<string>();
|
||||
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>('ADDRESS');
|
||||
const [autoReceive, setAutoReceive] = useState(false);
|
||||
const [preview, setPreview] = useState<PartnerProxyOrderPreviewResult | null>(null);
|
||||
@@ -168,6 +169,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
||||
setProductId(undefined);
|
||||
setSkuId(undefined);
|
||||
setPromoCodeId(undefined);
|
||||
setAssocPartnerAccountId(undefined);
|
||||
setDeliveryMode('ADDRESS');
|
||||
setAutoReceive(false);
|
||||
setPreview(null);
|
||||
@@ -235,6 +237,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
||||
quantity,
|
||||
promoCodeId: promoCodeId || undefined,
|
||||
skuId: skuId || undefined,
|
||||
assocPartnerAccountId: assocPartnerAccountId || undefined,
|
||||
};
|
||||
|
||||
setSubmitting(true);
|
||||
@@ -388,6 +391,21 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="关联合伙人(选填)">
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="不选则本单不计订单佣金"
|
||||
value={assocPartnerAccountId}
|
||||
onChange={setAssocPartnerAccountId}
|
||||
options={(options?.partners ?? []).map((p) => ({
|
||||
value: p.id,
|
||||
label: `${p.companyName || p.name}${p.phone ? ` · ${p.phone}` : ''}`,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
{(options?.promoCodes.length ?? 0) > 0 ? (
|
||||
<Form.Item label="绑定推广码(选填)">
|
||||
<Select
|
||||
|
||||
@@ -15,7 +15,13 @@ type Props = {
|
||||
|
||||
export default function RedeemRecordDetailDescriptions({ detail, maskUserPhone = false }: Props) {
|
||||
const user = detail.user as
|
||||
| { userNo?: string; nickname?: string | null; phone?: string | null }
|
||||
| {
|
||||
id?: string;
|
||||
userNo?: string;
|
||||
nickname?: string | null;
|
||||
phone?: string | null;
|
||||
hqRemark?: string | null;
|
||||
}
|
||||
| undefined;
|
||||
const store = detail.store as
|
||||
| {
|
||||
@@ -41,7 +47,13 @@ export default function RedeemRecordDetailDescriptions({ detail, maskUserPhone =
|
||||
<Descriptions.Item label="结算额">¥{Number(detail.settleAmount ?? 0).toFixed(2)}</Descriptions.Item>
|
||||
<Descriptions.Item label="时间">{fmtTime(String(detail.createdAt ?? ''))}</Descriptions.Item>
|
||||
<Descriptions.Item label="用户编号">{user?.userNo ?? '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="用户昵称">{user?.nickname?.trim() || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="用户昵称">
|
||||
{(() => {
|
||||
const name = user?.nickname?.trim() || '—';
|
||||
const remark = user?.hqRemark?.trim();
|
||||
return remark ? `${name}(${remark})` : name;
|
||||
})()}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="用户手机">
|
||||
{maskUserPhone ? maskPhone(user?.phone) : user?.phone || '—'}
|
||||
</Descriptions.Item>
|
||||
@@ -91,6 +103,9 @@ export default function RedeemRecordDetailDescriptions({ detail, maskUserPhone =
|
||||
<Descriptions.Item label="评价">
|
||||
服务 {(detail.rating as { serviceScore?: number }).serviceScore ?? '—'} 分 / 环境{' '}
|
||||
{(detail.rating as { envScore?: number }).envScore ?? '—'} 分
|
||||
{(detail.rating as { comment?: string | null }).comment
|
||||
? ` · ${(detail.rating as { comment?: string }).comment}`
|
||||
: ''}
|
||||
</Descriptions.Item>
|
||||
) : null}
|
||||
</Descriptions>
|
||||
|
||||
@@ -20,7 +20,11 @@ import {
|
||||
AccountBookOutlined,
|
||||
ProjectOutlined,
|
||||
} 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 { bindAdminEllipsisTitle } from '../lib/ellipsis-title';
|
||||
import { AUDIT_NOTICE_CHANGED_EVENT, PACKAGE_AUDIT_CHANGED_EVENT } from '../lib/admin-events';
|
||||
@@ -28,12 +32,15 @@ import { ListColumnPrefsProvider } from '../lib/ListColumnPrefsContext';
|
||||
|
||||
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];
|
||||
|
||||
const MENU_ITEMS: MenuProps['items'] = [
|
||||
{ key: '/', icon: <DashboardOutlined />, label: '概览' },
|
||||
{ key: '/users', icon: <UserOutlined />, label: '用户' },
|
||||
{ key: '/wechat-bindings', icon: <UserOutlined />, label: '微信绑定' },
|
||||
{
|
||||
key: 'products-group',
|
||||
icon: <ShoppingOutlined />,
|
||||
@@ -44,18 +51,17 @@ const MENU_ITEMS: MenuProps['items'] = [
|
||||
],
|
||||
},
|
||||
{ key: '/orders', icon: <ShoppingOutlined />, label: '订单' },
|
||||
{ key: '/promo-codes', icon: <GiftOutlined />, label: '推广码' },
|
||||
{
|
||||
key: 'wecom-group',
|
||||
key: 'partners-group',
|
||||
icon: <TeamOutlined />,
|
||||
label: '企微机器人',
|
||||
label: '开城',
|
||||
children: [
|
||||
{ key: '/wecom/bots', label: '智能机器人' },
|
||||
{ key: '/wecom/pushes', label: '消息推送' },
|
||||
{ key: '/cities', label: '城市' },
|
||||
{ key: '/city-partners', label: '城市合伙人' },
|
||||
{ key: '/city-warehouses', label: '仓库' },
|
||||
{ key: '/fulfillment-providers', label: '仓配管理' },
|
||||
],
|
||||
},
|
||||
{ key: '/llm-configs', icon: <RobotOutlined />, label: '语言模型' },
|
||||
{ key: '/knowledge-bases', icon: <FileTextOutlined />, label: '知识库' },
|
||||
{
|
||||
key: 'stores-group',
|
||||
icon: <ShopOutlined />,
|
||||
@@ -69,17 +75,6 @@ const MENU_ITEMS: MenuProps['items'] = [
|
||||
{ key: '/store-media', label: '门店资源' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'partners-group',
|
||||
icon: <TeamOutlined />,
|
||||
label: '开城',
|
||||
children: [
|
||||
{ key: '/cities', label: '城市' },
|
||||
{ key: '/city-partners', label: '城市合伙人' },
|
||||
{ key: '/city-warehouses', label: '仓库' },
|
||||
{ key: '/fulfillment-providers', label: '仓配管理' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'finance-group',
|
||||
icon: <AccountBookOutlined />,
|
||||
@@ -121,6 +116,20 @@ const MENU_ITEMS: MenuProps['items'] = [
|
||||
{ key: '/tickets/support', label: '技术支持' },
|
||||
],
|
||||
},
|
||||
{ key: '/invoices', icon: <FileTextOutlined />, label: '发票' },
|
||||
{ key: '/promo-codes', icon: <GiftOutlined />, label: '推广码' },
|
||||
{ key: '/wechat-bindings', icon: <UserOutlined />, label: '微信绑定' },
|
||||
{
|
||||
key: 'wecom-group',
|
||||
icon: <TeamOutlined />,
|
||||
label: '企微机器人',
|
||||
children: [
|
||||
{ key: '/wecom/bots', label: '智能机器人' },
|
||||
{ key: '/wecom/pushes', label: '消息推送' },
|
||||
],
|
||||
},
|
||||
{ key: '/llm-configs', icon: <RobotOutlined />, label: '语言模型' },
|
||||
{ key: '/knowledge-bases', icon: <FileTextOutlined />, label: '知识库' },
|
||||
{
|
||||
key: 'dev-plan-group',
|
||||
icon: <ProjectOutlined />,
|
||||
@@ -131,7 +140,6 @@ const MENU_ITEMS: MenuProps['items'] = [
|
||||
{ key: '/dev-plan/settings', label: '开发设置' },
|
||||
],
|
||||
},
|
||||
{ key: '/invoices', icon: <FileTextOutlined />, label: '发票管理' },
|
||||
{ key: '/resources', icon: <CloudUploadOutlined />, label: 'OSS 资源库' },
|
||||
{
|
||||
key: 'logs-group',
|
||||
@@ -148,9 +156,9 @@ const MENU_ITEMS: MenuProps['items'] = [
|
||||
],
|
||||
},
|
||||
{ key: '/hq-permissions', icon: <LockOutlined />, label: '权限分配' },
|
||||
{ key: '/hq-accounts', icon: <SafetyOutlined />, label: 'HQ账户' },
|
||||
{ key: '/test-whitelist', icon: <SafetyOutlined />, label: '白名单管理' },
|
||||
{ key: '/system-settings', icon: <SettingOutlined />, label: '系统设置' },
|
||||
{ key: '/hq-accounts', icon: <SafetyOutlined />, label: 'HQ账户' },
|
||||
];
|
||||
|
||||
function menuAllowed(key: string, permissionKeys: string[]): boolean {
|
||||
@@ -405,7 +413,9 @@ export default function AdminLayout() {
|
||||
</Typography.Title>
|
||||
<Space>
|
||||
<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>
|
||||
|
||||
@@ -183,6 +183,12 @@ export type AdminUserRow = {
|
||||
benefitUsedAmount?: number;
|
||||
/** 好客权益·剩余未使用 */
|
||||
benefitBalance?: number;
|
||||
assocPartner?: {
|
||||
id: string;
|
||||
name: string;
|
||||
companyName?: string | null;
|
||||
phone?: string | null;
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type AdminOrderItem = {
|
||||
@@ -229,12 +235,14 @@ export type AdminOrderRow = {
|
||||
proxyPartnerName?: string | null;
|
||||
proxyPartnerPhone?: string | null;
|
||||
isTest?: boolean;
|
||||
user?: { id: string; userNo: string; phone: string | null; nickname: string | null };
|
||||
user?: { id: string; userNo: string; phone: string | null; nickname: string | null; hqRemark?: string | null };
|
||||
delivery?: {
|
||||
provider: string;
|
||||
trackingNo: string | null;
|
||||
providerOrderNo: string | null;
|
||||
logisticsCompany?: string | null;
|
||||
manualQueryUrl?: string | null;
|
||||
/** 当次应付物流费(按瓶当量 × 承运商计价) */
|
||||
logisticsFee?: number | null;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -31,9 +31,18 @@ export const ORDER_STATUS_OPERATOR_LABELS: Record<string, string> = {
|
||||
USER_ON_SITE: '用户·现场取货',
|
||||
USER_WECHAT_CONFIRM: '用户·微信确认收货',
|
||||
WECHAT_TRADE_MANAGE: '微信结算同步',
|
||||
WECHAT_PAY: '微信支付',
|
||||
MOCK: 'Mock',
|
||||
MOCK_PAY: 'Mock 支付',
|
||||
SYSTEM: '系统',
|
||||
SYSTEM_AUTO_EXPIRE: '系统·超时取消',
|
||||
PARTNER_PROXY: '合伙人代下单',
|
||||
HQ_PROXY: 'HQ 代操作',
|
||||
HQ_LOGISTICS: 'HQ 物流',
|
||||
WAREHOUSE_MANUAL: '仓库手工',
|
||||
HQ: '总部',
|
||||
STORE: '门店',
|
||||
PARTNER: '合伙人',
|
||||
};
|
||||
|
||||
/** 订单状态 Tag 颜色(Ant Design preset) */
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
import {
|
||||
LEDGER_TYPE_LABELS,
|
||||
ORDER_STATUS_LABELS,
|
||||
ORDER_STATUS_OPERATOR_LABELS,
|
||||
} from './constants';
|
||||
import { HQ_OPERATION_ACTION_LABELS } from './hq-log';
|
||||
import { USER_LOG_CATEGORY_LABELS } from './user-log';
|
||||
import {
|
||||
PARTNER_LOG_CATEGORY_LABELS,
|
||||
HQ_ADMIN_ROLES,
|
||||
resolvePartnerLogCategory,
|
||||
resolveStoreLogCategory,
|
||||
resolveUserLogCategory,
|
||||
STORE_LOG_CATEGORY_LABELS,
|
||||
WECOM_BOT_PERMISSION_LABELS,
|
||||
} from '@dukang/shared-types';
|
||||
|
||||
export function zhLabel(dict: Record<string, string>, value?: string | null, empty = '—'): string {
|
||||
if (value == null || value === '') return empty;
|
||||
return dict[value] ?? value;
|
||||
}
|
||||
|
||||
export const CLIENT_APP_LABELS: Record<string, string> = {
|
||||
USER_MINI: 'C 端小程序',
|
||||
USER_H5: 'C 端 H5',
|
||||
PARTNER_MINI: '合伙人小程序',
|
||||
PARTNER_H5: '合伙人 H5',
|
||||
HQ_MINI: 'HQ 小程序',
|
||||
HQ_WEB: 'HQ 后台',
|
||||
SHOP_H5: '门店 H5',
|
||||
};
|
||||
|
||||
export const REF_TYPE_LABELS: Record<string, string> = {
|
||||
ORDER: '订单',
|
||||
USER: '用户',
|
||||
STORE: '门店',
|
||||
PARTNER: '合伙人',
|
||||
CITY: '城市',
|
||||
PRODUCT: '商品',
|
||||
COUPON: '权益券',
|
||||
TICKET: '工单',
|
||||
SUPPORT_TICKET: '技术支持工单',
|
||||
INVOICE: '发票',
|
||||
PROMO: '推广码',
|
||||
PROMO_CODE: '推广码',
|
||||
HQ: '总部',
|
||||
HQ_ACCOUNT: 'HQ 账号',
|
||||
STORE_ACCOUNT: '门店账号',
|
||||
PARTNER_ACCOUNT: '合伙人账号',
|
||||
PAYOUT: '打款',
|
||||
WITHDRAWAL: '提现',
|
||||
BILL: '账单',
|
||||
DELIVERY: '配送单',
|
||||
REDEEM: '核销',
|
||||
WAREHOUSE: '仓库',
|
||||
PACKAGE: '套餐',
|
||||
};
|
||||
|
||||
export const DOMAIN_EVENT_TYPE_LABELS: Record<string, string> = {
|
||||
ORDER_STATUS: '订单状态',
|
||||
BENEFIT_LEDGER: '权益流水',
|
||||
STORE_AUDIT: '门店审核',
|
||||
TICKET_COLLAB: '工单协作',
|
||||
PROMO_TOUCH: '推广触达',
|
||||
HQ_OPERATION: 'HQ 操作',
|
||||
};
|
||||
|
||||
export const PARAM_DESC_LABELS: Record<string, string> = {
|
||||
from_status: '原状态',
|
||||
to_status: '目标状态',
|
||||
operator: '操作人',
|
||||
ledger_type: '流水类型',
|
||||
coupon_id: '权益券 ID',
|
||||
action: '行为',
|
||||
target_type: '对象类型',
|
||||
target_id: '对象 ID',
|
||||
};
|
||||
|
||||
export const USER_LOG_EVENT_LABELS: Record<string, string> = {
|
||||
login_success: '登录成功',
|
||||
sms_login: '短信登录',
|
||||
sms_send: '发送验证码',
|
||||
sms_verify_fail: '验证码校验失败',
|
||||
session_start: '会话开始',
|
||||
home_view: '浏览首页',
|
||||
product_list_view: '浏览商品列表',
|
||||
product_click: '点击商品',
|
||||
product_detail_view: '浏览商品详情',
|
||||
order_confirm_view: '浏览确认订单',
|
||||
order_submit: '提交订单',
|
||||
order_list_view: '浏览订单列表',
|
||||
order_detail_view: '浏览订单详情',
|
||||
order_cancel: '取消订单',
|
||||
pay_page_view: '进入支付页',
|
||||
pay_success: '支付成功',
|
||||
pay_fail: '支付失败',
|
||||
wechat_login: '微信登录',
|
||||
wechat_phone: '微信授权手机号',
|
||||
wechat_phone_login: '微信手机号登录',
|
||||
wechat_location: '微信定位',
|
||||
wechat_album: '微信选图',
|
||||
wechat_bind: '绑定微信',
|
||||
store_list_view: '浏览门店列表',
|
||||
store_detail_view: '浏览门店详情',
|
||||
benefit_page_view: '浏览权益页',
|
||||
benefit_detail_view: '浏览权益详情',
|
||||
benefit_redeem_start: '开始核销',
|
||||
benefit_redeem_success: '核销成功',
|
||||
redeem_code_view: '查看核销码',
|
||||
redeem_success_view: '核销成功页',
|
||||
profile_update: '修改资料',
|
||||
bind_phone: '绑定手机号',
|
||||
address_list_view: '浏览地址列表',
|
||||
address_edit: '编辑地址',
|
||||
promo_touch: '推广触达',
|
||||
promo_share: '分享推广',
|
||||
cs_contact: '联系客服',
|
||||
after_sale_list_view: '浏览售后列表',
|
||||
after_sale_apply: '申请售后',
|
||||
client_error: '前端异常',
|
||||
};
|
||||
|
||||
export const STORE_LOG_EVENT_LABELS: Record<string, string> = {
|
||||
store_sms_send: '发送验证码',
|
||||
store_sms_login: '短信登录',
|
||||
store_sms_verify_fail: '验证码校验失败',
|
||||
store_login_success: '登录成功',
|
||||
store_select: '选择门店',
|
||||
store_wechat_login: '微信登录',
|
||||
store_wechat_bind: '绑定微信',
|
||||
store_home_view: '浏览首页',
|
||||
store_redeem_entry_view: '进入核销页',
|
||||
store_redeem_confirm_view: '核销确认页',
|
||||
store_phone_redeem_view: '手机号核销页',
|
||||
store_records_view: '浏览核销记录',
|
||||
store_withdraw_view: '浏览提现页',
|
||||
store_packages_view: '浏览套餐页',
|
||||
store_mine_view: '浏览我的',
|
||||
store_staff_view: '浏览子账号',
|
||||
store_redeem_preview: '核销预览',
|
||||
store_redeem_confirm: '确认核销',
|
||||
store_redeem_confirm_fail: '核销失败',
|
||||
store_redeem_weaknet_threshold: '弱网阈值',
|
||||
store_redeem_pending_submit: '提交挂起核销',
|
||||
store_redeem_pending_complete: '完成挂起核销',
|
||||
store_redeem_pending_reject: '驳回挂起核销',
|
||||
store_redeem_phone_lookup_sms: '手机号核销发码',
|
||||
store_redeem_phone_balance: '查询用户权益余额',
|
||||
store_redeem_phone_prepare: '手机号核销准备',
|
||||
store_redeem_scan_start: '扫码核销开始',
|
||||
store_payout_created: '生成打款单',
|
||||
store_payout_paid: '打款完成',
|
||||
store_withdraw_applied: '申请提现',
|
||||
store_withdraw_paid: '提现已打款',
|
||||
store_status_change: '变更营业状态',
|
||||
store_staff_create: '新增子账号',
|
||||
store_staff_update: '编辑子账号',
|
||||
store_staff_delete: '删除子账号',
|
||||
store_staff_permission_update: '更新子账号权限',
|
||||
store_package_apply: '申请套餐',
|
||||
store_package_audit_view: '查看套餐审核',
|
||||
};
|
||||
|
||||
export const PARTNER_LOG_EVENT_LABELS: Record<string, string> = {
|
||||
partner_sms_send: '发送验证码',
|
||||
partner_sms_login: '短信登录',
|
||||
partner_sms_verify_fail: '验证码校验失败',
|
||||
partner_login_success: '登录成功',
|
||||
partner_wechat_login: '微信登录',
|
||||
partner_wechat_bind: '绑定微信',
|
||||
partner_home_view: '浏览首页',
|
||||
partner_store_list_view: '浏览门店列表',
|
||||
partner_store_detail_view: '浏览门店详情',
|
||||
partner_store_create_view: '进入录店页',
|
||||
partner_order_list_view: '浏览订单列表',
|
||||
partner_order_detail_view: '浏览订单详情',
|
||||
partner_proxy_order_view: '进入代下单页',
|
||||
partner_bills_view: '浏览账单列表',
|
||||
partner_bill_detail_view: '浏览账单详情',
|
||||
partner_staff_list_view: '浏览子账号',
|
||||
partner_leaderboard_view: '浏览排行榜',
|
||||
partner_weekly_report_view: '浏览周报',
|
||||
partner_staff_create: '新增子账号',
|
||||
partner_staff_sms_send: '子账号发验证码',
|
||||
partner_staff_sms_verify_fail: '子账号验证码失败',
|
||||
partner_staff_update: '编辑子账号',
|
||||
partner_staff_delete: '删除子账号',
|
||||
partner_staff_permission_update: '更新子账号权限',
|
||||
partner_store_create: '录入门店',
|
||||
partner_store_status_change: '变更门店状态',
|
||||
partner_store_audit_approved: '门店审核通过',
|
||||
partner_store_audit_rejected: '门店审核驳回',
|
||||
partner_order_ship: '订单发货',
|
||||
partner_delivery_advance: '推进配送',
|
||||
partner_proxy_order_create: '代下单',
|
||||
partner_bill_view: '查看账单',
|
||||
partner_bill_confirm: '确认账单',
|
||||
partner_warehouse_view: '浏览仓库',
|
||||
partner_warehouse_update: '更新仓库',
|
||||
};
|
||||
|
||||
export const EVENT_NAME_LABELS: Record<string, string> = {
|
||||
...USER_LOG_EVENT_LABELS,
|
||||
...STORE_LOG_EVENT_LABELS,
|
||||
...PARTNER_LOG_EVENT_LABELS,
|
||||
};
|
||||
|
||||
export const THIRD_PARTY_PROVIDER_LABELS: Record<string, string> = {
|
||||
WECHAT_AUTH: '微信授权',
|
||||
WECHAT_PAY: '微信支付',
|
||||
WECHAT_REFUND: '微信退款',
|
||||
WECHAT_MAP: '微信/腾讯地图',
|
||||
ALIYUN_OSS: '阿里云 OSS',
|
||||
ALIYUN_SMS: '阿里云短信',
|
||||
MOCK_SMS: 'Mock 短信',
|
||||
SMS: '短信',
|
||||
XFX: '小飞侠',
|
||||
LOGISTICS: '物流快递',
|
||||
MANUAL: '手动',
|
||||
};
|
||||
|
||||
export const THIRD_PARTY_STATUS_LABELS: Record<string, string> = {
|
||||
SUCCESS: '成功',
|
||||
FAILED: '失败',
|
||||
PENDING: '处理中',
|
||||
};
|
||||
|
||||
export const THIRD_PARTY_SCENE_LABELS: Record<string, string> = {
|
||||
LOGIN: '登录',
|
||||
USERINFO: '用户信息',
|
||||
JSSDK_CONFIG: 'JSSDK 配置',
|
||||
BIND_PHONE: '绑定手机号',
|
||||
GET_LOCATION: '获取定位',
|
||||
CHOOSE_IMAGE: '选择图片',
|
||||
ORDER_PAY: '订单支付',
|
||||
ORDER_REFUND: '订单退款',
|
||||
UPLOAD_SHIPPING: '上传发货信息',
|
||||
TRADE_MANAGE_PUSH: '交易结算推送',
|
||||
ORDER_DISPATCH: '配送下单',
|
||||
ORDER_DISPATCH_HOLD: '配送暂不下发',
|
||||
TRACK_CALLBACK: '物流回调',
|
||||
UPLOAD_TOKEN: '上传凭证',
|
||||
UPLOAD_PUT_OBJECT: '上传文件',
|
||||
GEOCODE: '地理编码',
|
||||
REVERSE_GEOCODE: '逆地理编码',
|
||||
};
|
||||
|
||||
export const WECOM_BOT_ACTION_LABELS: Record<string, string> = {
|
||||
...WECOM_BOT_PERMISSION_LABELS,
|
||||
'user.read_sms.start': '查询用户·发送验证码',
|
||||
'user.read_sms.verify': '查询用户·校验验证码',
|
||||
};
|
||||
|
||||
export const GENERIC_STATUS_LABELS: Record<string, string> = {
|
||||
...ORDER_STATUS_LABELS,
|
||||
...LEDGER_TYPE_LABELS,
|
||||
...THIRD_PARTY_STATUS_LABELS,
|
||||
PENDING: '待处理',
|
||||
APPROVED: '已通过',
|
||||
REJECTED: '已驳回',
|
||||
ACTIVE: '正常',
|
||||
DISABLED: '停用',
|
||||
SUCCESS: '成功',
|
||||
FAILED: '失败',
|
||||
OPEN: '营业中',
|
||||
PAUSED: '已暂停',
|
||||
CLOSED: '已关闭',
|
||||
};
|
||||
|
||||
export const HQ_ROLE_LABELS: Record<string, string> = Object.fromEntries(
|
||||
HQ_ADMIN_ROLES.map((r) => [r.value, r.label]),
|
||||
);
|
||||
|
||||
const CODE_ZH: Record<string, string> = {
|
||||
...CLIENT_APP_LABELS,
|
||||
...REF_TYPE_LABELS,
|
||||
...DOMAIN_EVENT_TYPE_LABELS,
|
||||
...EVENT_NAME_LABELS,
|
||||
...ORDER_STATUS_LABELS,
|
||||
...ORDER_STATUS_OPERATOR_LABELS,
|
||||
...LEDGER_TYPE_LABELS,
|
||||
...HQ_OPERATION_ACTION_LABELS,
|
||||
...HQ_ROLE_LABELS,
|
||||
...THIRD_PARTY_PROVIDER_LABELS,
|
||||
...THIRD_PARTY_STATUS_LABELS,
|
||||
...THIRD_PARTY_SCENE_LABELS,
|
||||
...WECOM_BOT_ACTION_LABELS,
|
||||
...GENERIC_STATUS_LABELS,
|
||||
...PARAM_DESC_LABELS,
|
||||
};
|
||||
|
||||
export function zhCode(value?: string | null, empty = '—'): string {
|
||||
if (value == null || value === '') return empty;
|
||||
return CODE_ZH[value] ?? value;
|
||||
}
|
||||
|
||||
export function eventNameLabel(value?: string | null): string {
|
||||
return zhLabel(EVENT_NAME_LABELS, value);
|
||||
}
|
||||
|
||||
export function clientAppLabel(value?: string | null): string {
|
||||
return zhLabel(CLIENT_APP_LABELS, value);
|
||||
}
|
||||
|
||||
export function formatRef(refType?: string | null, refId?: string | null): string {
|
||||
if (!refType && !refId) return '—';
|
||||
const type = zhLabel(REF_TYPE_LABELS, refType, refType || '');
|
||||
return refId ? `${type} #${refId}` : type;
|
||||
}
|
||||
|
||||
export function userEventCategoryLabel(eventName: string, category?: string | null): string {
|
||||
const key = category || resolveUserLogCategory(eventName);
|
||||
if (key && USER_LOG_CATEGORY_LABELS[key]) return USER_LOG_CATEGORY_LABELS[key];
|
||||
return '其他';
|
||||
}
|
||||
|
||||
export function storeEventCategoryLabel(eventName: string, category?: string | null): string {
|
||||
const key = category || resolveStoreLogCategory(eventName);
|
||||
const labels = STORE_LOG_CATEGORY_LABELS as Record<string, string>;
|
||||
if (key && labels[key]) return labels[key];
|
||||
return '其他';
|
||||
}
|
||||
|
||||
export function partnerEventCategoryLabel(eventName: string, category?: string | null): string {
|
||||
const key = category || resolvePartnerLogCategory(eventName);
|
||||
const labels = PARTNER_LOG_CATEGORY_LABELS as Record<string, string>;
|
||||
if (key && labels[key]) return labels[key];
|
||||
return '其他';
|
||||
}
|
||||
|
||||
export function domainParamFieldLabel(desc?: string | null, fallbackIndex?: 1 | 2 | 3): string {
|
||||
if (desc && PARAM_DESC_LABELS[desc]) return PARAM_DESC_LABELS[desc];
|
||||
if (fallbackIndex) return `参数${fallbackIndex}`;
|
||||
return '参数';
|
||||
}
|
||||
|
||||
export function zhRemark(value?: string | null): string {
|
||||
if (!value) return '—';
|
||||
return value
|
||||
.replace(/partnerAccountId=/g, '合伙人账号=')
|
||||
.replace(/hqAccountId=/g, 'HQ账号=')
|
||||
.replace(/deliveryMode=/g, '履约方式=')
|
||||
.replace(/\bmode=/g, '履约方式=')
|
||||
.replace(/customer=/g, '客户=')
|
||||
.replace(/\bON_SITE_PICKUP\b/g, '现场提货')
|
||||
.replace(/\bCROSS_CITY\b/g, '跨城')
|
||||
.replace(/\bLOCAL\b/g, '同城');
|
||||
}
|
||||
|
||||
export function domainParamValue(desc?: string | null, value?: string | null): string {
|
||||
if (value == null || value === '') return '—';
|
||||
if (desc === 'from_status' || desc === 'to_status') return zhLabel(ORDER_STATUS_LABELS, value);
|
||||
if (desc === 'operator') return zhLabel(ORDER_STATUS_OPERATOR_LABELS, value);
|
||||
if (desc === 'ledger_type') return zhLabel(LEDGER_TYPE_LABELS, value);
|
||||
if (desc === 'action') return zhLabel(HQ_OPERATION_ACTION_LABELS, value);
|
||||
if (desc === 'target_type') return zhLabel(REF_TYPE_LABELS, value);
|
||||
return zhCode(value);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ export const HQ_OPERATION_ACTION_OPTIONS = [
|
||||
{ value: 'HQ_ACCOUNT_CREATE', label: '新增 HQ 管理员' },
|
||||
{ value: 'HQ_ACCOUNT_UPDATE', label: '编辑 HQ 管理员' },
|
||||
{ value: 'HQ_PERMISSION_UPDATE', label: '配置 HQ 权限' },
|
||||
{ value: 'USER_ASSOC_UPDATE', label: '修改用户关联合伙人' },
|
||||
{ value: 'USER_DELETE', label: '删除用户' },
|
||||
{ value: 'USER_BATCH_DELETE', label: '批量删除用户' },
|
||||
{ value: 'ORDER_SHIP', label: '订单发货' },
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/** 表单选填项常为 null,PUT 时去掉以免后端对 null 调 trim */
|
||||
export function omitNullFields<T extends Record<string, unknown>>(input: T): Partial<T> {
|
||||
const out: Partial<T> = {};
|
||||
for (const [key, value] of Object.entries(input)) {
|
||||
if (value === null || value === undefined) continue;
|
||||
(out as Record<string, unknown>)[key] = value;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
Button,
|
||||
Descriptions,
|
||||
@@ -111,9 +111,16 @@ type CouponDetail = Row & {
|
||||
|
||||
export default function BenefitCouponsPage() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const [searchParams] = useSearchParams();
|
||||
const initialCouponNo = searchParams.get('couponNo')?.trim() || '';
|
||||
const [form] = Form.useForm();
|
||||
const [grantForm] = Form.useForm<AdminBenefitGrantRequest>();
|
||||
const [filters, setFilters] = useState<Record<string, string>>({});
|
||||
const [filters, setFilters] = useState<Record<string, string>>(() => {
|
||||
const init: Record<string, string> = {};
|
||||
if (initialCouponNo) init.couponNo = initialCouponNo;
|
||||
return init;
|
||||
});
|
||||
const [grantOpen, setGrantOpen] = useState(false);
|
||||
const [granting, setGranting] = useState(false);
|
||||
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<Row>(
|
||||
@@ -132,6 +139,35 @@ export default function BenefitCouponsPage() {
|
||||
const [redeemDetail, setRedeemDetail] = useState<Record<string, unknown> | null>(null);
|
||||
const [redeemDrawerOpen, setRedeemDrawerOpen] = useState(false);
|
||||
const [redeemDetailLoading, setRedeemDetailLoading] = useState(false);
|
||||
const deepLinkOpenedRef = useRef(false);
|
||||
|
||||
async function openCouponDetail(id: string) {
|
||||
setDetail(await request<CouponDetail>(`/admin/benefit/coupons/${id}`));
|
||||
setDrawerOpen(true);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (initialCouponNo) form.setFieldsValue({ couponNo: initialCouponNo });
|
||||
}, [form, initialCouponNo]);
|
||||
|
||||
useEffect(() => {
|
||||
const openCouponId = (location.state as { openCouponId?: string } | null)?.openCouponId;
|
||||
if (openCouponId && !deepLinkOpenedRef.current) {
|
||||
deepLinkOpenedRef.current = true;
|
||||
void openCouponDetail(openCouponId).catch((e) => {
|
||||
message.error(e instanceof Error ? e.message : '加载权益券失败');
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!initialCouponNo || deepLinkOpenedRef.current || loading) return;
|
||||
const first = data?.items?.[0];
|
||||
if (first && String(first.couponNo) === initialCouponNo) {
|
||||
deepLinkOpenedRef.current = true;
|
||||
void openCouponDetail(first.id).catch((e) => {
|
||||
message.error(e instanceof Error ? e.message : '加载权益券失败');
|
||||
});
|
||||
}
|
||||
}, [data, initialCouponNo, loading, location.state]);
|
||||
|
||||
async function openRedeemDetail(redeemId: string) {
|
||||
setRedeemDetailLoading(true);
|
||||
@@ -154,12 +190,7 @@ export default function BenefitCouponsPage() {
|
||||
width: 200,
|
||||
ellipsis: false,
|
||||
render: (v, row) => (
|
||||
<AdminPrimaryLink
|
||||
onClick={async () => {
|
||||
setDetail(await request(`/admin/benefit/coupons/${row.id}`));
|
||||
setDrawerOpen(true);
|
||||
}}
|
||||
>
|
||||
<AdminPrimaryLink onClick={() => void openCouponDetail(row.id)}>
|
||||
{v}
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
@@ -211,10 +242,7 @@ export default function BenefitCouponsPage() {
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={async () => {
|
||||
setDetail(await request(`/admin/benefit/coupons/${row.id}`));
|
||||
setDrawerOpen(true);
|
||||
}}
|
||||
onClick={() => void openCouponDetail(row.id)}
|
||||
>
|
||||
详情
|
||||
</Button>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
||||
import { request } from '../lib/api';
|
||||
import bgmSrc from '../assets/big-screen/dukang-bgm.mp3';
|
||||
import sfxTier1 from '../assets/big-screen/celebrate-t1.mp3';
|
||||
import sfxTier2 from '../assets/big-screen/celebrate-t2.mp3';
|
||||
import sfxTier3 from '../assets/big-screen/celebrate-t3.mp3';
|
||||
@@ -33,6 +34,50 @@ const CELEBRATE_SFX: Record<AmountTier, string> = {
|
||||
/** 浏览器自动播放策略:需用户手势后才能出声 */
|
||||
let audioUnlocked = false;
|
||||
const sharedAudio = typeof Audio !== 'undefined' ? new Audio() : null;
|
||||
const BGM_VOLUME = 0.32;
|
||||
const BGM_DUCK_VOLUME = 0.08;
|
||||
let bgmAudio: HTMLAudioElement | null = null;
|
||||
let bgmDucked = false;
|
||||
|
||||
function getBgmAudio(): HTMLAudioElement | null {
|
||||
if (typeof Audio === 'undefined') return null;
|
||||
if (!bgmAudio) {
|
||||
bgmAudio = new Audio(bgmSrc);
|
||||
bgmAudio.loop = true;
|
||||
bgmAudio.preload = 'auto';
|
||||
bgmAudio.volume = BGM_VOLUME;
|
||||
}
|
||||
return bgmAudio;
|
||||
}
|
||||
|
||||
function applyBgmVolume() {
|
||||
if (!bgmAudio) return;
|
||||
bgmAudio.volume = bgmDucked ? BGM_DUCK_VOLUME : BGM_VOLUME;
|
||||
}
|
||||
|
||||
function duckBgm() {
|
||||
bgmDucked = true;
|
||||
applyBgmVolume();
|
||||
}
|
||||
|
||||
function unduckBgm() {
|
||||
bgmDucked = false;
|
||||
applyBgmVolume();
|
||||
}
|
||||
|
||||
function setBgmPlaying(on: boolean): Promise<boolean> {
|
||||
const audio = getBgmAudio();
|
||||
if (!audio) return Promise.resolve(false);
|
||||
applyBgmVolume();
|
||||
if (!on) {
|
||||
audio.pause();
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
return audio
|
||||
.play()
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
}
|
||||
|
||||
function unlockCelebrateAudio() {
|
||||
if (audioUnlocked || !sharedAudio) return;
|
||||
@@ -53,6 +98,7 @@ function unlockCelebrateAudio() {
|
||||
|
||||
function playCelebrateSfx(tier: AmountTier): () => void {
|
||||
if (!sharedAudio) return () => undefined;
|
||||
duckBgm();
|
||||
try {
|
||||
sharedAudio.pause();
|
||||
sharedAudio.currentTime = 0;
|
||||
@@ -72,6 +118,7 @@ function playCelebrateSfx(tier: AmountTier): () => void {
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
unduckBgm();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -341,10 +388,40 @@ function CelebrateFx({ order, onDone }: { order: BigScreenOrder; onDone: () => v
|
||||
);
|
||||
}
|
||||
|
||||
function BgmToggleButton({ on, onToggle }: { on: boolean; onToggle: () => void }) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`big-screen-bgm${on ? ' is-on' : ''}`}
|
||||
onClick={onToggle}
|
||||
aria-pressed={on}
|
||||
aria-label={on ? '暂停背景音乐' : '播放背景音乐'}
|
||||
>
|
||||
<span className="big-screen-bgm-icon" aria-hidden>
|
||||
{on ? (
|
||||
<svg viewBox="0 0 24 24" width="16" height="16">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M9 18V6h2v12H9zm4 0V6h2v12h-2z"
|
||||
/>
|
||||
</svg>
|
||||
) : (
|
||||
<svg viewBox="0 0 24 24" width="16" height="16">
|
||||
<path fill="currentColor" d="M8 5.14v13.72L19.06 12 8 5.14z" />
|
||||
</svg>
|
||||
)}
|
||||
</span>
|
||||
{on ? 'BGM 播放中' : '播放 BGM'}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default function BigScreenPage() {
|
||||
const [items, setItems] = useState<BigScreenOrder[]>([]);
|
||||
const [loadError, setLoadError] = useState('');
|
||||
const [paused, setPaused] = useState(false);
|
||||
const [bgmOn, setBgmOn] = useState(false);
|
||||
const bgmWantedRef = useRef(false);
|
||||
const [celebrate, setCelebrate] = useState<BigScreenOrder | null>(null);
|
||||
const seenIdsRef = useRef<Set<string> | null>(null);
|
||||
const celebratedIdsRef = useRef<Set<string>>(new Set());
|
||||
@@ -416,6 +493,22 @@ export default function BigScreenPage() {
|
||||
return () => clearInterval(id);
|
||||
}, [fetchData]);
|
||||
|
||||
const toggleBgm = useCallback(() => {
|
||||
unlockCelebrateAudio();
|
||||
const next = !bgmWantedRef.current;
|
||||
bgmWantedRef.current = next;
|
||||
if (!next) {
|
||||
void setBgmPlaying(false);
|
||||
setBgmOn(false);
|
||||
return;
|
||||
}
|
||||
setBgmOn(true);
|
||||
void setBgmPlaying(true).then((playing) => {
|
||||
if (!bgmWantedRef.current) return;
|
||||
setBgmOn(playing);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
unlockCelebrateAudio();
|
||||
const unlock = () => unlockCelebrateAudio();
|
||||
@@ -424,6 +517,8 @@ export default function BigScreenPage() {
|
||||
return () => {
|
||||
window.removeEventListener('pointerdown', unlock);
|
||||
window.removeEventListener('keydown', unlock);
|
||||
bgmWantedRef.current = false;
|
||||
void setBgmPlaying(false);
|
||||
};
|
||||
}, []);
|
||||
|
||||
@@ -480,6 +575,7 @@ export default function BigScreenPage() {
|
||||
<span className="big-screen-subtitle">· 发布会现场</span>
|
||||
</div>
|
||||
<div className="big-screen-live-wrap">
|
||||
<BgmToggleButton on={bgmOn} onToggle={toggleBgm} />
|
||||
<span className="big-screen-live-label">实时成交</span>
|
||||
<span className="big-screen-live">
|
||||
<span className="big-screen-live-dot" />
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
|
||||
import {
|
||||
Button,
|
||||
Descriptions,
|
||||
Divider,
|
||||
Drawer,
|
||||
Form,
|
||||
Input,
|
||||
@@ -362,8 +363,28 @@ export default function CitiesPage() {
|
||||
<Form.Item name="status" label="状态">
|
||||
<Select options={Object.entries(CITY_STATUS_LABELS).map(([value, label]) => ({ value, label }))} />
|
||||
</Form.Item>
|
||||
<Form.Item name="localMinQty" label="同城起购"><InputNumber min={1} style={{ width: '100%' }} /></Form.Item>
|
||||
<Form.Item name="crossMinQty" label="跨城起购"><InputNumber min={1} style={{ width: '100%' }} /></Form.Item>
|
||||
<Divider orientation="left">履约起购</Divider>
|
||||
<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
|
||||
name="maxPartnerCommissionPercent"
|
||||
label="合伙人佣金合计上限 %"
|
||||
|
||||
@@ -31,11 +31,13 @@ import {
|
||||
type PartnerPermissionKey,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { omitNullFields } from '../lib/omit-null-fields';
|
||||
import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
|
||||
import PartnerSubAccountList, { type PartnerSubAccountRow } from '../components/PartnerSubAccountList';
|
||||
import PartnerAssocPanel from '../components/PartnerAssocPanel';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
@@ -60,6 +62,7 @@ type Row = {
|
||||
managedWarehouseName?: string | null;
|
||||
maxPartnerCommissionRate?: number | null;
|
||||
storeCount: number;
|
||||
assocUserCount?: number;
|
||||
accountCount: number;
|
||||
subAccounts?: SubRow[];
|
||||
createdAt: string;
|
||||
@@ -209,7 +212,7 @@ export default function CityPartnersPage() {
|
||||
await request(`/admin/partners/${detail.id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
...v,
|
||||
...omitNullFields(v),
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: editScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
@@ -332,6 +335,19 @@ export default function CityPartnersPage() {
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '关联用户',
|
||||
dataIndex: 'assocUserCount',
|
||||
width: 80,
|
||||
render: (n: number, row) => (
|
||||
<Link
|
||||
to={`/users?assocPartnerAccountId=${encodeURIComponent(row.id)}`}
|
||||
title={`查看「${row.companyName || row.phone}」关联用户`}
|
||||
>
|
||||
{n ?? 0}
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{ title: '子账号', dataIndex: 'accountCount', width: 70, render: (n) => Math.max(0, n - 1) },
|
||||
{ title: '创建', dataIndex: 'createdAt', width: 150, render: fmtTime },
|
||||
{
|
||||
@@ -355,7 +371,9 @@ export default function CityPartnersPage() {
|
||||
title="城市合伙人"
|
||||
settings={settingsButton}
|
||||
actions={
|
||||
<Button
|
||||
<>
|
||||
<Link to="/users?assocPartnerAccountId=any">全部关联用户</Link>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
createForm.resetFields();
|
||||
@@ -372,6 +390,7 @@ export default function CityPartnersPage() {
|
||||
>
|
||||
新建合伙人
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -486,6 +505,14 @@ export default function CityPartnersPage() {
|
||||
{detail.storeCount ?? 0}
|
||||
</Link>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="关联用户">
|
||||
<Link
|
||||
to={`/users?assocPartnerAccountId=${encodeURIComponent(detail.id)}`}
|
||||
title="查看该城市合伙人关联用户"
|
||||
>
|
||||
{detail.assocUserCount ?? 0}
|
||||
</Link>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="管仓仓库" span={2}>
|
||||
{detail.managedWarehouseName ?? (
|
||||
<Typography.Text type="secondary">
|
||||
@@ -570,6 +597,11 @@ export default function CityPartnersPage() {
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'assoc',
|
||||
label: '关联码',
|
||||
children: <PartnerAssocPanel partnerId={detail.id} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -1,16 +1,43 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Button, Descriptions, Drawer, Form, Input, Space, Table, Typography, message,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import OrderTrackDrawer from '../components/OrderTrackDrawer';
|
||||
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 { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
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 = {
|
||||
id: string;
|
||||
@@ -19,19 +46,34 @@ type Row = {
|
||||
trackingNo: string | null;
|
||||
providerOrderNo: string | null;
|
||||
updatedAt: string;
|
||||
/** 当次应付物流费 */
|
||||
logisticsFee?: number | null;
|
||||
order?: {
|
||||
id: string;
|
||||
orderNo: string;
|
||||
status: string;
|
||||
receiverName: string;
|
||||
receiverPhone: string;
|
||||
deliveryType: string;
|
||||
};
|
||||
order?: DeliveryOrder;
|
||||
};
|
||||
|
||||
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() {
|
||||
const navigate = useNavigate();
|
||||
const [form] = Form.useForm();
|
||||
const [editForm] = Form.useForm();
|
||||
const [filters, setFilters] = useState<Record<string, string>>({});
|
||||
@@ -65,25 +107,91 @@ export default function DeliveriesPage() {
|
||||
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> = [
|
||||
{
|
||||
title: '订单号',
|
||||
dataIndex: ['order', 'orderNo'],
|
||||
width: 170,
|
||||
render: (v, row) => (
|
||||
<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>
|
||||
<AdminPrimaryLink onClick={() => void openDetail(row)}>{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: '运费',
|
||||
@@ -92,20 +200,33 @@ export default function DeliveriesPage() {
|
||||
render: (v: number | null | undefined) => (v == null ? '—' : `¥${Number(v).toFixed(2)}`),
|
||||
},
|
||||
{ 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', '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: '操作', width: 140,
|
||||
render: (_, row) => (
|
||||
<Space size={0}>
|
||||
<Button type="link" size="small" onClick={() => openTrack(row)}>路由</Button>
|
||||
<Button type="link" size="small" 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);
|
||||
}}>编辑</Button>
|
||||
<Button type="link" size="small" onClick={() => void openDetail(row)}>编辑</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -113,19 +234,21 @@ export default function DeliveriesPage() {
|
||||
|
||||
const { columns, settingsButton, settingsModal } = useAdminListColumns('deliveries', baseColumns, { page, pageSize });
|
||||
|
||||
const order = detail?.order;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{settingsModal}
|
||||
<AdminListHeader title="快递/配送单" settings={settingsButton} />
|
||||
<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="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><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
||||
</Form>
|
||||
<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); } }} />
|
||||
<Drawer title="配送单编辑" width={480} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||
<Drawer title="配送单编辑" width={560} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||
extra={
|
||||
<Space>
|
||||
<Button onClick={() => setDrawerOpen(false)}>取消</Button>
|
||||
@@ -142,14 +265,63 @@ export default function DeliveriesPage() {
|
||||
{detail && (
|
||||
<>
|
||||
<Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}>
|
||||
<Descriptions.Item label="订单">{detail.order?.orderNo}</Descriptions.Item>
|
||||
<Descriptions.Item label="收货">{detail.order?.receiverName} {detail.order?.receiverPhone}</Descriptions.Item>
|
||||
<Descriptions.Item label="订单">{order?.orderNo || '—'}</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>
|
||||
<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="trackingNo" label="运单号"><Input /></Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -71,11 +71,11 @@ export default function DevPlanTasksPage() {
|
||||
const [batchForm] = Form.useForm<{ status?: DevPlanTaskStatusDto; versionId?: string }>();
|
||||
|
||||
useEffect(() => {
|
||||
if (!batchEditOpen) return;
|
||||
if (!modalOpen && !batchEditOpen) return;
|
||||
request<{ items: DevPlanVersionDto[] }>('/admin/dev-plan/versions?pageSize=100')
|
||||
.then((res) => setVersions(res.items ?? []))
|
||||
.catch(() => setVersions([]));
|
||||
}, [batchEditOpen]);
|
||||
}, [modalOpen, batchEditOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!modalOpen || editing) return;
|
||||
@@ -108,6 +108,7 @@ export default function DevPlanTasksPage() {
|
||||
content: row.content,
|
||||
type: row.type,
|
||||
status: row.status,
|
||||
versionIds: row.versionIds?.length ? row.versionIds : row.versions?.map((v) => v.id) ?? [],
|
||||
attachmentUrls: row.attachmentUrls?.length ? row.attachmentUrls : [''],
|
||||
});
|
||||
setModalOpen(true);
|
||||
@@ -121,7 +122,11 @@ export default function DevPlanTasksPage() {
|
||||
if (editing) {
|
||||
await request(`/admin/dev-plan/tasks/${editing.id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ ...values, attachmentUrls }),
|
||||
body: JSON.stringify({
|
||||
...values,
|
||||
attachmentUrls,
|
||||
versionIds: values.versionIds ?? [],
|
||||
}),
|
||||
});
|
||||
message.success('已更新');
|
||||
} else {
|
||||
@@ -285,6 +290,21 @@ export default function DevPlanTasksPage() {
|
||||
),
|
||||
},
|
||||
{ title: '来源工单', dataIndex: 'supportTicketNo', width: 140, render: (v) => v || '—' },
|
||||
{
|
||||
title: '关联版本',
|
||||
dataIndex: 'versions',
|
||||
width: 140,
|
||||
render: (_, row) =>
|
||||
row.versions?.length ? (
|
||||
<Space size={4} wrap>
|
||||
{row.versions.map((v) => (
|
||||
<Tag key={v.id}>{v.versionNo}</Tag>
|
||||
))}
|
||||
</Space>
|
||||
) : (
|
||||
'—'
|
||||
),
|
||||
},
|
||||
{ title: '创建人', dataIndex: 'creatorName', width: 90 },
|
||||
{ title: '创建时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||
{
|
||||
@@ -405,9 +425,21 @@ export default function DevPlanTasksPage() {
|
||||
<Select options={TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
{editing ? (
|
||||
<Form.Item name="status" label="状态" rules={[{ required: true }]}>
|
||||
<Select options={STATUS_OPTIONS} />
|
||||
</Form.Item>
|
||||
<>
|
||||
<Form.Item name="status" label="状态" rules={[{ required: true }]}>
|
||||
<Select options={STATUS_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="versionIds" label="关联版本">
|
||||
<Select
|
||||
mode="multiple"
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="可选:关联版本"
|
||||
options={versions.map((v) => ({ value: v.id, label: v.versionNo }))}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
) : (
|
||||
<Form.Item name="supportTicketId" label="绑定技术支持工单">
|
||||
<Select
|
||||
|
||||
@@ -4,6 +4,14 @@ import { Card, Descriptions, Drawer, Select, Space, Table, Tag } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { request } from '../lib/api';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import {
|
||||
DOMAIN_EVENT_TYPE_LABELS,
|
||||
domainParamFieldLabel,
|
||||
domainParamValue,
|
||||
formatRef,
|
||||
zhCode,
|
||||
zhLabel,
|
||||
} from '../lib/display-labels';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
|
||||
@@ -15,8 +23,11 @@ type Row = {
|
||||
refId: string;
|
||||
status?: string | null;
|
||||
param1?: string | null;
|
||||
param1Desc?: string | null;
|
||||
param2?: string | null;
|
||||
param2Desc?: string | null;
|
||||
param3?: string | null;
|
||||
param3Desc?: string | null;
|
||||
remark?: string | null;
|
||||
createdAt: string;
|
||||
};
|
||||
@@ -70,13 +81,18 @@ export default function DomainEventsPage() {
|
||||
setDetail(await request<Row>(`/admin/logs/domain-events/${r.id}`));
|
||||
}}
|
||||
>
|
||||
<Tag>{v}</Tag>
|
||||
<Tag>{zhLabel(DOMAIN_EVENT_TYPE_LABELS, v)}</Tag>
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
},
|
||||
{ title: '关联', render: (_, r) => `${r.refType} #${r.refId}` },
|
||||
{ title: '状态', dataIndex: 'status', width: 100 },
|
||||
{ title: '摘要', render: (_, r) => r.param1 || r.remark || '—' },
|
||||
{ title: '关联', render: (_, r) => formatRef(r.refType, r.refId) },
|
||||
{ title: '状态', dataIndex: 'status', width: 100, render: (v) => zhCode(v) },
|
||||
{
|
||||
title: '摘要',
|
||||
render: (_, r) => domainParamValue(r.param1Desc, r.param1) !== '—'
|
||||
? domainParamValue(r.param1Desc, r.param1)
|
||||
: (r.remark || '—'),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
@@ -133,11 +149,18 @@ export default function DomainEventsPage() {
|
||||
{detail && (
|
||||
<Descriptions column={1} size="small">
|
||||
<Descriptions.Item label="ID">{detail.id}</Descriptions.Item>
|
||||
<Descriptions.Item label="类型">{detail.eventType}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联">{`${detail.refType} #${detail.refId}`}</Descriptions.Item>
|
||||
<Descriptions.Item label="param1">{detail.param1}</Descriptions.Item>
|
||||
<Descriptions.Item label="param2">{detail.param2}</Descriptions.Item>
|
||||
<Descriptions.Item label="param3">{detail.param3}</Descriptions.Item>
|
||||
<Descriptions.Item label="类型">{zhLabel(DOMAIN_EVENT_TYPE_LABELS, detail.eventType)}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联">{formatRef(detail.refType, detail.refId)}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">{zhCode(detail.status)}</Descriptions.Item>
|
||||
<Descriptions.Item label={domainParamFieldLabel(detail.param1Desc, 1)}>
|
||||
{domainParamValue(detail.param1Desc, detail.param1)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={domainParamFieldLabel(detail.param2Desc, 2)}>
|
||||
{domainParamValue(detail.param2Desc, detail.param2)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={domainParamFieldLabel(detail.param3Desc, 3)}>
|
||||
{domainParamValue(detail.param3Desc, detail.param3)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="备注">{detail.remark}</Descriptions.Item>
|
||||
<Descriptions.Item label="时间">{fmtTime(detail.createdAt)}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
@@ -68,7 +69,10 @@ export default function FulfillmentProvidersPage() {
|
||||
setLoading(true);
|
||||
try {
|
||||
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 {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -94,6 +98,7 @@ export default function FulfillmentProvidersPage() {
|
||||
extraBottleFee: DEFAULT_XFX_LOGISTICS_PRICING.extraBottleFee,
|
||||
boxBottles: DEFAULT_XFX_LOGISTICS_PRICING.boxBottles,
|
||||
boxFee: DEFAULT_XFX_LOGISTICS_PRICING.boxFee,
|
||||
deliveryHintHtml: '',
|
||||
});
|
||||
setOpen(true);
|
||||
}
|
||||
@@ -122,6 +127,7 @@ export default function FulfillmentProvidersPage() {
|
||||
extraBottleFee: pricing?.extraBottleFee ?? DEFAULT_XFX_LOGISTICS_PRICING.extraBottleFee,
|
||||
boxBottles: pricing?.boxBottles ?? DEFAULT_XFX_LOGISTICS_PRICING.boxBottles,
|
||||
boxFee: pricing?.boxFee ?? DEFAULT_XFX_LOGISTICS_PRICING.boxFee,
|
||||
deliveryHintHtml: row.deliveryHintHtml || '',
|
||||
});
|
||||
setOpen(true);
|
||||
}
|
||||
@@ -144,6 +150,7 @@ export default function FulfillmentProvidersPage() {
|
||||
boxBottles: v.boxBottles != null ? Number(v.boxBottles) : undefined,
|
||||
boxFee: v.boxFee != null ? Number(v.boxFee) : undefined,
|
||||
},
|
||||
deliveryHintHtml: v.deliveryHintHtml?.trim() || null,
|
||||
};
|
||||
|
||||
if (isXfxProviderCode(String(v.code)) && v.type === FulfillmentProviderType.API) {
|
||||
@@ -176,6 +183,16 @@ export default function FulfillmentProvidersPage() {
|
||||
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> = [
|
||||
{ title: '编码', dataIndex: 'code', width: 100 },
|
||||
{
|
||||
@@ -230,11 +247,23 @@ export default function FulfillmentProvidersPage() {
|
||||
{ title: '更新时间', dataIndex: 'updatedAt', width: 170, render: fmtTime },
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
width: 140,
|
||||
render: (_, row) => (
|
||||
<Button type="link" size="small" onClick={() => openEdit(row)}>
|
||||
编辑
|
||||
</Button>
|
||||
<Space size={0}>
|
||||
<Button type="link" size="small" onClick={() => openEdit(row)}>
|
||||
编辑
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title={`确认删除承运商「${row.name}」?`}
|
||||
okText="删除"
|
||||
okButtonProps={{ danger: true }}
|
||||
onConfirm={() => void remove(row)}
|
||||
>
|
||||
<Button type="link" size="small" danger>
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
@@ -288,6 +317,17 @@ export default function FulfillmentProvidersPage() {
|
||||
<Form.Item name="status" label="状态" rules={[{ required: true }]}>
|
||||
<Select options={STATUS_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="deliveryHintHtml"
|
||||
label="配送信息提示"
|
||||
extra="C 端同城送展示。支持 HTML:span/p/br/b/strong/i/em/font,style 可用 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>
|
||||
<Form.Item name="settlementMethod" label="结算方式" rules={[{ required: true }]}>
|
||||
@@ -309,6 +349,7 @@ export default function FulfillmentProvidersPage() {
|
||||
<Form.Item
|
||||
name="baseBottles"
|
||||
label="起送瓶数"
|
||||
extra="物流计价起步瓶数,不影响用户起购(起购在城市管理)"
|
||||
rules={[{ required: true }]}
|
||||
style={{ marginBottom: 12 }}
|
||||
>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useSearchParams } from 'react-router-dom';
|
||||
import { request } from '../lib/api';
|
||||
import { AdminCellLine } from '../components/AdminCellLine';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import { formatRef, zhCode } from '../lib/display-labels';
|
||||
import { HQ_OPERATION_ACTION_OPTIONS, resolveHqOperationLabel } from '../lib/hq-log';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
@@ -84,7 +85,7 @@ export default function HqLogsPage() {
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
},
|
||||
{ title: '对象类型', dataIndex: 'refType', width: 120, render: (v) => v || '—' },
|
||||
{ title: '对象类型', dataIndex: 'refType', width: 120, render: (v) => zhCode(v) },
|
||||
{ title: '对象 ID', dataIndex: 'refId', width: 100, render: (v) => v || '—' },
|
||||
{
|
||||
title: '操作',
|
||||
@@ -143,7 +144,7 @@ export default function HqLogsPage() {
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="refType" label="对象类型">
|
||||
<Input allowClear placeholder="ORDER / USER / CITY..." style={{ width: 140 }} />
|
||||
<Input allowClear placeholder="对象编码" style={{ width: 140 }} />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Space>
|
||||
@@ -192,12 +193,12 @@ export default function HqLogsPage() {
|
||||
secondary={[detail.hqPhone, detail.hqAccountId ? `ID:${detail.hqAccountId}` : ''].filter(Boolean).join(' ') || null}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="角色">{detail.hqRole || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="角色">{zhCode(detail.hqRole)}</Descriptions.Item>
|
||||
<Descriptions.Item label="行为">
|
||||
{detail.actionLabel || resolveHqOperationLabel(detail.action)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="对象">{detail.refType} / {detail.refId}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">{detail.status || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="对象">{formatRef(detail.refType, detail.refId)}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">{zhCode(detail.status)}</Descriptions.Item>
|
||||
<Descriptions.Item label="备注">{detail.remark || '—'}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Typography.Title level={5} style={{ marginTop: 16 }}>请求/响应快照</Typography.Title>
|
||||
|
||||
@@ -244,7 +244,7 @@ export default function HqPermissionsPage() {
|
||||
<Typography.Title level={4}>权限分配</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">
|
||||
按角色配置基础权限;按用户可追加或撤销。最终生效权限 =(角色权限 ∪ 追加)− 撤销。
|
||||
超级管理员默认拥有除「危险操作」外的全部权限;删除用户/订单/城市需在「按用户分配」中单独勾选(默认均无)。
|
||||
超级管理员默认拥有除「危险操作」外的全部权限;删除用户/订单/城市、修改用户关联合伙人需在「按用户分配」或「按角色分配」中单独勾选(默认均无)。
|
||||
运营/财务默认可删除门店分类;城市门店服务可新增分类,不可删除。
|
||||
「系统设置」已拆分为各配置分组;「财务」对应门店/合伙人/酒厂账单。
|
||||
</Typography.Paragraph>
|
||||
@@ -274,7 +274,7 @@ export default function HqPermissionsPage() {
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="超级管理员基础权限固定(不含危险操作)。删除用户/订单/城市请到「按用户分配」为具体账号勾选。"
|
||||
message="超级管理员基础权限固定(不含危险操作)。删除用户/订单/城市、修改用户关联合伙人请到「按用户分配」为具体账号勾选。"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { Link, useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Checkbox,
|
||||
Col,
|
||||
Collapse,
|
||||
DatePicker,
|
||||
Descriptions,
|
||||
@@ -14,7 +13,6 @@ import {
|
||||
InputNumber,
|
||||
Modal,
|
||||
Radio,
|
||||
Row,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
@@ -24,6 +22,7 @@ import {
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import dayjs, { type Dayjs } from 'dayjs';
|
||||
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
||||
import { ORDER_TYPE_LABELS } from '@dukang/shared-types';
|
||||
import { request, type AdminOrderItem, type AdminOrderRow, type HqProfile, type Paginated } from '../lib/api';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
@@ -39,6 +38,7 @@ import {
|
||||
ORDER_STATUS_OPERATOR_LABELS,
|
||||
fmtTime,
|
||||
} from '../lib/constants';
|
||||
import { zhRemark } from '../lib/display-labels';
|
||||
import { FULFILLMENT_HOLD_REASON_LABELS } from '@dukang/shared-types';
|
||||
import ProxyOrderModal from '../components/ProxyOrderModal';
|
||||
import OrderTrackDrawer from '../components/OrderTrackDrawer';
|
||||
@@ -57,6 +57,7 @@ type ShipDefaults = {
|
||||
};
|
||||
|
||||
type CityOption = { id: string; name: string; code: string };
|
||||
type PartnerOption = { id: string; companyName?: string | null; name?: string; phone?: string };
|
||||
|
||||
type WarehouseOption = {
|
||||
id: string;
|
||||
@@ -93,6 +94,20 @@ type OrderRedeemSummary = {
|
||||
redeemRecordSum: number;
|
||||
};
|
||||
|
||||
type AssocPartnerBrief = {
|
||||
id: string;
|
||||
name: string;
|
||||
companyName?: string | null;
|
||||
phone?: string | null;
|
||||
orderCommissionRate?: number | null;
|
||||
};
|
||||
|
||||
function formatAssocPartner(p?: AssocPartnerBrief | null) {
|
||||
if (!p) return '—';
|
||||
const title = p.companyName || p.name;
|
||||
return [title, p.phone].filter(Boolean).join(' / ') || '—';
|
||||
}
|
||||
|
||||
type OrderDetail = AdminOrderRow & {
|
||||
receiverAddress?: string;
|
||||
receiverProvince?: string;
|
||||
@@ -136,6 +151,11 @@ type OrderDetail = AdminOrderRow & {
|
||||
lng?: number | null;
|
||||
lat?: number | null;
|
||||
} | null;
|
||||
assocPartnerAtPay?: AssocPartnerBrief | null;
|
||||
orderCommissionRateAtPay?: number | null;
|
||||
user?: AdminOrderRow['user'] & {
|
||||
assocPartner?: AssocPartnerBrief | null;
|
||||
};
|
||||
};
|
||||
|
||||
type ShipMode = 'WAREHOUSE' | 'EXPRESS';
|
||||
@@ -149,9 +169,12 @@ type OrderExportFilters = {
|
||||
orderType?: string;
|
||||
cityId?: string;
|
||||
receiverPhone?: string;
|
||||
userKeyword?: string;
|
||||
productKeyword?: string;
|
||||
fulfillmentHold?: boolean;
|
||||
excludeTest?: boolean;
|
||||
deliveryType?: string;
|
||||
promoCodeId?: string;
|
||||
assocPartnerAccountId?: string;
|
||||
dateRange?: [Dayjs, Dayjs];
|
||||
};
|
||||
|
||||
@@ -211,6 +234,17 @@ const DATE_PRESETS: Array<{ key: 'day' | 'week' | 'month' | 'quarter' | 'year';
|
||||
{ key: 'year', label: '当年' },
|
||||
];
|
||||
|
||||
const FILTERS_COLLAPSED_KEY = 'admin-orders-filters-collapsed';
|
||||
|
||||
function formatUserWithRemark(user?: {
|
||||
userNo?: string;
|
||||
hqRemark?: string | null;
|
||||
} | null) {
|
||||
const userNo = user?.userNo || '—';
|
||||
const remark = user?.hqRemark?.trim();
|
||||
return remark ? `${userNo}(${remark})` : userNo;
|
||||
}
|
||||
|
||||
function formatBenefitBrief(row: AdminOrderRow) {
|
||||
const coupon = row.benefitCoupon;
|
||||
if (coupon) {
|
||||
@@ -243,9 +277,12 @@ function buildExportPayload(
|
||||
if (filters.orderType) payload.orderType = filters.orderType;
|
||||
if (filters.cityId) payload.cityId = filters.cityId;
|
||||
if (filters.receiverPhone) payload.receiverPhone = filters.receiverPhone;
|
||||
if (filters.userKeyword) payload.userKeyword = filters.userKeyword;
|
||||
if (filters.productKeyword) payload.productKeyword = filters.productKeyword;
|
||||
if (filters.deliveryType) payload.deliveryType = filters.deliveryType;
|
||||
if (filters.fulfillmentHold) payload.fulfillmentHold = true;
|
||||
if (filters.excludeTest) payload.excludeTest = true;
|
||||
if (filters.promoCodeId) payload.promoCodeId = filters.promoCodeId;
|
||||
if (filters.assocPartnerAccountId) payload.assocPartnerAccountId = filters.assocPartnerAccountId;
|
||||
if (filters.dateRange?.[0]) payload.createdFrom = filters.dateRange[0].format('YYYY-MM-DD');
|
||||
if (filters.dateRange?.[1]) payload.createdTo = filters.dateRange[1].format('YYYY-MM-DD');
|
||||
return payload;
|
||||
@@ -284,8 +321,15 @@ function warehouseToDefaults(wh: WarehouseOption, base?: ShipDefaults | null): S
|
||||
|
||||
export default function OrdersPage() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const [searchParams] = useSearchParams();
|
||||
const initialOrderNo = searchParams.get('orderNo')?.trim() || '';
|
||||
const initialPromoCodeId = searchParams.get('promoCodeId')?.trim() || '';
|
||||
const initialStatusParam = searchParams.getAll('status').join(',');
|
||||
const initialStatuses = useMemo(
|
||||
() => initialStatusParam.split(',').map((s) => s.trim()).filter(Boolean),
|
||||
[initialStatusParam],
|
||||
);
|
||||
const [form] = Form.useForm();
|
||||
const [shipForm] = Form.useForm();
|
||||
const [logisticsForm] = Form.useForm();
|
||||
@@ -308,6 +352,7 @@ export default function OrdersPage() {
|
||||
const [shipping, setShipping] = useState(false);
|
||||
const [logisticsShipping, setLogisticsShipping] = useState(false);
|
||||
const [cities, setCities] = useState<CityOption[]>([]);
|
||||
const [partners, setPartners] = useState<PartnerOption[]>([]);
|
||||
const [shipModalOpen, setShipModalOpen] = useState(false);
|
||||
const [shipTarget, setShipTarget] = useState<OrderDetail | null>(null);
|
||||
const [shipMode, setShipMode] = useState<ShipMode>('EXPRESS');
|
||||
@@ -316,6 +361,13 @@ export default function OrdersPage() {
|
||||
const [trackOpen, setTrackOpen] = useState(false);
|
||||
const [exporting, setExporting] = useState(false);
|
||||
const [exportFormat, setExportFormat] = useState<OrderExportFormat>('xlsx');
|
||||
const [filtersCollapsed, setFiltersCollapsed] = useState(() => {
|
||||
try {
|
||||
return localStorage.getItem(FILTERS_COLLAPSED_KEY) === '1';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
const canDeleteOrders = (profile?.permissionKeys ?? []).includes('orders_delete');
|
||||
const canProxyOrder = (profile?.permissionKeys ?? []).includes('orders');
|
||||
const canExportOrders = (profile?.permissionKeys ?? []).includes('orders');
|
||||
@@ -335,6 +387,20 @@ export default function OrdersPage() {
|
||||
}
|
||||
}, [form, initialOrderNo]);
|
||||
|
||||
useEffect(() => {
|
||||
if (initialStatuses.length) {
|
||||
form.setFieldsValue({ status: initialStatuses });
|
||||
}
|
||||
}, [form, initialStatuses]);
|
||||
|
||||
useEffect(() => {
|
||||
const openOrderId = (location.state as { openOrderId?: string } | null)?.openOrderId;
|
||||
if (openOrderId) {
|
||||
void openDetail(openOrderId);
|
||||
navigate(`${location.pathname}${location.search}`, { replace: true, state: null });
|
||||
}
|
||||
}, [location.state, location.pathname, location.search, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!initialOrderNo || deepLinkOpenedRef.current || loading) return;
|
||||
const first = data?.items?.[0];
|
||||
@@ -365,13 +431,18 @@ export default function OrdersPage() {
|
||||
const qs = new URLSearchParams({ page: String(page), pageSize: String(pageSize) });
|
||||
if (initialOrderNo) qs.set('orderNo', initialOrderNo);
|
||||
if (values.orderNo) qs.set('orderNo', values.orderNo);
|
||||
for (const status of selectedStatuses(values.status)) qs.append('status', status);
|
||||
const statuses = selectedStatuses(values.status);
|
||||
const statusList = statuses.length ? statuses : initialStatuses;
|
||||
for (const status of statusList) qs.append('status', status);
|
||||
if (values.orderType) qs.set('orderType', values.orderType);
|
||||
if (values.cityId) qs.set('cityId', values.cityId);
|
||||
if (values.receiverPhone) qs.set('receiverPhone', values.receiverPhone);
|
||||
if (values.userKeyword) qs.set('userKeyword', values.userKeyword);
|
||||
if (values.productKeyword) qs.set('productKeyword', values.productKeyword);
|
||||
if (values.fulfillmentHold) qs.set('fulfillmentHold', 'true');
|
||||
if (values.excludeTest) qs.set('excludeTest', 'true');
|
||||
if (values.deliveryType) qs.set('deliveryType', values.deliveryType);
|
||||
if (values.assocPartnerAccountId) qs.set('assocPartnerAccountId', values.assocPartnerAccountId);
|
||||
if (initialPromoCodeId) qs.set('promoCodeId', initialPromoCodeId);
|
||||
if (values.dateRange?.[0]) qs.set('createdFrom', values.dateRange[0].format('YYYY-MM-DD'));
|
||||
if (values.dateRange?.[1]) qs.set('createdTo', values.dateRange[1].format('YYYY-MM-DD'));
|
||||
const res = await request<Paginated<AdminOrderRow>>(`/admin/orders?${qs}`);
|
||||
@@ -379,7 +450,7 @@ export default function OrdersPage() {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [form, page, pageSize, initialOrderNo]);
|
||||
}, [form, page, pageSize, initialOrderNo, initialPromoCodeId, initialStatuses]);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
@@ -390,6 +461,9 @@ export default function OrdersPage() {
|
||||
void request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||
.then((res) => setCities(res.items ?? []))
|
||||
.catch(() => {});
|
||||
void request<Paginated<PartnerOption>>(`/admin/partners?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||
.then((res) => setPartners(res.items ?? []))
|
||||
.catch(() => setPartners([]));
|
||||
}, []);
|
||||
|
||||
function applyShipDefaults(defaults: ShipDefaults, warehouseId?: string | null) {
|
||||
@@ -588,7 +662,16 @@ export default function OrdersPage() {
|
||||
}
|
||||
setExporting(true);
|
||||
try {
|
||||
const payload = buildExportPayload(scope, exportFormat, values, selectedRowKeys);
|
||||
const payload = buildExportPayload(
|
||||
scope,
|
||||
exportFormat,
|
||||
{
|
||||
...values,
|
||||
promoCodeId: initialPromoCodeId || values.promoCodeId,
|
||||
status: selectedStatuses(values.status).length ? values.status : initialStatuses,
|
||||
},
|
||||
selectedRowKeys,
|
||||
);
|
||||
const result = await request<OrderExportResult>('/admin/orders/export', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
@@ -617,14 +700,14 @@ export default function OrdersPage() {
|
||||
{
|
||||
title: '用户',
|
||||
key: 'user',
|
||||
width: 120,
|
||||
width: 200,
|
||||
render: (_, row) =>
|
||||
row.user?.id ? (
|
||||
<AdminPrimaryLink onClick={() => navigate('/users', { state: { openUserId: String(row.user!.id) } })}>
|
||||
{row.user.userNo}
|
||||
<AdminPrimaryLink onClick={() => navigate(`/users?userId=${encodeURIComponent(String(row.user!.id))}`)}>
|
||||
{formatUserWithRemark(row.user)}
|
||||
</AdminPrimaryLink>
|
||||
) : (
|
||||
(row.user?.userNo || '—')
|
||||
formatUserWithRemark(row.user)
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -674,6 +757,13 @@ export default function OrdersPage() {
|
||||
width: 90,
|
||||
render: (v: number) => `¥${v}`,
|
||||
},
|
||||
{
|
||||
title: '运费',
|
||||
key: 'logisticsFee',
|
||||
width: 90,
|
||||
render: (_, row) =>
|
||||
row.delivery?.logisticsFee == null ? '—' : `¥${Number(row.delivery.logisticsFee).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '好客权益',
|
||||
width: 200,
|
||||
@@ -770,15 +860,117 @@ export default function OrdersPage() {
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{initialPromoCodeId ? (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
closable
|
||||
style={{ marginBottom: 16 }}
|
||||
message={
|
||||
initialStatuses.includes('COMPLETED') && initialStatuses.length === 1
|
||||
? '已按推广码筛选已完成订单'
|
||||
: '已按推广码筛选订单'
|
||||
}
|
||||
action={
|
||||
<Button size="small" onClick={() => navigate('/orders')}>
|
||||
清除筛选
|
||||
</Button>
|
||||
}
|
||||
onClose={() => navigate('/orders')}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<Form form={form} layout="vertical" onFinish={() => { setPage(1); void load(); }}>
|
||||
<Row gutter={[16, 8]}>
|
||||
<Col xs={24} md={14} lg={12}>
|
||||
<Form.Item label="下单日期" style={{ marginBottom: 12 }}>
|
||||
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
||||
<Form.Item name="dateRange" noStyle>
|
||||
<DatePicker.RangePicker allowClear style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<div className="admin-orders-filter-row">
|
||||
<Form.Item name="cityId" label="城市" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="全部"
|
||||
options={cities.map((c) => ({ value: c.id, label: c.name }))}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="receiverPhone" label="手机号" className="admin-orders-filter-item admin-orders-filter-item--md">
|
||||
<Input allowClear placeholder="手机号" />
|
||||
</Form.Item>
|
||||
<Form.Item name="userKeyword" label="用户" className="admin-orders-filter-item admin-orders-filter-item--search">
|
||||
<Input allowClear placeholder="编号/昵称/备注/手机" />
|
||||
</Form.Item>
|
||||
<Form.Item name="productKeyword" label="商品" className="admin-orders-filter-item admin-orders-filter-item--search">
|
||||
<Input allowClear placeholder="名称/规格" />
|
||||
</Form.Item>
|
||||
<Form.Item name="status" label="状态" className="admin-orders-filter-item admin-orders-filter-item--status">
|
||||
<Select
|
||||
mode="multiple"
|
||||
allowClear
|
||||
maxTagCount="responsive"
|
||||
placeholder="全部"
|
||||
options={Object.entries(ORDER_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="orderType" label="类型" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Select allowClear placeholder="全部" options={ORDER_TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="deliveryType" label="配送" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Select allowClear placeholder="全部" options={DELIVERY_TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="assocPartnerAccountId"
|
||||
label="关联合伙人"
|
||||
className="admin-orders-filter-item admin-orders-filter-item--status"
|
||||
>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="全部"
|
||||
options={[
|
||||
{ value: 'none', label: '未关联' },
|
||||
...partners.map((p) => ({
|
||||
value: p.id,
|
||||
label: formatAssocPartner({
|
||||
id: p.id,
|
||||
name: p.name || p.id,
|
||||
companyName: p.companyName,
|
||||
phone: p.phone,
|
||||
}),
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label=" " colon={false} className="admin-orders-filter-item admin-orders-filter-actions">
|
||||
<Space size={8} wrap>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
<Button
|
||||
type="link"
|
||||
icon={filtersCollapsed ? <DownOutlined /> : <UpOutlined />}
|
||||
onClick={() => {
|
||||
setFiltersCollapsed((prev) => {
|
||||
const next = !prev;
|
||||
try {
|
||||
localStorage.setItem(FILTERS_COLLAPSED_KEY, next ? '1' : '0');
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}}
|
||||
>
|
||||
{filtersCollapsed ? '展开' : '收起'}
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
{!filtersCollapsed ? (
|
||||
<>
|
||||
<div className="admin-orders-filter-row">
|
||||
<Form.Item label="下单日期" className="admin-orders-filter-item admin-orders-filter-item--date">
|
||||
<Space size={8} wrap>
|
||||
<Form.Item name="dateRange" noStyle>
|
||||
<DatePicker.RangePicker allowClear className="admin-orders-date-picker" />
|
||||
</Form.Item>
|
||||
{DATE_PRESETS.map((preset) => (
|
||||
<Button
|
||||
key={preset.key}
|
||||
@@ -789,98 +981,60 @@ export default function OrdersPage() {
|
||||
</Button>
|
||||
))}
|
||||
</Space>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} sm={12} md={8} lg={6}>
|
||||
<Form.Item name="status" label="状态" style={{ marginBottom: 12 }}>
|
||||
<Select
|
||||
mode="multiple"
|
||||
allowClear
|
||||
maxTagCount="responsive"
|
||||
placeholder="全部"
|
||||
options={Object.entries(ORDER_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={12} sm={6} md={5} lg={3}>
|
||||
<Form.Item name="orderType" label="类型" style={{ marginBottom: 12 }}>
|
||||
<Select allowClear placeholder="全部" options={ORDER_TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={12} sm={6} md={5} lg={3}>
|
||||
<Form.Item name="deliveryType" label="配送" style={{ marginBottom: 12 }}>
|
||||
<Select allowClear placeholder="全部" options={DELIVERY_TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={12} sm={6} md={5} lg={3}>
|
||||
<Form.Item name="cityId" label="城市" style={{ marginBottom: 12 }}>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="全部"
|
||||
options={cities.map((c) => ({ value: c.id, label: c.name }))}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={12} sm={8} md={6} lg={6}>
|
||||
<Form.Item name="receiverPhone" label="收货手机" style={{ marginBottom: 12 }}>
|
||||
<Input allowClear placeholder="手机号" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={12} sm={8} md={8} lg={8}>
|
||||
<Form.Item label=" " colon={false} style={{ marginBottom: 12 }}>
|
||||
<Space size={16} wrap>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div className="admin-orders-filter-row admin-orders-filter-row--tools">
|
||||
{canExportOrders ? (
|
||||
<Space size={12} wrap>
|
||||
<Radio.Group
|
||||
optionType="button"
|
||||
buttonStyle="solid"
|
||||
value={exportFormat}
|
||||
onChange={(e) => setExportFormat(e.target.value)}
|
||||
>
|
||||
<Radio.Button value="xlsx">Excel</Radio.Button>
|
||||
<Radio.Button value="pdf">PDF</Radio.Button>
|
||||
</Radio.Group>
|
||||
<Button
|
||||
disabled={!selectedRowKeys.length}
|
||||
loading={exporting}
|
||||
onClick={() => void submitExport('selected')}
|
||||
>
|
||||
导出已勾选{selectedRowKeys.length ? `(${selectedRowKeys.length})` : ''}
|
||||
</Button>
|
||||
<Button loading={exporting} onClick={() => void submitExport('filter')}>
|
||||
导出全部筛选
|
||||
</Button>
|
||||
</Space>
|
||||
) : <span />}
|
||||
<Space size={12} wrap>
|
||||
<Form.Item name="fulfillmentHold" valuePropName="checked" noStyle>
|
||||
<Checkbox>大单拦截</Checkbox>
|
||||
</Form.Item>
|
||||
<Form.Item name="excludeTest" valuePropName="checked" noStyle>
|
||||
<Checkbox>过滤测试</Checkbox>
|
||||
</Form.Item>
|
||||
<Button
|
||||
onClick={() => {
|
||||
form.resetFields();
|
||||
setPage(1);
|
||||
if (initialPromoCodeId || initialOrderNo || initialStatuses.length) navigate('/orders');
|
||||
else void load();
|
||||
}}
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
{canDeleteOrders ? (
|
||||
<Button
|
||||
danger
|
||||
disabled={!selectedRowKeys.length}
|
||||
onClick={() => setBatchDeleteOpen(true)}
|
||||
>
|
||||
批量删除{selectedRowKeys.length ? `(${selectedRowKeys.length})` : ''}
|
||||
</Button>
|
||||
) : null}
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', margin: '8px 0 16px', gap: 12, flexWrap: 'wrap' }}>
|
||||
{canExportOrders ? (
|
||||
<Space size={12} wrap>
|
||||
<Radio.Group
|
||||
optionType="button"
|
||||
buttonStyle="solid"
|
||||
value={exportFormat}
|
||||
onChange={(e) => setExportFormat(e.target.value)}
|
||||
>
|
||||
<Radio.Button value="xlsx">Excel</Radio.Button>
|
||||
<Radio.Button value="pdf">PDF</Radio.Button>
|
||||
</Radio.Group>
|
||||
<Button
|
||||
disabled={!selectedRowKeys.length}
|
||||
loading={exporting}
|
||||
onClick={() => void submitExport('selected')}
|
||||
>
|
||||
导出已勾选{selectedRowKeys.length ? `(${selectedRowKeys.length})` : ''}
|
||||
</Button>
|
||||
<Button loading={exporting} onClick={() => void submitExport('filter')}>
|
||||
导出全部筛选
|
||||
</Button>
|
||||
</Space>
|
||||
) : <span />}
|
||||
<Space size={12} wrap>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
<Button onClick={() => { form.resetFields(); setPage(1); void load(); }}>重置</Button>
|
||||
{canDeleteOrders ? (
|
||||
<Button
|
||||
danger
|
||||
disabled={!selectedRowKeys.length}
|
||||
onClick={() => setBatchDeleteOpen(true)}
|
||||
>
|
||||
批量删除{selectedRowKeys.length ? `(${selectedRowKeys.length})` : ''}
|
||||
</Button>
|
||||
) : null}
|
||||
</Space>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</Form>
|
||||
|
||||
<Table
|
||||
@@ -979,7 +1133,33 @@ export default function OrdersPage() {
|
||||
{[detail.proxyPartnerName, detail.proxyPartnerPhone].filter(Boolean).join(' / ') || '—'}
|
||||
</Descriptions.Item>
|
||||
) : null}
|
||||
<Descriptions.Item label="用户">{detail.user?.userNo} / {detail.user?.nickname}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联合伙人(本单佣金)">
|
||||
{detail.assocPartnerAtPay
|
||||
? `${formatAssocPartner(detail.assocPartnerAtPay)}${
|
||||
detail.assocPartnerAtPay.orderCommissionRate != null
|
||||
? ` · 费率 ${(Number(detail.assocPartnerAtPay.orderCommissionRate) * 100).toFixed(2)}%`
|
||||
: ''
|
||||
}`
|
||||
: '—'}
|
||||
</Descriptions.Item>
|
||||
{detail.user?.assocPartner &&
|
||||
detail.user.assocPartner.id !== detail.assocPartnerAtPay?.id ? (
|
||||
<Descriptions.Item label="用户当前关联">
|
||||
{formatAssocPartner(detail.user.assocPartner)}
|
||||
</Descriptions.Item>
|
||||
) : null}
|
||||
<Descriptions.Item label="用户">
|
||||
{detail.user?.id ? (
|
||||
<AdminPrimaryLink
|
||||
onClick={() => navigate(`/users?userId=${encodeURIComponent(String(detail.user!.id))}`)}
|
||||
>
|
||||
{formatUserWithRemark(detail.user)}
|
||||
</AdminPrimaryLink>
|
||||
) : (
|
||||
formatUserWithRemark(detail.user)
|
||||
)}
|
||||
{detail.user?.nickname ? ` / ${detail.user.nickname}` : ''}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="商品额">¥{detail.productAmount}</Descriptions.Item>
|
||||
<Descriptions.Item label="实付">¥{detail.payAmount}</Descriptions.Item>
|
||||
<Descriptions.Item label="好客权益">¥{detail.benefitAmount}</Descriptions.Item>
|
||||
@@ -1158,6 +1338,11 @@ export default function OrdersPage() {
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="运单号">{detail.delivery.trackingNo || '—'}</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 && (
|
||||
<Descriptions.Item label="查询链接">
|
||||
<a href={detail.delivery.manualQueryUrl} target="_blank" rel="noreferrer">
|
||||
@@ -1198,7 +1383,7 @@ export default function OrdersPage() {
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'remark',
|
||||
render: (v) => v || '—',
|
||||
render: (v) => zhRemark(v),
|
||||
},
|
||||
{
|
||||
title: '时间',
|
||||
|
||||
@@ -9,6 +9,7 @@ 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 { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import PartnerAssocPanel from '../components/PartnerAssocPanel';
|
||||
|
||||
|
||||
type PartnerOption = { id: string; companyName: string };
|
||||
@@ -413,6 +414,13 @@ export default function PartnerAccountsPage() {
|
||||
dataSource={detail.orders ?? []} pagination={false} scroll={{ x: 'max-content' }} />
|
||||
),
|
||||
},
|
||||
...(!detail.parentAccountId
|
||||
? [{
|
||||
key: 'assoc',
|
||||
label: '关联码',
|
||||
children: <PartnerAssocPanel partnerId={detail.id} />,
|
||||
}]
|
||||
: []),
|
||||
]} />
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
Space,
|
||||
Statistic,
|
||||
Table,
|
||||
Tabs,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
@@ -27,6 +28,19 @@ import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
|
||||
|
||||
type BillItemRow = {
|
||||
id: string;
|
||||
kind: 'ORDER' | 'REDEEM';
|
||||
refId: string;
|
||||
refNo: string;
|
||||
title?: string | null;
|
||||
extra?: string | null;
|
||||
baseAmount: number;
|
||||
rate: number;
|
||||
commission: number;
|
||||
occurredAt: string;
|
||||
};
|
||||
|
||||
type Row = {
|
||||
id: string;
|
||||
billNo: string;
|
||||
@@ -39,6 +53,8 @@ type Row = {
|
||||
rejectReason?: string | null;
|
||||
paymentRef?: string | null;
|
||||
paidAt?: string | null;
|
||||
orderItems?: BillItemRow[];
|
||||
redeemItems?: BillItemRow[];
|
||||
partner?: {
|
||||
companyName?: string;
|
||||
phone?: string;
|
||||
@@ -531,7 +547,7 @@ export default function PartnerBillsPage() {
|
||||
title="合伙人账单明细"
|
||||
open={drawerOpen}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
width={560}
|
||||
width={720}
|
||||
>
|
||||
{detail && (
|
||||
<>
|
||||
@@ -562,6 +578,84 @@ export default function PartnerBillsPage() {
|
||||
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Tabs
|
||||
style={{ marginTop: 16 }}
|
||||
items={[
|
||||
{
|
||||
key: 'orders',
|
||||
label: `酒订单 (${detail.orderItems?.length ?? 0})`,
|
||||
children: (
|
||||
<>
|
||||
<Table
|
||||
rowKey="id"
|
||||
size="small"
|
||||
pagination={false}
|
||||
dataSource={detail.orderItems ?? []}
|
||||
columns={[
|
||||
{ title: '订单号', dataIndex: 'refNo', width: 160 },
|
||||
{ title: '商品', dataIndex: 'title' },
|
||||
{ title: '数量', dataIndex: 'extra', width: 70 },
|
||||
{
|
||||
title: '实付',
|
||||
dataIndex: 'baseAmount',
|
||||
render: (v: number) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '费率',
|
||||
dataIndex: 'rate',
|
||||
render: (v: number) => `${(Number(v) * 100).toFixed(2)}%`,
|
||||
},
|
||||
{
|
||||
title: '佣金',
|
||||
dataIndex: 'commission',
|
||||
render: (v: number) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Typography.Paragraph style={{ textAlign: 'right', marginTop: 8 }}>
|
||||
酒单佣金 ¥{Number(detail.orderCommission).toFixed(2)}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'redeems',
|
||||
label: `核销订单 (${detail.redeemItems?.length ?? 0})`,
|
||||
children: (
|
||||
<>
|
||||
<Table
|
||||
rowKey="id"
|
||||
size="small"
|
||||
pagination={false}
|
||||
dataSource={detail.redeemItems ?? []}
|
||||
columns={[
|
||||
{ title: '核销单号', dataIndex: 'refNo', width: 160 },
|
||||
{ title: '门店', dataIndex: 'title' },
|
||||
{
|
||||
title: '核销额',
|
||||
dataIndex: 'baseAmount',
|
||||
render: (v: number) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '费率',
|
||||
dataIndex: 'rate',
|
||||
render: (v: number) => `${(Number(v) * 100).toFixed(2)}%`,
|
||||
},
|
||||
{
|
||||
title: '佣金',
|
||||
dataIndex: 'commission',
|
||||
render: (v: number) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Typography.Paragraph style={{ textAlign: 'right', marginTop: 8 }}>
|
||||
核销佣金 ¥{Number(detail.redeemCommission).toFixed(2)}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||
收款账户
|
||||
</Typography.Title>
|
||||
|
||||
@@ -4,15 +4,14 @@ import type { ColumnsType } from 'antd/es/table';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
PARTNER_LOG_CATEGORY_OPTIONS,
|
||||
PARTNER_LOG_CATEGORY_LABELS,
|
||||
PARTNER_STAFF_ROLE_LABELS,
|
||||
resolvePartnerLogCategory,
|
||||
type PartnerLogCategory,
|
||||
type PartnerStaffRole,
|
||||
} from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { AdminCellLine } from '../components/AdminCellLine';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import { clientAppLabel, eventNameLabel, formatRef, partnerEventCategoryLabel } from '../lib/display-labels';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
@@ -107,7 +106,7 @@ export default function PartnerLogsPage() {
|
||||
dataIndex: 'category',
|
||||
width: 100,
|
||||
render: (v: PartnerLogCategory | null, r) => (
|
||||
<Tag>{PARTNER_LOG_CATEGORY_LABELS[v ?? ''] || resolvePartnerLogCategory(r.eventName) || '其他'}</Tag>
|
||||
<Tag>{partnerEventCategoryLabel(r.eventName, v)}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -121,14 +120,14 @@ export default function PartnerLogsPage() {
|
||||
setDrawerOpen(true);
|
||||
}}
|
||||
>
|
||||
{v}
|
||||
{eventNameLabel(v)}
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '关联',
|
||||
width: 120,
|
||||
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
||||
render: (_, r) => formatRef(r.refType, r.refId),
|
||||
},
|
||||
{
|
||||
title: '摘要',
|
||||
@@ -188,11 +187,11 @@ export default function PartnerLogsPage() {
|
||||
<Form.Item name="companyName" label="公司">
|
||||
<Input placeholder="合伙人公司" allowClear style={{ width: 140 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="partnerId" label="合伙人ID">
|
||||
<Input placeholder="partnerId" allowClear style={{ width: 120 }} />
|
||||
<Form.Item name="partnerId" label="合伙人 ID">
|
||||
<Input placeholder="合伙人 ID" allowClear style={{ width: 120 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="eventName" label="事件名">
|
||||
<Input placeholder="partner_sms_login" allowClear style={{ width: 160 }} />
|
||||
<Form.Item name="eventName" label="事件编码">
|
||||
<Input placeholder="事件编码" allowClear style={{ width: 160 }} />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Space>
|
||||
@@ -237,11 +236,19 @@ export default function PartnerLogsPage() {
|
||||
<Drawer title="日志详情" open={drawerOpen} onClose={() => setDrawerOpen(false)} width={520}>
|
||||
{detail && (
|
||||
<Descriptions column={1} bordered size="small">
|
||||
{Object.entries(detail).map(([k, v]) => (
|
||||
<Descriptions.Item key={k} label={k}>
|
||||
{typeof v === 'object' ? JSON.stringify(v, null, 2) : String(v ?? '—')}
|
||||
</Descriptions.Item>
|
||||
))}
|
||||
<Descriptions.Item label="ID">{String(detail.id ?? '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="合伙人">{String(detail.companyName || detail.partnerId || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="账号">{String(detail.accountName || detail.accountPhone || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="分类">{partnerEventCategoryLabel(String(detail.eventName ?? ''), detail.category ? String(detail.category) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="事件">{eventNameLabel(String(detail.eventName ?? ''))}</Descriptions.Item>
|
||||
<Descriptions.Item label="端">{clientAppLabel(detail.clientApp ? String(detail.clientApp) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联">{formatRef(detail.refType ? String(detail.refType) : null, detail.refId ? String(detail.refId) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="时间">{fmtTime(detail.createdAt ? String(detail.createdAt) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="参数">
|
||||
<pre style={{ margin: 0, whiteSpace: 'pre-wrap', wordBreak: 'break-all' }}>
|
||||
{JSON.stringify(detail.extraJson ?? {}, null, 2)}
|
||||
</pre>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
type PartnerPermissionKey,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { omitNullFields } from '../lib/omit-null-fields';
|
||||
import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
@@ -30,6 +31,7 @@ import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
import PartnerAssocPanel from '../components/PartnerAssocPanel';
|
||||
|
||||
|
||||
type Row = {
|
||||
@@ -162,7 +164,7 @@ export default function PartnersPage() {
|
||||
try {
|
||||
const v = await editForm.validateFields();
|
||||
const body = {
|
||||
...v,
|
||||
...omitNullFields(v),
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: editScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
@@ -320,6 +322,11 @@ export default function PartnersPage() {
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'assoc',
|
||||
label: '关联码',
|
||||
children: <PartnerAssocPanel partnerId={detail.id} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -610,6 +610,7 @@ export default function ProductsPage() {
|
||||
label: '规格与 SKU',
|
||||
children: (
|
||||
<ProductSpecsEditor
|
||||
key={String(detail.id)}
|
||||
productId={String(detail.id)}
|
||||
initialAttrs={(detail.specAttrs as never) ?? []}
|
||||
initialSkus={(detail.skus as never) ?? []}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Button, Form, Input, Modal, Select, Space, Table, Tag, Typography, message,
|
||||
Button, Form, Input, Modal, Select, Space, Table, Tag, Tooltip, Typography, message,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import {
|
||||
@@ -23,21 +23,6 @@ type Row = PromoCodeItem;
|
||||
|
||||
type SceneOption = { value: PromoCodeScene; label: string };
|
||||
|
||||
async function downloadQrcode(url: string, filename: string) {
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
const blob = await res.blob();
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = objectUrl;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
} catch {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
export default function PromoCodesPage() {
|
||||
const navigate = useNavigate();
|
||||
const [filterForm] = Form.useForm();
|
||||
@@ -104,8 +89,26 @@ export default function PromoCodesPage() {
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{ title: '扫码', dataIndex: 'scanCount', width: 70 },
|
||||
{ title: '订单', dataIndex: 'orderCount', width: 70 },
|
||||
{
|
||||
title: '扫码',
|
||||
dataIndex: 'scanCount',
|
||||
width: 70,
|
||||
render: (v: number, row) => (
|
||||
<AdminPrimaryLink onClick={() => navigate(`/promo-codes/${row.id}?eventType=SCAN`)}>
|
||||
{v}
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: <Tooltip title="仅统计已完成订单">订单</Tooltip>,
|
||||
dataIndex: 'orderCount',
|
||||
width: 70,
|
||||
render: (v: number, row) => (
|
||||
<AdminPrimaryLink onClick={() => navigate(`/orders?promoCodeId=${row.id}&status=COMPLETED`)}>
|
||||
{v}
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '转化率',
|
||||
width: 90,
|
||||
@@ -119,24 +122,13 @@ export default function PromoCodesPage() {
|
||||
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 140,
|
||||
fixed: 'right',
|
||||
render: (_, row) => (
|
||||
<Space size="small" wrap>
|
||||
<Button type="link" size="small" onClick={() => navigate(`/promo-codes/${row.id}`)}>
|
||||
详情
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
disabled={!row.qrcodeUrl}
|
||||
onClick={() => {
|
||||
if (!row.qrcodeUrl) return;
|
||||
void downloadQrcode(row.qrcodeUrl, `${row.code}-wxacode.png`);
|
||||
}}
|
||||
>
|
||||
下载小程序码
|
||||
</Button>
|
||||
<Button type="link" size="small" onClick={() => navigate(`/promo-codes/${row.id}/users`)}>
|
||||
关联用户
|
||||
</Button>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { Button, Checkbox, Drawer, Form, Input, Select, Table, Tag, Typography } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { REDEEM_CHANNEL_LABELS, type RedeemChannel } from '@dukang/shared-types';
|
||||
@@ -20,17 +20,28 @@ type Row = {
|
||||
channel?: RedeemChannel;
|
||||
createdAt: string;
|
||||
isTest?: boolean;
|
||||
user?: { userNo: string; phone: string | null; nickname?: string | null };
|
||||
user?: {
|
||||
id?: string;
|
||||
userNo: string;
|
||||
phone: string | null;
|
||||
nickname?: string | null;
|
||||
hqRemark?: string | null;
|
||||
};
|
||||
store?: { name: string; cityName: string };
|
||||
coupon?: { couponNo: string };
|
||||
coupon?: { id?: string; couponNo: string };
|
||||
};
|
||||
|
||||
function maskPhone(phone: string | null | undefined) {
|
||||
if (!phone || phone.length < 7) return phone ?? '—';
|
||||
return `${phone.slice(0, 3)}****${phone.slice(-4)}`;
|
||||
function formatNicknameWithRemark(user?: {
|
||||
nickname?: string | null;
|
||||
hqRemark?: string | null;
|
||||
} | null) {
|
||||
const name = user?.nickname?.trim() || '—';
|
||||
const remark = user?.hqRemark?.trim();
|
||||
return remark ? `${name}(${remark})` : name;
|
||||
}
|
||||
|
||||
export default function RedeemRecordsPage() {
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const initialRedeemNo = searchParams.get('redeemNo')?.trim() || '';
|
||||
const [form] = Form.useForm();
|
||||
@@ -108,23 +119,60 @@ export default function RedeemRecordsPage() {
|
||||
);
|
||||
},
|
||||
},
|
||||
{ title: '用户编号', dataIndex: ['user', 'userNo'], width: 110 },
|
||||
{ title: '用户编号', dataIndex: ['user', 'userNo'], width: 110, render: (v: string | undefined, row) =>
|
||||
row.user?.id ? (
|
||||
<AdminPrimaryLink
|
||||
onClick={() => navigate('/users', { state: { openUserId: String(row.user!.id) } })}
|
||||
>
|
||||
{v || '—'}
|
||||
</AdminPrimaryLink>
|
||||
) : (
|
||||
v || '—'
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '用户昵称',
|
||||
dataIndex: ['user', 'nickname'],
|
||||
width: 100,
|
||||
render: (v: string | null | undefined) => v || '—',
|
||||
width: 160,
|
||||
render: (_: string | null | undefined, row) =>
|
||||
row.user?.id ? (
|
||||
<AdminPrimaryLink
|
||||
onClick={() => navigate('/users', { state: { openUserId: String(row.user!.id) } })}
|
||||
>
|
||||
{formatNicknameWithRemark(row.user)}
|
||||
</AdminPrimaryLink>
|
||||
) : (
|
||||
formatNicknameWithRemark(row.user)
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '用户手机',
|
||||
dataIndex: ['user', 'phone'],
|
||||
width: 120,
|
||||
render: (v: string | null | undefined) => maskPhone(v),
|
||||
render: (v: string | null | undefined) => v || '—',
|
||||
},
|
||||
{ title: '门店', dataIndex: ['store', 'name'] },
|
||||
{ title: '核销额', dataIndex: 'amount', width: 90, render: (v) => `¥${v}` },
|
||||
{ title: '结算额', dataIndex: 'settleAmount', width: 90, render: (v) => `¥${v}` },
|
||||
{ title: '券号', dataIndex: ['coupon', 'couponNo'], width: 160 },
|
||||
{
|
||||
title: '券号',
|
||||
dataIndex: ['coupon', 'couponNo'],
|
||||
width: 160,
|
||||
render: (v: string | undefined, row) =>
|
||||
v ? (
|
||||
<AdminPrimaryLink
|
||||
onClick={() =>
|
||||
navigate(`/benefit/coupons?couponNo=${encodeURIComponent(v)}`, {
|
||||
state: row.coupon?.id ? { openCouponId: String(row.coupon.id) } : undefined,
|
||||
})
|
||||
}
|
||||
>
|
||||
{v}
|
||||
</AdminPrimaryLink>
|
||||
) : (
|
||||
'—'
|
||||
),
|
||||
},
|
||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||
{
|
||||
title: '操作',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { useSearchParams, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
@@ -14,9 +14,11 @@ import {
|
||||
Statistic,
|
||||
Table,
|
||||
Tag,
|
||||
Tooltip,
|
||||
Typography,
|
||||
message,
|
||||
} from 'antd';
|
||||
import { FinancePayProofModal, PaymentProofGallery } from '../components/FinancePayProof';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import {
|
||||
@@ -75,6 +77,7 @@ const KIND_COLORS: Record<StoreSettlementKind, string> = {
|
||||
};
|
||||
|
||||
export default function StoreBillsPage() {
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const initialKind = searchParams.get('kind') === 'WITHDRAW' ? 'WITHDRAW' : '';
|
||||
const initialStoreId = searchParams.get('storeId') || '';
|
||||
@@ -111,6 +114,13 @@ export default function StoreBillsPage() {
|
||||
pendingCount: number;
|
||||
overdueCount: number;
|
||||
} | null>(null);
|
||||
const [payModal, setPayModal] = useState<{
|
||||
ids: string[];
|
||||
amountHint?: number;
|
||||
} | null>(null);
|
||||
const [paySubmitting, setPaySubmitting] = useState(false);
|
||||
const [withdrawApproveId, setWithdrawApproveId] = useState<string | null>(null);
|
||||
const [withdrawSubmitting, setWithdrawSubmitting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({
|
||||
@@ -132,77 +142,11 @@ export default function StoreBillsPage() {
|
||||
}, []);
|
||||
|
||||
function confirmPay(ids: string[], amountHint?: number) {
|
||||
let paymentRef = '';
|
||||
Modal.confirm({
|
||||
title: '确认打款?',
|
||||
content: (
|
||||
<div>
|
||||
<div>
|
||||
将确认 {ids.length} 笔 T+1 门店对账单
|
||||
{amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。此操作不可撤销。
|
||||
</div>
|
||||
<Input
|
||||
placeholder="打款凭证号(可选)"
|
||||
style={{ marginTop: 8 }}
|
||||
onChange={(e) => {
|
||||
paymentRef = e.target.value;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
okText: '确认打款',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
const body = JSON.stringify({ paymentRef: paymentRef.trim() || undefined });
|
||||
if (ids.length === 1) {
|
||||
await request(`/admin/store-bills/${ids[0]}/confirm`, { method: 'POST', body });
|
||||
} else {
|
||||
setBatchLoading(true);
|
||||
try {
|
||||
await request('/admin/store-bills/batch-confirm', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ ids }),
|
||||
});
|
||||
} finally {
|
||||
setBatchLoading(false);
|
||||
}
|
||||
}
|
||||
message.success('已确认打款');
|
||||
setSelectedKeys([]);
|
||||
reload();
|
||||
},
|
||||
});
|
||||
setPayModal({ ids, amountHint });
|
||||
}
|
||||
|
||||
function approveWithdraw(id: string) {
|
||||
let paymentRef = '';
|
||||
Modal.confirm({
|
||||
title: '审核通过并标记已结算?',
|
||||
content: (
|
||||
<Input
|
||||
placeholder="打款凭证号(可选)"
|
||||
onChange={(e) => {
|
||||
paymentRef = e.target.value;
|
||||
}}
|
||||
/>
|
||||
),
|
||||
okText: '通过并结算',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
await request(`/admin/store-withdrawals/${id}/approve`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ paymentRef: paymentRef.trim() || undefined }),
|
||||
});
|
||||
message.success('已通过并标记已结算');
|
||||
setDrawerOpen(false);
|
||||
reload();
|
||||
void request<{ pendingCount: number; overdueCount: number }>(
|
||||
'/admin/store-withdrawals/overdue-summary',
|
||||
)
|
||||
.then(setOverdueSummary)
|
||||
.catch(() => {});
|
||||
},
|
||||
});
|
||||
setWithdrawApproveId(id);
|
||||
}
|
||||
|
||||
function rejectWithdraw(id: string) {
|
||||
@@ -294,7 +238,11 @@ export default function StoreBillsPage() {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
title: (
|
||||
<Tooltip title="T+1 为出账日(昨日 00:00–今日 00:00 窗口中的今天,不是该账单里最后一笔核销时间);手动提现为申请时间">
|
||||
出账日
|
||||
</Tooltip>
|
||||
),
|
||||
dataIndex: 'date',
|
||||
width: 160,
|
||||
render: (v, row) => (row.kind === 'T1_BILL' ? String(v || '').slice(0, 10) : fmtTime(v)),
|
||||
@@ -389,6 +337,7 @@ export default function StoreBillsPage() {
|
||||
<>
|
||||
含 T+1 自动出账与门店手动提现;按类型筛选,详情与审核动作沿用原接口。
|
||||
「已打款」= T+1 出账终态,「已结算」= 手动提现终态。
|
||||
T+1「出账日」是任务跑的那天(昨日 00:00–今日 00:00 窗口中的今天),不是最后一笔核销时间。
|
||||
{overdueSummary && overdueSummary.overdueCount > 0 ? (
|
||||
<div>
|
||||
<Typography.Text type="danger">
|
||||
@@ -469,7 +418,7 @@ export default function StoreBillsPage() {
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="range" label="日期">
|
||||
<Form.Item name="range" label="出账日">
|
||||
<DatePicker.RangePicker />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
@@ -543,7 +492,7 @@ export default function StoreBillsPage() {
|
||||
<>
|
||||
<Descriptions column={1} size="small" bordered>
|
||||
<Descriptions.Item label="账单号">{String(detail.billNo)}</Descriptions.Item>
|
||||
<Descriptions.Item label="账单日">
|
||||
<Descriptions.Item label="出账日">
|
||||
{String(detail.billDate || '').slice(0, 10)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="应付">
|
||||
@@ -558,6 +507,9 @@ export default function StoreBillsPage() {
|
||||
<Descriptions.Item label="打款凭证">
|
||||
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="凭证照片">
|
||||
<PaymentProofGallery urls={detail.paymentProofUrls} />
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
{(detail.storeAccount as {
|
||||
bankAccountName?: string;
|
||||
@@ -592,8 +544,22 @@ export default function StoreBillsPage() {
|
||||
columns={[
|
||||
{
|
||||
title: '核销单号',
|
||||
render: (_, r) =>
|
||||
String((r.redeemRecord as { redeemNo?: string })?.redeemNo || '—'),
|
||||
render: (_, r) => {
|
||||
const redeemNo = String(
|
||||
(r.redeemRecord as { redeemNo?: string } | undefined)?.redeemNo || '',
|
||||
);
|
||||
return redeemNo ? (
|
||||
<AdminPrimaryLink
|
||||
onClick={() =>
|
||||
navigate(`/redeem-records?redeemNo=${encodeURIComponent(redeemNo)}`)
|
||||
}
|
||||
>
|
||||
{redeemNo}
|
||||
</AdminPrimaryLink>
|
||||
) : (
|
||||
'—'
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '金额',
|
||||
@@ -628,6 +594,9 @@ export default function StoreBillsPage() {
|
||||
<Descriptions.Item label="打款凭证">
|
||||
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="凭证照片">
|
||||
<PaymentProofGallery urls={detail.paymentProofUrls} />
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
{storeAccount ? (
|
||||
<>
|
||||
@@ -662,7 +631,18 @@ export default function StoreBillsPage() {
|
||||
const payout = r.storePayout as
|
||||
| { redeemRecord?: { redeemNo?: string }; payoutAmount?: number }
|
||||
| undefined;
|
||||
return String(payout?.redeemRecord?.redeemNo || '—');
|
||||
const redeemNo = payout?.redeemRecord?.redeemNo || '';
|
||||
return redeemNo ? (
|
||||
<AdminPrimaryLink
|
||||
onClick={() =>
|
||||
navigate(`/redeem-records?redeemNo=${encodeURIComponent(redeemNo)}`)
|
||||
}
|
||||
>
|
||||
{redeemNo}
|
||||
</AdminPrimaryLink>
|
||||
) : (
|
||||
'—'
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -687,6 +667,71 @@ export default function StoreBillsPage() {
|
||||
</>
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
<FinancePayProofModal
|
||||
open={!!payModal}
|
||||
title="确认打款?"
|
||||
hint={`将确认 ${payModal?.ids.length ?? 0} 笔 T+1 门店对账单${
|
||||
payModal?.amountHint != null ? `,合计约 ¥${payModal.amountHint.toFixed(2)}` : ''
|
||||
}。此操作不可撤销。`}
|
||||
okText="确认打款"
|
||||
confirmLoading={paySubmitting}
|
||||
onCancel={() => setPayModal(null)}
|
||||
onOk={async (payload) => {
|
||||
if (!payModal) return;
|
||||
const { ids } = payModal;
|
||||
setPaySubmitting(true);
|
||||
if (ids.length > 1) setBatchLoading(true);
|
||||
try {
|
||||
const body = JSON.stringify({
|
||||
...payload,
|
||||
...(ids.length > 1 ? { ids } : {}),
|
||||
});
|
||||
if (ids.length === 1) {
|
||||
await request(`/admin/store-bills/${ids[0]}/confirm`, { method: 'POST', body });
|
||||
} else {
|
||||
await request('/admin/store-bills/batch-confirm', { method: 'POST', body });
|
||||
}
|
||||
message.success('已确认打款');
|
||||
setPayModal(null);
|
||||
setSelectedKeys([]);
|
||||
reload();
|
||||
} finally {
|
||||
setPaySubmitting(false);
|
||||
setBatchLoading(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
<FinancePayProofModal
|
||||
open={!!withdrawApproveId}
|
||||
title="审核通过并标记已结算?"
|
||||
hint="通过后将标记该提现为已结算,此操作不可撤销。"
|
||||
okText="通过并结算"
|
||||
confirmLoading={withdrawSubmitting}
|
||||
onCancel={() => setWithdrawApproveId(null)}
|
||||
onOk={async (payload) => {
|
||||
if (!withdrawApproveId) return;
|
||||
setWithdrawSubmitting(true);
|
||||
try {
|
||||
await request(`/admin/store-withdrawals/${withdrawApproveId}/approve`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
message.success('已通过并标记已结算');
|
||||
setWithdrawApproveId(null);
|
||||
setDrawerOpen(false);
|
||||
reload();
|
||||
void request<{ pendingCount: number; overdueCount: number }>(
|
||||
'/admin/store-withdrawals/overdue-summary',
|
||||
)
|
||||
.then(setOverdueSummary)
|
||||
.catch(() => {});
|
||||
} finally {
|
||||
setWithdrawSubmitting(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -159,9 +159,20 @@ export default function StoreCategoriesPage() {
|
||||
<Popconfirm
|
||||
title={row.level === 1 ? '删除一级分类?若有门店占用将改为停用' : '删除该分类?若有门店占用将改为停用'}
|
||||
onConfirm={async () => {
|
||||
await request(`/admin/store-categories/${row.id}`, { method: 'DELETE' });
|
||||
message.success('已处理');
|
||||
void reload();
|
||||
try {
|
||||
const res = await request<{ deleted?: boolean; softDisabled?: boolean }>(
|
||||
`/admin/store-categories/${row.id}`,
|
||||
{ method: 'DELETE' },
|
||||
);
|
||||
if (res.softDisabled) {
|
||||
message.success('该分类已有门店占用,已改为停用');
|
||||
} else {
|
||||
message.success('已删除');
|
||||
}
|
||||
void reload();
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '删除失败');
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Button type="link" size="small" danger>删除</Button>
|
||||
|
||||
@@ -4,13 +4,12 @@ import type { ColumnsType } from 'antd/es/table';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
STORE_LOG_CATEGORY_OPTIONS,
|
||||
STORE_LOG_CATEGORY_LABELS,
|
||||
resolveStoreLogCategory,
|
||||
type StoreLogCategory,
|
||||
} from '../lib/store-log';
|
||||
import { request } from '../lib/api';
|
||||
import { AdminCellLine } from '../components/AdminCellLine';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import { clientAppLabel, eventNameLabel, formatRef, storeEventCategoryLabel } from '../lib/display-labels';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
@@ -102,7 +101,7 @@ export default function StoreLogsPage() {
|
||||
{
|
||||
title: '分类', dataIndex: 'category', width: 100,
|
||||
render: (v: StoreLogCategory | null, r) => (
|
||||
<Tag>{STORE_LOG_CATEGORY_LABELS[v ?? ''] || resolveStoreLogCategory(r.eventName) || '其他'}</Tag>
|
||||
<Tag>{storeEventCategoryLabel(r.eventName, v)}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -118,7 +117,7 @@ export default function StoreLogsPage() {
|
||||
setDrawerOpen(true);
|
||||
}}
|
||||
>
|
||||
{v}
|
||||
{eventNameLabel(v)}
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
},
|
||||
@@ -128,7 +127,7 @@ export default function StoreLogsPage() {
|
||||
},
|
||||
{
|
||||
title: '关联', width: 120,
|
||||
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
||||
render: (_, r) => formatRef(r.refType, r.refId),
|
||||
},
|
||||
{
|
||||
title: '摘要',
|
||||
@@ -184,7 +183,7 @@ export default function StoreLogsPage() {
|
||||
<Form.Item name="storeName" label="门店名称"><Input allowClear style={{ width: 140 }} /></Form.Item>
|
||||
<Form.Item name="storeAccountId" label="账号ID"><Input allowClear style={{ width: 120 }} /></Form.Item>
|
||||
<Form.Item name="phone" label="手机号"><Input allowClear style={{ width: 130 }} /></Form.Item>
|
||||
<Form.Item name="eventName" label="事件名"><Input allowClear style={{ width: 160 }} placeholder="store_login_success" /></Form.Item>
|
||||
<Form.Item name="eventName" label="事件编码"><Input allowClear style={{ width: 160 }} placeholder="事件编码" /></Form.Item>
|
||||
<Form.Item><Button type="primary" htmlType="submit">筛选</Button></Form.Item>
|
||||
<Form.Item><Button onClick={() => { form.resetFields(); setFilters({}); setCategory(''); setSearchParams({}); setPage(1); }}>重置</Button></Form.Item>
|
||||
</Form>
|
||||
@@ -198,12 +197,12 @@ export default function StoreLogsPage() {
|
||||
<Descriptions.Item label="账号">{String(detail.accountName || detail.storeAccountId || '系统/HQ')}</Descriptions.Item>
|
||||
<Descriptions.Item label="手机">{String(detail.accountPhone || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="分类">
|
||||
{(STORE_LOG_CATEGORY_LABELS as Record<string, string>)[String(detail.category ?? '')] || String(detail.category || '—')}
|
||||
{storeEventCategoryLabel(String(detail.eventName ?? ''), detail.category ? String(detail.category) : null)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="事件">{String(detail.eventName)}</Descriptions.Item>
|
||||
<Descriptions.Item label="事件">{eventNameLabel(String(detail.eventName ?? ''))}</Descriptions.Item>
|
||||
<Descriptions.Item label="来源">{SOURCE_LABELS[String(detail.source) as Row['source']] || String(detail.source || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="客户端">{String(detail.clientApp || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联">{detail.refType ? `${String(detail.refType)}#${String(detail.refId)}` : '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="端">{clientAppLabel(detail.clientApp ? String(detail.clientApp) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联">{formatRef(detail.refType ? String(detail.refType) : null, detail.refId ? String(detail.refId) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="时间">{fmtTime(String(detail.createdAt))}</Descriptions.Item>
|
||||
<Descriptions.Item label="参数">
|
||||
<pre style={{ margin: 0, whiteSpace: 'pre-wrap', wordBreak: 'break-all' }}>
|
||||
|
||||
@@ -13,6 +13,7 @@ type Row = {
|
||||
id: string;
|
||||
serviceScore: number;
|
||||
envScore: number;
|
||||
comment?: string | null;
|
||||
createdAt: string;
|
||||
redeemNo: string;
|
||||
redeemAmount: number;
|
||||
@@ -62,6 +63,12 @@ export default function StoreRatingsPage() {
|
||||
{ title: '核销额', dataIndex: 'redeemAmount', width: 90, render: (v) => `¥${v}` },
|
||||
{ title: '服务分', dataIndex: 'serviceScore', width: 80 },
|
||||
{ title: '环境分', dataIndex: 'envScore', width: 80 },
|
||||
{
|
||||
title: '评语',
|
||||
dataIndex: 'comment',
|
||||
ellipsis: true,
|
||||
render: (v: string | null) => v || '—',
|
||||
},
|
||||
{ title: '评价时间', dataIndex: 'createdAt', width: 170, render: fmtTime },
|
||||
];
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import { useAdminList } from '../lib/useAdminList';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
import { FinancePayProofModal, PaymentProofGallery } from '../components/FinancePayProof';
|
||||
|
||||
|
||||
type Row = {
|
||||
@@ -70,6 +71,8 @@ export default function StoreWithdrawalsPage() {
|
||||
pendingCount: number;
|
||||
overdueCount: number;
|
||||
} | null>(null);
|
||||
const [approveId, setApproveId] = useState<string | null>(null);
|
||||
const [approveSubmitting, setApproveSubmitting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
void request<Paginated<StoreOption>>(`/admin/stores?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||
@@ -89,34 +92,7 @@ export default function StoreWithdrawalsPage() {
|
||||
}
|
||||
|
||||
function approve(id: string) {
|
||||
let paymentRef = '';
|
||||
Modal.confirm({
|
||||
title: '审核通过并标记已结算?',
|
||||
content: (
|
||||
<Input
|
||||
placeholder="打款凭证号(可选)"
|
||||
onChange={(e) => {
|
||||
paymentRef = e.target.value;
|
||||
}}
|
||||
/>
|
||||
),
|
||||
okText: '通过并结算',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
await request(`/admin/store-withdrawals/${id}/approve`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ paymentRef: paymentRef.trim() || undefined }),
|
||||
});
|
||||
message.success('已通过并标记已结算');
|
||||
setDrawerOpen(false);
|
||||
reload();
|
||||
void request<{ pendingCount: number; overdueCount: number }>(
|
||||
'/admin/store-withdrawals/overdue-summary',
|
||||
)
|
||||
.then(setOverdueSummary)
|
||||
.catch(() => {});
|
||||
},
|
||||
});
|
||||
setApproveId(id);
|
||||
}
|
||||
|
||||
function reject(id: string) {
|
||||
@@ -356,6 +332,9 @@ export default function StoreWithdrawalsPage() {
|
||||
{detail.paymentRef ? (
|
||||
<Descriptions.Item label="打款凭证">{String(detail.paymentRef)}</Descriptions.Item>
|
||||
) : null}
|
||||
<Descriptions.Item label="凭证照片">
|
||||
<PaymentProofGallery urls={detail.paymentProofUrls} />
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="收款户名">
|
||||
{storeAccount?.bankAccountName || '—'}
|
||||
</Descriptions.Item>
|
||||
@@ -394,6 +373,36 @@ export default function StoreWithdrawalsPage() {
|
||||
</>
|
||||
) : null}
|
||||
</Drawer>
|
||||
|
||||
<FinancePayProofModal
|
||||
open={!!approveId}
|
||||
title="审核通过并标记已结算?"
|
||||
hint="通过后将标记该提现为已结算,此操作不可撤销。"
|
||||
okText="通过并结算"
|
||||
confirmLoading={approveSubmitting}
|
||||
onCancel={() => setApproveId(null)}
|
||||
onOk={async (payload) => {
|
||||
if (!approveId) return;
|
||||
setApproveSubmitting(true);
|
||||
try {
|
||||
await request(`/admin/store-withdrawals/${approveId}/approve`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
message.success('已通过并标记已结算');
|
||||
setApproveId(null);
|
||||
setDrawerOpen(false);
|
||||
reload();
|
||||
void request<{ pendingCount: number; overdueCount: number }>(
|
||||
'/admin/store-withdrawals/overdue-summary',
|
||||
)
|
||||
.then(setOverdueSummary)
|
||||
.catch(() => {});
|
||||
} finally {
|
||||
setApproveSubmitting(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import { fmtTime } from '../lib/constants';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import OssUpload from '../components/OssUpload';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
|
||||
|
||||
@@ -560,50 +561,43 @@ export default function SupportTicketsPage() {
|
||||
return (
|
||||
<div>
|
||||
{settingsModal}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
marginBottom: 16,
|
||||
}}
|
||||
>
|
||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||
技术支持
|
||||
</Typography.Title>
|
||||
{settingsButton}
|
||||
<Space>
|
||||
{isSuperAdmin ? (
|
||||
<>
|
||||
<Button
|
||||
disabled={!selectedRowKeys.length}
|
||||
loading={batchCreateSaving}
|
||||
onClick={() => void submitBatchCreateTasks()}
|
||||
>
|
||||
一键创建任务
|
||||
</Button>
|
||||
<Button disabled={!selectedRowKeys.length} onClick={openBatchPublish}>
|
||||
一键发布
|
||||
</Button>
|
||||
<Button disabled={!selectedRowKeys.length} loading={acting} onClick={() => void startBatchPreview()}>
|
||||
批量审核
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!selectedRowKeys.length}
|
||||
onClick={() => {
|
||||
batchStatusForm.setFieldsValue({ status: 'TESTING', rejectReason: '', note: '' });
|
||||
setBatchStatusOpen(true);
|
||||
}}
|
||||
>
|
||||
批量改状态
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
||||
创建工单
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
<AdminListHeader
|
||||
title="技术支持"
|
||||
settings={settingsButton}
|
||||
actions={
|
||||
<>
|
||||
{isSuperAdmin ? (
|
||||
<>
|
||||
<Button
|
||||
disabled={!selectedRowKeys.length}
|
||||
loading={batchCreateSaving}
|
||||
onClick={() => void submitBatchCreateTasks()}
|
||||
>
|
||||
一键创建任务
|
||||
</Button>
|
||||
<Button disabled={!selectedRowKeys.length} onClick={openBatchPublish}>
|
||||
一键发布
|
||||
</Button>
|
||||
<Button disabled={!selectedRowKeys.length} loading={acting} onClick={() => void startBatchPreview()}>
|
||||
批量审核
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!selectedRowKeys.length}
|
||||
onClick={() => {
|
||||
batchStatusForm.setFieldsValue({ status: 'TESTING', rejectReason: '', note: '' });
|
||||
setBatchStatusOpen(true);
|
||||
}}
|
||||
>
|
||||
批量改状态
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
||||
创建工单
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Form
|
||||
layout="inline"
|
||||
|
||||
@@ -3,6 +3,13 @@ import { Button, Descriptions, Drawer, Form, Input, Select, Table, Tag, Typograp
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { request } from '../lib/api';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import {
|
||||
THIRD_PARTY_PROVIDER_LABELS,
|
||||
THIRD_PARTY_SCENE_LABELS,
|
||||
THIRD_PARTY_STATUS_LABELS,
|
||||
formatRef,
|
||||
zhLabel,
|
||||
} from '../lib/display-labels';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
@@ -26,14 +33,14 @@ type Row = {
|
||||
};
|
||||
|
||||
const PROVIDER_OPTIONS = [
|
||||
{ value: 'WECHAT_AUTH', label: 'WECHAT_AUTH' },
|
||||
{ value: 'WECHAT_PAY', label: 'WECHAT_PAY' },
|
||||
{ value: 'WECHAT_MAP', label: 'WECHAT_MAP' },
|
||||
{ value: 'ALIYUN_OSS', label: 'ALIYUN_OSS' },
|
||||
{ value: 'ALIYUN_SMS', label: 'ALIYUN_SMS' },
|
||||
{ value: 'MOCK_SMS', label: 'MOCK_SMS' },
|
||||
{ value: 'XFX', label: '小飞侠 (XFX)' },
|
||||
{ value: 'LOGISTICS', label: 'LOGISTICS' },
|
||||
{ value: 'WECHAT_AUTH', label: '微信授权' },
|
||||
{ value: 'WECHAT_PAY', label: '微信支付' },
|
||||
{ value: 'WECHAT_MAP', label: '微信/腾讯地图' },
|
||||
{ value: 'ALIYUN_OSS', label: '阿里云 OSS' },
|
||||
{ value: 'ALIYUN_SMS', label: '阿里云短信' },
|
||||
{ value: 'MOCK_SMS', label: 'Mock 短信' },
|
||||
{ value: 'XFX', label: '小飞侠' },
|
||||
{ value: 'LOGISTICS', label: '物流快递' },
|
||||
];
|
||||
|
||||
const STATUS_COLOR: Record<string, string> = {
|
||||
@@ -75,18 +82,18 @@ export default function ThirdPartyLogsPage() {
|
||||
|
||||
const baseColumns: ColumnsType<Row> = [
|
||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||
{ title: 'Provider', dataIndex: 'provider', width: 120 },
|
||||
{ title: '场景', dataIndex: 'scene', width: 120 },
|
||||
{ title: '渠道', dataIndex: 'provider', width: 120, render: (v: string) => zhLabel(THIRD_PARTY_PROVIDER_LABELS, v) },
|
||||
{ title: '场景', dataIndex: 'scene', width: 140, render: (v: string) => zhLabel(THIRD_PARTY_SCENE_LABELS, v) },
|
||||
{
|
||||
title: '关联',
|
||||
width: 120,
|
||||
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
||||
render: (_, r) => formatRef(r.refType, r.refId),
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (v: string) => <Tag color={STATUS_COLOR[v] ?? 'default'}>{v}</Tag>,
|
||||
render: (v: string) => <Tag color={STATUS_COLOR[v] ?? 'default'}>{zhLabel(THIRD_PARTY_STATUS_LABELS, v)}</Tag>,
|
||||
},
|
||||
{
|
||||
title: '错误信息',
|
||||
@@ -147,11 +154,11 @@ export default function ThirdPartyLogsPage() {
|
||||
setPage(1);
|
||||
}}
|
||||
>
|
||||
<Form.Item name="provider" label="Provider">
|
||||
<Form.Item name="provider" label="渠道">
|
||||
<Select allowClear placeholder="全部" style={{ width: 160 }} options={PROVIDER_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="scene" label="场景">
|
||||
<Input allowClear placeholder="JSSDK_CONFIG / LOGIN" style={{ width: 160 }} />
|
||||
<Input allowClear placeholder="场景编码" style={{ width: 160 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="refId" label="关联ID">
|
||||
<Input allowClear style={{ width: 120 }} />
|
||||
@@ -181,13 +188,15 @@ export default function ThirdPartyLogsPage() {
|
||||
{detail && (
|
||||
<Descriptions column={1} bordered size="small">
|
||||
<Descriptions.Item label="ID">{String(detail.id)}</Descriptions.Item>
|
||||
<Descriptions.Item label="Provider">{String(detail.provider)}</Descriptions.Item>
|
||||
<Descriptions.Item label="场景">{String(detail.scene)}</Descriptions.Item>
|
||||
<Descriptions.Item label="渠道">{zhLabel(THIRD_PARTY_PROVIDER_LABELS, String(detail.provider))}</Descriptions.Item>
|
||||
<Descriptions.Item label="场景">{zhLabel(THIRD_PARTY_SCENE_LABELS, String(detail.scene))}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">
|
||||
<Tag color={STATUS_COLOR[String(detail.status)] ?? 'default'}>{String(detail.status)}</Tag>
|
||||
<Tag color={STATUS_COLOR[String(detail.status)] ?? 'default'}>
|
||||
{zhLabel(THIRD_PARTY_STATUS_LABELS, String(detail.status))}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="关联">
|
||||
{detail.refType ? `${String(detail.refType)}#${String(detail.refId)}` : '—'}
|
||||
{formatRef(detail.refType ? String(detail.refType) : null, detail.refId ? String(detail.refId) : null)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="外部单号">{String(detail.externalNo ?? '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="金额">{detail.amount != null ? String(detail.amount) : '—'}</Descriptions.Item>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Button, Descriptions, Drawer, Form, Input, Segmented, Space, Table, Tag, Typography } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { USER_LOG_CATEGORY_OPTIONS, resolveUserLogCategory, USER_LOG_CATEGORY_LABELS, type UserLogCategory } from '../lib/user-log';
|
||||
import { USER_LOG_CATEGORY_OPTIONS, type UserLogCategory } from '../lib/user-log';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { request } from '../lib/api';
|
||||
import { AdminCellLine } from '../components/AdminCellLine';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import { clientAppLabel, eventNameLabel, formatRef, userEventCategoryLabel } from '../lib/display-labels';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
@@ -27,8 +28,6 @@ type Row = {
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
const CATEGORY_LABELS = USER_LOG_CATEGORY_LABELS;
|
||||
|
||||
function summarizeExtra(json: Record<string, unknown> | null) {
|
||||
if (!json) return '—';
|
||||
const text = JSON.stringify(json);
|
||||
@@ -79,7 +78,7 @@ export default function UserLogsPage() {
|
||||
{
|
||||
title: '分类', dataIndex: 'category', width: 100,
|
||||
render: (v: UserLogCategory | null, r) => (
|
||||
<Tag>{CATEGORY_LABELS[v ?? ''] || resolveUserLogCategory(r.eventName) || '其他'}</Tag>
|
||||
<Tag>{userEventCategoryLabel(r.eventName, v)}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -93,13 +92,16 @@ export default function UserLogsPage() {
|
||||
setDrawerOpen(true);
|
||||
}}
|
||||
>
|
||||
{v}
|
||||
{eventNameLabel(v)}
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '端', dataIndex: 'clientApp', width: 110, render: (v) => clientAppLabel(v),
|
||||
},
|
||||
{
|
||||
title: '关联', width: 120,
|
||||
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
||||
render: (_, r) => formatRef(r.refType, r.refId),
|
||||
},
|
||||
{
|
||||
title: '摘要',
|
||||
@@ -148,7 +150,7 @@ export default function UserLogsPage() {
|
||||
<Form.Item name="userId" label="用户ID"><Input allowClear style={{ width: 120 }} /></Form.Item>
|
||||
<Form.Item name="phone" label="手机号"><Input allowClear style={{ width: 130 }} /></Form.Item>
|
||||
<Form.Item name="userNo" label="用户编号"><Input allowClear style={{ width: 120 }} /></Form.Item>
|
||||
<Form.Item name="eventName" label="事件名"><Input allowClear style={{ width: 160 }} placeholder="pay_success" /></Form.Item>
|
||||
<Form.Item name="eventName" label="事件编码"><Input allowClear style={{ width: 160 }} placeholder="事件编码" /></Form.Item>
|
||||
<Form.Item><Button type="primary" htmlType="submit">筛选</Button></Form.Item>
|
||||
<Form.Item><Button onClick={() => { form.resetFields(); setFilters({}); setCategory(''); setSearchParams({}); setPage(1); }}>重置</Button></Form.Item>
|
||||
</Form>
|
||||
@@ -160,10 +162,10 @@ export default function UserLogsPage() {
|
||||
<Descriptions.Item label="ID">{String(detail.id)}</Descriptions.Item>
|
||||
<Descriptions.Item label="用户">{String(detail.nickname || detail.userNo || detail.userId || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="手机">{String(detail.phone || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="分类">{CATEGORY_LABELS[String(detail.category ?? '')] || String(detail.category || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="事件">{String(detail.eventName)}</Descriptions.Item>
|
||||
<Descriptions.Item label="客户端">{String(detail.clientApp || '—')}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联">{detail.refType ? `${String(detail.refType)}#${String(detail.refId)}` : '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="分类">{userEventCategoryLabel(String(detail.eventName ?? ''), detail.category ? String(detail.category) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="事件">{eventNameLabel(String(detail.eventName ?? ''))}</Descriptions.Item>
|
||||
<Descriptions.Item label="端">{clientAppLabel(detail.clientApp ? String(detail.clientApp) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联">{formatRef(detail.refType ? String(detail.refType) : null, detail.refId ? String(detail.refId) : null)}</Descriptions.Item>
|
||||
<Descriptions.Item label="时间">{fmtTime(String(detail.createdAt))}</Descriptions.Item>
|
||||
<Descriptions.Item label="参数">
|
||||
<pre style={{ margin: 0, whiteSpace: 'pre-wrap', wordBreak: 'break-all' }}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Link, useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
@@ -17,12 +17,14 @@ import {
|
||||
message,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { USER_SOURCE_TYPE_LABELS, resolveUserLogCategory, type UserSourceType } from '@dukang/shared-types';
|
||||
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
||||
import { USER_SOURCE_TYPE_LABELS, type UserSourceType } from '@dukang/shared-types';
|
||||
import { request, type AdminUserRow, type HqProfile, type Paginated } from '../lib/api';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
import { ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
|
||||
import { clientAppLabel, eventNameLabel, userEventCategoryLabel } from '../lib/display-labels';
|
||||
|
||||
type UserOrderRow = {
|
||||
id: string;
|
||||
@@ -119,6 +121,24 @@ type UserBehaviorLog = {
|
||||
extraJson?: Record<string, unknown> | null;
|
||||
};
|
||||
|
||||
type AssocPartnerBrief = {
|
||||
id: string;
|
||||
name: string;
|
||||
companyName?: string | null;
|
||||
phone?: string | null;
|
||||
};
|
||||
|
||||
type PartnerOption = { id: string; companyName?: string | null; name?: string; phone?: string };
|
||||
|
||||
const FILTERS_COLLAPSED_KEY = 'admin-users-filters-collapsed';
|
||||
const ASSOC_UNBOUND = 'none';
|
||||
|
||||
function formatAssocPartner(p?: AssocPartnerBrief | PartnerOption | null) {
|
||||
if (!p) return '—';
|
||||
const title = p.companyName || p.name || p.id;
|
||||
return [title, p.phone].filter(Boolean).join(' / ') || '—';
|
||||
}
|
||||
|
||||
type UserDetail = AdminUserRow & {
|
||||
wxUnionId?: string | null;
|
||||
cityPref?: Record<string, unknown> | null;
|
||||
@@ -127,6 +147,8 @@ type UserDetail = AdminUserRow & {
|
||||
orders?: UserOrderRow[];
|
||||
mergedFromCount?: number;
|
||||
addressCount?: number;
|
||||
assocPartner?: AssocPartnerBrief | null;
|
||||
assocBoundAt?: string | null;
|
||||
};
|
||||
|
||||
type BatchDeletePreviewItem = {
|
||||
@@ -154,6 +176,7 @@ type BatchDeletePreview = {
|
||||
export default function UsersPage() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [form] = Form.useForm();
|
||||
const [profile, setProfile] = useState<HqProfile | null>(null);
|
||||
const [data, setData] = useState<Paginated<AdminUserRow> | null>(null);
|
||||
@@ -174,44 +197,88 @@ export default function UsersPage() {
|
||||
const [batchDeleting, setBatchDeleting] = useState(false);
|
||||
const [batchRiskAck, setBatchRiskAck] = useState(false);
|
||||
const canDeleteUsers = (profile?.permissionKeys ?? []).includes('users_delete');
|
||||
const canEditAssoc = (profile?.permissionKeys ?? []).includes('users_partner_assoc');
|
||||
const [partners, setPartners] = useState<PartnerOption[]>([]);
|
||||
const [assocPartnerId, setAssocPartnerId] = useState<string | undefined>();
|
||||
const [savingAssoc, setSavingAssoc] = useState(false);
|
||||
const [filtersCollapsed, setFiltersCollapsed] = useState(() => {
|
||||
try {
|
||||
return localStorage.getItem(FILTERS_COLLAPSED_KEY) === '1';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const partnerOptions = useMemo(() => {
|
||||
const map = new Map(partners.map((p) => [p.id, p]));
|
||||
if (detail?.assocPartner && !map.has(detail.assocPartner.id)) {
|
||||
map.set(detail.assocPartner.id, detail.assocPartner);
|
||||
}
|
||||
return [...map.values()];
|
||||
}, [partners, detail?.assocPartner]);
|
||||
|
||||
useEffect(() => {
|
||||
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void request<Paginated<PartnerOption>>(`/admin/partners?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||
.then((res) => setPartners(res.items ?? []))
|
||||
.catch(() => setPartners([]));
|
||||
}, []);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const values = form.getFieldsValue();
|
||||
const qs = new URLSearchParams({ page: String(page), pageSize: String(pageSize) });
|
||||
const userId = String(values.userId || '').trim();
|
||||
if (userId) qs.set('userId', userId);
|
||||
if (values.phone) qs.set('phone', values.phone);
|
||||
if (values.userNo) qs.set('userNo', values.userNo);
|
||||
if (values.deviceKey) qs.set('deviceKey', values.deviceKey);
|
||||
if (values.phoneVerified !== undefined && values.phoneVerified !== '') {
|
||||
qs.set('phoneVerified', values.phoneVerified);
|
||||
}
|
||||
if (values.status !== undefined && values.status !== '') {
|
||||
qs.set('status', String(values.status));
|
||||
}
|
||||
if (values.excludeTest) qs.set('excludeTest', 'true');
|
||||
const keyword = String(values.keyword || '').trim();
|
||||
if (keyword) qs.set('keyword', keyword);
|
||||
const assocPartnerAccountId = String(
|
||||
values.assocPartnerAccountId || searchParams.get('assocPartnerAccountId') || '',
|
||||
).trim();
|
||||
if (assocPartnerAccountId) qs.set('assocPartnerAccountId', assocPartnerAccountId);
|
||||
const res = await request<Paginated<AdminUserRow>>(`/admin/users?${qs}`);
|
||||
setData(res);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [form, page, pageSize]);
|
||||
}, [form, page, pageSize, searchParams]);
|
||||
|
||||
useEffect(() => {
|
||||
const userId = searchParams.get('userId');
|
||||
const assocPartnerAccountId = searchParams.get('assocPartnerAccountId');
|
||||
form.setFieldsValue({
|
||||
...(userId ? { userId } : {}),
|
||||
...(assocPartnerAccountId ? { assocPartnerAccountId } : {}),
|
||||
});
|
||||
}, [searchParams, form]);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
}, [load, searchParams]);
|
||||
|
||||
useEffect(() => {
|
||||
const openUserId = (location.state as { openUserId?: string } | null)?.openUserId;
|
||||
if (openUserId) {
|
||||
void openDetail(openUserId);
|
||||
navigate(location.pathname, { replace: true, state: null });
|
||||
}
|
||||
}, [location.state, location.pathname, navigate]);
|
||||
if (!openUserId) return;
|
||||
form.setFieldsValue({ userId: openUserId });
|
||||
setPage(1);
|
||||
void openDetail(openUserId);
|
||||
navigate(`${location.pathname}?userId=${encodeURIComponent(openUserId)}`, {
|
||||
replace: true,
|
||||
state: null,
|
||||
});
|
||||
}, [location.state, location.pathname, navigate, form]);
|
||||
|
||||
async function openDetail(id: string) {
|
||||
const [res, logs] = await Promise.all([
|
||||
@@ -221,10 +288,29 @@ export default function UsersPage() {
|
||||
),
|
||||
]);
|
||||
setDetail(res);
|
||||
setAssocPartnerId(res.assocPartner?.id);
|
||||
setBehaviorLogs(logs.items ?? []);
|
||||
setDrawerOpen(true);
|
||||
}
|
||||
|
||||
async function saveAssoc() {
|
||||
if (!detail) return;
|
||||
setSavingAssoc(true);
|
||||
try {
|
||||
await request(`/admin/users/${detail.id}/assoc`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ partnerAccountId: assocPartnerId || null }),
|
||||
});
|
||||
message.success(assocPartnerId ? '已更新关联合伙人' : '已解除关联');
|
||||
await openDetail(detail.id);
|
||||
void load();
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '保存失败');
|
||||
} finally {
|
||||
setSavingAssoc(false);
|
||||
}
|
||||
}
|
||||
|
||||
function openDeleteModal() {
|
||||
setDeleteConfirm('');
|
||||
setDeleteOpen(true);
|
||||
@@ -407,6 +493,12 @@ export default function UsersPage() {
|
||||
width: 120,
|
||||
render: (v) => v || '—',
|
||||
},
|
||||
{
|
||||
title: '关联合伙人',
|
||||
dataIndex: 'assocPartner',
|
||||
width: 180,
|
||||
render: (p: AdminUserRow['assocPartner']) => formatAssocPartner(p),
|
||||
},
|
||||
{
|
||||
title: 'deviceKey',
|
||||
dataIndex: 'deviceKey',
|
||||
@@ -497,37 +589,108 @@ export default function UsersPage() {
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={() => { setPage(1); void load(); }}>
|
||||
<Form.Item name="phone" label="手机号">
|
||||
<Input placeholder="模糊搜索" allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="userNo" label="用户编号">
|
||||
<Input placeholder="DK..." allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="deviceKey" label="deviceKey">
|
||||
<Input placeholder="UUID" allowClear style={{ width: 200 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="phoneVerified" label="验手机">
|
||||
<Select allowClear style={{ width: 100 }} options={[
|
||||
{ value: '1', label: '已验证' },
|
||||
{ value: '0', label: '访客' },
|
||||
]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="status" label="状态">
|
||||
<Select allowClear style={{ width: 90 }} options={[
|
||||
{ value: 1, label: '正常' },
|
||||
{ value: 0, label: '停用' },
|
||||
]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="excludeTest" valuePropName="checked">
|
||||
<Checkbox>过滤测试账号</Checkbox>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
<Button onClick={() => { form.resetFields(); setPage(1); void load(); }}>重置</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onFinish={() => {
|
||||
setPage(1);
|
||||
const next = new URLSearchParams();
|
||||
const userId = String(form.getFieldValue('userId') || '').trim();
|
||||
const assoc = String(form.getFieldValue('assocPartnerAccountId') || '').trim();
|
||||
if (userId) next.set('userId', userId);
|
||||
if (assoc) next.set('assocPartnerAccountId', assoc);
|
||||
if (next.toString() !== searchParams.toString()) {
|
||||
setSearchParams(next, { replace: true });
|
||||
}
|
||||
void load();
|
||||
}}
|
||||
>
|
||||
<div className="admin-orders-filter-row">
|
||||
<Form.Item name="keyword" label="搜索" className="admin-orders-filter-item admin-users-filter-item--keyword">
|
||||
<Input allowClear placeholder="编号/昵称/备注/手机" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="assocPartnerAccountId"
|
||||
label="关联合伙人"
|
||||
className="admin-orders-filter-item admin-orders-filter-item--status"
|
||||
>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="全部"
|
||||
options={[
|
||||
{ value: 'any', label: '已关联(全部)' },
|
||||
{ value: ASSOC_UNBOUND, label: '未关联' },
|
||||
...partners.map((p) => ({
|
||||
value: p.id,
|
||||
label: formatAssocPartner(p),
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label=" " colon={false} className="admin-orders-filter-item admin-orders-filter-actions">
|
||||
<Space size={8} wrap>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
form.resetFields();
|
||||
setPage(1);
|
||||
if (searchParams.toString()) {
|
||||
setSearchParams({}, { replace: true });
|
||||
} else {
|
||||
void load();
|
||||
}
|
||||
}}
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
icon={filtersCollapsed ? <DownOutlined /> : <UpOutlined />}
|
||||
onClick={() => {
|
||||
setFiltersCollapsed((prev) => {
|
||||
const next = !prev;
|
||||
try {
|
||||
localStorage.setItem(FILTERS_COLLAPSED_KEY, next ? '1' : '0');
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}}
|
||||
>
|
||||
{filtersCollapsed ? '展开' : '收起'}
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
{!filtersCollapsed ? (
|
||||
<div className="admin-orders-filter-row">
|
||||
<Form.Item name="phone" label="手机号" className="admin-orders-filter-item admin-orders-filter-item--md">
|
||||
<Input placeholder="模糊搜索" allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="userNo" label="用户编号" className="admin-orders-filter-item admin-orders-filter-item--md">
|
||||
<Input placeholder="DK..." allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="userId" label="用户ID" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Input placeholder="精确匹配" allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="phoneVerified" label="验手机" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Select allowClear placeholder="全部" options={[
|
||||
{ value: '1', label: '已验证' },
|
||||
{ value: '0', label: '访客' },
|
||||
]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="status" label="状态" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Select allowClear placeholder="全部" options={[
|
||||
{ value: 1, label: '正常' },
|
||||
{ value: 0, label: '停用' },
|
||||
]} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
) : null}
|
||||
</Form>
|
||||
|
||||
<Table
|
||||
@@ -569,7 +732,7 @@ export default function UsersPage() {
|
||||
<Descriptions.Item label="用户编号">{detail.userNo}</Descriptions.Item>
|
||||
<Descriptions.Item label="昵称">{detail.nickname || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="备注">{detail.hqRemark || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="手机号">{maskPhone(detail.phone)}</Descriptions.Item>
|
||||
<Descriptions.Item label="手机号">{detail.phone || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="验手机时间">
|
||||
{detail.phoneVerifiedAt ? new Date(detail.phoneVerifiedAt).toLocaleString('zh-CN') : '未验证'}
|
||||
</Descriptions.Item>
|
||||
@@ -591,6 +754,38 @@ export default function UsersPage() {
|
||||
) : '—'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="来源标签">{detail.sourceLabel || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联合伙人">
|
||||
{canEditAssoc ? (
|
||||
<Space wrap>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="未关联"
|
||||
style={{ minWidth: 260 }}
|
||||
value={assocPartnerId}
|
||||
onChange={setAssocPartnerId}
|
||||
options={partnerOptions.map((p) => ({
|
||||
value: p.id,
|
||||
label: `${p.companyName || p.name || p.id}${p.phone ? ` · ${p.phone}` : ''}`,
|
||||
}))}
|
||||
/>
|
||||
<Button type="primary" size="small" loading={savingAssoc} onClick={() => void saveAssoc()}>
|
||||
保存关联
|
||||
</Button>
|
||||
<Typography.Text type="secondary">清空后保存即解绑;已支付订单佣金快照不变</Typography.Text>
|
||||
</Space>
|
||||
) : detail.assocPartner ? (
|
||||
`${detail.assocPartner.companyName || detail.assocPartner.name}${
|
||||
detail.assocPartner.phone ? ` / ${detail.assocPartner.phone}` : ''
|
||||
}`
|
||||
) : (
|
||||
'—'
|
||||
)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="关联时间">
|
||||
{detail.assocBoundAt ? fmtTime(detail.assocBoundAt) : '—'}
|
||||
</Descriptions.Item>
|
||||
{detail.sourcePromo && (
|
||||
<Descriptions.Item label="推广码">
|
||||
<Link to={`/promo-codes/${detail.sourcePromo.id}`}>
|
||||
@@ -603,7 +798,7 @@ export default function UsersPage() {
|
||||
<Descriptions.Item label="deviceKey">{detail.deviceKey || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="合并至">
|
||||
{detail.mergedInto
|
||||
? `${detail.mergedInto.userNo} (${detail.mergedInto.phone ? maskPhone(detail.mergedInto.phone) : '无手机'})`
|
||||
? `${detail.mergedInto.userNo} (${detail.mergedInto.phone || '无手机'})`
|
||||
: '—'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="被合并访客数">{detail.mergedFromCount ?? 0}</Descriptions.Item>
|
||||
@@ -640,10 +835,10 @@ export default function UsersPage() {
|
||||
{
|
||||
title: '分类',
|
||||
width: 100,
|
||||
render: (_, r) => resolveUserLogCategory(r.eventName) ?? '—',
|
||||
render: (_, r) => userEventCategoryLabel(r.eventName),
|
||||
},
|
||||
{ title: '事件', dataIndex: 'eventName' },
|
||||
{ title: '端', dataIndex: 'clientApp', width: 90 },
|
||||
{ title: '事件', dataIndex: 'eventName', render: (v: string) => eventNameLabel(v) },
|
||||
{ title: '端', dataIndex: 'clientApp', width: 110, render: (v: string | null) => clientAppLabel(v) },
|
||||
]}
|
||||
/>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { ColumnsType } from 'antd/es/table';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import { request } from '../lib/api';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import { WECOM_BOT_ACTION_LABELS, zhLabel } from '../lib/display-labels';
|
||||
import type { WecomBotLogDto } from '@dukang/shared-types';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
@@ -39,8 +40,8 @@ export default function WecomBotLogsPage() {
|
||||
),
|
||||
},
|
||||
{ title: '企微用户', dataIndex: 'wecomUserId', width: 120 },
|
||||
{ title: '动作', dataIndex: 'action', width: 160 },
|
||||
{ title: '权限', dataIndex: 'permission', width: 140, render: (v) => v || '—' },
|
||||
{ title: '动作', dataIndex: 'action', width: 180, render: (v: string) => zhLabel(WECOM_BOT_ACTION_LABELS, v) },
|
||||
{ title: '权限', dataIndex: 'permission', width: 160, render: (v) => zhLabel(WECOM_BOT_ACTION_LABELS, v) },
|
||||
{
|
||||
title: '结果',
|
||||
dataIndex: 'success',
|
||||
@@ -81,13 +82,13 @@ export default function WecomBotLogsPage() {
|
||||
}}
|
||||
>
|
||||
<Form.Item name="botId" label="机器人 ID">
|
||||
<Input allowClear placeholder="wecom_bot.id" style={{ width: 140 }} />
|
||||
<Input allowClear placeholder="机器人 ID" style={{ width: 140 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="wecomUserId" label="企微 userid">
|
||||
<Input allowClear placeholder="userid" style={{ width: 140 }} />
|
||||
<Form.Item name="wecomUserId" label="企微用户">
|
||||
<Input allowClear placeholder="企微用户 ID" style={{ width: 140 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="action" label="动作">
|
||||
<Input allowClear placeholder="order.read" style={{ width: 140 }} />
|
||||
<Input allowClear placeholder="动作编码" style={{ width: 140 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="success" label="结果">
|
||||
<Select
|
||||
@@ -130,8 +131,8 @@ export default function WecomBotLogsPage() {
|
||||
<Descriptions.Item label="时间">{fmtTime(detail.createdAt)}</Descriptions.Item>
|
||||
<Descriptions.Item label="机器人">{detail.botName || detail.botKey || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="企微用户">{detail.wecomUserId}</Descriptions.Item>
|
||||
<Descriptions.Item label="动作">{detail.action}</Descriptions.Item>
|
||||
<Descriptions.Item label="权限">{detail.permission || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="动作">{zhLabel(WECOM_BOT_ACTION_LABELS, detail.action)}</Descriptions.Item>
|
||||
<Descriptions.Item label="权限">{zhLabel(WECOM_BOT_ACTION_LABELS, detail.permission)}</Descriptions.Item>
|
||||
<Descriptions.Item label="输入摘要">{detail.inputSummary || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="结果">{detail.success ? '成功' : '失败'}</Descriptions.Item>
|
||||
<Descriptions.Item label="错误">{detail.errorMessage || '—'}</Descriptions.Item>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState, type CSSProperties } from 'react';
|
||||
import { useOutletContext } from 'react-router-dom';
|
||||
import { useNavigate, useOutletContext } from 'react-router-dom';
|
||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
@@ -13,6 +14,7 @@ import {
|
||||
Select,
|
||||
Space,
|
||||
Statistic,
|
||||
Tooltip,
|
||||
Typography,
|
||||
message,
|
||||
} from 'antd';
|
||||
@@ -35,6 +37,9 @@ const descContentStyle: CSSProperties = {
|
||||
wordBreak: 'break-all',
|
||||
};
|
||||
|
||||
const ATTRIBUTION_HINT =
|
||||
'首次触达本推广码的用户。每人只归因一次、只归一个码:已登录用户扫码或带参进入时,若还没有归因记录,则记到本码;之后再扫其他码不会改。与「扫码注册」不同:注册只统计来源仍是自然量并被标记为本码的用户;已有其他来源(如分享)的用户仍可计入归因,但不计入扫码注册。';
|
||||
|
||||
async function downloadQrcode(url: string, filename: string) {
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
@@ -51,6 +56,7 @@ async function downloadQrcode(url: string, filename: string) {
|
||||
}
|
||||
|
||||
export default function PromoCodeDetailPage() {
|
||||
const navigate = useNavigate();
|
||||
const { detail, reload } = useOutletContext<PromoCodeDetailContext>();
|
||||
const [editForm] = Form.useForm();
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
@@ -209,14 +215,26 @@ export default function PromoCodeDetailPage() {
|
||||
|
||||
<Row gutter={16} style={{ marginTop: 16 }}>
|
||||
<Col xs={12} sm={6}>
|
||||
<Card size="small">
|
||||
<Card
|
||||
size="small"
|
||||
hoverable
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => navigate(`/promo-codes/${detail.id}?eventType=SCAN`)}
|
||||
>
|
||||
<Statistic title="扫码进入次数" value={stats?.scanCount ?? detail.scanCount} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={12} sm={6}>
|
||||
<Card size="small">
|
||||
<Statistic
|
||||
title="归因用户数"
|
||||
title={
|
||||
<span>
|
||||
归因用户数
|
||||
<Tooltip title={ATTRIBUTION_HINT} overlayInnerStyle={{ maxWidth: 360 }}>
|
||||
<QuestionCircleOutlined style={{ marginLeft: 6, color: 'rgba(0,0,0,0.45)' }} />
|
||||
</Tooltip>
|
||||
</span>
|
||||
}
|
||||
value={stats?.attributionCount ?? 0}
|
||||
/>
|
||||
</Card>
|
||||
@@ -230,8 +248,23 @@ export default function PromoCodeDetailPage() {
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={12} sm={6}>
|
||||
<Card size="small">
|
||||
<Statistic title="订单数" value={stats?.orderCount ?? detail.orderCount} />
|
||||
<Card
|
||||
size="small"
|
||||
hoverable
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => navigate(`/orders?promoCodeId=${detail.id}&status=COMPLETED`)}
|
||||
>
|
||||
<Statistic
|
||||
title={
|
||||
<span>
|
||||
订单数
|
||||
<Tooltip title="仅统计已完成订单" overlayInnerStyle={{ maxWidth: 280 }}>
|
||||
<QuestionCircleOutlined style={{ marginLeft: 6, color: 'rgba(0,0,0,0.45)' }} />
|
||||
</Tooltip>
|
||||
</span>
|
||||
}
|
||||
value={stats?.orderCount ?? detail.orderCount}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={12} sm={6}>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
Card,
|
||||
DatePicker,
|
||||
@@ -21,6 +22,7 @@ import {
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../../lib/api';
|
||||
import { fmtTime } from '../../lib/constants';
|
||||
import { AdminPrimaryLink } from '../../components/AdminPrimaryLink';
|
||||
|
||||
type Props = {
|
||||
promoId: string;
|
||||
@@ -57,11 +59,45 @@ function buildEventsQs(
|
||||
return `/admin/promo-codes/${promoId}/metrics/events?${qs.toString()}`;
|
||||
}
|
||||
|
||||
function formatRefId(row: PromoMetricEventItem): string {
|
||||
if (row.orderId) return `订单 ${row.orderId}`;
|
||||
if (row.userId) return `用户 ${row.userId}`;
|
||||
if (row.sessionId) return `会话 ${row.sessionId}`;
|
||||
return '—';
|
||||
function parseEventType(raw: string | null): PromoMetricEventType | undefined {
|
||||
if (raw === 'SCAN' || raw === 'ATTRIBUTION' || raw === 'REGISTER' || raw === 'ORDER') return raw;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function EventRefLinks({ row }: { row: PromoMetricEventItem }) {
|
||||
const navigate = useNavigate();
|
||||
const links = [];
|
||||
if (row.orderId) {
|
||||
links.push(
|
||||
<AdminPrimaryLink
|
||||
key="order"
|
||||
onClick={() => {
|
||||
if (row.orderNo) {
|
||||
navigate(`/orders?orderNo=${encodeURIComponent(row.orderNo)}`);
|
||||
} else {
|
||||
navigate('/orders', { state: { openOrderId: String(row.orderId) } });
|
||||
}
|
||||
}}
|
||||
>
|
||||
订单 {row.orderNo || row.orderId}
|
||||
</AdminPrimaryLink>,
|
||||
);
|
||||
}
|
||||
if (row.userId) {
|
||||
links.push(
|
||||
<AdminPrimaryLink
|
||||
key="user"
|
||||
onClick={() => navigate('/users', { state: { openUserId: String(row.userId) } })}
|
||||
>
|
||||
用户 {row.userNo || row.userId}
|
||||
</AdminPrimaryLink>,
|
||||
);
|
||||
}
|
||||
if (links.length) {
|
||||
return <Space size={12}>{links}</Space>;
|
||||
}
|
||||
if (row.sessionId) return <>会话 {row.sessionId}</>;
|
||||
return <>—</>;
|
||||
}
|
||||
|
||||
function formatLocation(row: PromoMetricEventItem): string {
|
||||
@@ -71,15 +107,27 @@ function formatLocation(row: PromoMetricEventItem): string {
|
||||
}
|
||||
|
||||
export default function PromoCodeMetricsPanel({ promoId }: Props) {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const urlEventType = parseEventType(searchParams.get('eventType'));
|
||||
const [range, setRange] = useState<[Dayjs, Dayjs]>([dayjs().subtract(6, 'day'), dayjs()]);
|
||||
const [granularity, setGranularity] = useState<'day' | 'hour'>('day');
|
||||
const [timeline, setTimeline] = useState<PromoMetricTimelineDto | null>(null);
|
||||
const [timelineLoading, setTimelineLoading] = useState(false);
|
||||
const [eventType, setEventType] = useState<PromoMetricEventType | undefined>();
|
||||
const [eventType, setEventType] = useState<PromoMetricEventType | undefined>(urlEventType);
|
||||
const [eventsPage, setEventsPage] = useState(1);
|
||||
const [events, setEvents] = useState<Paginated<PromoMetricEventItem> | null>(null);
|
||||
const [eventsLoading, setEventsLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setEventType(urlEventType);
|
||||
setEventsPage(1);
|
||||
if (urlEventType) {
|
||||
window.requestAnimationFrame(() => {
|
||||
document.getElementById('promo-metric-events')?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
}
|
||||
}, [urlEventType]);
|
||||
|
||||
const loadTimeline = useCallback(() => {
|
||||
setTimelineLoading(true);
|
||||
return request<PromoMetricTimelineDto>(buildTimelineQs(promoId, range, granularity))
|
||||
@@ -164,7 +212,7 @@ export default function PromoCodeMetricsPanel({ promoId }: Props) {
|
||||
{
|
||||
title: 'ID',
|
||||
key: 'ref',
|
||||
render: (_, row) => formatRefId(row),
|
||||
render: (_, row) => <EventRefLinks row={row} />,
|
||||
},
|
||||
{
|
||||
title: 'IP',
|
||||
@@ -220,7 +268,7 @@ export default function PromoCodeMetricsPanel({ promoId }: Props) {
|
||||
notMerge
|
||||
/>
|
||||
|
||||
<Typography.Title level={5} style={{ marginTop: 24, marginBottom: 12 }}>
|
||||
<Typography.Title id="promo-metric-events" level={5} style={{ marginTop: 24, marginBottom: 12 }}>
|
||||
事件日志
|
||||
</Typography.Title>
|
||||
<Space wrap style={{ marginBottom: 12 }}>
|
||||
@@ -232,6 +280,10 @@ export default function PromoCodeMetricsPanel({ promoId }: Props) {
|
||||
onChange={(v) => {
|
||||
setEventType(v);
|
||||
setEventsPage(1);
|
||||
const next = new URLSearchParams(searchParams);
|
||||
if (v) next.set('eventType', v);
|
||||
else next.delete('eventType');
|
||||
setSearchParams(next, { replace: true });
|
||||
}}
|
||||
options={Object.entries(PROMO_METRIC_EVENT_LABELS).map(([value, label]) => ({
|
||||
value,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useNavigate, useOutletContext, useParams } from 'react-router-dom';
|
||||
import { Button, Space, Table, Tag } from 'antd';
|
||||
import { Button, Space, Table, Tag, Tooltip } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import {
|
||||
USER_SOURCE_TYPE_LABELS,
|
||||
@@ -66,7 +66,7 @@ export default function PromoCodeUsersPage() {
|
||||
width: 160,
|
||||
render: (v) => (v ? fmtTime(v) : '—'),
|
||||
},
|
||||
{ title: '订单数', dataIndex: 'orderCount', width: 80 },
|
||||
{ title: <Tooltip title="仅统计已完成订单">订单数</Tooltip>, dataIndex: 'orderCount', width: 80 },
|
||||
{ title: '注册时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||
{
|
||||
title: '操作',
|
||||
|
||||
@@ -22,12 +22,16 @@ import ProxyOrderDetailPage from './pages/ProxyOrderDetailPage';
|
||||
import StaffListPage from './pages/StaffListPage';
|
||||
import StaffCreatePage from './pages/StaffCreatePage';
|
||||
import LeaderboardPage from './pages/LeaderboardPage';
|
||||
import UsersManagePage from './pages/UsersManagePage';
|
||||
import AssocOrdersPage from './pages/AssocOrdersPage';
|
||||
import CommissionOrdersPage from './pages/CommissionOrdersPage';
|
||||
|
||||
function PrimaryRoutes() {
|
||||
return (
|
||||
<Routes>
|
||||
<Route element={<TabLayout />}>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
<Route path="/users" element={<UsersManagePage />} />
|
||||
<Route path="/stores" element={<StoreListPage />} />
|
||||
<Route path="/center" element={<CenterPage />} />
|
||||
</Route>
|
||||
@@ -37,6 +41,11 @@ function PrimaryRoutes() {
|
||||
<Route path="/center/settlement" element={<SettlementPage />} />
|
||||
<Route path="/center/staff" element={<StaffListPage />} />
|
||||
<Route path="/center/staff/new" element={<StaffCreatePage />} />
|
||||
<Route path="/center/assoc" element={<Navigate to="/users" replace />} />
|
||||
<Route path="/center/assoc/users" element={<Navigate to="/users" replace />} />
|
||||
<Route path="/users/orders" element={<AssocOrdersPage />} />
|
||||
<Route path="/users/:userId/orders" element={<AssocOrdersPage />} />
|
||||
<Route path="/center/commissions" element={<CommissionOrdersPage />} />
|
||||
<Route path="/center/proxy-orders" element={<ProxyOrderListPage />} />
|
||||
<Route path="/center/proxy-orders/:id" element={<ProxyOrderDetailPage />} />
|
||||
<Route path="/proxy-order" element={<ProxyOrderPage />} />
|
||||
|
||||
@@ -3,6 +3,7 @@ import { isLoggedIn } from '../lib/api';
|
||||
|
||||
const TABS = [
|
||||
{ to: '/', end: true, icon: 'dashboard', label: '首页' },
|
||||
{ to: '/users', icon: 'group', label: '用户管理' },
|
||||
{ to: '/stores', icon: 'store', label: '门店管理' },
|
||||
{ to: '/center', icon: 'account_circle', label: '合伙人中心' },
|
||||
] as const;
|
||||
|
||||
@@ -12,6 +12,7 @@ export type ProxyOrderDraft = {
|
||||
promoCodeId: string;
|
||||
deliveryMode: PartnerProxyDeliveryMode;
|
||||
autoReceive: boolean;
|
||||
assocEnabled: boolean;
|
||||
};
|
||||
|
||||
export function saveProxyOrderDraft(draft: ProxyOrderDraft) {
|
||||
@@ -40,6 +41,7 @@ export function loadProxyOrderDraft(): ProxyOrderDraft | null {
|
||||
promoCodeId: typeof parsed.promoCodeId === 'string' ? parsed.promoCodeId : '',
|
||||
deliveryMode: parsed.deliveryMode === 'ON_SITE_PICKUP' ? 'ON_SITE_PICKUP' : 'ADDRESS',
|
||||
autoReceive: parsed.autoReceive === true,
|
||||
assocEnabled: parsed.assocEnabled !== false,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type { PartnerAssocUserOrderItem } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError } from '../lib/toast';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
type ListRes = { items: PartnerAssocUserOrderItem[]; total: number };
|
||||
|
||||
function fmtMoney(n: number) {
|
||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
export default function AssocOrdersPage() {
|
||||
const { userId } = useParams();
|
||||
usePartnerPageView(userId ? 'partner_assoc_user_orders_view' : 'partner_assoc_orders_view');
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<PartnerAssocUserOrderItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const path = userId
|
||||
? `/partner/assoc/users/${userId}/orders?page=1&pageSize=50`
|
||||
: '/partner/assoc/orders?page=1&pageSize=50';
|
||||
const res = await request<ListRes>('PARTNER_H5', path);
|
||||
setItems(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '加载失败');
|
||||
setItems([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [userId]);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
return (
|
||||
<PullToRefresh onRefresh={load}>
|
||||
<PageHeader title={userId ? '用户订单' : '关联用户订单'} onBack={() => navigate(-1)} />
|
||||
<div style={{ padding: '0 20px 24px' }}>
|
||||
<p className="label-md text-muted" style={{ margin: '12px 0' }}>
|
||||
{loading ? '加载中…' : `共 ${total} 笔已付购酒单`}
|
||||
</p>
|
||||
{!loading && items.length === 0 && <div className="empty">暂无订单</div>}
|
||||
{items.map((o) => (
|
||||
<div key={o.id} className="partner-store-card" style={{ marginBottom: 12 }}>
|
||||
<div className="partner-store-card-header" style={{ marginBottom: 0 }}>
|
||||
<div>
|
||||
<p className="body-md">{o.productName}</p>
|
||||
<p className="label-md text-muted">{o.orderNo} · ×{o.quantity}</p>
|
||||
<p className="label-md text-muted">{o.paidAt ? o.paidAt.slice(0, 16).replace('T', ' ') : ''}</p>
|
||||
</div>
|
||||
<span className="amount-lg" style={{ fontSize: 18 }}>¥{fmtMoney(o.payAmount)}</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</PullToRefresh>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import type { PartnerAssocSummary } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError, toastSuccess } from '../lib/toast';
|
||||
import { isWechatEnv } from '../lib/weixin';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
export default function AssocQrcodePage() {
|
||||
usePartnerPageView('partner_assoc_qrcode_view');
|
||||
const navigate = useNavigate();
|
||||
const [summary, setSummary] = useState<PartnerAssocSummary | null>(null);
|
||||
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
request<PartnerAssocSummary>('PARTNER_H5', '/partner/assoc')
|
||||
.then(setSummary)
|
||||
.catch((e) => toastError(e instanceof Error ? e.message : '加载失败'))
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
useEffect(() => () => {
|
||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||
}, [previewUrl]);
|
||||
|
||||
async function downloadQr() {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
try {
|
||||
const res = await fetch('/api/v1/partner/assoc/qrcode', {
|
||||
headers: {
|
||||
Authorization: token ? `Bearer ${token}` : '',
|
||||
'X-Client-App': 'PARTNER_H5',
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error('下载失败');
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
if (isWechatEnv()) {
|
||||
setPreviewUrl(url);
|
||||
toastSuccess('请长按图片保存到相册');
|
||||
return;
|
||||
}
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `partner-assoc-${summary?.partnerId || 'qr'}.png`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
toastSuccess('已开始下载');
|
||||
} catch (e) {
|
||||
if (summary?.qrcodeUrl) {
|
||||
setPreviewUrl(summary.qrcodeUrl);
|
||||
toastSuccess('请长按图片保存到相册');
|
||||
return;
|
||||
}
|
||||
toastError(e instanceof Error ? e.message : '下载失败');
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageHeader title="关联码" onBack={() => navigate(-1)} />
|
||||
{loading && <div className="empty">加载中…</div>}
|
||||
{!loading && (
|
||||
<section className="partner-bill-card" style={{ margin: 16 }}>
|
||||
<div style={{ padding: 24, textAlign: 'center' }}>
|
||||
<p className="body-md text-muted" style={{ marginBottom: 16 }}>
|
||||
用户扫码后首次锁定本合伙人,后续酒单按订单佣金结算
|
||||
</p>
|
||||
{summary?.qrcodeUrl ? (
|
||||
<img
|
||||
src={previewUrl || summary.qrcodeUrl}
|
||||
alt="关联码"
|
||||
style={{ width: 220, height: 220, background: '#fff' }}
|
||||
/>
|
||||
) : (
|
||||
<p className="body-md text-muted">关联码尚未生成,请稍后重试或联系总部补发</p>
|
||||
)}
|
||||
<p className="label-md text-muted" style={{ marginTop: 12 }}>
|
||||
已关联 {summary?.userCount ?? 0} 人
|
||||
</p>
|
||||
<button type="button" className="partner-btn-primary" style={{ marginTop: 20 }} onClick={() => void downloadQr()}>
|
||||
下载二维码
|
||||
</button>
|
||||
{previewUrl && isWechatEnv() && (
|
||||
<p className="label-md text-muted" style={{ marginTop: 12 }}>
|
||||
微信内请长按上方图片保存
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type { PartnerAssocUserItem } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError } from '../lib/toast';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
type ListRes = { items: PartnerAssocUserItem[]; total: number; page: number; pageSize: number };
|
||||
|
||||
export default function AssocUsersPage() {
|
||||
usePartnerPageView('partner_assoc_users_view');
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<PartnerAssocUserItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
async function load() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await request<ListRes>('PARTNER_H5', '/partner/assoc/users?page=1&pageSize=50');
|
||||
setItems(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '加载失败');
|
||||
setItems([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PullToRefresh onRefresh={load}>
|
||||
<PageHeader title="关联用户" onBack={() => navigate(-1)} />
|
||||
<div style={{ padding: '0 20px 24px' }}>
|
||||
<p className="label-md text-muted" style={{ margin: '12px 0' }}>
|
||||
{loading ? '加载中…' : `共 ${total} 人`}
|
||||
</p>
|
||||
{!loading && items.length === 0 && <div className="empty">暂无关联用户</div>}
|
||||
{items.map((u) => (
|
||||
<div key={u.id} className="partner-store-card" style={{ marginBottom: 12 }}>
|
||||
<div className="partner-store-card-header" style={{ marginBottom: 0 }}>
|
||||
<div>
|
||||
<p className="body-md">{u.nickname || u.userNo}</p>
|
||||
<p className="label-md text-muted">{u.phone || '未绑定手机'}</p>
|
||||
<p className="label-md text-muted">{u.boundAt ? u.boundAt.slice(0, 16).replace('T', ' ') : ''}</p>
|
||||
</div>
|
||||
<span className="label-md">{u.orderCount} 单</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</PullToRefresh>
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useState } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type { PartnerBillDto } from '@dukang/shared-types';
|
||||
import type { PartnerBillDetailDto, PartnerBillDto, PartnerBillItemDto } from '@dukang/shared-types';
|
||||
import { isLoggedIn, request } from '../lib/api';
|
||||
import { toastError, toastSuccess } from '../lib/toast';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
@@ -34,6 +34,7 @@ export default function BillsPage() {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
||||
const [detail, setDetail] = useState<PartnerBillDetailDto | null>(null);
|
||||
|
||||
async function loadBills() {
|
||||
setLoading(true);
|
||||
@@ -67,6 +68,44 @@ export default function BillsPage() {
|
||||
const isRejected = status === 'REJECTED';
|
||||
const isPaid = status === 'PAID';
|
||||
|
||||
useEffect(() => {
|
||||
if (!bill?.id) {
|
||||
setDetail(null);
|
||||
return;
|
||||
}
|
||||
request<PartnerBillDetailDto>('PARTNER_H5', `/partner/settlement/bills/${bill.id}`)
|
||||
.then(setDetail)
|
||||
.catch(() => setDetail(null));
|
||||
}, [bill?.id]);
|
||||
|
||||
function renderItemList(title: string, items: PartnerBillItemDto[] | undefined, subtotal: number) {
|
||||
const list = items ?? [];
|
||||
return (
|
||||
<div style={{ marginTop: 16 }}>
|
||||
<div className="partner-info-row" style={{ marginBottom: 8 }}>
|
||||
<span className="body-md" style={{ fontWeight: 700 }}>{title}</span>
|
||||
<span className="body-md" style={{ fontWeight: 700 }}>¥ {fmtMoney(subtotal)}</span>
|
||||
</div>
|
||||
{list.length === 0 ? (
|
||||
<p className="label-md text-muted">本账期无明细</p>
|
||||
) : (
|
||||
list.map((it) => (
|
||||
<div key={it.id} className="partner-info-row" style={{ alignItems: 'flex-start' }}>
|
||||
<div>
|
||||
<p className="body-md">{it.title || it.refNo}</p>
|
||||
<p className="label-md text-muted">
|
||||
{it.refNo}
|
||||
{it.extra ? ` ${it.extra}` : ''} · {((it.rate ?? 0) * 100).toFixed(2)}%
|
||||
</p>
|
||||
</div>
|
||||
<span className="body-md">¥ {fmtMoney(it.commission)}</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function askConfirm(ids: string[]) {
|
||||
if (!window.confirm(`确认 ${ids.length} 笔账单无误并提交?确认后状态将变为「未打款」,等待总部打款。`)) {
|
||||
return;
|
||||
@@ -183,16 +222,8 @@ export default function BillsPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
<div className="partner-info-row">
|
||||
<span className="text-variant body-md">订单分佣收入</span>
|
||||
<span className="body-md" style={{ fontWeight: 700 }}>¥ {fmtMoney(Number(bill.orderCommission || 0))}</span>
|
||||
</div>
|
||||
<div className="partner-info-row">
|
||||
<span className="text-variant body-md">核销权益分佣</span>
|
||||
<span className="body-md" style={{ fontWeight: 700 }}>¥ {fmtMoney(Number(bill.redeemCommission || 0))}</span>
|
||||
</div>
|
||||
</div>
|
||||
{renderItemList('酒订单', detail?.orderItems, Number(detail?.orderCommission ?? bill.orderCommission ?? 0))}
|
||||
{renderItemList('核销订单', detail?.redeemItems, Number(detail?.redeemCommission ?? bill.redeemCommission ?? 0))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
@@ -219,6 +219,24 @@ export default function CenterPage({ variant = 'primary', roleLabel }: CenterPag
|
||||
<span className="material-symbols-outlined text-muted">chevron_right</span>
|
||||
</div>
|
||||
</Link>
|
||||
<Link to="/users" className="partner-menu-item">
|
||||
<div className="partner-menu-item-left">
|
||||
<div className="partner-menu-icon">
|
||||
<span className="material-symbols-outlined">group</span>
|
||||
</div>
|
||||
<span className="body-md" style={{ fontSize: 16 }}>用户管理</span>
|
||||
</div>
|
||||
<span className="material-symbols-outlined text-muted">chevron_right</span>
|
||||
</Link>
|
||||
<Link to="/center/commissions" className="partner-menu-item">
|
||||
<div className="partner-menu-item-left">
|
||||
<div className="partner-menu-icon">
|
||||
<span className="material-symbols-outlined">payments</span>
|
||||
</div>
|
||||
<span className="body-md" style={{ fontSize: 16 }}>订单佣金</span>
|
||||
</div>
|
||||
<span className="material-symbols-outlined text-muted">chevron_right</span>
|
||||
</Link>
|
||||
<Link to="/center/proxy-orders" className="partner-menu-item">
|
||||
<div className="partner-menu-item-left">
|
||||
<div className="partner-menu-icon">
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type { PartnerCommissionOrderItem } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError } from '../lib/toast';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
function fmtMoney(n: number) {
|
||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
type ListRes = { items: PartnerCommissionOrderItem[]; total: number };
|
||||
|
||||
export default function CommissionOrdersPage() {
|
||||
usePartnerPageView('partner_commission_orders_view');
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<PartnerCommissionOrderItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
async function load() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await request<ListRes>('PARTNER_H5', '/partner/commissions/orders?page=1&pageSize=50');
|
||||
setItems(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '加载失败');
|
||||
setItems([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PullToRefresh onRefresh={load}>
|
||||
<PageHeader title="订单佣金" onBack={() => navigate(-1)} />
|
||||
<div style={{ padding: '0 20px 24px' }}>
|
||||
<p className="label-md text-muted" style={{ margin: '12px 0' }}>
|
||||
{loading ? '加载中…' : `共 ${total} 笔关联酒单`}
|
||||
</p>
|
||||
{!loading && items.length === 0 && <div className="empty">暂无订单佣金</div>}
|
||||
{items.map((o) => (
|
||||
<div key={o.id} className="partner-store-card" style={{ marginBottom: 12 }}>
|
||||
<div className="partner-store-card-header">
|
||||
<div>
|
||||
<p className="body-md">{o.productName}</p>
|
||||
<p className="label-md text-muted">{o.orderNo} · ×{o.quantity}</p>
|
||||
<p className="label-md text-muted">{o.paidAt ? o.paidAt.slice(0, 16).replace('T', ' ') : ''}</p>
|
||||
</div>
|
||||
<span className="amount-lg" style={{ fontSize: 18 }}>¥{fmtMoney(o.commission)}</span>
|
||||
</div>
|
||||
<p className="label-md text-muted">
|
||||
实付 ¥{fmtMoney(o.payAmount)} × {((o.rate ?? 0) * 100).toFixed(2)}%
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</PullToRefresh>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import type { PartnerLeaderboardEntry } from '@dukang/shared-types';
|
||||
import type { PartnerAssocStats, PartnerLeaderboardEntry } from '@dukang/shared-types';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
import { isLoggedIn, request } from '../lib/api';
|
||||
@@ -153,6 +153,7 @@ export default function HomePage() {
|
||||
const [stores, setStores] = useState<Array<Record<string, unknown>>>([]);
|
||||
const [orders, setOrders] = useState<Array<Record<string, unknown>>>([]);
|
||||
const [leaderboardEntries, setLeaderboardEntries] = useState<PartnerLeaderboardEntry[]>([]);
|
||||
const [assocStats, setAssocStats] = useState<PartnerAssocStats | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
document.title = '工作台';
|
||||
@@ -197,6 +198,16 @@ export default function HomePage() {
|
||||
setStores([]);
|
||||
}
|
||||
|
||||
if (isPrimary) {
|
||||
tasks.push(
|
||||
request<PartnerAssocStats>('PARTNER_H5', '/partner/assoc/stats', { silent: true })
|
||||
.then(setAssocStats)
|
||||
.catch(() => setAssocStats(null)),
|
||||
);
|
||||
} else {
|
||||
setAssocStats(null);
|
||||
}
|
||||
|
||||
tasks.push(
|
||||
fetchPartnerLeaderboard('month')
|
||||
.then((data) => {
|
||||
@@ -208,7 +219,7 @@ export default function HomePage() {
|
||||
);
|
||||
|
||||
return Promise.all(tasks).then(() => undefined);
|
||||
}, [navigate, account, canOrders, canDashboard, canStores]);
|
||||
}, [navigate, account, canOrders, canDashboard, canStores, isPrimary]);
|
||||
|
||||
useEffect(() => {
|
||||
void loadHome();
|
||||
@@ -287,6 +298,51 @@ export default function HomePage() {
|
||||
</>
|
||||
)}
|
||||
|
||||
{isPrimary && (
|
||||
<>
|
||||
<Link to="/users" className="partner-bento-card" style={{ display: 'block', marginBottom: 16, color: 'inherit', textDecoration: 'none' }}>
|
||||
<div className="partner-bento-header">
|
||||
<h2 className="headline-md">关联用户</h2>
|
||||
<span className="amount-lg" style={{ fontSize: 24 }}>{assocStats?.userTotal ?? 0}</span>
|
||||
</div>
|
||||
<div className="partner-store-stats">
|
||||
<div className="partner-store-stat">
|
||||
<div>
|
||||
<p className="label-md text-muted">本日</p>
|
||||
<p className="headline-md">{assocStats?.userToday ?? 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="partner-store-stat">
|
||||
<div>
|
||||
<p className="label-md text-muted">本月</p>
|
||||
<p className="headline-md">{assocStats?.userMonth ?? 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
<Link to="/users/orders" className="partner-bento-card" style={{ display: 'block', marginBottom: 16, color: 'inherit', textDecoration: 'none' }}>
|
||||
<div className="partner-bento-header">
|
||||
<h2 className="headline-md">关联用户订单</h2>
|
||||
<span className="amount-lg" style={{ fontSize: 24 }}>{assocStats?.orderTotal ?? 0}</span>
|
||||
</div>
|
||||
<div className="partner-store-stats">
|
||||
<div className="partner-store-stat">
|
||||
<div>
|
||||
<p className="label-md text-muted">本日</p>
|
||||
<p className="headline-md">{assocStats?.orderToday ?? 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="partner-store-stat">
|
||||
<div>
|
||||
<p className="label-md text-muted">本月</p>
|
||||
<p className="headline-md">{assocStats?.orderMonth ?? 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
|
||||
{isWarehouse && (
|
||||
<p className="headline-md" style={{ marginBottom: 8 }}>订单管理</p>
|
||||
)}
|
||||
|
||||
@@ -42,6 +42,7 @@ function initialDraft(): ProxyOrderDraft {
|
||||
promoCodeId: '',
|
||||
deliveryMode: 'ADDRESS',
|
||||
autoReceive: false,
|
||||
assocEnabled: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -63,6 +64,7 @@ export default function ProxyOrderPage() {
|
||||
const [promoCodeId, setPromoCodeId] = useState(draft0.promoCodeId);
|
||||
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>(draft0.deliveryMode);
|
||||
const [autoReceive, setAutoReceive] = useState(draft0.autoReceive);
|
||||
const [assocEnabled, setAssocEnabled] = useState(draft0.assocEnabled !== false);
|
||||
const [preview, setPreview] = useState<PartnerProxyOrderPreviewResult | null>(null);
|
||||
const [previewLoading, setPreviewLoading] = useState(false);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
@@ -108,6 +110,7 @@ export default function ProxyOrderPage() {
|
||||
promoCodeId,
|
||||
deliveryMode,
|
||||
autoReceive,
|
||||
assocEnabled,
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
@@ -154,6 +157,7 @@ export default function ProxyOrderPage() {
|
||||
promoCodeId,
|
||||
deliveryMode,
|
||||
autoReceive,
|
||||
assocEnabled,
|
||||
]);
|
||||
|
||||
const selectedProduct = options?.products.find((p) => p.id === productId);
|
||||
@@ -390,6 +394,9 @@ export default function ProxyOrderPage() {
|
||||
quantity,
|
||||
promoCodeId: promoCodeId || undefined,
|
||||
skuId: skuId || undefined,
|
||||
assocPartnerAccountId: assocEnabled
|
||||
? options?.partners?.[0]?.id || undefined
|
||||
: undefined,
|
||||
};
|
||||
|
||||
setSubmitting(true);
|
||||
@@ -595,6 +602,17 @@ export default function ProxyOrderPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-checkbox-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={assocEnabled}
|
||||
onChange={(e) => setAssocEnabled(e.target.checked)}
|
||||
/>
|
||||
<span>关联合伙人(本单计订单佣金;取消则本单不计)</span>
|
||||
</label>
|
||||
</section>
|
||||
|
||||
{(options?.promoCodes.length ?? 0) > 0 && (
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-form-label">绑定推广码(选填)</label>
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type {
|
||||
PartnerAssocSummary,
|
||||
PartnerAssocUserItem,
|
||||
PartnerAssocUserSort,
|
||||
} from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError, toastSuccess } from '../lib/toast';
|
||||
import { isWechatEnv } from '../lib/weixin';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
type ListRes = { items: PartnerAssocUserItem[]; total: number };
|
||||
|
||||
const SORTS: { key: PartnerAssocUserSort; label: string }[] = [
|
||||
{ key: 'boundAt', label: '关联时间' },
|
||||
{ key: 'createdAt', label: '注册时间' },
|
||||
{ key: 'orderCount', label: '订单数' },
|
||||
];
|
||||
|
||||
function formatUserLabel(u: PartnerAssocUserItem) {
|
||||
const name = u.nickname?.trim() || u.userNo || '—';
|
||||
const remark = u.partnerRemark?.trim();
|
||||
return remark ? `${name}(${remark})` : name;
|
||||
}
|
||||
|
||||
function fmtTime(iso?: string | null) {
|
||||
if (!iso) return '—';
|
||||
return iso.slice(0, 16).replace('T', ' ');
|
||||
}
|
||||
|
||||
export default function UsersManagePage() {
|
||||
usePartnerPageView('partner_users_manage_view');
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const [summary, setSummary] = useState<PartnerAssocSummary | null>(null);
|
||||
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
||||
const [items, setItems] = useState<PartnerAssocUserItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [keyword, setKeyword] = useState('');
|
||||
const [appliedKeyword, setAppliedKeyword] = useState('');
|
||||
const [sort, setSort] = useState<PartnerAssocUserSort>('boundAt');
|
||||
const [editing, setEditing] = useState<PartnerAssocUserItem | null>(null);
|
||||
const [remarkDraft, setRemarkDraft] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
document.title = '用户管理';
|
||||
}, []);
|
||||
|
||||
useEffect(() => () => {
|
||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||
}, [previewUrl]);
|
||||
|
||||
const loadSummary = useCallback(async () => {
|
||||
const data = await request<PartnerAssocSummary>('PARTNER_H5', '/partner/assoc');
|
||||
setSummary(data);
|
||||
}, []);
|
||||
|
||||
const loadUsers = useCallback(async () => {
|
||||
const qs = new URLSearchParams({ page: '1', pageSize: '50', sort });
|
||||
const q = appliedKeyword.trim();
|
||||
if (q) qs.set('keyword', q);
|
||||
const res = await request<ListRes>('PARTNER_H5', `/partner/assoc/users?${qs}`);
|
||||
setItems(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
}, [appliedKeyword, sort]);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await Promise.all([loadSummary(), loadUsers()]);
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '加载失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [loadSummary, loadUsers]);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
useEffect(() => {
|
||||
const t = window.setTimeout(() => setAppliedKeyword(keyword.trim()), 400);
|
||||
return () => window.clearTimeout(t);
|
||||
}, [keyword]);
|
||||
|
||||
useEffect(() => {
|
||||
const uid = searchParams.get('userId');
|
||||
if (uid) navigate(`/users/${uid}/orders`, { replace: true });
|
||||
}, [searchParams, navigate]);
|
||||
|
||||
async function downloadQr() {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
try {
|
||||
const res = await fetch('/api/v1/partner/assoc/qrcode', {
|
||||
headers: {
|
||||
Authorization: token ? `Bearer ${token}` : '',
|
||||
'X-Client-App': 'PARTNER_H5',
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error('下载失败');
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
if (isWechatEnv()) {
|
||||
setPreviewUrl(url);
|
||||
toastSuccess('请长按图片保存到相册');
|
||||
return;
|
||||
}
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `partner-assoc-${summary?.partnerId || 'qr'}.png`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
toastSuccess('已开始下载');
|
||||
} catch (e) {
|
||||
if (summary?.qrcodeUrl) {
|
||||
setPreviewUrl(summary.qrcodeUrl);
|
||||
toastSuccess('请长按图片保存到相册');
|
||||
return;
|
||||
}
|
||||
toastError(e instanceof Error ? e.message : '下载失败');
|
||||
}
|
||||
}
|
||||
|
||||
async function saveRemark() {
|
||||
if (!editing) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
await request(`PARTNER_H5`, `/partner/assoc/users/${editing.id}/remark`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ remark: remarkDraft }),
|
||||
});
|
||||
toastSuccess(remarkDraft.trim() ? '备注已保存' : '已清除备注');
|
||||
setEditing(null);
|
||||
await loadUsers();
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '保存失败');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<PullToRefresh onRefresh={load} className="page partner-users-page">
|
||||
<div style={{ padding: '16px 20px 24px' }}>
|
||||
<h1 className="headline-lg" style={{ marginBottom: 16 }}>用户管理</h1>
|
||||
|
||||
<section className="partner-bill-card" style={{ marginBottom: 20, textAlign: 'center', padding: 20 }}>
|
||||
<p className="body-md text-muted" style={{ marginBottom: 12 }}>
|
||||
用户扫码后首次锁定,后续购酒计入关联订单
|
||||
</p>
|
||||
{summary?.qrcodeUrl ? (
|
||||
<img
|
||||
src={previewUrl || summary.qrcodeUrl}
|
||||
alt="关联码"
|
||||
style={{ width: 200, height: 200, background: '#fff' }}
|
||||
/>
|
||||
) : (
|
||||
<p className="body-md text-muted">{loading ? '加载中…' : '关联码尚未生成'}</p>
|
||||
)}
|
||||
<p className="label-md text-muted" style={{ marginTop: 8 }}>
|
||||
已关联 {summary?.userCount ?? total} 人
|
||||
</p>
|
||||
<button type="button" className="partner-btn-primary" style={{ marginTop: 16 }} onClick={() => void downloadQr()}>
|
||||
下载二维码
|
||||
</button>
|
||||
{previewUrl && isWechatEnv() && (
|
||||
<p className="label-md text-muted" style={{ marginTop: 8 }}>微信内请长按上方图片保存</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<h2 className="headline-md" style={{ marginBottom: 12 }}>已关联用户</h2>
|
||||
<div className="partner-search">
|
||||
<span className="material-symbols-outlined">search</span>
|
||||
<input
|
||||
value={keyword}
|
||||
placeholder="搜索昵称 / 手机 / 备注 / 编号"
|
||||
onChange={(e) => setKeyword(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') void loadUsers();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="partner-filter-row" style={{ marginBottom: 12, paddingLeft: 0, paddingRight: 0 }}>
|
||||
{SORTS.map((s) => (
|
||||
<button
|
||||
key={s.key}
|
||||
type="button"
|
||||
className={`partner-filter-tab${sort === s.key ? ' active' : ''}`}
|
||||
onClick={() => setSort(s.key)}
|
||||
>
|
||||
{s.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<p className="label-md text-muted" style={{ marginBottom: 12 }}>
|
||||
{loading ? '加载中…' : `共 ${total} 人`}
|
||||
</p>
|
||||
{!loading && items.length === 0 && <div className="empty">暂无关联用户</div>}
|
||||
{items.map((u) => (
|
||||
<div key={u.id} className="partner-store-card" style={{ marginBottom: 12 }}>
|
||||
<div className="partner-store-card-header" style={{ marginBottom: 8 }}>
|
||||
<div>
|
||||
<p className="body-md">{formatUserLabel(u)}</p>
|
||||
<p className="label-md text-muted">{u.phone || '未绑定手机'}</p>
|
||||
<p className="label-md text-muted">注册 {fmtTime(u.createdAt)}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="label-md text-primary"
|
||||
style={{ background: 'none', border: 0, padding: 0 }}
|
||||
onClick={() => navigate(`/users/${u.id}/orders`)}
|
||||
>
|
||||
{u.orderCount} 单
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="label-md text-primary"
|
||||
style={{ background: 'none', border: 0, padding: 0 }}
|
||||
onClick={() => {
|
||||
setEditing(u);
|
||||
setRemarkDraft(u.partnerRemark ?? '');
|
||||
}}
|
||||
>
|
||||
{u.partnerRemark ? '改备注' : '添加备注'}
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{editing && (
|
||||
<div className="partner-remark-mask" onClick={() => setEditing(null)}>
|
||||
<div className="partner-remark-sheet" onClick={(e) => e.stopPropagation()}>
|
||||
<p className="headline-md" style={{ marginBottom: 8 }}>用户备注</p>
|
||||
<p className="label-md text-muted" style={{ marginBottom: 12 }}>仅自己可见,总部看不到</p>
|
||||
<textarea
|
||||
value={remarkDraft}
|
||||
maxLength={128}
|
||||
rows={3}
|
||||
placeholder="最多 128 字"
|
||||
style={{ width: '100%', padding: 12, borderRadius: 8, border: '1px solid #eee' }}
|
||||
onChange={(e) => setRemarkDraft(e.target.value)}
|
||||
/>
|
||||
<div className="partner-ship-actions">
|
||||
<button type="button" className="partner-btn-secondary" onClick={() => setEditing(null)}>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="partner-btn-primary"
|
||||
disabled={saving}
|
||||
onClick={() => void saveRemark()}
|
||||
>
|
||||
保存
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</PullToRefresh>
|
||||
);
|
||||
}
|
||||
@@ -278,6 +278,22 @@ html {
|
||||
|
||||
.partner-btn-primary:active { transform: scale(0.98); }
|
||||
|
||||
.partner-btn-secondary {
|
||||
width: 100%;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--color-outline-variant);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-surface-container-low);
|
||||
color: var(--color-on-surface);
|
||||
font-family: var(--font-headline);
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.partner-btn-ghost {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
@@ -1344,7 +1360,7 @@ nav.app-tabbar {
|
||||
nav.app-tabbar .app-tabbar-item {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
max-width: 33.333%;
|
||||
max-width: 25%;
|
||||
height: 56px;
|
||||
padding: 6px 0 4px;
|
||||
border-radius: 0;
|
||||
@@ -3932,3 +3948,26 @@ header:has(> .app-page-title:only-child),
|
||||
margin-left: var(--space-page);
|
||||
margin-right: var(--space-page);
|
||||
}
|
||||
|
||||
.partner-users-page {
|
||||
padding-bottom: 96px;
|
||||
}
|
||||
|
||||
.partner-remark-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 200;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.partner-remark-sheet {
|
||||
width: 100%;
|
||||
max-width: 480px;
|
||||
background: var(--color-card, #fff);
|
||||
border-radius: 16px 16px 0 0;
|
||||
padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Navigate, useLocation } from 'react-router-dom';
|
||||
import { getStoreProfile, hasShopWxSession } from '../lib/api';
|
||||
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 SELECT_STORE_PATH = '/select-store';
|
||||
@@ -18,14 +19,17 @@ export default function AuthGate({ children }: { children: React.ReactNode }) {
|
||||
}
|
||||
|
||||
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) {
|
||||
rememberShopReturnPath(location);
|
||||
return <Navigate to={SELECT_STORE_PATH} replace />;
|
||||
}
|
||||
|
||||
if (!authenticated && !PUBLIC_PATHS.has(location.pathname)) {
|
||||
rememberShopReturnPath(location);
|
||||
const profile = getStoreProfile();
|
||||
if (profile && hasShopWxSession() && location.pathname !== '/login') {
|
||||
return <Navigate to="/login?quick=1" replace state={{ from: location }} />;
|
||||
|
||||
@@ -1,22 +1 @@
|
||||
/** 从微信扫码结果解析核销 token(32 位 hex 或带 token 参数的 URL) */
|
||||
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;
|
||||
}
|
||||
export { parseRedeemTokenFromScan } from '@dukang/shared-types';
|
||||
|
||||
@@ -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 { request } from '../lib/api';
|
||||
import { reportRedeemFailure } from '../lib/redeem-failure';
|
||||
import { consumeShopReturnTo } from '../lib/shop-redeem-return';
|
||||
import { toastError } from '../lib/toast';
|
||||
import { useStorePageView } from '../lib/usePageView';
|
||||
|
||||
@@ -47,6 +48,7 @@ export default function RedeemConfirmPage() {
|
||||
navigate('/', { replace: true });
|
||||
return;
|
||||
}
|
||||
consumeShopReturnTo();
|
||||
setToken(scanned);
|
||||
}, [searchParams, navigate]);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { goShopPath } from '../lib/shop-nav';
|
||||
import { notifyRedeemSuccess } from '../lib/useRedeemSuccessBus';
|
||||
import { formatMoney, toMoneyNumber } from '../lib/money';
|
||||
|
||||
@@ -35,10 +36,12 @@ export default function RedeemSuccessPage() {
|
||||
});
|
||||
}, [redeemNo, amount]);
|
||||
|
||||
const goHome = () => goShopPath('/', navigate, { replace: true });
|
||||
|
||||
return (
|
||||
<div className="shop-success-page">
|
||||
<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>
|
||||
</button>
|
||||
<h1 className="app-page-title">杜康好客</h1>
|
||||
@@ -85,11 +88,11 @@ export default function RedeemSuccessPage() {
|
||||
</div>
|
||||
|
||||
<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 className="material-symbols-outlined" style={{ fontSize: 20 }}>qr_code_scanner</span>
|
||||
</button>
|
||||
<button type="button" className="shop-success-outline-btn" onClick={() => navigate('/')}>
|
||||
<button type="button" className="shop-success-outline-btn" onClick={goHome}>
|
||||
<span>返回首页</span>
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>home</span>
|
||||
</button>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import { hardNavigateInWechat, shouldHardNavigateForJssdk } from '@dukang/weixin-sdk';
|
||||
import { useStoreSession } from '../contexts/StoreSessionContext';
|
||||
import {
|
||||
needsStoreSelection,
|
||||
@@ -10,13 +9,11 @@ import {
|
||||
type ShopSessionPayload,
|
||||
type ShopStoreOption,
|
||||
} 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) {
|
||||
if (shouldHardNavigateForJssdk()) {
|
||||
hardNavigateInWechat('/');
|
||||
return;
|
||||
}
|
||||
navigate('/', { replace: true });
|
||||
function goAfterSelectStore(navigate: (path: string, opts?: { replace?: boolean }) => void) {
|
||||
goShopPath(consumeShopReturnTo() || '/', navigate);
|
||||
}
|
||||
|
||||
export default function SelectStorePage() {
|
||||
@@ -46,7 +43,7 @@ export default function SelectStorePage() {
|
||||
async function onSelect(storeId: string) {
|
||||
if (loadingId) return;
|
||||
if (storeId === currentStoreId) {
|
||||
goShopHome(navigate);
|
||||
goAfterSelectStore(navigate);
|
||||
return;
|
||||
}
|
||||
setLoadingId(storeId);
|
||||
@@ -54,7 +51,7 @@ export default function SelectStorePage() {
|
||||
try {
|
||||
const session = await selectStore(storeId);
|
||||
applySession(session);
|
||||
goShopHome(navigate);
|
||||
goAfterSelectStore(navigate);
|
||||
} catch (e) {
|
||||
setMsg(e instanceof Error ? e.message : '选店失败');
|
||||
} 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(
|
||||
session: ShopSessionPayload,
|
||||
navigate: (path: string, opts?: { replace?: boolean }) => void,
|
||||
) {
|
||||
const path = needsStoreSelection(session) ? '/select-store' : '/';
|
||||
// iOS 微信:必须整页跳转,让业务页成为 JSSDK 新入场 URL,否则扫码验签必挂
|
||||
if (shouldHardNavigateForJssdk()) {
|
||||
hardNavigateInWechat(path);
|
||||
if (needsStoreSelection(session)) {
|
||||
goShopPath('/select-store', navigate);
|
||||
return;
|
||||
}
|
||||
navigate(path, { replace: true });
|
||||
goShopPath(peekShopReturnTo() || '/', navigate);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@dukang/mini-user",
|
||||
"version": "3.5.4",
|
||||
"version": "3.5.16",
|
||||
"private": true,
|
||||
"description": "杜康好客 · C 端用户微信小程序(Taro)",
|
||||
"scripts": {
|
||||
|
||||
@@ -26,6 +26,7 @@ export default defineAppConfig({
|
||||
{ root: 'pages/login', pages: ['index'] },
|
||||
{ root: 'pages/user-agreement', pages: ['index'] },
|
||||
{ root: 'pages/privacy-policy', pages: ['index'] },
|
||||
{ root: 'pages/benefit-rules', pages: ['index'] },
|
||||
{ root: 'pages/invoice-titles', pages: ['index'] },
|
||||
{ root: 'pages/invoice-apply', pages: ['index'] },
|
||||
],
|
||||
@@ -75,7 +76,7 @@ export default defineAppConfig({
|
||||
pagePath: 'pages/benefit/index',
|
||||
text: '好客权益',
|
||||
iconPath: 'assets/tabbar/benefit.png',
|
||||
selectedIconPath: 'assets/tabbar/benefit-active.png',
|
||||
selectedIconPath: 'assets/icons/store-benefit-y.png',
|
||||
},
|
||||
{
|
||||
pagePath: 'pages/mine/index',
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
@import './styles/benefit.css';
|
||||
@import './styles/mine.css';
|
||||
@import './styles/address.css';
|
||||
@import './styles/benefit-promo.css';
|
||||
@import './components/HomeSplash.css';
|
||||
|
||||
page,
|
||||
body {
|
||||
|
||||
@@ -4,12 +4,14 @@ import Taro, { useDidShow } from '@tarojs/taro';
|
||||
import { handleWechatOrderConfirmShow } from './lib/wechat-order-confirm';
|
||||
import { installClientErrorReporting } from './lib/client-error';
|
||||
import { prefetchShareBrandAssets } from './lib/wechat-share';
|
||||
import { prefetchHomeSplashAssets } from './lib/home-splash';
|
||||
import { capturePromoSceneAndTouchScan } from './lib/promo';
|
||||
import { initClientVersionChecks } from './lib/client-version';
|
||||
import './app.css';
|
||||
|
||||
installClientErrorReporting();
|
||||
prefetchShareBrandAssets();
|
||||
prefetchHomeSplashAssets();
|
||||
|
||||
function App({ children }: PropsWithChildren) {
|
||||
const handlingRef = useRef(false);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 307 B |
Binary file not shown.
|
Before Width: | Height: | Size: 69 KiB |
@@ -1,5 +1,5 @@
|
||||
import { Image, Text, View } from '@tarojs/components';
|
||||
import iconStoreBenefit from '../assets/icons/store-benefit.png';
|
||||
import iconStoreBenefit from '../assets/icons/store-benefit-y.png';
|
||||
|
||||
type BenefitFigureSize = 'sm' | 'md' | 'lg' | 'xl';
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import {
|
||||
BENEFIT_INTRO,
|
||||
BENEFIT_INTRO_EMPHASIS,
|
||||
BENEFIT_RULES_PATH,
|
||||
BENEFIT_SLOGAN,
|
||||
} from '../lib/benefit-copy';
|
||||
|
||||
type BenefitIntroCardProps = {
|
||||
showLink?: boolean;
|
||||
className?: string;
|
||||
/** 左侧金色粗条(门店详情等强调卡) */
|
||||
accent?: boolean;
|
||||
};
|
||||
|
||||
export default function BenefitIntroCard({
|
||||
showLink = false,
|
||||
className,
|
||||
accent = false,
|
||||
}: BenefitIntroCardProps) {
|
||||
const prefix = BENEFIT_INTRO.endsWith(BENEFIT_INTRO_EMPHASIS)
|
||||
? BENEFIT_INTRO.slice(0, -BENEFIT_INTRO_EMPHASIS.length)
|
||||
: BENEFIT_INTRO;
|
||||
|
||||
function goRules() {
|
||||
Taro.navigateTo({ url: BENEFIT_RULES_PATH });
|
||||
}
|
||||
|
||||
const inner = (
|
||||
<>
|
||||
<Text className="benefit-intro-card-title">{BENEFIT_SLOGAN}</Text>
|
||||
<Text className="benefit-intro-card-body">
|
||||
{prefix}
|
||||
<Text className="benefit-intro-card-em">{BENEFIT_INTRO_EMPHASIS}</Text>
|
||||
</Text>
|
||||
{showLink ? (
|
||||
<Text className="benefit-intro-card-link" onClick={goRules}>
|
||||
查看完整说明 ›
|
||||
</Text>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<View
|
||||
className={`benefit-intro-card${accent ? ' benefit-intro-card--accent' : ''}${className ? ` ${className}` : ''}`}
|
||||
>
|
||||
{accent ? <View className="benefit-intro-card-bar" /> : null}
|
||||
{accent ? <View className="benefit-intro-card-main">{inner}</View> : inner}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import { BENEFIT_SLOGAN } from '../lib/benefit-copy';
|
||||
|
||||
type BenefitSloganBarProps = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export default function BenefitSloganBar({ className }: BenefitSloganBarProps) {
|
||||
return (
|
||||
<View className={`benefit-slogan-bar${className ? ` ${className}` : ''}`}>
|
||||
<View className="benefit-slogan-bar-accent" />
|
||||
<Text className="benefit-slogan-bar-text">{BENEFIT_SLOGAN}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export const EMPTY_CATEGORY: CategorySelection = {
|
||||
export function formatCategoryLabel(sel: CategorySelection): string {
|
||||
if (sel.childName) return sel.childName;
|
||||
if (sel.parentName) return sel.parentName;
|
||||
return '全部分类';
|
||||
return '全部菜系';
|
||||
}
|
||||
|
||||
type CategoryPickerProps = {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Button, Text } from '@tarojs/components';
|
||||
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 = {
|
||||
orderId?: string;
|
||||
@@ -16,7 +20,7 @@ type ContactCsButtonProps = {
|
||||
|
||||
const isWeapp = process.env.TARO_ENV === 'weapp';
|
||||
|
||||
/** 组装 session-from(微信限制约 1000 字符) */
|
||||
/** 组装 session-from(微信限制约 1000 字符;原生小程序客服兜底用) */
|
||||
export function buildCsSessionFrom(session?: ContactCsSessionContext): string {
|
||||
if (!session) return 'dukang|from=mini-user';
|
||||
const parts = ['dukang'];
|
||||
@@ -26,16 +30,61 @@ export function buildCsSessionFrom(session?: ContactCsSessionContext): string {
|
||||
return parts.join('|');
|
||||
}
|
||||
|
||||
function canOpenWecom(url: string, corpId: string) {
|
||||
return !!url.trim() && !!corpId.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序客服入口(open-type=contact)。
|
||||
* 非 weapp 环境不渲染,由调用方走电话等兜底。
|
||||
* C 端在线客服:
|
||||
* - weapp 且已配置 CorpID + kfid:调起企业微信「微信客服」
|
||||
* - weapp 未配 CorpID:回退 open-type=contact
|
||||
* - H5:有 kfid 则打开企微客服链接
|
||||
*/
|
||||
export default function ContactCsButton({
|
||||
className = '',
|
||||
children = '联系在线客服',
|
||||
session,
|
||||
}: 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 (
|
||||
<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 用 RichText;textarea 里的换行转成 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} />;
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
/* 首页开场:半透明底 + 酒瓶 + 分流光 + 文字渐显 */
|
||||
|
||||
.home-splash {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 10010;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.home-splash--out {
|
||||
animation: home-splash-out 0.8s ease-in forwards;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.home-splash-veil {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: rgba(20, 8, 8, 0.58);
|
||||
background-image: radial-gradient(
|
||||
ellipse at 50% 48%,
|
||||
rgba(166, 29, 36, 0.42) 0%,
|
||||
rgba(20, 8, 8, 0.62) 62%,
|
||||
rgba(10, 4, 4, 0.72) 100%
|
||||
);
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 0.7s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-copy {
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.home-splash-title {
|
||||
font-family: 'Songti SC', 'STSong', 'Noto Serif SC', 'PingFang SC', serif;
|
||||
font-size: 40px;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
letter-spacing: 0.22em;
|
||||
color: #f5d76e;
|
||||
text-shadow: 0 0 14px rgba(255, 191, 0, 0.55), 0 2px 10px rgba(20, 8, 8, 0.45);
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 1.1s 0.65s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-sub {
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.16em;
|
||||
color: rgba(255, 248, 210, 0.88);
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 1.1s 1.35s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-stage {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
width: 220px;
|
||||
height: 420px;
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 1s 0.2s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-glow {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
left: 18px;
|
||||
right: 18px;
|
||||
top: 18%;
|
||||
bottom: 8%;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(ellipse at 50% 50%, rgba(255, 191, 0, 0.34) 0%, rgba(255, 191, 0, 0) 72%);
|
||||
opacity: 0;
|
||||
animation: home-splash-glow 2.6s 0.8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.home-splash-beam {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
width: 46px;
|
||||
margin-left: -23px;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(255, 248, 210, 0) 0%,
|
||||
rgba(255, 248, 210, 0.16) 28%,
|
||||
rgba(255, 191, 0, 0.22) 50%,
|
||||
rgba(255, 248, 210, 0.1) 78%,
|
||||
rgba(255, 248, 210, 0) 100%
|
||||
);
|
||||
opacity: 0;
|
||||
animation: home-splash-beam 3.2s 1.1s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.home-splash-bottle {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: block;
|
||||
width: 220px;
|
||||
height: 420px;
|
||||
}
|
||||
|
||||
.home-splash-bottle img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.home-splash-lights {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 220px;
|
||||
height: 420px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
-webkit-mask-size: contain;
|
||||
mask-size: contain;
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
mask-repeat: no-repeat;
|
||||
-webkit-mask-position: center;
|
||||
mask-mode: alpha;
|
||||
}
|
||||
|
||||
.home-splash-sheen {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
top: -12%;
|
||||
bottom: -12%;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.home-splash-sheen--a {
|
||||
width: 48px;
|
||||
left: 0;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgba(255, 255, 255, 0) 0%,
|
||||
rgba(255, 248, 210, 0.08) 28%,
|
||||
rgba(255, 248, 210, 0.55) 50%,
|
||||
rgba(255, 191, 0, 0.18) 72%,
|
||||
rgba(255, 255, 255, 0) 100%
|
||||
);
|
||||
transform: translateX(-70px) skewX(-22deg);
|
||||
animation: home-splash-sheen-a 2.8s 1.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.home-splash-sheen--b {
|
||||
width: 22px;
|
||||
left: 0;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgba(255, 255, 255, 0) 0%,
|
||||
rgba(255, 255, 255, 0.42) 50%,
|
||||
rgba(255, 255, 255, 0) 100%
|
||||
);
|
||||
transform: translateX(-50px) skewX(-18deg);
|
||||
animation: home-splash-sheen-b 3.6s 2.3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.home-splash-skip {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
z-index: 4;
|
||||
padding: 6px 14px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(245, 215, 110, 0.45);
|
||||
background: rgba(20, 8, 8, 0.35);
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 0.6s 0.35s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-skip-text {
|
||||
color: rgba(255, 248, 210, 0.92);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
@keyframes home-splash-fade {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-glow {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.35;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-beam {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
40% {
|
||||
opacity: 0.7;
|
||||
}
|
||||
70% {
|
||||
opacity: 0.15;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-sheen-a {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateX(-70px) skewX(-22deg);
|
||||
}
|
||||
18% {
|
||||
opacity: 1;
|
||||
}
|
||||
82% {
|
||||
opacity: 0.7;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translateX(250px) skewX(-22deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-sheen-b {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateX(-40px) skewX(-18deg);
|
||||
}
|
||||
22% {
|
||||
opacity: 0.9;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translateX(240px) skewX(-18deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { Image, Text, View } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { HOME_SPLASH_BOTTLE_URL } from '@dukang/shared-types';
|
||||
import { markHomeSplashPlayed } from '../lib/home-splash';
|
||||
|
||||
const SPLASH_NAV_BG = '#140808';
|
||||
const HOME_NAV_BG = '#FAF9F7';
|
||||
const FADE_AT_MS = 4800;
|
||||
const FADE_MS = 800;
|
||||
|
||||
type HomeSplashProps = {
|
||||
onDone: () => void;
|
||||
};
|
||||
|
||||
function applySplashChrome() {
|
||||
try {
|
||||
void Taro.hideTabBar({ animation: false });
|
||||
} catch {
|
||||
/* H5 无原生 TabBar */
|
||||
}
|
||||
void Taro.setNavigationBarColor({
|
||||
frontColor: '#ffffff',
|
||||
backgroundColor: SPLASH_NAV_BG,
|
||||
animation: { duration: 200, timingFunc: 'easeIn' },
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
function restoreChrome() {
|
||||
try {
|
||||
void Taro.showTabBar({ animation: false });
|
||||
} catch {
|
||||
/* H5 无原生 TabBar */
|
||||
}
|
||||
void Taro.setNavigationBarColor({
|
||||
frontColor: '#000000',
|
||||
backgroundColor: HOME_NAV_BG,
|
||||
animation: { duration: 200, timingFunc: 'easeOut' },
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
export default function HomeSplash({ onDone }: HomeSplashProps) {
|
||||
const finishedRef = useRef(false);
|
||||
const fadingRef = useRef(false);
|
||||
const onDoneRef = useRef(onDone);
|
||||
onDoneRef.current = onDone;
|
||||
const [leaving, setLeaving] = useState(false);
|
||||
|
||||
const finish = useCallback(() => {
|
||||
if (finishedRef.current) return;
|
||||
finishedRef.current = true;
|
||||
restoreChrome();
|
||||
onDoneRef.current();
|
||||
}, []);
|
||||
|
||||
const beginExit = useCallback(() => {
|
||||
if (fadingRef.current || finishedRef.current) return;
|
||||
fadingRef.current = true;
|
||||
setLeaving(true);
|
||||
setTimeout(finish, FADE_MS);
|
||||
}, [finish]);
|
||||
|
||||
useEffect(() => {
|
||||
markHomeSplashPlayed();
|
||||
applySplashChrome();
|
||||
const timer = setTimeout(beginExit, FADE_AT_MS);
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
if (!finishedRef.current) restoreChrome();
|
||||
};
|
||||
}, [beginExit]);
|
||||
|
||||
return (
|
||||
<View
|
||||
className={`home-splash${leaving ? ' home-splash--out' : ''}`}
|
||||
catchMove
|
||||
onTouchMove={(e) => {
|
||||
e.stopPropagation?.();
|
||||
}}
|
||||
>
|
||||
<View className="home-splash-veil" />
|
||||
|
||||
<View className="home-splash-copy">
|
||||
<Text className="home-splash-title">杜康好客</Text>
|
||||
<Text className="home-splash-sub">购杜康好酒,赠好客权益</Text>
|
||||
</View>
|
||||
|
||||
<View className="home-splash-stage">
|
||||
<View className="home-splash-glow" />
|
||||
<Image
|
||||
className="home-splash-bottle"
|
||||
src={HOME_SPLASH_BOTTLE_URL}
|
||||
mode="aspectFit"
|
||||
style={{ width: '220px', height: '420px' }}
|
||||
/>
|
||||
<View
|
||||
className="home-splash-lights"
|
||||
style={{
|
||||
width: '220px',
|
||||
height: '420px',
|
||||
WebkitMaskImage: `url(${HOME_SPLASH_BOTTLE_URL})`,
|
||||
maskImage: `url(${HOME_SPLASH_BOTTLE_URL})`,
|
||||
WebkitMaskSize: 'contain',
|
||||
maskSize: 'contain',
|
||||
WebkitMaskRepeat: 'no-repeat',
|
||||
maskRepeat: 'no-repeat',
|
||||
WebkitMaskPosition: 'center',
|
||||
}}
|
||||
>
|
||||
<View className="home-splash-beam" />
|
||||
<View className="home-splash-sheen home-splash-sheen--a" />
|
||||
<View className="home-splash-sheen home-splash-sheen--b" />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="home-splash-skip" onClick={finish}>
|
||||
<Text className="home-splash-skip-text">跳过</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { View, Text, Input } from '@tarojs/components';
|
||||
|
||||
type OrderQtyControlsProps = {
|
||||
value: number;
|
||||
unitLabel: string;
|
||||
onChange: (next: number) => void;
|
||||
};
|
||||
|
||||
const MAX_QTY = 999;
|
||||
|
||||
function parseQty(raw: string): number | null {
|
||||
const n = parseInt(String(raw).replace(/\D/g, ''), 10);
|
||||
if (!Number.isFinite(n)) return null;
|
||||
return Math.min(MAX_QTY, Math.max(1, n));
|
||||
}
|
||||
|
||||
/** 下单数量:加减 + 手动输入,旁注单位(瓶/箱) */
|
||||
export default function OrderQtyControls({ value, unitLabel, onChange }: OrderQtyControlsProps) {
|
||||
const [draft, setDraft] = useState(String(value));
|
||||
|
||||
useEffect(() => {
|
||||
setDraft(String(value));
|
||||
}, [value]);
|
||||
|
||||
function current(): number {
|
||||
return parseQty(draft) ?? value;
|
||||
}
|
||||
|
||||
function commit() {
|
||||
const next = parseQty(draft);
|
||||
if (next == null) {
|
||||
setDraft(String(value));
|
||||
return;
|
||||
}
|
||||
setDraft(String(next));
|
||||
if (next !== value) onChange(next);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="order-qty-row">
|
||||
<Text>购买数量</Text>
|
||||
<View className="order-qty-controls">
|
||||
<View className="order-qty-btn" onClick={() => onChange(Math.max(1, current() - 1))}>
|
||||
<Text>−</Text>
|
||||
</View>
|
||||
<Input
|
||||
className="order-qty-input"
|
||||
type="number"
|
||||
maxlength={3}
|
||||
value={draft}
|
||||
onInput={(e) => setDraft(String(e.detail.value ?? ''))}
|
||||
onBlur={commit}
|
||||
onConfirm={commit}
|
||||
/>
|
||||
<Text className="order-qty-unit">{unitLabel}</Text>
|
||||
<View className="order-qty-btn" onClick={() => onChange(Math.min(MAX_QTY, current() + 1))}>
|
||||
<Text>+</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -10,10 +10,11 @@ import {
|
||||
const CANVAS_ID = 'redeem-qr-canvas';
|
||||
|
||||
type RedeemQrCodeProps = {
|
||||
token: string;
|
||||
/** 二维码内容:门店 H5 落地 URL,缺省回退 token */
|
||||
payload: string;
|
||||
};
|
||||
|
||||
function drawOnWeappCanvas(token: string) {
|
||||
function drawOnWeappCanvas(payload: string) {
|
||||
const page = Taro.getCurrentInstance().page;
|
||||
const query = page ? Taro.createSelectorQuery().in(page) : Taro.createSelectorQuery();
|
||||
query
|
||||
@@ -33,33 +34,33 @@ function drawOnWeappCanvas(token: string) {
|
||||
canvas.width = layoutW * dpr;
|
||||
canvas.height = layoutH * 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 isWeapp = process.env.TARO_ENV === 'weapp';
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) {
|
||||
if (!payload) {
|
||||
setImgSrc('');
|
||||
return;
|
||||
}
|
||||
|
||||
if (isWeapp) {
|
||||
const timer = setTimeout(() => drawOnWeappCanvas(token), 120);
|
||||
const timer = setTimeout(() => drawOnWeappCanvas(payload), 120);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
void buildRedeemQrDataUrl(token).then((url) => {
|
||||
void buildRedeemQrDataUrl(payload).then((url) => {
|
||||
if (!cancelled) setImgSrc(url);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [token, isWeapp]);
|
||||
}, [payload, isWeapp]);
|
||||
|
||||
return (
|
||||
<View className="redeem-qr-box">
|
||||
|
||||
@@ -1,215 +1,67 @@
|
||||
import { useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { useMemo } from 'react';
|
||||
import { View, Text, Swiper, SwiperItem } from '@tarojs/components';
|
||||
|
||||
type StoreRedeemMarqueeProps = {
|
||||
lines: string[];
|
||||
export type StoreRedeemMarqueeItem = {
|
||||
userLabel: string;
|
||||
amount: string;
|
||||
};
|
||||
|
||||
const FLY_SPEED = 56;
|
||||
const MIN_FLY_MS = 2400;
|
||||
const PAUSE_MIN_MS = 1000;
|
||||
const PAUSE_MAX_MS = 5000;
|
||||
const TICK_MS = 16;
|
||||
/** 全文滚出视口后,再向左多走 10px */
|
||||
const EXTRA_AFTER_EXIT_PX = 10;
|
||||
type StoreRedeemMarqueeProps = {
|
||||
items: StoreRedeemMarqueeItem[];
|
||||
};
|
||||
|
||||
function estimateTextWidth(text: string): number {
|
||||
let w = 0;
|
||||
for (const ch of text) {
|
||||
w += /[^\x00-\xff]/.test(ch) ? 12 : 7;
|
||||
}
|
||||
return Math.max(Math.ceil(w), 80);
|
||||
}
|
||||
|
||||
function randomPauseMs() {
|
||||
return PAUSE_MIN_MS + Math.floor(Math.random() * (PAUSE_MAX_MS - PAUSE_MIN_MS + 1));
|
||||
}
|
||||
|
||||
/** 容器宽兜底(不依赖 DOM 测量,小程序首帧即可用) */
|
||||
function getBoxWidthFallback(): number {
|
||||
try {
|
||||
const sys = Taro.getSystemInfoSync();
|
||||
const screenW = Number(sys.windowWidth || sys.screenWidth || 375);
|
||||
// 与 section 同宽:左右 var(--space-page)
|
||||
return Math.max(220, Math.floor(screenW - 32));
|
||||
} catch {
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
||||
function measureBoxWidth(selector: string, fallback: number): Promise<number> {
|
||||
return new Promise((resolve) => {
|
||||
Taro.nextTick(() => {
|
||||
try {
|
||||
const page = Taro.getCurrentInstance().page;
|
||||
const query = page ? Taro.createSelectorQuery().in(page) : Taro.createSelectorQuery();
|
||||
query
|
||||
.select(selector)
|
||||
.boundingClientRect()
|
||||
.exec((res) => {
|
||||
const w = Number(res?.[0]?.width || 0);
|
||||
resolve(w > 8 ? Math.ceil(w) : fallback);
|
||||
});
|
||||
} catch {
|
||||
resolve(fallback);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function measureTextWidth(selector: string, text: string): Promise<number> {
|
||||
const fallback = estimateTextWidth(text);
|
||||
return new Promise((resolve) => {
|
||||
Taro.nextTick(() => {
|
||||
try {
|
||||
const page = Taro.getCurrentInstance().page;
|
||||
const query = page ? Taro.createSelectorQuery().in(page) : Taro.createSelectorQuery();
|
||||
query
|
||||
.select(selector)
|
||||
.boundingClientRect()
|
||||
.exec((res) => {
|
||||
const w = Number(res?.[0]?.width || 0);
|
||||
if (w > 8 && w < fallback * 3) resolve(Math.ceil(w));
|
||||
else resolve(fallback);
|
||||
});
|
||||
} catch {
|
||||
resolve(fallback);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销走马灯:单条从右向左位移飞出,间隔 1~5 秒随机再播下一条。
|
||||
*
|
||||
* 小程序注意:
|
||||
* - 不用 useReady(子组件内不触发 → opacity 永远 0)
|
||||
* - 不用 Text + transform(支持差),改用 View + left
|
||||
* - 字宽用估算,避免屏外元素测宽失败
|
||||
*/
|
||||
export default function StoreRedeemMarquee({ lines }: StoreRedeemMarqueeProps) {
|
||||
const items = useMemo(
|
||||
() =>
|
||||
lines
|
||||
.map((s) => String(s || '').trim())
|
||||
.filter(Boolean),
|
||||
[lines],
|
||||
);
|
||||
|
||||
const rootIdRef = useRef(`smr${Math.random().toString(36).slice(2, 10)}`);
|
||||
const textIdRef = useRef(`smt${Math.random().toString(36).slice(2, 10)}`);
|
||||
const indexRef = useRef(0);
|
||||
const boxWidthRef = useRef(getBoxWidthFallback());
|
||||
const itemsKey = items.join('\n');
|
||||
|
||||
const [displayIndex, setDisplayIndex] = useState(0);
|
||||
const [leftPx, setLeftPx] = useState(() => boxWidthRef.current);
|
||||
|
||||
useEffect(() => {
|
||||
if (!items.length) return;
|
||||
|
||||
let cancelled = false;
|
||||
const waiters = new Set<ReturnType<typeof setTimeout>>();
|
||||
let tickTimer: ReturnType<typeof setInterval> | undefined;
|
||||
|
||||
const sleep = (ms: number) =>
|
||||
new Promise<void>((resolve) => {
|
||||
const id = setTimeout(() => {
|
||||
waiters.delete(id);
|
||||
resolve();
|
||||
}, ms);
|
||||
waiters.add(id);
|
||||
});
|
||||
|
||||
const clearTick = () => {
|
||||
if (tickTimer) {
|
||||
clearInterval(tickTimer);
|
||||
tickTimer = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const fly = (from: number, to: number, durationMs: number) =>
|
||||
new Promise<void>((resolve) => {
|
||||
const began = Date.now();
|
||||
setLeftPx(from);
|
||||
clearTick();
|
||||
tickTimer = setInterval(() => {
|
||||
if (cancelled) {
|
||||
clearTick();
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
const t = Math.min(1, (Date.now() - began) / durationMs);
|
||||
setLeftPx(from + (to - from) * t);
|
||||
if (t >= 1) {
|
||||
clearTick();
|
||||
resolve();
|
||||
}
|
||||
}, TICK_MS);
|
||||
});
|
||||
|
||||
const loop = async () => {
|
||||
indexRef.current = 0;
|
||||
setDisplayIndex(0);
|
||||
|
||||
const measured = await measureBoxWidth(`#${rootIdRef.current}`, boxWidthRef.current);
|
||||
boxWidthRef.current = measured;
|
||||
if (cancelled) return;
|
||||
|
||||
while (!cancelled && items.length) {
|
||||
const idx = indexRef.current % items.length;
|
||||
const text = items[idx];
|
||||
const box = boxWidthRef.current;
|
||||
|
||||
setDisplayIndex(idx);
|
||||
|
||||
const from = box;
|
||||
setLeftPx(from);
|
||||
await sleep(48);
|
||||
if (cancelled) break;
|
||||
|
||||
const textW = await measureTextWidth(`#${textIdRef.current}`, text);
|
||||
// 全文 left 边缘移出容器左边界后再走 10px
|
||||
const to = -(textW + EXTRA_AFTER_EXIT_PX);
|
||||
const distance = from - to;
|
||||
const durationMs = Math.max(MIN_FLY_MS, Math.round((distance / FLY_SPEED) * 1000));
|
||||
|
||||
await sleep(32);
|
||||
if (cancelled) break;
|
||||
|
||||
await fly(from, to, durationMs);
|
||||
if (cancelled) break;
|
||||
|
||||
await sleep(randomPauseMs());
|
||||
if (cancelled) break;
|
||||
|
||||
indexRef.current = (idx + 1) % items.length;
|
||||
}
|
||||
};
|
||||
|
||||
void loop();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
clearTick();
|
||||
waiters.forEach(clearTimeout);
|
||||
waiters.clear();
|
||||
};
|
||||
}, [itemsKey, items]);
|
||||
|
||||
if (!items.length) return null;
|
||||
|
||||
const current = items[displayIndex] || items[0];
|
||||
const innerStyle: CSSProperties = { left: `${leftPx}px` };
|
||||
const STAY_MS = 20000;
|
||||
|
||||
function MarqueeRow({ item }: { item: StoreRedeemMarqueeItem }) {
|
||||
return (
|
||||
<View id={rootIdRef.current} className="store-detail-marquee">
|
||||
<View className="store-detail-marquee-inner" style={innerStyle}>
|
||||
<Text id={textIdRef.current} className="store-detail-marquee-text">
|
||||
{current}
|
||||
</Text>
|
||||
</View>
|
||||
<View className="store-detail-marquee-inner">
|
||||
<View className="store-detail-marquee-dot" />
|
||||
<Text className="store-detail-marquee-text">{item.userLabel} 刚刚到店核销</Text>
|
||||
<Text className="store-detail-marquee-amount">{item.amount}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 核销记录:单条静止;多条竖向循环,每条停留 20 秒 */
|
||||
export default function StoreRedeemMarquee({ items }: StoreRedeemMarqueeProps) {
|
||||
const list = useMemo(
|
||||
() =>
|
||||
items
|
||||
.map((row) => ({
|
||||
userLabel: String(row.userLabel || '用户***').trim() || '用户***',
|
||||
amount: String(row.amount || '').trim(),
|
||||
}))
|
||||
.filter((row) => row.amount),
|
||||
[items],
|
||||
);
|
||||
|
||||
if (!list.length) return null;
|
||||
|
||||
if (list.length === 1) {
|
||||
return (
|
||||
<View className="store-detail-marquee">
|
||||
<MarqueeRow item={list[0]} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="store-detail-marquee">
|
||||
<Swiper
|
||||
className="store-detail-marquee-swiper"
|
||||
vertical
|
||||
circular
|
||||
autoplay
|
||||
interval={STAY_MS}
|
||||
duration={400}
|
||||
indicatorDots={false}
|
||||
>
|
||||
{list.map((row, index) => (
|
||||
<SwiperItem key={`${row.userLabel}|${row.amount}|${index}`}>
|
||||
<MarqueeRow item={row} />
|
||||
</SwiperItem>
|
||||
))}
|
||||
</Swiper>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import iconHomeActive from '../assets/tabbar/home-active.png';
|
||||
import iconStore from '../assets/tabbar/store.png';
|
||||
import iconStoreActive from '../assets/tabbar/store-active.png';
|
||||
import iconBenefit from '../assets/tabbar/benefit.png';
|
||||
import iconBenefitActive from '../assets/tabbar/benefit-active.png';
|
||||
import iconBenefitActive from '../assets/icons/store-benefit-y.png';
|
||||
import iconMine from '../assets/tabbar/mine.png';
|
||||
import iconMineActive from '../assets/tabbar/mine-active.png';
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
export const BENEFIT_SLOGAN = '购杜康好酒,赠用餐权益';
|
||||
|
||||
export const BENEFIT_INTRO =
|
||||
'购杜康好酒,赠用餐权益,到签约饭店核销。权益随酒赠送,仅限签约饭店到店用餐,不可兑现、不可转卖。';
|
||||
|
||||
export const BENEFIT_INTRO_EMPHASIS = '不可兑现、不可转卖。';
|
||||
|
||||
export const BENEFIT_GIFT_TAG = '买酒即赠用餐权益';
|
||||
|
||||
export const BENEFIT_TAG = '好客权益';
|
||||
|
||||
export const BENEFIT_RULES_PATH = '/pages/benefit-rules/index';
|
||||
|
||||
export const BENEFIT_RULES_TITLE = '好客权益使用说明';
|
||||
|
||||
export const BENEFIT_RULES_SUMMARY =
|
||||
'购杜康好酒,赠用餐权益,到签约饭店核销。权益随酒赠送,仅限杜康好客平台签约饭店到店用餐,不可兑现、不可转卖。';
|
||||
|
||||
export const BENEFIT_RULES_SECTIONS = [
|
||||
{
|
||||
heading: '一、权益从哪来',
|
||||
paragraphs: [
|
||||
'好客权益是购买杜康好酒时随酒赠送的用餐权益,用于在签约饭店到店用餐,不是储值卡、预付卡,也不是现金账户。',
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: '二、如何获得',
|
||||
paragraphs: [
|
||||
'在小程序内购买杜康好酒并支付成功后,系统按商品说明发放对应用餐权益。未支付或已取消的订单不产生权益。不支持单独购买或充值权益。',
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: '三、如何使用',
|
||||
paragraphs: [
|
||||
'1. 在「门店」中选择签约饭店,到店用餐时出示核销码或提供手机号,由门店完成核销。',
|
||||
'2. 核销码有效期为 3 分钟,过期请重新生成。',
|
||||
'3. 权益可按实际消费分次核销,累计核销金额不可超过已获得的权益总额。',
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: '四、使用范围',
|
||||
paragraphs: [
|
||||
'仅限杜康好客平台签约饭店到店用餐使用。香烟、酒水一律不可核销。其他菜品是否可核销以门店当场说明为准。',
|
||||
],
|
||||
emphasize: '香烟、酒水一律不可核销。',
|
||||
},
|
||||
{
|
||||
heading: '五、使用限制',
|
||||
paragraphs: ['不可兑现、不可转卖、不可提现、不可充值,不可当现金使用。'],
|
||||
emphasizeAll: true,
|
||||
},
|
||||
{
|
||||
heading: '六、退货与权益收回',
|
||||
paragraphs: [
|
||||
'酒水退货退款时,未使用的权益将收回;已核销部分不退回。酒款按原支付路径退回。仅换货不退款的,一般保留原权益。',
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: '七、有效期',
|
||||
paragraphs: ['好客权益暂无使用期限,持续有效,直至收回或全部核销完毕。'],
|
||||
},
|
||||
{
|
||||
heading: '八、联系客服',
|
||||
paragraphs: ['如有疑问,可通过小程序「联系客服」咨询,或拨打客服电话。'],
|
||||
},
|
||||
] as const;
|
||||
|
||||
export const BENEFIT_RULES_FOOTER = '请理性饮酒。未满十八周岁不得饮酒。过量饮酒有害健康。';
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
BRAND_LOGO_URL,
|
||||
BRAND_LOGO_WIDE_URL,
|
||||
CUSTOMER_SERVICE_PHONE,
|
||||
CUSTOMER_SERVICE_WECOM_URL,
|
||||
QUALIFICATION_DISCLOSURE_URL,
|
||||
type ClientRuntimeConfig,
|
||||
} from '@dukang/shared-types';
|
||||
@@ -14,6 +15,8 @@ export type BrandAssets = {
|
||||
brandLogoMarkUrl: string;
|
||||
qualificationDisclosureUrl: string;
|
||||
customerServicePhone: string;
|
||||
customerServiceWecomUrl: string;
|
||||
wecomCorpId: string;
|
||||
};
|
||||
|
||||
const FALLBACK: BrandAssets = {
|
||||
@@ -22,6 +25,8 @@ const FALLBACK: BrandAssets = {
|
||||
brandLogoMarkUrl: BRAND_LOGO_MARK_URL,
|
||||
qualificationDisclosureUrl: QUALIFICATION_DISCLOSURE_URL,
|
||||
customerServicePhone: CUSTOMER_SERVICE_PHONE,
|
||||
customerServiceWecomUrl: CUSTOMER_SERVICE_WECOM_URL,
|
||||
wecomCorpId: '',
|
||||
};
|
||||
|
||||
let cached: BrandAssets | null = null;
|
||||
@@ -35,6 +40,9 @@ function fromConfig(config: ClientRuntimeConfig | null | undefined): BrandAssets
|
||||
qualificationDisclosureUrl:
|
||||
config?.qualificationDisclosureUrl?.trim() || FALLBACK.qualificationDisclosureUrl,
|
||||
customerServicePhone: config?.customerServicePhone?.trim() || FALLBACK.customerServicePhone,
|
||||
customerServiceWecomUrl:
|
||||
config?.customerServiceWecomUrl?.trim() || FALLBACK.customerServiceWecomUrl,
|
||||
wecomCorpId: config?.wecomCorpId?.trim() || FALLBACK.wecomCorpId,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import Taro from '@tarojs/taro';
|
||||
import { fetchClientConfig } from './pay-wechat';
|
||||
|
||||
/** 与 package.json version 同步,供服务端 minClientVersion 比对 */
|
||||
export const APP_VERSION = '3.5.4';
|
||||
export const APP_VERSION = '3.5.16';
|
||||
|
||||
export const APP_VERSION_LABEL = `v${APP_VERSION}`;
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
import { HOME_SPLASH_BOTTLE_URL } from '@dukang/shared-types';
|
||||
|
||||
/** 冷启动会话内是否已播过首页开场(进程级,切 Tab 不重播) */
|
||||
|
||||
let played = false;
|
||||
|
||||
export function hasHomeSplashPlayed() {
|
||||
return played;
|
||||
}
|
||||
|
||||
export function markHomeSplashPlayed() {
|
||||
played = true;
|
||||
}
|
||||
|
||||
/** 冷启动预拉 OSS 开场图(仅 weapp;H5 的 getImageInfo 会走 CORS) */
|
||||
export function prefetchHomeSplashAssets() {
|
||||
if (played) return;
|
||||
if (process.env.TARO_ENV !== 'weapp') return;
|
||||
void Taro.getImageInfo({ src: HOME_SPLASH_BOTTLE_URL }).catch(() => {});
|
||||
}
|
||||
@@ -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 / 交易硬闸一致) */
|
||||
|
||||
export type FulfillmentFlags = {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
import { request } from './api';
|
||||
import { request, isLoggedIn, toast } from './api';
|
||||
|
||||
const PROMO_ID_KEY = 'dukang_promo_id';
|
||||
const ASSOC_SCENE_KEY = 'dukang_partner_assoc_scene';
|
||||
|
||||
/** 同一次进入只 touch 一次扫码计数,避免首页反复 onShow 刷量 */
|
||||
let lastScanTouchKey = '';
|
||||
@@ -28,10 +29,54 @@ type EnterOptionsLike = {
|
||||
path?: string;
|
||||
};
|
||||
|
||||
function normalizeAssocScene(raw: unknown): string | null {
|
||||
if (raw == null || raw === '') return null;
|
||||
const s = safeDecode(String(raw)).trim();
|
||||
return /^pa_\d+$/.test(s) ? s : null;
|
||||
}
|
||||
|
||||
function extractAssocSceneFromEnterOptions(opts?: EnterOptionsLike | null): string | null {
|
||||
if (!opts) return null;
|
||||
const q = opts.query ?? {};
|
||||
return (
|
||||
normalizeAssocScene(q.scene) ||
|
||||
normalizeAssocScene(opts.scene) ||
|
||||
normalizeAssocScene(q.partnerId) ||
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
export function getStoredAssocScene(): string | null {
|
||||
try {
|
||||
return normalizeAssocScene(Taro.getStorageSync(ASSOC_SCENE_KEY));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function setStoredAssocScene(scene: string) {
|
||||
const id = normalizeAssocScene(scene);
|
||||
if (!id) return;
|
||||
try {
|
||||
Taro.setStorageSync(ASSOC_SCENE_KEY, id);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export function clearStoredAssocScene() {
|
||||
try {
|
||||
Taro.removeStorageSync(ASSOC_SCENE_KEY);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
/** 从启动/进入参数解析推广活动 ID(优先 query.scene,与 getwxacodeunlimit 一致) */
|
||||
export function extractPromoIdFromEnterOptions(opts?: EnterOptionsLike | null): string | null {
|
||||
if (!opts) return null;
|
||||
const q = opts.query ?? {};
|
||||
if (extractAssocSceneFromEnterOptions(opts)) return null;
|
||||
return (
|
||||
normalizePromoId(q.scene) ||
|
||||
normalizePromoId(q.promoId) ||
|
||||
@@ -92,8 +137,35 @@ function readEnterOptions(): EnterOptionsLike | null {
|
||||
* 主页面进入时:取出 scene(活动 ID)本地缓存,并回传 /promo/touch 累加扫码次数。
|
||||
* 同一进入会话只计一次扫码。
|
||||
*/
|
||||
async function bindStoredAssocIfLoggedIn(): Promise<void> {
|
||||
const scene = getStoredAssocScene();
|
||||
if (!scene || !isLoggedIn()) return;
|
||||
try {
|
||||
const result = await request<{ alreadyBound?: boolean; bound?: boolean }>('/user/partner-assoc/bind', {
|
||||
method: 'POST',
|
||||
data: { scene },
|
||||
});
|
||||
clearStoredAssocScene();
|
||||
if (result.alreadyBound) toast('已关联');
|
||||
else if (result.bound) toast('关联成功', 'success');
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : '';
|
||||
if (msg.includes('已关联')) {
|
||||
clearStoredAssocScene();
|
||||
toast('已关联');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function capturePromoSceneAndTouchScan(): Promise<void> {
|
||||
const opts = readEnterOptions();
|
||||
const assocScene = extractAssocSceneFromEnterOptions(opts);
|
||||
if (assocScene) {
|
||||
setStoredAssocScene(assocScene);
|
||||
await bindStoredAssocIfLoggedIn();
|
||||
return;
|
||||
}
|
||||
|
||||
const fromEnter = extractPromoIdFromEnterOptions(opts);
|
||||
if (fromEnter) {
|
||||
setStoredPromoId(fromEnter);
|
||||
@@ -109,6 +181,7 @@ export async function capturePromoSceneAndTouchScan(): Promise<void> {
|
||||
|
||||
/** 登录成功后:用已缓存的活动 ID 做归因(不重复加扫码次数) */
|
||||
export async function touchStoredPromoAfterLogin(): Promise<void> {
|
||||
await bindStoredAssocIfLoggedIn();
|
||||
const promoId = getStoredPromoId();
|
||||
if (!promoId) return;
|
||||
await touchPromo({ promoId, countScan: false });
|
||||
|
||||
@@ -8,13 +8,13 @@ const QR_OPTIONS = {
|
||||
color: { dark: '#1f1a17', light: '#ffffff' },
|
||||
} as const;
|
||||
|
||||
/** 在 2d Canvas 上绘制二维码(小程序 / H5 通用) */
|
||||
/** 在 2d Canvas 上绘制二维码(小程序 / H5 通用;payload 为落地 URL 或纯 token) */
|
||||
export function drawRedeemQrOnCanvas(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
token: string,
|
||||
payload: string,
|
||||
sizePx = QR_SIZE,
|
||||
) {
|
||||
const qr = QRCode.create(token, { errorCorrectionLevel: 'M' });
|
||||
const qr = QRCode.create(payload, { errorCorrectionLevel: 'M' });
|
||||
const count = qr.modules.size;
|
||||
const cell = sizePx / count;
|
||||
|
||||
@@ -31,11 +31,11 @@ export function drawRedeemQrOnCanvas(
|
||||
}
|
||||
|
||||
/** H5:Data URL;失败时回退到与 h5-user 相同的外部 QR 服务 */
|
||||
export async function buildRedeemQrDataUrl(token: string): Promise<string> {
|
||||
export async function buildRedeemQrDataUrl(payload: string): Promise<string> {
|
||||
try {
|
||||
return await QRCode.toDataURL(token, QR_OPTIONS);
|
||||
return await QRCode.toDataURL(payload, QR_OPTIONS);
|
||||
} 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)}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
export type StoreCategoryLike = {
|
||||
id?: string;
|
||||
name?: string;
|
||||
parentId?: string | null;
|
||||
parent?: { name?: string } | null;
|
||||
};
|
||||
|
||||
export type StoreCategoryTreeNode = {
|
||||
id: string;
|
||||
name: string;
|
||||
children?: { id: string; name: string }[];
|
||||
};
|
||||
|
||||
export function storeStarCount(rating?: number | string | null): number {
|
||||
const n = Number(rating);
|
||||
if (!Number.isFinite(n) || n <= 0) return 5;
|
||||
return Math.min(5, Math.max(1, Math.round(n)));
|
||||
}
|
||||
|
||||
export function storeCategoryTags(
|
||||
store: {
|
||||
tags?: unknown;
|
||||
categoryId?: string | null;
|
||||
category?: StoreCategoryLike | null;
|
||||
},
|
||||
tree: StoreCategoryTreeNode[] = [],
|
||||
): string[] {
|
||||
const fromJson = Array.isArray(store.tags)
|
||||
? store.tags.map((t) => String(t).trim()).filter(Boolean)
|
||||
: [];
|
||||
if (fromJson.length) return fromJson;
|
||||
|
||||
const names: string[] = [];
|
||||
const childName = String(store.category?.name || '').trim();
|
||||
const parentName = String(store.category?.parent?.name || '').trim();
|
||||
if (parentName) names.push(parentName);
|
||||
if (childName && childName !== parentName) names.push(childName);
|
||||
|
||||
const storeCatId = String(store.categoryId || store.category?.id || '');
|
||||
const storeParentId = String(store.category?.parentId || '');
|
||||
for (const root of tree) {
|
||||
if (root.id === storeParentId || root.id === storeCatId) {
|
||||
if (root.name && !names.includes(root.name)) names.unshift(root.name);
|
||||
}
|
||||
for (const child of root.children ?? []) {
|
||||
if (child.id === storeCatId) {
|
||||
if (root.name && !names.includes(root.name)) names.unshift(root.name);
|
||||
if (child.name && !names.includes(child.name)) names.push(child.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user