@@ -75,7 +75,6 @@ export class TradeService {
|
||||
city.localMinQty,
|
||||
city.crossMinQty,
|
||||
);
|
||||
if (!check.ok) throw new BadRequestException(check.message);
|
||||
|
||||
const unitPrice = Number(product.price);
|
||||
const productAmount = unitPrice * body.quantity;
|
||||
@@ -96,6 +95,10 @@ export class TradeService {
|
||||
payAmount: productAmount,
|
||||
benefitAmount: benefitPerUnit * body.quantity,
|
||||
city: serializeBigInt(city),
|
||||
/** 起购未满足时仍返回预览,供确认页改数量;下单接口仍会硬校验 */
|
||||
quantityOk: check.ok,
|
||||
quantityMessage: check.ok ? null : (check.message ?? null),
|
||||
minQty: deliveryType === 'LOCAL' ? city.localMinQty : city.crossMinQty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -110,6 +113,9 @@ export class TradeService {
|
||||
req: Request,
|
||||
) {
|
||||
const preview = await this.preview(userId, body);
|
||||
if (preview.quantityOk === false) {
|
||||
throw new BadRequestException(preview.quantityMessage || '购买数量不满足起购要求');
|
||||
}
|
||||
const address = await this.prisma.userAddress.findFirst({
|
||||
where: { id: BigInt(body.addressId), userId },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user