增加现场提货的配置
This commit is contained in:
@@ -143,6 +143,7 @@ export class AdminCitiesService {
|
||||
...(dto.name !== undefined ? { name: dto.name } : {}),
|
||||
...(dto.province !== undefined ? { province: dto.province } : {}),
|
||||
...(dto.status !== undefined ? { status: dto.status as 'PENDING' | 'ACTIVE' | 'PAUSED' } : {}),
|
||||
...(dto.pickupMinQty !== undefined ? { pickupMinQty: dto.pickupMinQty } : {}),
|
||||
...(dto.localMinQty !== undefined ? { localMinQty: dto.localMinQty } : {}),
|
||||
...(dto.crossMinQty !== undefined ? { crossMinQty: dto.crossMinQty } : {}),
|
||||
...(dto.maxPartnerCommissionRate !== undefined
|
||||
|
||||
@@ -554,9 +554,18 @@ export class UpdateCityDto {
|
||||
status?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(1)
|
||||
pickupMinQty?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(1)
|
||||
localMinQty?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(1)
|
||||
crossMinQty?: number;
|
||||
|
||||
@IsOptional()
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user