fix(partner): drop pickup store and reorder promo on proxy order
CI / verify (pull_request) Has been cancelled
CI / verify (pull_request) Has been cancelled
On-site pickup no longer requires a store; move optional promo above fulfillment mode. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -31,7 +31,6 @@ export default function ProxyOrderPage() {
|
||||
const [quantity, setQuantity] = useState(2);
|
||||
const [promoCodeId, setPromoCodeId] = useState('');
|
||||
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>('ADDRESS');
|
||||
const [storeId, setStoreId] = useState('');
|
||||
const [autoReceive, setAutoReceive] = useState(false);
|
||||
const [confirmStep, setConfirmStep] = useState(false);
|
||||
const [preview, setPreview] = useState<PartnerProxyOrderPreviewResult | null>(null);
|
||||
@@ -57,7 +56,6 @@ export default function ProxyOrderPage() {
|
||||
} else if (data.products[0] && !productId) {
|
||||
setProductId(data.products[0].id);
|
||||
}
|
||||
if (data.stores?.[0] && !storeId) setStoreId(data.stores[0].id);
|
||||
})
|
||||
.catch((e) => toastError(e instanceof Error ? e.message : '加载失败'))
|
||||
.finally(() => setLoadingOptions(false));
|
||||
@@ -82,7 +80,6 @@ export default function ProxyOrderPage() {
|
||||
productId,
|
||||
quantity,
|
||||
deliveryMode,
|
||||
storeId: deliveryMode === 'ON_SITE_PICKUP' ? storeId || undefined : undefined,
|
||||
receiverCity: deliveryMode === 'ADDRESS' ? region?.city || undefined : undefined,
|
||||
receiverDistrict: deliveryMode === 'ADDRESS' ? region?.district || undefined : undefined,
|
||||
}),
|
||||
@@ -93,7 +90,7 @@ export default function ProxyOrderPage() {
|
||||
.finally(() => setPreviewLoading(false));
|
||||
}, 300);
|
||||
return () => clearTimeout(timer);
|
||||
}, [productId, quantity, deliveryMode, storeId, region?.city, region?.district]);
|
||||
}, [productId, quantity, deliveryMode, region?.city, region?.district]);
|
||||
|
||||
function startCooldown(setter: (n: number | ((s: number) => number)) => void) {
|
||||
setter(60);
|
||||
@@ -150,8 +147,8 @@ export default function ProxyOrderPage() {
|
||||
if (!/^1\d{10}$/.test(phone.trim())) return '请输入有效手机号';
|
||||
if (!customerSmsCode.trim()) return '请输入客户验证码';
|
||||
if (!productId) return '请选择商品';
|
||||
if (deliveryMode === 'ON_SITE_PICKUP') {
|
||||
if (!storeId) return '请选择提货门店';
|
||||
if (deliveryMode !== 'ADDRESS') {
|
||||
// 现场提货不需要地址与门店
|
||||
} else {
|
||||
if (!region?.province || !region?.city || !region?.district) return '请选择省市区';
|
||||
if (!addressDetail.trim()) return '请填写详细地址';
|
||||
@@ -191,7 +188,6 @@ export default function ProxyOrderPage() {
|
||||
partnerSmsCode: partnerSmsCode.trim(),
|
||||
deliveryMode,
|
||||
autoReceive: deliveryMode === 'ADDRESS' ? true : undefined,
|
||||
storeId: deliveryMode === 'ON_SITE_PICKUP' ? storeId : undefined,
|
||||
receiverName: receiverName.trim() || undefined,
|
||||
province: deliveryMode === 'ADDRESS' ? region?.province : undefined,
|
||||
city: deliveryMode === 'ADDRESS' ? region?.city : undefined,
|
||||
@@ -232,7 +228,7 @@ export default function ProxyOrderPage() {
|
||||
|
||||
<main className="partner-form-card" style={{ margin: '0 16px 24px' }}>
|
||||
{loadingOptions ? (
|
||||
<p className="label-md text-muted">加载商品与门店…</p>
|
||||
<p className="label-md text-muted">加载商品…</p>
|
||||
) : (
|
||||
<>
|
||||
<section className="partner-form-section">
|
||||
@@ -307,6 +303,30 @@ export default function ProxyOrderPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{(options?.promoCodes.length ?? 0) > 0 && (
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-form-label">绑定推广码(选填)</label>
|
||||
<select
|
||||
className="partner-input"
|
||||
value={promoCodeId}
|
||||
onChange={(e) => setPromoCodeId(e.target.value)}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '12px 14px',
|
||||
borderRadius: 12,
|
||||
border: '1px solid var(--color-border)',
|
||||
}}
|
||||
>
|
||||
<option value="">不绑定</option>
|
||||
{options!.promoCodes.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name}({p.code})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-form-label">履约方式</label>
|
||||
<div className="partner-proxy-mode-tabs">
|
||||
@@ -327,33 +347,7 @@ export default function ProxyOrderPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{deliveryMode === 'ON_SITE_PICKUP' ? (
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-form-label">提货门店</label>
|
||||
{(options?.stores.length ?? 0) === 0 ? (
|
||||
<p className="label-md text-muted">暂无名下门店,请先录入门店</p>
|
||||
) : (
|
||||
<select
|
||||
className="partner-input"
|
||||
value={storeId}
|
||||
onChange={(e) => setStoreId(e.target.value)}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '12px 14px',
|
||||
borderRadius: 12,
|
||||
border: '1px solid var(--color-border)',
|
||||
}}
|
||||
>
|
||||
{options!.stores.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.name}({s.district}
|
||||
{s.address})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
</section>
|
||||
) : (
|
||||
{deliveryMode === 'ADDRESS' ? (
|
||||
<>
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-form-label">收货人(选填)</label>
|
||||
@@ -398,31 +392,7 @@ export default function ProxyOrderPage() {
|
||||
<span>同意自动收货(线下代下单提交后视为已送达并发放权益)</span>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
|
||||
{(options?.promoCodes.length ?? 0) > 0 && (
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-form-label">绑定推广码(选填)</label>
|
||||
<select
|
||||
className="partner-input"
|
||||
value={promoCodeId}
|
||||
onChange={(e) => setPromoCodeId(e.target.value)}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '12px 14px',
|
||||
borderRadius: 12,
|
||||
border: '1px solid var(--color-border)',
|
||||
}}
|
||||
>
|
||||
<option value="">不绑定</option>
|
||||
{options!.promoCodes.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name}({p.code})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</section>
|
||||
)}
|
||||
) : null}
|
||||
|
||||
<section className="partner-proxy-fee-card">
|
||||
<h3 className="headline-md">费用明细</h3>
|
||||
|
||||
@@ -65,9 +65,8 @@ export class PartnerProxyOrderCreateDto {
|
||||
@IsBoolean()
|
||||
autoReceive?: boolean;
|
||||
|
||||
@ValidateIf((o: PartnerProxyOrderCreateDto) => o.deliveryMode === 'ON_SITE_PICKUP')
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
storeId?: string;
|
||||
|
||||
@IsOptional()
|
||||
|
||||
@@ -1228,17 +1228,12 @@ export class TradeService {
|
||||
let commissionDistrict = receiverDistrict;
|
||||
|
||||
if (body.deliveryMode === 'ON_SITE_PICKUP') {
|
||||
if (!body.storeId?.trim()) throw new BadRequestException('请选择提货门店');
|
||||
const store = await this.prisma.store.findFirst({
|
||||
where: { id: BigInt(body.storeId.trim()), partnerAccountId: primary.id },
|
||||
});
|
||||
if (!store) throw new BadRequestException('门店不存在或不属于当前合伙人');
|
||||
receiverName = store.name;
|
||||
receiverProvince = store.province;
|
||||
receiverCity = store.cityName;
|
||||
receiverDistrict = store.district;
|
||||
receiverAddress = `现场提货·${store.name}·${store.province}${store.cityName}${store.district}${store.address}`;
|
||||
commissionDistrict = store.district;
|
||||
receiverName = body.receiverName?.trim() || `用户${normalizedPhone.slice(-4)}`;
|
||||
receiverProvince = '现场';
|
||||
receiverCity = '现场';
|
||||
receiverDistrict = '取货';
|
||||
receiverAddress = '现场提货';
|
||||
commissionDistrict = '';
|
||||
} else {
|
||||
if (!receiverProvince || !receiverCity || !receiverDistrict) {
|
||||
throw new BadRequestException('请选择省市区');
|
||||
|
||||
Reference in New Issue
Block a user