@pisell/pisellos 0.10.2 → 0.10.4
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/core/index.d.ts +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BaseModule.d.ts +1 -0
- package/dist/modules/BaseModule.js +24 -28
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +8 -0
- package/dist/modules/Order/index.d.ts +41 -10
- package/dist/modules/Order/index.js +943 -546
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +43 -2
- package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
- package/dist/modules/Order/utils.js +10 -6
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +79 -50
- package/dist/modules/Payment/types.d.ts +107 -28
- package/dist/modules/Payment/types.js +20 -3
- package/dist/modules/Payment/walletpass.d.ts +38 -1
- package/dist/modules/Payment/walletpass.js +917 -114
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/Rules/index.d.ts +3 -0
- package/dist/modules/Rules/index.js +130 -99
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.js +2084 -1188
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +70 -4
- package/dist/server/modules/order/index.js +1816 -728
- package/dist/server/modules/order/types.d.ts +25 -3
- package/dist/server/modules/order/types.js +7 -1
- package/dist/solution/BaseSales/index.d.ts +114 -14
- package/dist/solution/BaseSales/index.js +1848 -478
- package/dist/solution/BaseSales/types.d.ts +55 -1
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -16
- package/dist/solution/BookingTicket/index.js +138 -52
- package/dist/solution/BookingTicket/types.d.ts +1 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.js +392 -304
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +34 -24
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BaseModule.d.ts +1 -0
- package/lib/modules/BaseModule.js +24 -37
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +5 -0
- package/lib/modules/Order/index.d.ts +41 -10
- package/lib/modules/Order/index.js +322 -86
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +43 -2
- package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
- package/lib/modules/Order/utils.js +11 -4
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +34 -13
- package/lib/modules/Payment/types.d.ts +107 -28
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +38 -1
- package/lib/modules/Payment/walletpass.js +730 -21
- package/lib/modules/ProductList/index.js +9 -1
- package/lib/modules/Rules/index.d.ts +3 -0
- package/lib/modules/Rules/index.js +39 -10
- package/lib/server/index.d.ts +16 -0
- package/lib/server/index.js +677 -28
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +70 -4
- package/lib/server/modules/order/index.js +818 -69
- package/lib/server/modules/order/types.d.ts +25 -3
- package/lib/server/modules/order/types.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +114 -14
- package/lib/solution/BaseSales/index.js +907 -58
- package/lib/solution/BaseSales/types.d.ts +55 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -16
- package/lib/solution/BookingTicket/index.js +63 -9
- package/lib/solution/BookingTicket/types.d.ts +1 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.js +48 -2
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +13 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -191,210 +191,300 @@ export function applyGlobalScan(_x14, _x15, _x16) {
|
|
|
191
191
|
return _applyGlobalScan.apply(this, arguments);
|
|
192
192
|
}
|
|
193
193
|
function _applyGlobalScan() {
|
|
194
|
-
_applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
195
|
-
var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify,
|
|
196
|
-
return _regeneratorRuntime().wrap(function
|
|
197
|
-
while (1) switch (
|
|
194
|
+
_applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(host, formatted, bridge) {
|
|
195
|
+
var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify, _host$refreshWalletAs, _bridge$onNotify5, snapshot, scannedCustomerIsWalkIn, trySelectWalletAsset, _result$isAccepted, _walletSelection, result, walletSelection, _data$id, _promotionResult$isAc, promotionResult, list, _bridge$onNotify6, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify7, _data$order_id, _data$business_code, orderId, _bridge$onNotify8;
|
|
196
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
197
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
198
198
|
case 0:
|
|
199
199
|
searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode;
|
|
200
200
|
if (!(searchType === 'wallet')) {
|
|
201
|
-
|
|
201
|
+
_context5.next = 8;
|
|
202
202
|
break;
|
|
203
203
|
}
|
|
204
204
|
if (data) {
|
|
205
|
-
|
|
205
|
+
_context5.next = 5;
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
208
208
|
bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
209
|
-
return
|
|
209
|
+
return _context5.abrupt("return", {
|
|
210
210
|
status: 'failed',
|
|
211
211
|
reason: 'invalid_data'
|
|
212
212
|
});
|
|
213
213
|
case 5:
|
|
214
214
|
host.setOrderCustomer(data);
|
|
215
215
|
bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'success', 'pisell2.text.add-client-success');
|
|
216
|
-
return
|
|
216
|
+
return _context5.abrupt("return", {
|
|
217
217
|
status: 'success',
|
|
218
218
|
kind: 'customer'
|
|
219
219
|
});
|
|
220
220
|
case 8:
|
|
221
221
|
if (!(searchType === 'walletPass')) {
|
|
222
|
-
|
|
222
|
+
_context5.next = 42;
|
|
223
223
|
break;
|
|
224
224
|
}
|
|
225
|
-
if (data) {
|
|
226
|
-
_context4.next = 12;
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
230
|
-
return _context4.abrupt("return", {
|
|
231
|
-
status: 'failed',
|
|
232
|
-
reason: 'invalid_data'
|
|
233
|
-
});
|
|
234
|
-
case 12:
|
|
235
225
|
snapshot = host.getOrderCustomerSnapshot();
|
|
236
226
|
scannedCustomerIsWalkIn = isWalkInCustomer(data);
|
|
227
|
+
trySelectWalletAsset = /*#__PURE__*/function () {
|
|
228
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
229
|
+
var _bridge$onNotify4;
|
|
230
|
+
var walletResult, _bridge$onNotify3;
|
|
231
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
232
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
233
|
+
case 0:
|
|
234
|
+
if (host.scanWalletAsset) {
|
|
235
|
+
_context4.next = 2;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
return _context4.abrupt("return", null);
|
|
239
|
+
case 2:
|
|
240
|
+
_context4.next = 4;
|
|
241
|
+
return host.scanWalletAsset(scanCode).catch(function (error) {
|
|
242
|
+
console.warn('[GlobalScan] Wallet asset lookup failed', error);
|
|
243
|
+
return null;
|
|
244
|
+
});
|
|
245
|
+
case 4:
|
|
246
|
+
walletResult = _context4.sent;
|
|
247
|
+
if (walletResult) {
|
|
248
|
+
_context4.next = 7;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
return _context4.abrupt("return", null);
|
|
252
|
+
case 7:
|
|
253
|
+
if (!(walletResult.type !== 'normalCode' || !walletResult.asset)) {
|
|
254
|
+
_context4.next = 9;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
return _context4.abrupt("return", null);
|
|
258
|
+
case 9:
|
|
259
|
+
if (!walletResult.selected) {
|
|
260
|
+
_context4.next = 12;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'success');
|
|
264
|
+
return _context4.abrupt("return", {
|
|
265
|
+
status: 'success',
|
|
266
|
+
kind: 'promotion'
|
|
267
|
+
});
|
|
268
|
+
case 12:
|
|
269
|
+
// 已识别为 Wallet 支付资产但当前不可用:保留禁用展示,不回退优惠码。
|
|
270
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'fail', 'pisell2.text.goodpass.code-invalid-cart');
|
|
271
|
+
return _context4.abrupt("return", {
|
|
272
|
+
status: 'failed',
|
|
273
|
+
reason: 'invalid_data'
|
|
274
|
+
});
|
|
275
|
+
case 14:
|
|
276
|
+
case "end":
|
|
277
|
+
return _context4.stop();
|
|
278
|
+
}
|
|
279
|
+
}, _callee4);
|
|
280
|
+
}));
|
|
281
|
+
return function trySelectWalletAsset() {
|
|
282
|
+
return _ref2.apply(this, arguments);
|
|
283
|
+
};
|
|
284
|
+
}();
|
|
237
285
|
if (!(isWalkInCustomer(snapshot) || scannedCustomerIsWalkIn)) {
|
|
238
|
-
|
|
286
|
+
_context5.next = 26;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
_context5.next = 15;
|
|
290
|
+
return trySelectWalletAsset();
|
|
291
|
+
case 15:
|
|
292
|
+
_walletSelection = _context5.sent;
|
|
293
|
+
if (!_walletSelection) {
|
|
294
|
+
_context5.next = 18;
|
|
239
295
|
break;
|
|
240
296
|
}
|
|
297
|
+
return _context5.abrupt("return", _walletSelection);
|
|
298
|
+
case 18:
|
|
241
299
|
if (bridge !== null && bridge !== void 0 && bridge.applyPromotionCode) {
|
|
242
|
-
|
|
300
|
+
_context5.next = 20;
|
|
243
301
|
break;
|
|
244
302
|
}
|
|
245
|
-
return
|
|
303
|
+
return _context5.abrupt("return", {
|
|
246
304
|
status: 'failed',
|
|
247
305
|
reason: 'no_bridge'
|
|
248
306
|
});
|
|
249
|
-
case
|
|
250
|
-
|
|
307
|
+
case 20:
|
|
308
|
+
_context5.next = 22;
|
|
251
309
|
return bridge.applyPromotionCode(scanCode);
|
|
252
|
-
case
|
|
253
|
-
result =
|
|
254
|
-
if (!(result !== null &&
|
|
255
|
-
|
|
310
|
+
case 22:
|
|
311
|
+
result = _context5.sent;
|
|
312
|
+
if (!((_result$isAccepted = result === null || result === void 0 ? void 0 : result.isAccepted) !== null && _result$isAccepted !== void 0 ? _result$isAccepted : result === null || result === void 0 ? void 0 : result.isAvailable)) {
|
|
313
|
+
_context5.next = 25;
|
|
256
314
|
break;
|
|
257
315
|
}
|
|
258
|
-
return
|
|
316
|
+
return _context5.abrupt("return", {
|
|
259
317
|
status: 'success',
|
|
260
318
|
kind: 'promotion'
|
|
261
319
|
});
|
|
262
|
-
case
|
|
263
|
-
return
|
|
320
|
+
case 25:
|
|
321
|
+
return _context5.abrupt("return", {
|
|
264
322
|
status: 'failed',
|
|
265
323
|
reason: 'invalid_data'
|
|
266
324
|
});
|
|
267
|
-
case
|
|
325
|
+
case 26:
|
|
268
326
|
host.setOrderCustomer(data);
|
|
269
|
-
|
|
270
|
-
return
|
|
327
|
+
_context5.next = 29;
|
|
328
|
+
return (_host$refreshWalletAs = host.refreshWalletAssets) === null || _host$refreshWalletAs === void 0 ? void 0 : _host$refreshWalletAs.call(host, {
|
|
329
|
+
preserveSelection: false
|
|
330
|
+
});
|
|
331
|
+
case 29:
|
|
332
|
+
_context5.next = 31;
|
|
333
|
+
return trySelectWalletAsset();
|
|
334
|
+
case 31:
|
|
335
|
+
walletSelection = _context5.sent;
|
|
336
|
+
if (!walletSelection) {
|
|
337
|
+
_context5.next = 34;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
return _context5.abrupt("return", walletSelection);
|
|
341
|
+
case 34:
|
|
342
|
+
if (!(bridge !== null && bridge !== void 0 && bridge.applyPromotionCode)) {
|
|
343
|
+
_context5.next = 40;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
_context5.next = 37;
|
|
347
|
+
return bridge.applyPromotionCode(scanCode, Number((_data$id = data === null || data === void 0 ? void 0 : data.id) !== null && _data$id !== void 0 ? _data$id : data === null || data === void 0 ? void 0 : data.customer_id) || undefined);
|
|
348
|
+
case 37:
|
|
349
|
+
promotionResult = _context5.sent;
|
|
350
|
+
if (!((_promotionResult$isAc = promotionResult === null || promotionResult === void 0 ? void 0 : promotionResult.isAccepted) !== null && _promotionResult$isAc !== void 0 ? _promotionResult$isAc : promotionResult === null || promotionResult === void 0 ? void 0 : promotionResult.isAvailable)) {
|
|
351
|
+
_context5.next = 40;
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
return _context5.abrupt("return", {
|
|
355
|
+
status: 'success',
|
|
356
|
+
kind: 'promotion'
|
|
357
|
+
});
|
|
358
|
+
case 40:
|
|
359
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify5 = bridge.onNotify) === null || _bridge$onNotify5 === void 0 || _bridge$onNotify5.call(bridge, 'success', 'pisell2.text.add-client-success');
|
|
360
|
+
return _context5.abrupt("return", {
|
|
271
361
|
status: 'success',
|
|
272
362
|
kind: 'customer'
|
|
273
363
|
});
|
|
274
|
-
case
|
|
364
|
+
case 42:
|
|
275
365
|
if (!(searchType === 'product' || searchType === 'local_product')) {
|
|
276
|
-
|
|
366
|
+
_context5.next = 75;
|
|
277
367
|
break;
|
|
278
368
|
}
|
|
279
369
|
list = data === null || data === void 0 ? void 0 : data.list;
|
|
280
370
|
if (!(!Array.isArray(list) || list.length === 0)) {
|
|
281
|
-
|
|
371
|
+
_context5.next = 47;
|
|
282
372
|
break;
|
|
283
373
|
}
|
|
284
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
285
|
-
return
|
|
374
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
375
|
+
return _context5.abrupt("return", {
|
|
286
376
|
status: 'failed',
|
|
287
377
|
reason: 'invalid_data'
|
|
288
378
|
});
|
|
289
|
-
case
|
|
379
|
+
case 47:
|
|
290
380
|
addedCount = 0;
|
|
291
381
|
_iterator = _createForOfIteratorHelper(list);
|
|
292
|
-
|
|
382
|
+
_context5.prev = 49;
|
|
293
383
|
_iterator.s();
|
|
294
|
-
case
|
|
384
|
+
case 51:
|
|
295
385
|
if ((_step = _iterator.n()).done) {
|
|
296
|
-
|
|
386
|
+
_context5.next = 63;
|
|
297
387
|
break;
|
|
298
388
|
}
|
|
299
389
|
_item = _step.value;
|
|
300
|
-
|
|
390
|
+
_context5.next = 55;
|
|
301
391
|
return processScannedProductItem(host, _item, scanCode, bridge);
|
|
302
|
-
case
|
|
303
|
-
outcome =
|
|
392
|
+
case 55:
|
|
393
|
+
outcome = _context5.sent;
|
|
304
394
|
if (outcome === 'added') {
|
|
305
395
|
addedCount += 1;
|
|
306
396
|
}
|
|
307
397
|
if (!(outcome === 'cancelled')) {
|
|
308
|
-
|
|
398
|
+
_context5.next = 59;
|
|
309
399
|
break;
|
|
310
400
|
}
|
|
311
|
-
return
|
|
401
|
+
return _context5.abrupt("return", {
|
|
312
402
|
status: 'cancelled'
|
|
313
403
|
});
|
|
314
|
-
case
|
|
404
|
+
case 59:
|
|
315
405
|
if (!(outcome === 'pending')) {
|
|
316
|
-
|
|
406
|
+
_context5.next = 61;
|
|
317
407
|
break;
|
|
318
408
|
}
|
|
319
|
-
return
|
|
409
|
+
return _context5.abrupt("return", {
|
|
320
410
|
status: 'pending',
|
|
321
411
|
kind: 'requiresDetail'
|
|
322
412
|
});
|
|
323
|
-
case
|
|
324
|
-
|
|
413
|
+
case 61:
|
|
414
|
+
_context5.next = 51;
|
|
325
415
|
break;
|
|
326
|
-
case
|
|
327
|
-
|
|
416
|
+
case 63:
|
|
417
|
+
_context5.next = 68;
|
|
328
418
|
break;
|
|
329
|
-
case
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
_iterator.e(
|
|
333
|
-
case
|
|
334
|
-
|
|
419
|
+
case 65:
|
|
420
|
+
_context5.prev = 65;
|
|
421
|
+
_context5.t0 = _context5["catch"](49);
|
|
422
|
+
_iterator.e(_context5.t0);
|
|
423
|
+
case 68:
|
|
424
|
+
_context5.prev = 68;
|
|
335
425
|
_iterator.f();
|
|
336
|
-
return
|
|
337
|
-
case
|
|
426
|
+
return _context5.finish(68);
|
|
427
|
+
case 71:
|
|
338
428
|
if (!(addedCount > 0)) {
|
|
339
|
-
|
|
429
|
+
_context5.next = 74;
|
|
340
430
|
break;
|
|
341
431
|
}
|
|
342
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
343
|
-
return
|
|
432
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'success');
|
|
433
|
+
return _context5.abrupt("return", {
|
|
344
434
|
status: 'success',
|
|
345
435
|
kind: 'products',
|
|
346
436
|
meta: {
|
|
347
437
|
count: addedCount
|
|
348
438
|
}
|
|
349
439
|
});
|
|
350
|
-
case
|
|
351
|
-
return
|
|
440
|
+
case 74:
|
|
441
|
+
return _context5.abrupt("return", {
|
|
352
442
|
status: 'failed',
|
|
353
443
|
reason: 'no_bridge'
|
|
354
444
|
});
|
|
355
|
-
case
|
|
445
|
+
case 75:
|
|
356
446
|
if (!(searchType === 'order')) {
|
|
357
|
-
|
|
447
|
+
_context5.next = 84;
|
|
358
448
|
break;
|
|
359
449
|
}
|
|
360
450
|
orderId = (_data$order_id = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id !== void 0 ? _data$order_id : data === null || data === void 0 ? void 0 : data.id;
|
|
361
451
|
if (orderId) {
|
|
362
|
-
|
|
452
|
+
_context5.next = 80;
|
|
363
453
|
break;
|
|
364
454
|
}
|
|
365
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
366
|
-
return
|
|
455
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify8 = bridge.onNotify) === null || _bridge$onNotify8 === void 0 || _bridge$onNotify8.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
456
|
+
return _context5.abrupt("return", {
|
|
367
457
|
status: 'failed',
|
|
368
458
|
reason: 'invalid_data'
|
|
369
459
|
});
|
|
370
|
-
case
|
|
460
|
+
case 80:
|
|
371
461
|
if (bridge !== null && bridge !== void 0 && bridge.openOrder) {
|
|
372
|
-
|
|
462
|
+
_context5.next = 82;
|
|
373
463
|
break;
|
|
374
464
|
}
|
|
375
|
-
return
|
|
465
|
+
return _context5.abrupt("return", {
|
|
376
466
|
status: 'pending',
|
|
377
467
|
kind: 'openOrder'
|
|
378
468
|
});
|
|
379
|
-
case
|
|
469
|
+
case 82:
|
|
380
470
|
bridge.openOrder({
|
|
381
471
|
order_id: Number(orderId),
|
|
382
472
|
business_code: (_data$business_code = data === null || data === void 0 ? void 0 : data.business_code) !== null && _data$business_code !== void 0 ? _data$business_code : host.getBusinessCode()
|
|
383
473
|
});
|
|
384
|
-
return
|
|
474
|
+
return _context5.abrupt("return", {
|
|
385
475
|
status: 'pending',
|
|
386
476
|
kind: 'openOrder'
|
|
387
477
|
});
|
|
388
|
-
case
|
|
389
|
-
return
|
|
478
|
+
case 84:
|
|
479
|
+
return _context5.abrupt("return", {
|
|
390
480
|
status: 'failed',
|
|
391
481
|
reason: 'invalid_data'
|
|
392
482
|
});
|
|
393
|
-
case
|
|
483
|
+
case 85:
|
|
394
484
|
case "end":
|
|
395
|
-
return
|
|
485
|
+
return _context5.stop();
|
|
396
486
|
}
|
|
397
|
-
},
|
|
487
|
+
}, _callee5, null, [[49, 65, 68, 71]]);
|
|
398
488
|
}));
|
|
399
489
|
return _applyGlobalScan.apply(this, arguments);
|
|
400
490
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
|
+
var WEIGHT_UNIT_MAP = {
|
|
8
|
+
KILOGRAMS: 'kg',
|
|
9
|
+
GRAMS: 'g',
|
|
10
|
+
POUNDS: 'lb',
|
|
11
|
+
OUNCES: 'oz'
|
|
12
|
+
};
|
|
13
|
+
function isRecord(value) {
|
|
14
|
+
return Boolean(value) && _typeof(value) === 'object' && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 将规格弹窗的称重结果写入订单行权威字段 product_sku。
|
|
19
|
+
* 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
|
|
20
|
+
*/
|
|
21
|
+
export function buildProductSkuFromCacheItem(cacheItem) {
|
|
22
|
+
var _cacheItem$_extend, _cacheItem$_extend2, _weighing$unit_weight, _weighing$tare$label, _weighing$tare, _weighing$tare$value, _weighing$tare2, _weighing$weight, _weighing$net_weight;
|
|
23
|
+
var currentSku = isRecord(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_sku) ? cacheItem.product_sku : undefined;
|
|
24
|
+
var weighing = isRecord(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.weighing) ? cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.weighing : undefined;
|
|
25
|
+
var hasRuntimeWeighingSku = Number((currentSku === null || currentSku === void 0 ? void 0 : currentSku.open_sold_weight) || 0) === 1 && ((currentSku === null || currentSku === void 0 ? void 0 : currentSku.weight) !== undefined || (currentSku === null || currentSku === void 0 ? void 0 : currentSku.net_weight) !== undefined || (currentSku === null || currentSku === void 0 ? void 0 : currentSku.weight_source) !== undefined);
|
|
26
|
+
var isWeighingSku = Number((currentSku === null || currentSku === void 0 ? void 0 : currentSku.open_sold_weight) || 0) === 1;
|
|
27
|
+
|
|
28
|
+
// 普通商品维持旧转换行为,不把目录侧完整 SKU 引入订单行。
|
|
29
|
+
if (!isWeighingSku && !weighing) return undefined;
|
|
30
|
+
// 新版 SkuDetailModal 已直接生成 product_sku;_extend.weighing 只作为旧调用方回退。
|
|
31
|
+
if (hasRuntimeWeighingSku) return _objectSpread({}, currentSku);
|
|
32
|
+
if (!weighing) return currentSku ? _objectSpread({}, currentSku) : undefined;
|
|
33
|
+
return _objectSpread(_objectSpread({}, currentSku || {}), {}, {
|
|
34
|
+
open_sold_weight: 1,
|
|
35
|
+
unit_data_snapshot: weighing.scalePriceProduct,
|
|
36
|
+
unit: WEIGHT_UNIT_MAP[String(weighing.unit)] || weighing.unit,
|
|
37
|
+
unit_weight: (_weighing$unit_weight = weighing.unit_weight) !== null && _weighing$unit_weight !== void 0 ? _weighing$unit_weight : '1.000',
|
|
38
|
+
unit_price: weighing.unit_price,
|
|
39
|
+
weight_source: weighing.mode,
|
|
40
|
+
tare_name: (_weighing$tare$label = (_weighing$tare = weighing.tare) === null || _weighing$tare === void 0 ? void 0 : _weighing$tare.label) !== null && _weighing$tare$label !== void 0 ? _weighing$tare$label : '',
|
|
41
|
+
tare_weight: (_weighing$tare$value = (_weighing$tare2 = weighing.tare) === null || _weighing$tare2 === void 0 ? void 0 : _weighing$tare2.value) !== null && _weighing$tare$value !== void 0 ? _weighing$tare$value : 0,
|
|
42
|
+
weight: (_weighing$weight = weighing.weight) !== null && _weighing$weight !== void 0 ? _weighing$weight : 0,
|
|
43
|
+
net_weight: (_weighing$net_weight = weighing.net_weight) !== null && _weighing$net_weight !== void 0 ? _weighing$net_weight : 0
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -83,6 +83,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
83
83
|
private getBookingAppointmentStatus;
|
|
84
84
|
private isBookingIncludedInStats;
|
|
85
85
|
private getBookingOrderPaymentStatus;
|
|
86
|
+
private isUnpaidBooking;
|
|
86
87
|
private countBookingOrders;
|
|
87
88
|
private countCompletedBookings;
|
|
88
89
|
private groupBookingsByResource;
|
|
@@ -29,6 +29,7 @@ import dayjs from 'dayjs';
|
|
|
29
29
|
import { BaseModule } from "../../modules/BaseModule";
|
|
30
30
|
import { SalesHooks } from "./types";
|
|
31
31
|
export * from "./types";
|
|
32
|
+
var UNPAID_PAYMENT_STATUSES = new Set(['unpaid', 'partially_paid', 'payment_processing']);
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Sales 解决方案基础骨架
|
|
@@ -415,6 +416,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
415
416
|
var _booking$order$paymen, _booking$order;
|
|
416
417
|
return String((_booking$order$paymen = (_booking$order = booking.order) === null || _booking$order === void 0 ? void 0 : _booking$order.payment_status) !== null && _booking$order$paymen !== void 0 ? _booking$order$paymen : '');
|
|
417
418
|
}
|
|
419
|
+
}, {
|
|
420
|
+
key: "isUnpaidBooking",
|
|
421
|
+
value: function isUnpaidBooking(booking) {
|
|
422
|
+
return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
|
|
423
|
+
}
|
|
418
424
|
}, {
|
|
419
425
|
key: "countBookingOrders",
|
|
420
426
|
value: function countBookingOrders(bookings) {
|
|
@@ -895,9 +901,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
895
901
|
});
|
|
896
902
|
completedBookingList = matchedBookingList.filter(function (booking) {
|
|
897
903
|
return _this7.getBookingAppointmentStatus(booking) === 'completed';
|
|
898
|
-
});
|
|
904
|
+
}); // const unpaidBookingList = matchedBookingList.filter(
|
|
905
|
+
// (booking) => this.getBookingOrderPaymentStatus(booking) === 'unpaid' || this.getBookingOrderPaymentStatus(booking) === 'payment_processing',
|
|
906
|
+
// );
|
|
899
907
|
unpaidBookingList = matchedBookingList.filter(function (booking) {
|
|
900
|
-
return _this7.
|
|
908
|
+
return _this7.isUnpaidBooking(booking);
|
|
901
909
|
});
|
|
902
910
|
bookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList));
|
|
903
911
|
completedBookings = completedBookingList.map(function (booking) {
|
|
@@ -40,6 +40,10 @@ import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOption
|
|
|
40
40
|
import dayjs from 'dayjs';
|
|
41
41
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
42
42
|
export * from "./types";
|
|
43
|
+
function isItemRewardProductDiscount(discount) {
|
|
44
|
+
var _discount$metadata, _discount$metadata2;
|
|
45
|
+
return (discount === null || discount === void 0 ? void 0 : discount.type) === 'product' && (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.source) === 'promotion' && (discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.actionType) === 'ITEM_REWARD';
|
|
46
|
+
}
|
|
43
47
|
export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
44
48
|
_inherits(ScanOrderImpl, _BaseSalesImpl);
|
|
45
49
|
var _super = _createSuper(ScanOrderImpl);
|
|
@@ -1109,7 +1113,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1109
1113
|
_iterator3.s();
|
|
1110
1114
|
case 19:
|
|
1111
1115
|
if ((_step3 = _iterator3.n()).done) {
|
|
1112
|
-
_context14.next =
|
|
1116
|
+
_context14.next = 36;
|
|
1113
1117
|
break;
|
|
1114
1118
|
}
|
|
1115
1119
|
product = _step3.value;
|
|
@@ -1117,8 +1121,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1117
1121
|
_context14.next = 23;
|
|
1118
1122
|
break;
|
|
1119
1123
|
}
|
|
1120
|
-
return _context14.abrupt("continue",
|
|
1124
|
+
return _context14.abrupt("continue", 34);
|
|
1121
1125
|
case 23:
|
|
1126
|
+
if (!(product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
1127
|
+
_context14.next = 26;
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
1131
|
+
return _context14.abrupt("continue", 34);
|
|
1132
|
+
case 26:
|
|
1122
1133
|
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1123
1134
|
var _pd$discount$resource, _pd$discount;
|
|
1124
1135
|
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
@@ -1142,47 +1153,47 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1142
1153
|
mainPrice: newMainSellingPrice,
|
|
1143
1154
|
bundle: product.product_bundle
|
|
1144
1155
|
});
|
|
1145
|
-
case
|
|
1156
|
+
case 34:
|
|
1146
1157
|
_context14.next = 19;
|
|
1147
1158
|
break;
|
|
1148
|
-
case
|
|
1149
|
-
_context14.next =
|
|
1159
|
+
case 36:
|
|
1160
|
+
_context14.next = 41;
|
|
1150
1161
|
break;
|
|
1151
|
-
case 35:
|
|
1152
|
-
_context14.prev = 35;
|
|
1153
|
-
_context14.t0 = _context14["catch"](17);
|
|
1154
|
-
_iterator3.e(_context14.t0);
|
|
1155
1162
|
case 38:
|
|
1156
1163
|
_context14.prev = 38;
|
|
1157
|
-
|
|
1158
|
-
|
|
1164
|
+
_context14.t0 = _context14["catch"](17);
|
|
1165
|
+
_iterator3.e(_context14.t0);
|
|
1159
1166
|
case 41:
|
|
1167
|
+
_context14.prev = 41;
|
|
1168
|
+
_iterator3.f();
|
|
1169
|
+
return _context14.finish(41);
|
|
1170
|
+
case 44:
|
|
1160
1171
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1161
|
-
_context14.next =
|
|
1172
|
+
_context14.next = 47;
|
|
1162
1173
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1163
|
-
case
|
|
1174
|
+
case 47:
|
|
1164
1175
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1165
1176
|
return d.isSelected;
|
|
1166
1177
|
});
|
|
1167
|
-
_context14.next =
|
|
1178
|
+
_context14.next = 50;
|
|
1168
1179
|
return this.store.order.recalculateSummary({
|
|
1169
1180
|
createIfMissing: true
|
|
1170
1181
|
});
|
|
1171
|
-
case
|
|
1182
|
+
case 50:
|
|
1172
1183
|
this.store.order.persistTempOrder();
|
|
1173
1184
|
this.logMethodSuccess('setDiscountSelected', params);
|
|
1174
|
-
_context14.next =
|
|
1185
|
+
_context14.next = 58;
|
|
1175
1186
|
break;
|
|
1176
|
-
case
|
|
1177
|
-
_context14.prev =
|
|
1187
|
+
case 54:
|
|
1188
|
+
_context14.prev = 54;
|
|
1178
1189
|
_context14.t1 = _context14["catch"](1);
|
|
1179
1190
|
this.logMethodError('setDiscountSelected', _context14.t1);
|
|
1180
1191
|
throw _context14.t1;
|
|
1181
|
-
case
|
|
1192
|
+
case 58:
|
|
1182
1193
|
case "end":
|
|
1183
1194
|
return _context14.stop();
|
|
1184
1195
|
}
|
|
1185
|
-
}, _callee14, this, [[1,
|
|
1196
|
+
}, _callee14, this, [[1, 54], [17, 38, 41, 44]]);
|
|
1186
1197
|
}));
|
|
1187
1198
|
function setDiscountSelected(_x8) {
|
|
1188
1199
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -63,6 +63,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
63
63
|
private openDataTarget;
|
|
64
64
|
private loadOpenDataInFlight;
|
|
65
65
|
private loadOpenDataInFlightTarget;
|
|
66
|
+
protected isSessionStoragePersistEnabled(): boolean;
|
|
67
|
+
protected shouldUseSessionStorageForSubModule(moduleName?: string): boolean;
|
|
66
68
|
/**
|
|
67
69
|
* Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
|
|
68
70
|
* 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
|
|
@@ -72,6 +74,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
72
74
|
protected getDefaultCheckoutSmallTicketDataFlag(): number;
|
|
73
75
|
protected getRegisteredModuleNames(): readonly string[];
|
|
74
76
|
protected createSubModule(moduleName: string): Module | null;
|
|
77
|
+
addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
75
78
|
/**
|
|
76
79
|
* Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
|
|
77
80
|
* business/channel target so a reused solution instance cannot leak another entry's menus.
|