@pisell/pisellos 2.3.6 → 2.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
- package/dist/modules/Order/index.d.ts +18 -2
- package/dist/modules/Order/index.js +392 -222
- package/dist/modules/Order/types.d.ts +15 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +114 -28
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +8 -3
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/server/index.js +1 -0
- package/dist/server/modules/order/index.d.ts +4 -4
- package/dist/server/modules/order/index.js +4 -4
- package/dist/solution/BaseSales/index.d.ts +8 -1
- package/dist/solution/BaseSales/index.js +145 -104
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.d.ts +18 -2
- package/lib/modules/Order/index.js +229 -40
- package/lib/modules/Order/types.d.ts +15 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +84 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/server/modules/order/index.d.ts +4 -4
- package/lib/server/modules/order/index.js +4 -4
- package/lib/solution/BaseSales/index.d.ts +8 -1
- package/lib/solution/BaseSales/index.js +58 -22
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -165,10 +165,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
165
165
|
return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
|
|
166
166
|
}
|
|
167
167
|
getReusableSharedSubModule(moduleName) {
|
|
168
|
-
var _a;
|
|
168
|
+
var _a, _b;
|
|
169
169
|
if (moduleName !== "schedule" && moduleName !== "quotation")
|
|
170
170
|
return null;
|
|
171
|
-
return ((_a = this.core) == null ? void 0 : _a.getModule(moduleName)) || null;
|
|
171
|
+
return ((_b = (_a = this.core) == null ? void 0 : _a.getModule) == null ? void 0 : _b.call(_a, moduleName)) || null;
|
|
172
172
|
}
|
|
173
173
|
isScheduleListLoaded(scheduleModule) {
|
|
174
174
|
if (!scheduleModule)
|
|
@@ -1019,7 +1019,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1019
1019
|
});
|
|
1020
1020
|
}
|
|
1021
1021
|
async loadDiscountConfig(params) {
|
|
1022
|
-
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;
|
|
1023
1023
|
if (!this.store.order)
|
|
1024
1024
|
throw new Error("order 模块未初始化");
|
|
1025
1025
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1090,13 +1090,15 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1090
1090
|
};
|
|
1091
1091
|
}
|
|
1092
1092
|
if (rulesModule) {
|
|
1093
|
-
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.
|
|
1093
|
+
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.form_record) || [];
|
|
1094
|
+
const orderTotalAmount = Number(((_m = orderStore.summary) == null ? void 0 : _m.total_amount) || 0);
|
|
1095
|
+
console.log("[BaseSales.applyDiscountConfig.calcDiscount]");
|
|
1094
1096
|
const result = rulesModule.calcDiscount({
|
|
1095
1097
|
productList: tempOrder.products,
|
|
1096
1098
|
discountList: nextDiscountList,
|
|
1097
1099
|
holders,
|
|
1098
|
-
isFormSubject:
|
|
1099
|
-
orderTotalAmount
|
|
1100
|
+
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1101
|
+
orderTotalAmount
|
|
1100
1102
|
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
1101
1103
|
if (result.productList) {
|
|
1102
1104
|
tempOrder.products = preserveManualProductDiscountProducts(
|
|
@@ -1105,8 +1107,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1105
1107
|
);
|
|
1106
1108
|
}
|
|
1107
1109
|
for (const product of tempOrder.products || []) {
|
|
1108
|
-
const productUid = (
|
|
1109
|
-
const runtimeOrigin = productUid ? (
|
|
1110
|
+
const productUid = (_n = product.metadata) == null ? void 0 : _n.unique_identification_number;
|
|
1111
|
+
const runtimeOrigin = productUid ? (_q = (_p = (_o = tempOrder._extend) == null ? void 0 : _o.productsByUid) == null ? void 0 : _p[productUid]) == null ? void 0 : _q.origin : void 0;
|
|
1110
1112
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1111
1113
|
continue;
|
|
1112
1114
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
@@ -1114,7 +1116,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1114
1116
|
0
|
|
1115
1117
|
);
|
|
1116
1118
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
1117
|
-
const sourcePrice = ((
|
|
1119
|
+
const sourcePrice = ((_r = product.metadata) == null ? void 0 : _r.source_product_price) ?? (((_s = product.metadata) == null ? void 0 : _s.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");
|
|
1118
1120
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1119
1121
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1120
1122
|
if (product.metadata) {
|
|
@@ -1150,7 +1152,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1150
1152
|
};
|
|
1151
1153
|
}
|
|
1152
1154
|
async bestDiscount(cb) {
|
|
1153
|
-
var _a, _b, _c, _d
|
|
1155
|
+
var _a, _b, _c, _d;
|
|
1154
1156
|
if (!this.store.order)
|
|
1155
1157
|
throw new Error("order 模块未初始化");
|
|
1156
1158
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1169,13 +1171,15 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1169
1171
|
};
|
|
1170
1172
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1171
1173
|
if (rulesModule) {
|
|
1172
|
-
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.
|
|
1174
|
+
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.form_record) || [];
|
|
1175
|
+
const orderTotalAmount = Number(((_d = orderStore.summary) == null ? void 0 : _d.total_amount) || 0);
|
|
1176
|
+
console.log("[BaseSales.bestDiscount.calcDiscount]");
|
|
1173
1177
|
result = rulesModule.calcDiscount({
|
|
1174
1178
|
productList: tempOrder.products,
|
|
1175
1179
|
discountList: nextDiscountList,
|
|
1176
1180
|
holders,
|
|
1177
|
-
isFormSubject:
|
|
1178
|
-
orderTotalAmount
|
|
1181
|
+
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1182
|
+
orderTotalAmount
|
|
1179
1183
|
}) || result;
|
|
1180
1184
|
if (result.productList) {
|
|
1181
1185
|
tempOrder.products = preserveManualProductDiscountProducts(
|
|
@@ -1244,16 +1248,19 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1244
1248
|
const orderStore = this.store.order.store || {};
|
|
1245
1249
|
const discountModule = orderStore.discount;
|
|
1246
1250
|
const rulesModule = orderStore.rules;
|
|
1247
|
-
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.
|
|
1251
|
+
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record) || [];
|
|
1248
1252
|
let nextDiscountList = updated;
|
|
1249
1253
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
1250
1254
|
if (rulesModule) {
|
|
1255
|
+
const orderTotalAmount = Number(((_b = orderStore.summary) == null ? void 0 : _b.total_amount) || 0);
|
|
1256
|
+
console.log("[BaseSales.setDiscountSelected.calcDiscount]");
|
|
1251
1257
|
const result = rulesModule.calcDiscount(
|
|
1252
1258
|
{
|
|
1253
1259
|
productList: tempOrder.products,
|
|
1254
1260
|
discountList: updated,
|
|
1255
1261
|
holders,
|
|
1256
|
-
isFormSubject:
|
|
1262
|
+
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1263
|
+
orderTotalAmount
|
|
1257
1264
|
},
|
|
1258
1265
|
{
|
|
1259
1266
|
discountId: params.discountId,
|
|
@@ -1276,6 +1283,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1276
1283
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1277
1284
|
d.isSelected = false;
|
|
1278
1285
|
d.isManualSelect = true;
|
|
1286
|
+
d.appliedProductDetails = [];
|
|
1279
1287
|
}
|
|
1280
1288
|
}
|
|
1281
1289
|
}
|
|
@@ -1284,16 +1292,32 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1284
1292
|
const selectedResourceIds = new Set(
|
|
1285
1293
|
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1286
1294
|
);
|
|
1295
|
+
const filterSelectedDiscountDetails = (discountList) => (discountList || []).filter((pd) => {
|
|
1296
|
+
var _a2;
|
|
1297
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1298
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1299
|
+
});
|
|
1287
1300
|
for (const product of tempOrder.products) {
|
|
1288
1301
|
const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
|
|
1289
1302
|
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;
|
|
1290
1303
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1291
1304
|
continue;
|
|
1292
|
-
product.discount_list = (product.discount_list
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1305
|
+
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
1306
|
+
if (Array.isArray(product.product_bundle)) {
|
|
1307
|
+
product.product_bundle = product.product_bundle.map((bundle) => {
|
|
1308
|
+
const nextBundleDiscountList = filterSelectedDiscountDetails(bundle == null ? void 0 : bundle.discount_list);
|
|
1309
|
+
const shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
1310
|
+
const restoredBundlePrice = (bundle == null ? void 0 : bundle.original_price) ?? (bundle == null ? void 0 : bundle.product_price) ?? (bundle == null ? void 0 : bundle.price);
|
|
1311
|
+
return {
|
|
1312
|
+
...bundle,
|
|
1313
|
+
...shouldRestoreBundlePrice ? {
|
|
1314
|
+
price: restoredBundlePrice,
|
|
1315
|
+
bundle_selling_price: restoredBundlePrice
|
|
1316
|
+
} : {},
|
|
1317
|
+
discount_list: nextBundleDiscountList
|
|
1318
|
+
};
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1297
1321
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1298
1322
|
(sum, pd) => sum + (pd.amount || 0),
|
|
1299
1323
|
0
|
|
@@ -1382,6 +1406,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1382
1406
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1383
1407
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1384
1408
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1409
|
+
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1385
1410
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1386
1411
|
};
|
|
1387
1412
|
return this.store.order.submitTempOrder(submitParams);
|
|
@@ -1401,6 +1426,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1401
1426
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1402
1427
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1403
1428
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1429
|
+
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1404
1430
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1405
1431
|
};
|
|
1406
1432
|
return this.store.order.submitTempOrderAsync(submitParams);
|
|
@@ -1592,10 +1618,20 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1592
1618
|
return this.store.order.deleteOrderPayment(paymentIdentity);
|
|
1593
1619
|
}
|
|
1594
1620
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
1595
|
-
updateVoucherOrderPayments(payments) {
|
|
1621
|
+
updateVoucherOrderPayments(payments, options) {
|
|
1622
|
+
if (!this.store.order)
|
|
1623
|
+
throw new Error("order 模块未初始化");
|
|
1624
|
+
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
1625
|
+
}
|
|
1626
|
+
confirmPendingVoucherPayments() {
|
|
1627
|
+
if (!this.store.order)
|
|
1628
|
+
throw new Error("order 模块未初始化");
|
|
1629
|
+
return this.store.order.confirmPendingVoucherPayments();
|
|
1630
|
+
}
|
|
1631
|
+
discardPendingVoucherPayments() {
|
|
1596
1632
|
if (!this.store.order)
|
|
1597
1633
|
throw new Error("order 模块未初始化");
|
|
1598
|
-
return this.store.order.
|
|
1634
|
+
return this.store.order.discardPendingVoucherPayments();
|
|
1599
1635
|
}
|
|
1600
1636
|
getWalletProductList() {
|
|
1601
1637
|
var _a, _b, _c;
|
|
@@ -129,10 +129,9 @@ 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
|
-
|
|
135
|
-
);
|
|
132
|
+
const explicitLineTotal = payload.line_total ?? payload.total ?? ((_c = payload._extend) == null ? void 0 : _c.total);
|
|
133
|
+
const hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
134
|
+
const lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
136
135
|
const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
|
|
137
136
|
const productOptionItem = (0, import_utils.normalizeProductSkuOptions)(
|
|
138
137
|
normalizeOptionItems(
|
|
@@ -180,7 +179,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
180
179
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(productOptionItem).toNumber();
|
|
181
180
|
const mainProductOriginalPrice = toPriceString(Number(sourceProductPrice) + optionSum);
|
|
182
181
|
const bundleOnlyComposite = (0, import_utils.composeLinePrice)({ mainPrice: 0, bundle: productBundle });
|
|
183
|
-
const derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
|
|
182
|
+
const derivedMainSelling = hasExplicitLineTotal ? Number(lineCompositeTotal) - Number(bundleOnlyComposite) : Number(mainProductOriginalPrice);
|
|
184
183
|
const mainProductSellingPrice = toPriceString(
|
|
185
184
|
Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice)
|
|
186
185
|
);
|
|
@@ -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 | 1 | 2 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|