@pisell/pisellos 2.2.147 → 2.2.149
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 +251 -196
- 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 +31 -4
- 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
|
@@ -0,0 +1,655 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/solution/BaseSales/index.ts
|
|
31
|
+
var BaseSales_exports = {};
|
|
32
|
+
__export(BaseSales_exports, {
|
|
33
|
+
BaseSalesImpl: () => BaseSalesImpl
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(BaseSales_exports);
|
|
36
|
+
var import_BaseModule = require("../../modules/BaseModule");
|
|
37
|
+
var import_Order = require("../../modules/Order");
|
|
38
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
39
|
+
var import_types = require("../BookingByStep/types");
|
|
40
|
+
var import_utils = require("../../modules/Order/utils");
|
|
41
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
42
|
+
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
43
|
+
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
44
|
+
constructor(name, version) {
|
|
45
|
+
super(name, version);
|
|
46
|
+
this.defaultName = "baseSales";
|
|
47
|
+
this.defaultVersion = "1.0.0";
|
|
48
|
+
this.isSolution = true;
|
|
49
|
+
this.initializeOptions = {};
|
|
50
|
+
this.store = {
|
|
51
|
+
order: void 0
|
|
52
|
+
};
|
|
53
|
+
this.otherParams = {};
|
|
54
|
+
// 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
|
|
55
|
+
this.currentSalesDetail = null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
59
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule。
|
|
60
|
+
*/
|
|
61
|
+
getRegisteredModuleNames() {
|
|
62
|
+
return ["products", "order", "salesSummary", "schedule"];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 工厂入口:根据子模块名实例化对应模块。
|
|
66
|
+
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
67
|
+
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
68
|
+
*/
|
|
69
|
+
createSubModule(moduleName) {
|
|
70
|
+
return (0, import_types.createModule)(moduleName, this.name);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 读取 sessionStorage[this.name][cacheId],作为子模块 initialState 的来源。
|
|
74
|
+
* sessionStorage 损坏时静默忽略,按空状态注册。
|
|
75
|
+
*/
|
|
76
|
+
readSessionCacheData() {
|
|
77
|
+
if (!this.cacheId || !this.window)
|
|
78
|
+
return {};
|
|
79
|
+
try {
|
|
80
|
+
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
81
|
+
if (!sessionData)
|
|
82
|
+
return {};
|
|
83
|
+
const data = JSON.parse(sessionData);
|
|
84
|
+
return data && data[this.cacheId] || {};
|
|
85
|
+
} catch {
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async initialize(core, options = {}) {
|
|
90
|
+
var _a;
|
|
91
|
+
this.core = core;
|
|
92
|
+
this.initializeOptions = options || {};
|
|
93
|
+
this.otherParams = options.otherParams || {};
|
|
94
|
+
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
95
|
+
this.window = core.getPlugin("window");
|
|
96
|
+
this.request = core.getPlugin("request");
|
|
97
|
+
const targetCacheData = this.readSessionCacheData();
|
|
98
|
+
const moduleNames = this.getRegisteredModuleNames();
|
|
99
|
+
moduleNames.forEach((step) => {
|
|
100
|
+
const targetModule = this.createSubModule(step);
|
|
101
|
+
if (!targetModule) {
|
|
102
|
+
throw new Error(`模块 ${step} 不存在`);
|
|
103
|
+
}
|
|
104
|
+
this.store[step] = targetModule;
|
|
105
|
+
this.core.registerModule(targetModule, {
|
|
106
|
+
initialState: (targetCacheData == null ? void 0 : targetCacheData[targetModule.name]) || {},
|
|
107
|
+
otherParams: {
|
|
108
|
+
...this.otherParams,
|
|
109
|
+
salesSummaryModuleName: `${this.name}_salesSummary`,
|
|
110
|
+
fatherModule: this.name,
|
|
111
|
+
openCache: this.cacheId ? true : false,
|
|
112
|
+
cacheId: this.cacheId
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
if (this.store.schedule) {
|
|
117
|
+
await this.store.schedule.loadAllSchedule();
|
|
118
|
+
}
|
|
119
|
+
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
120
|
+
}
|
|
121
|
+
async destroy() {
|
|
122
|
+
Object.keys(this.store).forEach((key) => {
|
|
123
|
+
const sub = this.store[key];
|
|
124
|
+
if (sub && typeof sub.destroy === "function") {
|
|
125
|
+
try {
|
|
126
|
+
sub.destroy();
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.warn(`[BaseSales] 子模块 ${key} 销毁失败`, error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
this.currentSalesDetail = null;
|
|
133
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
134
|
+
super.destroy();
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 加载销售订单到统一 tempOrder 工作区。
|
|
138
|
+
* 有 app.sqlite 时优先读取本地记录;本地未命中或 forceRemote=true 时再拉云端。
|
|
139
|
+
*
|
|
140
|
+
* 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
|
|
141
|
+
* (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
|
|
142
|
+
*/
|
|
143
|
+
async loadSalesDetail(orderIdOrParams) {
|
|
144
|
+
if (!this.store.order)
|
|
145
|
+
throw new Error("order 模块未初始化");
|
|
146
|
+
const params = typeof orderIdOrParams === "object" ? orderIdOrParams : { orderId: orderIdOrParams };
|
|
147
|
+
const externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
148
|
+
if (!params.forceRemote) {
|
|
149
|
+
const localRecord = params.orderId !== void 0 ? await this.store.order.getLocalOrderByOrderId(params.orderId) : externalSaleNumber ? await this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber) : params.orderNumber ? await this.store.order.getLocalOrderByOrderNumber(params.orderNumber) : null;
|
|
150
|
+
if (localRecord) {
|
|
151
|
+
const sales2 = await this.store.order.hydrateTempOrderFromRecord(localRecord, { recalcOnHydrate: false });
|
|
152
|
+
this.currentSalesDetail = sales2;
|
|
153
|
+
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales: sales2 });
|
|
154
|
+
return sales2;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (params.orderId === void 0 || params.orderId === null) {
|
|
158
|
+
throw new Error("加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber");
|
|
159
|
+
}
|
|
160
|
+
const res = await this.store.order.getOrderInfoByRemote(Number(params.orderId));
|
|
161
|
+
if (!res || res.code !== 200) {
|
|
162
|
+
const message = res && (res.message || res.msg) || `加载销售详情失败: ${params.orderId}`;
|
|
163
|
+
throw new Error(message);
|
|
164
|
+
}
|
|
165
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(res.data, { recalcOnHydrate: false });
|
|
166
|
+
await this.store.order.saveDraft();
|
|
167
|
+
this.currentSalesDetail = sales;
|
|
168
|
+
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
169
|
+
return sales;
|
|
170
|
+
}
|
|
171
|
+
/** 获取当前已加载的销售详情(只读快照)。未加载过则返回 null。 */
|
|
172
|
+
getSalesOrder() {
|
|
173
|
+
return this.currentSalesDetail;
|
|
174
|
+
}
|
|
175
|
+
/** 获取销售详情顶部业务字段(订单号/状态/金额等通用字段集合)。 */
|
|
176
|
+
getOrderHeader() {
|
|
177
|
+
if (!this.currentSalesDetail)
|
|
178
|
+
return null;
|
|
179
|
+
return this.currentSalesDetail.header || this.currentSalesDetail;
|
|
180
|
+
}
|
|
181
|
+
/** 获取所有 booking(含 root + children),按服务端原始顺序输出。 */
|
|
182
|
+
getBookings() {
|
|
183
|
+
var _a;
|
|
184
|
+
return ((_a = this.currentSalesDetail) == null ? void 0 : _a.bookings) || [];
|
|
185
|
+
}
|
|
186
|
+
/** 获取根 booking(is_next === 0 / is_root === 1),多个时取第一个。 */
|
|
187
|
+
getRootBooking() {
|
|
188
|
+
if (!this.currentSalesDetail)
|
|
189
|
+
return null;
|
|
190
|
+
if (this.currentSalesDetail.rootBooking)
|
|
191
|
+
return this.currentSalesDetail.rootBooking;
|
|
192
|
+
const bookings = this.currentSalesDetail.bookings || [];
|
|
193
|
+
return bookings.find((booking) => {
|
|
194
|
+
const parentId = booking == null ? void 0 : booking.parent_id;
|
|
195
|
+
return parentId === 0 || parentId === null || parentId === void 0;
|
|
196
|
+
}) || null;
|
|
197
|
+
}
|
|
198
|
+
/** 按 product_uid 反查 booking 列表(用于商品行 ↔ booking 映射)。 */
|
|
199
|
+
getChildBookingsByProductUid(productUid) {
|
|
200
|
+
var _a;
|
|
201
|
+
if (!this.currentSalesDetail || !productUid)
|
|
202
|
+
return [];
|
|
203
|
+
const indexed = (_a = this.currentSalesDetail.bookingsByProductUid) == null ? void 0 : _a[productUid];
|
|
204
|
+
if (indexed)
|
|
205
|
+
return indexed;
|
|
206
|
+
return (this.currentSalesDetail.bookings || []).filter((booking) => {
|
|
207
|
+
var _a2;
|
|
208
|
+
const uid = (booking == null ? void 0 : booking.product_uid) || ((_a2 = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a2.product_uid);
|
|
209
|
+
return String(uid || "") === String(productUid);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** 获取支付列表(已支付/退款等明细)。 */
|
|
213
|
+
getPayments() {
|
|
214
|
+
var _a;
|
|
215
|
+
return ((_a = this.currentSalesDetail) == null ? void 0 : _a.payments) || [];
|
|
216
|
+
}
|
|
217
|
+
/** 获取附加费用(运费/服务费/税费等)。 */
|
|
218
|
+
getSurcharges() {
|
|
219
|
+
var _a;
|
|
220
|
+
return ((_a = this.currentSalesDetail) == null ? void 0 : _a.surcharges) || [];
|
|
221
|
+
}
|
|
222
|
+
getTempOrder() {
|
|
223
|
+
var _a;
|
|
224
|
+
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
getOrderIdentity() {
|
|
228
|
+
if (!this.store.order)
|
|
229
|
+
return null;
|
|
230
|
+
return this.store.order.getOrderIdentity();
|
|
231
|
+
}
|
|
232
|
+
getOrderSnapshot() {
|
|
233
|
+
if (!this.store.order)
|
|
234
|
+
return null;
|
|
235
|
+
return this.store.order.getOrderSnapshot();
|
|
236
|
+
}
|
|
237
|
+
getOrderSyncState() {
|
|
238
|
+
if (!this.store.order)
|
|
239
|
+
return "local";
|
|
240
|
+
return this.store.order.getOrderSyncState();
|
|
241
|
+
}
|
|
242
|
+
getOrderAmountSnapshot() {
|
|
243
|
+
if (!this.store.order)
|
|
244
|
+
return null;
|
|
245
|
+
return this.store.order.getOrderAmountSnapshot();
|
|
246
|
+
}
|
|
247
|
+
getTempOrderNote() {
|
|
248
|
+
if (!this.store.order)
|
|
249
|
+
return "";
|
|
250
|
+
return this.store.order.getTempOrderNote();
|
|
251
|
+
}
|
|
252
|
+
updateTempOrderNote(note) {
|
|
253
|
+
try {
|
|
254
|
+
if (!this.store.order)
|
|
255
|
+
throw new Error("order 模块未初始化");
|
|
256
|
+
const result = this.store.order.updateTempOrderNote(note);
|
|
257
|
+
return result;
|
|
258
|
+
} catch (error) {
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
updateOrderShopDiscount(amount) {
|
|
263
|
+
if (!this.store.order)
|
|
264
|
+
throw new Error("order 模块未初始化");
|
|
265
|
+
return this.store.order.updateTempOrderShopDiscount(amount);
|
|
266
|
+
}
|
|
267
|
+
ensureTempOrder() {
|
|
268
|
+
if (!this.store.order)
|
|
269
|
+
throw new Error("order 模块未初始化");
|
|
270
|
+
return this.store.order.ensureTempOrder();
|
|
271
|
+
}
|
|
272
|
+
// 主动创建临时订单;若已存在则直接返回已有订单
|
|
273
|
+
async addNewOrder() {
|
|
274
|
+
try {
|
|
275
|
+
if (!this.store.order)
|
|
276
|
+
throw new Error("order 模块未初始化");
|
|
277
|
+
const tempOrder = await this.store.order.addNewOrder();
|
|
278
|
+
return tempOrder;
|
|
279
|
+
} catch (error) {
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
async saveDraft() {
|
|
284
|
+
if (!this.store.order)
|
|
285
|
+
throw new Error("order 模块未初始化");
|
|
286
|
+
return this.store.order.saveDraft();
|
|
287
|
+
}
|
|
288
|
+
// 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
|
|
289
|
+
// 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
|
|
290
|
+
async restoreOrder() {
|
|
291
|
+
try {
|
|
292
|
+
if (!this.store.order) {
|
|
293
|
+
throw new Error("scanOrder 解决方案需要 order 模块支持");
|
|
294
|
+
}
|
|
295
|
+
const tempOrder = this.store.order.restoreOrder();
|
|
296
|
+
return tempOrder;
|
|
297
|
+
} catch (error) {
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
getOrderProducts() {
|
|
302
|
+
if (!this.store.order)
|
|
303
|
+
throw new Error("order 模块未初始化");
|
|
304
|
+
const products = this.store.order.getOrderProducts();
|
|
305
|
+
return products;
|
|
306
|
+
}
|
|
307
|
+
async getSummary() {
|
|
308
|
+
try {
|
|
309
|
+
if (!this.store.order)
|
|
310
|
+
throw new Error("order 模块未初始化");
|
|
311
|
+
const summary = await this.store.order.getOrderSummary();
|
|
312
|
+
return summary;
|
|
313
|
+
} catch (error) {
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
getDiscountList() {
|
|
318
|
+
if (!this.store.order)
|
|
319
|
+
return [];
|
|
320
|
+
return this.store.order.getDiscountList();
|
|
321
|
+
}
|
|
322
|
+
async scanPromotionCode(code, customerId) {
|
|
323
|
+
try {
|
|
324
|
+
if (!this.store.order)
|
|
325
|
+
throw new Error("order 模块未初始化");
|
|
326
|
+
const raw = await this.store.order.scanCode(code, customerId);
|
|
327
|
+
if (raw.isAvailable) {
|
|
328
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
329
|
+
this.store.order.persistTempOrder();
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
isAvailable: raw.isAvailable,
|
|
333
|
+
type: raw.type,
|
|
334
|
+
unavailableReason: raw.unavailableReason
|
|
335
|
+
};
|
|
336
|
+
} catch (error) {
|
|
337
|
+
throw error;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
// TODO 需要优化,这段逻辑太长了,里面应该有些历史遗留问题
|
|
341
|
+
async setDiscountSelected(params) {
|
|
342
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
343
|
+
try {
|
|
344
|
+
if (!this.store.order)
|
|
345
|
+
throw new Error("order 模块未初始化");
|
|
346
|
+
const list = this.store.order.getDiscountList();
|
|
347
|
+
const updated = list.map(
|
|
348
|
+
(d) => d.id === params.discountId ? {
|
|
349
|
+
...d,
|
|
350
|
+
isSelected: params.isSelected,
|
|
351
|
+
isManualSelect: !params.isSelected
|
|
352
|
+
} : d
|
|
353
|
+
);
|
|
354
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
355
|
+
const orderStore = this.store.order.store || {};
|
|
356
|
+
const discountModule = orderStore.discount;
|
|
357
|
+
const rulesModule = orderStore.rules;
|
|
358
|
+
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
359
|
+
let nextDiscountList = updated;
|
|
360
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
361
|
+
if (rulesModule) {
|
|
362
|
+
const result = rulesModule.calcDiscount(
|
|
363
|
+
{
|
|
364
|
+
productList: tempOrder.products,
|
|
365
|
+
discountList: updated,
|
|
366
|
+
holders,
|
|
367
|
+
isFormSubject: !!((_b = tempOrder.holder) == null ? void 0 : _b.type) && tempOrder.holder.type === "form"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
discountId: params.discountId,
|
|
371
|
+
isSelected: params.isSelected
|
|
372
|
+
}
|
|
373
|
+
) || { productList: tempOrder.products, discountList: updated };
|
|
374
|
+
if (result == null ? void 0 : result.productList) {
|
|
375
|
+
tempOrder.products = result.productList;
|
|
376
|
+
}
|
|
377
|
+
if (result == null ? void 0 : result.discountList) {
|
|
378
|
+
nextDiscountList = result.discountList;
|
|
379
|
+
if (!params.isSelected) {
|
|
380
|
+
const beforeSelectedIds = new Set(
|
|
381
|
+
updated.filter((d) => d.isSelected).map((d) => d.id)
|
|
382
|
+
);
|
|
383
|
+
for (const d of nextDiscountList) {
|
|
384
|
+
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
385
|
+
d.isSelected = false;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const selectedResourceIds = new Set(
|
|
392
|
+
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
393
|
+
);
|
|
394
|
+
for (const product of tempOrder.products) {
|
|
395
|
+
const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
|
|
396
|
+
const runtimeOrigin = productUid ? (_f = (_e = (_d = tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[productUid]) == null ? void 0 : _f.origin : void 0;
|
|
397
|
+
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || ((_g = product.metadata) == null ? void 0 : _g.is_manual_discount))
|
|
398
|
+
continue;
|
|
399
|
+
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
400
|
+
var _a2;
|
|
401
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
402
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
403
|
+
});
|
|
404
|
+
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
405
|
+
(sum, pd) => sum + (pd.amount || 0),
|
|
406
|
+
0
|
|
407
|
+
);
|
|
408
|
+
const optionSum = (0, import_utils.sumOptionUnitPrice)(product.product_option_item);
|
|
409
|
+
const sourcePrice = ((_h = product.metadata) == null ? void 0 : _h.source_product_price) ?? (((_i = product.metadata) == null ? void 0 : _i.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
410
|
+
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
411
|
+
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
412
|
+
if (product.metadata) {
|
|
413
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
414
|
+
product.metadata.price_schema_version = 2;
|
|
415
|
+
}
|
|
416
|
+
product.selling_price = (0, import_utils.composeLinePrice)({
|
|
417
|
+
mainPrice: newMainSellingPrice,
|
|
418
|
+
bundle: product.product_bundle
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
422
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
423
|
+
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
424
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
425
|
+
this.store.order.persistTempOrder();
|
|
426
|
+
} catch (error) {
|
|
427
|
+
throw error;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
async submitScanOrder(params) {
|
|
431
|
+
return this.submitSalesOrder(params);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* 提交当前 Sales 订单。
|
|
435
|
+
*
|
|
436
|
+
* PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
|
|
437
|
+
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
438
|
+
*/
|
|
439
|
+
async submitSalesOrder(params) {
|
|
440
|
+
var _a, _b, _c, _d;
|
|
441
|
+
if (!this.store.order) {
|
|
442
|
+
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
443
|
+
}
|
|
444
|
+
this.store.order.persistTempOrder();
|
|
445
|
+
const submitParams = {
|
|
446
|
+
cacheId: this.cacheId,
|
|
447
|
+
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
448
|
+
businessCode: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
449
|
+
channel: (_c = this.otherParams) == null ? void 0 : _c.channel,
|
|
450
|
+
type: (_d = this.otherParams) == null ? void 0 : _d.type,
|
|
451
|
+
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
452
|
+
...(params == null ? void 0 : params.paymentStatus) !== void 0 ? { paymentStatus: params.paymentStatus } : {},
|
|
453
|
+
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
454
|
+
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
455
|
+
};
|
|
456
|
+
return this.store.order.submitTempOrder(submitParams);
|
|
457
|
+
}
|
|
458
|
+
async syncPaymentsToOrder(params) {
|
|
459
|
+
if (!this.store.order)
|
|
460
|
+
throw new Error("order 模块未初始化");
|
|
461
|
+
return this.store.order.syncPaymentsToOrder(params);
|
|
462
|
+
}
|
|
463
|
+
/** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
464
|
+
getOrderPayments() {
|
|
465
|
+
if (!this.store.order)
|
|
466
|
+
return [];
|
|
467
|
+
return this.store.order.getOrderPayments();
|
|
468
|
+
}
|
|
469
|
+
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
470
|
+
setOrderPayments(payments) {
|
|
471
|
+
if (!this.store.order)
|
|
472
|
+
throw new Error("order 模块未初始化");
|
|
473
|
+
return this.store.order.setOrderPayments(payments);
|
|
474
|
+
}
|
|
475
|
+
/** 追加单个支付项到当前订单。 */
|
|
476
|
+
addOrderPayment(payment) {
|
|
477
|
+
if (!this.store.order)
|
|
478
|
+
throw new Error("order 模块未初始化");
|
|
479
|
+
return this.store.order.addOrderPayment(payment);
|
|
480
|
+
}
|
|
481
|
+
/** 更新当前订单中的指定支付项。 */
|
|
482
|
+
updateOrderPayment(paymentIdentity, updates) {
|
|
483
|
+
if (!this.store.order)
|
|
484
|
+
throw new Error("order 模块未初始化");
|
|
485
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates);
|
|
486
|
+
}
|
|
487
|
+
/** 删除当前订单中的指定支付项。 */
|
|
488
|
+
deleteOrderPayment(paymentIdentity) {
|
|
489
|
+
if (!this.store.order)
|
|
490
|
+
throw new Error("order 模块未初始化");
|
|
491
|
+
return this.store.order.deleteOrderPayment(paymentIdentity);
|
|
492
|
+
}
|
|
493
|
+
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
494
|
+
updateVoucherOrderPayments(payments) {
|
|
495
|
+
if (!this.store.order)
|
|
496
|
+
throw new Error("order 模块未初始化");
|
|
497
|
+
return this.store.order.updateVoucherOrderPayments(payments);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* 更新当前订单客户字段。
|
|
501
|
+
*
|
|
502
|
+
* 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
|
|
503
|
+
* 调用方通过 onCustomerChange 回调完成。
|
|
504
|
+
*/
|
|
505
|
+
updateOrderCustomer(customer) {
|
|
506
|
+
if (!this.store.order)
|
|
507
|
+
throw new Error("order 模块未初始化");
|
|
508
|
+
const result = this.store.order.updateTempOrderCustomer(customer);
|
|
509
|
+
this.store.order.recalculateSummary({ createIfMissing: true });
|
|
510
|
+
this.store.order.persistTempOrder();
|
|
511
|
+
return result;
|
|
512
|
+
}
|
|
513
|
+
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
514
|
+
async getPaymentMethodsAsync() {
|
|
515
|
+
const response = await this.request.get("/pay/custom-payment/all");
|
|
516
|
+
return (response == null ? void 0 : response.data) || [];
|
|
517
|
+
}
|
|
518
|
+
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
519
|
+
roundAmount(params) {
|
|
520
|
+
const amount = new import_decimal.default(params.amount || 0);
|
|
521
|
+
const interval = new import_decimal.default(params.interval || 0.05);
|
|
522
|
+
const rule = params.rule || "standard_rounding";
|
|
523
|
+
const quotient = amount.div(interval);
|
|
524
|
+
let roundedQuotient;
|
|
525
|
+
if (rule === "always_up") {
|
|
526
|
+
roundedQuotient = quotient.ceil();
|
|
527
|
+
} else if (rule === "always_down") {
|
|
528
|
+
roundedQuotient = quotient.floor();
|
|
529
|
+
} else if (rule === "standard_down") {
|
|
530
|
+
roundedQuotient = quotient.toDecimalPlaces(0, import_decimal.default.ROUND_HALF_DOWN);
|
|
531
|
+
} else {
|
|
532
|
+
roundedQuotient = quotient.toDecimalPlaces(0, import_decimal.default.ROUND_HALF_UP);
|
|
533
|
+
}
|
|
534
|
+
const roundedAmount = roundedQuotient.times(interval).toDecimalPlaces(2);
|
|
535
|
+
return {
|
|
536
|
+
originalAmount: amount.toFixed(2),
|
|
537
|
+
roundedAmount: roundedAmount.toFixed(2),
|
|
538
|
+
roundingDifference: roundedAmount.minus(amount).toFixed(2)
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* 发送支付链接。
|
|
543
|
+
*
|
|
544
|
+
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
545
|
+
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
546
|
+
*/
|
|
547
|
+
async sendCustomerPayLink(params) {
|
|
548
|
+
var _a, _b;
|
|
549
|
+
if (!this.store.order)
|
|
550
|
+
throw new Error("order 模块未初始化");
|
|
551
|
+
let orderIds = params.order_ids || params.orderIds || [];
|
|
552
|
+
if (!orderIds.length || params.submitBeforeSend) {
|
|
553
|
+
const submitResult = await this.submitSalesOrder({
|
|
554
|
+
smallTicketDataFlag: 1
|
|
555
|
+
});
|
|
556
|
+
const orderId = ((_a = submitResult == null ? void 0 : submitResult.data) == null ? void 0 : _a.order_id) ?? (submitResult == null ? void 0 : submitResult.order_id) ?? ((_b = submitResult == null ? void 0 : submitResult.data) == null ? void 0 : _b.id) ?? (submitResult == null ? void 0 : submitResult.id);
|
|
557
|
+
if (!orderId) {
|
|
558
|
+
throw new Error("本地订单提交云端失败,无法发送支付链接");
|
|
559
|
+
}
|
|
560
|
+
orderIds = [orderId];
|
|
561
|
+
}
|
|
562
|
+
return this.store.order.sendCustomerPayLink({
|
|
563
|
+
emails: params.emails,
|
|
564
|
+
notify_action: params.notify_action,
|
|
565
|
+
order_ids: orderIds
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
async addProductToOrder(product, booking) {
|
|
569
|
+
try {
|
|
570
|
+
if (!this.store.order)
|
|
571
|
+
throw new Error("order 模块未初始化");
|
|
572
|
+
const products = await this.store.order.addProductToOrder(product, booking);
|
|
573
|
+
return products;
|
|
574
|
+
} catch (error) {
|
|
575
|
+
throw error;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
async updateProductInOrder(params) {
|
|
579
|
+
try {
|
|
580
|
+
if (!this.store.order)
|
|
581
|
+
throw new Error("order 模块未初始化");
|
|
582
|
+
const products = await this.store.order.updateProductInOrder(params);
|
|
583
|
+
return products;
|
|
584
|
+
} catch (error) {
|
|
585
|
+
throw error;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
590
|
+
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
591
|
+
*/
|
|
592
|
+
async setOrderProductLineNote(identity, note) {
|
|
593
|
+
try {
|
|
594
|
+
const params = {
|
|
595
|
+
product_id: identity.product_id,
|
|
596
|
+
product_variant_id: identity.product_variant_id,
|
|
597
|
+
updates: { note: String(note || "") }
|
|
598
|
+
};
|
|
599
|
+
if (identity.unique_identification_number !== void 0) {
|
|
600
|
+
params.unique_identification_number = identity.unique_identification_number;
|
|
601
|
+
}
|
|
602
|
+
if (identity.product_option_item !== void 0) {
|
|
603
|
+
params.product_option_item = identity.product_option_item;
|
|
604
|
+
}
|
|
605
|
+
if (identity.product_bundle !== void 0)
|
|
606
|
+
params.product_bundle = identity.product_bundle;
|
|
607
|
+
const products = await this.updateProductInOrder(params);
|
|
608
|
+
return products;
|
|
609
|
+
} catch (error) {
|
|
610
|
+
throw error;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
async removeProductFromOrder(identity) {
|
|
614
|
+
try {
|
|
615
|
+
if (!this.store.order)
|
|
616
|
+
throw new Error("order 模块未初始化");
|
|
617
|
+
const products = await this.store.order.removeProductFromOrder(identity);
|
|
618
|
+
return products;
|
|
619
|
+
} catch (error) {
|
|
620
|
+
throw error;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
// 获取商品列表
|
|
624
|
+
// TODO 需要跟 webpos 内的对齐一下
|
|
625
|
+
async getProductList() {
|
|
626
|
+
var _a, _b, _c;
|
|
627
|
+
const menu_list_ids = ((_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"].map((n) => Number(n.value))) || [];
|
|
628
|
+
try {
|
|
629
|
+
const res = await ((_c = this.store.products) == null ? void 0 : _c.loadProducts({
|
|
630
|
+
menu_list_ids,
|
|
631
|
+
cacheId: this.cacheId,
|
|
632
|
+
schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
633
|
+
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
634
|
+
}));
|
|
635
|
+
return res;
|
|
636
|
+
} catch (error) {
|
|
637
|
+
throw error;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
getOtherParams() {
|
|
641
|
+
return this.otherParams;
|
|
642
|
+
}
|
|
643
|
+
async setOtherParams(params, { cover = false } = {}) {
|
|
644
|
+
if (cover) {
|
|
645
|
+
this.otherParams = params;
|
|
646
|
+
} else {
|
|
647
|
+
this.otherParams = { ...this.otherParams, ...params };
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
652
|
+
0 && (module.exports = {
|
|
653
|
+
BaseSalesImpl,
|
|
654
|
+
...require("./types")
|
|
655
|
+
});
|