@pisell/pisellos 2.2.266 → 2.2.268
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/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/Order/index.d.ts +13 -32
- package/dist/modules/Order/index.js +562 -778
- package/dist/modules/Order/types.d.ts +22 -36
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +50 -79
- package/dist/modules/Payment/types.d.ts +27 -29
- package/dist/modules/Payment/types.js +3 -5
- package/dist/modules/Rules/index.d.ts +0 -1
- package/dist/modules/Rules/index.js +14 -34
- package/dist/server/index.d.ts +0 -16
- package/dist/server/index.js +1036 -1933
- package/dist/server/modules/order/index.d.ts +4 -49
- package/dist/server/modules/order/index.js +695 -1574
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +14 -58
- package/dist/solution/BaseSales/index.js +398 -713
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +29 -35
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.js +19 -30
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Order/index.d.ts +13 -32
- package/lib/modules/Order/index.js +142 -201
- package/lib/modules/Order/types.d.ts +22 -36
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +13 -34
- package/lib/modules/Payment/types.d.ts +27 -29
- package/lib/modules/Payment/types.js +3 -3
- package/lib/modules/Rules/index.d.ts +0 -1
- package/lib/modules/Rules/index.js +4 -23
- package/lib/server/index.d.ts +0 -16
- package/lib/server/index.js +18 -670
- package/lib/server/modules/order/index.d.ts +4 -49
- package/lib/server/modules/order/index.js +66 -657
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +14 -58
- package/lib/solution/BaseSales/index.js +41 -241
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +3 -6
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.js +0 -8
- package/package.json +2 -2
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -77,43 +77,19 @@ function getOrderProductOriginalPriceForPromotion(product) {
|
|
|
77
77
|
}
|
|
78
78
|
return getOrderProductBasePrice(product);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
var ITEM_REWARD = "ITEM_REWARD";
|
|
82
|
-
function isItemRewardPromotionDiscountItem(item) {
|
|
83
|
-
var _a, _b;
|
|
84
|
-
return (item == null ? void 0 : item.type) === "product" && ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === ITEM_REWARD;
|
|
85
|
-
}
|
|
86
|
-
function isManagedPromotionDiscountItem(item) {
|
|
87
|
-
if ((item == null ? void 0 : item.type) === "promotion")
|
|
88
|
-
return true;
|
|
89
|
-
return isItemRewardPromotionDiscountItem(item);
|
|
90
|
-
}
|
|
91
|
-
function wasInPromotionBeforeEvaluation(item) {
|
|
92
|
-
var _a, _b;
|
|
93
|
-
if (((_b = (_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a._promotion) == null ? void 0 : _b.inPromotion) === true)
|
|
94
|
-
return true;
|
|
95
|
-
return Array.isArray(item == null ? void 0 : item.discount_list) && item.discount_list.some(isItemRewardPromotionDiscountItem);
|
|
96
|
-
}
|
|
97
|
-
function updatePromotionDiscountList(item, promotionDiscount, options) {
|
|
80
|
+
function updatePromotionDiscountList(item, promotionDiscount) {
|
|
98
81
|
let discountList = Array.isArray(item.discount_list) ? [...item.discount_list] : [];
|
|
99
|
-
discountList = discountList.filter((d) =>
|
|
82
|
+
discountList = discountList.filter((d) => (d == null ? void 0 : d.type) !== "promotion");
|
|
100
83
|
if (promotionDiscount) {
|
|
101
|
-
const discountType = (options == null ? void 0 : options.discountType) || "promotion";
|
|
102
84
|
discountList.push({
|
|
103
|
-
type:
|
|
85
|
+
type: "promotion",
|
|
104
86
|
amount: promotionDiscount.amount,
|
|
105
87
|
discount: {
|
|
106
88
|
original_amount: promotionDiscount.original_amount,
|
|
107
89
|
fixed_amount: promotionDiscount.fixed_amount,
|
|
108
90
|
title: promotionDiscount.title,
|
|
109
91
|
resource_id: ""
|
|
110
|
-
}
|
|
111
|
-
...discountType === "product" ? {
|
|
112
|
-
metadata: {
|
|
113
|
-
source: "promotion",
|
|
114
|
-
actionType: (options == null ? void 0 : options.actionType) || ITEM_REWARD
|
|
115
|
-
}
|
|
116
|
-
} : {}
|
|
92
|
+
}
|
|
117
93
|
});
|
|
118
94
|
}
|
|
119
95
|
if (discountList.length > 0) {
|
|
@@ -122,15 +98,7 @@ function updatePromotionDiscountList(item, promotionDiscount, options) {
|
|
|
122
98
|
delete item.discount_list;
|
|
123
99
|
}
|
|
124
100
|
}
|
|
125
|
-
|
|
126
|
-
var _a;
|
|
127
|
-
const configs = (_a = evaluator == null ? void 0 : evaluator.getStrategyConfigs) == null ? void 0 : _a.call(evaluator);
|
|
128
|
-
if (!Array.isArray(configs))
|
|
129
|
-
return false;
|
|
130
|
-
return configs.some(
|
|
131
|
-
(config) => ((config == null ? void 0 : config.actions) || []).some((action) => (action == null ? void 0 : action.type) === actionType)
|
|
132
|
-
);
|
|
133
|
-
}
|
|
101
|
+
var X_ITEMS_FOR_Y_PRICE = "X_ITEMS_FOR_Y_PRICE";
|
|
134
102
|
function applyPromoUnitPriceToLine(item, input) {
|
|
135
103
|
const metadata = item.metadata || (item.metadata = {});
|
|
136
104
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(item)).toNumber();
|
|
@@ -157,9 +125,6 @@ function applyPromoUnitPriceToLine(item, input) {
|
|
|
157
125
|
amount: discountAmount,
|
|
158
126
|
original_amount: catalogSource,
|
|
159
127
|
fixed_amount: discountAmount
|
|
160
|
-
}, {
|
|
161
|
-
actionType: input.actionType,
|
|
162
|
-
discountType: input.actionType === ITEM_REWARD ? "product" : "promotion"
|
|
163
128
|
});
|
|
164
129
|
} else {
|
|
165
130
|
updatePromotionDiscountList(item, null);
|
|
@@ -367,8 +332,11 @@ function getProductLineNoteSignature(product) {
|
|
|
367
332
|
return uid ? `note:${uid}` : `note:${normalizedNote}`;
|
|
368
333
|
}
|
|
369
334
|
function getPromotionLineMergeBoundary(product) {
|
|
370
|
-
var _a;
|
|
371
|
-
if (((_a = product == null ? void 0 : product.
|
|
335
|
+
var _a, _b;
|
|
336
|
+
if (Number(((_a = product == null ? void 0 : product.product_sku) == null ? void 0 : _a.open_sold_weight) || 0) === 1) {
|
|
337
|
+
return `weighing:${getOrderProductUid(product)}`;
|
|
338
|
+
}
|
|
339
|
+
if (((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.is_edit_for_runtime) !== true)
|
|
372
340
|
return "";
|
|
373
341
|
return `edit:${getOrderProductUid(product)}`;
|
|
374
342
|
}
|
|
@@ -431,13 +399,14 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
431
399
|
].join("#");
|
|
432
400
|
}
|
|
433
401
|
function consolidateMainProductsForPromotion(entries) {
|
|
402
|
+
var _a, _b;
|
|
434
403
|
if (!Array.isArray(entries) || entries.length <= 1) {
|
|
435
404
|
return [...entries || []];
|
|
436
405
|
}
|
|
437
406
|
const groups = /* @__PURE__ */ new Map();
|
|
438
407
|
for (const { item, originalListIndex } of entries) {
|
|
439
408
|
const key = buildConsolidateKeyForPromotion(item);
|
|
440
|
-
const wasInPromotion =
|
|
409
|
+
const wasInPromotion = ((_b = (_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a._promotion) == null ? void 0 : _b.inPromotion) === true;
|
|
441
410
|
const existing = groups.get(key);
|
|
442
411
|
if (!existing) {
|
|
443
412
|
const mergedItem = (0, import_lodash_es.cloneDeep)(item);
|
|
@@ -503,9 +472,6 @@ function splitXItemsPromoLinesByGroup(lines, strategyActionMap) {
|
|
|
503
472
|
function generateNumericId() {
|
|
504
473
|
return Math.floor(Math.random() * 1e9) + Date.now();
|
|
505
474
|
}
|
|
506
|
-
function isBookingEditProductLine(product) {
|
|
507
|
-
return (product == null ? void 0 : product.booking_id) !== void 0 && (product == null ? void 0 : product.booking_id) !== null && product.booking_id !== 0 && product.booking_id !== "0";
|
|
508
|
-
}
|
|
509
475
|
function convertToPromotionProduct(product, index) {
|
|
510
476
|
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
511
477
|
const numericId = generateNumericId();
|
|
@@ -518,7 +484,6 @@ function convertToPromotionProduct(product, index) {
|
|
|
518
484
|
price: getOrderProductOriginalPriceForPromotion(product),
|
|
519
485
|
quantity: Number((product == null ? void 0 : product.num) ?? 1) || 1,
|
|
520
486
|
bundle: getProductBundleForEvaluator(product),
|
|
521
|
-
_promotionOnlyForItemReward: isBookingEditProductLine(product),
|
|
522
487
|
_originalItem: originalItem,
|
|
523
488
|
_originalId: getOrderProductUid(product),
|
|
524
489
|
_originalIndex: index
|
|
@@ -620,9 +585,6 @@ function resolveStrategyRequiredQuantity(matched) {
|
|
|
620
585
|
if (matched.actionType === "BUY_X_GET_Y_FREE") {
|
|
621
586
|
return Number(detail.buyQuantity) || 1;
|
|
622
587
|
}
|
|
623
|
-
if (matched.actionType === "ITEM_REWARD") {
|
|
624
|
-
return Number(detail.triggerQuantity) || 1;
|
|
625
|
-
}
|
|
626
588
|
return 1;
|
|
627
589
|
}
|
|
628
590
|
function resolveStrategyEligibleProducts(matched) {
|
|
@@ -733,10 +695,6 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
733
695
|
};
|
|
734
696
|
if (!list || list.length === 0 || !evaluator)
|
|
735
697
|
return empty;
|
|
736
|
-
const shouldIncludeEditProductsForItemReward = evaluatorHasActionType(
|
|
737
|
-
evaluator,
|
|
738
|
-
ITEM_REWARD
|
|
739
|
-
);
|
|
740
698
|
const mainProductsWithIndex = [];
|
|
741
699
|
const existingGiftsWithIndex = [];
|
|
742
700
|
const editProductsWithIndex = [];
|
|
@@ -747,12 +705,8 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
747
705
|
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
748
706
|
} else if (giftInfo) {
|
|
749
707
|
existingGiftsWithIndex.push({ item, originalListIndex: i });
|
|
750
|
-
} else if (
|
|
751
|
-
|
|
752
|
-
mainProductsWithIndex.push({ item, originalListIndex: i });
|
|
753
|
-
} else {
|
|
754
|
-
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
755
|
-
}
|
|
708
|
+
} else if ((item == null ? void 0 : item.booking_id) !== void 0 && (item == null ? void 0 : item.booking_id) !== null && item.booking_id !== 0 && item.booking_id !== "0") {
|
|
709
|
+
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
756
710
|
} else {
|
|
757
711
|
mainProductsWithIndex.push({ item, originalListIndex: i });
|
|
758
712
|
}
|
|
@@ -795,8 +749,7 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
795
749
|
name: ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.product_name) || (item == null ? void 0 : item.title) || "",
|
|
796
750
|
price: getOrderProductBasePrice(item),
|
|
797
751
|
quantity: Number((item == null ? void 0 : item.num) ?? 1) || 1,
|
|
798
|
-
bundle: getProductBundleForEvaluator(item)
|
|
799
|
-
_promotionOnlyForItemReward: isBookingEditProductLine(item)
|
|
752
|
+
bundle: getProductBundleForEvaluator(item)
|
|
800
753
|
};
|
|
801
754
|
});
|
|
802
755
|
for (let i = 0; i < consolidatedMainProductsWithIndex.length; i++) {
|
|
@@ -865,7 +818,7 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
865
818
|
const metadata = newItem.metadata || {};
|
|
866
819
|
const sourceCartNum = (0, import_utils2.getSafeProductNum)(originalItem.num);
|
|
867
820
|
newItem._sourceCartNum = sourceCartNum;
|
|
868
|
-
const wasInPromotion =
|
|
821
|
+
const wasInPromotion = ((_a = metadata._promotion) == null ? void 0 : _a.inPromotion) === true || originalItem._wasInPromotionBeforeConsolidate === true;
|
|
869
822
|
delete metadata._promotion;
|
|
870
823
|
if (Array.isArray(newItem.product_bundle)) {
|
|
871
824
|
for (const b of newItem.product_bundle) {
|
|
@@ -882,8 +835,7 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
882
835
|
applyPromoUnitPriceToLine(newItem, {
|
|
883
836
|
promoUnitPrice,
|
|
884
837
|
originalBasePrice,
|
|
885
|
-
strategyTitle: (
|
|
886
|
-
actionType: priced.strategyId ? (_b = strategyActionMap.get(priced.strategyId)) == null ? void 0 : _b.actionType : void 0
|
|
838
|
+
strategyTitle: (_b = priced.strategyMetadata) == null ? void 0 : _b.name
|
|
887
839
|
});
|
|
888
840
|
} else {
|
|
889
841
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(newItem)).toNumber();
|
|
@@ -82,13 +82,8 @@ export interface ISalesBooking {
|
|
|
82
82
|
metadata?: Record<string, any> | null;
|
|
83
83
|
[key: string]: any;
|
|
84
84
|
}
|
|
85
|
-
export interface ISalesPaymentMetadata extends Record<string, any> {
|
|
86
|
-
/** 刷卡机设备快照;OS 不解析内部字段 */
|
|
87
|
-
card_reader_snapshot?: Record<string, unknown>;
|
|
88
|
-
}
|
|
89
85
|
export interface ISalesPayment {
|
|
90
86
|
order_payment_id?: number | null;
|
|
91
|
-
payment_number?: string;
|
|
92
87
|
custom_payment_id?: number;
|
|
93
88
|
code?: string;
|
|
94
89
|
name?: string;
|
|
@@ -100,7 +95,7 @@ export interface ISalesPayment {
|
|
|
100
95
|
status?: string;
|
|
101
96
|
payment_time?: string | null;
|
|
102
97
|
service_charge?: Record<string, any> | null;
|
|
103
|
-
metadata?:
|
|
98
|
+
metadata?: Record<string, any> | null;
|
|
104
99
|
[key: string]: any;
|
|
105
100
|
}
|
|
106
101
|
export interface ISalesSurcharge {
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -233,7 +233,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
233
233
|
return String(this.getAppData("device_id") || 0).slice(-2);
|
|
234
234
|
}
|
|
235
235
|
async configureIdGeneratorFromOpenData() {
|
|
236
|
-
this.setPaymentNumberDevicePrefix(null);
|
|
237
236
|
let openDataConfig = null;
|
|
238
237
|
try {
|
|
239
238
|
openDataConfig = await this.loadOpenDataConfig();
|
|
@@ -265,7 +264,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
265
264
|
const resetReceiptSequenceDaily = typeof (openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"]) === "boolean" ? openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"] : false;
|
|
266
265
|
const operatingDayBoundary = this.getAppData("operating_day_boundary");
|
|
267
266
|
const deviceId = await this.getShortNumberOrDeviceId();
|
|
268
|
-
this.setPaymentNumberDevicePrefix(deviceId);
|
|
269
267
|
const businessCode = this.getBookingTicketBusinessCode();
|
|
270
268
|
if (!businessCode) {
|
|
271
269
|
console.warn("[BookingTicket] businessCode 缺失,跳过 idGenerator 配置");
|
|
@@ -1155,8 +1153,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1155
1153
|
}
|
|
1156
1154
|
/** 读取当前 booking config。 */
|
|
1157
1155
|
getBookingConfig() {
|
|
1158
|
-
|
|
1159
|
-
return (_a = this.store.bookingContext) == null ? void 0 : _a.getBookingConfig();
|
|
1156
|
+
return this.store.bookingContext.getBookingConfig();
|
|
1160
1157
|
}
|
|
1161
1158
|
/** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
|
|
1162
1159
|
setResources(resources) {
|
|
@@ -1529,8 +1526,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1529
1526
|
return result;
|
|
1530
1527
|
}
|
|
1531
1528
|
async setOtherParams(params, { cover = false } = {}) {
|
|
1532
|
-
|
|
1533
|
-
if (
|
|
1529
|
+
super.setOtherParams(params, { cover });
|
|
1530
|
+
if (params == null ? void 0 : params.businessCode) {
|
|
1534
1531
|
await this.configureIdGeneratorFromOpenData();
|
|
1535
1532
|
}
|
|
1536
1533
|
}
|
|
@@ -118,12 +118,15 @@ export interface BookingTicketCartBookingView extends ISalesBooking {
|
|
|
118
118
|
canAddTime: boolean;
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
+
export type BookingTicketCartLineView = BookingTicketCartBookingView | BookingTicketCartItemView;
|
|
121
122
|
/**
|
|
122
123
|
* BookingTicket 面向 UI 的购物车视图。
|
|
123
124
|
*/
|
|
124
125
|
export interface BookingTicketCartView {
|
|
125
126
|
bookings: BookingTicketCartBookingView[];
|
|
126
127
|
items: BookingTicketCartItemView[];
|
|
128
|
+
/** 以 tempOrder.products 为唯一顺序真源的统一购物车行(旧到新)。 */
|
|
129
|
+
lines: BookingTicketCartLineView[];
|
|
127
130
|
}
|
|
128
131
|
/**
|
|
129
132
|
* BookingTicket 面向 UI 的客户展示视图。
|
|
@@ -44,6 +44,7 @@ module.exports = __toCommonJS(addProductDecision_exports);
|
|
|
44
44
|
var import_dayjs = __toESM(require("dayjs"));
|
|
45
45
|
var import_BookingContext = require("../../../modules/BookingContext");
|
|
46
46
|
var import_transformBaseProductToOrderProduct = require("../../BaseSales/utils/transformBaseProductToOrderProduct");
|
|
47
|
+
var import_weighingProductSku = require("./weighingProductSku");
|
|
47
48
|
function needsSpecDetailModal(item) {
|
|
48
49
|
if (item == null ? void 0 : item.open_sold_weight)
|
|
49
50
|
return true;
|
|
@@ -281,11 +282,14 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
|
|
|
281
282
|
const quantity = (ctx == null ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) ?? 1;
|
|
282
283
|
const resolvedPid = (cacheItem == null ? void 0 : cacheItem.product_id) ?? (cacheItem == null ? void 0 : cacheItem.id);
|
|
283
284
|
const extend = (cacheItem == null ? void 0 : cacheItem._extend) || {};
|
|
285
|
+
const productSku = (0, import_weighingProductSku.buildProductSkuFromCacheItem)(cacheItem);
|
|
284
286
|
return {
|
|
285
287
|
id: (cacheItem == null ? void 0 : cacheItem.id) ?? (cacheItem == null ? void 0 : cacheItem.product_id),
|
|
286
288
|
product_id: resolvedPid,
|
|
287
289
|
variant_id: (other == null ? void 0 : other.product_variant_id) ?? (other == null ? void 0 : other.variant_id) ?? 0,
|
|
288
290
|
quantity,
|
|
291
|
+
// 规格弹窗本次选择是 option 权威源,避免目录/旧订单里的空 option 覆盖它。
|
|
292
|
+
product_sku: productSku ? { ...productSku, option: (other == null ? void 0 : other.option) || [] } : void 0,
|
|
289
293
|
option: (other == null ? void 0 : other.option) || [],
|
|
290
294
|
bundle: (other == null ? void 0 : other.bundle) || ((_c = extend == null ? void 0 : extend.skuValue) == null ? void 0 : _c.bundle) || ((_d = extend == null ? void 0 : extend._skuValue) == null ? void 0 : _d.bundle) || [],
|
|
291
295
|
unique: other == null ? void 0 : other.unique,
|
|
@@ -86,29 +86,27 @@ function isGiftProductLine(line) {
|
|
|
86
86
|
function buildCartView(lines, bookings, options = {}) {
|
|
87
87
|
const productLines = Array.isArray(lines) ? lines : [];
|
|
88
88
|
const bookingList = Array.isArray(bookings) ? bookings : [];
|
|
89
|
+
const childBookings = bookingList.filter((booking) => booking.parent_id !== 0);
|
|
90
|
+
const bookingsByProductUid = indexBookingsByProductUid(childBookings);
|
|
89
91
|
const linesByUid = indexProductsByUid(productLines);
|
|
90
92
|
const addTimeLinesByBookingUid = indexAddTimeProductsByBookingUid(productLines);
|
|
91
|
-
const claimedUids = /* @__PURE__ */ new Set();
|
|
92
93
|
const claimedAddTimeLines = /* @__PURE__ */ new Set();
|
|
93
|
-
|
|
94
|
-
const
|
|
94
|
+
childBookings.forEach((booking) => {
|
|
95
|
+
const bookingUid = getBookingUid(booking);
|
|
96
|
+
if (!bookingUid)
|
|
97
|
+
return;
|
|
98
|
+
(addTimeLinesByBookingUid[bookingUid] || []).forEach((line) => {
|
|
99
|
+
claimedAddTimeLines.add(line);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
const claimedBookings = /* @__PURE__ */ new Set();
|
|
103
|
+
const cartBookings = [];
|
|
104
|
+
const items = [];
|
|
105
|
+
const orderedLines = [];
|
|
106
|
+
const buildBookingView = (booking, product) => {
|
|
95
107
|
const bookingUid = getBookingUid(booking);
|
|
96
|
-
let product = null;
|
|
97
|
-
if (uid !== void 0 && uid !== null && uid !== "") {
|
|
98
|
-
const key = String(uid);
|
|
99
|
-
if (!claimedUids.has(key)) {
|
|
100
|
-
const line = linesByUid[key];
|
|
101
|
-
if (isGiftProductLine(line))
|
|
102
|
-
return acc;
|
|
103
|
-
if (line) {
|
|
104
|
-
claimedUids.add(key);
|
|
105
|
-
product = line;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
108
|
const addTimeProduct = bookingUid ? addTimeLinesByBookingUid[bookingUid] || [] : [];
|
|
110
|
-
|
|
111
|
-
acc.push({
|
|
109
|
+
return {
|
|
112
110
|
...booking,
|
|
113
111
|
_extend: {
|
|
114
112
|
product,
|
|
@@ -122,21 +120,36 @@ function buildCartView(lines, bookings, options = {}) {
|
|
|
122
120
|
shopOpeningHours: options.shopOpeningHours
|
|
123
121
|
})
|
|
124
122
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const items = productLines.filter((line) => {
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
productLines.forEach((line) => {
|
|
129
126
|
var _a;
|
|
130
|
-
if (isGiftProductLine(line))
|
|
131
|
-
return
|
|
132
|
-
if (claimedAddTimeLines.has(line))
|
|
133
|
-
return false;
|
|
127
|
+
if (isGiftProductLine(line) || claimedAddTimeLines.has(line))
|
|
128
|
+
return;
|
|
134
129
|
const uid = (_a = line.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
const matchedBooking = uid === void 0 || uid === null || uid === "" ? void 0 : (bookingsByProductUid[String(uid)] || []).find(
|
|
131
|
+
(booking) => !claimedBookings.has(booking)
|
|
132
|
+
);
|
|
133
|
+
if (matchedBooking) {
|
|
134
|
+
claimedBookings.add(matchedBooking);
|
|
135
|
+
const bookingView = buildBookingView(matchedBooking, line);
|
|
136
|
+
cartBookings.push(bookingView);
|
|
137
|
+
orderedLines.push(bookingView);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
items.push(line);
|
|
141
|
+
orderedLines.push(line);
|
|
142
|
+
});
|
|
143
|
+
childBookings.forEach((booking) => {
|
|
144
|
+
if (claimedBookings.has(booking))
|
|
145
|
+
return;
|
|
146
|
+
const uid = booking == null ? void 0 : booking.product_uid;
|
|
147
|
+
const linkedProduct = uid === void 0 || uid === null || uid === "" ? null : linesByUid[String(uid)] || null;
|
|
148
|
+
if (isGiftProductLine(linkedProduct))
|
|
149
|
+
return;
|
|
150
|
+
cartBookings.push(buildBookingView(booking, null));
|
|
138
151
|
});
|
|
139
|
-
return { bookings: cartBookings, items };
|
|
152
|
+
return { bookings: cartBookings, items, lines: orderedLines };
|
|
140
153
|
}
|
|
141
154
|
function isWalkInCustomer(customer) {
|
|
142
155
|
if (!customer)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/solution/BookingTicket/utils/weighingProductSku.ts
|
|
20
|
+
var weighingProductSku_exports = {};
|
|
21
|
+
__export(weighingProductSku_exports, {
|
|
22
|
+
buildProductSkuFromCacheItem: () => buildProductSkuFromCacheItem
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(weighingProductSku_exports);
|
|
25
|
+
var WEIGHT_UNIT_MAP = {
|
|
26
|
+
KILOGRAMS: "kg",
|
|
27
|
+
GRAMS: "g",
|
|
28
|
+
POUNDS: "lb",
|
|
29
|
+
OUNCES: "oz"
|
|
30
|
+
};
|
|
31
|
+
function isRecord(value) {
|
|
32
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
function buildProductSkuFromCacheItem(cacheItem) {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
const currentSku = isRecord(cacheItem == null ? void 0 : cacheItem.product_sku) ? cacheItem.product_sku : void 0;
|
|
37
|
+
const weighing = isRecord((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.weighing) ? (_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.weighing : void 0;
|
|
38
|
+
const hasRuntimeWeighingSku = Number((currentSku == null ? void 0 : currentSku.open_sold_weight) || 0) === 1 && ((currentSku == null ? void 0 : currentSku.weight) !== void 0 || (currentSku == null ? void 0 : currentSku.net_weight) !== void 0 || (currentSku == null ? void 0 : currentSku.weight_source) !== void 0);
|
|
39
|
+
const isWeighingSku = Number((currentSku == null ? void 0 : currentSku.open_sold_weight) || 0) === 1;
|
|
40
|
+
if (!isWeighingSku && !weighing)
|
|
41
|
+
return void 0;
|
|
42
|
+
if (hasRuntimeWeighingSku)
|
|
43
|
+
return { ...currentSku };
|
|
44
|
+
if (!weighing)
|
|
45
|
+
return currentSku ? { ...currentSku } : void 0;
|
|
46
|
+
return {
|
|
47
|
+
...currentSku || {},
|
|
48
|
+
open_sold_weight: 1,
|
|
49
|
+
unit_data_snapshot: weighing.scalePriceProduct,
|
|
50
|
+
unit: WEIGHT_UNIT_MAP[String(weighing.unit)] || weighing.unit,
|
|
51
|
+
unit_weight: weighing.unit_weight ?? "1.000",
|
|
52
|
+
unit_price: weighing.unit_price,
|
|
53
|
+
weight_source: weighing.mode,
|
|
54
|
+
tare_name: ((_c = weighing.tare) == null ? void 0 : _c.label) ?? "",
|
|
55
|
+
tare_weight: ((_d = weighing.tare) == null ? void 0 : _d.value) ?? 0,
|
|
56
|
+
weight: weighing.weight ?? 0,
|
|
57
|
+
net_weight: weighing.net_weight ?? 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
buildProductSkuFromCacheItem
|
|
63
|
+
});
|
|
@@ -83,7 +83,6 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
83
83
|
private getBookingAppointmentStatus;
|
|
84
84
|
private isBookingIncludedInStats;
|
|
85
85
|
private getBookingOrderPaymentStatus;
|
|
86
|
-
private isUnpaidBooking;
|
|
87
86
|
private countBookingOrders;
|
|
88
87
|
private countCompletedBookings;
|
|
89
88
|
private groupBookingsByResource;
|
|
@@ -39,7 +39,6 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
39
39
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
40
40
|
var import_types = require("./types");
|
|
41
41
|
__reExport(Sales_exports, require("./types"), module.exports);
|
|
42
|
-
var UNPAID_PAYMENT_STATUSES = /* @__PURE__ */ new Set(["unpaid", "partially_paid", "payment_processing"]);
|
|
43
42
|
var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
44
43
|
// LoggerManager 实例
|
|
45
44
|
constructor(name, version) {
|
|
@@ -259,9 +258,6 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
259
258
|
var _a;
|
|
260
259
|
return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
|
|
261
260
|
}
|
|
262
|
-
isUnpaidBooking(booking) {
|
|
263
|
-
return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
|
|
264
|
-
}
|
|
265
261
|
countBookingOrders(bookings) {
|
|
266
262
|
const orderIds = /* @__PURE__ */ new Set();
|
|
267
263
|
bookings.forEach((booking) => {
|
|
@@ -635,7 +631,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
635
631
|
const completedBookingList = matchedBookingList.filter(
|
|
636
632
|
(booking) => this.getBookingAppointmentStatus(booking) === "completed"
|
|
637
633
|
);
|
|
638
|
-
const unpaidBookingList = matchedBookingList.filter(
|
|
634
|
+
const unpaidBookingList = matchedBookingList.filter(
|
|
635
|
+
(booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
|
|
636
|
+
);
|
|
639
637
|
const bookings = this.pickBookingsForCurrentPoint(
|
|
640
638
|
current,
|
|
641
639
|
this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
|
|
@@ -48,10 +48,6 @@ var import_utils2 = require("../../modules/Order/utils");
|
|
|
48
48
|
var import_dayjs = __toESM(require("dayjs"));
|
|
49
49
|
var import_itemRule = require("../../model/strategy/adapter/itemRule");
|
|
50
50
|
__reExport(ScanOrder_exports, require("./types"), module.exports);
|
|
51
|
-
function isItemRewardProductDiscount(discount) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
54
|
-
}
|
|
55
51
|
var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
56
52
|
constructor(name, version) {
|
|
57
53
|
super(name, version);
|
|
@@ -746,10 +742,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
746
742
|
for (const product of tempOrder.products) {
|
|
747
743
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
748
744
|
continue;
|
|
749
|
-
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
750
|
-
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
751
|
-
continue;
|
|
752
|
-
}
|
|
753
745
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
754
746
|
var _a2;
|
|
755
747
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
@@ -65,10 +65,6 @@ var OPEN_DATA_SECTION_CODES = [
|
|
|
65
65
|
"workflow",
|
|
66
66
|
"checkout"
|
|
67
67
|
];
|
|
68
|
-
function isItemRewardProductDiscount(discount) {
|
|
69
|
-
var _a, _b;
|
|
70
|
-
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
71
|
-
}
|
|
72
68
|
function cloneCustomDepositData(customDepositData) {
|
|
73
69
|
if (!customDepositData || typeof customDepositData !== "object")
|
|
74
70
|
return void 0;
|
|
@@ -1343,10 +1339,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1343
1339
|
for (const product of tempOrder.products) {
|
|
1344
1340
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
1345
1341
|
continue;
|
|
1346
|
-
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
1347
|
-
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
1348
|
-
continue;
|
|
1349
|
-
}
|
|
1350
1342
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1351
1343
|
var _a2;
|
|
1352
1344
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.268",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
19
19
|
"changeset": "changeset",
|
|
20
20
|
"version": "changeset version",
|
|
21
|
-
"release": "changeset publish
|
|
21
|
+
"release": "changeset publish && npm run sync && git push",
|
|
22
22
|
"example": "npx parcel-bundler examples/index.html",
|
|
23
23
|
"docs": "typedoc --out docs src/index.ts",
|
|
24
24
|
"sync": "node sync.js",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type OrderPaymentTransactionStatus = 'success' | 'fail';
|
|
2
|
-
export interface OrderPaymentTransaction {
|
|
3
|
-
number: string;
|
|
4
|
-
status: OrderPaymentTransactionStatus;
|
|
5
|
-
}
|
|
6
|
-
export type OrderPaymentIdentityType = 'order_payment_id' | 'payment_number' | 'unique_payment_number';
|
|
7
|
-
export interface OrderPaymentIdentityMatch<T> {
|
|
8
|
-
index: number;
|
|
9
|
-
payment: T;
|
|
10
|
-
matchedBy: OrderPaymentIdentityType;
|
|
11
|
-
}
|
|
12
|
-
export declare function getOrderPaymentIdentityKeys(payment: unknown): string[];
|
|
13
|
-
export declare function isPendingOrderPayment(payment: unknown): boolean;
|
|
14
|
-
export declare function isIdentifiedPendingOrderPayment(payment: unknown): boolean;
|
|
15
|
-
export declare function hasOrderPaymentIdentityOverlap(left: unknown, right: unknown): boolean;
|
|
16
|
-
export declare function resolveOrderPaymentIdentity<T extends Record<string, any>>(payments: T[] | null | undefined, identity: string | number, mode?: 'payment_number' | 'compat'): OrderPaymentIdentityMatch<T> | null;
|
|
17
|
-
export declare function ensureOrderPaymentNumber<T extends Record<string, any>>(payment: T, devicePrefix: string, createPaymentNumber: () => string): T & {
|
|
18
|
-
payment_number: string;
|
|
19
|
-
};
|
|
20
|
-
export declare function mergeOrderPaymentTransactions(current: unknown, incoming: unknown): OrderPaymentTransaction[];
|
|
21
|
-
export declare function mergeOrderPaymentRecord<T extends Record<string, any>>(payment: T, updates: Record<string, any>): T;
|
|
22
|
-
export declare function mergeOrderPaymentSnapshot<T extends Record<string, any>>(current: T, incoming: T): T;
|
|
23
|
-
export declare function mergeOrderPaymentListsByIdentity<T extends Record<string, any>>(existing: T[] | null | undefined, incoming: T[] | null | undefined, options?: {
|
|
24
|
-
preserveUnmatchedExisting?: boolean;
|
|
25
|
-
preserveUnmatchedExistingWhen?: (payment: T) => boolean;
|
|
26
|
-
}): T[];
|