@pisell/pisellos 2.3.109 → 2.3.110
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/modules/OpenData/index.d.ts +1 -1
- package/dist/modules/OpenData/index.js +19 -11
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +22 -21
- package/dist/server/index.js +4 -5
- package/dist/server/utils/small-ticket.d.ts +7 -5
- package/dist/server/utils/small-ticket.js +653 -138
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +548 -485
- package/dist/utils/os-private-payload.d.ts +5 -0
- package/dist/utils/os-private-payload.js +17 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/OpenData/index.d.ts +1 -1
- package/lib/modules/OpenData/index.js +9 -1
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +15 -18
- package/lib/server/index.js +4 -5
- package/lib/server/utils/small-ticket.d.ts +7 -5
- package/lib/server/utils/small-ticket.js +504 -65
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +32 -3
- package/lib/utils/os-private-payload.d.ts +5 -0
- package/lib/utils/os-private-payload.js +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
import { cloneDeep } from 'lodash-es';
|
|
3
|
+
var OS_PRIVATE_FIELD_PREFIX = '_os_';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Remove top-level fields reserved for communication with the PisellOS proxy.
|
|
7
|
+
* Nested business payloads are intentionally left untouched.
|
|
8
|
+
*/
|
|
9
|
+
export function stripOsPrivatePayloadFields(data) {
|
|
10
|
+
var next = cloneDeep(data);
|
|
11
|
+
if (!next || _typeof(next) !== 'object' || Array.isArray(next)) return next;
|
|
12
|
+
var record = next;
|
|
13
|
+
Object.keys(record).forEach(function (key) {
|
|
14
|
+
if (key.startsWith(OS_PRIVATE_FIELD_PREFIX)) delete record[key];
|
|
15
|
+
});
|
|
16
|
+
return next;
|
|
17
|
+
}
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -33,7 +33,7 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
33
33
|
getOpenData(): OpenDataConfig | null;
|
|
34
34
|
getInvoiceLayoutConfig(): InvoiceLayoutConfig;
|
|
35
35
|
getInvoiceTemplateSettings(): InvoiceTemplateSettings;
|
|
36
|
-
ensureInvoiceTemplateSettings(target: string): Promise<InvoiceTemplateSettings>;
|
|
36
|
+
ensureInvoiceTemplateSettings(target: string, openDataConfig?: OpenDataConfig): Promise<InvoiceTemplateSettings>;
|
|
37
37
|
private commitInvoiceTemplateSettings;
|
|
38
38
|
private resolveInvoiceTemplateSettings;
|
|
39
39
|
private buildInvoiceTemplateCacheKey;
|
|
@@ -211,8 +211,16 @@ class OpenDataModule extends _BaseModule.BaseModule {
|
|
|
211
211
|
}
|
|
212
212
|
return (0, _utils.getDefaultInvoiceTemplateSettings)();
|
|
213
213
|
}
|
|
214
|
-
async ensureInvoiceTemplateSettings(target) {
|
|
214
|
+
async ensureInvoiceTemplateSettings(target, openDataConfig) {
|
|
215
215
|
const normalizedTarget = String(target || '').trim();
|
|
216
|
+
if (openDataConfig && openDataConfig !== this.store.data) {
|
|
217
|
+
// 部分解决方案会在初始化参数中直接收到已经拉取完成的 OpenData。
|
|
218
|
+
// 将它纳入模块状态后再解析 Document,避免为了 Invoice 重复请求 setting,
|
|
219
|
+
// 同时让后续同步 getter 能校验同一份 document id 与 target。
|
|
220
|
+
this.fetchRevision += 1;
|
|
221
|
+
this.store.data = openDataConfig;
|
|
222
|
+
this.store.lastFetchedAt = Date.now();
|
|
223
|
+
}
|
|
216
224
|
const config = this.store.data;
|
|
217
225
|
if (!normalizedTarget || !config) {
|
|
218
226
|
return (0, _utils.getDefaultInvoiceTemplateSettings)();
|
|
@@ -588,6 +588,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
588
588
|
*/
|
|
589
589
|
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
590
590
|
submitSalesOrder<T = any>(params: SubmitSalesOrderParams): Promise<T>;
|
|
591
|
+
private isSalesCheckoutHandledByOsServer;
|
|
591
592
|
/**
|
|
592
593
|
* 发送支付链接邮件。
|
|
593
594
|
*
|
|
@@ -9,6 +9,7 @@ var _types = require("./types");
|
|
|
9
9
|
var _utils = require("./utils");
|
|
10
10
|
var _utils2 = require("../Product/utils");
|
|
11
11
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
12
|
+
var _osPrivatePayload = require("../../utils/os-private-payload");
|
|
12
13
|
var _salesNotes = require("./salesNotes");
|
|
13
14
|
var _paymentUtils = require("./payment-utils");
|
|
14
15
|
var _paymentNumber = require("../../utils/payment-number");
|
|
@@ -72,13 +73,6 @@ function getVoucherPaymentLifecycleKey(payment) {
|
|
|
72
73
|
if (!isVoucherPaymentRecord(payment)) return null;
|
|
73
74
|
return `${String(payment.voucher_id)}::${String(payment.status || '')}`;
|
|
74
75
|
}
|
|
75
|
-
function hasPersistedOrderId(orderId) {
|
|
76
|
-
if (orderId === undefined || orderId === null || orderId === '') return false;
|
|
77
|
-
if (typeof orderId === 'string' && orderId.startsWith('LOCAL_')) return false;
|
|
78
|
-
const normalizedOrderId = Number(orderId);
|
|
79
|
-
if (Number.isFinite(normalizedOrderId)) return normalizedOrderId > 0;
|
|
80
|
-
return String(orderId).trim() !== '';
|
|
81
|
-
}
|
|
82
76
|
class OrderModule extends _BaseModule.BaseModule {
|
|
83
77
|
defaultName = 'order';
|
|
84
78
|
defaultVersion = '1.0.0';
|
|
@@ -482,7 +476,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
482
476
|
this.store.virtualCurrencyList = prepareConfigResult?.virtualCurrencyList || [];
|
|
483
477
|
if (prepareConfigResult) {
|
|
484
478
|
this.writePointCardSnapshotFromPrepareConfig({
|
|
485
|
-
orderId,
|
|
486
479
|
customerId: params.customerId,
|
|
487
480
|
availableWalletPassList: prepareConfigResult.availableWalletPassList || []
|
|
488
481
|
});
|
|
@@ -1022,8 +1015,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1022
1015
|
const tempOrder = this.store.tempOrder;
|
|
1023
1016
|
if (!tempOrder) return;
|
|
1024
1017
|
if (String(tempOrder.customer_id ?? '') !== String(params.customerId)) return;
|
|
1025
|
-
const effectiveOrderId = params.orderId ?? tempOrder.order_id;
|
|
1026
|
-
if (hasPersistedOrderId(effectiveOrderId)) return;
|
|
1027
1018
|
tempOrder.order_meta_list = {
|
|
1028
1019
|
...((0, _utils.normalizeOrderMetaList)(tempOrder.order_meta_list) || {}),
|
|
1029
1020
|
point_cards_snapshot: (0, _utils.buildPointCardSnapshotFromWalletPassList)(params.availableWalletPassList)
|
|
@@ -2699,7 +2690,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2699
2690
|
email: tempOrder.email
|
|
2700
2691
|
});
|
|
2701
2692
|
const nextCustomerId = tempOrder.customer_id ?? null;
|
|
2702
|
-
if (String(previousCustomerId ?? '') !== String(nextCustomerId ?? '')
|
|
2693
|
+
if (String(previousCustomerId ?? '') !== String(nextCustomerId ?? '')) {
|
|
2703
2694
|
this.store.availableWalletIds = [];
|
|
2704
2695
|
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
2705
2696
|
}
|
|
@@ -2739,9 +2730,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2739
2730
|
if (String(previousCustomerId ?? '') !== String(nextCustomerId ?? '')) {
|
|
2740
2731
|
this.store.availableWalletIds = [];
|
|
2741
2732
|
this.store.virtualCurrencyList = [];
|
|
2742
|
-
|
|
2743
|
-
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
2744
|
-
}
|
|
2733
|
+
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
2745
2734
|
(0, _utils.clearTempOrderHolderAssignments)(tempOrder);
|
|
2746
2735
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
2747
2736
|
this.applyDiscount();
|
|
@@ -2781,9 +2770,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2781
2770
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
2782
2771
|
this.store.availableWalletIds = [];
|
|
2783
2772
|
this.store.virtualCurrencyList = [];
|
|
2784
|
-
|
|
2785
|
-
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
2786
|
-
}
|
|
2773
|
+
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
2787
2774
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
2788
2775
|
this.applyDiscount();
|
|
2789
2776
|
this.persistTempOrder();
|
|
@@ -4680,11 +4667,21 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4680
4667
|
query
|
|
4681
4668
|
} = params;
|
|
4682
4669
|
const fetchUrl = url || '/order/sales/checkout';
|
|
4683
|
-
|
|
4670
|
+
const requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : (0, _osPrivatePayload.stripOsPrivatePayloadFields)(query);
|
|
4671
|
+
return this.request.post(fetchUrl, requestQuery, {
|
|
4684
4672
|
osServer: true,
|
|
4685
4673
|
customToast: () => {}
|
|
4686
4674
|
});
|
|
4687
4675
|
}
|
|
4676
|
+
isSalesCheckoutHandledByOsServer(fetchUrl) {
|
|
4677
|
+
const server = this.core?.server;
|
|
4678
|
+
if (!server || typeof server.hasRoute !== 'function') return false;
|
|
4679
|
+
const requestBaseUrl = String(this.request?.baseUrl || '/shop').replace(/\/+$/, '');
|
|
4680
|
+
if (!requestBaseUrl.startsWith('/')) return false;
|
|
4681
|
+
const normalizedFetchUrl = fetchUrl.startsWith('/') ? fetchUrl : `/${fetchUrl}`;
|
|
4682
|
+
const routePath = normalizedFetchUrl === requestBaseUrl || normalizedFetchUrl.startsWith(`${requestBaseUrl}/`) ? normalizedFetchUrl : `${requestBaseUrl}${normalizedFetchUrl}`;
|
|
4683
|
+
return server.hasRoute('post', routePath) === true;
|
|
4684
|
+
}
|
|
4688
4685
|
|
|
4689
4686
|
/**
|
|
4690
4687
|
* 发送支付链接邮件。
|
package/lib/server/index.js
CHANGED
|
@@ -29,6 +29,7 @@ var _BaseSales = require("../solution/BaseSales");
|
|
|
29
29
|
var _paymentUtils = require("../modules/Order/payment-utils");
|
|
30
30
|
var _salesNotes = require("../modules/Order/salesNotes");
|
|
31
31
|
var _orderCollectionIdentity = require("../modules/Order/utils/orderCollectionIdentity");
|
|
32
|
+
var _osPrivatePayload = require("../utils/os-private-payload");
|
|
32
33
|
var _OpenData = require("../modules/OpenData");
|
|
33
34
|
var _modules = require("./modules");
|
|
34
35
|
Object.keys(_modules).forEach(function (key) {
|
|
@@ -643,7 +644,7 @@ class Server {
|
|
|
643
644
|
} = params;
|
|
644
645
|
const normalizedData = await this.normalizeCheckoutSubmitData(params.data, title);
|
|
645
646
|
const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
646
|
-
const checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
|
|
647
|
+
const checkoutData = this.normalizeCheckoutCollections((0, _osPrivatePayload.stripOsPrivatePayloadFields)(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
|
|
647
648
|
const remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
|
|
648
649
|
const deviceHeaders = await this.buildCheckoutDeviceHeaders(title);
|
|
649
650
|
if (!this.app?.request?.post) {
|
|
@@ -715,11 +716,9 @@ class Server {
|
|
|
715
716
|
return next;
|
|
716
717
|
}
|
|
717
718
|
buildRemoteCheckoutData(data, title) {
|
|
718
|
-
const next = (0,
|
|
719
|
+
const next = (0, _osPrivatePayload.stripOsPrivatePayloadFields)(this.omitCheckoutSyncMode(data));
|
|
719
720
|
if (!next || typeof next !== 'object') return next;
|
|
720
721
|
const record = next;
|
|
721
|
-
delete record[OS_FULFILLMENT_REF_MODE_FIELD];
|
|
722
|
-
delete record[OS_INVOICE_LAYOUT_CONFIG_FIELD];
|
|
723
722
|
this.applyKioskCheckoutOperator(record);
|
|
724
723
|
if (!Array.isArray(record.payments)) return next;
|
|
725
724
|
const originalPayments = record.payments;
|
|
@@ -4330,7 +4329,7 @@ class Server {
|
|
|
4330
4329
|
}
|
|
4331
4330
|
const normalizedData = await this.normalizeCheckoutSubmitData(data, title);
|
|
4332
4331
|
const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
4333
|
-
const checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
|
|
4332
|
+
const checkoutData = this.normalizeCheckoutCollections((0, _osPrivatePayload.stripOsPrivatePayloadFields)(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
|
|
4334
4333
|
const pendingResult = await this.handlePendingSyncCheckoutOrder({
|
|
4335
4334
|
backendPath,
|
|
4336
4335
|
data: checkoutData,
|
|
@@ -28,14 +28,19 @@ export interface SmallTicketItem {
|
|
|
28
28
|
value: string;
|
|
29
29
|
size?: number;
|
|
30
30
|
align?: string;
|
|
31
|
+
product_uid?: string | number;
|
|
32
|
+
booking_uid?: string | number;
|
|
31
33
|
}
|
|
32
34
|
export interface SmallTicketProduct {
|
|
33
35
|
product_title: string;
|
|
34
36
|
product_quantity: number;
|
|
35
37
|
selling_price: string;
|
|
38
|
+
total_selling_price: string;
|
|
36
39
|
original_price: string;
|
|
37
40
|
base_price?: string;
|
|
38
41
|
total_original_price: string;
|
|
42
|
+
options_total_price?: string;
|
|
43
|
+
package_items_total_price?: string;
|
|
39
44
|
extension_list: any[];
|
|
40
45
|
product_uid?: string | number;
|
|
41
46
|
booking_uid?: string | number;
|
|
@@ -44,16 +49,13 @@ export interface SmallTicketProduct {
|
|
|
44
49
|
name: string;
|
|
45
50
|
num?: number;
|
|
46
51
|
price?: string;
|
|
52
|
+
total_price: string;
|
|
47
53
|
value?: string;
|
|
48
54
|
}>;
|
|
49
55
|
variant?: string;
|
|
50
56
|
combinations?: any[];
|
|
51
57
|
}
|
|
52
|
-
export
|
|
53
|
-
product_uid?: string | number;
|
|
54
|
-
booking_uid?: string | number;
|
|
55
|
-
}
|
|
56
|
-
export type SmallTicketAppointment = SmallTicketItem[] | SmallTicketBookingSnapshot[];
|
|
58
|
+
export type SmallTicketAppointment = SmallTicketItem[];
|
|
57
59
|
export interface SmallTicketLocaleData {
|
|
58
60
|
base_data: Record<string, any>;
|
|
59
61
|
products: SmallTicketProduct[];
|