@pisell/pisellos 2.2.258 → 2.2.260
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/dataVariant/adapter.d.ts +49 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
- package/dist/modules/Order/index.d.ts +2 -30
- package/dist/modules/Order/index.js +241 -508
- package/dist/modules/Order/types.d.ts +2 -20
- package/dist/modules/Order/utils.d.ts +0 -4
- package/dist/modules/Order/utils.js +28 -114
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +3 -8
- package/dist/modules/Rules/types.d.ts +1 -2
- package/dist/server/index.d.ts +50 -3
- package/dist/server/index.js +958 -1000
- package/dist/server/modules/order/index.d.ts +3 -22
- package/dist/server/modules/order/index.js +314 -397
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +166 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +2 -16
- package/dist/solution/BaseSales/index.js +314 -484
- package/dist/solution/BaseSales/types.d.ts +0 -1
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -9
- package/dist/solution/BookingTicket/index.js +6 -162
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
- package/lib/modules/Order/index.d.ts +2 -30
- package/lib/modules/Order/index.js +57 -340
- package/lib/modules/Order/types.d.ts +2 -20
- package/lib/modules/Order/utils.d.ts +0 -4
- package/lib/modules/Order/utils.js +2 -84
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +3 -4
- package/lib/modules/Rules/types.d.ts +1 -2
- package/lib/server/index.d.ts +50 -3
- package/lib/server/index.js +215 -230
- package/lib/server/modules/order/index.d.ts +3 -22
- package/lib/server/modules/order/index.js +51 -102
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +113 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +2 -16
- package/lib/solution/BaseSales/index.js +31 -143
- package/lib/solution/BaseSales/types.d.ts +0 -1
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +5 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -9
- package/lib/solution/BookingTicket/index.js +0 -112
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
|
@@ -40,7 +40,6 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
40
40
|
var import_cartPromotion = require("../../solution/BaseSales/utils/cartPromotion");
|
|
41
41
|
var import_utils3 = require("../../solution/ScanOrder/utils");
|
|
42
42
|
var import_manualProductDiscount = require("./utils/manualProductDiscount");
|
|
43
|
-
var import_bundleDiscountHydration = require("./utils/bundleDiscountHydration");
|
|
44
43
|
var import_Discount = require("../Discount");
|
|
45
44
|
var import_Rules = require("../Rules");
|
|
46
45
|
var import_types2 = require("../Rules/types");
|
|
@@ -65,23 +64,6 @@ function isManualProductDiscountProduct(product) {
|
|
|
65
64
|
var _a, _b;
|
|
66
65
|
return ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_manual_discount) === true || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.is_manual_discount) === 1 || ((product == null ? void 0 : product.discount_list) || []).some((item) => (item == null ? void 0 : item.type) === "product");
|
|
67
66
|
}
|
|
68
|
-
var ORDER_PAYMENT_STATUS_PAID = "paid";
|
|
69
|
-
var ORDER_PAYMENT_STATUS_PENDING = "payment_pending";
|
|
70
|
-
function isVoucherPaymentRecord(payment) {
|
|
71
|
-
return (payment == null ? void 0 : payment.voucher_id) !== void 0 && Number(payment.voucher_id) !== 0;
|
|
72
|
-
}
|
|
73
|
-
function hasSyncedOrderPaymentRecord(payment) {
|
|
74
|
-
return (payment == null ? void 0 : payment.order_payment_id) !== void 0 && payment.order_payment_id !== null;
|
|
75
|
-
}
|
|
76
|
-
function isPendingVoucherPaymentRecord(payment) {
|
|
77
|
-
return isVoucherPaymentRecord(payment) && (payment == null ? void 0 : payment.status) === ORDER_PAYMENT_STATUS_PENDING;
|
|
78
|
-
}
|
|
79
|
-
function isPaidPaymentRecord(payment) {
|
|
80
|
-
return (payment == null ? void 0 : payment.status) === ORDER_PAYMENT_STATUS_PAID;
|
|
81
|
-
}
|
|
82
|
-
function isCommittedVoucherPaymentRecord(payment) {
|
|
83
|
-
return isVoucherPaymentRecord(payment) && (payment == null ? void 0 : payment.status) !== "voided" && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
84
|
-
}
|
|
85
67
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
86
68
|
constructor(name, version) {
|
|
87
69
|
super(name || "order", version);
|
|
@@ -109,7 +91,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
109
91
|
collectHydratedEditDiscounts(products) {
|
|
110
92
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
111
93
|
const discountMap = /* @__PURE__ */ new Map();
|
|
112
|
-
for (const product of
|
|
94
|
+
for (const product of products || []) {
|
|
113
95
|
for (const item of (product == null ? void 0 : product.discount_list) || []) {
|
|
114
96
|
const type = (item == null ? void 0 : item.type) ?? (item == null ? void 0 : item.tag);
|
|
115
97
|
if (!type || type === "product")
|
|
@@ -132,21 +114,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
132
114
|
discount: item == null ? void 0 : item.discount,
|
|
133
115
|
_num: Number(((_e = item == null ? void 0 : item.metadata) == null ? void 0 : _e.num) ?? (product == null ? void 0 : product.num) ?? (product == null ? void 0 : product.product_quantity) ?? 1) || 1
|
|
134
116
|
};
|
|
135
|
-
const existed = discountMap.get(key);
|
|
136
|
-
if (existed) {
|
|
137
|
-
existed.amount = Number(existed.amount || 0) + amount;
|
|
138
|
-
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
139
|
-
existed.balance = String(Number(existed.balance || 0) + amount);
|
|
140
|
-
existed.applicableProductDetails = [
|
|
141
|
-
...existed.applicableProductDetails || [],
|
|
142
|
-
detail
|
|
143
|
-
];
|
|
144
|
-
existed.appliedProductDetails = [
|
|
145
|
-
...existed.appliedProductDetails || [],
|
|
146
|
-
detail
|
|
147
|
-
];
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
117
|
discountMap.set(key, {
|
|
151
118
|
id: key,
|
|
152
119
|
product_name: "",
|
|
@@ -269,21 +236,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
269
236
|
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
270
237
|
product.metadata.price_schema_version = 2;
|
|
271
238
|
}
|
|
272
|
-
if (Array.isArray(product.product_bundle)) {
|
|
273
|
-
product.product_bundle = product.product_bundle.map((bundle) => {
|
|
274
|
-
const hasBundleDiscount = Array.isArray(bundle == null ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
275
|
-
if (hasBundleDiscount)
|
|
276
|
-
return bundle;
|
|
277
|
-
const restoredPrice = (bundle == null ? void 0 : bundle.original_price) ?? (bundle == null ? void 0 : bundle.product_price) ?? (bundle == null ? void 0 : bundle.price);
|
|
278
|
-
if (restoredPrice === void 0 || restoredPrice === null || restoredPrice === "")
|
|
279
|
-
return bundle;
|
|
280
|
-
return {
|
|
281
|
-
...bundle,
|
|
282
|
-
price: restoredPrice,
|
|
283
|
-
bundle_selling_price: restoredPrice
|
|
284
|
-
};
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
239
|
product.selling_price = (0, import_utils.composeLinePrice)({
|
|
288
240
|
mainPrice: newMainSellingPrice,
|
|
289
241
|
bundle: product.product_bundle
|
|
@@ -482,7 +434,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
482
434
|
});
|
|
483
435
|
}
|
|
484
436
|
async scanCode(code, customerId) {
|
|
485
|
-
var _a, _b, _c, _d;
|
|
437
|
+
var _a, _b, _c, _d, _e;
|
|
486
438
|
const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId })) || { discountList: [], unavailableReasonKey: null };
|
|
487
439
|
const { discountList: resultDiscountList, unavailableReasonKey } = resultDiscountWithReason;
|
|
488
440
|
const rulesModule = this.store.rules;
|
|
@@ -518,17 +470,17 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
518
470
|
};
|
|
519
471
|
}
|
|
520
472
|
const tempOrder = this.store.tempOrder;
|
|
521
|
-
const holders = ((_b = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _b.
|
|
473
|
+
const holders = ((_b = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _b.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
522
474
|
const { isAvailable, discountList: newDiscountList, unavailableReason } = rulesModule.isDiscountListAvailable({
|
|
523
475
|
productList: (tempOrder == null ? void 0 : tempOrder.products) || [],
|
|
524
476
|
oldDiscountList: this.getDiscountList(),
|
|
525
477
|
newDiscountList: withScanList,
|
|
526
478
|
orderTotalAmount: Number(((_c = this.store.summary) == null ? void 0 : _c.total_amount) || 0),
|
|
527
479
|
holders,
|
|
528
|
-
isFormSubject: (
|
|
480
|
+
isFormSubject: !!((_d = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _d.type) && tempOrder.holder.type === "form"
|
|
529
481
|
}) || { isAvailable: false, discountList: this.getDiscountList() };
|
|
530
482
|
if (isAvailable && newDiscountList) {
|
|
531
|
-
(
|
|
483
|
+
(_e = this.store.discount) == null ? void 0 : _e.setDiscountList(newDiscountList);
|
|
532
484
|
this.applyDiscount();
|
|
533
485
|
}
|
|
534
486
|
return {
|
|
@@ -540,25 +492,24 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
540
492
|
};
|
|
541
493
|
}
|
|
542
494
|
applyDiscount() {
|
|
543
|
-
var _a, _b, _c, _d;
|
|
495
|
+
var _a, _b, _c, _d, _e;
|
|
544
496
|
const tempOrder = this.store.tempOrder;
|
|
545
497
|
if (!tempOrder)
|
|
546
498
|
return;
|
|
547
499
|
delete tempOrder.discount_list;
|
|
548
|
-
|
|
549
|
-
const shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
550
|
-
if (shouldSkipDiscountCalculation)
|
|
500
|
+
if (this.shouldSkipDiscountCalculation(tempOrder))
|
|
551
501
|
return;
|
|
552
502
|
const rulesModule = this.store.rules;
|
|
553
503
|
if (!rulesModule)
|
|
554
504
|
return;
|
|
555
|
-
const
|
|
505
|
+
const discountList = ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
|
|
506
|
+
const holders = ((_b = tempOrder.holder) == null ? void 0 : _b.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
556
507
|
const result = rulesModule.calcDiscount({
|
|
557
508
|
productList: tempOrder.products,
|
|
558
509
|
discountList,
|
|
559
510
|
holders,
|
|
560
|
-
isFormSubject: (
|
|
561
|
-
orderTotalAmount: Number(((
|
|
511
|
+
isFormSubject: !!((_c = tempOrder.holder) == null ? void 0 : _c.type) && tempOrder.holder.type === "form",
|
|
512
|
+
orderTotalAmount: Number(((_d = this.store.summary) == null ? void 0 : _d.total_amount) || 0)
|
|
562
513
|
});
|
|
563
514
|
if (result == null ? void 0 : result.productList) {
|
|
564
515
|
const previousProductsByUid = (0, import_utils.indexOrderProductsByUid)(tempOrder.products);
|
|
@@ -587,7 +538,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
587
538
|
result.productList || tempOrder.products,
|
|
588
539
|
result.discountList
|
|
589
540
|
);
|
|
590
|
-
(
|
|
541
|
+
(_e = this.store.discount) == null ? void 0 : _e.setDiscountList(result.discountList);
|
|
591
542
|
}
|
|
592
543
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(
|
|
593
544
|
(product) => this.productHasCustomerBoundDiscount(product)
|
|
@@ -865,8 +816,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
865
816
|
return (0, import_utils.mapPaymentItemsToOrderPayments)(payments, {
|
|
866
817
|
includeVoided: false
|
|
867
818
|
}).reduce((sum, payment) => {
|
|
868
|
-
if (!isPaidPaymentRecord(payment))
|
|
869
|
-
return sum;
|
|
870
819
|
return sum.plus(this.calculatePaymentEffectiveAmount(payment));
|
|
871
820
|
}, new import_decimal.default(0));
|
|
872
821
|
}
|
|
@@ -876,33 +825,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
876
825
|
normalizeDepositAmount(amount) {
|
|
877
826
|
return import_decimal.default.max(new import_decimal.default(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
|
|
878
827
|
}
|
|
879
|
-
getLastOrderDepositSnapshot() {
|
|
880
|
-
var _a;
|
|
881
|
-
const lastOrderInfo = this.store.lastOrderInfo;
|
|
882
|
-
if (!lastOrderInfo || typeof lastOrderInfo !== "object")
|
|
883
|
-
return null;
|
|
884
|
-
const rawDepositAmount = lastOrderInfo.deposit_amount ?? ((_a = lastOrderInfo.summary) == null ? void 0 : _a.deposit_amount);
|
|
885
|
-
const depositAmount = this.normalizeDepositAmount(rawDepositAmount ?? 0);
|
|
886
|
-
const hasDepositAmount = new import_decimal.default(depositAmount).gt(0);
|
|
887
|
-
const isDeposit = Number(lastOrderInfo.is_deposit) === 1 || hasDepositAmount;
|
|
888
|
-
if (!isDeposit || !hasDepositAmount)
|
|
889
|
-
return null;
|
|
890
|
-
return {
|
|
891
|
-
isDeposit: 1,
|
|
892
|
-
depositAmount
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
getLastOrderSubmitSnapshot() {
|
|
896
|
-
const lastOrderInfo = this.store.lastOrderInfo;
|
|
897
|
-
if (!lastOrderInfo || typeof lastOrderInfo !== "object")
|
|
898
|
-
return {};
|
|
899
|
-
const businessCode = lastOrderInfo.business_code;
|
|
900
|
-
const type = lastOrderInfo.type;
|
|
901
|
-
return {
|
|
902
|
-
...typeof businessCode === "string" && businessCode ? { businessCode } : {},
|
|
903
|
-
...typeof type === "string" && type ? { type } : {}
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
828
|
applyDepositAmountToSummary(tempOrder, summary, amount) {
|
|
907
829
|
const depositAmount = this.normalizeDepositAmount(amount);
|
|
908
830
|
const hasDepositAmount = new import_decimal.default(depositAmount).gt(0);
|
|
@@ -921,27 +843,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
921
843
|
tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
|
|
922
844
|
return nextSummary;
|
|
923
845
|
}
|
|
924
|
-
applyLastOrderDepositSnapshot(tempOrder, summary) {
|
|
925
|
-
const snapshot = this.getLastOrderDepositSnapshot();
|
|
926
|
-
if (!snapshot)
|
|
927
|
-
return summary;
|
|
928
|
-
const existedDeposit = summary.deposit && typeof summary.deposit === "object" ? summary.deposit : void 0;
|
|
929
|
-
const nextSummary = {
|
|
930
|
-
...summary,
|
|
931
|
-
deposit_amount: snapshot.depositAmount,
|
|
932
|
-
deposit: {
|
|
933
|
-
...existedDeposit || {},
|
|
934
|
-
total: snapshot.depositAmount,
|
|
935
|
-
deposit_policy_ids: (existedDeposit == null ? void 0 : existedDeposit.deposit_policy_ids) || [],
|
|
936
|
-
hasDeposit: true
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
tempOrder.deposit_amount = snapshot.depositAmount;
|
|
940
|
-
tempOrder.is_deposit = tempOrder.is_deposit === 0 && new import_decimal.default(tempOrder.deposit_amount || 0).gt(0) ? 0 : snapshot.isDeposit;
|
|
941
|
-
return nextSummary;
|
|
942
|
-
}
|
|
943
846
|
isDepositOrder(tempOrder, depositAmount) {
|
|
944
|
-
return tempOrder.is_deposit === 1
|
|
847
|
+
return tempOrder.is_deposit === 1 || depositAmount.gt(0);
|
|
945
848
|
}
|
|
946
849
|
getOrderExpectedAmount(summary) {
|
|
947
850
|
return new import_decimal.default(summary.expect_amount || summary.total_amount || 0);
|
|
@@ -954,37 +857,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
954
857
|
return false;
|
|
955
858
|
return params.paidAmount.gte(depositAmount);
|
|
956
859
|
}
|
|
957
|
-
getPaymentCompletion(payments) {
|
|
958
|
-
const tempOrder = this.ensureTempOrder();
|
|
959
|
-
const summary = this.store.summary || (0, import_utils.createEmptySummary)();
|
|
960
|
-
const paymentList = payments || tempOrder.payments || [];
|
|
961
|
-
const refundAmount = this.getSummaryRefundAmount(summary);
|
|
962
|
-
const netPaidAmount = import_decimal.default.max(
|
|
963
|
-
this.calculatePaymentTotal(paymentList).minus(refundAmount),
|
|
964
|
-
0
|
|
965
|
-
);
|
|
966
|
-
const depositAmount = this.getDepositAmount(tempOrder, summary);
|
|
967
|
-
const orderExpectedAmount = this.getOrderExpectedAmount(summary);
|
|
968
|
-
const isDepositFullyPaid = this.isDepositCovered({
|
|
969
|
-
tempOrder,
|
|
970
|
-
summary,
|
|
971
|
-
paidAmount: netPaidAmount
|
|
972
|
-
});
|
|
973
|
-
const isOrderFullyPaid = orderExpectedAmount.lte(0) ? true : netPaidAmount.gte(orderExpectedAmount);
|
|
974
|
-
const paymentStage = this.isDepositOrder(tempOrder, depositAmount) && !isDepositFullyPaid ? "deposit" : "normal";
|
|
975
|
-
return {
|
|
976
|
-
isFullyPaid: isOrderFullyPaid,
|
|
977
|
-
isOrderFullyPaid,
|
|
978
|
-
isDepositFullyPaid,
|
|
979
|
-
paymentStage,
|
|
980
|
-
depositAmount: depositAmount.toFixed(2),
|
|
981
|
-
orderExpectedAmount: orderExpectedAmount.toFixed(2)
|
|
982
|
-
};
|
|
983
|
-
}
|
|
984
860
|
calculateDepositPaidAmount(payments) {
|
|
985
861
|
return (payments || []).reduce((sum, payment) => {
|
|
986
862
|
const paymentRecord = payment;
|
|
987
|
-
if (
|
|
863
|
+
if ((paymentRecord == null ? void 0 : paymentRecord.status) !== "paid")
|
|
988
864
|
return sum;
|
|
989
865
|
const isDepositPayment = paymentRecord.type === "deposit" || paymentRecord.order_payment_type === "deposit";
|
|
990
866
|
if (!isDepositPayment)
|
|
@@ -1135,7 +1011,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1135
1011
|
return (payments || []).reduce(
|
|
1136
1012
|
(summary, payment) => {
|
|
1137
1013
|
const paymentRecord = payment;
|
|
1138
|
-
if (
|
|
1014
|
+
if ((paymentRecord == null ? void 0 : paymentRecord.status) !== "paid")
|
|
1139
1015
|
return summary;
|
|
1140
1016
|
return {
|
|
1141
1017
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
@@ -1561,7 +1437,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1561
1437
|
}
|
|
1562
1438
|
restoreOrder() {
|
|
1563
1439
|
var _a, _b;
|
|
1564
|
-
this.logInfo("restoreOrder start", {});
|
|
1565
1440
|
const freshTempOrder = this.createDefaultTempOrderInstance();
|
|
1566
1441
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
1567
1442
|
this.store.tempOrder = freshTempOrder;
|
|
@@ -1640,7 +1515,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1640
1515
|
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
1641
1516
|
});
|
|
1642
1517
|
return {
|
|
1643
|
-
isDeposit: tempOrder.is_deposit === 1,
|
|
1518
|
+
isDeposit: tempOrder.is_deposit === 1 || depositAmount !== "0.00",
|
|
1644
1519
|
depositAmount,
|
|
1645
1520
|
expectAmount: summary.expect_amount || "0.00",
|
|
1646
1521
|
totalAmount: summary.total_amount || "0.00",
|
|
@@ -1925,10 +1800,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1925
1800
|
hasDeposit: true
|
|
1926
1801
|
} : void 0
|
|
1927
1802
|
};
|
|
1928
|
-
const isExistingDepositDisabled = tempOrder.is_deposit === 0 && new import_decimal.default(tempOrder.deposit_amount || 0).gt(0);
|
|
1929
1803
|
tempOrder.deposit_amount = depositAmount;
|
|
1930
|
-
tempOrder.is_deposit = hasDepositAmount
|
|
1931
|
-
return
|
|
1804
|
+
tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
|
|
1805
|
+
return nextSummary;
|
|
1932
1806
|
}
|
|
1933
1807
|
async recalculateSummary(options) {
|
|
1934
1808
|
const tempOrder = (options == null ? void 0 : options.createIfMissing) ? this.ensureTempOrder() : this.store.tempOrder;
|
|
@@ -2272,7 +2146,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2272
2146
|
if (String(previousCustomerId ?? "") !== String(nextCustomerId ?? "")) {
|
|
2273
2147
|
(0, import_utils.clearTempOrderHolderAssignments)(tempOrder);
|
|
2274
2148
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
2275
|
-
this.applyDiscount();
|
|
2276
2149
|
}
|
|
2277
2150
|
this.persistTempOrder();
|
|
2278
2151
|
this.saveDraftInBackground();
|
|
@@ -2430,153 +2303,49 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2430
2303
|
this.persistTempOrder();
|
|
2431
2304
|
return tempOrder.payments;
|
|
2432
2305
|
}
|
|
2433
|
-
confirmPendingVoucherPaymentsInList(payments) {
|
|
2434
|
-
return (payments || []).map((payment) => {
|
|
2435
|
-
if (!isPendingVoucherPaymentRecord(payment))
|
|
2436
|
-
return payment;
|
|
2437
|
-
return {
|
|
2438
|
-
...payment,
|
|
2439
|
-
status: ORDER_PAYMENT_STATUS_PAID
|
|
2440
|
-
};
|
|
2441
|
-
});
|
|
2442
|
-
}
|
|
2443
|
-
discardPendingVoucherPaymentsFromList(payments) {
|
|
2444
|
-
return (payments || []).filter((payment) => !isPendingVoucherPaymentRecord(payment));
|
|
2445
|
-
}
|
|
2446
|
-
prepareVoucherPaymentsForSubmit(payments, confirmPendingVoucherPayments = true) {
|
|
2447
|
-
const mappedPayments = (0, import_utils.mapPaymentItemsToOrderPayments)(payments || []);
|
|
2448
|
-
return confirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : this.discardPendingVoucherPaymentsFromList(mappedPayments);
|
|
2449
|
-
}
|
|
2450
|
-
applyPaymentLifecycleChange(tempOrder, options) {
|
|
2451
|
-
this.updateTempOrderPaymentStatus(tempOrder);
|
|
2452
|
-
if ((options == null ? void 0 : options.persist) !== false) {
|
|
2453
|
-
this.persistTempOrder();
|
|
2454
|
-
}
|
|
2455
|
-
if ((options == null ? void 0 : options.recalculateSummary) === false)
|
|
2456
|
-
return;
|
|
2457
|
-
const logContext = (options == null ? void 0 : options.logContext) || "payment lifecycle change";
|
|
2458
|
-
void this.recalculateSummary({ createIfMissing: true }).catch((error) => {
|
|
2459
|
-
this.logError(`recalculate summary after ${logContext} failed`, {
|
|
2460
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2461
|
-
});
|
|
2462
|
-
});
|
|
2463
|
-
}
|
|
2464
|
-
confirmPendingVoucherPayments(options) {
|
|
2465
|
-
const tempOrder = this.ensureTempOrder();
|
|
2466
|
-
const payments = tempOrder.payments || [];
|
|
2467
|
-
const hasPendingVoucher = payments.some((payment) => isPendingVoucherPaymentRecord(payment));
|
|
2468
|
-
if (!hasPendingVoucher)
|
|
2469
|
-
return payments;
|
|
2470
|
-
tempOrder.payments = this.confirmPendingVoucherPaymentsInList(payments);
|
|
2471
|
-
this.applyPaymentLifecycleChange(tempOrder, {
|
|
2472
|
-
...options,
|
|
2473
|
-
logContext: "confirmPendingVoucherPayments"
|
|
2474
|
-
});
|
|
2475
|
-
return tempOrder.payments;
|
|
2476
|
-
}
|
|
2477
|
-
discardPendingVoucherPayments(options) {
|
|
2478
|
-
const tempOrder = this.ensureTempOrder();
|
|
2479
|
-
const payments = tempOrder.payments || [];
|
|
2480
|
-
const nextPayments = this.discardPendingVoucherPaymentsFromList(payments);
|
|
2481
|
-
if (nextPayments.length === payments.length)
|
|
2482
|
-
return payments;
|
|
2483
|
-
tempOrder.payments = nextPayments;
|
|
2484
|
-
this.applyPaymentLifecycleChange(tempOrder, {
|
|
2485
|
-
...options,
|
|
2486
|
-
logContext: "discardPendingVoucherPayments"
|
|
2487
|
-
});
|
|
2488
|
-
return tempOrder.payments;
|
|
2489
|
-
}
|
|
2490
2306
|
/**
|
|
2491
2307
|
* 覆盖当前订单中的 wallet pass 支付项。
|
|
2492
2308
|
*
|
|
2493
2309
|
* 判断口径与 PaymentModal 保持一致:voucher_id 存在且不为 0 的支付项
|
|
2494
2310
|
* 视为 wallet pass;其它支付项保持不变。
|
|
2495
2311
|
*/
|
|
2496
|
-
updateVoucherOrderPayments(payments
|
|
2312
|
+
updateVoucherOrderPayments(payments) {
|
|
2497
2313
|
const tempOrder = this.ensureTempOrder();
|
|
2498
|
-
const
|
|
2499
|
-
return
|
|
2314
|
+
const isVoucherPayment = (payment) => {
|
|
2315
|
+
return payment.voucher_id !== void 0 && Number(payment.voucher_id) !== 0;
|
|
2500
2316
|
};
|
|
2501
|
-
const
|
|
2502
|
-
|
|
2503
|
-
const paymentRecord = payment;
|
|
2504
|
-
if (!isVoucherPaymentRecord(paymentRecord))
|
|
2505
|
-
return payment;
|
|
2506
|
-
const explicitPaymentType = isOrderPaymentType(paymentRecord.order_payment_type) ? paymentRecord.order_payment_type : isOrderPaymentType(paymentRecord.type) ? paymentRecord.type : void 0;
|
|
2507
|
-
const nextPaymentType = explicitPaymentType || voucherOrderPaymentType;
|
|
2508
|
-
const shouldPreserveCustomPaymentType = paymentRecord.custom_payment_type === void 0 && paymentRecord.type !== void 0 && !isOrderPaymentType(paymentRecord.type);
|
|
2509
|
-
return {
|
|
2510
|
-
...paymentRecord,
|
|
2511
|
-
...shouldPreserveCustomPaymentType ? { custom_payment_type: paymentRecord.type } : {},
|
|
2512
|
-
type: nextPaymentType,
|
|
2513
|
-
order_payment_type: nextPaymentType
|
|
2514
|
-
};
|
|
2515
|
-
};
|
|
2516
|
-
const normalizeVoucherPaymentStatus = (payment) => {
|
|
2517
|
-
const paymentRecord = payment;
|
|
2518
|
-
if (!isVoucherPaymentRecord(paymentRecord))
|
|
2519
|
-
return payment;
|
|
2520
|
-
if (hasSyncedOrderPaymentRecord(paymentRecord) && (paymentRecord.status === void 0 || paymentRecord.status === "active")) {
|
|
2521
|
-
return {
|
|
2522
|
-
...paymentRecord,
|
|
2523
|
-
status: ORDER_PAYMENT_STATUS_PAID
|
|
2524
|
-
};
|
|
2525
|
-
}
|
|
2526
|
-
if (paymentRecord.status !== void 0 && paymentRecord.status !== "active") {
|
|
2527
|
-
return payment;
|
|
2528
|
-
}
|
|
2529
|
-
return {
|
|
2530
|
-
...paymentRecord,
|
|
2531
|
-
status: (options == null ? void 0 : options.status) || ORDER_PAYMENT_STATUS_PENDING
|
|
2532
|
-
};
|
|
2317
|
+
const hasSyncedOrderPayment = (payment) => {
|
|
2318
|
+
return payment.order_payment_id !== void 0 && payment.order_payment_id !== null;
|
|
2533
2319
|
};
|
|
2534
2320
|
const mappedVouchers = (0, import_utils.mapPaymentItemsToOrderPayments)(
|
|
2535
2321
|
payments.map(
|
|
2536
|
-
(payment) => this.normalizePaymentSource(
|
|
2537
|
-
normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)),
|
|
2538
|
-
{ defaultPaid: false }
|
|
2539
|
-
)
|
|
2322
|
+
(payment) => this.normalizePaymentSource(payment, { defaultPaid: true })
|
|
2540
2323
|
)
|
|
2541
2324
|
).filter((payment) => {
|
|
2542
|
-
return
|
|
2325
|
+
return isVoucherPayment(payment);
|
|
2543
2326
|
});
|
|
2544
2327
|
const nonVoucherPayments = (tempOrder.payments || []).filter((payment) => {
|
|
2545
|
-
return !
|
|
2328
|
+
return !isVoucherPayment(payment);
|
|
2546
2329
|
});
|
|
2547
|
-
const
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
};
|
|
2553
|
-
}
|
|
2554
|
-
return payment;
|
|
2555
|
-
};
|
|
2556
|
-
const committedVoucherPayments = (tempOrder.payments || []).filter((payment) => isCommittedVoucherPaymentRecord(payment)).map((payment) => normalizeCommittedVoucherPayment(payment));
|
|
2557
|
-
const committedVoucherPaymentIds = new Set(
|
|
2558
|
-
committedVoucherPayments.filter((payment) => hasSyncedOrderPaymentRecord(payment)).map((payment) => String(payment.order_payment_id))
|
|
2559
|
-
);
|
|
2560
|
-
const committedVoucherIds = new Set(
|
|
2561
|
-
committedVoucherPayments.map((payment) => String(payment.voucher_id))
|
|
2330
|
+
const syncedVoucherPayments = (tempOrder.payments || []).filter((payment) => {
|
|
2331
|
+
return isVoucherPayment(payment) && hasSyncedOrderPayment(payment);
|
|
2332
|
+
});
|
|
2333
|
+
const syncedVoucherPaymentIds = new Set(
|
|
2334
|
+
syncedVoucherPayments.map((payment) => String(payment.order_payment_id))
|
|
2562
2335
|
);
|
|
2563
2336
|
const replaceableVouchers = mappedVouchers.filter((payment) => {
|
|
2564
|
-
if (
|
|
2565
|
-
return
|
|
2566
|
-
|
|
2567
|
-
if (payment.voucher_id !== void 0 && committedVoucherIds.has(String(payment.voucher_id))) {
|
|
2568
|
-
return false;
|
|
2569
|
-
}
|
|
2570
|
-
return true;
|
|
2337
|
+
if (!hasSyncedOrderPayment(payment))
|
|
2338
|
+
return true;
|
|
2339
|
+
return !syncedVoucherPaymentIds.has(String(payment.order_payment_id));
|
|
2571
2340
|
});
|
|
2572
2341
|
const cappedVouchers = this.capVoucherPaymentsByRemainingAmount({
|
|
2573
2342
|
vouchers: replaceableVouchers,
|
|
2574
2343
|
nonVoucherPayments: [
|
|
2575
2344
|
...nonVoucherPayments,
|
|
2576
|
-
...
|
|
2345
|
+
...syncedVoucherPayments
|
|
2577
2346
|
]
|
|
2578
2347
|
});
|
|
2579
|
-
tempOrder.payments = [...nonVoucherPayments, ...
|
|
2348
|
+
tempOrder.payments = [...nonVoucherPayments, ...syncedVoucherPayments, ...cappedVouchers];
|
|
2580
2349
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
2581
2350
|
this.persistTempOrder();
|
|
2582
2351
|
void this.recalculateSummary({ createIfMissing: true }).catch((error) => {
|
|
@@ -2792,6 +2561,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2792
2561
|
*/
|
|
2793
2562
|
async addProductToOrder(product, booking) {
|
|
2794
2563
|
const tempOrder = this.ensureTempOrder();
|
|
2564
|
+
debugger;
|
|
2795
2565
|
if (booking) {
|
|
2796
2566
|
const productRecord = product;
|
|
2797
2567
|
const splitCount = (0, import_utils3.getSafeProductNum)(
|
|
@@ -2814,10 +2584,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2814
2584
|
}
|
|
2815
2585
|
await this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
2816
2586
|
await this.finalizeProductOrderMutation(tempOrder);
|
|
2817
|
-
this.logInfo("addProductToOrder success", {
|
|
2818
|
-
product_id: product.product_id,
|
|
2819
|
-
with_booking: !!booking
|
|
2820
|
-
});
|
|
2821
2587
|
return tempOrder.products;
|
|
2822
2588
|
}
|
|
2823
2589
|
/**
|
|
@@ -2859,9 +2625,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2859
2625
|
await this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
2860
2626
|
}
|
|
2861
2627
|
await this.finalizeProductOrderMutation(tempOrder, options);
|
|
2862
|
-
this.logInfo("addProductsToOrder success", {
|
|
2863
|
-
itemsCount: items.length
|
|
2864
|
-
});
|
|
2865
2628
|
return tempOrder.products;
|
|
2866
2629
|
}
|
|
2867
2630
|
hasGoodPassDiscount(product) {
|
|
@@ -3084,9 +2847,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3084
2847
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3085
2848
|
await this.recalculateSummary({ createIfMissing: true });
|
|
3086
2849
|
this.persistTempOrder();
|
|
3087
|
-
this.logInfo("updateOrderProduct success", {
|
|
3088
|
-
params
|
|
3089
|
-
});
|
|
3090
2850
|
return tempOrder.products;
|
|
3091
2851
|
}
|
|
3092
2852
|
async updateOrderProducts(paramsList) {
|
|
@@ -3098,9 +2858,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3098
2858
|
this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
3099
2859
|
});
|
|
3100
2860
|
await this.finalizeAfterProductsMutation(tempOrder);
|
|
3101
|
-
this.logInfo("updateOrderProduct success", {
|
|
3102
|
-
paramsList
|
|
3103
|
-
});
|
|
3104
2861
|
return tempOrder.products;
|
|
3105
2862
|
}
|
|
3106
2863
|
async updateOrderProductQuantity(params) {
|
|
@@ -3165,9 +2922,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3165
2922
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3166
2923
|
await this.recalculateSummary({ createIfMissing: true });
|
|
3167
2924
|
this.persistTempOrder();
|
|
3168
|
-
this.logInfo("updateOrderProductQuantity success", {
|
|
3169
|
-
params
|
|
3170
|
-
});
|
|
3171
2925
|
return tempOrder.products;
|
|
3172
2926
|
}
|
|
3173
2927
|
updateOrderBooking(params) {
|
|
@@ -3269,9 +3023,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3269
3023
|
});
|
|
3270
3024
|
}
|
|
3271
3025
|
await this.finalizeAfterProductsMutation(tempOrder);
|
|
3272
|
-
this.logInfo("removeProductsFromOrder success", {
|
|
3273
|
-
identities
|
|
3274
|
-
});
|
|
3275
3026
|
return tempOrder.products;
|
|
3276
3027
|
}
|
|
3277
3028
|
async removeProductFromOrder(identity) {
|
|
@@ -3297,7 +3048,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3297
3048
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3298
3049
|
await this.recalculateSummary({ createIfMissing: true });
|
|
3299
3050
|
this.persistTempOrder();
|
|
3300
|
-
this.logInfo("clearOrderCartLines success", {});
|
|
3301
3051
|
return tempOrder;
|
|
3302
3052
|
}
|
|
3303
3053
|
// ─── TempOrder: 提交 ───
|
|
@@ -3358,55 +3108,37 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3358
3108
|
async runSubmitTempOrder(params) {
|
|
3359
3109
|
var _a, _b, _c, _d, _e;
|
|
3360
3110
|
const tempOrder = this.ensureTempOrder();
|
|
3361
|
-
const shouldConfirmPendingVoucherPayments = (params == null ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
3362
|
-
const hasPaymentOverride = (params == null ? void 0 : params.payments) !== void 0;
|
|
3363
|
-
const preparedPaymentOverride = hasPaymentOverride ? this.prepareVoucherPaymentsForSubmit(
|
|
3364
|
-
(params == null ? void 0 : params.payments) || [],
|
|
3365
|
-
shouldConfirmPendingVoucherPayments
|
|
3366
|
-
) : void 0;
|
|
3367
|
-
if (!hasPaymentOverride) {
|
|
3368
|
-
if (shouldConfirmPendingVoucherPayments) {
|
|
3369
|
-
this.confirmPendingVoucherPayments({
|
|
3370
|
-
persist: false,
|
|
3371
|
-
recalculateSummary: false
|
|
3372
|
-
});
|
|
3373
|
-
} else {
|
|
3374
|
-
this.discardPendingVoucherPayments({
|
|
3375
|
-
persist: false,
|
|
3376
|
-
recalculateSummary: false
|
|
3377
|
-
});
|
|
3378
|
-
}
|
|
3379
|
-
}
|
|
3380
3111
|
this.persistTempOrder();
|
|
3381
3112
|
const latestSummary = await this.recalculateSummary({ createIfMissing: true }) || this.store.summary || (0, import_utils.createEmptySummary)();
|
|
3382
3113
|
const effectiveCacheId = (params == null ? void 0 : params.cacheId) ?? this.cacheId;
|
|
3114
|
+
const hasPaymentOverride = (params == null ? void 0 : params.payments) !== void 0;
|
|
3383
3115
|
const hasPaymentStatusOverride = (params == null ? void 0 : params.paymentStatus) !== void 0;
|
|
3384
3116
|
const hasSmallTicketDataFlagOverride = (params == null ? void 0 : params.smallTicketDataFlag) !== void 0;
|
|
3385
3117
|
const enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || (params == null ? void 0 : params.enhancePayload) ? (payload2, ctx) => {
|
|
3386
3118
|
const nextPayload = {
|
|
3387
3119
|
...payload2,
|
|
3388
3120
|
...hasPaymentOverride ? {
|
|
3389
|
-
payments:
|
|
3121
|
+
payments: (0, import_utils.mapPaymentItemsToOrderPayments)(
|
|
3122
|
+
(params == null ? void 0 : params.payments) || []
|
|
3123
|
+
)
|
|
3390
3124
|
} : {},
|
|
3391
|
-
...hasPaymentStatusOverride
|
|
3125
|
+
...hasPaymentStatusOverride ? { payment_status: params == null ? void 0 : params.paymentStatus } : {},
|
|
3392
3126
|
...hasSmallTicketDataFlagOverride ? { small_ticket_data_flag: params == null ? void 0 : params.smallTicketDataFlag } : {}
|
|
3393
3127
|
};
|
|
3394
3128
|
const enhancedPayload = (params == null ? void 0 : params.enhancePayload) ? params.enhancePayload(nextPayload, ctx) : nextPayload;
|
|
3395
3129
|
return enhancedPayload;
|
|
3396
3130
|
} : void 0;
|
|
3397
|
-
const submitSnapshot = this.getLastOrderSubmitSnapshot();
|
|
3398
3131
|
const payload = (0, import_utils.buildSubmitPayload)({
|
|
3399
3132
|
tempOrder,
|
|
3400
3133
|
cacheId: effectiveCacheId,
|
|
3401
3134
|
platform: (params == null ? void 0 : params.platform) || ((_a = this.otherParams) == null ? void 0 : _a.platform),
|
|
3402
|
-
businessCode:
|
|
3135
|
+
businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
3403
3136
|
channel: params == null ? void 0 : params.channel,
|
|
3404
|
-
type:
|
|
3137
|
+
type: params == null ? void 0 : params.type,
|
|
3405
3138
|
summary: latestSummary,
|
|
3406
3139
|
request_unique_idempotency_token: params == null ? void 0 : params.request_unique_idempotency_token,
|
|
3407
3140
|
enhance: enhancePayload
|
|
3408
3141
|
});
|
|
3409
|
-
console.log("[Order.runSubmitTempOrder.payload]", payload);
|
|
3410
3142
|
if (params == null ? void 0 : params.syncMode) {
|
|
3411
3143
|
payload.sync_mode = true;
|
|
3412
3144
|
}
|
|
@@ -3454,10 +3186,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3454
3186
|
this.logInfo("runSubmitTempOrder: 提交成功", {
|
|
3455
3187
|
submittedOrderId,
|
|
3456
3188
|
result,
|
|
3457
|
-
tempOrder
|
|
3458
|
-
...tempOrder,
|
|
3459
|
-
_extend: void 0
|
|
3460
|
-
}
|
|
3189
|
+
tempOrder
|
|
3461
3190
|
});
|
|
3462
3191
|
if (submittedOrderId !== null && submittedOrderId !== void 0) {
|
|
3463
3192
|
tempOrder.order_id = submittedOrderId;
|
|
@@ -3543,33 +3272,31 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3543
3272
|
const mappedPayments = (0, import_utils.mapPaymentItemsToOrderPayments)(
|
|
3544
3273
|
params.payments || []
|
|
3545
3274
|
);
|
|
3546
|
-
const
|
|
3547
|
-
const
|
|
3548
|
-
const
|
|
3549
|
-
const
|
|
3550
|
-
|
|
3551
|
-
tempOrder.payments = effectivePayments;
|
|
3275
|
+
const paymentTotal = this.calculatePaymentTotal(mappedPayments);
|
|
3276
|
+
const targetAmount = this.getPaymentTargetAmount();
|
|
3277
|
+
const isFullyPaid = targetAmount.lte(0) ? true : paymentTotal.gte(targetAmount);
|
|
3278
|
+
const paymentStatus = isFullyPaid ? params.paymentStatus || "paid" : "partially_paid";
|
|
3279
|
+
tempOrder.payments = mappedPayments;
|
|
3552
3280
|
tempOrder.payment_status = paymentStatus;
|
|
3553
3281
|
this.persistTempOrder();
|
|
3554
3282
|
await this.saveDraft();
|
|
3555
3283
|
if (!params.submitWhenPaid) {
|
|
3556
|
-
return
|
|
3284
|
+
return { isFullyPaid };
|
|
3557
3285
|
}
|
|
3558
3286
|
if (this.store.syncState === "submitting") {
|
|
3559
|
-
return
|
|
3287
|
+
return { isFullyPaid };
|
|
3560
3288
|
}
|
|
3561
3289
|
this.store.syncState = "submitting";
|
|
3562
3290
|
const paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(
|
|
3563
3291
|
tempOrder,
|
|
3564
|
-
|
|
3292
|
+
mappedPayments
|
|
3565
3293
|
);
|
|
3566
3294
|
const submitResult = await this.submitTempOrder({
|
|
3567
|
-
payments:
|
|
3295
|
+
payments: mappedPayments,
|
|
3568
3296
|
paymentStatus,
|
|
3569
3297
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
3570
3298
|
businessCode: params.businessCode,
|
|
3571
3299
|
channel: params.channel,
|
|
3572
|
-
confirmPendingVoucherPayments: true,
|
|
3573
3300
|
enhancePayload: (payload) => {
|
|
3574
3301
|
const nextPayload = {
|
|
3575
3302
|
...payload,
|
|
@@ -3578,7 +3305,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3578
3305
|
return nextPayload;
|
|
3579
3306
|
}
|
|
3580
3307
|
});
|
|
3581
|
-
return {
|
|
3308
|
+
return { isFullyPaid, submitResult };
|
|
3582
3309
|
}
|
|
3583
3310
|
createOrder(params) {
|
|
3584
3311
|
var _a;
|
|
@@ -3912,10 +3639,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3912
3639
|
const currentDiscounts = typeof ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList) === "function" ? this.store.discount.getDiscountList() || [] : [];
|
|
3913
3640
|
const shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
3914
3641
|
if (!shouldSkipEmptyDiscountSync) {
|
|
3915
|
-
OrderModule.populateSavedAmounts(
|
|
3916
|
-
nextTempOrder.products,
|
|
3917
|
-
hydratedEditDiscounts
|
|
3918
|
-
);
|
|
3919
3642
|
await ((_b = this.store.discount) == null ? void 0 : _b.setOriginalDiscountList(hydratedEditDiscounts));
|
|
3920
3643
|
await ((_c = this.store.discount) == null ? void 0 : _c.setDiscountList(hydratedEditDiscounts));
|
|
3921
3644
|
}
|
|
@@ -4120,7 +3843,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
4120
3843
|
return normalized;
|
|
4121
3844
|
}
|
|
4122
3845
|
normalizeHydratedOrderProduct(product) {
|
|
4123
|
-
|
|
3846
|
+
const row = { ...product || {} };
|
|
4124
3847
|
if (row.num === void 0 && row.product_quantity !== void 0) {
|
|
4125
3848
|
row.num = row.product_quantity;
|
|
4126
3849
|
}
|
|
@@ -4141,7 +3864,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
4141
3864
|
if (row.booking_uid && !row.metadata.booking_uid) {
|
|
4142
3865
|
row.metadata.booking_uid = row.booking_uid;
|
|
4143
3866
|
}
|
|
4144
|
-
row = (0, import_bundleDiscountHydration.restoreHydratedBundleDiscounts)(row, import_utils.normalizeOrderProductDiscountList);
|
|
4145
3867
|
const existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
|
|
4146
3868
|
if (!existingIdentity) {
|
|
4147
3869
|
row.metadata.unique_identification_number = (0, import_utils.createUuidV4)();
|
|
@@ -4161,8 +3883,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
4161
3883
|
};
|
|
4162
3884
|
if (result.metadata)
|
|
4163
3885
|
delete result.metadata.price_schema_version;
|
|
4164
|
-
|
|
4165
|
-
return this.sanitizeOrderProductForTempOrder(restored);
|
|
3886
|
+
return this.sanitizeOrderProductForTempOrder(result);
|
|
4166
3887
|
}
|
|
4167
3888
|
getLastOrderInfo() {
|
|
4168
3889
|
var _a;
|
|
@@ -4176,10 +3897,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
4176
3897
|
});
|
|
4177
3898
|
return res;
|
|
4178
3899
|
}
|
|
4179
|
-
getVouchers() {
|
|
4180
|
-
var _a;
|
|
4181
|
-
return ((_a = this.store.tempOrder) == null ? void 0 : _a.vouchers) || [];
|
|
4182
|
-
}
|
|
4183
3900
|
};
|
|
4184
3901
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4185
3902
|
0 && (module.exports = {
|