@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
|
@@ -156,9 +156,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
156
156
|
this.hasManualDiscountSelection = false;
|
|
157
157
|
this.reusedSharedSubModuleNames = /* @__PURE__ */ new Set();
|
|
158
158
|
this.paymentMethodsCache = [];
|
|
159
|
-
this.queuedAutoPaymentSync = false;
|
|
160
|
-
this.autoPaymentSyncFlushing = false;
|
|
161
|
-
this.autoPaymentSyncTimer = null;
|
|
162
159
|
}
|
|
163
160
|
/**
|
|
164
161
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -168,10 +165,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
168
165
|
return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
|
|
169
166
|
}
|
|
170
167
|
getReusableSharedSubModule(moduleName) {
|
|
171
|
-
var _a
|
|
168
|
+
var _a;
|
|
172
169
|
if (moduleName !== "schedule" && moduleName !== "quotation")
|
|
173
170
|
return null;
|
|
174
|
-
return ((
|
|
171
|
+
return ((_a = this.core) == null ? void 0 : _a.getModule(moduleName)) || null;
|
|
175
172
|
}
|
|
176
173
|
isScheduleListLoaded(scheduleModule) {
|
|
177
174
|
if (!scheduleModule)
|
|
@@ -1022,7 +1019,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1022
1019
|
});
|
|
1023
1020
|
}
|
|
1024
1021
|
async loadDiscountConfig(params) {
|
|
1025
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1022
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1026
1023
|
if (!this.store.order)
|
|
1027
1024
|
throw new Error("order 模块未初始化");
|
|
1028
1025
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1093,15 +1090,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1093
1090
|
};
|
|
1094
1091
|
}
|
|
1095
1092
|
if (rulesModule) {
|
|
1096
|
-
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.
|
|
1097
|
-
const orderTotalAmount = Number(((_m = orderStore.summary) == null ? void 0 : _m.total_amount) || 0);
|
|
1098
|
-
console.log("[BaseSales.applyDiscountConfig.calcDiscount]");
|
|
1093
|
+
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
1099
1094
|
const result = rulesModule.calcDiscount({
|
|
1100
1095
|
productList: tempOrder.products,
|
|
1101
1096
|
discountList: nextDiscountList,
|
|
1102
1097
|
holders,
|
|
1103
|
-
isFormSubject: (
|
|
1104
|
-
orderTotalAmount
|
|
1098
|
+
isFormSubject: !!((_m = tempOrder.holder) == null ? void 0 : _m.type) && tempOrder.holder.type === "form",
|
|
1099
|
+
orderTotalAmount: Number(((_n = orderStore.summary) == null ? void 0 : _n.total_amount) || 0)
|
|
1105
1100
|
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
1106
1101
|
if (result.productList) {
|
|
1107
1102
|
tempOrder.products = preserveManualProductDiscountProducts(
|
|
@@ -1110,8 +1105,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1110
1105
|
);
|
|
1111
1106
|
}
|
|
1112
1107
|
for (const product of tempOrder.products || []) {
|
|
1113
|
-
const productUid = (
|
|
1114
|
-
const runtimeOrigin = productUid ? (
|
|
1108
|
+
const productUid = (_o = product.metadata) == null ? void 0 : _o.unique_identification_number;
|
|
1109
|
+
const runtimeOrigin = productUid ? (_r = (_q = (_p = tempOrder._extend) == null ? void 0 : _p.productsByUid) == null ? void 0 : _q[productUid]) == null ? void 0 : _r.origin : void 0;
|
|
1115
1110
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1116
1111
|
continue;
|
|
1117
1112
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
@@ -1119,7 +1114,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1119
1114
|
0
|
|
1120
1115
|
);
|
|
1121
1116
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
1122
|
-
const sourcePrice = ((
|
|
1117
|
+
const sourcePrice = ((_s = product.metadata) == null ? void 0 : _s.source_product_price) ?? (((_t = product.metadata) == null ? void 0 : _t.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1123
1118
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1124
1119
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1125
1120
|
if (product.metadata) {
|
|
@@ -1155,7 +1150,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1155
1150
|
};
|
|
1156
1151
|
}
|
|
1157
1152
|
async bestDiscount(cb) {
|
|
1158
|
-
var _a, _b, _c, _d;
|
|
1153
|
+
var _a, _b, _c, _d, _e;
|
|
1159
1154
|
if (!this.store.order)
|
|
1160
1155
|
throw new Error("order 模块未初始化");
|
|
1161
1156
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1174,15 +1169,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1174
1169
|
};
|
|
1175
1170
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1176
1171
|
if (rulesModule) {
|
|
1177
|
-
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.
|
|
1178
|
-
const orderTotalAmount = Number(((_d = orderStore.summary) == null ? void 0 : _d.total_amount) || 0);
|
|
1179
|
-
console.log("[BaseSales.bestDiscount.calcDiscount]");
|
|
1172
|
+
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
1180
1173
|
result = rulesModule.calcDiscount({
|
|
1181
1174
|
productList: tempOrder.products,
|
|
1182
1175
|
discountList: nextDiscountList,
|
|
1183
1176
|
holders,
|
|
1184
|
-
isFormSubject: (
|
|
1185
|
-
orderTotalAmount
|
|
1177
|
+
isFormSubject: !!((_d = tempOrder.holder) == null ? void 0 : _d.type) && tempOrder.holder.type === "form",
|
|
1178
|
+
orderTotalAmount: Number(((_e = orderStore.summary) == null ? void 0 : _e.total_amount) || 0)
|
|
1186
1179
|
}) || result;
|
|
1187
1180
|
if (result.productList) {
|
|
1188
1181
|
tempOrder.products = preserveManualProductDiscountProducts(
|
|
@@ -1251,19 +1244,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1251
1244
|
const orderStore = this.store.order.store || {};
|
|
1252
1245
|
const discountModule = orderStore.discount;
|
|
1253
1246
|
const rulesModule = orderStore.rules;
|
|
1254
|
-
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.
|
|
1247
|
+
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
1255
1248
|
let nextDiscountList = updated;
|
|
1256
1249
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
1257
1250
|
if (rulesModule) {
|
|
1258
|
-
const orderTotalAmount = Number(((_b = orderStore.summary) == null ? void 0 : _b.total_amount) || 0);
|
|
1259
|
-
console.log("[BaseSales.setDiscountSelected.calcDiscount]");
|
|
1260
1251
|
const result = rulesModule.calcDiscount(
|
|
1261
1252
|
{
|
|
1262
1253
|
productList: tempOrder.products,
|
|
1263
1254
|
discountList: updated,
|
|
1264
1255
|
holders,
|
|
1265
|
-
isFormSubject: (
|
|
1266
|
-
orderTotalAmount
|
|
1256
|
+
isFormSubject: !!((_b = tempOrder.holder) == null ? void 0 : _b.type) && tempOrder.holder.type === "form"
|
|
1267
1257
|
},
|
|
1268
1258
|
{
|
|
1269
1259
|
discountId: params.discountId,
|
|
@@ -1286,7 +1276,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1286
1276
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1287
1277
|
d.isSelected = false;
|
|
1288
1278
|
d.isManualSelect = true;
|
|
1289
|
-
d.appliedProductDetails = [];
|
|
1290
1279
|
}
|
|
1291
1280
|
}
|
|
1292
1281
|
}
|
|
@@ -1295,32 +1284,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1295
1284
|
const selectedResourceIds = new Set(
|
|
1296
1285
|
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1297
1286
|
);
|
|
1298
|
-
const filterSelectedDiscountDetails = (discountList) => (discountList || []).filter((pd) => {
|
|
1299
|
-
var _a2;
|
|
1300
|
-
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1301
|
-
return rid != null && selectedResourceIds.has(rid);
|
|
1302
|
-
});
|
|
1303
1287
|
for (const product of tempOrder.products) {
|
|
1304
1288
|
const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
|
|
1305
1289
|
const runtimeOrigin = productUid ? (_f = (_e = (_d = tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[productUid]) == null ? void 0 : _f.origin : void 0;
|
|
1306
1290
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1307
1291
|
continue;
|
|
1308
|
-
product.discount_list =
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
const restoredBundlePrice = (bundle == null ? void 0 : bundle.original_price) ?? (bundle == null ? void 0 : bundle.product_price) ?? (bundle == null ? void 0 : bundle.price);
|
|
1314
|
-
return {
|
|
1315
|
-
...bundle,
|
|
1316
|
-
...shouldRestoreBundlePrice ? {
|
|
1317
|
-
price: restoredBundlePrice,
|
|
1318
|
-
bundle_selling_price: restoredBundlePrice
|
|
1319
|
-
} : {},
|
|
1320
|
-
discount_list: nextBundleDiscountList
|
|
1321
|
-
};
|
|
1322
|
-
});
|
|
1323
|
-
}
|
|
1292
|
+
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1293
|
+
var _a2;
|
|
1294
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1295
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1296
|
+
});
|
|
1324
1297
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1325
1298
|
(sum, pd) => sum + (pd.amount || 0),
|
|
1326
1299
|
0
|
|
@@ -1409,7 +1382,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1409
1382
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1410
1383
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1411
1384
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1412
|
-
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1413
1385
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1414
1386
|
};
|
|
1415
1387
|
return this.store.order.submitTempOrder(submitParams);
|
|
@@ -1429,7 +1401,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1429
1401
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1430
1402
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1431
1403
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1432
|
-
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1433
1404
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1434
1405
|
};
|
|
1435
1406
|
return this.store.order.submitTempOrderAsync(submitParams);
|
|
@@ -1498,7 +1469,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1498
1469
|
};
|
|
1499
1470
|
const syncState = this.store.order.getOrderSyncState();
|
|
1500
1471
|
if (params.submitWhenPaid && syncState === "submitting") {
|
|
1501
|
-
this.queueLatestAutoPaymentSync();
|
|
1502
1472
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
1503
1473
|
}
|
|
1504
1474
|
const payments = params.payments || [];
|
|
@@ -1510,28 +1480,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1510
1480
|
});
|
|
1511
1481
|
try {
|
|
1512
1482
|
const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
|
|
1513
|
-
|
|
1514
|
-
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1515
|
-
const orderSnapshot = this.store.order.getOrderSnapshot();
|
|
1516
|
-
const syncPayload = {
|
|
1483
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1517
1484
|
ok: true,
|
|
1518
1485
|
syncResult,
|
|
1519
|
-
payments:
|
|
1486
|
+
payments: this.store.order.getOrderPayments(),
|
|
1520
1487
|
params: syncParams,
|
|
1521
|
-
amountSnapshot,
|
|
1522
|
-
orderSnapshot
|
|
1523
|
-
|
|
1524
|
-
isOrderFullyPaid: syncResult.isOrderFullyPaid,
|
|
1525
|
-
isDepositFullyPaid: syncResult.isDepositFullyPaid,
|
|
1526
|
-
paymentStage: syncResult.paymentStage,
|
|
1527
|
-
depositAmount: syncResult.depositAmount,
|
|
1528
|
-
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
1529
|
-
};
|
|
1530
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
1531
|
-
if (syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid) {
|
|
1532
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
1533
|
-
}
|
|
1534
|
-
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1488
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1489
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1490
|
+
});
|
|
1535
1491
|
return syncResult;
|
|
1536
1492
|
} catch (error) {
|
|
1537
1493
|
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
@@ -1542,7 +1498,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1542
1498
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1543
1499
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1544
1500
|
});
|
|
1545
|
-
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1546
1501
|
throw error;
|
|
1547
1502
|
}
|
|
1548
1503
|
}
|
|
@@ -1559,61 +1514,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1559
1514
|
throw new Error("order 模块未初始化");
|
|
1560
1515
|
return this.store.order.setOrderPayments(payments);
|
|
1561
1516
|
}
|
|
1562
|
-
getPaymentStatusForSync(payments) {
|
|
1563
|
-
const order = this.store.order;
|
|
1564
|
-
if (!order)
|
|
1565
|
-
throw new Error("order 模块未初始化");
|
|
1566
|
-
const completion = order.getPaymentCompletion(payments);
|
|
1567
|
-
return completion.isOrderFullyPaid ? "paid" : "partially_paid";
|
|
1568
|
-
}
|
|
1569
|
-
queueLatestAutoPaymentSync() {
|
|
1570
|
-
this.queuedAutoPaymentSync = true;
|
|
1571
|
-
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
1572
|
-
}
|
|
1573
|
-
scheduleQueuedAutoPaymentSyncFlush(delay = 100) {
|
|
1574
|
-
if (!this.queuedAutoPaymentSync)
|
|
1575
|
-
return;
|
|
1576
|
-
if (this.autoPaymentSyncTimer)
|
|
1577
|
-
return;
|
|
1578
|
-
this.autoPaymentSyncTimer = setTimeout(() => {
|
|
1579
|
-
this.autoPaymentSyncTimer = null;
|
|
1580
|
-
void this.flushQueuedAutoPaymentSync();
|
|
1581
|
-
}, delay);
|
|
1582
|
-
}
|
|
1583
|
-
async flushQueuedAutoPaymentSync() {
|
|
1584
|
-
if (!this.store.order)
|
|
1585
|
-
return;
|
|
1586
|
-
if (!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)
|
|
1587
|
-
return;
|
|
1588
|
-
if (this.store.order.getOrderSyncState() === "submitting") {
|
|
1589
|
-
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
1590
|
-
return;
|
|
1591
|
-
}
|
|
1592
|
-
this.autoPaymentSyncFlushing = true;
|
|
1593
|
-
try {
|
|
1594
|
-
while (this.queuedAutoPaymentSync) {
|
|
1595
|
-
this.queuedAutoPaymentSync = false;
|
|
1596
|
-
const payments = this.store.order.getOrderPayments();
|
|
1597
|
-
if (!payments.length)
|
|
1598
|
-
continue;
|
|
1599
|
-
await this.syncPaymentsToOrder({
|
|
1600
|
-
payments,
|
|
1601
|
-
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
1602
|
-
submitWhenPaid: true,
|
|
1603
|
-
smallTicketDataFlag: 1
|
|
1604
|
-
});
|
|
1605
|
-
}
|
|
1606
|
-
} catch (error) {
|
|
1607
|
-
this.logError("queued auto sync payments failed", {
|
|
1608
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1609
|
-
});
|
|
1610
|
-
} finally {
|
|
1611
|
-
this.autoPaymentSyncFlushing = false;
|
|
1612
|
-
if (this.queuedAutoPaymentSync) {
|
|
1613
|
-
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
1517
|
/** 追加单个支付项到当前订单。 */
|
|
1618
1518
|
addOrderPayment(payment) {
|
|
1619
1519
|
var _a;
|
|
@@ -1649,14 +1549,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1649
1549
|
});
|
|
1650
1550
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1651
1551
|
const syncState = this.store.order.getOrderSyncState();
|
|
1652
|
-
if (amountSnapshot) {
|
|
1653
|
-
|
|
1654
|
-
this.queueLatestAutoPaymentSync();
|
|
1655
|
-
return payments;
|
|
1656
|
-
}
|
|
1552
|
+
if (amountSnapshot && syncState !== "submitting") {
|
|
1553
|
+
const paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? "paid" : "partially_paid";
|
|
1657
1554
|
void this.syncPaymentsToOrder({
|
|
1658
1555
|
payments,
|
|
1659
|
-
paymentStatus
|
|
1556
|
+
paymentStatus,
|
|
1660
1557
|
submitWhenPaid: true,
|
|
1661
1558
|
smallTicketDataFlag: 1
|
|
1662
1559
|
}).catch((error) => {
|
|
@@ -1664,6 +1561,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1664
1561
|
error: error instanceof Error ? error.message : String(error)
|
|
1665
1562
|
});
|
|
1666
1563
|
});
|
|
1564
|
+
} else {
|
|
1667
1565
|
}
|
|
1668
1566
|
return payments;
|
|
1669
1567
|
}
|
|
@@ -1680,20 +1578,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1680
1578
|
return this.store.order.deleteOrderPayment(paymentIdentity);
|
|
1681
1579
|
}
|
|
1682
1580
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
1683
|
-
updateVoucherOrderPayments(payments
|
|
1684
|
-
if (!this.store.order)
|
|
1685
|
-
throw new Error("order 模块未初始化");
|
|
1686
|
-
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
1687
|
-
}
|
|
1688
|
-
confirmPendingVoucherPayments() {
|
|
1689
|
-
if (!this.store.order)
|
|
1690
|
-
throw new Error("order 模块未初始化");
|
|
1691
|
-
return this.store.order.confirmPendingVoucherPayments();
|
|
1692
|
-
}
|
|
1693
|
-
discardPendingVoucherPayments() {
|
|
1581
|
+
updateVoucherOrderPayments(payments) {
|
|
1694
1582
|
if (!this.store.order)
|
|
1695
1583
|
throw new Error("order 模块未初始化");
|
|
1696
|
-
return this.store.order.
|
|
1584
|
+
return this.store.order.updateVoucherOrderPayments(payments);
|
|
1697
1585
|
}
|
|
1698
1586
|
getWalletProductList() {
|
|
1699
1587
|
var _a, _b, _c;
|
|
@@ -14,7 +14,6 @@ export declare const BaseSalesHookNames: {
|
|
|
14
14
|
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
15
15
|
readonly onPaymentSyncStart: "onPaymentSyncStart";
|
|
16
16
|
readonly onPaymentSyncEnd: "onPaymentSyncEnd";
|
|
17
|
-
readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
|
|
18
17
|
};
|
|
19
18
|
export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
|
|
20
19
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
@@ -30,8 +30,7 @@ var BaseSalesHookNames = {
|
|
|
30
30
|
onRefresh: "onRefresh",
|
|
31
31
|
onCartValidationChanged: "onCartValidationChanged",
|
|
32
32
|
onPaymentSyncStart: "onPaymentSyncStart",
|
|
33
|
-
onPaymentSyncEnd: "onPaymentSyncEnd"
|
|
34
|
-
onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd"
|
|
33
|
+
onPaymentSyncEnd: "onPaymentSyncEnd"
|
|
35
34
|
};
|
|
36
35
|
function createBaseSalesHook(moduleName, hookName) {
|
|
37
36
|
return `${moduleName}:${hookName}`;
|
|
@@ -129,9 +129,10 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
129
129
|
payload.price ?? payload.selling_price ?? (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price),
|
|
130
130
|
"0.00"
|
|
131
131
|
);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
const lineCompositeTotal = toPriceString(
|
|
133
|
+
payload.line_total ?? payload.total ?? ((_c = payload._extend) == null ? void 0 : _c.total),
|
|
134
|
+
sourceProductPrice
|
|
135
|
+
);
|
|
135
136
|
const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
|
|
136
137
|
const productOptionItem = (0, import_utils.normalizeProductSkuOptions)(
|
|
137
138
|
normalizeOptionItems(
|
|
@@ -179,7 +180,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
179
180
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(productOptionItem).toNumber();
|
|
180
181
|
const mainProductOriginalPrice = toPriceString(Number(sourceProductPrice) + optionSum);
|
|
181
182
|
const bundleOnlyComposite = (0, import_utils.composeLinePrice)({ mainPrice: 0, bundle: productBundle });
|
|
182
|
-
const derivedMainSelling =
|
|
183
|
+
const derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
|
|
183
184
|
const mainProductSellingPrice = toPriceString(
|
|
184
185
|
Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice)
|
|
185
186
|
);
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|
|
@@ -551,14 +551,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
551
551
|
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
552
552
|
cover?: boolean;
|
|
553
553
|
}): Promise<void>;
|
|
554
|
-
private getDeviceTaskPlugin;
|
|
555
|
-
handlePrintWristband(params: {
|
|
556
|
-
voucher_ids: number[];
|
|
557
|
-
}): Promise<void>;
|
|
558
|
-
handleCheckIn(params: {
|
|
559
|
-
voucher_ids: number[];
|
|
560
|
-
is_checkin: boolean;
|
|
561
|
-
}): Promise<any>;
|
|
562
554
|
/**
|
|
563
555
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
564
556
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
@@ -52,7 +52,6 @@ var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/Boo
|
|
|
52
52
|
var import_orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
|
|
53
53
|
var import_bookingStatus = require("./utils/bookingStatus");
|
|
54
54
|
var import_resolveBestAddTimePlan = require("./utils/resolveBestAddTimePlan");
|
|
55
|
-
var import_utils = require("../../modules/Order/utils");
|
|
56
55
|
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
57
56
|
var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
|
|
58
57
|
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
@@ -1506,117 +1505,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1506
1505
|
await this.configureIdGeneratorFromOpenData();
|
|
1507
1506
|
}
|
|
1508
1507
|
}
|
|
1509
|
-
getDeviceTaskPlugin() {
|
|
1510
|
-
var _a;
|
|
1511
|
-
const app = this.core.getPlugin("app");
|
|
1512
|
-
return ((_a = app == null ? void 0 : app.getApp()) == null ? void 0 : _a.getPlugin("deviceTask")) || null;
|
|
1513
|
-
}
|
|
1514
|
-
// 打印手环,单个或批量都可以
|
|
1515
|
-
async handlePrintWristband(params) {
|
|
1516
|
-
var _a;
|
|
1517
|
-
const deviceTask = this.getDeviceTaskPlugin();
|
|
1518
|
-
if (!(deviceTask == null ? void 0 : deviceTask.dispatch)) {
|
|
1519
|
-
this.logger.addLog({
|
|
1520
|
-
type: "info",
|
|
1521
|
-
title: "[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用",
|
|
1522
|
-
metadata: {
|
|
1523
|
-
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1524
|
-
}
|
|
1525
|
-
});
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
this.logger.addLog({
|
|
1529
|
-
type: "info",
|
|
1530
|
-
title: "[BookingTicket] handlePrintWristband",
|
|
1531
|
-
metadata: {
|
|
1532
|
-
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1533
|
-
}
|
|
1534
|
-
});
|
|
1535
|
-
const deviceId = await this.getShortNumberOrDeviceId();
|
|
1536
|
-
const idempotencyKey = (0, import_utils.createUuidV4)();
|
|
1537
|
-
deviceTask.dispatch({
|
|
1538
|
-
action: "print_all",
|
|
1539
|
-
device_id: deviceId,
|
|
1540
|
-
payload: {
|
|
1541
|
-
type: "WRISTBAND",
|
|
1542
|
-
data: {
|
|
1543
|
-
order_id: (_a = this.getOrderIdentity()) == null ? void 0 : _a.orderId,
|
|
1544
|
-
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1545
|
-
}
|
|
1546
|
-
},
|
|
1547
|
-
idempotency_key: idempotencyKey,
|
|
1548
|
-
name: "PRINT_WRISTBAND",
|
|
1549
|
-
source: "bookingTicket",
|
|
1550
|
-
source_type: "handlePrintWristband",
|
|
1551
|
-
source_id: idempotencyKey
|
|
1552
|
-
});
|
|
1553
|
-
}
|
|
1554
|
-
// 触发 checkIn
|
|
1555
|
-
async handleCheckIn(params) {
|
|
1556
|
-
var _a, _b, _c;
|
|
1557
|
-
this.logger.addLog({
|
|
1558
|
-
type: "info",
|
|
1559
|
-
title: "[BookingTicket] handleCheckIn",
|
|
1560
|
-
metadata: {
|
|
1561
|
-
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids],
|
|
1562
|
-
is_checkin: params.is_checkin
|
|
1563
|
-
}
|
|
1564
|
-
});
|
|
1565
|
-
const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
1566
|
-
const voucherIdSet = new Set(voucherIds);
|
|
1567
|
-
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
1568
|
-
const vouchers = (tempOrder == null ? void 0 : tempOrder.vouchers) || ((_c = this.store.order) == null ? void 0 : _c.getVouchers()) || [];
|
|
1569
|
-
const batchMetadata = [];
|
|
1570
|
-
let hasUpdatedVoucher = false;
|
|
1571
|
-
const nextVouchers = vouchers.map((voucher) => {
|
|
1572
|
-
var _a2;
|
|
1573
|
-
if (!voucherIdSet.has(voucher.voucher_id))
|
|
1574
|
-
return voucher;
|
|
1575
|
-
hasUpdatedVoucher = true;
|
|
1576
|
-
const metadata = {
|
|
1577
|
-
...voucher.metadata || {},
|
|
1578
|
-
ticket: {
|
|
1579
|
-
...((_a2 = voucher.metadata) == null ? void 0 : _a2.ticket) || {},
|
|
1580
|
-
is_checkin: params.is_checkin
|
|
1581
|
-
}
|
|
1582
|
-
};
|
|
1583
|
-
batchMetadata.push({
|
|
1584
|
-
voucher_id: voucher.voucher_id,
|
|
1585
|
-
metadata
|
|
1586
|
-
});
|
|
1587
|
-
return {
|
|
1588
|
-
...voucher,
|
|
1589
|
-
metadata
|
|
1590
|
-
};
|
|
1591
|
-
});
|
|
1592
|
-
if (tempOrder && hasUpdatedVoucher) {
|
|
1593
|
-
await this.replaceTempOrder({
|
|
1594
|
-
...tempOrder,
|
|
1595
|
-
vouchers: nextVouchers
|
|
1596
|
-
});
|
|
1597
|
-
}
|
|
1598
|
-
this.core.effects.emit(`${this.name}:onVouchersChange`, {});
|
|
1599
|
-
if (batchMetadata.length === 0) {
|
|
1600
|
-
return {
|
|
1601
|
-
code: 200,
|
|
1602
|
-
status: true,
|
|
1603
|
-
message: "",
|
|
1604
|
-
data: []
|
|
1605
|
-
};
|
|
1606
|
-
}
|
|
1607
|
-
const identity = this.getOrderIdentity();
|
|
1608
|
-
const externalSaleNumber = (tempOrder == null ? void 0 : tempOrder.external_sale_number) || (identity == null ? void 0 : identity.externalSaleNumber) || void 0;
|
|
1609
|
-
const orderId = (tempOrder == null ? void 0 : tempOrder.order_id) ?? (identity == null ? void 0 : identity.orderId) ?? void 0;
|
|
1610
|
-
const orderLookup = externalSaleNumber || orderId || (identity == null ? void 0 : identity.orderNumber) || (identity == null ? void 0 : identity.shopOrderNumber) || (identity == null ? void 0 : identity.shopFullOrderNumber) || void 0;
|
|
1611
|
-
return this.request.post("/machinecode/batch-metadata", {
|
|
1612
|
-
data: batchMetadata,
|
|
1613
|
-
order_lookup: orderLookup,
|
|
1614
|
-
order_id: orderId,
|
|
1615
|
-
external_sale_number: externalSaleNumber
|
|
1616
|
-
}, {
|
|
1617
|
-
osServer: true
|
|
1618
|
-
});
|
|
1619
|
-
}
|
|
1620
1508
|
/**
|
|
1621
1509
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
1622
1510
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { OrderProductDiscountItem } from '../types';
|
|
2
|
-
type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
|
|
3
|
-
export declare function restoreHydratedBundleDiscounts<T extends Record<string, any>>(product: T, normalizeDiscountList: NormalizeDiscountList): T;
|
|
4
|
-
export declare function expandHydratedProductsForDiscountCollection(products: any[] | undefined | null): any[];
|
|
5
|
-
export {};
|