@pisell/pisellos 2.2.258 → 2.2.259
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 +4 -1
- package/dist/modules/Order/index.js +135 -75
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +2 -1
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +184 -191
- package/dist/server/modules/order/index.js +1 -2
- package/dist/solution/BaseSales/index.d.ts +6 -0
- package/dist/solution/BaseSales/index.js +782 -658
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.js +17 -26
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +4 -1
- package/lib/modules/Order/index.js +62 -7
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +2 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/server/index.d.ts +2 -2
- package/lib/server/index.js +55 -41
- package/lib/server/modules/order/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +6 -0
- package/lib/solution/BaseSales/index.js +103 -29
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.js +12 -23
- package/package.json +1 -1
|
@@ -66,7 +66,8 @@ function normalizeBundleItems(bundleItems) {
|
|
|
66
66
|
price: (_bundleItem$price3 = bundleItem.price) !== null && _bundleItem$price3 !== void 0 ? _bundleItem$price3 : unitStr,
|
|
67
67
|
bundle_selling_price: unitStr,
|
|
68
68
|
original_price: (_ref8 = (_ref9 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.price) !== null && _ref8 !== void 0 ? _ref8 : unitStr,
|
|
69
|
-
option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option)
|
|
69
|
+
option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option),
|
|
70
|
+
discount_list: preferPriceField ? [] : bundleItem.discount_list
|
|
70
71
|
});
|
|
71
72
|
// bundle_selling_price 落「正净额」:markdown = |price| − Σoptions;markup/原价维持原值。
|
|
72
73
|
normalizedItem.bundle_selling_price = getBundleSellingMagnitude(magnitudeSource).toFixed(2);
|
|
@@ -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 | 3 | 4 | 5 | 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 客户状态
|
|
@@ -555,7 +555,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
555
555
|
handlePrintWristband(params: {
|
|
556
556
|
voucher_ids: number[];
|
|
557
557
|
}): Promise<void>;
|
|
558
|
-
|
|
558
|
+
handleRedeem(params: {
|
|
559
559
|
voucher_ids: number[];
|
|
560
560
|
is_checkin: boolean;
|
|
561
561
|
}): Promise<any>;
|
|
@@ -2657,45 +2657,35 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2657
2657
|
return _handlePrintWristband.apply(this, arguments);
|
|
2658
2658
|
}
|
|
2659
2659
|
return handlePrintWristband;
|
|
2660
|
-
}() //
|
|
2660
|
+
}() // 触发核销
|
|
2661
2661
|
}, {
|
|
2662
|
-
key: "
|
|
2662
|
+
key: "handleRedeem",
|
|
2663
2663
|
value: function () {
|
|
2664
|
-
var
|
|
2664
|
+
var _handleRedeem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
2665
2665
|
var _this$store$order5, _this$store$order5$ge, _this$store$order6, _ref20, _tempOrder$order_id2;
|
|
2666
|
-
var voucherIds, voucherIdSet, tempOrder, vouchers,
|
|
2666
|
+
var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
|
|
2667
2667
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2668
2668
|
while (1) switch (_context33.prev = _context33.next) {
|
|
2669
2669
|
case 0:
|
|
2670
|
+
voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
2671
|
+
status = params.is_checkin ? 'used' : 'unused';
|
|
2670
2672
|
this.logger.addLog({
|
|
2671
2673
|
type: 'info',
|
|
2672
|
-
title: '[BookingTicket]
|
|
2674
|
+
title: '[BookingTicket] handleRedeem',
|
|
2673
2675
|
metadata: {
|
|
2674
|
-
voucher_ids:
|
|
2675
|
-
|
|
2676
|
+
voucher_ids: voucherIds,
|
|
2677
|
+
status: status
|
|
2676
2678
|
}
|
|
2677
2679
|
});
|
|
2678
|
-
voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
2679
2680
|
voucherIdSet = new Set(voucherIds);
|
|
2680
2681
|
tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getTempOrder) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
|
|
2681
2682
|
vouchers = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.vouchers) || ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getVouchers()) || [];
|
|
2682
|
-
batchMetadata = [];
|
|
2683
2683
|
hasUpdatedVoucher = false;
|
|
2684
2684
|
nextVouchers = vouchers.map(function (voucher) {
|
|
2685
|
-
var _voucher$metadata;
|
|
2686
2685
|
if (!voucherIdSet.has(voucher.voucher_id)) return voucher;
|
|
2687
2686
|
hasUpdatedVoucher = true;
|
|
2688
|
-
var metadata = _objectSpread(_objectSpread({}, voucher.metadata || {}), {}, {
|
|
2689
|
-
ticket: _objectSpread(_objectSpread({}, ((_voucher$metadata = voucher.metadata) === null || _voucher$metadata === void 0 ? void 0 : _voucher$metadata.ticket) || {}), {}, {
|
|
2690
|
-
is_checkin: params.is_checkin
|
|
2691
|
-
})
|
|
2692
|
-
});
|
|
2693
|
-
batchMetadata.push({
|
|
2694
|
-
voucher_id: voucher.voucher_id,
|
|
2695
|
-
metadata: metadata
|
|
2696
|
-
});
|
|
2697
2687
|
return _objectSpread(_objectSpread({}, voucher), {}, {
|
|
2698
|
-
|
|
2688
|
+
status: status
|
|
2699
2689
|
});
|
|
2700
2690
|
});
|
|
2701
2691
|
if (!(tempOrder && hasUpdatedVoucher)) {
|
|
@@ -2708,7 +2698,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2708
2698
|
}));
|
|
2709
2699
|
case 11:
|
|
2710
2700
|
this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
|
|
2711
|
-
if (!(
|
|
2701
|
+
if (!(voucherIds.length === 0)) {
|
|
2712
2702
|
_context33.next = 14;
|
|
2713
2703
|
break;
|
|
2714
2704
|
}
|
|
@@ -2723,8 +2713,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2723
2713
|
externalSaleNumber = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) || (identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) || undefined;
|
|
2724
2714
|
orderId = (_ref20 = (_tempOrder$order_id2 = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _ref20 !== void 0 ? _ref20 : undefined;
|
|
2725
2715
|
orderLookup = externalSaleNumber || orderId || (identity === null || identity === void 0 ? void 0 : identity.orderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopOrderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopFullOrderNumber) || undefined;
|
|
2726
|
-
return _context33.abrupt("return", this.request.post('/machinecode/batch
|
|
2727
|
-
|
|
2716
|
+
return _context33.abrupt("return", this.request.post('/machinecode/batch', {
|
|
2717
|
+
ids: voucherIds,
|
|
2718
|
+
status: status,
|
|
2728
2719
|
order_lookup: orderLookup,
|
|
2729
2720
|
order_id: orderId,
|
|
2730
2721
|
external_sale_number: externalSaleNumber
|
|
@@ -2737,10 +2728,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2737
2728
|
}
|
|
2738
2729
|
}, _callee33, this);
|
|
2739
2730
|
}));
|
|
2740
|
-
function
|
|
2741
|
-
return
|
|
2731
|
+
function handleRedeem(_x24) {
|
|
2732
|
+
return _handleRedeem.apply(this, arguments);
|
|
2742
2733
|
}
|
|
2743
|
-
return
|
|
2734
|
+
return handleRedeem;
|
|
2744
2735
|
}()
|
|
2745
2736
|
/**
|
|
2746
2737
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
});
|
|
@@ -197,6 +197,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
197
197
|
private clearManualDepositOverride;
|
|
198
198
|
private getOriginalSalesSnapshot;
|
|
199
199
|
private isSnapshotPayableAmountUnchanged;
|
|
200
|
+
private hasShopDiscountChangedFromSnapshot;
|
|
200
201
|
private restoreOriginalSnapshotIfProductsUnchanged;
|
|
201
202
|
private clearPersistedAmountFieldsForFullRecalc;
|
|
202
203
|
private getPaymentTargetAmount;
|
|
@@ -230,6 +231,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
230
231
|
* const ids = this.collectBookingHolderRecords(booking);
|
|
231
232
|
*/
|
|
232
233
|
private collectBookingHolderRecords;
|
|
234
|
+
private setProductHolderFromBooking;
|
|
235
|
+
private syncLinkedBookingHoldersToProducts;
|
|
233
236
|
/**
|
|
234
237
|
* 按 form_record 顺序读取 booking holder 的主字段名称。
|
|
235
238
|
*
|
|
@@ -458,7 +461,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
458
461
|
generateIdempotencyToken(): string;
|
|
459
462
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
460
463
|
createOrder(params: CommitOrderParams['query']): {
|
|
461
|
-
type: "
|
|
464
|
+
type: "virtual" | "appointment_booking";
|
|
462
465
|
platform: string;
|
|
463
466
|
sales_channel: string;
|
|
464
467
|
order_sales_channel: string;
|
|
@@ -544,6 +544,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
544
544
|
const tempOrder = this.store.tempOrder;
|
|
545
545
|
if (!tempOrder)
|
|
546
546
|
return;
|
|
547
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
547
548
|
delete tempOrder.discount_list;
|
|
548
549
|
const discountList = ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
|
|
549
550
|
const shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
@@ -1469,10 +1470,15 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1469
1470
|
});
|
|
1470
1471
|
return currentAmountGap === snapshotAmountGap;
|
|
1471
1472
|
}
|
|
1472
|
-
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1473
|
+
hasShopDiscountChangedFromSnapshot(tempOrder, snapshot) {
|
|
1474
|
+
const snapshotSummary = snapshot.summary && typeof snapshot.summary === "object" ? snapshot.summary : {};
|
|
1475
|
+
const snapshotShopDiscount = snapshot.shop_discount ?? snapshotSummary.shop_discount;
|
|
1476
|
+
if (snapshotShopDiscount === void 0 || snapshotShopDiscount === null || snapshotShopDiscount === "") {
|
|
1477
|
+
return !new import_decimal.default(tempOrder.shop_discount || 0).equals(0);
|
|
1478
|
+
}
|
|
1479
|
+
return !new import_decimal.default(tempOrder.shop_discount || 0).equals(snapshotShopDiscount || 0);
|
|
1480
|
+
}
|
|
1481
|
+
restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
1476
1482
|
const currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
1477
1483
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
1478
1484
|
const currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
@@ -1787,6 +1793,47 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1787
1793
|
const records = Array.isArray(source) ? source : [source];
|
|
1788
1794
|
return records.filter((record) => record !== void 0 && record !== null && record !== "");
|
|
1789
1795
|
}
|
|
1796
|
+
setProductHolderFromBooking(product, booking) {
|
|
1797
|
+
if (!product || !booking)
|
|
1798
|
+
return;
|
|
1799
|
+
const holderRecords = this.collectBookingHolderRecords(booking);
|
|
1800
|
+
if (!product.metadata || typeof product.metadata !== "object") {
|
|
1801
|
+
product.metadata = {};
|
|
1802
|
+
}
|
|
1803
|
+
product.metadata.holder_id = holderRecords.length > 0 ? holderRecords : null;
|
|
1804
|
+
}
|
|
1805
|
+
syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
1806
|
+
const bookings = tempOrder.bookings || [];
|
|
1807
|
+
const products = tempOrder.products || [];
|
|
1808
|
+
if (!bookings.length || !products.length)
|
|
1809
|
+
return;
|
|
1810
|
+
const bookingByProductUid = /* @__PURE__ */ new Map();
|
|
1811
|
+
const bookingByBookingUid = /* @__PURE__ */ new Map();
|
|
1812
|
+
bookings.forEach((booking) => {
|
|
1813
|
+
var _a, _b;
|
|
1814
|
+
if (!booking || typeof booking !== "object")
|
|
1815
|
+
return;
|
|
1816
|
+
const productUid = booking.product_uid || ((_a = booking.metadata) == null ? void 0 : _a.product_uid);
|
|
1817
|
+
if (productUid !== void 0 && productUid !== null && String(productUid) !== "") {
|
|
1818
|
+
bookingByProductUid.set(String(productUid), booking);
|
|
1819
|
+
}
|
|
1820
|
+
const bookingUid = ((_b = booking.metadata) == null ? void 0 : _b.unique_identification_number) || booking.booking_uid;
|
|
1821
|
+
if (bookingUid !== void 0 && bookingUid !== null && String(bookingUid) !== "") {
|
|
1822
|
+
bookingByBookingUid.set(String(bookingUid), booking);
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
products.forEach((product) => {
|
|
1826
|
+
var _a, _b;
|
|
1827
|
+
if (!product || typeof product !== "object")
|
|
1828
|
+
return;
|
|
1829
|
+
const productUid = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || product.unique_identification_number;
|
|
1830
|
+
const bookingUid = product.booking_uid || ((_b = product.metadata) == null ? void 0 : _b.booking_uid);
|
|
1831
|
+
const linkedBooking = (productUid !== void 0 && productUid !== null && String(productUid) !== "" ? bookingByProductUid.get(String(productUid)) : void 0) || (bookingUid !== void 0 && bookingUid !== null && String(bookingUid) !== "" ? bookingByBookingUid.get(String(bookingUid)) : void 0);
|
|
1832
|
+
if (linkedBooking) {
|
|
1833
|
+
this.setProductHolderFromBooking(product, linkedBooking);
|
|
1834
|
+
}
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1790
1837
|
/**
|
|
1791
1838
|
* 按 form_record 顺序读取 booking holder 的主字段名称。
|
|
1792
1839
|
*
|
|
@@ -1866,6 +1913,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1866
1913
|
if (nextHolder || hasHolderSource || bookings.length === 0) {
|
|
1867
1914
|
tempOrder.holder = nextHolder;
|
|
1868
1915
|
}
|
|
1916
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
1869
1917
|
}
|
|
1870
1918
|
getBookingUniqueIdentificationNumber(booking) {
|
|
1871
1919
|
var _a;
|
|
@@ -1931,14 +1979,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1931
1979
|
return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
1932
1980
|
}
|
|
1933
1981
|
async recalculateSummary(options) {
|
|
1982
|
+
var _a;
|
|
1934
1983
|
const tempOrder = (options == null ? void 0 : options.createIfMissing) ? this.ensureTempOrder() : this.store.tempOrder;
|
|
1935
1984
|
if (!tempOrder)
|
|
1936
1985
|
return null;
|
|
1937
1986
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
1938
|
-
const
|
|
1987
|
+
const originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
1988
|
+
const hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
|
|
1989
|
+
const shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
1990
|
+
const snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
1939
1991
|
if (snapshotSummary)
|
|
1940
1992
|
return snapshotSummary;
|
|
1941
|
-
const shouldFullRecalculateFromSnapshot = Boolean(
|
|
1993
|
+
const shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
1942
1994
|
const summaryProducts = shouldFullRecalculateFromSnapshot ? (0, import_lodash_es.cloneDeep)(tempOrder.products || []) : tempOrder.products;
|
|
1943
1995
|
if (shouldFullRecalculateFromSnapshot) {
|
|
1944
1996
|
this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
|
|
@@ -1985,7 +2037,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1985
2037
|
const salesSummaryResult = await salesSummary.getSummary({
|
|
1986
2038
|
products: summaryProducts,
|
|
1987
2039
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
1988
|
-
shopDiscount: tempOrder.shop_discount
|
|
2040
|
+
shopDiscount: tempOrder.shop_discount,
|
|
2041
|
+
...((_a = this.otherParams) == null ? void 0 : _a.channel) ? { channel: this.otherParams.channel } : {}
|
|
1989
2042
|
});
|
|
1990
2043
|
if (shouldFullRecalculateFromSnapshot) {
|
|
1991
2044
|
tempOrder.products = summaryProducts;
|
|
@@ -3904,6 +3957,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3904
3957
|
products: (0, import_lodash_es.cloneDeep)(nextTempOrder.products || []),
|
|
3905
3958
|
payments: (0, import_lodash_es.cloneDeep)(nextTempOrder.payments || []),
|
|
3906
3959
|
surcharges: (0, import_lodash_es.cloneDeep)(nextTempOrder.surcharges || []),
|
|
3960
|
+
shop_discount: nextTempOrder.shop_discount || "0.00",
|
|
3907
3961
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
3908
3962
|
}
|
|
3909
3963
|
};
|
|
@@ -4069,6 +4123,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
4069
4123
|
product.booking_uid = linkedBookingUid;
|
|
4070
4124
|
product.metadata.booking_uid = linkedBookingUid;
|
|
4071
4125
|
});
|
|
4126
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
4072
4127
|
}
|
|
4073
4128
|
pickHydratedDisplayText(value) {
|
|
4074
4129
|
if (value === void 0 || value === null)
|
|
@@ -9,16 +9,19 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
11
|
private surchargeListModuleName;
|
|
12
|
+
private otherParams;
|
|
13
|
+
private surchargeListChannel;
|
|
12
14
|
constructor(name?: string, version?: string);
|
|
13
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
14
16
|
/**
|
|
15
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
17
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
|
-
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
20
|
+
* await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
|
|
19
21
|
*/
|
|
20
22
|
updateOtherParams(params: Record<string, any>): Promise<void>;
|
|
21
|
-
|
|
23
|
+
private resolveChannel;
|
|
24
|
+
getSurchargeList(channel?: string): Promise<void>;
|
|
22
25
|
private getAppData;
|
|
23
26
|
private getTaxConfig;
|
|
24
27
|
getSummary(params: {
|
|
@@ -26,6 +29,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
26
29
|
isPriceIncludeTax?: number;
|
|
27
30
|
taxRate?: number;
|
|
28
31
|
shopDiscount?: string | number;
|
|
32
|
+
channel?: string;
|
|
29
33
|
}): Promise<{
|
|
30
34
|
tax_title: string;
|
|
31
35
|
tax_rate: number | undefined;
|
|
@@ -33,12 +33,15 @@ var salesSummaryDataKeys = {
|
|
|
33
33
|
taxTitle: "tax_title",
|
|
34
34
|
taxCountryCode: "tax_country_code"
|
|
35
35
|
};
|
|
36
|
+
var DEFAULT_SURCHARGE_CHANNEL = "online-store";
|
|
36
37
|
var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
37
38
|
constructor(name, version) {
|
|
38
39
|
super(name, version);
|
|
39
40
|
this.defaultName = "salesSummary";
|
|
40
41
|
this.defaultVersion = "1.0.0";
|
|
41
42
|
this.surchargeListModuleName = "surchargeList";
|
|
43
|
+
this.otherParams = {};
|
|
44
|
+
this.surchargeListChannel = DEFAULT_SURCHARGE_CHANNEL;
|
|
42
45
|
}
|
|
43
46
|
async initialize(core, options) {
|
|
44
47
|
var _a, _b, _c;
|
|
@@ -46,9 +49,10 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
46
49
|
this.store = options.store;
|
|
47
50
|
this.appPlugin = this.core.getPlugin("app");
|
|
48
51
|
this.request = this.core.getPlugin("request");
|
|
52
|
+
this.otherParams = options.otherParams || {};
|
|
49
53
|
this.store.surchargeList = ((_a = options.initialState) == null ? void 0 : _a.surchargeList) || [];
|
|
50
54
|
this.store.summary = ((_b = options.initialState) == null ? void 0 : _b.summary) || (0, import_utils.createEmptySalesSummary)();
|
|
51
|
-
this.surchargeListModuleName = ((_c =
|
|
55
|
+
this.surchargeListModuleName = ((_c = this.otherParams) == null ? void 0 : _c.surchargeListModuleName) || "surchargeList";
|
|
52
56
|
if (!this.appPlugin) {
|
|
53
57
|
throw new Error("SalesSummaryModule 需要 app 插件支持");
|
|
54
58
|
}
|
|
@@ -58,41 +62,50 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
58
62
|
await this.getSurchargeList();
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
61
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
65
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
|
|
62
66
|
*
|
|
63
67
|
* @example
|
|
64
|
-
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
68
|
+
* await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
|
|
65
69
|
*/
|
|
66
70
|
async updateOtherParams(params) {
|
|
71
|
+
const previousChannel = this.resolveChannel();
|
|
67
72
|
const nextSurchargeListModuleName = (params == null ? void 0 : params.surchargeListModuleName) || "surchargeList";
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
const nextChannel = this.resolveChannel(params);
|
|
74
|
+
const shouldReload = nextSurchargeListModuleName !== this.surchargeListModuleName || nextChannel !== previousChannel;
|
|
75
|
+
this.otherParams = params || {};
|
|
70
76
|
this.surchargeListModuleName = nextSurchargeListModuleName;
|
|
71
|
-
|
|
77
|
+
if (shouldReload) {
|
|
78
|
+
await this.getSurchargeList(nextChannel);
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
|
-
|
|
81
|
+
resolveChannel(params = this.otherParams) {
|
|
82
|
+
return (params == null ? void 0 : params.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
83
|
+
}
|
|
84
|
+
async getSurchargeList(channel = this.resolveChannel()) {
|
|
74
85
|
try {
|
|
75
86
|
const surchargeListModule = this.core.getModule(
|
|
76
87
|
this.surchargeListModuleName
|
|
77
88
|
);
|
|
78
89
|
if (surchargeListModule == null ? void 0 : surchargeListModule.getSurchargeList) {
|
|
79
|
-
this.store.surchargeList = await surchargeListModule.getSurchargeList();
|
|
90
|
+
this.store.surchargeList = await surchargeListModule.getSurchargeList({ channel });
|
|
91
|
+
this.surchargeListChannel = channel;
|
|
80
92
|
return;
|
|
81
93
|
}
|
|
82
94
|
const surchargeList = await this.request.get(
|
|
83
95
|
"/order/custom-surcharge/available/v2",
|
|
84
96
|
{
|
|
85
|
-
|
|
86
|
-
channel: "online-store",
|
|
97
|
+
channel,
|
|
87
98
|
is_assemble_product_data: 1,
|
|
88
99
|
is_assemble_schedule_data: 1,
|
|
89
100
|
with: ["relationSchedule"]
|
|
90
101
|
}
|
|
91
102
|
);
|
|
92
103
|
this.store.surchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
104
|
+
this.surchargeListChannel = channel;
|
|
93
105
|
} catch (error) {
|
|
94
106
|
console.warn("[SalesSummaryModule] 加载附加费配置失败", error);
|
|
95
107
|
this.store.surchargeList = [];
|
|
108
|
+
this.surchargeListChannel = channel;
|
|
96
109
|
}
|
|
97
110
|
}
|
|
98
111
|
getAppData(key) {
|
|
@@ -114,7 +127,11 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
114
127
|
}
|
|
115
128
|
async getSummary(params) {
|
|
116
129
|
var _a, _b;
|
|
117
|
-
const { products = [], isPriceIncludeTax, taxRate, shopDiscount } = params;
|
|
130
|
+
const { products = [], isPriceIncludeTax, taxRate, shopDiscount, channel } = params;
|
|
131
|
+
const summaryChannel = channel || this.resolveChannel();
|
|
132
|
+
if (summaryChannel !== this.surchargeListChannel) {
|
|
133
|
+
await this.getSurchargeList(summaryChannel);
|
|
134
|
+
}
|
|
118
135
|
const taxConfig = this.getTaxConfig();
|
|
119
136
|
const summarySchedule = this.core.getModule(
|
|
120
137
|
`${this.name.split("_")[0]}_schedule`
|
|
@@ -308,6 +308,8 @@ function getFallbackAllProductSurchargeIds(surchargeList) {
|
|
|
308
308
|
return ids;
|
|
309
309
|
if (Number(config.is_all ?? 0) !== 1)
|
|
310
310
|
return ids;
|
|
311
|
+
if (Number(config.open_schedule ?? 0) === 1 && config.schedule_type !== "all")
|
|
312
|
+
return ids;
|
|
311
313
|
ids.push(id);
|
|
312
314
|
return ids;
|
|
313
315
|
}, []);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { SurchargeListItem, SurchargeListModuleAPI } from './types';
|
|
3
|
+
import { SurchargeListItem, SurchargeListModuleAPI, SurchargeListQuery } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private request;
|
|
9
9
|
private store;
|
|
10
|
-
private
|
|
10
|
+
private loadingPromises;
|
|
11
|
+
private requestVersion;
|
|
11
12
|
constructor(name?: string, version?: string);
|
|
12
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
private resolveChannel;
|
|
15
|
+
getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
16
|
+
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
15
17
|
private loadSurchargeList;
|
|
16
18
|
}
|
|
@@ -25,15 +25,17 @@ __export(SurchargeList_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(SurchargeList_exports);
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
27
|
__reExport(SurchargeList_exports, require("./types"), module.exports);
|
|
28
|
+
var DEFAULT_SURCHARGE_CHANNEL = "online-store";
|
|
28
29
|
var SurchargeListModule = class extends import_BaseModule.BaseModule {
|
|
29
30
|
constructor(name, version) {
|
|
30
31
|
super(name, version);
|
|
31
32
|
this.defaultName = "surchargeList";
|
|
32
33
|
this.defaultVersion = "1.0.0";
|
|
33
|
-
this.
|
|
34
|
+
this.loadingPromises = /* @__PURE__ */ new Map();
|
|
35
|
+
this.requestVersion = 0;
|
|
34
36
|
}
|
|
35
37
|
async initialize(core, options) {
|
|
36
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d, _e;
|
|
37
39
|
this.core = core;
|
|
38
40
|
this.store = options.store;
|
|
39
41
|
this.request = this.core.getPlugin("request");
|
|
@@ -41,44 +43,62 @@ var SurchargeListModule = class extends import_BaseModule.BaseModule {
|
|
|
41
43
|
(_a = options.initialState) == null ? void 0 : _a.surchargeList
|
|
42
44
|
);
|
|
43
45
|
this.store.surchargeList = hasInitialSurchargeList ? (_b = options.initialState) == null ? void 0 : _b.surchargeList : [];
|
|
44
|
-
this.store.
|
|
46
|
+
this.store.channel = ((_c = options.initialState) == null ? void 0 : _c.channel) || ((_d = options.otherParams) == null ? void 0 : _d.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
47
|
+
this.store.isLoaded = Boolean((_e = options.initialState) == null ? void 0 : _e.isLoaded) || hasInitialSurchargeList;
|
|
45
48
|
if (!this.request) {
|
|
46
49
|
throw new Error("SurchargeListModule 需要 request 插件支持");
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
resolveChannel(query) {
|
|
53
|
+
return (query == null ? void 0 : query.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
54
|
+
}
|
|
55
|
+
async getSurchargeList(query) {
|
|
56
|
+
const channel = this.resolveChannel(query);
|
|
57
|
+
if (this.store.isLoaded && this.store.channel === channel) {
|
|
51
58
|
return this.store.surchargeList;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
}
|
|
60
|
+
const loadingPromise = this.loadingPromises.get(channel);
|
|
61
|
+
if (loadingPromise)
|
|
62
|
+
return loadingPromise;
|
|
63
|
+
const nextPromise = this.loadSurchargeList(channel);
|
|
64
|
+
this.loadingPromises.set(channel, nextPromise);
|
|
65
|
+
return nextPromise;
|
|
56
66
|
}
|
|
57
|
-
async refreshSurchargeList() {
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
async refreshSurchargeList(query) {
|
|
68
|
+
const channel = this.resolveChannel(query);
|
|
69
|
+
const nextPromise = this.loadSurchargeList(channel);
|
|
70
|
+
this.loadingPromises.set(channel, nextPromise);
|
|
71
|
+
return nextPromise;
|
|
60
72
|
}
|
|
61
|
-
async loadSurchargeList() {
|
|
73
|
+
async loadSurchargeList(channel) {
|
|
74
|
+
const currentRequestVersion = ++this.requestVersion;
|
|
62
75
|
try {
|
|
63
76
|
const surchargeList = await this.request.get(
|
|
64
77
|
"/order/custom-surcharge/available/v2",
|
|
65
78
|
{
|
|
66
|
-
channel
|
|
79
|
+
channel,
|
|
67
80
|
is_assemble_product_data: 1,
|
|
68
81
|
is_assemble_schedule_data: 1,
|
|
69
82
|
with: ["relationSchedule"]
|
|
70
83
|
}
|
|
71
84
|
);
|
|
72
|
-
|
|
73
|
-
this.
|
|
74
|
-
|
|
85
|
+
const nextSurchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
86
|
+
if (currentRequestVersion === this.requestVersion) {
|
|
87
|
+
this.store.surchargeList = nextSurchargeList;
|
|
88
|
+
this.store.channel = channel;
|
|
89
|
+
this.store.isLoaded = true;
|
|
90
|
+
}
|
|
91
|
+
return nextSurchargeList;
|
|
75
92
|
} catch (error) {
|
|
76
93
|
console.warn("[SurchargeListModule] 加载附加费配置失败", error);
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
if (currentRequestVersion === this.requestVersion) {
|
|
95
|
+
this.store.surchargeList = [];
|
|
96
|
+
this.store.channel = channel;
|
|
97
|
+
this.store.isLoaded = true;
|
|
98
|
+
}
|
|
99
|
+
return [];
|
|
80
100
|
} finally {
|
|
81
|
-
this.
|
|
101
|
+
this.loadingPromises.delete(channel);
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
104
|
};
|
|
@@ -4,8 +4,12 @@ export interface SurchargeListItem {
|
|
|
4
4
|
export interface SurchargeListState {
|
|
5
5
|
surchargeList: SurchargeListItem[];
|
|
6
6
|
isLoaded: boolean;
|
|
7
|
+
channel?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SurchargeListQuery {
|
|
10
|
+
channel?: string;
|
|
7
11
|
}
|
|
8
12
|
export interface SurchargeListModuleAPI {
|
|
9
|
-
getSurchargeList(): Promise<SurchargeListItem[]>;
|
|
10
|
-
refreshSurchargeList(): Promise<SurchargeListItem[]>;
|
|
13
|
+
getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
14
|
+
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
11
15
|
}
|
package/lib/server/index.d.ts
CHANGED
|
@@ -431,9 +431,9 @@ declare class Server {
|
|
|
431
431
|
private shouldLookupLocalPrintOrder;
|
|
432
432
|
private getLocalPrintOrderLookup;
|
|
433
433
|
private handleLocalPrintOrder;
|
|
434
|
-
private
|
|
434
|
+
private handleMachinecodeBatchMeta;
|
|
435
435
|
private resolveMachinecodeBatchMetadataLookup;
|
|
436
|
-
private
|
|
436
|
+
private syncMachinecodeRedeemStatusToLocalOrder;
|
|
437
437
|
private handleOrderCheckoutSubmit;
|
|
438
438
|
private handleSyncCheckoutSubmit;
|
|
439
439
|
private handlePendingSyncCheckoutOrder;
|