@pisell/pisellos 2.3.228 → 2.3.230
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 +9 -0
- package/dist/modules/Customer/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +123 -79
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/dist/modules/Order/utils/bookingUuid.js +24 -0
- package/dist/modules/Order/utils.js +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Summary/utils.d.ts +1 -1
- package/dist/solution/BaseSales/index.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -3
- package/dist/solution/BookingTicket/index.d.ts +1 -0
- package/dist/solution/BookingTicket/index.js +49 -18
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +6 -6
- package/dist/solution/Checkout/index.js +104 -69
- package/dist/solution/Checkout/types.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +10 -2
- package/dist/solution/VenueBooking/index.js +522 -490
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Customer/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +44 -6
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/lib/modules/Order/utils/bookingUuid.js +25 -0
- package/lib/modules/Order/utils.js +5 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Summary/utils.d.ts +1 -1
- package/lib/solution/BaseSales/index.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -3
- package/lib/solution/BookingTicket/index.d.ts +1 -0
- package/lib/solution/BookingTicket/index.js +27 -6
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +6 -6
- package/lib/solution/Checkout/index.js +21 -0
- package/lib/solution/Checkout/types.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +6 -0
- package/lib/solution/VenueBooking/index.js +6 -1
- package/package.json +1 -1
|
@@ -295,6 +295,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
295
295
|
private getCustomerContactOrderKey;
|
|
296
296
|
replaceTempOrder(...args: Parameters<BaseSalesImpl['replaceTempOrder']>): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
297
297
|
private applyDefaultOrderCustomerContactInfo;
|
|
298
|
+
private withAccountNameFallback;
|
|
298
299
|
private prefillOrderCustomerContactInfo;
|
|
299
300
|
protected waitForOrderCustomerContactInfo(): Promise<void>;
|
|
300
301
|
validateContactInfo(): Promise<void>;
|
|
@@ -2047,26 +2047,56 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2047
2047
|
}
|
|
2048
2048
|
return applyDefaultOrderCustomerContactInfo;
|
|
2049
2049
|
}()
|
|
2050
|
+
}, {
|
|
2051
|
+
key: "withAccountNameFallback",
|
|
2052
|
+
value: function withAccountNameFallback(contact, customer) {
|
|
2053
|
+
var next = contact;
|
|
2054
|
+
// Saved booking contacts take precedence. Only missing name fields fall back
|
|
2055
|
+
// to the account profile; phone/email keep their existing contact-info source.
|
|
2056
|
+
var _iterator2 = _createForOfIteratorHelper(['first_name', 'last_name']),
|
|
2057
|
+
_step2;
|
|
2058
|
+
try {
|
|
2059
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2060
|
+
var field = _step2.value;
|
|
2061
|
+
if (typeof (contact === null || contact === void 0 ? void 0 : contact[field]) === 'string' && contact[field].trim()) continue;
|
|
2062
|
+
var name = customer[field];
|
|
2063
|
+
if (typeof name !== 'string' || !name.trim()) continue;
|
|
2064
|
+
if (next === contact) next = _objectSpread({}, contact);
|
|
2065
|
+
next[field] = name.trim();
|
|
2066
|
+
}
|
|
2067
|
+
} catch (err) {
|
|
2068
|
+
_iterator2.e(err);
|
|
2069
|
+
} finally {
|
|
2070
|
+
_iterator2.f();
|
|
2071
|
+
}
|
|
2072
|
+
return next;
|
|
2073
|
+
}
|
|
2050
2074
|
}, {
|
|
2051
2075
|
key: "prefillOrderCustomerContactInfo",
|
|
2052
2076
|
value: function prefillOrderCustomerContactInfo(customer, customerChanged) {
|
|
2053
2077
|
var _order$_extend2,
|
|
2078
|
+
_order$contacts_info,
|
|
2054
2079
|
_this$otherParams9,
|
|
2055
2080
|
_this5 = this;
|
|
2056
2081
|
var order = this.getTempOrder();
|
|
2057
2082
|
var customerId = Number(order === null || order === void 0 ? void 0 : order.customer_id);
|
|
2058
|
-
if (!order || !Number.isInteger(customerId) || customerId <= 1 ||
|
|
2083
|
+
if (!order || !Number.isInteger(customerId) || customerId <= 1 || (_order$_extend2 = order._extend) !== null && _order$_extend2 !== void 0 && _order$_extend2.contactInfoEdited) return;
|
|
2059
2084
|
// A restored new cart may already have its customer ID. Existing sales keep their snapshot,
|
|
2060
2085
|
// even when it is empty; only an explicit customer switch replaces it.
|
|
2061
2086
|
if (!customerChanged && order.order_id && !String(order.order_id).startsWith('local_order')) return;
|
|
2062
|
-
var contact = extractCustomerContactInfo(customer);
|
|
2087
|
+
var contact = (_order$contacts_info = order.contacts_info) !== null && _order$contacts_info !== void 0 ? _order$contacts_info : extractCustomerContactInfo(customer);
|
|
2063
2088
|
if (contact) {
|
|
2064
2089
|
this.orderCustomerContactRequest = null;
|
|
2065
|
-
|
|
2090
|
+
var next = this.withAccountNameFallback(contact, customer);
|
|
2091
|
+
if (next !== order.contacts_info) void this.applyDefaultOrderCustomerContactInfo(next);
|
|
2066
2092
|
return;
|
|
2067
2093
|
}
|
|
2068
2094
|
// A relation explicitly returned as null is authoritative. Only a missing relation needs fetching.
|
|
2069
|
-
if (customer.contacts_info !== undefined)
|
|
2095
|
+
if (customer.contacts_info !== undefined) {
|
|
2096
|
+
var _next3 = this.withAccountNameFallback(null, customer);
|
|
2097
|
+
if (_next3) void this.applyDefaultOrderCustomerContactInfo(_next3);
|
|
2098
|
+
return;
|
|
2099
|
+
}
|
|
2070
2100
|
var userPlatform = isCustomerUserPlatform((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.platform);
|
|
2071
2101
|
var getAuthenticatedCustomerId = function getAuthenticatedCustomerId() {
|
|
2072
2102
|
var _this5$core, _this5$core$getPlugin, _this5$core$getPlugin2;
|
|
@@ -2112,7 +2142,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2112
2142
|
return _this5.resolveCustomerById(customerId);
|
|
2113
2143
|
case 9:
|
|
2114
2144
|
resolved = _context30.sent;
|
|
2115
|
-
return _context30.abrupt("return",
|
|
2145
|
+
return _context30.abrupt("return", resolved && Number(resolved.id) === customerId ? _this5.withAccountNameFallback(extractCustomerContactInfo(resolved), resolved) : null);
|
|
2116
2146
|
case 11:
|
|
2117
2147
|
case "end":
|
|
2118
2148
|
return _context30.stop();
|
|
@@ -2126,7 +2156,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2126
2156
|
pending.promise = loadContact().then( /*#__PURE__*/function () {
|
|
2127
2157
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(value) {
|
|
2128
2158
|
var _current$_extend;
|
|
2129
|
-
var current;
|
|
2159
|
+
var current, next;
|
|
2130
2160
|
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2131
2161
|
while (1) switch (_context31.prev = _context31.next) {
|
|
2132
2162
|
case 0:
|
|
@@ -2137,13 +2167,14 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2137
2167
|
}
|
|
2138
2168
|
return _context31.abrupt("return");
|
|
2139
2169
|
case 3:
|
|
2140
|
-
|
|
2141
|
-
|
|
2170
|
+
next = _this5.withAccountNameFallback(value, customer);
|
|
2171
|
+
if (!next) {
|
|
2172
|
+
_context31.next = 7;
|
|
2142
2173
|
break;
|
|
2143
2174
|
}
|
|
2144
|
-
_context31.next =
|
|
2145
|
-
return _this5.applyDefaultOrderCustomerContactInfo(
|
|
2146
|
-
case
|
|
2175
|
+
_context31.next = 7;
|
|
2176
|
+
return _this5.applyDefaultOrderCustomerContactInfo(next);
|
|
2177
|
+
case 7:
|
|
2147
2178
|
case "end":
|
|
2148
2179
|
return _context31.stop();
|
|
2149
2180
|
}
|
|
@@ -3516,7 +3547,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3516
3547
|
var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(input) {
|
|
3517
3548
|
var _this13 = this,
|
|
3518
3549
|
_input$bookingPatch;
|
|
3519
|
-
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result,
|
|
3550
|
+
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator3, _step3, line;
|
|
3520
3551
|
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3521
3552
|
while (1) switch (_context46.prev = _context46.next) {
|
|
3522
3553
|
case 0:
|
|
@@ -3553,15 +3584,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3553
3584
|
return _context46.abrupt("return", this.store.order.addProductsToOrder(orderLines));
|
|
3554
3585
|
case 11:
|
|
3555
3586
|
result = [];
|
|
3556
|
-
|
|
3587
|
+
_iterator3 = _createForOfIteratorHelper(orderLines);
|
|
3557
3588
|
_context46.prev = 13;
|
|
3558
|
-
|
|
3589
|
+
_iterator3.s();
|
|
3559
3590
|
case 15:
|
|
3560
|
-
if ((
|
|
3591
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
3561
3592
|
_context46.next = 29;
|
|
3562
3593
|
break;
|
|
3563
3594
|
}
|
|
3564
|
-
line =
|
|
3595
|
+
line = _step3.value;
|
|
3565
3596
|
_context46.t0 = result.splice;
|
|
3566
3597
|
_context46.t1 = result;
|
|
3567
3598
|
_context46.t2 = [0, result.length];
|
|
@@ -3582,10 +3613,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3582
3613
|
case 31:
|
|
3583
3614
|
_context46.prev = 31;
|
|
3584
3615
|
_context46.t7 = _context46["catch"](13);
|
|
3585
|
-
|
|
3616
|
+
_iterator3.e(_context46.t7);
|
|
3586
3617
|
case 34:
|
|
3587
3618
|
_context46.prev = 34;
|
|
3588
|
-
|
|
3619
|
+
_iterator3.f();
|
|
3589
3620
|
return _context46.finish(34);
|
|
3590
3621
|
case 37:
|
|
3591
3622
|
return _context46.abrupt("return", result);
|
|
@@ -26,12 +26,16 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
27
|
small_ticket_data_flag?: number | undefined;
|
|
28
28
|
metadata: Record<string, any>;
|
|
29
|
+
type: string;
|
|
29
30
|
note: string;
|
|
31
|
+
holder: Record<string, any> | null;
|
|
32
|
+
relation_forms: any[];
|
|
33
|
+
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
30
34
|
order_id: number | null;
|
|
35
|
+
external_sale_number: string;
|
|
31
36
|
order_number: string | null;
|
|
32
37
|
shop_order_number: string | null;
|
|
33
38
|
shop_full_order_number: string | null;
|
|
34
|
-
type: string;
|
|
35
39
|
business_code?: string | undefined;
|
|
36
40
|
sales_channel: string;
|
|
37
41
|
order_sales_channel: string;
|
|
@@ -58,14 +62,10 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
58
62
|
schedule_date: string;
|
|
59
63
|
bookings: any[];
|
|
60
64
|
payments: any[];
|
|
65
|
+
refunds?: any[] | undefined;
|
|
61
66
|
surcharges: any[];
|
|
62
|
-
relation_forms: any[];
|
|
63
67
|
contacts: any[];
|
|
64
68
|
contacts_info: Record<string, any> | null;
|
|
65
|
-
holder: Record<string, any> | null;
|
|
66
|
-
external_sale_number: string;
|
|
67
|
-
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
68
|
-
refunds?: any[] | undefined;
|
|
69
69
|
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
70
70
|
};
|
|
71
71
|
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
@@ -31,6 +31,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
31
31
|
import { BaseModule } from "../../modules/BaseModule";
|
|
32
32
|
import Decimal from 'decimal.js';
|
|
33
33
|
import { OrderModule } from "../../modules/Order";
|
|
34
|
+
import { assignBookingUuid } from "../../modules/Order/utils/bookingUuid";
|
|
35
|
+
import { getOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
34
36
|
import { PaymentModule } from "../../modules/Payment";
|
|
35
37
|
import { CheckoutErrorType } from "./types";
|
|
36
38
|
import { PaymentStatus, PaymentHooks } from "../../modules/Payment/types";
|
|
@@ -605,7 +607,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
605
607
|
value: (function () {
|
|
606
608
|
var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
607
609
|
var _params$orderData, _params$orderData2, _params$orderData3, _params$orderData4, _params$orderData5, _params$cartSummary;
|
|
608
|
-
var _params$totalInfo, _params$totalInfo2, _params$totalInfo3, _params$totalInfo4, validation, localOrderId, amountInfo, customerInfo, isNeedDeposit, paymentOrder, updateAmountStartTime, updateAmountDuration;
|
|
610
|
+
var _params$totalInfo, _params$totalInfo2, _params$totalInfo3, _params$totalInfo4, _params$orderData$boo, validation, localOrderId, amountInfo, customerInfo, isNeedDeposit, paymentOrder, updateAmountStartTime, updateAmountDuration;
|
|
609
611
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
610
612
|
while (1) switch (_context9.prev = _context9.next) {
|
|
611
613
|
case 0:
|
|
@@ -645,6 +647,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
645
647
|
params.orderData.tax_fee = (_params$totalInfo4 = params.totalInfo) === null || _params$totalInfo4 === void 0 || (_params$totalInfo4 = _params$totalInfo4.total) === null || _params$totalInfo4 === void 0 ? void 0 : _params$totalInfo4.tax;
|
|
646
648
|
|
|
647
649
|
// 保存原始订单数据和小计数据到状态中
|
|
650
|
+
(_params$orderData$boo = params.orderData.bookings) === null || _params$orderData$boo === void 0 || _params$orderData$boo.forEach(assignBookingUuid);
|
|
648
651
|
this.store.localOrderData = params.orderData;
|
|
649
652
|
this.store.cartSummary = params.cartSummary;
|
|
650
653
|
|
|
@@ -661,7 +664,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
661
664
|
|
|
662
665
|
// 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
663
666
|
isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 创建支付订单对象
|
|
664
|
-
_context9.next =
|
|
667
|
+
_context9.next = 22;
|
|
665
668
|
return this.payment.createPaymentOrderAsync({
|
|
666
669
|
order_id: localOrderId,
|
|
667
670
|
total_amount: amountInfo.totalAmount,
|
|
@@ -678,7 +681,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
678
681
|
amount_breakdown: amountInfo
|
|
679
682
|
}
|
|
680
683
|
});
|
|
681
|
-
case
|
|
684
|
+
case 22:
|
|
682
685
|
paymentOrder = _context9.sent;
|
|
683
686
|
this.store.currentOrder = paymentOrder;
|
|
684
687
|
|
|
@@ -695,9 +698,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
695
698
|
// 自动设置 stateAmount 为剩余未支付金额
|
|
696
699
|
// 🚀 性能监控:记录 updateStateAmountToRemaining 操作耗时
|
|
697
700
|
updateAmountStartTime = Date.now();
|
|
698
|
-
_context9.next =
|
|
701
|
+
_context9.next = 28;
|
|
699
702
|
return this.updateStateAmountToRemaining(false);
|
|
700
|
-
case
|
|
703
|
+
case 28:
|
|
701
704
|
updateAmountDuration = Date.now() - updateAmountStartTime;
|
|
702
705
|
this.logInfo('updateStateAmountToRemaining operation completed', {
|
|
703
706
|
operation: 'updateStateAmountToRemaining',
|
|
@@ -716,23 +719,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
716
719
|
});
|
|
717
720
|
this.initWalletData();
|
|
718
721
|
return _context9.abrupt("return", paymentOrder);
|
|
719
|
-
case
|
|
720
|
-
_context9.prev =
|
|
722
|
+
case 35:
|
|
723
|
+
_context9.prev = 35;
|
|
721
724
|
_context9.t0 = _context9["catch"](1);
|
|
722
|
-
_context9.next =
|
|
725
|
+
_context9.next = 39;
|
|
723
726
|
return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
|
|
724
|
-
case
|
|
727
|
+
case 39:
|
|
725
728
|
this.logError('本地订单创建失败:', _context9.t0);
|
|
726
729
|
this.core.effects.emit("".concat(this.name, ":onOrderCreationFailed"), {
|
|
727
730
|
error: this.store.lastError,
|
|
728
731
|
timestamp: Date.now()
|
|
729
732
|
});
|
|
730
733
|
throw _context9.t0;
|
|
731
|
-
case
|
|
734
|
+
case 42:
|
|
732
735
|
case "end":
|
|
733
736
|
return _context9.stop();
|
|
734
737
|
}
|
|
735
|
-
}, _callee9, this, [[1,
|
|
738
|
+
}, _callee9, this, [[1, 35]]);
|
|
736
739
|
}));
|
|
737
740
|
function createLocalOrderAsync(_x11) {
|
|
738
741
|
return _createLocalOrderAsync.apply(this, arguments);
|
|
@@ -750,8 +753,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
750
753
|
key: "updateLocalOrderAsync",
|
|
751
754
|
value: (function () {
|
|
752
755
|
var _updateLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
753
|
-
var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8, _this$store$currentOr9, _this$store$currentOr10;
|
|
754
|
-
var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment2, _existingOrder$paymen, _updated$payment, currentTime, formattedExistPayments, _isNeedDeposit, _updated, syncedPayments, _syncedAmount, _totalAmount, _remainingExpectAmount, _depositDiffAmount, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit2, updated, syncedAmount, remainingExpectAmount, depositDiffAmount, isNeedDeposit, created, _syncedPayments, _syncedAmount2;
|
|
756
|
+
var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8, _existingOrder$order_, _this$store$currentOr9, _this$store$currentOr10;
|
|
757
|
+
var validation, amountInfo, customerInfo, allOrders, existingOrder, previousBookings, previousUuids, _iterator, _step, booking, uid, _iterator2, _step2, _booking, _uid, _booking$uuid, _updated$payment2, _existingOrder$paymen, _updated$payment, currentTime, formattedExistPayments, _isNeedDeposit, _updated, syncedPayments, _syncedAmount, _totalAmount, _remainingExpectAmount, _depositDiffAmount, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit2, updated, syncedAmount, remainingExpectAmount, depositDiffAmount, isNeedDeposit, created, _syncedPayments, _syncedAmount2;
|
|
755
758
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
756
759
|
while (1) switch (_context10.prev = _context10.next) {
|
|
757
760
|
case 0:
|
|
@@ -803,13 +806,45 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
803
806
|
allOrders = _context10.sent;
|
|
804
807
|
existingOrder = allOrders.find(function (o) {
|
|
805
808
|
return String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId);
|
|
806
|
-
});
|
|
809
|
+
}); // POS 再次保存会重建预约行;按已有行标识复用上次保存的 UUID。
|
|
810
|
+
previousBookings = existingOrder === null || existingOrder === void 0 || (_existingOrder$order_ = existingOrder.order_info) === null || _existingOrder$order_ === void 0 || (_existingOrder$order_ = _existingOrder$order_.original_order_data) === null || _existingOrder$order_ === void 0 ? void 0 : _existingOrder$order_.bookings;
|
|
811
|
+
previousUuids = new Map();
|
|
812
|
+
if (Array.isArray(previousBookings)) {
|
|
813
|
+
_iterator = _createForOfIteratorHelper(previousBookings);
|
|
814
|
+
try {
|
|
815
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
816
|
+
booking = _step.value;
|
|
817
|
+
uid = getOrderCollectionUid('booking', booking);
|
|
818
|
+
if (uid && booking.uuid !== undefined) previousUuids.set(uid, booking.uuid);
|
|
819
|
+
}
|
|
820
|
+
} catch (err) {
|
|
821
|
+
_iterator.e(err);
|
|
822
|
+
} finally {
|
|
823
|
+
_iterator.f();
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
_iterator2 = _createForOfIteratorHelper(params.orderData.bookings || []);
|
|
827
|
+
try {
|
|
828
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
829
|
+
_booking = _step2.value;
|
|
830
|
+
_uid = getOrderCollectionUid('booking', _booking);
|
|
831
|
+
if (_uid && previousUuids.has(_uid)) {
|
|
832
|
+
(_booking$uuid = _booking.uuid) !== null && _booking$uuid !== void 0 ? _booking$uuid : _booking.uuid = previousUuids.get(_uid);
|
|
833
|
+
previousUuids.delete(_uid);
|
|
834
|
+
}
|
|
835
|
+
assignBookingUuid(_booking);
|
|
836
|
+
}
|
|
837
|
+
} catch (err) {
|
|
838
|
+
_iterator2.e(err);
|
|
839
|
+
} finally {
|
|
840
|
+
_iterator2.f();
|
|
841
|
+
}
|
|
807
842
|
if (!existingOrder) {
|
|
808
|
-
_context10.next =
|
|
843
|
+
_context10.next = 77;
|
|
809
844
|
break;
|
|
810
845
|
}
|
|
811
846
|
if (!(params.existPayment && params.existPayment.length > 0)) {
|
|
812
|
-
_context10.next =
|
|
847
|
+
_context10.next = 53;
|
|
813
848
|
break;
|
|
814
849
|
}
|
|
815
850
|
this.logInfo('检测到云端支付项,将替换本地订单的支付项列表', {
|
|
@@ -833,7 +868,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
833
868
|
});
|
|
834
869
|
}); // 计算是否需要支付定金
|
|
835
870
|
_isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新订单,替换支付项列表
|
|
836
|
-
_context10.next =
|
|
871
|
+
_context10.next = 34;
|
|
837
872
|
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
838
873
|
total_amount: amountInfo.totalAmount,
|
|
839
874
|
is_deposit: _isNeedDeposit.hasDeposit ? 1 : 0,
|
|
@@ -851,21 +886,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
851
886
|
amount_breakdown: amountInfo
|
|
852
887
|
}
|
|
853
888
|
});
|
|
854
|
-
case
|
|
855
|
-
_context10.next =
|
|
889
|
+
case 34:
|
|
890
|
+
_context10.next = 36;
|
|
856
891
|
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
857
|
-
case
|
|
892
|
+
case 36:
|
|
858
893
|
_updated = _context10.sent;
|
|
859
894
|
if (_updated) {
|
|
860
|
-
_context10.next =
|
|
895
|
+
_context10.next = 39;
|
|
861
896
|
break;
|
|
862
897
|
}
|
|
863
898
|
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
864
|
-
case
|
|
899
|
+
case 39:
|
|
865
900
|
this.store.currentOrder = _updated;
|
|
866
|
-
_context10.next =
|
|
901
|
+
_context10.next = 42;
|
|
867
902
|
return this.updateStateAmountToRemaining(false);
|
|
868
|
-
case
|
|
903
|
+
case 42:
|
|
869
904
|
this.logInfo('本地订单更新成功(已替换云端支付项):', {
|
|
870
905
|
orderId: params.orderId,
|
|
871
906
|
uuid: _updated.uuid,
|
|
@@ -876,12 +911,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
876
911
|
});
|
|
877
912
|
|
|
878
913
|
// 事件通知
|
|
879
|
-
_context10.next =
|
|
914
|
+
_context10.next = 45;
|
|
880
915
|
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
881
916
|
order: _updated,
|
|
882
917
|
timestamp: Date.now()
|
|
883
918
|
});
|
|
884
|
-
case
|
|
919
|
+
case 45:
|
|
885
920
|
// 计算已同步的支付金额
|
|
886
921
|
syncedPayments = _updated.payment.filter(function (p) {
|
|
887
922
|
return p.isSynced && p.status !== 'voided';
|
|
@@ -901,7 +936,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
901
936
|
order_wait_pay_amount: Number(_depositDiffAmount) > 0 ? Number(_depositDiffAmount) : Number(_remainingExpectAmount)
|
|
902
937
|
});
|
|
903
938
|
return _context10.abrupt("return", _updated);
|
|
904
|
-
case
|
|
939
|
+
case 53:
|
|
905
940
|
// 原有逻辑:保留现有支付项
|
|
906
941
|
totalAmount = new Decimal(amountInfo.totalAmount || '0');
|
|
907
942
|
activePayments = (existingOrder.payment || []).filter(function (p) {
|
|
@@ -914,7 +949,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
914
949
|
}, new Decimal(0));
|
|
915
950
|
remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
916
951
|
_isNeedDeposit2 = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新到支付模块(使用 uuid,不修改 payment 列表)
|
|
917
|
-
_context10.next =
|
|
952
|
+
_context10.next = 60;
|
|
918
953
|
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
919
954
|
total_amount: amountInfo.totalAmount,
|
|
920
955
|
is_deposit: _isNeedDeposit2.hasDeposit ? 1 : 0,
|
|
@@ -931,21 +966,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
931
966
|
amount_breakdown: amountInfo
|
|
932
967
|
}
|
|
933
968
|
});
|
|
934
|
-
case
|
|
935
|
-
_context10.next =
|
|
969
|
+
case 60:
|
|
970
|
+
_context10.next = 62;
|
|
936
971
|
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
937
|
-
case
|
|
972
|
+
case 62:
|
|
938
973
|
updated = _context10.sent;
|
|
939
974
|
if (updated) {
|
|
940
|
-
_context10.next =
|
|
975
|
+
_context10.next = 65;
|
|
941
976
|
break;
|
|
942
977
|
}
|
|
943
978
|
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
944
|
-
case
|
|
979
|
+
case 65:
|
|
945
980
|
this.store.currentOrder = updated;
|
|
946
|
-
_context10.next =
|
|
981
|
+
_context10.next = 68;
|
|
947
982
|
return this.updateStateAmountToRemaining(false);
|
|
948
|
-
case
|
|
983
|
+
case 68:
|
|
949
984
|
this.logInfo('本地订单更新成功(保留支付项):', {
|
|
950
985
|
orderId: params.orderId,
|
|
951
986
|
uuid: updated.uuid,
|
|
@@ -955,12 +990,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
955
990
|
});
|
|
956
991
|
|
|
957
992
|
// 事件通知(复用创建事件,便于上层监听刷新)
|
|
958
|
-
_context10.next =
|
|
993
|
+
_context10.next = 71;
|
|
959
994
|
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
960
995
|
order: updated,
|
|
961
996
|
timestamp: Date.now()
|
|
962
997
|
});
|
|
963
|
-
case
|
|
998
|
+
case 71:
|
|
964
999
|
// 需要减去已经同步给后端的支付过的钱
|
|
965
1000
|
syncedAmount = activePayments.reduce(function (sum, p) {
|
|
966
1001
|
var amt = new Decimal(p.amount || '0');
|
|
@@ -976,10 +1011,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
976
1011
|
order_wait_pay_amount: Number(depositDiffAmount) > 0 ? Number(depositDiffAmount) : Number(remainingExpectAmount)
|
|
977
1012
|
});
|
|
978
1013
|
return _context10.abrupt("return", updated);
|
|
979
|
-
case
|
|
1014
|
+
case 77:
|
|
980
1015
|
// 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
981
1016
|
isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 没找到现有订单时,回退为创建逻辑(用于异常兜底)
|
|
982
|
-
_context10.next =
|
|
1017
|
+
_context10.next = 80;
|
|
983
1018
|
return this.payment.createPaymentOrderAsync({
|
|
984
1019
|
order_id: String(params.orderId),
|
|
985
1020
|
total_amount: amountInfo.totalAmount,
|
|
@@ -998,7 +1033,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
998
1033
|
amount_breakdown: amountInfo
|
|
999
1034
|
}
|
|
1000
1035
|
});
|
|
1001
|
-
case
|
|
1036
|
+
case 80:
|
|
1002
1037
|
created = _context10.sent;
|
|
1003
1038
|
this.store.currentOrder = created;
|
|
1004
1039
|
|
|
@@ -1034,7 +1069,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1034
1069
|
this.initWalletData();
|
|
1035
1070
|
}
|
|
1036
1071
|
return _context10.abrupt("return", created);
|
|
1037
|
-
case
|
|
1072
|
+
case 84:
|
|
1038
1073
|
case "end":
|
|
1039
1074
|
return _context10.stop();
|
|
1040
1075
|
}
|
|
@@ -2821,7 +2856,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2821
2856
|
key: "cleanupExpiredOrdersAsync",
|
|
2822
2857
|
value: (function () {
|
|
2823
2858
|
var _cleanupExpiredOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2824
|
-
var cleanupConfig, isCleanupEnabled, retentionDays, maxOrdersToDelete, allOrders, thresholdDate, deletedCount, ordersToDelete,
|
|
2859
|
+
var cleanupConfig, isCleanupEnabled, retentionDays, maxOrdersToDelete, allOrders, thresholdDate, deletedCount, ordersToDelete, _iterator3, _step3, order, _order$order_info, _order$order_info2, isSynced, orderCreatedAt, actualOrdersToDelete, _iterator4, _step4, orderInfo, summary, errorMessage;
|
|
2825
2860
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2826
2861
|
while (1) switch (_context30.prev = _context30.next) {
|
|
2827
2862
|
case 0:
|
|
@@ -2851,15 +2886,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2851
2886
|
thresholdDate.setDate(thresholdDate.getDate() - retentionDays);
|
|
2852
2887
|
deletedCount = 0;
|
|
2853
2888
|
ordersToDelete = [];
|
|
2854
|
-
|
|
2889
|
+
_iterator3 = _createForOfIteratorHelper(allOrders);
|
|
2855
2890
|
_context30.prev = 17;
|
|
2856
|
-
|
|
2891
|
+
_iterator3.s();
|
|
2857
2892
|
case 19:
|
|
2858
|
-
if ((
|
|
2893
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
2859
2894
|
_context30.next = 38;
|
|
2860
2895
|
break;
|
|
2861
2896
|
}
|
|
2862
|
-
order =
|
|
2897
|
+
order = _step3.value;
|
|
2863
2898
|
_context30.prev = 21;
|
|
2864
2899
|
// 检查订单是否已同步(订单ID不是虚拟ID)
|
|
2865
2900
|
isSynced = order.order_id && !isVirtualOrderId(order.order_id);
|
|
@@ -2911,10 +2946,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2911
2946
|
case 40:
|
|
2912
2947
|
_context30.prev = 40;
|
|
2913
2948
|
_context30.t1 = _context30["catch"](17);
|
|
2914
|
-
|
|
2949
|
+
_iterator3.e(_context30.t1);
|
|
2915
2950
|
case 43:
|
|
2916
2951
|
_context30.prev = 43;
|
|
2917
|
-
|
|
2952
|
+
_iterator3.f();
|
|
2918
2953
|
return _context30.finish(43);
|
|
2919
2954
|
case 46:
|
|
2920
2955
|
// 按创建时间排序(最老的先删除)并限制删除数量
|
|
@@ -2922,15 +2957,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2922
2957
|
return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
|
|
2923
2958
|
});
|
|
2924
2959
|
actualOrdersToDelete = ordersToDelete.slice(0, maxOrdersToDelete); // 删除符合条件的订单
|
|
2925
|
-
|
|
2960
|
+
_iterator4 = _createForOfIteratorHelper(actualOrdersToDelete);
|
|
2926
2961
|
_context30.prev = 49;
|
|
2927
|
-
|
|
2962
|
+
_iterator4.s();
|
|
2928
2963
|
case 51:
|
|
2929
|
-
if ((
|
|
2964
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
2930
2965
|
_context30.next = 64;
|
|
2931
2966
|
break;
|
|
2932
2967
|
}
|
|
2933
|
-
orderInfo =
|
|
2968
|
+
orderInfo = _step4.value;
|
|
2934
2969
|
_context30.prev = 53;
|
|
2935
2970
|
_context30.next = 56;
|
|
2936
2971
|
return this.payment.deletePaymentOrderAsync(orderInfo.uuid);
|
|
@@ -2951,10 +2986,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2951
2986
|
case 66:
|
|
2952
2987
|
_context30.prev = 66;
|
|
2953
2988
|
_context30.t3 = _context30["catch"](49);
|
|
2954
|
-
|
|
2989
|
+
_iterator4.e(_context30.t3);
|
|
2955
2990
|
case 69:
|
|
2956
2991
|
_context30.prev = 69;
|
|
2957
|
-
|
|
2992
|
+
_iterator4.f();
|
|
2958
2993
|
return _context30.finish(69);
|
|
2959
2994
|
case 72:
|
|
2960
2995
|
summary = {
|
|
@@ -3819,7 +3854,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3819
3854
|
_checkoutResponse4,
|
|
3820
3855
|
_checkoutResponse5,
|
|
3821
3856
|
_checkoutResponse9;
|
|
3822
|
-
var orderUuid, paymentOrder, localOrderData, paymentItems, processedPaymentItems, finalDepositAmount, manualDepositAmount, manualDepositValue, orderPaymentStatus, totalPaidAmount, orderParams, currentOrderId, isUpdateOperation, startTime, checkoutResponse, submitSuccess, submitError, _checkoutResponse, _checkoutResponse2, _checkoutResponse3, responseStatus, isSuccessResponse, _checkoutResponse6, errorMessage, realOrderId, _checkoutResponse7, extractedOrderId, _checkoutResponse8, syncedPaymentUuids,
|
|
3857
|
+
var orderUuid, paymentOrder, localOrderData, paymentItems, processedPaymentItems, finalDepositAmount, manualDepositAmount, manualDepositValue, orderPaymentStatus, totalPaidAmount, orderParams, currentOrderId, isUpdateOperation, startTime, checkoutResponse, submitSuccess, submitError, _checkoutResponse, _checkoutResponse2, _checkoutResponse3, responseStatus, isSuccessResponse, _checkoutResponse6, errorMessage, realOrderId, _checkoutResponse7, extractedOrderId, _checkoutResponse8, syncedPaymentUuids, _iterator5, _step5, paymentUuid, latestPaymentStatus;
|
|
3823
3858
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3824
3859
|
while (1) switch (_context40.prev = _context40.next) {
|
|
3825
3860
|
case 0:
|
|
@@ -4058,15 +4093,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4058
4093
|
}).map(function (item) {
|
|
4059
4094
|
return item.uuid;
|
|
4060
4095
|
}).filter(Boolean);
|
|
4061
|
-
|
|
4096
|
+
_iterator5 = _createForOfIteratorHelper(syncedPaymentUuids);
|
|
4062
4097
|
_context40.prev = 69;
|
|
4063
|
-
|
|
4098
|
+
_iterator5.s();
|
|
4064
4099
|
case 71:
|
|
4065
|
-
if ((
|
|
4100
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
4066
4101
|
_context40.next = 77;
|
|
4067
4102
|
break;
|
|
4068
4103
|
}
|
|
4069
|
-
paymentUuid =
|
|
4104
|
+
paymentUuid = _step5.value;
|
|
4070
4105
|
_context40.next = 75;
|
|
4071
4106
|
return this.payment.updatePaymentAsync(orderUuid, paymentUuid, {
|
|
4072
4107
|
isSynced: true,
|
|
@@ -4081,10 +4116,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4081
4116
|
case 79:
|
|
4082
4117
|
_context40.prev = 79;
|
|
4083
4118
|
_context40.t1 = _context40["catch"](69);
|
|
4084
|
-
|
|
4119
|
+
_iterator5.e(_context40.t1);
|
|
4085
4120
|
case 82:
|
|
4086
4121
|
_context40.prev = 82;
|
|
4087
|
-
|
|
4122
|
+
_iterator5.f();
|
|
4088
4123
|
return _context40.finish(82);
|
|
4089
4124
|
case 85:
|
|
4090
4125
|
latestPaymentStatus = ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 || (_checkoutResponse9 = _checkoutResponse9.data) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.payment_status) || orderPaymentStatus;
|
|
@@ -4178,8 +4213,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4178
4213
|
updatedOrder,
|
|
4179
4214
|
beforeManualUpdate,
|
|
4180
4215
|
syncedPaymentUuids,
|
|
4181
|
-
|
|
4182
|
-
|
|
4216
|
+
_iterator6,
|
|
4217
|
+
_step6,
|
|
4183
4218
|
paymentUuid,
|
|
4184
4219
|
result,
|
|
4185
4220
|
currentInFlight,
|
|
@@ -4584,15 +4619,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4584
4619
|
}).map(function (item) {
|
|
4585
4620
|
return item.uuid;
|
|
4586
4621
|
}).filter(Boolean);
|
|
4587
|
-
|
|
4622
|
+
_iterator6 = _createForOfIteratorHelper(syncedPaymentUuids);
|
|
4588
4623
|
_context41.prev = 112;
|
|
4589
|
-
|
|
4624
|
+
_iterator6.s();
|
|
4590
4625
|
case 114:
|
|
4591
|
-
if ((
|
|
4626
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
4592
4627
|
_context41.next = 120;
|
|
4593
4628
|
break;
|
|
4594
4629
|
}
|
|
4595
|
-
paymentUuid =
|
|
4630
|
+
paymentUuid = _step6.value;
|
|
4596
4631
|
_context41.next = 118;
|
|
4597
4632
|
return this.payment.updatePaymentAsync(this.store.currentOrder.uuid, paymentUuid, {
|
|
4598
4633
|
isSynced: true,
|
|
@@ -4607,10 +4642,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4607
4642
|
case 122:
|
|
4608
4643
|
_context41.prev = 122;
|
|
4609
4644
|
_context41.t3 = _context41["catch"](112);
|
|
4610
|
-
|
|
4645
|
+
_iterator6.e(_context41.t3);
|
|
4611
4646
|
case 125:
|
|
4612
4647
|
_context41.prev = 125;
|
|
4613
|
-
|
|
4648
|
+
_iterator6.f();
|
|
4614
4649
|
return _context41.finish(125);
|
|
4615
4650
|
case 128:
|
|
4616
4651
|
_context41.next = 133;
|