增加现场提货的配置

This commit is contained in:
2026-08-26 09:22:29 +08:00
parent c7cd0f6cf2
commit 632539e8dc
28 changed files with 393 additions and 105 deletions
@@ -10,6 +10,7 @@ import type { FreightPayType } from '@prisma/client';
import {
calcBenefitAmount,
generateOrderNo,
minBottleQtyForDelivery,
orderTabToStatuses,
toMinSaleQuantity,
validateMinPurchase,
@@ -157,11 +158,15 @@ export class TradeService {
}
const bottlesPerUnit = sale.bottlesPerUnit > 0 ? sale.bottlesPerUnit : 1;
const mins = {
pickupMinQty: city.pickupMinQty,
localMinQty: city.localMinQty,
crossMinQty: city.crossMinQty,
};
const check = validateMinPurchase(
deliveryType,
body.quantity,
city.localMinQty,
city.crossMinQty,
mins,
{ bottlesPerUnit, saleUnit: sale.saleUnit },
);
@@ -173,12 +178,7 @@ export class TradeService {
});
const freightPayType: FreightPayType | null = deliveryType === 'CROSS_CITY' ? 'COD' : null;
const minBottleQty =
deliveryType === 'ON_SITE_PICKUP'
? city.localMinQty
: deliveryType === 'LOCAL'
? city.localMinQty
: city.crossMinQty;
const minBottleQty = minBottleQtyForDelivery(deliveryType, mins);
const minQty = toMinSaleQuantity(minBottleQty, bottlesPerUnit);
return {
@@ -1666,11 +1666,15 @@ export class TradeService {
}
const bottlesPerUnit = sale.bottlesPerUnit > 0 ? sale.bottlesPerUnit : 1;
const mins = {
pickupMinQty: city.pickupMinQty,
localMinQty: city.localMinQty,
crossMinQty: city.crossMinQty,
};
const check = validateMinPurchase(
deliveryType === 'CROSS_CITY' ? 'CROSS_CITY' : deliveryType === 'ON_SITE_PICKUP' ? 'ON_SITE_PICKUP' : 'LOCAL',
body.quantity,
city.localMinQty,
city.crossMinQty,
mins,
{ bottlesPerUnit, saleUnit: sale.saleUnit },
);
if (!check.ok) throw new BadRequestException(check.message);
@@ -1695,7 +1699,7 @@ export class TradeService {
bottlesPerUnit,
bottleQuantity: body.quantity * bottlesPerUnit,
minQuantity: toMinSaleQuantity(
deliveryType === 'CROSS_CITY' ? city.crossMinQty : city.localMinQty,
minBottleQtyForDelivery(deliveryType, mins),
bottlesPerUnit,
),
};