@pisell/pisellos 2.3.22 → 2.3.23
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/Order/index.d.ts +2 -1
- package/dist/modules/Order/index.js +24 -11
- package/dist/modules/Order/utils.d.ts +2 -2
- package/dist/modules/Order/utils.js +35 -47
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BaseSales/index.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +7 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +2 -1
- package/lib/modules/Order/index.js +14 -3
- package/lib/modules/Order/utils.d.ts +2 -2
- package/lib/modules/Order/utils.js +0 -3
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BaseSales/index.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +5 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -276,6 +276,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
276
276
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
277
277
|
private buildTempOrderCustomer;
|
|
278
278
|
private isCustomerBoundDiscount;
|
|
279
|
+
private shouldKeepCustomerBoundDiscountAfterCustomerChange;
|
|
279
280
|
private productHasCustomerBoundDiscount;
|
|
280
281
|
private shouldSkipDiscountCalculation;
|
|
281
282
|
private clearCustomerBoundDiscounts;
|
|
@@ -463,7 +464,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
463
464
|
generateIdempotencyToken(): string;
|
|
464
465
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
465
466
|
createOrder(params: CommitOrderParams['query']): {
|
|
466
|
-
type: "
|
|
467
|
+
type: "virtual" | "appointment_booking";
|
|
467
468
|
platform: string;
|
|
468
469
|
sales_channel: string;
|
|
469
470
|
order_sales_channel: string;
|
|
@@ -492,7 +492,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
492
492
|
value: function () {
|
|
493
493
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
494
494
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
495
|
-
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
495
|
+
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
496
496
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
497
497
|
while (1) switch (_context3.prev = _context3.next) {
|
|
498
498
|
case 0:
|
|
@@ -511,30 +511,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
511
511
|
case 3:
|
|
512
512
|
discountList = _context3.sent;
|
|
513
513
|
if (!discountList) {
|
|
514
|
-
_context3.next =
|
|
514
|
+
_context3.next = 16;
|
|
515
515
|
break;
|
|
516
516
|
}
|
|
517
|
-
|
|
517
|
+
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
518
|
+
currentEditDiscounts = currentDiscountList.filter(function (discount) {
|
|
518
519
|
return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
|
|
519
520
|
});
|
|
521
|
+
currentScanDiscounts = currentDiscountList.filter(function (discount) {
|
|
522
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
523
|
+
});
|
|
524
|
+
currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
|
|
525
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
526
|
+
}));
|
|
520
527
|
runtimeDiscountIds = new Set();
|
|
521
528
|
runtimeDiscounts = discountList.filter(function (discount) {
|
|
529
|
+
if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
522
530
|
if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
523
531
|
runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
524
532
|
return true;
|
|
525
533
|
});
|
|
526
|
-
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
527
|
-
_context3.next =
|
|
534
|
+
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
535
|
+
_context3.next = 14;
|
|
528
536
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
529
|
-
case
|
|
530
|
-
_context3.next =
|
|
537
|
+
case 14:
|
|
538
|
+
_context3.next = 16;
|
|
531
539
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
532
|
-
case
|
|
540
|
+
case 16:
|
|
533
541
|
if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
|
|
534
542
|
this.applyDiscount();
|
|
535
543
|
}
|
|
536
544
|
return _context3.abrupt("return", this.getDiscountList());
|
|
537
|
-
case
|
|
545
|
+
case 18:
|
|
538
546
|
case "end":
|
|
539
547
|
return _context3.stop();
|
|
540
548
|
}
|
|
@@ -2962,6 +2970,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2962
2970
|
var type = (_discount$type5 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type5 !== void 0 ? _discount$type5 : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
2963
2971
|
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2964
2972
|
}
|
|
2973
|
+
}, {
|
|
2974
|
+
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
2975
|
+
value: function shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
2976
|
+
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isScan) || (discount === null || discount === void 0 ? void 0 : discount.isEditMode));
|
|
2977
|
+
}
|
|
2965
2978
|
}, {
|
|
2966
2979
|
key: "productHasCustomerBoundDiscount",
|
|
2967
2980
|
value: function productHasCustomerBoundDiscount(product) {
|
|
@@ -3029,11 +3042,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3029
3042
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3030
3043
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3031
3044
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3032
|
-
if (discount
|
|
3045
|
+
if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3033
3046
|
return !_this18.isCustomerBoundDiscount(discount);
|
|
3034
3047
|
});
|
|
3035
3048
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3036
|
-
if (discount
|
|
3049
|
+
if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3037
3050
|
return !_this18.isCustomerBoundDiscount(discount);
|
|
3038
3051
|
});
|
|
3039
3052
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
@@ -67,8 +67,8 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
67
67
|
/**
|
|
68
68
|
* 仅基于 tempOrder.products 重算整单定金。
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
70
|
+
* 商品折扣在进入定金计算前已体现在商品行价格字段中,
|
|
71
|
+
* 因此这里只按商品定金规则汇总,不再扣减 discount_list;tempOrder.bookings 不参与这里的计算。
|
|
72
72
|
*/
|
|
73
73
|
export declare function calculateOrderProductsDeposit(products?: OrderProduct[], options?: {
|
|
74
74
|
productsByUid?: Record<string, Record<string, any>>;
|
|
@@ -252,8 +252,8 @@ function getOrderProductDeposit(product, runtimeOrigin) {
|
|
|
252
252
|
/**
|
|
253
253
|
* 仅基于 tempOrder.products 重算整单定金。
|
|
254
254
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
255
|
+
* 商品折扣在进入定金计算前已体现在商品行价格字段中,
|
|
256
|
+
* 因此这里只按商品定金规则汇总,不再扣减 discount_list;tempOrder.bookings 不参与这里的计算。
|
|
257
257
|
*/
|
|
258
258
|
export function calculateOrderProductsDeposit() {
|
|
259
259
|
var products = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -273,30 +273,18 @@ export function calculateOrderProductsDeposit() {
|
|
|
273
273
|
product.deposit = deposit;
|
|
274
274
|
if (!(deposit !== null && deposit !== void 0 && deposit.total) || Number(deposit.total) <= 0) continue;
|
|
275
275
|
total = total.plus(deposit.total);
|
|
276
|
-
var _iterator4 = _createForOfIteratorHelper(
|
|
276
|
+
var _iterator4 = _createForOfIteratorHelper(deposit.protocols || []),
|
|
277
277
|
_step4;
|
|
278
278
|
try {
|
|
279
279
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
280
|
-
var
|
|
281
|
-
|
|
280
|
+
var protocol = _step4.value;
|
|
281
|
+
if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
|
|
282
282
|
}
|
|
283
283
|
} catch (err) {
|
|
284
284
|
_iterator4.e(err);
|
|
285
285
|
} finally {
|
|
286
286
|
_iterator4.f();
|
|
287
287
|
}
|
|
288
|
-
var _iterator5 = _createForOfIteratorHelper(deposit.protocols || []),
|
|
289
|
-
_step5;
|
|
290
|
-
try {
|
|
291
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
292
|
-
var protocol = _step5.value;
|
|
293
|
-
if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
|
|
294
|
-
}
|
|
295
|
-
} catch (err) {
|
|
296
|
-
_iterator5.e(err);
|
|
297
|
-
} finally {
|
|
298
|
-
_iterator5.f();
|
|
299
|
-
}
|
|
300
288
|
hasDeposit = true;
|
|
301
289
|
}
|
|
302
290
|
} catch (err) {
|
|
@@ -460,19 +448,19 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
460
448
|
}
|
|
461
449
|
function collectSubmitProductDiscountList(product) {
|
|
462
450
|
var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
|
|
463
|
-
var
|
|
464
|
-
|
|
451
|
+
var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
452
|
+
_step5;
|
|
465
453
|
try {
|
|
466
|
-
for (
|
|
467
|
-
var bundle =
|
|
454
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
455
|
+
var bundle = _step5.value;
|
|
468
456
|
if (!bundle || _typeof(bundle) !== 'object') continue;
|
|
469
457
|
var bundleMapId = resolveSubmitBundleMapId(bundle);
|
|
470
458
|
var bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
|
|
471
|
-
var
|
|
472
|
-
|
|
459
|
+
var _iterator6 = _createForOfIteratorHelper(bundleDiscountList),
|
|
460
|
+
_step6;
|
|
473
461
|
try {
|
|
474
|
-
for (
|
|
475
|
-
var discount =
|
|
462
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
463
|
+
var discount = _step6.value;
|
|
476
464
|
if (!discount || _typeof(discount) !== 'object') continue;
|
|
477
465
|
var discountMetadata = discount.metadata && _typeof(discount.metadata) === 'object' ? discount.metadata : {};
|
|
478
466
|
var discountMapId = discountMetadata.custom_product_bundle_map_id !== undefined && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== '' ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
|
|
@@ -483,15 +471,15 @@ function collectSubmitProductDiscountList(product) {
|
|
|
483
471
|
} : {}));
|
|
484
472
|
}
|
|
485
473
|
} catch (err) {
|
|
486
|
-
|
|
474
|
+
_iterator6.e(err);
|
|
487
475
|
} finally {
|
|
488
|
-
|
|
476
|
+
_iterator6.f();
|
|
489
477
|
}
|
|
490
478
|
}
|
|
491
479
|
} catch (err) {
|
|
492
|
-
|
|
480
|
+
_iterator5.e(err);
|
|
493
481
|
} finally {
|
|
494
|
-
|
|
482
|
+
_iterator5.f();
|
|
495
483
|
}
|
|
496
484
|
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
497
485
|
}
|
|
@@ -961,19 +949,19 @@ export function normalizeBookingSubType(booking) {
|
|
|
961
949
|
export function normalizeSubmitBooking(booking) {
|
|
962
950
|
var rawMetadata = booking.metadata || {};
|
|
963
951
|
var cleanMetadata = {};
|
|
964
|
-
var
|
|
965
|
-
|
|
952
|
+
var _iterator7 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
|
|
953
|
+
_step7;
|
|
966
954
|
try {
|
|
967
|
-
for (
|
|
968
|
-
var key =
|
|
955
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
956
|
+
var key = _step7.value;
|
|
969
957
|
if (rawMetadata[key] !== undefined) {
|
|
970
958
|
cleanMetadata[key] = rawMetadata[key];
|
|
971
959
|
}
|
|
972
960
|
}
|
|
973
961
|
} catch (err) {
|
|
974
|
-
|
|
962
|
+
_iterator7.e(err);
|
|
975
963
|
} finally {
|
|
976
|
-
|
|
964
|
+
_iterator7.f();
|
|
977
965
|
}
|
|
978
966
|
if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
|
|
979
967
|
var bookingRecord = booking;
|
|
@@ -1286,25 +1274,25 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1286
1274
|
target[key] = null;
|
|
1287
1275
|
changed = true;
|
|
1288
1276
|
};
|
|
1289
|
-
var
|
|
1290
|
-
|
|
1277
|
+
var _iterator8 = _createForOfIteratorHelper(tempOrder.products || []),
|
|
1278
|
+
_step8;
|
|
1291
1279
|
try {
|
|
1292
|
-
for (
|
|
1293
|
-
var product =
|
|
1280
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1281
|
+
var product = _step8.value;
|
|
1294
1282
|
if (product.metadata && _typeof(product.metadata) === 'object') {
|
|
1295
1283
|
resetHolderField(product.metadata);
|
|
1296
1284
|
}
|
|
1297
1285
|
}
|
|
1298
1286
|
} catch (err) {
|
|
1299
|
-
|
|
1287
|
+
_iterator8.e(err);
|
|
1300
1288
|
} finally {
|
|
1301
|
-
|
|
1289
|
+
_iterator8.f();
|
|
1302
1290
|
}
|
|
1303
|
-
var
|
|
1304
|
-
|
|
1291
|
+
var _iterator9 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
1292
|
+
_step9;
|
|
1305
1293
|
try {
|
|
1306
|
-
for (
|
|
1307
|
-
var booking =
|
|
1294
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1295
|
+
var booking = _step9.value;
|
|
1308
1296
|
var bookingRecord = booking;
|
|
1309
1297
|
if (booking.metadata && _typeof(booking.metadata) === 'object') {
|
|
1310
1298
|
resetHolderField(booking.metadata);
|
|
@@ -1315,9 +1303,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1315
1303
|
}
|
|
1316
1304
|
}
|
|
1317
1305
|
} catch (err) {
|
|
1318
|
-
|
|
1306
|
+
_iterator9.e(err);
|
|
1319
1307
|
} finally {
|
|
1320
|
-
|
|
1308
|
+
_iterator9.f();
|
|
1321
1309
|
}
|
|
1322
1310
|
var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
|
|
1323
1311
|
if (productsByUid && _typeof(productsByUid) === 'object') {
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -52,6 +52,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
52
52
|
private salesDetailLoadInFlight;
|
|
53
53
|
private serverOrderChangeUnsubscribe;
|
|
54
54
|
private serverOrderChangeHydrateInFlight;
|
|
55
|
+
private serverOrderChangeSyncEnabled;
|
|
55
56
|
constructor(name?: string, version?: string);
|
|
56
57
|
/**
|
|
57
58
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -73,6 +74,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
73
74
|
*/
|
|
74
75
|
private logError;
|
|
75
76
|
private isCurrentSalesOrderRecord;
|
|
77
|
+
setServerOrderChangeSyncEnabled(enabled: boolean): void;
|
|
76
78
|
private syncCurrentSalesDetailFromServerOrderChange;
|
|
77
79
|
private registerServerOrderChangeSync;
|
|
78
80
|
private hydrateOrderPaymentNames;
|
|
@@ -187,6 +187,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
187
187
|
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlight", false);
|
|
188
188
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
|
|
189
189
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
|
|
190
|
+
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeSyncEnabled", false);
|
|
190
191
|
return _this;
|
|
191
192
|
}
|
|
192
193
|
|
|
@@ -276,6 +277,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
276
277
|
return isSameBaseSalesOrderRecord(record, order);
|
|
277
278
|
});
|
|
278
279
|
}
|
|
280
|
+
}, {
|
|
281
|
+
key: "setServerOrderChangeSyncEnabled",
|
|
282
|
+
value: function setServerOrderChangeSyncEnabled(enabled) {
|
|
283
|
+
this.serverOrderChangeSyncEnabled = enabled;
|
|
284
|
+
}
|
|
279
285
|
}, {
|
|
280
286
|
key: "syncCurrentSalesDetailFromServerOrderChange",
|
|
281
287
|
value: function () {
|
|
@@ -286,7 +292,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
286
292
|
while (1) switch (_context2.prev = _context2.next) {
|
|
287
293
|
case 0:
|
|
288
294
|
changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload === null || payload === void 0 ? void 0 : payload.changedOrders) ? payload.changedOrders : payload !== null && payload !== void 0 && payload.data && _typeof(payload.data) === 'object' ? [payload.data] : [];
|
|
289
|
-
if (!(this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)) {
|
|
295
|
+
if (!(!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)) {
|
|
290
296
|
_context2.next = 3;
|
|
291
297
|
break;
|
|
292
298
|
}
|
|
@@ -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;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
-
var promotion_exports = {};
|
|
31
|
-
__export(promotion_exports, {
|
|
32
|
-
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
-
default: () => import_adapter2.default
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
-
var import_evaluator = require("./evaluator");
|
|
40
|
-
var import_adapter = require("./adapter");
|
|
41
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
-
var import_examples = require("./examples");
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
-
PromotionAdapter,
|
|
47
|
-
PromotionEvaluator,
|
|
48
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
-
});
|
|
@@ -276,6 +276,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
276
276
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
277
277
|
private buildTempOrderCustomer;
|
|
278
278
|
private isCustomerBoundDiscount;
|
|
279
|
+
private shouldKeepCustomerBoundDiscountAfterCustomerChange;
|
|
279
280
|
private productHasCustomerBoundDiscount;
|
|
280
281
|
private shouldSkipDiscountCalculation;
|
|
281
282
|
private clearCustomerBoundDiscounts;
|
|
@@ -463,7 +464,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
463
464
|
generateIdempotencyToken(): string;
|
|
464
465
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
465
466
|
createOrder(params: CommitOrderParams['query']): {
|
|
466
|
-
type: "
|
|
467
|
+
type: "virtual" | "appointment_booking";
|
|
467
468
|
platform: string;
|
|
468
469
|
sales_channel: string;
|
|
469
470
|
order_sales_channel: string;
|
|
@@ -445,9 +445,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
445
445
|
...orderId ? { order_id: orderId } : {}
|
|
446
446
|
}));
|
|
447
447
|
if (discountList) {
|
|
448
|
-
const
|
|
448
|
+
const currentDiscountList = ((_c = this.store.discount) == null ? void 0 : _c.getDiscountList()) || [];
|
|
449
|
+
const currentEditDiscounts = currentDiscountList.filter((discount) => discount == null ? void 0 : discount.isEditMode);
|
|
450
|
+
const currentScanDiscounts = currentDiscountList.filter((discount) => discount == null ? void 0 : discount.isScan);
|
|
451
|
+
const currentScanDiscountIds = new Set(
|
|
452
|
+
currentScanDiscounts.map((discount) => discount == null ? void 0 : discount.id)
|
|
453
|
+
);
|
|
449
454
|
const runtimeDiscountIds = /* @__PURE__ */ new Set();
|
|
450
455
|
const runtimeDiscounts = discountList.filter((discount) => {
|
|
456
|
+
if (currentScanDiscountIds.has(discount == null ? void 0 : discount.id))
|
|
457
|
+
return false;
|
|
451
458
|
if (runtimeDiscountIds.has(discount == null ? void 0 : discount.id))
|
|
452
459
|
return false;
|
|
453
460
|
runtimeDiscountIds.add(discount == null ? void 0 : discount.id);
|
|
@@ -455,6 +462,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
455
462
|
});
|
|
456
463
|
const mergedDiscountList = [
|
|
457
464
|
...currentEditDiscounts,
|
|
465
|
+
...currentScanDiscounts,
|
|
458
466
|
...runtimeDiscounts
|
|
459
467
|
];
|
|
460
468
|
await ((_d = this.store.discount) == null ? void 0 : _d.setOriginalDiscountList(mergedDiscountList));
|
|
@@ -2214,6 +2222,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2214
2222
|
const type = (discount == null ? void 0 : discount.type) ?? (discount == null ? void 0 : discount.tag);
|
|
2215
2223
|
return type === "good_pass" || type === "discount_card" || type === "product_discount_card";
|
|
2216
2224
|
}
|
|
2225
|
+
shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
2226
|
+
return Boolean((discount == null ? void 0 : discount.isScan) || (discount == null ? void 0 : discount.isEditMode));
|
|
2227
|
+
}
|
|
2217
2228
|
productHasCustomerBoundDiscount(product) {
|
|
2218
2229
|
if (((product == null ? void 0 : product.discount_list) || []).some((discount) => this.isCustomerBoundDiscount(discount))) {
|
|
2219
2230
|
return true;
|
|
@@ -2269,12 +2280,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2269
2280
|
const currentDiscounts = ((_a = discountModule.getDiscountList) == null ? void 0 : _a.call(discountModule)) || [];
|
|
2270
2281
|
const currentOriginalDiscounts = ((_b = discountModule.getOriginalDiscountList) == null ? void 0 : _b.call(discountModule)) || [];
|
|
2271
2282
|
const nextDiscounts = currentDiscounts.filter((discount) => {
|
|
2272
|
-
if (discount
|
|
2283
|
+
if (this.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount))
|
|
2273
2284
|
return true;
|
|
2274
2285
|
return !this.isCustomerBoundDiscount(discount);
|
|
2275
2286
|
});
|
|
2276
2287
|
const nextOriginalDiscounts = currentOriginalDiscounts.filter((discount) => {
|
|
2277
|
-
if (discount
|
|
2288
|
+
if (this.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount))
|
|
2278
2289
|
return true;
|
|
2279
2290
|
return !this.isCustomerBoundDiscount(discount);
|
|
2280
2291
|
});
|
|
@@ -67,8 +67,8 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
67
67
|
/**
|
|
68
68
|
* 仅基于 tempOrder.products 重算整单定金。
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
70
|
+
* 商品折扣在进入定金计算前已体现在商品行价格字段中,
|
|
71
|
+
* 因此这里只按商品定金规则汇总,不再扣减 discount_list;tempOrder.bookings 不参与这里的计算。
|
|
72
72
|
*/
|
|
73
73
|
export declare function calculateOrderProductsDeposit(products?: OrderProduct[], options?: {
|
|
74
74
|
productsByUid?: Record<string, Record<string, any>>;
|
|
@@ -286,9 +286,6 @@ function calculateOrderProductsDeposit(products = [], options) {
|
|
|
286
286
|
if (!(deposit == null ? void 0 : deposit.total) || Number(deposit.total) <= 0)
|
|
287
287
|
continue;
|
|
288
288
|
total = total.plus(deposit.total);
|
|
289
|
-
for (const discount of product.discount_list || []) {
|
|
290
|
-
total = total.minus((discount == null ? void 0 : discount.amount) || 0);
|
|
291
|
-
}
|
|
292
289
|
for (const protocol of deposit.protocols || []) {
|
|
293
290
|
if (!protocolMap.has(protocol.id))
|
|
294
291
|
protocolMap.set(protocol.id, protocol);
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -52,6 +52,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
52
52
|
private salesDetailLoadInFlight;
|
|
53
53
|
private serverOrderChangeUnsubscribe;
|
|
54
54
|
private serverOrderChangeHydrateInFlight;
|
|
55
|
+
private serverOrderChangeSyncEnabled;
|
|
55
56
|
constructor(name?: string, version?: string);
|
|
56
57
|
/**
|
|
57
58
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -73,6 +74,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
73
74
|
*/
|
|
74
75
|
private logError;
|
|
75
76
|
private isCurrentSalesOrderRecord;
|
|
77
|
+
setServerOrderChangeSyncEnabled(enabled: boolean): void;
|
|
76
78
|
private syncCurrentSalesDetailFromServerOrderChange;
|
|
77
79
|
private registerServerOrderChangeSync;
|
|
78
80
|
private hydrateOrderPaymentNames;
|
|
@@ -193,6 +193,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
193
193
|
this.salesDetailLoadInFlight = false;
|
|
194
194
|
this.serverOrderChangeUnsubscribe = null;
|
|
195
195
|
this.serverOrderChangeHydrateInFlight = null;
|
|
196
|
+
this.serverOrderChangeSyncEnabled = false;
|
|
196
197
|
}
|
|
197
198
|
/**
|
|
198
199
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -266,9 +267,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
266
267
|
].filter(Boolean);
|
|
267
268
|
return currentRecords.some((record) => isSameBaseSalesOrderRecord(record, order));
|
|
268
269
|
}
|
|
270
|
+
setServerOrderChangeSyncEnabled(enabled) {
|
|
271
|
+
this.serverOrderChangeSyncEnabled = enabled;
|
|
272
|
+
}
|
|
269
273
|
async syncCurrentSalesDetailFromServerOrderChange(payload) {
|
|
270
274
|
const changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload == null ? void 0 : payload.changedOrders) ? payload.changedOrders : (payload == null ? void 0 : payload.data) && typeof payload.data === "object" ? [payload.data] : [];
|
|
271
|
-
if (this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)
|
|
275
|
+
if (!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)
|
|
272
276
|
return;
|
|
273
277
|
const changedOrder = changedOrders.find(
|
|
274
278
|
(order) => this.isCurrentSalesOrderRecord(order)
|
|
@@ -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;
|