@pisell/pisellos 2.3.214 → 2.3.215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +12 -0
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/SalesSummary/index.d.ts +3 -0
- package/dist/modules/SalesSummary/index.js +104 -56
- package/dist/solution/BaseSales/index.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +47 -37
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +10 -0
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/SalesSummary/index.d.ts +3 -0
- package/lib/modules/SalesSummary/index.js +36 -15
- package/lib/solution/BaseSales/index.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -304,6 +304,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
304
304
|
ensureTempOrder(): OrderTempOrder;
|
|
305
305
|
restoreOrder(): OrderTempOrder;
|
|
306
306
|
getTempOrder(): OrderTempOrder | null;
|
|
307
|
+
/** 真实支付前固定本地创建时间;重试、恢复及后续付款沿用同一时间,不触发提交。 */
|
|
308
|
+
ensureOrderCreatedAt(): string;
|
|
307
309
|
replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
|
|
308
310
|
getOrderIdentity(): OrderIdentitySnapshot | null;
|
|
309
311
|
getOrderSyncState(): OrderSyncState;
|
|
@@ -3448,6 +3448,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3448
3448
|
value: function getTempOrder() {
|
|
3449
3449
|
return this.orderReplacement ? this.orderReplacement.state.tempOrder : this.store.tempOrder;
|
|
3450
3450
|
}
|
|
3451
|
+
|
|
3452
|
+
/** 真实支付前固定本地创建时间;重试、恢复及后续付款沿用同一时间,不触发提交。 */
|
|
3453
|
+
}, {
|
|
3454
|
+
key: "ensureOrderCreatedAt",
|
|
3455
|
+
value: function ensureOrderCreatedAt() {
|
|
3456
|
+
var tempOrder = this.ensureTempOrder();
|
|
3457
|
+
if (!tempOrder.created_at) {
|
|
3458
|
+
tempOrder.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
3459
|
+
this.persistTempOrder();
|
|
3460
|
+
}
|
|
3461
|
+
return tempOrder.created_at;
|
|
3462
|
+
}
|
|
3451
3463
|
}, {
|
|
3452
3464
|
key: "replaceTempOrder",
|
|
3453
3465
|
value: function () {
|
|
@@ -974,6 +974,8 @@ export interface OrderModuleAPI {
|
|
|
974
974
|
removeProductsFromOrder: (identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
|
|
975
975
|
/** 在显式开启时保存当前 tempOrder 的 sessionStorage 会话快照。 */
|
|
976
976
|
persistTempOrder: () => void;
|
|
977
|
+
/** 仅在缺失时固定本地订单创建时间,不触发云端提交。 */
|
|
978
|
+
ensureOrderCreatedAt: () => string;
|
|
977
979
|
/**
|
|
978
980
|
* 删除当前 cacheId 的 tempOrder 会话快照,并阻止当前模块实例再次写入。
|
|
979
981
|
* 新模块实例初始化时会按 otherParams 重新启用持久化。
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -11,6 +11,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
11
11
|
private surchargeListModuleName;
|
|
12
12
|
private otherParams;
|
|
13
13
|
private surchargeListChannel;
|
|
14
|
+
private surchargeLoads;
|
|
14
15
|
constructor(name?: string, version?: string);
|
|
15
16
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
17
|
/**
|
|
@@ -22,6 +23,8 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
22
23
|
updateOtherParams(params: Record<string, any>): Promise<void>;
|
|
23
24
|
private resolveChannel;
|
|
24
25
|
getSurchargeList(channel?: string): Promise<void>;
|
|
26
|
+
private loadSurcharges;
|
|
27
|
+
private fetchSurcharges;
|
|
25
28
|
private getAppData;
|
|
26
29
|
private getTaxConfig;
|
|
27
30
|
getSummary(params: {
|
|
@@ -46,6 +46,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
46
46
|
_defineProperty(_assertThisInitialized(_this), "surchargeListModuleName", 'surchargeList');
|
|
47
47
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
48
48
|
_defineProperty(_assertThisInitialized(_this), "surchargeListChannel", DEFAULT_SURCHARGE_CHANNEL);
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "surchargeLoads", new Map());
|
|
49
50
|
return _this;
|
|
50
51
|
}
|
|
51
52
|
_createClass(SalesSummaryModule, [{
|
|
@@ -61,6 +62,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
61
62
|
this.appPlugin = this.core.getPlugin('app');
|
|
62
63
|
this.request = this.core.getPlugin('request');
|
|
63
64
|
this.otherParams = options.otherParams || {};
|
|
65
|
+
this.surchargeLoads = new Map();
|
|
64
66
|
this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
|
|
65
67
|
this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
|
|
66
68
|
this.surchargeListModuleName = ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.surchargeListModuleName) || 'surchargeList';
|
|
@@ -69,14 +71,14 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
69
71
|
// throw new Error('SalesSummaryModule 需要 app 插件支持');
|
|
70
72
|
// }
|
|
71
73
|
if (this.request) {
|
|
72
|
-
_context.next =
|
|
74
|
+
_context.next = 11;
|
|
73
75
|
break;
|
|
74
76
|
}
|
|
75
77
|
throw new Error('SalesSummaryModule 需要 request 插件支持');
|
|
76
|
-
case
|
|
77
|
-
_context.next =
|
|
78
|
+
case 11:
|
|
79
|
+
_context.next = 13;
|
|
78
80
|
return this.getSurchargeList();
|
|
79
|
-
case
|
|
81
|
+
case 13:
|
|
80
82
|
case "end":
|
|
81
83
|
return _context.stop();
|
|
82
84
|
}
|
|
@@ -97,23 +99,25 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
97
99
|
key: "updateOtherParams",
|
|
98
100
|
value: (function () {
|
|
99
101
|
var _updateOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
100
|
-
var
|
|
102
|
+
var _params$shopId, _this$otherParams$sho, _params$tenantId, _this$otherParams$ten;
|
|
103
|
+
var previousChannel, nextSurchargeListModuleName, nextChannel, sourceChanged;
|
|
101
104
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
102
105
|
while (1) switch (_context2.prev = _context2.next) {
|
|
103
106
|
case 0:
|
|
104
107
|
previousChannel = this.resolveChannel();
|
|
105
108
|
nextSurchargeListModuleName = (params === null || params === void 0 ? void 0 : params.surchargeListModuleName) || 'surchargeList';
|
|
106
109
|
nextChannel = this.resolveChannel(params);
|
|
107
|
-
|
|
110
|
+
sourceChanged = nextSurchargeListModuleName !== this.surchargeListModuleName || ((_params$shopId = params === null || params === void 0 ? void 0 : params.shopId) !== null && _params$shopId !== void 0 ? _params$shopId : params === null || params === void 0 ? void 0 : params.shop_id) !== ((_this$otherParams$sho = this.otherParams.shopId) !== null && _this$otherParams$sho !== void 0 ? _this$otherParams$sho : this.otherParams.shop_id) || ((_params$tenantId = params === null || params === void 0 ? void 0 : params.tenantId) !== null && _params$tenantId !== void 0 ? _params$tenantId : params === null || params === void 0 ? void 0 : params.tenant_id) !== ((_this$otherParams$ten = this.otherParams.tenantId) !== null && _this$otherParams$ten !== void 0 ? _this$otherParams$ten : this.otherParams.tenant_id);
|
|
108
111
|
this.otherParams = params || {};
|
|
109
112
|
this.surchargeListModuleName = nextSurchargeListModuleName;
|
|
110
|
-
if (
|
|
111
|
-
|
|
113
|
+
if (sourceChanged) this.surchargeLoads = new Map();
|
|
114
|
+
if (!(sourceChanged || nextChannel !== previousChannel)) {
|
|
115
|
+
_context2.next = 10;
|
|
112
116
|
break;
|
|
113
117
|
}
|
|
114
|
-
_context2.next =
|
|
118
|
+
_context2.next = 10;
|
|
115
119
|
return this.getSurchargeList(nextChannel);
|
|
116
|
-
case
|
|
120
|
+
case 10:
|
|
117
121
|
case "end":
|
|
118
122
|
return _context2.stop();
|
|
119
123
|
}
|
|
@@ -135,57 +139,91 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
135
139
|
value: function () {
|
|
136
140
|
var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
137
141
|
var channel,
|
|
138
|
-
surchargeListModule,
|
|
139
|
-
surchargeList,
|
|
140
142
|
_args3 = arguments;
|
|
141
143
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
142
144
|
while (1) switch (_context3.prev = _context3.next) {
|
|
143
145
|
case 0:
|
|
144
146
|
channel = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : this.resolveChannel();
|
|
145
|
-
_context3.
|
|
147
|
+
_context3.next = 3;
|
|
148
|
+
return this.loadSurcharges(channel);
|
|
149
|
+
case 3:
|
|
150
|
+
case "end":
|
|
151
|
+
return _context3.stop();
|
|
152
|
+
}
|
|
153
|
+
}, _callee3, this);
|
|
154
|
+
}));
|
|
155
|
+
function getSurchargeList() {
|
|
156
|
+
return _getSurchargeList.apply(this, arguments);
|
|
157
|
+
}
|
|
158
|
+
return getSurchargeList;
|
|
159
|
+
}()
|
|
160
|
+
}, {
|
|
161
|
+
key: "loadSurcharges",
|
|
162
|
+
value: function loadSurcharges(channel) {
|
|
163
|
+
var _this2 = this;
|
|
164
|
+
this.surchargeListChannel = channel;
|
|
165
|
+
var loads = this.surchargeLoads;
|
|
166
|
+
var pending = loads.get(channel);
|
|
167
|
+
if (pending) return pending;
|
|
168
|
+
|
|
169
|
+
// The core exposes the summary module while initialization is still pending.
|
|
170
|
+
// All calculations for this channel must wait for the same configuration, even when it is empty.
|
|
171
|
+
var load = this.fetchSurcharges(channel).then(function (list) {
|
|
172
|
+
loads.delete(channel);
|
|
173
|
+
if (loads === _this2.surchargeLoads && channel === _this2.surchargeListChannel) {
|
|
174
|
+
_this2.store.surchargeList = list;
|
|
175
|
+
}
|
|
176
|
+
return list;
|
|
177
|
+
});
|
|
178
|
+
loads.set(channel, load);
|
|
179
|
+
return load;
|
|
180
|
+
}
|
|
181
|
+
}, {
|
|
182
|
+
key: "fetchSurcharges",
|
|
183
|
+
value: function () {
|
|
184
|
+
var _fetchSurcharges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(channel) {
|
|
185
|
+
var surchargeListModule, surchargeList;
|
|
186
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
187
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
188
|
+
case 0:
|
|
189
|
+
_context4.prev = 0;
|
|
146
190
|
surchargeListModule = this.core.getModule(this.surchargeListModuleName);
|
|
147
191
|
if (!(surchargeListModule !== null && surchargeListModule !== void 0 && surchargeListModule.getSurchargeList)) {
|
|
148
|
-
|
|
192
|
+
_context4.next = 6;
|
|
149
193
|
break;
|
|
150
194
|
}
|
|
151
|
-
|
|
195
|
+
_context4.next = 5;
|
|
152
196
|
return surchargeListModule.getSurchargeList({
|
|
153
197
|
channel: channel
|
|
154
198
|
});
|
|
199
|
+
case 5:
|
|
200
|
+
return _context4.abrupt("return", _context4.sent);
|
|
155
201
|
case 6:
|
|
156
|
-
|
|
157
|
-
this.surchargeListChannel = channel;
|
|
158
|
-
return _context3.abrupt("return");
|
|
159
|
-
case 9:
|
|
160
|
-
_context3.next = 11;
|
|
202
|
+
_context4.next = 8;
|
|
161
203
|
return this.request.get('/order/custom-surcharge/available/v2', {
|
|
162
204
|
channel: channel,
|
|
163
205
|
is_assemble_product_data: 1,
|
|
164
206
|
is_assemble_schedule_data: 1,
|
|
165
207
|
with: ['relationSchedule']
|
|
166
208
|
});
|
|
167
|
-
case
|
|
168
|
-
surchargeList =
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
209
|
+
case 8:
|
|
210
|
+
surchargeList = _context4.sent;
|
|
211
|
+
return _context4.abrupt("return", (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || []);
|
|
212
|
+
case 12:
|
|
213
|
+
_context4.prev = 12;
|
|
214
|
+
_context4.t0 = _context4["catch"](0);
|
|
215
|
+
console.warn('[SalesSummaryModule] 加载附加费配置失败', _context4.t0);
|
|
216
|
+
return _context4.abrupt("return", []);
|
|
173
217
|
case 16:
|
|
174
|
-
_context3.prev = 16;
|
|
175
|
-
_context3.t0 = _context3["catch"](1);
|
|
176
|
-
console.warn('[SalesSummaryModule] 加载附加费配置失败', _context3.t0);
|
|
177
|
-
this.store.surchargeList = [];
|
|
178
|
-
this.surchargeListChannel = channel;
|
|
179
|
-
case 21:
|
|
180
218
|
case "end":
|
|
181
|
-
return
|
|
219
|
+
return _context4.stop();
|
|
182
220
|
}
|
|
183
|
-
},
|
|
221
|
+
}, _callee4, this, [[0, 12]]);
|
|
184
222
|
}));
|
|
185
|
-
function
|
|
186
|
-
return
|
|
223
|
+
function fetchSurcharges(_x4) {
|
|
224
|
+
return _fetchSurcharges.apply(this, arguments);
|
|
187
225
|
}
|
|
188
|
-
return
|
|
226
|
+
return fetchSurcharges;
|
|
189
227
|
}()
|
|
190
228
|
}, {
|
|
191
229
|
key: "getAppData",
|
|
@@ -211,28 +249,36 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
211
249
|
}, {
|
|
212
250
|
key: "getSummary",
|
|
213
251
|
value: function () {
|
|
214
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
215
|
-
var _this$otherParams2,
|
|
216
|
-
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, _params$virtualSettle, virtualSettlementMode, summaryChannel, taxConfig, fatherModuleName, scheduleModuleName, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
217
|
-
return _regeneratorRuntime().wrap(function
|
|
218
|
-
while (1) switch (
|
|
252
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
253
|
+
var _this$otherParams2, _surchargeList$map, _ref;
|
|
254
|
+
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, _params$virtualSettle, virtualSettlementMode, summaryChannel, loads, surchargeList, taxConfig, fatherModuleName, scheduleModuleName, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
255
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
256
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
219
257
|
case 0:
|
|
220
258
|
_params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount, channel = params.channel, _params$virtualSettle = params.virtualSettlementMode, virtualSettlementMode = _params$virtualSettle === void 0 ? false : _params$virtualSettle;
|
|
221
259
|
summaryChannel = channel || this.resolveChannel();
|
|
222
|
-
|
|
223
|
-
|
|
260
|
+
loads = this.surchargeLoads;
|
|
261
|
+
if (!(loads.has(summaryChannel) || summaryChannel !== this.surchargeListChannel)) {
|
|
262
|
+
_context5.next = 9;
|
|
224
263
|
break;
|
|
225
264
|
}
|
|
226
|
-
|
|
227
|
-
return this.
|
|
228
|
-
case
|
|
265
|
+
_context5.next = 6;
|
|
266
|
+
return this.loadSurcharges(summaryChannel);
|
|
267
|
+
case 6:
|
|
268
|
+
_context5.t0 = _context5.sent;
|
|
269
|
+
_context5.next = 10;
|
|
270
|
+
break;
|
|
271
|
+
case 9:
|
|
272
|
+
_context5.t0 = this.store.surchargeList;
|
|
273
|
+
case 10:
|
|
274
|
+
surchargeList = _context5.t0;
|
|
229
275
|
taxConfig = this.getTaxConfig();
|
|
230
276
|
fatherModuleName = ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.fatherModule) || this.name.replace(/_salesSummary$/, '');
|
|
231
277
|
scheduleModuleName = "".concat(fatherModuleName, "_schedule");
|
|
232
278
|
summarySchedule = this.core.getModule(scheduleModuleName);
|
|
233
|
-
needScheduleIds = ((
|
|
279
|
+
needScheduleIds = ((surchargeList === null || surchargeList === void 0 || (_surchargeList$map = surchargeList.map(function (item) {
|
|
234
280
|
return item.available_schedule_ids;
|
|
235
|
-
})) === null ||
|
|
281
|
+
})) === null || _surchargeList$map === void 0 ? void 0 : _surchargeList$map.flat()) || []).filter(function (id) {
|
|
236
282
|
return id !== undefined && id !== null && id !== '';
|
|
237
283
|
});
|
|
238
284
|
scheduleList = needScheduleIds.length > 0 ? summarySchedule === null || summarySchedule === void 0 ? void 0 : summarySchedule.getScheduleListByIds(needScheduleIds) : [];
|
|
@@ -254,7 +300,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
300
|
products: products,
|
|
255
301
|
isPriceIncludeTax: (_ref = isPriceIncludeTax !== null && isPriceIncludeTax !== void 0 ? isPriceIncludeTax : taxConfig.isPriceIncludeTax) !== null && _ref !== void 0 ? _ref : 1,
|
|
256
302
|
taxRate: taxRate !== null && taxRate !== void 0 ? taxRate : taxConfig.taxRate,
|
|
257
|
-
surchargeList:
|
|
303
|
+
surchargeList: surchargeList,
|
|
258
304
|
scheduleById: scheduleById,
|
|
259
305
|
isInScheduleByDate: ScheduleModule.isInScheduleByDate,
|
|
260
306
|
shopDiscount: shopDiscount,
|
|
@@ -265,15 +311,17 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
265
311
|
tax_rate: taxRate !== null && taxRate !== void 0 ? taxRate : taxConfig.taxRate,
|
|
266
312
|
tax_country_code: taxConfig.taxCountryCode || ''
|
|
267
313
|
});
|
|
268
|
-
this.
|
|
269
|
-
|
|
270
|
-
|
|
314
|
+
if (loads === this.surchargeLoads && summaryChannel === this.surchargeListChannel) {
|
|
315
|
+
this.store.summary = summaryWithTaxMeta;
|
|
316
|
+
}
|
|
317
|
+
return _context5.abrupt("return", summaryWithTaxMeta);
|
|
318
|
+
case 23:
|
|
271
319
|
case "end":
|
|
272
|
-
return
|
|
320
|
+
return _context5.stop();
|
|
273
321
|
}
|
|
274
|
-
},
|
|
322
|
+
}, _callee5, this);
|
|
275
323
|
}));
|
|
276
|
-
function getSummary(
|
|
324
|
+
function getSummary(_x5) {
|
|
277
325
|
return _getSummary.apply(this, arguments);
|
|
278
326
|
}
|
|
279
327
|
return getSummary;
|
|
@@ -276,6 +276,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
276
276
|
/** 获取附加费用(运费/服务费/税费等)。 */
|
|
277
277
|
getSurcharges(): ISalesSurcharge[];
|
|
278
278
|
getTempOrder(): OrderTempOrder | null;
|
|
279
|
+
/** 在真实支付前固定创建时间;只更新本地订单,已有时间不覆盖。 */
|
|
280
|
+
ensureOrderCreatedAt(): string;
|
|
279
281
|
getOrderSessionId(): string | null;
|
|
280
282
|
isOrderSessionCurrent(sessionId: string): boolean;
|
|
281
283
|
replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
|
|
@@ -2838,6 +2838,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2838
2838
|
var result = ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder()) || null;
|
|
2839
2839
|
return result;
|
|
2840
2840
|
}
|
|
2841
|
+
|
|
2842
|
+
/** 在真实支付前固定创建时间;只更新本地订单,已有时间不覆盖。 */
|
|
2843
|
+
}, {
|
|
2844
|
+
key: "ensureOrderCreatedAt",
|
|
2845
|
+
value: function ensureOrderCreatedAt() {
|
|
2846
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2847
|
+
return this.store.order.ensureOrderCreatedAt();
|
|
2848
|
+
}
|
|
2841
2849
|
}, {
|
|
2842
2850
|
key: "getOrderSessionId",
|
|
2843
2851
|
value: function getOrderSessionId() {
|
|
@@ -6761,7 +6769,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6761
6769
|
value: (function () {
|
|
6762
6770
|
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
|
|
6763
6771
|
var _this$store$order$get13, _params$actualPaidAmo, _this$otherParams42, _this$window, _this$window$postMess;
|
|
6764
|
-
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber,
|
|
6772
|
+
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, actualPaidAmount, changeAmount, shopWalletPassId, paymentTimestamp, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
6765
6773
|
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6766
6774
|
while (1) switch (_context67.prev = _context67.next) {
|
|
6767
6775
|
case 0:
|
|
@@ -6824,25 +6832,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6824
6832
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
6825
6833
|
beforePaymentStatus = (_this$store$order$get13 = this.store.order.getTempOrder()) === null || _this$store$order$get13 === void 0 ? void 0 : _this$store$order$get13.payment_status;
|
|
6826
6834
|
uniquePaymentNumber = createUuidV4();
|
|
6827
|
-
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6828
6835
|
actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
|
|
6829
6836
|
changeAmount = Number(params.changeAmount || 0);
|
|
6830
6837
|
shopWalletPassId = (_this$otherParams42 = this.otherParams) === null || _this$otherParams42 === void 0 ? void 0 : _this$otherParams42.shop_wallet_pass_id;
|
|
6831
6838
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
6832
|
-
_context67.next =
|
|
6839
|
+
_context67.next = 34;
|
|
6833
6840
|
break;
|
|
6834
6841
|
}
|
|
6835
6842
|
throw new Error('顾客实收现金不能小于支付金额');
|
|
6836
|
-
case
|
|
6843
|
+
case 34:
|
|
6837
6844
|
if (!this.isPickupTimingEnabled()) {
|
|
6838
|
-
_context67.next =
|
|
6845
|
+
_context67.next = 37;
|
|
6839
6846
|
break;
|
|
6840
6847
|
}
|
|
6841
|
-
_context67.next =
|
|
6848
|
+
_context67.next = 37;
|
|
6842
6849
|
return this.preparePickupTimingForCheckout({
|
|
6843
6850
|
freeze: true
|
|
6844
6851
|
});
|
|
6845
|
-
case
|
|
6852
|
+
case 37:
|
|
6853
|
+
this.ensureOrderCreatedAt();
|
|
6854
|
+
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6846
6855
|
(_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
|
|
6847
6856
|
module: 'till',
|
|
6848
6857
|
key: 'open_till',
|
|
@@ -6873,57 +6882,57 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6873
6882
|
var _item$metadata2;
|
|
6874
6883
|
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
6875
6884
|
});
|
|
6876
|
-
_context67.prev =
|
|
6877
|
-
_context67.next =
|
|
6885
|
+
_context67.prev = 42;
|
|
6886
|
+
_context67.next = 45;
|
|
6878
6887
|
return this.syncPaymentsToOrder({
|
|
6879
6888
|
payments: payments,
|
|
6880
6889
|
submitWhenPaid: true,
|
|
6881
6890
|
smallTicketDataFlag: 1,
|
|
6882
6891
|
confirmPendingVoucherPayments: true
|
|
6883
6892
|
});
|
|
6884
|
-
case
|
|
6893
|
+
case 45:
|
|
6885
6894
|
syncResult = _context67.sent;
|
|
6886
6895
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
6887
|
-
_context67.next =
|
|
6896
|
+
_context67.next = 48;
|
|
6888
6897
|
break;
|
|
6889
6898
|
}
|
|
6890
6899
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
6891
|
-
case
|
|
6900
|
+
case 48:
|
|
6892
6901
|
if (!this.store.payment) {
|
|
6893
|
-
_context67.next =
|
|
6902
|
+
_context67.next = 53;
|
|
6894
6903
|
break;
|
|
6895
6904
|
}
|
|
6896
6905
|
committed = this.getCommittedWalletAssets();
|
|
6897
6906
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
6898
|
-
_context67.next =
|
|
6907
|
+
_context67.next = 53;
|
|
6899
6908
|
return this.publishWalletAssetsState(walletState, 'local');
|
|
6900
|
-
case
|
|
6909
|
+
case 53:
|
|
6901
6910
|
return _context67.abrupt("return", {
|
|
6902
6911
|
payment: payment || {},
|
|
6903
6912
|
payments: this.store.order.getOrderPayments(),
|
|
6904
6913
|
syncResult: syncResult,
|
|
6905
6914
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
6906
6915
|
});
|
|
6907
|
-
case
|
|
6908
|
-
_context67.prev =
|
|
6909
|
-
_context67.t1 = _context67["catch"](
|
|
6916
|
+
case 56:
|
|
6917
|
+
_context67.prev = 56;
|
|
6918
|
+
_context67.t1 = _context67["catch"](42);
|
|
6910
6919
|
this.store.order.setOrderPayments(beforePayments);
|
|
6911
6920
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
6912
6921
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
6913
6922
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
6914
6923
|
this.store.order.persistTempOrder();
|
|
6915
6924
|
}
|
|
6916
|
-
_context67.next =
|
|
6925
|
+
_context67.next = 63;
|
|
6917
6926
|
return this.store.order.recalculateSummary({
|
|
6918
6927
|
createIfMissing: true
|
|
6919
6928
|
});
|
|
6920
|
-
case 62:
|
|
6921
|
-
throw _context67.t1;
|
|
6922
6929
|
case 63:
|
|
6930
|
+
throw _context67.t1;
|
|
6931
|
+
case 64:
|
|
6923
6932
|
case "end":
|
|
6924
6933
|
return _context67.stop();
|
|
6925
6934
|
}
|
|
6926
|
-
}, _callee67, this, [[
|
|
6935
|
+
}, _callee67, this, [[42, 56]]);
|
|
6927
6936
|
}));
|
|
6928
6937
|
function payCash(_x52) {
|
|
6929
6938
|
return _payCash.apply(this, arguments);
|
|
@@ -7003,6 +7012,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
7003
7012
|
case 22:
|
|
7004
7013
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
7005
7014
|
beforePaymentStatus = (_this$store$order$get15 = this.store.order.getTempOrder()) === null || _this$store$order$get15 === void 0 ? void 0 : _this$store$order$get15.payment_status;
|
|
7015
|
+
this.ensureOrderCreatedAt();
|
|
7006
7016
|
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
7007
7017
|
metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
|
|
7008
7018
|
unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
|
|
@@ -7035,57 +7045,57 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
7035
7045
|
var _item$metadata3;
|
|
7036
7046
|
return (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_payment_number) === metadata.unique_payment_number;
|
|
7037
7047
|
});
|
|
7038
|
-
_context68.prev =
|
|
7039
|
-
_context68.next =
|
|
7048
|
+
_context68.prev = 31;
|
|
7049
|
+
_context68.next = 34;
|
|
7040
7050
|
return this.syncPaymentsToOrder({
|
|
7041
7051
|
payments: payments,
|
|
7042
7052
|
submitWhenPaid: true,
|
|
7043
7053
|
smallTicketDataFlag: 1,
|
|
7044
7054
|
confirmPendingVoucherPayments: true
|
|
7045
7055
|
});
|
|
7046
|
-
case
|
|
7056
|
+
case 34:
|
|
7047
7057
|
syncResult = _context68.sent;
|
|
7048
7058
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
7049
|
-
_context68.next =
|
|
7059
|
+
_context68.next = 37;
|
|
7050
7060
|
break;
|
|
7051
7061
|
}
|
|
7052
7062
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
7053
|
-
case
|
|
7063
|
+
case 37:
|
|
7054
7064
|
if (!this.store.payment) {
|
|
7055
|
-
_context68.next =
|
|
7065
|
+
_context68.next = 42;
|
|
7056
7066
|
break;
|
|
7057
7067
|
}
|
|
7058
7068
|
committed = this.getCommittedWalletAssets();
|
|
7059
7069
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
7060
|
-
_context68.next =
|
|
7070
|
+
_context68.next = 42;
|
|
7061
7071
|
return this.publishWalletAssetsState(walletState, 'local');
|
|
7062
|
-
case
|
|
7072
|
+
case 42:
|
|
7063
7073
|
return _context68.abrupt("return", {
|
|
7064
7074
|
payment: payment || {},
|
|
7065
7075
|
payments: this.store.order.getOrderPayments(),
|
|
7066
7076
|
syncResult: syncResult,
|
|
7067
7077
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
7068
7078
|
});
|
|
7069
|
-
case
|
|
7070
|
-
_context68.prev =
|
|
7071
|
-
_context68.t0 = _context68["catch"](
|
|
7079
|
+
case 45:
|
|
7080
|
+
_context68.prev = 45;
|
|
7081
|
+
_context68.t0 = _context68["catch"](31);
|
|
7072
7082
|
this.store.order.setOrderPayments(beforePayments);
|
|
7073
7083
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
7074
7084
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
7075
7085
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
7076
7086
|
this.store.order.persistTempOrder();
|
|
7077
7087
|
}
|
|
7078
|
-
_context68.next =
|
|
7088
|
+
_context68.next = 52;
|
|
7079
7089
|
return this.store.order.recalculateSummary({
|
|
7080
7090
|
createIfMissing: true
|
|
7081
7091
|
});
|
|
7082
|
-
case 51:
|
|
7083
|
-
throw _context68.t0;
|
|
7084
7092
|
case 52:
|
|
7093
|
+
throw _context68.t0;
|
|
7094
|
+
case 53:
|
|
7085
7095
|
case "end":
|
|
7086
7096
|
return _context68.stop();
|
|
7087
7097
|
}
|
|
7088
|
-
}, _callee68, this, [[
|
|
7098
|
+
}, _callee68, this, [[31, 45]]);
|
|
7089
7099
|
}));
|
|
7090
7100
|
function commitPaymentMethodPayment(_x53) {
|
|
7091
7101
|
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"normal" | "
|
|
392
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
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; }
|
|
@@ -304,6 +304,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
304
304
|
ensureTempOrder(): OrderTempOrder;
|
|
305
305
|
restoreOrder(): OrderTempOrder;
|
|
306
306
|
getTempOrder(): OrderTempOrder | null;
|
|
307
|
+
/** 真实支付前固定本地创建时间;重试、恢复及后续付款沿用同一时间,不触发提交。 */
|
|
308
|
+
ensureOrderCreatedAt(): string;
|
|
307
309
|
replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
|
|
308
310
|
getOrderIdentity(): OrderIdentitySnapshot | null;
|
|
309
311
|
getOrderSyncState(): OrderSyncState;
|
|
@@ -2361,6 +2361,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2361
2361
|
getTempOrder() {
|
|
2362
2362
|
return this.orderReplacement ? this.orderReplacement.state.tempOrder : this.store.tempOrder;
|
|
2363
2363
|
}
|
|
2364
|
+
|
|
2365
|
+
/** 真实支付前固定本地创建时间;重试、恢复及后续付款沿用同一时间,不触发提交。 */
|
|
2366
|
+
ensureOrderCreatedAt() {
|
|
2367
|
+
const tempOrder = this.ensureTempOrder();
|
|
2368
|
+
if (!tempOrder.created_at) {
|
|
2369
|
+
tempOrder.created_at = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
|
|
2370
|
+
this.persistTempOrder();
|
|
2371
|
+
}
|
|
2372
|
+
return tempOrder.created_at;
|
|
2373
|
+
}
|
|
2364
2374
|
async replaceTempOrder(tempOrder, options) {
|
|
2365
2375
|
if (!(0, _utils.isTempOrder)(tempOrder)) {
|
|
2366
2376
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -974,6 +974,8 @@ export interface OrderModuleAPI {
|
|
|
974
974
|
removeProductsFromOrder: (identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
|
|
975
975
|
/** 在显式开启时保存当前 tempOrder 的 sessionStorage 会话快照。 */
|
|
976
976
|
persistTempOrder: () => void;
|
|
977
|
+
/** 仅在缺失时固定本地订单创建时间,不触发云端提交。 */
|
|
978
|
+
ensureOrderCreatedAt: () => string;
|
|
977
979
|
/**
|
|
978
980
|
* 删除当前 cacheId 的 tempOrder 会话快照,并阻止当前模块实例再次写入。
|
|
979
981
|
* 新模块实例初始化时会按 otherParams 重新启用持久化。
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -11,6 +11,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
11
11
|
private surchargeListModuleName;
|
|
12
12
|
private otherParams;
|
|
13
13
|
private surchargeListChannel;
|
|
14
|
+
private surchargeLoads;
|
|
14
15
|
constructor(name?: string, version?: string);
|
|
15
16
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
17
|
/**
|
|
@@ -22,6 +23,8 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
22
23
|
updateOtherParams(params: Record<string, any>): Promise<void>;
|
|
23
24
|
private resolveChannel;
|
|
24
25
|
getSurchargeList(channel?: string): Promise<void>;
|
|
26
|
+
private loadSurcharges;
|
|
27
|
+
private fetchSurcharges;
|
|
25
28
|
private getAppData;
|
|
26
29
|
private getTaxConfig;
|
|
27
30
|
getSummary(params: {
|
|
@@ -38,6 +38,7 @@ class SalesSummaryModule extends _BaseModule.BaseModule {
|
|
|
38
38
|
surchargeListModuleName = 'surchargeList';
|
|
39
39
|
otherParams = {};
|
|
40
40
|
surchargeListChannel = DEFAULT_SURCHARGE_CHANNEL;
|
|
41
|
+
surchargeLoads = new Map();
|
|
41
42
|
constructor(name, version) {
|
|
42
43
|
super(name, version);
|
|
43
44
|
}
|
|
@@ -47,6 +48,7 @@ class SalesSummaryModule extends _BaseModule.BaseModule {
|
|
|
47
48
|
this.appPlugin = this.core.getPlugin('app');
|
|
48
49
|
this.request = this.core.getPlugin('request');
|
|
49
50
|
this.otherParams = options.otherParams || {};
|
|
51
|
+
this.surchargeLoads = new Map();
|
|
50
52
|
this.store.surchargeList = options.initialState?.surchargeList || [];
|
|
51
53
|
this.store.summary = options.initialState?.summary || (0, _utils.createEmptySalesSummary)();
|
|
52
54
|
this.surchargeListModuleName = this.otherParams?.surchargeListModuleName || 'surchargeList';
|
|
@@ -70,10 +72,11 @@ class SalesSummaryModule extends _BaseModule.BaseModule {
|
|
|
70
72
|
const previousChannel = this.resolveChannel();
|
|
71
73
|
const nextSurchargeListModuleName = params?.surchargeListModuleName || 'surchargeList';
|
|
72
74
|
const nextChannel = this.resolveChannel(params);
|
|
73
|
-
const
|
|
75
|
+
const sourceChanged = nextSurchargeListModuleName !== this.surchargeListModuleName || (params?.shopId ?? params?.shop_id) !== (this.otherParams.shopId ?? this.otherParams.shop_id) || (params?.tenantId ?? params?.tenant_id) !== (this.otherParams.tenantId ?? this.otherParams.tenant_id);
|
|
74
76
|
this.otherParams = params || {};
|
|
75
77
|
this.surchargeListModuleName = nextSurchargeListModuleName;
|
|
76
|
-
if (
|
|
78
|
+
if (sourceChanged) this.surchargeLoads = new Map();
|
|
79
|
+
if (sourceChanged || nextChannel !== previousChannel) {
|
|
77
80
|
await this.getSurchargeList(nextChannel);
|
|
78
81
|
}
|
|
79
82
|
}
|
|
@@ -81,14 +84,33 @@ class SalesSummaryModule extends _BaseModule.BaseModule {
|
|
|
81
84
|
return params?.channel || DEFAULT_SURCHARGE_CHANNEL;
|
|
82
85
|
}
|
|
83
86
|
async getSurchargeList(channel = this.resolveChannel()) {
|
|
87
|
+
await this.loadSurcharges(channel);
|
|
88
|
+
}
|
|
89
|
+
loadSurcharges(channel) {
|
|
90
|
+
this.surchargeListChannel = channel;
|
|
91
|
+
const loads = this.surchargeLoads;
|
|
92
|
+
const pending = loads.get(channel);
|
|
93
|
+
if (pending) return pending;
|
|
94
|
+
|
|
95
|
+
// The core exposes the summary module while initialization is still pending.
|
|
96
|
+
// All calculations for this channel must wait for the same configuration, even when it is empty.
|
|
97
|
+
const load = this.fetchSurcharges(channel).then(list => {
|
|
98
|
+
loads.delete(channel);
|
|
99
|
+
if (loads === this.surchargeLoads && channel === this.surchargeListChannel) {
|
|
100
|
+
this.store.surchargeList = list;
|
|
101
|
+
}
|
|
102
|
+
return list;
|
|
103
|
+
});
|
|
104
|
+
loads.set(channel, load);
|
|
105
|
+
return load;
|
|
106
|
+
}
|
|
107
|
+
async fetchSurcharges(channel) {
|
|
84
108
|
try {
|
|
85
109
|
const surchargeListModule = this.core.getModule(this.surchargeListModuleName);
|
|
86
110
|
if (surchargeListModule?.getSurchargeList) {
|
|
87
|
-
|
|
111
|
+
return await surchargeListModule.getSurchargeList({
|
|
88
112
|
channel
|
|
89
113
|
});
|
|
90
|
-
this.surchargeListChannel = channel;
|
|
91
|
-
return;
|
|
92
114
|
}
|
|
93
115
|
const surchargeList = await this.request.get('/order/custom-surcharge/available/v2', {
|
|
94
116
|
channel,
|
|
@@ -96,12 +118,10 @@ class SalesSummaryModule extends _BaseModule.BaseModule {
|
|
|
96
118
|
is_assemble_schedule_data: 1,
|
|
97
119
|
with: ['relationSchedule']
|
|
98
120
|
});
|
|
99
|
-
|
|
100
|
-
this.surchargeListChannel = channel;
|
|
121
|
+
return surchargeList?.data || [];
|
|
101
122
|
} catch (error) {
|
|
102
123
|
console.warn('[SalesSummaryModule] 加载附加费配置失败', error);
|
|
103
|
-
|
|
104
|
-
this.surchargeListChannel = channel;
|
|
124
|
+
return [];
|
|
105
125
|
}
|
|
106
126
|
}
|
|
107
127
|
getAppData(key) {
|
|
@@ -130,14 +150,13 @@ class SalesSummaryModule extends _BaseModule.BaseModule {
|
|
|
130
150
|
virtualSettlementMode = false
|
|
131
151
|
} = params;
|
|
132
152
|
const summaryChannel = channel || this.resolveChannel();
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
153
|
+
const loads = this.surchargeLoads;
|
|
154
|
+
const surchargeList = loads.has(summaryChannel) || summaryChannel !== this.surchargeListChannel ? await this.loadSurcharges(summaryChannel) : this.store.surchargeList;
|
|
136
155
|
const taxConfig = this.getTaxConfig();
|
|
137
156
|
const fatherModuleName = this.otherParams?.fatherModule || this.name.replace(/_salesSummary$/, '');
|
|
138
157
|
const scheduleModuleName = `${fatherModuleName}_schedule`;
|
|
139
158
|
const summarySchedule = this.core.getModule(scheduleModuleName);
|
|
140
|
-
const needScheduleIds = (
|
|
159
|
+
const needScheduleIds = (surchargeList?.map(item => item.available_schedule_ids)?.flat() || []).filter(id => id !== undefined && id !== null && id !== '');
|
|
141
160
|
const scheduleList = needScheduleIds.length > 0 ? summarySchedule?.getScheduleListByIds(needScheduleIds) : [];
|
|
142
161
|
const scheduleById = {};
|
|
143
162
|
if (Array.isArray(scheduleList)) {
|
|
@@ -149,7 +168,7 @@ class SalesSummaryModule extends _BaseModule.BaseModule {
|
|
|
149
168
|
products,
|
|
150
169
|
isPriceIncludeTax: isPriceIncludeTax ?? taxConfig.isPriceIncludeTax ?? 1,
|
|
151
170
|
taxRate: taxRate ?? taxConfig.taxRate,
|
|
152
|
-
surchargeList
|
|
171
|
+
surchargeList,
|
|
153
172
|
scheduleById,
|
|
154
173
|
isInScheduleByDate: _Schedule.ScheduleModule.isInScheduleByDate,
|
|
155
174
|
shopDiscount,
|
|
@@ -161,7 +180,9 @@ class SalesSummaryModule extends _BaseModule.BaseModule {
|
|
|
161
180
|
tax_rate: taxRate ?? taxConfig.taxRate,
|
|
162
181
|
tax_country_code: taxConfig.taxCountryCode || ''
|
|
163
182
|
};
|
|
164
|
-
this.
|
|
183
|
+
if (loads === this.surchargeLoads && summaryChannel === this.surchargeListChannel) {
|
|
184
|
+
this.store.summary = summaryWithTaxMeta;
|
|
185
|
+
}
|
|
165
186
|
return summaryWithTaxMeta;
|
|
166
187
|
}
|
|
167
188
|
}
|
|
@@ -276,6 +276,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
276
276
|
/** 获取附加费用(运费/服务费/税费等)。 */
|
|
277
277
|
getSurcharges(): ISalesSurcharge[];
|
|
278
278
|
getTempOrder(): OrderTempOrder | null;
|
|
279
|
+
/** 在真实支付前固定创建时间;只更新本地订单,已有时间不覆盖。 */
|
|
280
|
+
ensureOrderCreatedAt(): string;
|
|
279
281
|
getOrderSessionId(): string | null;
|
|
280
282
|
isOrderSessionCurrent(sessionId: string): boolean;
|
|
281
283
|
replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
|
|
@@ -1926,6 +1926,12 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1926
1926
|
const result = this.store.order?.getTempOrder() || null;
|
|
1927
1927
|
return result;
|
|
1928
1928
|
}
|
|
1929
|
+
|
|
1930
|
+
/** 在真实支付前固定创建时间;只更新本地订单,已有时间不覆盖。 */
|
|
1931
|
+
ensureOrderCreatedAt() {
|
|
1932
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1933
|
+
return this.store.order.ensureOrderCreatedAt();
|
|
1934
|
+
}
|
|
1929
1935
|
getOrderSessionId() {
|
|
1930
1936
|
return this.store.order?.getOrderSessionId?.() || null;
|
|
1931
1937
|
}
|
|
@@ -4042,7 +4048,6 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4042
4048
|
const beforePayments = (0, _lodashEs.cloneDeep)(this.store.order.getOrderPayments());
|
|
4043
4049
|
const beforePaymentStatus = this.store.order.getTempOrder()?.payment_status;
|
|
4044
4050
|
const uniquePaymentNumber = (0, _utils.createUuidV4)();
|
|
4045
|
-
const paymentTimestamp = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
|
|
4046
4051
|
const actualPaidAmount = Number(params.actualPaidAmount ?? amount);
|
|
4047
4052
|
const changeAmount = Number(params.changeAmount || 0);
|
|
4048
4053
|
const shopWalletPassId = this.otherParams?.shop_wallet_pass_id;
|
|
@@ -4052,6 +4057,8 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4052
4057
|
if (this.isPickupTimingEnabled()) await this.preparePickupTimingForCheckout({
|
|
4053
4058
|
freeze: true
|
|
4054
4059
|
});
|
|
4060
|
+
this.ensureOrderCreatedAt();
|
|
4061
|
+
const paymentTimestamp = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
|
|
4055
4062
|
this.window?.interaction?.utils?.postMessageToApp?.({
|
|
4056
4063
|
module: 'till',
|
|
4057
4064
|
key: 'open_till',
|
|
@@ -4153,6 +4160,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4153
4160
|
}
|
|
4154
4161
|
const beforePayments = (0, _lodashEs.cloneDeep)(this.store.order.getOrderPayments());
|
|
4155
4162
|
const beforePaymentStatus = this.store.order.getTempOrder()?.payment_status;
|
|
4163
|
+
this.ensureOrderCreatedAt();
|
|
4156
4164
|
const paymentTimestamp = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
|
|
4157
4165
|
const metadata = {
|
|
4158
4166
|
...(params.metadata || {}),
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"normal" | "
|
|
392
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|