@pisell/pisellos 2.1.119 → 2.1.121
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/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +7 -0
- package/dist/model/strategy/adapter/index.js +7 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +439 -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 +64 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +315 -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 +206 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
- package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/dist/model/strategy/adapter/promotion/examples.js +166 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/dist/model/strategy/adapter/promotion/type.js +209 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
- package/dist/model/strategy/engine.d.ts +106 -0
- package/dist/model/strategy/engine.js +611 -0
- package/dist/model/strategy/index.d.ts +3 -0
- package/dist/model/strategy/index.js +8 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- 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 +58 -1
- package/dist/modules/Order/index.js +796 -29
- package/dist/modules/Order/types.d.ts +144 -12
- package/dist/modules/Order/utils.d.ts +28 -0
- package/dist/modules/Order/utils.js +250 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +245 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.js +4 -1
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +59 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +513 -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 +95 -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 +46 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +4 -4
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +90 -0
- package/dist/solution/ScanOrder/index.js +1853 -0
- package/dist/solution/ScanOrder/types.d.ts +210 -0
- package/dist/solution/ScanOrder/types.js +16 -0
- package/dist/solution/ScanOrder/utils.d.ts +93 -0
- package/dist/solution/ScanOrder/utils.js +397 -0
- package/dist/solution/VenueBooking/index.d.ts +163 -0
- package/dist/solution/VenueBooking/index.js +2931 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +130 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/resource.js +94 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +203 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +7 -0
- package/lib/model/strategy/adapter/index.js +57 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +338 -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 +64 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +58 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/lib/model/strategy/adapter/promotion/examples.js +192 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/lib/model/strategy/adapter/promotion/type.js +51 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
- package/lib/model/strategy/engine.d.ts +106 -0
- package/lib/model/strategy/engine.js +450 -0
- package/lib/model/strategy/index.d.ts +3 -0
- package/lib/model/strategy/index.js +38 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- 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 +58 -1
- package/lib/modules/Order/index.js +437 -1
- package/lib/modules/Order/types.d.ts +144 -12
- package/lib/modules/Order/utils.d.ts +28 -0
- package/lib/modules/Order/utils.js +250 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +149 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.js +4 -1
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +59 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +452 -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 +82 -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 +46 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +4 -4
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +90 -0
- package/lib/solution/ScanOrder/index.js +1071 -0
- package/lib/solution/ScanOrder/types.d.ts +210 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +93 -0
- package/lib/solution/ScanOrder/utils.js +359 -0
- package/lib/solution/VenueBooking/index.d.ts +163 -0
- package/lib/solution/VenueBooking/index.js +1578 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +130 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/resource.js +80 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +208 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/modules/OpenData/index.ts
|
|
21
|
+
var OpenData_exports = {};
|
|
22
|
+
__export(OpenData_exports, {
|
|
23
|
+
OpenDataModule: () => OpenDataModule,
|
|
24
|
+
computeAvailability: () => import_utils2.computeAvailability
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(OpenData_exports);
|
|
27
|
+
var import_BaseModule = require("../BaseModule");
|
|
28
|
+
var import_utils = require("./utils");
|
|
29
|
+
__reExport(OpenData_exports, require("./types"), module.exports);
|
|
30
|
+
var import_utils2 = require("./utils");
|
|
31
|
+
var OpenDataModule = class extends import_BaseModule.BaseModule {
|
|
32
|
+
constructor(name, version) {
|
|
33
|
+
super(name, version);
|
|
34
|
+
this.defaultName = "openData";
|
|
35
|
+
this.defaultVersion = "1.0.0";
|
|
36
|
+
this.openCache = false;
|
|
37
|
+
this.otherParams = {};
|
|
38
|
+
}
|
|
39
|
+
async initialize(core, options) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
this.core = core;
|
|
42
|
+
this.store = options.store;
|
|
43
|
+
this.store.data = ((_a = options.initialState) == null ? void 0 : _a.data) ?? null;
|
|
44
|
+
this.store.lastFetchedAt = ((_b = options.initialState) == null ? void 0 : _b.lastFetchedAt) ?? null;
|
|
45
|
+
this.otherParams = options.otherParams || {};
|
|
46
|
+
if (this.otherParams.cacheId) {
|
|
47
|
+
this.openCache = this.otherParams.openCache ?? false;
|
|
48
|
+
this.cacheId = this.otherParams.cacheId;
|
|
49
|
+
}
|
|
50
|
+
if (this.otherParams.fatherModule) {
|
|
51
|
+
this.fatherModule = this.otherParams.fatherModule;
|
|
52
|
+
}
|
|
53
|
+
this.request = core.getPlugin("request");
|
|
54
|
+
this.window = core.getPlugin("window");
|
|
55
|
+
if (!this.request)
|
|
56
|
+
throw new Error("OpenDataModule 需要 request 插件支持");
|
|
57
|
+
if (!this.window)
|
|
58
|
+
throw new Error("OpenDataModule 需要 window 插件支持");
|
|
59
|
+
console.log("[OpenDataModule] 初始化完成");
|
|
60
|
+
}
|
|
61
|
+
async fetchOpenData(params) {
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
const shopId = (_b = (_a = this.otherParams) == null ? void 0 : _a.getStateData) == null ? void 0 : _b.call(_a, "shop_id");
|
|
64
|
+
if (!shopId)
|
|
65
|
+
throw new Error("[OpenDataModule] 无法获取 shop_id");
|
|
66
|
+
const tenantId = (_d = (_c = this.otherParams) == null ? void 0 : _c.getStateData) == null ? void 0 : _d.call(_c, "tenant_id");
|
|
67
|
+
const headers = {};
|
|
68
|
+
if (tenantId)
|
|
69
|
+
headers["Tenant-Id"] = String(tenantId);
|
|
70
|
+
const response = await this.request.post(
|
|
71
|
+
`/open/my-pisell/${shopId}/setting`,
|
|
72
|
+
{
|
|
73
|
+
scope: params.scope,
|
|
74
|
+
target: params.target,
|
|
75
|
+
section_code: params.section_code
|
|
76
|
+
},
|
|
77
|
+
{ pisell2: true, headers }
|
|
78
|
+
);
|
|
79
|
+
if ((response == null ? void 0 : response.status) === false) {
|
|
80
|
+
throw new Error((response == null ? void 0 : response.message) || "获取 OpenData 配置失败");
|
|
81
|
+
}
|
|
82
|
+
const data = (response == null ? void 0 : response.data) || {};
|
|
83
|
+
this.store.data = data;
|
|
84
|
+
this.store.lastFetchedAt = Date.now();
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
getOpenData() {
|
|
88
|
+
return this.store.data;
|
|
89
|
+
}
|
|
90
|
+
getLastFetchedAt() {
|
|
91
|
+
return this.store.lastFetchedAt ?? null;
|
|
92
|
+
}
|
|
93
|
+
checkAvailability(scheduleModule) {
|
|
94
|
+
var _a;
|
|
95
|
+
const scheduleList = scheduleModule ? scheduleModule.getScheduleListByIds(
|
|
96
|
+
((_a = this.store.data) == null ? void 0 : _a["availability.operating_hours"]) || []
|
|
97
|
+
) : void 0;
|
|
98
|
+
return (0, import_utils.computeAvailability)({
|
|
99
|
+
config: this.store.data,
|
|
100
|
+
scheduleList
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
storeChange() {
|
|
104
|
+
if (this.openCache) {
|
|
105
|
+
this.checkSaveCache({
|
|
106
|
+
cacheId: this.cacheId,
|
|
107
|
+
fatherModule: this.fatherModule,
|
|
108
|
+
store: this.store,
|
|
109
|
+
cacheKey: ["data", "lastFetchedAt"]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
115
|
+
0 && (module.exports = {
|
|
116
|
+
OpenDataModule,
|
|
117
|
+
computeAvailability,
|
|
118
|
+
...require("./types")
|
|
119
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ScheduleItem } from '../Schedule/types';
|
|
2
|
+
export interface MultiLangObject {
|
|
3
|
+
en?: string;
|
|
4
|
+
ja?: string;
|
|
5
|
+
pt?: string;
|
|
6
|
+
'zh-CN'?: string;
|
|
7
|
+
'zh-HK'?: string;
|
|
8
|
+
original?: string;
|
|
9
|
+
[key: string]: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface OpenDataConfig {
|
|
12
|
+
'basic.enable'?: boolean;
|
|
13
|
+
'basic.code'?: string | null;
|
|
14
|
+
'basic.name'?: string | MultiLangObject;
|
|
15
|
+
'basic.unavailable_message'?: string | MultiLangObject;
|
|
16
|
+
'availability.paused'?: boolean;
|
|
17
|
+
'availability.pause_message'?: string | MultiLangObject;
|
|
18
|
+
'availability.pause_behavior'?: string;
|
|
19
|
+
'availability.closed_behavior'?: string;
|
|
20
|
+
'availability.closed_message'?: string | MultiLangObject;
|
|
21
|
+
'availability.operating_hours'?: number[];
|
|
22
|
+
'reservation.enable'?: boolean;
|
|
23
|
+
'reservation.auto_confirm'?: boolean;
|
|
24
|
+
'reservation.auto_confirm_mode'?: string;
|
|
25
|
+
'reservation.auto_confirm_delay_seconds'?: number;
|
|
26
|
+
'sale.allow_item_notes'?: boolean;
|
|
27
|
+
'sale.allow_order_notes'?: boolean;
|
|
28
|
+
'sale.enable_item_rules'?: boolean;
|
|
29
|
+
'sale.enable_short_number'?: boolean;
|
|
30
|
+
'sale.short_number_daily_reset'?: boolean;
|
|
31
|
+
'sale.short_number_start_number'?: number;
|
|
32
|
+
'sale.short_number_prefix'?: string | null;
|
|
33
|
+
'sale.sale_number_prefix'?: string | null;
|
|
34
|
+
'sale.enabled_item_rules'?: number[];
|
|
35
|
+
'fulfillment.enable_pickup'?: boolean;
|
|
36
|
+
'fulfillment.overdue_reminder'?: boolean;
|
|
37
|
+
'fulfillment.manual_input_type'?: string;
|
|
38
|
+
'fulfillment.enable_auto_complete'?: boolean;
|
|
39
|
+
'fulfillment.enable_table_service'?: boolean;
|
|
40
|
+
'fulfillment.fulfillment_ref_mode'?: string;
|
|
41
|
+
'fulfillment.advance_warning_minutes'?: number;
|
|
42
|
+
'fulfillment.update_end_time_on_auto_complete'?: string;
|
|
43
|
+
'menu.associated_menus'?: Array<{
|
|
44
|
+
label: string;
|
|
45
|
+
value: number;
|
|
46
|
+
}>;
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
49
|
+
export interface OpenDataState {
|
|
50
|
+
data: OpenDataConfig | null;
|
|
51
|
+
lastFetchedAt: number | null;
|
|
52
|
+
}
|
|
53
|
+
export interface OpenDataFetchParams {
|
|
54
|
+
scope: string;
|
|
55
|
+
target: string;
|
|
56
|
+
section_code: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface OpenDataApiResponse {
|
|
59
|
+
status: boolean;
|
|
60
|
+
code: number;
|
|
61
|
+
message: string;
|
|
62
|
+
data: OpenDataConfig;
|
|
63
|
+
}
|
|
64
|
+
export type OpenDataUnavailableReason = 'shop_disabled' | 'paused' | 'closed' | 'reservation_disabled';
|
|
65
|
+
export interface OpenDataAvailabilityResult {
|
|
66
|
+
available: boolean;
|
|
67
|
+
reason: OpenDataUnavailableReason | null;
|
|
68
|
+
message: string | MultiLangObject | null;
|
|
69
|
+
}
|
|
70
|
+
export interface ComputeAvailabilityParams {
|
|
71
|
+
config: OpenDataConfig | null;
|
|
72
|
+
scheduleList?: ScheduleItem[];
|
|
73
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/modules/OpenData/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/modules/OpenData/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
computeAvailability: () => computeAvailability
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(utils_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_getDateIsInSchedule = require("../Schedule/getDateIsInSchedule");
|
|
37
|
+
function toBoolean(value) {
|
|
38
|
+
if (typeof value === "boolean")
|
|
39
|
+
return value;
|
|
40
|
+
if (typeof value === "string")
|
|
41
|
+
return value === "true" || value === "1";
|
|
42
|
+
if (typeof value === "number")
|
|
43
|
+
return value !== 0;
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
function resolveMessage(...candidates) {
|
|
47
|
+
for (const val of candidates) {
|
|
48
|
+
if (!val)
|
|
49
|
+
continue;
|
|
50
|
+
if (typeof val === "string" && val.length > 0)
|
|
51
|
+
return val;
|
|
52
|
+
if (typeof val === "object" && val !== null && !Array.isArray(val))
|
|
53
|
+
return val;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function computeAvailability(params) {
|
|
58
|
+
const { config, scheduleList } = params;
|
|
59
|
+
if (!config) {
|
|
60
|
+
return { available: true, reason: null, message: null };
|
|
61
|
+
}
|
|
62
|
+
if (config["basic.enable"] === false) {
|
|
63
|
+
return {
|
|
64
|
+
available: false,
|
|
65
|
+
reason: "shop_disabled",
|
|
66
|
+
message: resolveMessage(
|
|
67
|
+
config["basic.unavailable_message"],
|
|
68
|
+
config["availability.closed_message"]
|
|
69
|
+
)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (toBoolean(config["availability.paused"])) {
|
|
73
|
+
return {
|
|
74
|
+
available: false,
|
|
75
|
+
reason: "paused",
|
|
76
|
+
message: resolveMessage(
|
|
77
|
+
config["availability.pause_message"],
|
|
78
|
+
config["availability.closed_message"]
|
|
79
|
+
)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const operatingHourIds = config["availability.operating_hours"];
|
|
83
|
+
if (Array.isArray(operatingHourIds) && operatingHourIds.length > 0 && (scheduleList == null ? void 0 : scheduleList.length)) {
|
|
84
|
+
const relevantSchedules = scheduleList.filter(
|
|
85
|
+
(s) => operatingHourIds.includes(s.id)
|
|
86
|
+
);
|
|
87
|
+
if (relevantSchedules.length > 0) {
|
|
88
|
+
const now = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
89
|
+
const isOpen = (0, import_getDateIsInSchedule.getDateIsInSchedule)(now, relevantSchedules);
|
|
90
|
+
if (!isOpen) {
|
|
91
|
+
return {
|
|
92
|
+
available: false,
|
|
93
|
+
reason: "closed",
|
|
94
|
+
message: resolveMessage(config["availability.closed_message"])
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (config["reservation.enable"] === false) {
|
|
100
|
+
return {
|
|
101
|
+
available: false,
|
|
102
|
+
reason: "reservation_disabled",
|
|
103
|
+
message: resolveMessage(config["availability.closed_message"])
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return { available: true, reason: null, message: null };
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
computeAvailability
|
|
111
|
+
});
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams } from './types';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, SubmitScanOrderParams, ScanOrderMoreParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
|
+
import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderSummary, ScanOrderTempOrder } from '../../solution/ScanOrder/types';
|
|
6
|
+
import type { Discount } from '../Discount/types';
|
|
7
|
+
import { UnavailableReason } from '../Rules/types';
|
|
5
8
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
6
9
|
protected defaultName: string;
|
|
7
10
|
protected defaultVersion: string;
|
|
8
11
|
private store;
|
|
9
12
|
private request;
|
|
10
13
|
private logger;
|
|
14
|
+
private window;
|
|
15
|
+
private cacheId;
|
|
16
|
+
private salesSummaryModuleName;
|
|
17
|
+
private rulesHooksOverride?;
|
|
18
|
+
/**
|
|
19
|
+
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
20
|
+
* Only selected discounts get a non-zero value.
|
|
21
|
+
*/
|
|
22
|
+
static populateSavedAmounts(productList: Array<Record<string, any>>, discountList: Array<Record<string, any>>): void;
|
|
11
23
|
constructor(name?: string, version?: string);
|
|
12
24
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
25
|
/**
|
|
@@ -22,6 +34,49 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
22
34
|
* 记录错误日志
|
|
23
35
|
*/
|
|
24
36
|
private logError;
|
|
37
|
+
private registerDiscountModules;
|
|
38
|
+
private createDefaultRulesHooks;
|
|
39
|
+
loadDiscountConfig(params: {
|
|
40
|
+
customerId: number;
|
|
41
|
+
action?: 'create';
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
getDiscountList(): Discount[];
|
|
44
|
+
scanCode(code: string, customerId?: number): Promise<{
|
|
45
|
+
isAvailable: boolean;
|
|
46
|
+
discountList: Discount[];
|
|
47
|
+
type: 'server' | 'clientCalc';
|
|
48
|
+
unavailableReason?: UnavailableReason;
|
|
49
|
+
}>;
|
|
50
|
+
applyDiscount(): void;
|
|
51
|
+
initTempOrder(params: {
|
|
52
|
+
cacheId?: string;
|
|
53
|
+
salesSummaryModuleName?: string;
|
|
54
|
+
}): void;
|
|
55
|
+
private getTempOrderStorageKey;
|
|
56
|
+
private restoreTempOrderFromStorage;
|
|
57
|
+
persistTempOrder(): void;
|
|
58
|
+
private createDefaultTempOrderInstance;
|
|
59
|
+
ensureTempOrder(): ScanOrderTempOrder;
|
|
60
|
+
getTempOrder(): ScanOrderTempOrder | null;
|
|
61
|
+
addNewOrder(): Promise<ScanOrderTempOrder>;
|
|
62
|
+
getOrderProducts(): ScanOrderOrderProduct[];
|
|
63
|
+
private getSalesSummary;
|
|
64
|
+
recalculateSummary(options?: {
|
|
65
|
+
createIfMissing?: boolean;
|
|
66
|
+
}): Promise<ScanOrderSummary | null>;
|
|
67
|
+
getScanOrderSummary(): Promise<ScanOrderSummary>;
|
|
68
|
+
updateTempOrderNote(note: string): string;
|
|
69
|
+
updateTempOrderContactsInfo(contactsInfo: any[]): any[];
|
|
70
|
+
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
71
|
+
updateProductInOrder(params: {
|
|
72
|
+
product_id: number | null;
|
|
73
|
+
product_variant_id: number;
|
|
74
|
+
updates: Partial<ScanOrderOrderProduct>;
|
|
75
|
+
}): Promise<ScanOrderOrderProduct[]>;
|
|
76
|
+
removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
77
|
+
submitTempOrder<T = any>(params?: {
|
|
78
|
+
cacheId?: string;
|
|
79
|
+
}): Promise<T>;
|
|
25
80
|
createOrder(params: CommitOrderParams['query']): {
|
|
26
81
|
type: "virtual" | "appointment_booking";
|
|
27
82
|
platform: string;
|
|
@@ -51,4 +106,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
51
106
|
* @returns 后端返回的订单数据(包含订单ID等)
|
|
52
107
|
*/
|
|
53
108
|
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
109
|
+
submitScanOrder<T = any>(params: SubmitScanOrderParams): Promise<T>;
|
|
110
|
+
scanOrderMore<T = any>(params: ScanOrderMoreParams): Promise<T>;
|
|
54
111
|
}
|