@pisell/pisellos 0.10.84 → 0.10.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/OpenData/types.d.ts +3 -0
- package/dist/modules/Order/index.js +6 -3
- package/dist/modules/Order/types.d.ts +1 -1
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +105 -53
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +18 -1
- package/dist/solution/BookingTicket/index.js +220 -16
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +77 -0
- package/dist/solution/BookingTicket/utils/redeemArrival.js +171 -0
- package/lib/modules/OpenData/types.d.ts +3 -0
- package/lib/modules/Order/index.js +4 -1
- package/lib/modules/Order/types.d.ts +1 -1
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +45 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +18 -1
- package/lib/solution/BookingTicket/index.js +102 -1
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/redeemArrival.js +149 -0
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings } from
|
|
|
37
37
|
import { getProductExtend as getProductExtendUtil, getResourceByIds as getResourceByIdsUtil, getResourceErrors as getResourceErrorsUtil, derivePresetStartTimeFromDate } from "../../modules/BookingContext";
|
|
38
38
|
import { BaseSalesImpl } from "../BaseSales";
|
|
39
39
|
import Scan from "./utils/scan";
|
|
40
|
+
import { applyRedeemArrival, buildArrivalCheckoutQuery, createArrivalLogger, describeChangedBookings, readArrivalWindow } from "./utils/redeemArrival";
|
|
40
41
|
import { formatOrderCustomerPatch } from "./utils/orderCustomer";
|
|
41
42
|
import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
|
|
42
43
|
import scanCache from "./utils/scan/scanCache";
|
|
@@ -191,6 +192,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
191
192
|
_defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlight", null);
|
|
192
193
|
_defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlightTarget", null);
|
|
193
194
|
_defineProperty(_assertThisInitialized(_this), "openDataTarget", null);
|
|
195
|
+
_defineProperty(_assertThisInitialized(_this), "redeemStatusWrite", void 0);
|
|
196
|
+
_defineProperty(_assertThisInitialized(_this), "arrivalQueue", Promise.resolve());
|
|
194
197
|
return _this;
|
|
195
198
|
}
|
|
196
199
|
_createClass(BookingTicketImpl, [{
|
|
@@ -3519,13 +3522,26 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3519
3522
|
return _handlePrintWristband.apply(this, arguments);
|
|
3520
3523
|
}
|
|
3521
3524
|
return handlePrintWristband;
|
|
3522
|
-
}()
|
|
3525
|
+
}()
|
|
3526
|
+
}, {
|
|
3527
|
+
key: "getRedeemArrivalWindow",
|
|
3528
|
+
value: function getRedeemArrivalWindow() {
|
|
3529
|
+
var _this$store$openData$, _this$store$openData2, _this$store$openData3;
|
|
3530
|
+
return readArrivalWindow((_this$store$openData$ = (_this$store$openData2 = this.store.openData) === null || _this$store$openData2 === void 0 || (_this$store$openData3 = _this$store$openData2.getOpenData) === null || _this$store$openData3 === void 0 ? void 0 : _this$store$openData3.call(_this$store$openData2)) !== null && _this$store$openData$ !== void 0 ? _this$store$openData$ : this.getInjectedOpenDataConfig());
|
|
3531
|
+
}
|
|
3532
|
+
}, {
|
|
3533
|
+
key: "isRedeemArrivalEnabled",
|
|
3534
|
+
value: function isRedeemArrivalEnabled() {
|
|
3535
|
+
return Boolean(this.getRedeemArrivalWindow());
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3538
|
+
// 触发核销
|
|
3523
3539
|
}, {
|
|
3524
3540
|
key: "handleRedeem",
|
|
3525
3541
|
value: function () {
|
|
3526
3542
|
var _handleRedeem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
3527
3543
|
var _this$store$order8, _this$store$order8$ge, _this$store$order9, _ref22, _tempOrder$order_id2;
|
|
3528
|
-
var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
|
|
3544
|
+
var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, write, identity, externalSaleNumber, orderId, orderLookup;
|
|
3529
3545
|
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3530
3546
|
while (1) switch (_context45.prev = _context45.next) {
|
|
3531
3547
|
case 0:
|
|
@@ -3551,17 +3567,24 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3551
3567
|
});
|
|
3552
3568
|
});
|
|
3553
3569
|
if (!(tempOrder && hasUpdatedVoucher)) {
|
|
3554
|
-
_context45.next =
|
|
3570
|
+
_context45.next = 17;
|
|
3555
3571
|
break;
|
|
3556
3572
|
}
|
|
3557
|
-
|
|
3558
|
-
return this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
|
|
3573
|
+
write = this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
|
|
3559
3574
|
vouchers: nextVouchers
|
|
3560
3575
|
}));
|
|
3561
|
-
|
|
3576
|
+
this.redeemStatusWrite = write;
|
|
3577
|
+
_context45.prev = 11;
|
|
3578
|
+
_context45.next = 14;
|
|
3579
|
+
return write;
|
|
3580
|
+
case 14:
|
|
3581
|
+
_context45.prev = 14;
|
|
3582
|
+
if (this.redeemStatusWrite === write) this.redeemStatusWrite = undefined;
|
|
3583
|
+
return _context45.finish(14);
|
|
3584
|
+
case 17:
|
|
3562
3585
|
this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
|
|
3563
3586
|
if (!(voucherIds.length === 0)) {
|
|
3564
|
-
_context45.next =
|
|
3587
|
+
_context45.next = 20;
|
|
3565
3588
|
break;
|
|
3566
3589
|
}
|
|
3567
3590
|
return _context45.abrupt("return", {
|
|
@@ -3570,7 +3593,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3570
3593
|
message: '',
|
|
3571
3594
|
data: []
|
|
3572
3595
|
});
|
|
3573
|
-
case
|
|
3596
|
+
case 20:
|
|
3574
3597
|
identity = this.getOrderIdentity();
|
|
3575
3598
|
externalSaleNumber = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) || (identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) || undefined;
|
|
3576
3599
|
orderId = (_ref22 = (_tempOrder$order_id2 = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _ref22 !== void 0 ? _ref22 : undefined;
|
|
@@ -3584,17 +3607,198 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3584
3607
|
}, {
|
|
3585
3608
|
osServer: true
|
|
3586
3609
|
}));
|
|
3587
|
-
case
|
|
3610
|
+
case 25:
|
|
3588
3611
|
case "end":
|
|
3589
3612
|
return _context45.stop();
|
|
3590
3613
|
}
|
|
3591
|
-
}, _callee45, this);
|
|
3614
|
+
}, _callee45, this, [[11,, 14, 17]]);
|
|
3592
3615
|
}));
|
|
3593
3616
|
function handleRedeem(_x30) {
|
|
3594
3617
|
return _handleRedeem.apply(this, arguments);
|
|
3595
3618
|
}
|
|
3596
3619
|
return handleRedeem;
|
|
3597
3620
|
}()
|
|
3621
|
+
}, {
|
|
3622
|
+
key: "updateTicketArrival",
|
|
3623
|
+
value: function () {
|
|
3624
|
+
var _updateTicketArrival = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(voucherIds) {
|
|
3625
|
+
var _this$store$order10,
|
|
3626
|
+
_this$store$order10$g,
|
|
3627
|
+
_this12 = this;
|
|
3628
|
+
var window, tempOrder, log, operation, arrivalTime, updateArrival, completion;
|
|
3629
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3630
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
3631
|
+
case 0:
|
|
3632
|
+
window = this.getRedeemArrivalWindow();
|
|
3633
|
+
tempOrder = (_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$g = _this$store$order10.getTempOrder) === null || _this$store$order10$g === void 0 ? void 0 : _this$store$order10$g.call(_this$store$order10);
|
|
3634
|
+
log = createArrivalLogger(this.logger, tempOrder, voucherIds);
|
|
3635
|
+
if (!(!window || !tempOrder)) {
|
|
3636
|
+
_context47.next = 6;
|
|
3637
|
+
break;
|
|
3638
|
+
}
|
|
3639
|
+
log('skipped', {
|
|
3640
|
+
reason: !window ? 'no_effective_window' : 'missing_order'
|
|
3641
|
+
});
|
|
3642
|
+
return _context47.abrupt("return");
|
|
3643
|
+
case 6:
|
|
3644
|
+
log('started', {
|
|
3645
|
+
early_minutes: window.earlyMinutes,
|
|
3646
|
+
late_minutes: window.lateMinutes
|
|
3647
|
+
});
|
|
3648
|
+
operation = 'prepare';
|
|
3649
|
+
arrivalTime = new Date();
|
|
3650
|
+
updateArrival = /*#__PURE__*/function () {
|
|
3651
|
+
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3652
|
+
var _this12$store$order, _this12$store$order$g, _next$summary;
|
|
3653
|
+
var current, sameOrder, order, arrival, next, query, checkout, latest, patch;
|
|
3654
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3655
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
3656
|
+
case 0:
|
|
3657
|
+
if (!_this12.redeemStatusWrite) {
|
|
3658
|
+
_context46.next = 3;
|
|
3659
|
+
break;
|
|
3660
|
+
}
|
|
3661
|
+
_context46.next = 3;
|
|
3662
|
+
return _this12.redeemStatusWrite.catch(function () {});
|
|
3663
|
+
case 3:
|
|
3664
|
+
current = (_this12$store$order = _this12.store.order) === null || _this12$store$order === void 0 || (_this12$store$order$g = _this12$store$order.getTempOrder) === null || _this12$store$order$g === void 0 ? void 0 : _this12$store$order$g.call(_this12$store$order);
|
|
3665
|
+
sameOrder = function sameOrder() {
|
|
3666
|
+
var _this12$store$order2, _this12$store$order2$;
|
|
3667
|
+
var active = (_this12$store$order2 = _this12.store.order) === null || _this12$store$order2 === void 0 || (_this12$store$order2$ = _this12$store$order2.getTempOrder) === null || _this12$store$order2$ === void 0 ? void 0 : _this12$store$order2$.call(_this12$store$order2);
|
|
3668
|
+
return active && active.order_id === tempOrder.order_id && active.external_sale_number === tempOrder.external_sale_number;
|
|
3669
|
+
};
|
|
3670
|
+
order = current && sameOrder() ? current : tempOrder;
|
|
3671
|
+
arrival = applyRedeemArrival(order, new Set(voucherIds.map(String)), arrivalTime, window, function (reason) {
|
|
3672
|
+
return log('skipped', {
|
|
3673
|
+
reason: reason
|
|
3674
|
+
});
|
|
3675
|
+
});
|
|
3676
|
+
if (arrival) {
|
|
3677
|
+
_context46.next = 9;
|
|
3678
|
+
break;
|
|
3679
|
+
}
|
|
3680
|
+
return _context46.abrupt("return");
|
|
3681
|
+
case 9:
|
|
3682
|
+
next = _objectSpread(_objectSpread({}, order), arrival);
|
|
3683
|
+
_context46.t0 = buildArrivalCheckoutQuery;
|
|
3684
|
+
_context46.t1 = next;
|
|
3685
|
+
if (!((_next$summary = next.summary) !== null && _next$summary !== void 0)) {
|
|
3686
|
+
_context46.next = 16;
|
|
3687
|
+
break;
|
|
3688
|
+
}
|
|
3689
|
+
_context46.t2 = _next$summary;
|
|
3690
|
+
_context46.next = 24;
|
|
3691
|
+
break;
|
|
3692
|
+
case 16:
|
|
3693
|
+
if (!sameOrder()) {
|
|
3694
|
+
_context46.next = 22;
|
|
3695
|
+
break;
|
|
3696
|
+
}
|
|
3697
|
+
_context46.next = 19;
|
|
3698
|
+
return _this12.getSummary();
|
|
3699
|
+
case 19:
|
|
3700
|
+
_context46.t3 = _context46.sent;
|
|
3701
|
+
_context46.next = 23;
|
|
3702
|
+
break;
|
|
3703
|
+
case 22:
|
|
3704
|
+
_context46.t3 = undefined;
|
|
3705
|
+
case 23:
|
|
3706
|
+
_context46.t2 = _context46.t3;
|
|
3707
|
+
case 24:
|
|
3708
|
+
_context46.t4 = _context46.t2;
|
|
3709
|
+
query = (0, _context46.t0)(_context46.t1, _context46.t4);
|
|
3710
|
+
operation = 'checkout';
|
|
3711
|
+
log('checkout_requested', {
|
|
3712
|
+
bookings: describeChangedBookings(order.bookings, arrival.bookings)
|
|
3713
|
+
});
|
|
3714
|
+
_context46.next = 30;
|
|
3715
|
+
return _this12.store.order.submitSalesOrder({
|
|
3716
|
+
query: query
|
|
3717
|
+
});
|
|
3718
|
+
case 30:
|
|
3719
|
+
checkout = _context46.sent;
|
|
3720
|
+
if (!((checkout === null || checkout === void 0 ? void 0 : checkout.status) === false || (checkout === null || checkout === void 0 ? void 0 : checkout.code) != null && checkout.code !== 200)) {
|
|
3721
|
+
_context46.next = 34;
|
|
3722
|
+
break;
|
|
3723
|
+
}
|
|
3724
|
+
log('checkout_rejected', {
|
|
3725
|
+
code: checkout.code,
|
|
3726
|
+
status: checkout.status,
|
|
3727
|
+
message: checkout.message
|
|
3728
|
+
}, true);
|
|
3729
|
+
return _context46.abrupt("return", checkout);
|
|
3730
|
+
case 34:
|
|
3731
|
+
log('checkout_accepted', {
|
|
3732
|
+
code: checkout === null || checkout === void 0 ? void 0 : checkout.code
|
|
3733
|
+
});
|
|
3734
|
+
operation = 'local_update';
|
|
3735
|
+
if (!_this12.redeemStatusWrite) {
|
|
3736
|
+
_context46.next = 39;
|
|
3737
|
+
break;
|
|
3738
|
+
}
|
|
3739
|
+
_context46.next = 39;
|
|
3740
|
+
return _this12.redeemStatusWrite.catch(function () {});
|
|
3741
|
+
case 39:
|
|
3742
|
+
if (!sameOrder()) {
|
|
3743
|
+
_context46.next = 52;
|
|
3744
|
+
break;
|
|
3745
|
+
}
|
|
3746
|
+
latest = _this12.store.order.getTempOrder();
|
|
3747
|
+
patch = applyRedeemArrival(latest, new Set(voucherIds.map(String)), arrivalTime, window);
|
|
3748
|
+
if (!patch) {
|
|
3749
|
+
_context46.next = 49;
|
|
3750
|
+
break;
|
|
3751
|
+
}
|
|
3752
|
+
_context46.next = 45;
|
|
3753
|
+
return _this12.replaceTempOrder(_objectSpread(_objectSpread({}, latest), patch));
|
|
3754
|
+
case 45:
|
|
3755
|
+
log('local_updated');
|
|
3756
|
+
_this12.core.effects.emit("".concat(_this12.name, ":onVouchersChange"), {});
|
|
3757
|
+
_context46.next = 50;
|
|
3758
|
+
break;
|
|
3759
|
+
case 49:
|
|
3760
|
+
log('local_skipped', {
|
|
3761
|
+
reason: 'no_pending_change'
|
|
3762
|
+
});
|
|
3763
|
+
case 50:
|
|
3764
|
+
_context46.next = 53;
|
|
3765
|
+
break;
|
|
3766
|
+
case 52:
|
|
3767
|
+
log('local_skipped', {
|
|
3768
|
+
reason: 'order_changed'
|
|
3769
|
+
});
|
|
3770
|
+
case 53:
|
|
3771
|
+
return _context46.abrupt("return", checkout);
|
|
3772
|
+
case 54:
|
|
3773
|
+
case "end":
|
|
3774
|
+
return _context46.stop();
|
|
3775
|
+
}
|
|
3776
|
+
}, _callee46);
|
|
3777
|
+
}));
|
|
3778
|
+
return function updateArrival() {
|
|
3779
|
+
return _ref23.apply(this, arguments);
|
|
3780
|
+
};
|
|
3781
|
+
}();
|
|
3782
|
+
completion = this.arrivalQueue.then(updateArrival).catch(function (error) {
|
|
3783
|
+
log('failed', {
|
|
3784
|
+
operation: operation,
|
|
3785
|
+
message: error instanceof Error ? error.message : String(error)
|
|
3786
|
+
}, true);
|
|
3787
|
+
throw error;
|
|
3788
|
+
});
|
|
3789
|
+
this.arrivalQueue = completion.then(function () {}, function () {});
|
|
3790
|
+
return _context47.abrupt("return", completion);
|
|
3791
|
+
case 13:
|
|
3792
|
+
case "end":
|
|
3793
|
+
return _context47.stop();
|
|
3794
|
+
}
|
|
3795
|
+
}, _callee47, this);
|
|
3796
|
+
}));
|
|
3797
|
+
function updateTicketArrival(_x31) {
|
|
3798
|
+
return _updateTicketArrival.apply(this, arguments);
|
|
3799
|
+
}
|
|
3800
|
+
return updateTicketArrival;
|
|
3801
|
+
}()
|
|
3598
3802
|
/**
|
|
3599
3803
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
3600
3804
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
@@ -3602,13 +3806,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3602
3806
|
}, {
|
|
3603
3807
|
key: "destroy",
|
|
3604
3808
|
value: (function () {
|
|
3605
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3809
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
3606
3810
|
var _this$scan;
|
|
3607
|
-
return _regeneratorRuntime().wrap(function
|
|
3608
|
-
while (1) switch (
|
|
3811
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
3812
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
3609
3813
|
case 0:
|
|
3610
3814
|
this.orderCustomerContactRequest = null;
|
|
3611
|
-
|
|
3815
|
+
_context48.next = 3;
|
|
3612
3816
|
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
|
|
3613
3817
|
case 3:
|
|
3614
3818
|
try {
|
|
@@ -3619,9 +3823,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3619
3823
|
scanCache.clear();
|
|
3620
3824
|
case 5:
|
|
3621
3825
|
case "end":
|
|
3622
|
-
return
|
|
3826
|
+
return _context48.stop();
|
|
3623
3827
|
}
|
|
3624
|
-
},
|
|
3828
|
+
}, _callee48, this);
|
|
3625
3829
|
}));
|
|
3626
3830
|
function destroy() {
|
|
3627
3831
|
return _destroy.apply(this, arguments);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type LoggerManager from '../../../plugins/app-types/logger';
|
|
2
|
+
import type { OrderTempOrder } from '../../../modules/Order/types';
|
|
3
|
+
export interface ArrivalWindow {
|
|
4
|
+
earlyMinutes: number;
|
|
5
|
+
lateMinutes: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function readArrivalWindow(config?: Record<string, any> | null): ArrivalWindow | undefined;
|
|
8
|
+
type TicketOrder = Pick<OrderTempOrder, 'vouchers' | 'bookings'>;
|
|
9
|
+
export declare function applyRedeemArrival(order: TicketOrder, ids: Set<string>, now: Date, window?: ArrivalWindow, onSkip?: (reason: string) => void): {
|
|
10
|
+
vouchers: any[];
|
|
11
|
+
bookings: any[];
|
|
12
|
+
} | undefined;
|
|
13
|
+
export declare function createArrivalLogger(logger: Pick<LoggerManager, 'addLog'> | undefined, order: OrderTempOrder | null | undefined, voucherIds: Array<string | number>): (stage: string, details?: Record<string, unknown>, failed?: boolean) => void;
|
|
14
|
+
export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary: OrderTempOrder['summary']): {
|
|
15
|
+
small_ticket_data_flag: number;
|
|
16
|
+
platform: string;
|
|
17
|
+
payment_status?: string | undefined;
|
|
18
|
+
created_at?: string | undefined;
|
|
19
|
+
request_unique_idempotency_token?: string | undefined;
|
|
20
|
+
form_record_ids?: {
|
|
21
|
+
form_id: string | number;
|
|
22
|
+
form_record_id: string | number;
|
|
23
|
+
}[] | undefined;
|
|
24
|
+
products: import("../../../modules/Order/types").OrderSubmitProduct[];
|
|
25
|
+
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
|
+
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
|
+
status: string;
|
|
28
|
+
metadata: Record<string, any>;
|
|
29
|
+
business_code?: string | undefined;
|
|
30
|
+
customer_id: number | null;
|
|
31
|
+
type: string;
|
|
32
|
+
holder: Record<string, any> | null;
|
|
33
|
+
email: string;
|
|
34
|
+
phone: string;
|
|
35
|
+
note: string;
|
|
36
|
+
relation_forms: any[];
|
|
37
|
+
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
38
|
+
country_calling_code: string;
|
|
39
|
+
contacts_info: Record<string, any> | null;
|
|
40
|
+
order_id: number | null;
|
|
41
|
+
external_sale_number: string;
|
|
42
|
+
order_number: string | null;
|
|
43
|
+
shop_order_number: string | null;
|
|
44
|
+
shop_full_order_number: string | null;
|
|
45
|
+
sales_channel: string;
|
|
46
|
+
order_sales_channel: string;
|
|
47
|
+
shipping_status: string;
|
|
48
|
+
customer_name: string;
|
|
49
|
+
is_price_include_tax: number;
|
|
50
|
+
tax_title: string;
|
|
51
|
+
tax_country_code: string;
|
|
52
|
+
currency_code: string;
|
|
53
|
+
currency_symbol: string;
|
|
54
|
+
currency_format: string;
|
|
55
|
+
is_deposit: number;
|
|
56
|
+
deposit_amount: string;
|
|
57
|
+
shop_discount: string;
|
|
58
|
+
surcharge_fee: string;
|
|
59
|
+
buzzer?: string | undefined;
|
|
60
|
+
delivery_type?: string | undefined;
|
|
61
|
+
table_number?: Record<string, any> | undefined;
|
|
62
|
+
schedule_date: string;
|
|
63
|
+
bookings: any[];
|
|
64
|
+
payments: any[];
|
|
65
|
+
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
66
|
+
refunds?: any[] | undefined;
|
|
67
|
+
surcharges: any[];
|
|
68
|
+
contacts: any[];
|
|
69
|
+
};
|
|
70
|
+
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
71
|
+
schedule_event_id: any;
|
|
72
|
+
previous_start: any;
|
|
73
|
+
previous_end: any;
|
|
74
|
+
start: any;
|
|
75
|
+
end: any;
|
|
76
|
+
}[];
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["vouchers"];
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
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); }
|
|
14
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
+
import dayjs from 'dayjs';
|
|
18
|
+
import { buildSubmitPayload, redeemEventKey } from "../../../modules/Order/utils";
|
|
19
|
+
export function readArrivalWindow(config) {
|
|
20
|
+
var enabled = config === null || config === void 0 ? void 0 : config['fulfillment.enable_adjust_session_on_arrival'];
|
|
21
|
+
if (enabled !== true && enabled !== 1 && enabled !== '1') return;
|
|
22
|
+
var minutes = function minutes(value) {
|
|
23
|
+
var number = Number(value);
|
|
24
|
+
return Number.isFinite(number) ? Math.max(0, Math.floor(number)) : 0;
|
|
25
|
+
};
|
|
26
|
+
var earlyMinutes = minutes(config === null || config === void 0 ? void 0 : config['fulfillment.max_earlier_shift_minutes']);
|
|
27
|
+
var lateMinutes = minutes(config === null || config === void 0 ? void 0 : config['fulfillment.max_later_shift_minutes']);
|
|
28
|
+
// 两个方向都没有可调整的分钟数时,核销和打印沿用关闭开关时的流程。
|
|
29
|
+
if (earlyMinutes === 0 && lateMinutes === 0) return;
|
|
30
|
+
return {
|
|
31
|
+
earlyMinutes: earlyMinutes,
|
|
32
|
+
lateMinutes: lateMinutes
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function shiftedSession(booking, now, window) {
|
|
36
|
+
if (!window || !booking.start_date || !booking.start_time || !booking.end_time) return;
|
|
37
|
+
var start = dayjs("".concat(booking.start_date, " ").concat(booking.start_time));
|
|
38
|
+
var end = dayjs("".concat(booking.end_date || booking.start_date, " ").concat(booking.end_time));
|
|
39
|
+
if (!start.isValid() || !end.isValid() || end.isBefore(start)) return;
|
|
40
|
+
var delta = dayjs(now).startOf('minute').diff(start, 'minute');
|
|
41
|
+
var minutes = Math.max(-window.earlyMinutes, Math.min(window.lateMinutes, delta));
|
|
42
|
+
if (!Number.isFinite(minutes) || !minutes) return;
|
|
43
|
+
var shiftedStart = start.add(minutes, 'minute');
|
|
44
|
+
var shiftedEnd = end.add(minutes, 'minute');
|
|
45
|
+
return {
|
|
46
|
+
start_date: shiftedStart.format('YYYY-MM-DD'),
|
|
47
|
+
start_time: shiftedStart.format(booking.start_time.length > 5 ? 'HH:mm:ss' : 'HH:mm'),
|
|
48
|
+
end_date: shiftedEnd.format('YYYY-MM-DD'),
|
|
49
|
+
end_time: shiftedEnd.format(booking.end_time.length > 5 ? 'HH:mm:ss' : 'HH:mm')
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function applyRedeemArrival(order, ids, now, window, onSkip) {
|
|
53
|
+
var _order$bookings, _order$vouchers;
|
|
54
|
+
if (!window || !((_order$bookings = order.bookings) !== null && _order$bookings !== void 0 && _order$bookings.length) || !((_order$vouchers = order.vouchers) !== null && _order$vouchers !== void 0 && _order$vouchers.length)) {
|
|
55
|
+
onSkip === null || onSkip === void 0 || onSkip('missing_window_or_booking_data');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
var selected = new Set();
|
|
59
|
+
var _iterator = _createForOfIteratorHelper(order.vouchers),
|
|
60
|
+
_step;
|
|
61
|
+
try {
|
|
62
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
63
|
+
var voucher = _step.value;
|
|
64
|
+
var event = redeemEventKey(voucher === null || voucher === void 0 ? void 0 : voucher.schedule_event_id);
|
|
65
|
+
if (event && ids.has(String(voucher.voucher_id))) selected.add(event);
|
|
66
|
+
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
_iterator.e(err);
|
|
69
|
+
} finally {
|
|
70
|
+
_iterator.f();
|
|
71
|
+
}
|
|
72
|
+
var alreadyMarked = false;
|
|
73
|
+
var changes = new Map();
|
|
74
|
+
var bookings = order.bookings.map(function (booking) {
|
|
75
|
+
var _booking$metadata;
|
|
76
|
+
var event = redeemEventKey(booking === null || booking === void 0 ? void 0 : booking.schedule_event_id);
|
|
77
|
+
if (!event || !selected.has(event) || booking.parent_id === 0) return booking;
|
|
78
|
+
if (Number((_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.is_change_by_redeem) === 1) {
|
|
79
|
+
alreadyMarked = true;
|
|
80
|
+
return booking;
|
|
81
|
+
}
|
|
82
|
+
var shift = shiftedSession(booking, now, window);
|
|
83
|
+
// 准点核销的偏移量为零,也要打标,避免下一张票改变这个时段。
|
|
84
|
+
changes.set(event, shift);
|
|
85
|
+
return _objectSpread(_objectSpread(_objectSpread({}, booking), shift), {}, {
|
|
86
|
+
metadata: _objectSpread(_objectSpread({}, booking.metadata), {}, {
|
|
87
|
+
is_change_by_redeem: 1
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
if (!changes.size) {
|
|
92
|
+
onSkip === null || onSkip === void 0 || onSkip(alreadyMarked ? 'already_marked' : 'no_linked_booking');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
var vouchers = order.vouchers.map(function (voucher) {
|
|
96
|
+
var event = redeemEventKey(voucher === null || voucher === void 0 ? void 0 : voucher.schedule_event_id);
|
|
97
|
+
var shift = event && changes.get(event);
|
|
98
|
+
if (!shift) return voucher;
|
|
99
|
+
return _objectSpread(_objectSpread({}, voucher), {}, {
|
|
100
|
+
start_date: shift.start_date,
|
|
101
|
+
expire_date: shift.end_date,
|
|
102
|
+
start_time: shift.start_time,
|
|
103
|
+
end_time: shift.end_time
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
vouchers: vouchers,
|
|
108
|
+
bookings: bookings
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export function createArrivalLogger(logger, order, voucherIds) {
|
|
112
|
+
return function (stage) {
|
|
113
|
+
var details = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
114
|
+
var failed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
115
|
+
try {
|
|
116
|
+
logger === null || logger === void 0 || logger.addLog({
|
|
117
|
+
type: failed ? 'error' : 'info',
|
|
118
|
+
title: '[BookingTicket] updateTicketArrival',
|
|
119
|
+
metadata: _objectSpread({
|
|
120
|
+
stage: stage,
|
|
121
|
+
order_id: order === null || order === void 0 ? void 0 : order.order_id,
|
|
122
|
+
external_sale_number: order === null || order === void 0 ? void 0 : order.external_sale_number,
|
|
123
|
+
voucher_ids: voucherIds
|
|
124
|
+
}, details)
|
|
125
|
+
});
|
|
126
|
+
} catch (_unused) {
|
|
127
|
+
// 日志不可用时,核销和预约调时仍按原流程执行。
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export function buildArrivalCheckoutQuery(order, summary) {
|
|
132
|
+
var _buildSubmitPayload = buildSubmitPayload({
|
|
133
|
+
tempOrder: order,
|
|
134
|
+
platform: order.platform,
|
|
135
|
+
businessCode: order.business_code,
|
|
136
|
+
type: order.type,
|
|
137
|
+
summary: summary
|
|
138
|
+
}),
|
|
139
|
+
_localVouchers = _buildSubmitPayload.vouchers,
|
|
140
|
+
payload = _objectWithoutProperties(_buildSubmitPayload, _excluded);
|
|
141
|
+
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
142
|
+
// 调时提交无需自动打印整单小票;Redeem & Print 由票券按钮发起打印。
|
|
143
|
+
small_ticket_data_flag: 0
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
export function describeChangedBookings(before, after) {
|
|
147
|
+
var changes = [];
|
|
148
|
+
var _iterator2 = _createForOfIteratorHelper(after.entries()),
|
|
149
|
+
_step2;
|
|
150
|
+
try {
|
|
151
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
152
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
153
|
+
index = _step2$value[0],
|
|
154
|
+
booking = _step2$value[1];
|
|
155
|
+
var previous = before[index];
|
|
156
|
+
if (booking === previous) continue;
|
|
157
|
+
changes.push({
|
|
158
|
+
schedule_event_id: booking.schedule_event_id,
|
|
159
|
+
previous_start: previous.start_time,
|
|
160
|
+
previous_end: previous.end_time,
|
|
161
|
+
start: booking.start_time,
|
|
162
|
+
end: booking.end_time
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
} catch (err) {
|
|
166
|
+
_iterator2.e(err);
|
|
167
|
+
} finally {
|
|
168
|
+
_iterator2.f();
|
|
169
|
+
}
|
|
170
|
+
return changes;
|
|
171
|
+
}
|
|
@@ -100,6 +100,9 @@ export interface OpenDataConfig {
|
|
|
100
100
|
'sale.short_number_prefix'?: string | null;
|
|
101
101
|
'sale.sale_number_prefix'?: string | null;
|
|
102
102
|
'sale.enabled_item_rules'?: number[];
|
|
103
|
+
'fulfillment.enable_adjust_session_on_arrival'?: boolean | 0 | 1;
|
|
104
|
+
'fulfillment.max_earlier_shift_minutes'?: number | string;
|
|
105
|
+
'fulfillment.max_later_shift_minutes'?: number | string;
|
|
103
106
|
'fulfillment.enable_pickup'?: boolean;
|
|
104
107
|
'fulfillment.handover_mode'?: string[];
|
|
105
108
|
'fulfillment.pickup.timing_mode'?: 'asap_only' | 'scheduled_only' | 'asap_and_scheduled';
|
|
@@ -4740,6 +4740,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4740
4740
|
metadata: {
|
|
4741
4741
|
...(targetBooking.metadata || {}),
|
|
4742
4742
|
...(updates.metadata || {}),
|
|
4743
|
+
...(Number(targetBooking.metadata?.is_change_by_redeem) === 1 ? {
|
|
4744
|
+
is_change_by_redeem: 1
|
|
4745
|
+
} : {}),
|
|
4743
4746
|
unique_identification_number: bookingUid
|
|
4744
4747
|
}
|
|
4745
4748
|
};
|
|
@@ -5919,7 +5922,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5919
5922
|
if (options?.ensureIdentity !== false) {
|
|
5920
5923
|
this.ensureExternalSaleNumber(nextTempOrder);
|
|
5921
5924
|
}
|
|
5922
|
-
nextTempOrder.vouchers = raw.vouchers || [];
|
|
5925
|
+
nextTempOrder.vouchers = (0, _utils.restoreRedeemVoucherTimes)(nextTempOrder, raw.vouchers || []);
|
|
5923
5926
|
return nextTempOrder;
|
|
5924
5927
|
}
|
|
5925
5928
|
isSyntheticDraftOrderIdForRuntime(record, options) {
|
|
@@ -644,7 +644,7 @@ export interface SubmitSalesOrderParams {
|
|
|
644
644
|
holder_relations?: OrderHolderRelation[];
|
|
645
645
|
bookings: OrderSubmitBooking[];
|
|
646
646
|
payments: any[];
|
|
647
|
-
vouchers
|
|
647
|
+
vouchers?: any[];
|
|
648
648
|
surcharges?: any[];
|
|
649
649
|
relation_forms: any[];
|
|
650
650
|
form_record_ids?: OrderSubmitFormRecord[];
|
|
@@ -208,6 +208,10 @@ export declare const getAllDiscountList: (cartItem: CartItem) => any;
|
|
|
208
208
|
export { createUuidV4 };
|
|
209
209
|
export declare function isTempOrder(data: any): data is OrderTempOrder;
|
|
210
210
|
export declare function formatDateTime(date: Date): string;
|
|
211
|
+
/** 旧票券可能没有事件 ID;缺失或占位值不能用于关联预约。 */
|
|
212
|
+
export declare function redeemEventKey(value: unknown): string | undefined;
|
|
213
|
+
/** checkout 提交子预约的标记;重新加载订单时,从已调时的子预约恢复关联票券的票面时段。 */
|
|
214
|
+
export declare function restoreRedeemVoucherTimes(order: Pick<OrderTempOrder, 'bookings'>, vouchers: any[]): any[];
|
|
211
215
|
export declare function normalizeBookingIsAll(booking: Record<string, any>): 0 | 1;
|
|
212
216
|
export declare function normalizeBookingSubType(booking: Record<string, any>): string;
|
|
213
217
|
export declare function normalizeSubmitBooking<T extends {
|