拦截伪区县写入与下单;推单失败挂 fulfillmentHold,HQ 可见超区/推单失败。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -30,6 +30,12 @@ export function getDistrictsForPicker(province: string, city: string): string[]
|
||||
return [REGION_ALL, ...getDistricts(province, city)];
|
||||
}
|
||||
|
||||
/** 收货地址:不含「全市」 */
|
||||
export function getDistrictsForShippingPicker(province: string, city: string): string[] {
|
||||
if (province === REGION_ALL || city === REGION_ALL) return [];
|
||||
return [...getDistricts(province, city)];
|
||||
}
|
||||
|
||||
export function formatRegion(province: string, city: string, district: string): string {
|
||||
if (!province) return '';
|
||||
if (province === REGION_ALL) return REGION_ALL;
|
||||
@@ -96,6 +102,35 @@ export const DEFAULT_REGION: RegionSelection = {
|
||||
district: REGION_ALL,
|
||||
};
|
||||
|
||||
/** 收货地址默认:不预填伪区县,迫使用户选真实区县 */
|
||||
export const DEFAULT_SHIPPING_REGION: RegionSelection = {
|
||||
province: '河南省',
|
||||
city: '郑州市',
|
||||
district: '',
|
||||
};
|
||||
|
||||
/** 收货场景:区县必须在省市区树内且非全市 */
|
||||
export function normalizeShippingRegionSelection(selection: RegionSelection): RegionSelection {
|
||||
const province = PROVINCES.includes(selection.province)
|
||||
? selection.province
|
||||
: DEFAULT_SHIPPING_REGION.province;
|
||||
const cities = getCities(province);
|
||||
const city = cities.includes(selection.city) ? selection.city : (cities[0] ?? DEFAULT_SHIPPING_REGION.city);
|
||||
const districts = getDistricts(province, city);
|
||||
const district =
|
||||
selection.district &&
|
||||
selection.district !== REGION_ALL &&
|
||||
districts.includes(selection.district)
|
||||
? selection.district
|
||||
: '';
|
||||
return { province, city, district };
|
||||
}
|
||||
|
||||
export function isShippingRegionComplete(selection: RegionSelection): boolean {
|
||||
const n = normalizeShippingRegionSelection(selection);
|
||||
return Boolean(n.province && n.city && n.district && n.district !== REGION_ALL);
|
||||
}
|
||||
|
||||
export function regionFromGeo(province: string, city: string, district?: string): RegionSelection {
|
||||
const cityName = city.endsWith('市') ? city : `${city}市`;
|
||||
const provinceInTree = PROVINCES.includes(province) ? province : DEFAULT_REGION.province;
|
||||
|
||||
Reference in New Issue
Block a user