@pisell/pisellos 2.2.148 → 2.2.150
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +246 -193
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +26 -1
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -29,12 +29,155 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/modules/Order/utils.ts
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
|
+
buildSubmitPayload: () => buildSubmitPayload,
|
|
33
|
+
composeLinePrice: () => composeLinePrice,
|
|
34
|
+
createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
|
|
35
|
+
createDefaultTempOrder: () => createDefaultTempOrder,
|
|
36
|
+
createEmptySummary: () => import_utils2.createEmptySummary,
|
|
37
|
+
createUuidV4: () => createUuidV4,
|
|
38
|
+
formatDateTime: () => formatDateTime,
|
|
39
|
+
formatV1Product: () => formatV1Product,
|
|
32
40
|
generateDuration: () => generateDuration,
|
|
33
41
|
getAllDiscountList: () => getAllDiscountList,
|
|
34
|
-
|
|
42
|
+
isTempOrder: () => isTempOrder,
|
|
43
|
+
mapPaymentItemToOrderPayment: () => mapPaymentItemToOrderPayment,
|
|
44
|
+
mapPaymentItemsToOrderPayments: () => mapPaymentItemsToOrderPayments,
|
|
45
|
+
mergeRelationForms: () => mergeRelationForms,
|
|
46
|
+
normalizeBookingIsAll: () => normalizeBookingIsAll,
|
|
47
|
+
normalizeBookingSubType: () => normalizeBookingSubType,
|
|
48
|
+
normalizeSubmitBooking: () => normalizeSubmitBooking,
|
|
49
|
+
normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
|
|
50
|
+
resolveSubmitCollectPax: () => resolveSubmitCollectPax,
|
|
51
|
+
sumOptionUnitPrice: () => sumOptionUnitPrice
|
|
35
52
|
});
|
|
36
53
|
module.exports = __toCommonJS(utils_exports);
|
|
37
54
|
var import_dayjs = __toESM(require("dayjs"));
|
|
55
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
56
|
+
var import_utils = require("../../solution/ScanOrder/utils");
|
|
57
|
+
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
58
|
+
function composeLinePrice(params) {
|
|
59
|
+
const { mainPrice, bundle, useOriginalBundle } = params;
|
|
60
|
+
let total = new import_decimal.default(Number(mainPrice) || 0);
|
|
61
|
+
if (Array.isArray(bundle)) {
|
|
62
|
+
for (const item of bundle) {
|
|
63
|
+
const rawPrice = useOriginalBundle ? (item == null ? void 0 : item.original_price) ?? (item == null ? void 0 : item.product_price) ?? (item == null ? void 0 : item.price) : (item == null ? void 0 : item.bundle_selling_price) ?? (item == null ? void 0 : item.price);
|
|
64
|
+
const price = new import_decimal.default(Number(rawPrice) || 0);
|
|
65
|
+
const rawNum = (item == null ? void 0 : item.num) ?? (item == null ? void 0 : item.quantity) ?? 1;
|
|
66
|
+
const num = new import_decimal.default(Number(rawNum) || 0);
|
|
67
|
+
total = total.plus(price.times(num));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return total.toDecimalPlaces(2).toFixed(2);
|
|
71
|
+
}
|
|
72
|
+
function sumOptionUnitPrice(options) {
|
|
73
|
+
let total = new import_decimal.default(0);
|
|
74
|
+
if (!Array.isArray(options))
|
|
75
|
+
return total;
|
|
76
|
+
for (const opt of options) {
|
|
77
|
+
const price = new import_decimal.default(Number(opt == null ? void 0 : opt.price) || 0);
|
|
78
|
+
const num = new import_decimal.default(Number(opt == null ? void 0 : opt.num) || 0);
|
|
79
|
+
total = total.plus(price.times(num));
|
|
80
|
+
}
|
|
81
|
+
return total;
|
|
82
|
+
}
|
|
83
|
+
function createDefaultOrderRulesHooks() {
|
|
84
|
+
const toUnitPriceString = (totalLike, num) => {
|
|
85
|
+
const effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
86
|
+
return new import_decimal.default(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
getProduct: (product) => {
|
|
90
|
+
var _a, _b, _c, _d, _e, _f;
|
|
91
|
+
const metadataAny = product.metadata || {};
|
|
92
|
+
const optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
93
|
+
let sourcePrice;
|
|
94
|
+
if (metadataAny.source_product_price !== void 0) {
|
|
95
|
+
sourcePrice = String(metadataAny.source_product_price);
|
|
96
|
+
} else if (metadataAny.main_product_selling_price !== void 0) {
|
|
97
|
+
sourcePrice = new import_decimal.default(
|
|
98
|
+
Number(metadataAny.main_product_selling_price) || 0
|
|
99
|
+
).minus(optionSum).toDecimalPlaces(2).toString();
|
|
100
|
+
} else {
|
|
101
|
+
sourcePrice = String(product.selling_price ?? 0);
|
|
102
|
+
}
|
|
103
|
+
let sourceOriginalPrice;
|
|
104
|
+
if (metadataAny.source_product_price !== void 0) {
|
|
105
|
+
sourceOriginalPrice = String(metadataAny.source_product_price);
|
|
106
|
+
} else if (metadataAny.main_product_original_price !== void 0) {
|
|
107
|
+
sourceOriginalPrice = new import_decimal.default(
|
|
108
|
+
Number(metadataAny.main_product_original_price) || 0
|
|
109
|
+
).minus(optionSum).toDecimalPlaces(2).toString();
|
|
110
|
+
} else {
|
|
111
|
+
sourceOriginalPrice = sourcePrice;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
id: product.product_id,
|
|
115
|
+
// Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
|
|
116
|
+
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
117
|
+
// 不透明 identity 契约下,normalizeOrderProduct / restoreTempOrderFromStorage 已保证唯一值存在;
|
|
118
|
+
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
119
|
+
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils.buildProductLineFingerprint)(
|
|
120
|
+
product.product_option_item,
|
|
121
|
+
product.product_bundle
|
|
122
|
+
)}`,
|
|
123
|
+
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
124
|
+
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
125
|
+
price: sourcePrice,
|
|
126
|
+
// total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
|
|
127
|
+
total: new import_decimal.default(product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
128
|
+
origin_total: new import_decimal.default(
|
|
129
|
+
product.original_price || product.selling_price || 0
|
|
130
|
+
).times(product.num || 1).toNumber(),
|
|
131
|
+
original_price: sourceOriginalPrice,
|
|
132
|
+
quantity: product.num || 1,
|
|
133
|
+
num: product.num || 1,
|
|
134
|
+
discount_list: product.discount_list || [],
|
|
135
|
+
bundle: product.product_bundle || [],
|
|
136
|
+
booking_id: ((_b = product.metadata) == null ? void 0 : _b.booking_id) || null,
|
|
137
|
+
isClient: false,
|
|
138
|
+
isManualDiscount: ((_c = product.metadata) == null ? void 0 : _c.is_manual_discount) || false,
|
|
139
|
+
holder_id: (_d = product.metadata) == null ? void 0 : _d.holder_id,
|
|
140
|
+
startDate: ((_e = product.metadata) == null ? void 0 : _e.start_date) || ((_f = product.metadata) == null ? void 0 : _f.startDate)
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
setProduct: (product, values) => {
|
|
144
|
+
const nextNum = Number(values.quantity ?? product.num ?? 1) || 1;
|
|
145
|
+
const metadataAny = product.metadata || {};
|
|
146
|
+
const existedSource = metadataAny.source_product_price ?? product.selling_price ?? "0";
|
|
147
|
+
const nextOptions = product.product_option_item;
|
|
148
|
+
const optionSum = sumOptionUnitPrice(nextOptions);
|
|
149
|
+
const nextSourceSellingPrice = values.main_product_selling_price !== void 0 ? String(values.main_product_selling_price) : values.price !== void 0 ? String(values.price) : values.total !== void 0 ? toUnitPriceString(values.total, nextNum) : String(existedSource);
|
|
150
|
+
const nextSourceOriginalPrice = values.original_price !== void 0 ? String(values.original_price) : String(existedSource);
|
|
151
|
+
const nextMainSellingPrice = new import_decimal.default(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
152
|
+
const nextMainOriginalPrice = new import_decimal.default(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
153
|
+
const nextBundle = values.bundle ?? product.product_bundle;
|
|
154
|
+
const composedSellingPrice = composeLinePrice({
|
|
155
|
+
mainPrice: nextMainSellingPrice,
|
|
156
|
+
bundle: nextBundle
|
|
157
|
+
});
|
|
158
|
+
const composedOriginalPrice = composeLinePrice({
|
|
159
|
+
mainPrice: nextMainOriginalPrice,
|
|
160
|
+
bundle: nextBundle,
|
|
161
|
+
useOriginalBundle: true
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
...product,
|
|
165
|
+
selling_price: composedSellingPrice,
|
|
166
|
+
original_price: composedOriginalPrice,
|
|
167
|
+
discount_list: values.discount_list ?? product.discount_list,
|
|
168
|
+
num: values.quantity ?? product.num,
|
|
169
|
+
product_bundle: nextBundle,
|
|
170
|
+
metadata: {
|
|
171
|
+
...metadataAny,
|
|
172
|
+
source_product_price: nextSourceOriginalPrice,
|
|
173
|
+
main_product_selling_price: nextMainSellingPrice,
|
|
174
|
+
main_product_original_price: nextMainOriginalPrice,
|
|
175
|
+
price_schema_version: 2
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
38
181
|
var generateDuration = (cartItem) => {
|
|
39
182
|
const startDate = (0, import_dayjs.default)(`${cartItem.start_date} ${cartItem.start_time}`);
|
|
40
183
|
const endDate = (0, import_dayjs.default)(`${cartItem.end_date} ${cartItem.end_time}`);
|
|
@@ -65,9 +208,426 @@ var getAllDiscountList = (cartItem) => {
|
|
|
65
208
|
});
|
|
66
209
|
return discountList;
|
|
67
210
|
};
|
|
211
|
+
function createUuidV4() {
|
|
212
|
+
const template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
|
|
213
|
+
return template.replace(/[xy]/g, (char) => {
|
|
214
|
+
const randomValue = Math.floor(Math.random() * 16);
|
|
215
|
+
const value = char === "x" ? randomValue : randomValue & 3 | 8;
|
|
216
|
+
return value.toString(16);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function isTempOrder(data) {
|
|
220
|
+
if (!data || typeof data !== "object")
|
|
221
|
+
return false;
|
|
222
|
+
if (!Array.isArray(data.products))
|
|
223
|
+
return false;
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
function formatDateTime(date) {
|
|
227
|
+
const pad = (value) => value.toString().padStart(2, "0");
|
|
228
|
+
const year = date.getFullYear();
|
|
229
|
+
const month = pad(date.getMonth() + 1);
|
|
230
|
+
const day = pad(date.getDate());
|
|
231
|
+
const hours = pad(date.getHours());
|
|
232
|
+
const minutes = pad(date.getMinutes());
|
|
233
|
+
const seconds = pad(date.getSeconds());
|
|
234
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
235
|
+
}
|
|
236
|
+
function normalizeSubmitPlatform(platform) {
|
|
237
|
+
const value = String(platform || "").trim();
|
|
238
|
+
if (!value)
|
|
239
|
+
return "H5";
|
|
240
|
+
const lower = value.toLowerCase();
|
|
241
|
+
if (lower === "pc")
|
|
242
|
+
return "PC";
|
|
243
|
+
if (lower === "h5")
|
|
244
|
+
return "H5";
|
|
245
|
+
return value;
|
|
246
|
+
}
|
|
247
|
+
function formatSubmitOptionItems(options) {
|
|
248
|
+
if (!Array.isArray(options))
|
|
249
|
+
return [];
|
|
250
|
+
return options.map((d) => {
|
|
251
|
+
const option = {
|
|
252
|
+
num: d == null ? void 0 : d.num,
|
|
253
|
+
option_group_item_id: (d == null ? void 0 : d.option_group_item_id) ?? (d == null ? void 0 : d.product_option_item_id),
|
|
254
|
+
option_group_id: d == null ? void 0 : d.option_group_id
|
|
255
|
+
};
|
|
256
|
+
const addPrice = (d == null ? void 0 : d.add_price) ?? (d == null ? void 0 : d.price);
|
|
257
|
+
if (addPrice !== void 0)
|
|
258
|
+
option.add_price = String(addPrice);
|
|
259
|
+
return option;
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function toBundleNumber(value, fallback = 0) {
|
|
263
|
+
const parsed = Number(value);
|
|
264
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
265
|
+
}
|
|
266
|
+
function toMoneyString(value) {
|
|
267
|
+
const parsed = Number(value);
|
|
268
|
+
if (Number.isFinite(parsed))
|
|
269
|
+
return parsed.toFixed(2);
|
|
270
|
+
if (value === null || value === void 0 || value === "")
|
|
271
|
+
return "0.00";
|
|
272
|
+
return String(value);
|
|
273
|
+
}
|
|
274
|
+
function formatSubmitBundleItems(bundle) {
|
|
275
|
+
if (!Array.isArray(bundle))
|
|
276
|
+
return [];
|
|
277
|
+
return bundle.map((b) => {
|
|
278
|
+
const rawBundle = b && typeof b === "object" ? b : {};
|
|
279
|
+
const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
|
|
280
|
+
const sellingPrice = toMoneyString(
|
|
281
|
+
rawBundle.bundle_selling_price ?? rawBundle.price
|
|
282
|
+
);
|
|
283
|
+
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
284
|
+
const relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
285
|
+
const surchargeFee = toMoneyString(
|
|
286
|
+
rawBundle.surcharge_fee ?? existedMetadata.surcharge_fee
|
|
287
|
+
);
|
|
288
|
+
const productDiscountDifference = toBundleNumber(
|
|
289
|
+
existedMetadata.product_discount_difference,
|
|
290
|
+
0
|
|
291
|
+
);
|
|
292
|
+
const num = toBundleNumber(rawBundle.num ?? rawBundle.quantity, 1);
|
|
293
|
+
return {
|
|
294
|
+
is_charge_tax: rawBundle.is_charge_tax ?? 0,
|
|
295
|
+
bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
|
|
296
|
+
num,
|
|
297
|
+
quantity: toBundleNumber(rawBundle.quantity ?? rawBundle.num, num),
|
|
298
|
+
extension_id: rawBundle.extension_id ?? 0,
|
|
299
|
+
extension_type: rawBundle.extension_type ?? "normal",
|
|
300
|
+
price: priceValue,
|
|
301
|
+
price_type: rawBundle.price_type ?? rawBundle.custom_price_type ?? "",
|
|
302
|
+
price_type_ext: rawBundle.price_type_ext ?? rawBundle.custom_price_type_ext ?? "",
|
|
303
|
+
bundle_selling_price: sellingPrice,
|
|
304
|
+
option: formatSubmitOptionItems(rawBundle.option),
|
|
305
|
+
bundle_group_id: (rawBundle == null ? void 0 : rawBundle.bundle_group_id) ?? (rawBundle == null ? void 0 : rawBundle.group_id),
|
|
306
|
+
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
307
|
+
bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
|
|
308
|
+
metadata: {
|
|
309
|
+
...existedMetadata,
|
|
310
|
+
surcharge_fee: surchargeFee,
|
|
311
|
+
relation_surcharge_ids: relationSurchargeIds,
|
|
312
|
+
product_discount_difference: productDiscountDifference
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function normalizeSubmitProduct(product) {
|
|
318
|
+
var _a;
|
|
319
|
+
const { unique_identification_number: _runtimeUid, ...submitProduct } = product;
|
|
320
|
+
const {
|
|
321
|
+
num,
|
|
322
|
+
product_option_item: productOptionItem,
|
|
323
|
+
surcharge_fee: _productSurchargeFee,
|
|
324
|
+
...productRest
|
|
325
|
+
} = submitProduct;
|
|
326
|
+
const rawMetadata = submitProduct.metadata || {};
|
|
327
|
+
const bookingUid = rawMetadata.booking_uid;
|
|
328
|
+
const cleanMetadata = {};
|
|
329
|
+
if (rawMetadata.unique_identification_number) {
|
|
330
|
+
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
331
|
+
}
|
|
332
|
+
const priceMetaKeys = [
|
|
333
|
+
"main_product_original_price",
|
|
334
|
+
"main_product_selling_price",
|
|
335
|
+
"source_product_price",
|
|
336
|
+
"main_product_attached_bundle_surcharge_fee",
|
|
337
|
+
"main_product_attached_bundle_tax_fee",
|
|
338
|
+
"surcharge_rounding_remainder",
|
|
339
|
+
"tax_fee_rounding_remainder",
|
|
340
|
+
"relation_surcharge_ids",
|
|
341
|
+
"discountable_flag",
|
|
342
|
+
"parent_unique_identification_number",
|
|
343
|
+
"product_add_schedule_time"
|
|
344
|
+
];
|
|
345
|
+
for (const key of priceMetaKeys) {
|
|
346
|
+
if (rawMetadata[key] !== void 0) {
|
|
347
|
+
cleanMetadata[key] = rawMetadata[key];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
cleanMetadata.product_discount_difference = rawMetadata.product_discount_difference ?? "";
|
|
351
|
+
if (rawMetadata.price_breakdown) {
|
|
352
|
+
cleanMetadata.price_breakdown = rawMetadata.price_breakdown;
|
|
353
|
+
}
|
|
354
|
+
if (rawMetadata.is_rule !== void 0) {
|
|
355
|
+
cleanMetadata.is_rule = rawMetadata.is_rule;
|
|
356
|
+
}
|
|
357
|
+
const productSku = {
|
|
358
|
+
...submitProduct.product_sku && typeof submitProduct.product_sku === "object" ? submitProduct.product_sku : {},
|
|
359
|
+
option: formatSubmitOptionItems(
|
|
360
|
+
(productOptionItem == null ? void 0 : productOptionItem.length) ? productOptionItem : (_a = submitProduct.product_sku) == null ? void 0 : _a.option
|
|
361
|
+
)
|
|
362
|
+
};
|
|
363
|
+
return {
|
|
364
|
+
...productRest,
|
|
365
|
+
...bookingUid ? { booking_uid: bookingUid } : {},
|
|
366
|
+
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
367
|
+
product_sku: productSku,
|
|
368
|
+
discount_list: submitProduct.discount_list || [],
|
|
369
|
+
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
370
|
+
metadata: cleanMetadata,
|
|
371
|
+
// 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
|
|
372
|
+
// 新语义下 selling_price 是 composite(含 option/bundle),payment_price 同语义。
|
|
373
|
+
payment_price: submitProduct.selling_price
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
var SUBMIT_BOOKING_METADATA_WHITELIST = [
|
|
377
|
+
"unique_identification_number",
|
|
378
|
+
"collect_pax",
|
|
379
|
+
"capacity",
|
|
380
|
+
"holder_id",
|
|
381
|
+
"resource_select_type"
|
|
382
|
+
];
|
|
383
|
+
function normalizeBookingIsAll(booking) {
|
|
384
|
+
return booking.is_all === true || booking.is_all === 1 || booking.is_all === "1" || booking.is_all === "true" ? 1 : 0;
|
|
385
|
+
}
|
|
386
|
+
function normalizeBookingSubType(booking) {
|
|
387
|
+
if (normalizeBookingIsAll(booking) === 1)
|
|
388
|
+
return "days";
|
|
389
|
+
if (booking.sub_type !== void 0 && booking.sub_type !== null && booking.sub_type !== "") {
|
|
390
|
+
return String(booking.sub_type);
|
|
391
|
+
}
|
|
392
|
+
return "minutes";
|
|
393
|
+
}
|
|
394
|
+
function normalizeSubmitBooking(booking) {
|
|
395
|
+
const rawMetadata = booking.metadata || {};
|
|
396
|
+
const cleanMetadata = {};
|
|
397
|
+
for (const key of SUBMIT_BOOKING_METADATA_WHITELIST) {
|
|
398
|
+
if (rawMetadata[key] !== void 0) {
|
|
399
|
+
cleanMetadata[key] = rawMetadata[key];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (cleanMetadata.holder_id === void 0)
|
|
403
|
+
cleanMetadata.holder_id = null;
|
|
404
|
+
const bookingRecord = booking;
|
|
405
|
+
const startDate = bookingRecord.start_date;
|
|
406
|
+
const shouldRestoreSelectDate = bookingRecord.select_date === void 0 || bookingRecord.select_date === null || bookingRecord.select_date === "";
|
|
407
|
+
const selectDateFromStartDate = typeof startDate === "string" ? startDate.split(/\s+/)[0] : startDate;
|
|
408
|
+
return {
|
|
409
|
+
...booking,
|
|
410
|
+
...shouldRestoreSelectDate && selectDateFromStartDate ? { select_date: selectDateFromStartDate } : {},
|
|
411
|
+
is_all: normalizeBookingIsAll(bookingRecord),
|
|
412
|
+
sub_type: normalizeBookingSubType(bookingRecord),
|
|
413
|
+
metadata: cleanMetadata
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function normalizeSubmitCollectPaxValue(value) {
|
|
417
|
+
const n = Number(value);
|
|
418
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : 1;
|
|
419
|
+
}
|
|
420
|
+
function resolveSubmitCollectPax(tempOrder) {
|
|
421
|
+
var _a;
|
|
422
|
+
return normalizeSubmitCollectPaxValue((_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax);
|
|
423
|
+
}
|
|
424
|
+
function createDefaultTempOrder(params) {
|
|
425
|
+
return {
|
|
426
|
+
order_id: null,
|
|
427
|
+
external_sale_number: "",
|
|
428
|
+
order_number: "",
|
|
429
|
+
shop_order_number: "",
|
|
430
|
+
shop_full_order_number: "",
|
|
431
|
+
type: "appointment_booking",
|
|
432
|
+
business_code: "appointment_booking",
|
|
433
|
+
platform: "h5",
|
|
434
|
+
sales_channel: "my_pisel",
|
|
435
|
+
order_sales_channel: "online_store",
|
|
436
|
+
status: "normal",
|
|
437
|
+
payment_status: "payment_processing",
|
|
438
|
+
shipping_status: "unfulfilled",
|
|
439
|
+
customer_id: null,
|
|
440
|
+
customer_name: "",
|
|
441
|
+
country_calling_code: "",
|
|
442
|
+
phone: "",
|
|
443
|
+
email: "",
|
|
444
|
+
is_price_include_tax: 1,
|
|
445
|
+
tax_title: "",
|
|
446
|
+
tax_country_code: "",
|
|
447
|
+
currency_code: "",
|
|
448
|
+
currency_symbol: "",
|
|
449
|
+
currency_format: "symbol_first",
|
|
450
|
+
is_deposit: 0,
|
|
451
|
+
deposit_amount: "0.00",
|
|
452
|
+
shop_discount: "0.00",
|
|
453
|
+
surcharge_fee: "0.00",
|
|
454
|
+
note: "",
|
|
455
|
+
schedule_date: params.now,
|
|
456
|
+
created_at: params.now,
|
|
457
|
+
request_unique_idempotency_token: "",
|
|
458
|
+
products: [],
|
|
459
|
+
bookings: [],
|
|
460
|
+
payments: [],
|
|
461
|
+
surcharges: [],
|
|
462
|
+
discount_list: [],
|
|
463
|
+
relation_forms: [],
|
|
464
|
+
contacts: [],
|
|
465
|
+
contacts_info: null,
|
|
466
|
+
holder: null,
|
|
467
|
+
metadata: {},
|
|
468
|
+
_extend: {
|
|
469
|
+
productsByUid: {}
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function buildSubmitPayload(params) {
|
|
474
|
+
const {
|
|
475
|
+
tempOrder,
|
|
476
|
+
cacheId,
|
|
477
|
+
now = /* @__PURE__ */ new Date(),
|
|
478
|
+
platform,
|
|
479
|
+
businessCode,
|
|
480
|
+
channel,
|
|
481
|
+
type,
|
|
482
|
+
enhance
|
|
483
|
+
} = params;
|
|
484
|
+
const scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
485
|
+
const bookingUuid = createUuidV4();
|
|
486
|
+
const {
|
|
487
|
+
_extend,
|
|
488
|
+
relation_id: _relationId,
|
|
489
|
+
table_form_id: _tableFormId,
|
|
490
|
+
resource_id: _resourceId,
|
|
491
|
+
summary: _summary,
|
|
492
|
+
lastOrderInfo: _lastOrderInfo,
|
|
493
|
+
paid_amount: _paidAmount,
|
|
494
|
+
shop_id: _shopId,
|
|
495
|
+
shop_note: _shopNote,
|
|
496
|
+
shop_service_type: _shopServiceType,
|
|
497
|
+
start_time: _startTime,
|
|
498
|
+
customer: _customer,
|
|
499
|
+
shop_full_order_number: _shopFullOrderNumber,
|
|
500
|
+
tax_fee: _rootTaxFee,
|
|
501
|
+
total_amount: _totalAmount,
|
|
502
|
+
total_refund_amount: _totalRefundAmount,
|
|
503
|
+
create_date: _createDate,
|
|
504
|
+
holder_id: _holderId,
|
|
505
|
+
...tempOrderRest
|
|
506
|
+
} = tempOrder;
|
|
507
|
+
const payload = {
|
|
508
|
+
...tempOrderRest,
|
|
509
|
+
platform: normalizeSubmitPlatform(platform),
|
|
510
|
+
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || `${tempOrder.external_sale_number}_${now.getTime()}`,
|
|
511
|
+
type: type ?? tempOrder.type ?? "table-order",
|
|
512
|
+
business_code: businessCode ?? tempOrder.business_code ?? "table-order",
|
|
513
|
+
sales_channel: tempOrder.sales_channel || "my_pisel",
|
|
514
|
+
order_sales_channel: channel ?? tempOrder.order_sales_channel ?? "online_store",
|
|
515
|
+
status: tempOrder.status || "normal",
|
|
516
|
+
payment_status: tempOrder.payment_status || "payment_processing",
|
|
517
|
+
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
518
|
+
is_price_include_tax: tempOrder.is_price_include_tax ?? 1,
|
|
519
|
+
currency_format: tempOrder.currency_format || "symbol_first",
|
|
520
|
+
is_deposit: tempOrder.is_deposit ?? 0,
|
|
521
|
+
deposit_amount: tempOrder.deposit_amount || "0.00",
|
|
522
|
+
shop_discount: tempOrder.shop_discount || "0.00",
|
|
523
|
+
surcharge_fee: tempOrder.surcharge_fee || "0.00",
|
|
524
|
+
note: tempOrder.note || "",
|
|
525
|
+
delivery_type: tempOrder.delivery_type || "nil",
|
|
526
|
+
schedule_date: scheduleDate,
|
|
527
|
+
created_at: tempOrder.created_at || formatDateTime(now),
|
|
528
|
+
bookings: (tempOrder.bookings || []).map((booking) => normalizeSubmitBooking(booking)),
|
|
529
|
+
payments: tempOrder.payments || [],
|
|
530
|
+
// discount_list: tempOrder.discount_list || [],
|
|
531
|
+
relation_forms: tempOrder.relation_forms || [],
|
|
532
|
+
// contacts: tempOrder.contacts || [],
|
|
533
|
+
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
534
|
+
// holder: tempOrder.holder || null,
|
|
535
|
+
// summary,
|
|
536
|
+
metadata: (() => {
|
|
537
|
+
const {
|
|
538
|
+
collect_pax: _collectPax,
|
|
539
|
+
table_occupancy_duration: _tableOccupancyDuration,
|
|
540
|
+
...rest
|
|
541
|
+
} = tempOrder.metadata || {};
|
|
542
|
+
return { ...rest };
|
|
543
|
+
})(),
|
|
544
|
+
products: (tempOrder.products || []).map(
|
|
545
|
+
(product) => normalizeSubmitProduct(product)
|
|
546
|
+
)
|
|
547
|
+
};
|
|
548
|
+
return enhance ? enhance(payload, { tempOrder, bookingUuid, now }) : payload;
|
|
549
|
+
}
|
|
550
|
+
function mapPaymentItemToOrderPayment(paymentItem) {
|
|
551
|
+
const item = paymentItem;
|
|
552
|
+
const customPaymentId = item.custom_payment_id ?? item.id;
|
|
553
|
+
const metadata = item.metadata && typeof item.metadata === "object" ? { ...item.metadata } : {};
|
|
554
|
+
if (item.uuid && !metadata.unique_payment_number) {
|
|
555
|
+
metadata.unique_payment_number = String(item.uuid);
|
|
556
|
+
}
|
|
557
|
+
const paymentMetadataKeys = [
|
|
558
|
+
"rounding_rule",
|
|
559
|
+
"shop_wallet_pass_id",
|
|
560
|
+
"actual_paid_amount",
|
|
561
|
+
"change_given_amount"
|
|
562
|
+
];
|
|
563
|
+
for (const key of paymentMetadataKeys) {
|
|
564
|
+
if (item[key] !== void 0 && metadata[key] === void 0) {
|
|
565
|
+
metadata[key] = item[key];
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return {
|
|
569
|
+
amount: String(item.amount ?? "0.00"),
|
|
570
|
+
code: String(item.code || ""),
|
|
571
|
+
custom_payment_id: Number(customPaymentId ?? 0),
|
|
572
|
+
name: String(item.name || ""),
|
|
573
|
+
type: String(item.type || ""),
|
|
574
|
+
...item.voucher_id !== void 0 ? { voucher_id: item.voucher_id } : {},
|
|
575
|
+
...item.origin_amount !== void 0 ? { origin_amount: String(item.origin_amount) } : {},
|
|
576
|
+
...item.service_fee !== void 0 ? { service_fee: String(item.service_fee) } : {},
|
|
577
|
+
...item.status !== void 0 ? { status: item.status } : {},
|
|
578
|
+
...item.payment_time !== void 0 ? { payment_time: item.payment_time } : {},
|
|
579
|
+
...item.wallet_pass_usage_unit !== void 0 ? { wallet_pass_usage_unit: item.wallet_pass_usage_unit } : {},
|
|
580
|
+
...item.wallet_pass_use_value !== void 0 ? { wallet_pass_use_value: item.wallet_pass_use_value } : {},
|
|
581
|
+
metadata,
|
|
582
|
+
...item.rounding_amount !== void 0 ? { rounding_amount: String(item.rounding_amount) } : {},
|
|
583
|
+
...item.service_charge !== void 0 ? { service_charge: item.service_charge } : {},
|
|
584
|
+
...item.order_payment_type !== void 0 ? { order_payment_type: item.order_payment_type } : {},
|
|
585
|
+
...item.created_at !== void 0 ? { created_at: item.created_at } : {},
|
|
586
|
+
...item.updated_at !== void 0 ? { updated_at: item.updated_at } : {}
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function mapPaymentItemsToOrderPayments(paymentItems, options = {}) {
|
|
590
|
+
if (!Array.isArray(paymentItems))
|
|
591
|
+
return [];
|
|
592
|
+
return paymentItems.filter((item) => options.includeVoided || item.status !== "voided").map((item) => mapPaymentItemToOrderPayment(item));
|
|
593
|
+
}
|
|
594
|
+
function formatV1Product(products) {
|
|
595
|
+
return products.map((product) => {
|
|
596
|
+
var _a;
|
|
597
|
+
return {
|
|
598
|
+
bundle: product.product_bundle,
|
|
599
|
+
key: product.product_id,
|
|
600
|
+
option: ((_a = product.product_sku) == null ? void 0 : _a.option) || [],
|
|
601
|
+
product_id: product.product_id,
|
|
602
|
+
product_variant_id: product.product_variant_id,
|
|
603
|
+
num: product.product_quantity,
|
|
604
|
+
note: String(product.note ?? ""),
|
|
605
|
+
rowKey: product.product_id,
|
|
606
|
+
session: null,
|
|
607
|
+
unique: createUuidV4()
|
|
608
|
+
};
|
|
609
|
+
});
|
|
610
|
+
}
|
|
68
611
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
612
|
0 && (module.exports = {
|
|
613
|
+
buildSubmitPayload,
|
|
614
|
+
composeLinePrice,
|
|
615
|
+
createDefaultOrderRulesHooks,
|
|
616
|
+
createDefaultTempOrder,
|
|
617
|
+
createEmptySummary,
|
|
618
|
+
createUuidV4,
|
|
619
|
+
formatDateTime,
|
|
620
|
+
formatV1Product,
|
|
70
621
|
generateDuration,
|
|
71
622
|
getAllDiscountList,
|
|
72
|
-
|
|
623
|
+
isTempOrder,
|
|
624
|
+
mapPaymentItemToOrderPayment,
|
|
625
|
+
mapPaymentItemsToOrderPayments,
|
|
626
|
+
mergeRelationForms,
|
|
627
|
+
normalizeBookingIsAll,
|
|
628
|
+
normalizeBookingSubType,
|
|
629
|
+
normalizeSubmitBooking,
|
|
630
|
+
normalizeSubmitCollectPaxValue,
|
|
631
|
+
resolveSubmitCollectPax,
|
|
632
|
+
sumOptionUnitPrice
|
|
73
633
|
});
|
|
@@ -25,10 +25,10 @@ __export(utils_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(utils_exports);
|
|
26
26
|
function isNormalProduct(product) {
|
|
27
27
|
var _a;
|
|
28
|
-
if (product.duration) {
|
|
28
|
+
if (product == null ? void 0 : product.duration) {
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
|
-
if ((_a = product["schedule.ids"]) == null ? void 0 : _a.length) {
|
|
31
|
+
if ((_a = product == null ? void 0 : product["schedule.ids"]) == null ? void 0 : _a.length) {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
return true;
|
|
@@ -100,7 +100,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
100
100
|
with_schedule,
|
|
101
101
|
schedule_datetime
|
|
102
102
|
},
|
|
103
|
-
{ osServer: true, callback: options == null ? void 0 : options.callback, subscriberId: options == null ? void 0 : options.subscriberId
|
|
103
|
+
{ osServer: true, callback: options == null ? void 0 : options.callback, subscriberId: options == null ? void 0 : options.subscriberId, customToast: () => {
|
|
104
|
+
} }
|
|
104
105
|
);
|
|
105
106
|
const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
106
107
|
this.addProduct(sortedList);
|
|
@@ -2,7 +2,7 @@ import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import type { ScheduleItem } from '../Schedule/types';
|
|
4
4
|
import type { QuotationItem } from './types';
|
|
5
|
-
export type { QuotationItem, QuotationProductData, QuotationSchedule, QuotationState } from './types';
|
|
5
|
+
export type { QuotationItem, QuotationProductData, QuotationSchedule, QuotationState, QuotationCustomer } from './types';
|
|
6
6
|
export declare class QuotationModule extends BaseModule implements Module {
|
|
7
7
|
protected defaultName: string;
|
|
8
8
|
protected defaultVersion: string;
|
|
@@ -13,6 +13,7 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
13
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
14
14
|
loadQuotations(params?: {
|
|
15
15
|
channel?: string;
|
|
16
|
+
customer_id?: number | string;
|
|
16
17
|
}): Promise<void>;
|
|
17
18
|
getQuotationList(): QuotationItem[];
|
|
18
19
|
/**
|
|
@@ -27,11 +28,13 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
27
28
|
productId: number;
|
|
28
29
|
variantId?: number;
|
|
29
30
|
datetime: string;
|
|
31
|
+
customer_id?: number | string;
|
|
30
32
|
}): string | null;
|
|
31
33
|
getQuotationShelfId(params: {
|
|
32
34
|
productId: number;
|
|
33
35
|
variantId?: number;
|
|
34
36
|
datetime: string;
|
|
37
|
+
customer_id?: number | string;
|
|
35
38
|
}): number;
|
|
36
39
|
/**
|
|
37
40
|
* Batch pre-compute quotation prices for a set of products across multiple time points.
|
|
@@ -41,8 +44,12 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
41
44
|
buildProductPriceMap(params: {
|
|
42
45
|
productIds: number[];
|
|
43
46
|
timePoints: string[];
|
|
47
|
+
customer_id?: number | string;
|
|
44
48
|
}): Map<string, string | null>;
|
|
45
49
|
setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
|
|
50
|
+
private filterQuotationsByCustomer;
|
|
51
|
+
private isQuotationVisibleForCustomer;
|
|
52
|
+
private hasValidCustomerId;
|
|
46
53
|
private isQuotationActiveAt;
|
|
47
54
|
private findProductData;
|
|
48
55
|
}
|