@pisell/pisellos 2.2.308 → 2.2.309
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +118 -59
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.js +6 -4
- package/dist/modules/Rules/index.js +4 -2
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +71 -11
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.js +3 -2
- package/lib/modules/Rules/index.js +4 -2
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/package.json +1 -1
|
@@ -211,7 +211,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
211
211
|
// 识别出来是不是在编辑的界面里又新增了商品
|
|
212
212
|
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
213
213
|
const isEditModeAddNewProduct = productList.find(n => n.booking_id) && productList.find(n => !n.booking_id);
|
|
214
|
-
const
|
|
214
|
+
const reapplyWeighedDiscountProductUids = new Set((options?.reapplyWeighedDiscountProductUids || []).map(String));
|
|
215
|
+
const reapplyBookingDiscountProductUids = new Set([...(options?.reapplyBookingDiscountProductUids || []), ...reapplyWeighedDiscountProductUids].filter(uid => uid !== undefined && uid !== null && uid !== '').map(String));
|
|
215
216
|
const getOriginProductUid = originProduct => {
|
|
216
217
|
const uid = originProduct?.metadata?.unique_identification_number ?? originProduct?.unique_identification_number;
|
|
217
218
|
if (uid === undefined || uid === null || uid === '') return undefined;
|
|
@@ -915,7 +916,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
915
916
|
});
|
|
916
917
|
|
|
917
918
|
// 已持久化且已有钱包券/折扣卡的商品行跳过,保留后端历史折扣结果。
|
|
918
|
-
|
|
919
|
+
const isReweighedProduct = reapplyWeighedDiscountProductUids.has(getOriginProductUid(originProduct) || '');
|
|
920
|
+
if (isPersistedProduct && hasExistingWalletDiscount && !isReweighedProduct) {
|
|
919
921
|
if (flatItem.type === 'main') {
|
|
920
922
|
processedProductsMap.set(product._id, [originProduct]);
|
|
921
923
|
}
|
|
@@ -31,6 +31,8 @@ export interface RulesCalcDiscountOptions {
|
|
|
31
31
|
scan?: boolean;
|
|
32
32
|
/** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
|
|
33
33
|
reapplyBookingDiscountProductUids?: string[];
|
|
34
|
+
/** Reweighed order lines only: reapply selected wallet discounts against their new amount. */
|
|
35
|
+
reapplyWeighedDiscountProductUids?: string[];
|
|
34
36
|
}
|
|
35
37
|
export interface RulesModuleAPI {
|
|
36
38
|
setRulesList: (rulesList: Rules[]) => Promise<void>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformBaseProductToOrderProduct = transformBaseProductToOrderProduct;
|
|
7
|
+
var _weighedProduct = require("../../../modules/Order/utils/weighedProduct");
|
|
7
8
|
var _utils = require("../../../modules/Order/utils");
|
|
8
9
|
var _manualProductDiscount = require("../../../modules/Order/utils/manualProductDiscount");
|
|
9
10
|
function toNumber(value, fallback = 0) {
|
|
@@ -65,11 +66,11 @@ function appendDataVariantIds(base, ...values) {
|
|
|
65
66
|
}
|
|
66
67
|
return Array.isArray(base) || result.length ? result : undefined;
|
|
67
68
|
}
|
|
68
|
-
function normalizeOptionItems(optionItems) {
|
|
69
|
+
function normalizeOptionItems(optionItems, useOriginalPrice = false) {
|
|
69
70
|
if (!Array.isArray(optionItems)) return [];
|
|
70
71
|
return optionItems.map(optionItem => {
|
|
71
72
|
const optionGroupItemId = toNumber(optionItem?.option_group_item_id ?? optionItem?.id);
|
|
72
|
-
const price = optionItem?.price ?? optionItem?.add_price ?? 0;
|
|
73
|
+
const price = (useOriginalPrice ? optionItem?.original_price : undefined) ?? optionItem?.price ?? optionItem?.add_price ?? 0;
|
|
73
74
|
return {
|
|
74
75
|
...optionItem,
|
|
75
76
|
option_group_item_id: optionGroupItemId,
|
|
@@ -80,10 +81,12 @@ function normalizeOptionItems(optionItems) {
|
|
|
80
81
|
};
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
84
|
+
function normalizeBundleItems(bundleItems, preferPriceField = false, preferBundleSellingPrice = false) {
|
|
84
85
|
if (!Array.isArray(bundleItems)) return [];
|
|
85
86
|
return bundleItems.map(bundleItem => {
|
|
86
|
-
|
|
87
|
+
// Weighed manual prices distribute the bundle base and nested options separately.
|
|
88
|
+
// Its explicit selling amount already includes those options.
|
|
89
|
+
const unitSelling = preferPriceField && !preferBundleSellingPrice ? bundleItem.price ?? bundleItem.bundle_selling_price ?? bundleItem.custom_price ?? bundleItem.product_price ?? '0' : bundleItem.bundle_selling_price ?? bundleItem.price ?? bundleItem.custom_price ?? bundleItem.product_price ?? '0';
|
|
87
90
|
const unitStr = toPriceString(unitSelling, '0.00');
|
|
88
91
|
const num = toSafePositiveInt(bundleItem?.num ?? bundleItem?.quantity, 1);
|
|
89
92
|
const magnitudeSource = {
|
|
@@ -147,19 +150,25 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
147
150
|
const productionCode = normalizeProductionCode(Object.prototype.hasOwnProperty.call(payload, 'production_code') ? payload.production_code : productVariantId > 0 ? matchedVariant?.production_code : origin?.production_code ?? sourceProduct?.production_code);
|
|
148
151
|
const hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
|
|
149
152
|
// 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
|
|
150
|
-
//
|
|
153
|
+
// 称重商品使用改价前净重金额;其它商品从商品/variant 快照读取目录价。
|
|
154
|
+
// 售价仍由 line_total - bundle 推导。
|
|
151
155
|
const catalogSourcePrice = matchedVariant?.price ?? matchedVariant?.base_price ?? origin?.price ?? origin?.base_price ?? sourceProduct?.price ?? sourceProduct?.selling_price ?? sourceProduct?.base_price;
|
|
152
|
-
const
|
|
156
|
+
const weighedSourcePrice = (0, _weighedProduct.resolveWeighedSourcePrice)(payload.product_sku ?? origin.product_sku, payload._extend?.weighing ?? origin._extend?.weighing);
|
|
157
|
+
const sourceProductPrice = toPriceString(weighedSourcePrice ?? (hasPriceOverride ? catalogSourcePrice ?? payload.price ?? payload.selling_price : payload.price ?? payload.selling_price ?? catalogSourcePrice), '0.00');
|
|
153
158
|
const explicitLineTotal = payload.line_total ?? payload.total ?? payload._extend?.total;
|
|
154
159
|
const hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
155
160
|
const lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
156
|
-
const productOptionItem = (0, _utils.normalizeProductSkuOptions)(normalizeOptionItems(payload.product_sku?.option ?? payload.option ?? payload.options ?? payload.product_option_item));
|
|
157
|
-
const productBundle = normalizeBundleItems(payload.bundle ?? payload.product_bundle, hasPriceOverride);
|
|
161
|
+
const productOptionItem = (0, _utils.normalizeProductSkuOptions)(normalizeOptionItems(payload.product_sku?.option ?? payload.option ?? payload.options ?? payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
|
|
162
|
+
const productBundle = normalizeBundleItems(payload.bundle ?? payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
|
|
158
163
|
// `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
|
|
159
164
|
// 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
|
|
160
165
|
const uniqueIdentificationNumber = payload.unique_identification_number;
|
|
161
166
|
const resolvedQuantity = toSafePositiveInt(payload.quantity ?? payload.num, 1);
|
|
162
|
-
const originTotal = (0,
|
|
167
|
+
const originTotal = weighedSourcePrice !== undefined ? Number((0, _utils.composeLinePrice)({
|
|
168
|
+
mainPrice: Number(weighedSourcePrice) + (0, _utils.sumOptionUnitPrice)(productOptionItem).toNumber(),
|
|
169
|
+
bundle: hasPriceOverride ? (0, _weighedProduct.withOriginalBundleOptionPrices)(productBundle) : productBundle,
|
|
170
|
+
useOriginalBundle: true
|
|
171
|
+
})) : (0, _manualProductDiscount.resolveManualDiscountOriginTotal)({
|
|
163
172
|
originTotal: payload.origin_total,
|
|
164
173
|
extendOriginTotal: payload._extend?.origin_total,
|
|
165
174
|
originExtendOriginTotal: origin?._extend?.origin_total,
|
|
@@ -260,6 +269,12 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
260
269
|
product_cover: firstNonBlank(matchedVariant?.cover, sourceProduct?.cover),
|
|
261
270
|
_origin: {
|
|
262
271
|
...(sourceProduct || {}),
|
|
272
|
+
...(weighedSourcePrice !== undefined && hasPriceOverride ? {
|
|
273
|
+
_extend: {
|
|
274
|
+
...sourceProduct?._extend,
|
|
275
|
+
origin_total: originTotal
|
|
276
|
+
}
|
|
277
|
+
} : {}),
|
|
263
278
|
callbackData: payload
|
|
264
279
|
}
|
|
265
280
|
};
|
|
@@ -8,6 +8,7 @@ exports.createEmptySummary = createEmptySummary;
|
|
|
8
8
|
exports.getSafeProductNum = getSafeProductNum;
|
|
9
9
|
exports.isSkuOnlyDeleteIdentity = isSkuOnlyDeleteIdentity;
|
|
10
10
|
exports.normalizeOrderProduct = normalizeOrderProduct;
|
|
11
|
+
var _weighedProduct = require("../../modules/Order/utils/weighedProduct");
|
|
11
12
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
12
13
|
var _utils = require("../../modules/Order/utils");
|
|
13
14
|
var _manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
|
|
@@ -237,7 +238,7 @@ function normalizeOrderProduct(product) {
|
|
|
237
238
|
});
|
|
238
239
|
const composedOriginalPrice = (0, _utils.composeLinePrice)({
|
|
239
240
|
mainPrice: mainOriginalStr,
|
|
240
|
-
bundle: normalizedBundle,
|
|
241
|
+
bundle: Number(productSku.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadata) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(normalizedBundle) : normalizedBundle,
|
|
241
242
|
useOriginalBundle: true
|
|
242
243
|
});
|
|
243
244
|
const finalOriginalPrice = (0, _utils.resolveManualOverrideLineOriginalPrice)({
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 2 | 1 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -339,7 +339,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
339
339
|
* 获取当前的客户搜索条件
|
|
340
340
|
* @returns 当前搜索条件
|
|
341
341
|
*/
|
|
342
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
342
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
343
343
|
/**
|
|
344
344
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
345
345
|
* @returns 客户状态
|
|
@@ -34,6 +34,7 @@ exports.toNonNegativeInt = toNonNegativeInt;
|
|
|
34
34
|
exports.toNonNegativeNumber = toNonNegativeNumber;
|
|
35
35
|
exports.toPositiveString = toPositiveString;
|
|
36
36
|
exports.toPriceString = toPriceString;
|
|
37
|
+
var _weighedProduct = require("../../modules/Order/utils/weighedProduct");
|
|
37
38
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
38
39
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
39
40
|
var _utils = require("../../modules/Order/utils");
|
|
@@ -612,7 +613,7 @@ function normalizeOrderProduct(product) {
|
|
|
612
613
|
});
|
|
613
614
|
const composedOriginalPrice = (0, _utils.composeLinePrice)({
|
|
614
615
|
mainPrice: mainOriginalStr,
|
|
615
|
-
bundle: normalizedBundle,
|
|
616
|
+
bundle: Number(productSku.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadata) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(normalizedBundle) : normalizedBundle,
|
|
616
617
|
useOriginalBundle: true
|
|
617
618
|
});
|
|
618
619
|
const finalOriginalPrice = (0, _utils.resolveManualOverrideLineOriginalPrice)({
|