@pisell/pisellos 2.3.5 → 2.3.7
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/core/index.js +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
- package/dist/modules/Order/index.d.ts +12 -1
- package/dist/modules/Order/index.js +260 -160
- package/dist/modules/Order/types.d.ts +5 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +31 -0
- 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 +4 -3
- package/dist/server/modules/order/index.d.ts +4 -4
- package/dist/server/modules/order/index.js +4 -4
- package/dist/solution/BaseSales/index.js +93 -68
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/core/index.js +1 -1
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.d.ts +12 -1
- package/lib/modules/Order/index.js +135 -26
- package/lib/modules/Order/types.d.ts +5 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +39 -0
- 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/index.js +1 -4
- package/lib/server/modules/order/index.d.ts +4 -4
- package/lib/server/modules/order/index.js +4 -4
- package/lib/solution/BaseSales/index.js +40 -19
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -1480,14 +1487,27 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1480
1487
|
});
|
|
1481
1488
|
try {
|
|
1482
1489
|
const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
|
|
1483
|
-
|
|
1490
|
+
const latestPayments = this.store.order.getOrderPayments();
|
|
1491
|
+
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1492
|
+
const orderSnapshot = this.store.order.getOrderSnapshot();
|
|
1493
|
+
const syncPayload = {
|
|
1484
1494
|
ok: true,
|
|
1485
1495
|
syncResult,
|
|
1486
|
-
payments:
|
|
1496
|
+
payments: latestPayments,
|
|
1487
1497
|
params: syncParams,
|
|
1488
|
-
amountSnapshot
|
|
1489
|
-
orderSnapshot
|
|
1490
|
-
|
|
1498
|
+
amountSnapshot,
|
|
1499
|
+
orderSnapshot,
|
|
1500
|
+
isFullyPaid: syncResult.isFullyPaid,
|
|
1501
|
+
isOrderFullyPaid: syncResult.isOrderFullyPaid,
|
|
1502
|
+
isDepositFullyPaid: syncResult.isDepositFullyPaid,
|
|
1503
|
+
paymentStage: syncResult.paymentStage,
|
|
1504
|
+
depositAmount: syncResult.depositAmount,
|
|
1505
|
+
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
1506
|
+
};
|
|
1507
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
1508
|
+
if (syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid) {
|
|
1509
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
1510
|
+
}
|
|
1491
1511
|
return syncResult;
|
|
1492
1512
|
} catch (error) {
|
|
1493
1513
|
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
@@ -1550,7 +1570,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1550
1570
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1551
1571
|
const syncState = this.store.order.getOrderSyncState();
|
|
1552
1572
|
if (amountSnapshot && syncState !== "submitting") {
|
|
1553
|
-
const
|
|
1573
|
+
const completion = this.store.order.getPaymentCompletion(payments);
|
|
1574
|
+
const paymentStatus = completion.isOrderFullyPaid ? "paid" : "partially_paid";
|
|
1554
1575
|
void this.syncPaymentsToOrder({
|
|
1555
1576
|
payments,
|
|
1556
1577
|
paymentStatus,
|
|
@@ -14,6 +14,7 @@ export declare const BaseSalesHookNames: {
|
|
|
14
14
|
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
15
15
|
readonly onPaymentSyncStart: "onPaymentSyncStart";
|
|
16
16
|
readonly onPaymentSyncEnd: "onPaymentSyncEnd";
|
|
17
|
+
readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
|
|
17
18
|
};
|
|
18
19
|
export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
|
|
19
20
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
@@ -30,7 +30,8 @@ var BaseSalesHookNames = {
|
|
|
30
30
|
onRefresh: "onRefresh",
|
|
31
31
|
onCartValidationChanged: "onCartValidationChanged",
|
|
32
32
|
onPaymentSyncStart: "onPaymentSyncStart",
|
|
33
|
-
onPaymentSyncEnd: "onPaymentSyncEnd"
|
|
33
|
+
onPaymentSyncEnd: "onPaymentSyncEnd",
|
|
34
|
+
onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd"
|
|
34
35
|
};
|
|
35
36
|
function createBaseSalesHook(moduleName, hookName) {
|
|
36
37
|
return `${moduleName}:${hookName}`;
|
|
@@ -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 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|