拦截伪区县写入与下单;推单失败挂 fulfillmentHold,HQ 可见超区/推单失败。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
orderTabToStatuses,
|
||||
toMinSaleQuantity,
|
||||
validateMinPurchase,
|
||||
validateShippingAddress,
|
||||
} from '@dukang/domain';
|
||||
import { loadAppConfig, ClientApp, WECHAT_AUTH_REQUIRED } from '@dukang/shared-types';
|
||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||
@@ -155,6 +156,19 @@ export class TradeService {
|
||||
addressMessage = '该规格不支持跨城配送,请更换为开城城市内的收货地址';
|
||||
}
|
||||
}
|
||||
|
||||
if (addressOk && body.addressId) {
|
||||
const address = await this.prisma.userAddress.findFirst({
|
||||
where: { id: BigInt(body.addressId), userId },
|
||||
});
|
||||
if (address) {
|
||||
const shipping = validateShippingAddress(address);
|
||||
if (!shipping.ok) {
|
||||
addressOk = false;
|
||||
addressMessage = shipping.message || '请完善收货地址(需具体区县)';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bottlesPerUnit = sale.bottlesPerUnit > 0 ? sale.bottlesPerUnit : 1;
|
||||
@@ -276,6 +290,10 @@ export class TradeService {
|
||||
where: { id: BigInt(body.addressId), userId },
|
||||
});
|
||||
if (!address) throw new BadRequestException('请选择收货地址');
|
||||
const shipping = validateShippingAddress(address);
|
||||
if (!shipping.ok) {
|
||||
throw new BadRequestException(shipping.message || '请完善收货地址(需具体区县)');
|
||||
}
|
||||
receiverName = address.receiverName;
|
||||
receiverPhone = address.phone;
|
||||
receiverAddress = `${address.province}${address.city}${address.district}${address.detail}`;
|
||||
@@ -1866,6 +1884,15 @@ export class TradeService {
|
||||
if (!body.addressDetail?.trim()) {
|
||||
throw new BadRequestException('请填写详细地址');
|
||||
}
|
||||
const shipping = validateShippingAddress({
|
||||
province: receiverProvince,
|
||||
city: receiverCity,
|
||||
district: receiverDistrict,
|
||||
detail: body.addressDetail,
|
||||
});
|
||||
if (!shipping.ok) {
|
||||
throw new BadRequestException(shipping.message || '请完善收货地址(需具体区县)');
|
||||
}
|
||||
receiverAddress = `${receiverProvince}${receiverCity}${receiverDistrict}${body.addressDetail.trim()}`;
|
||||
}
|
||||
|
||||
@@ -2281,6 +2308,15 @@ export class TradeService {
|
||||
if (!body.addressDetail?.trim()) {
|
||||
throw new BadRequestException('请填写详细地址');
|
||||
}
|
||||
const shipping = validateShippingAddress({
|
||||
province: receiverProvince,
|
||||
city: receiverCity,
|
||||
district: receiverDistrict,
|
||||
detail: body.addressDetail,
|
||||
});
|
||||
if (!shipping.ok) {
|
||||
throw new BadRequestException(shipping.message || '请完善收货地址(需具体区县)');
|
||||
}
|
||||
receiverAddress = `${receiverProvince}${receiverCity}${receiverDistrict}${body.addressDetail.trim()}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user