@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
package/lib/server/index.js
CHANGED
|
@@ -662,17 +662,19 @@ var Server = class {
|
|
|
662
662
|
};
|
|
663
663
|
}
|
|
664
664
|
};
|
|
665
|
-
this.
|
|
665
|
+
this.handleMachinecodeBatchMeta = async ({ data }) => {
|
|
666
666
|
var _a, _b;
|
|
667
|
-
const title = "
|
|
668
|
-
const backendPath = "/shop/machinecode/batch
|
|
669
|
-
const
|
|
667
|
+
const title = "handleMachinecodeBatchMeta";
|
|
668
|
+
const backendPath = "/shop/machinecode/batch";
|
|
669
|
+
const ids = Array.isArray(data == null ? void 0 : data.ids) ? data.ids : [];
|
|
670
|
+
const status = data == null ? void 0 : data.status;
|
|
670
671
|
this.logInfo(`${title}: 开始处理`, {
|
|
671
672
|
backendPath,
|
|
672
|
-
batchSize:
|
|
673
|
+
batchSize: ids.length,
|
|
674
|
+
status,
|
|
673
675
|
order_lookup: this.resolveMachinecodeBatchMetadataLookup(data) ?? null
|
|
674
676
|
});
|
|
675
|
-
if (
|
|
677
|
+
if (ids.length === 0) {
|
|
676
678
|
return {
|
|
677
679
|
code: 200,
|
|
678
680
|
status: true,
|
|
@@ -680,11 +682,19 @@ var Server = class {
|
|
|
680
682
|
data: []
|
|
681
683
|
};
|
|
682
684
|
}
|
|
685
|
+
if (status !== "used" && status !== "unused") {
|
|
686
|
+
return {
|
|
687
|
+
code: 400,
|
|
688
|
+
status: false,
|
|
689
|
+
message: "无效的核销状态",
|
|
690
|
+
data: null
|
|
691
|
+
};
|
|
692
|
+
}
|
|
683
693
|
try {
|
|
684
|
-
await this.
|
|
694
|
+
await this.syncMachinecodeRedeemStatusToLocalOrder(data, ids, status);
|
|
685
695
|
} catch (error) {
|
|
686
696
|
const message = this.getUnknownErrorMessage(error);
|
|
687
|
-
this.logError(`${title}:
|
|
697
|
+
this.logError(`${title}: 本地订单核销状态更新失败`, {
|
|
688
698
|
error: message,
|
|
689
699
|
error_detail: this.normalizeUnknownError(error)
|
|
690
700
|
});
|
|
@@ -706,7 +716,8 @@ var Server = class {
|
|
|
706
716
|
}
|
|
707
717
|
try {
|
|
708
718
|
const response = await this.app.request.post(backendPath, {
|
|
709
|
-
|
|
719
|
+
ids,
|
|
720
|
+
status
|
|
710
721
|
}, {
|
|
711
722
|
isShopApi: true,
|
|
712
723
|
customToast: () => {
|
|
@@ -1827,13 +1838,13 @@ var Server = class {
|
|
|
1827
1838
|
},
|
|
1828
1839
|
{
|
|
1829
1840
|
method: "post",
|
|
1830
|
-
path: "/shop/machinecode/batch
|
|
1831
|
-
handler: this.
|
|
1841
|
+
path: "/shop/machinecode/batch",
|
|
1842
|
+
handler: this.handleMachinecodeBatchMeta.bind(this)
|
|
1832
1843
|
},
|
|
1833
1844
|
{
|
|
1834
1845
|
method: "post",
|
|
1835
|
-
path: "/machinecode/batch
|
|
1836
|
-
handler: this.
|
|
1846
|
+
path: "/machinecode/batch",
|
|
1847
|
+
handler: this.handleMachinecodeBatchMeta.bind(this)
|
|
1837
1848
|
}
|
|
1838
1849
|
]);
|
|
1839
1850
|
this.registerPrefixRoutes([
|
|
@@ -2839,39 +2850,39 @@ var Server = class {
|
|
|
2839
2850
|
];
|
|
2840
2851
|
return candidates.find((candidate) => candidate !== void 0 && candidate !== null && candidate !== "");
|
|
2841
2852
|
}
|
|
2842
|
-
async
|
|
2853
|
+
async syncMachinecodeRedeemStatusToLocalOrder(data, ids, status) {
|
|
2843
2854
|
var _a;
|
|
2844
2855
|
const title = "handleMachinecodeBatchMetadata";
|
|
2845
2856
|
const lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
2846
2857
|
if (lookup === void 0) {
|
|
2847
|
-
this.logWarning(`${title}: order lookup
|
|
2848
|
-
batchSize:
|
|
2858
|
+
this.logWarning(`${title}: order lookup 缺失,跳过本地订单核销状态更新`, {
|
|
2859
|
+
batchSize: ids.length,
|
|
2860
|
+
status
|
|
2849
2861
|
});
|
|
2850
2862
|
return;
|
|
2851
2863
|
}
|
|
2852
2864
|
if (!((_a = this.order) == null ? void 0 : _a.getLocalOrderByLookup)) {
|
|
2853
|
-
this.logWarning(`${title}: Order
|
|
2854
|
-
lookup
|
|
2865
|
+
this.logWarning(`${title}: Order 模块未注册,跳过本地订单核销状态更新`, {
|
|
2866
|
+
lookup,
|
|
2867
|
+
status
|
|
2855
2868
|
});
|
|
2856
2869
|
return;
|
|
2857
2870
|
}
|
|
2858
2871
|
const localOrder = await this.order.getLocalOrderByLookup(lookup);
|
|
2859
2872
|
if (!localOrder) {
|
|
2860
|
-
this.logWarning(`${title}:
|
|
2861
|
-
lookup
|
|
2873
|
+
this.logWarning(`${title}: 本地订单不存在,跳过核销状态更新`, {
|
|
2874
|
+
lookup,
|
|
2875
|
+
status
|
|
2862
2876
|
});
|
|
2863
2877
|
return;
|
|
2864
2878
|
}
|
|
2865
|
-
const
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
if (metadataByVoucherId.size === 0) {
|
|
2873
|
-
this.logWarning(`${title}: voucher metadata 缺失,跳过本地订单 metadata 更新`, {
|
|
2874
|
-
lookup
|
|
2879
|
+
const voucherIdSet = new Set(
|
|
2880
|
+
ids.filter((id) => id !== void 0 && id !== null && id !== "").map((id) => String(id))
|
|
2881
|
+
);
|
|
2882
|
+
if (voucherIdSet.size === 0) {
|
|
2883
|
+
this.logWarning(`${title}: voucher ids 缺失,跳过本地订单核销状态更新`, {
|
|
2884
|
+
lookup,
|
|
2885
|
+
status
|
|
2875
2886
|
});
|
|
2876
2887
|
return;
|
|
2877
2888
|
}
|
|
@@ -2881,19 +2892,19 @@ var Server = class {
|
|
|
2881
2892
|
const voucherId = voucher == null ? void 0 : voucher.voucher_id;
|
|
2882
2893
|
if (voucherId === void 0 || voucherId === null)
|
|
2883
2894
|
return voucher;
|
|
2884
|
-
|
|
2885
|
-
if (!metadata)
|
|
2895
|
+
if (!voucherIdSet.has(String(voucherId)))
|
|
2886
2896
|
return voucher;
|
|
2887
2897
|
hasUpdatedVoucher = true;
|
|
2888
2898
|
return {
|
|
2889
2899
|
...voucher,
|
|
2890
|
-
|
|
2900
|
+
status
|
|
2891
2901
|
};
|
|
2892
2902
|
});
|
|
2893
2903
|
if (!hasUpdatedVoucher) {
|
|
2894
|
-
this.logWarning(`${title}: 本地订单未命中任何 voucher
|
|
2904
|
+
this.logWarning(`${title}: 本地订单未命中任何 voucher,跳过核销状态更新`, {
|
|
2895
2905
|
lookup,
|
|
2896
|
-
voucher_ids: Array.from(
|
|
2906
|
+
voucher_ids: Array.from(voucherIdSet),
|
|
2907
|
+
status
|
|
2897
2908
|
});
|
|
2898
2909
|
return;
|
|
2899
2910
|
}
|
|
@@ -2902,9 +2913,10 @@ var Server = class {
|
|
|
2902
2913
|
...localOrder,
|
|
2903
2914
|
vouchers: nextVouchers
|
|
2904
2915
|
});
|
|
2905
|
-
this.logInfo(`${title}: 本地订单 vouchers
|
|
2916
|
+
this.logInfo(`${title}: 本地订单 vouchers 核销状态已更新`, {
|
|
2906
2917
|
lookup,
|
|
2907
|
-
updatedCount:
|
|
2918
|
+
updatedCount: voucherIdSet.size,
|
|
2919
|
+
status
|
|
2908
2920
|
});
|
|
2909
2921
|
return;
|
|
2910
2922
|
}
|
|
@@ -2913,14 +2925,16 @@ var Server = class {
|
|
|
2913
2925
|
externalSaleNumber: data.external_sale_number,
|
|
2914
2926
|
patch: { vouchers: nextVouchers }
|
|
2915
2927
|
});
|
|
2916
|
-
this.logInfo(`${title}: 本地订单 vouchers
|
|
2928
|
+
this.logInfo(`${title}: 本地订单 vouchers 核销状态已更新`, {
|
|
2917
2929
|
lookup,
|
|
2918
|
-
updatedCount:
|
|
2930
|
+
updatedCount: voucherIdSet.size,
|
|
2931
|
+
status
|
|
2919
2932
|
});
|
|
2920
2933
|
return;
|
|
2921
2934
|
}
|
|
2922
|
-
this.logWarning(`${title}: Order
|
|
2923
|
-
lookup
|
|
2935
|
+
this.logWarning(`${title}: Order 模块不支持本地订单覆盖,跳过核销状态更新`, {
|
|
2936
|
+
lookup,
|
|
2937
|
+
status
|
|
2924
2938
|
});
|
|
2925
2939
|
}
|
|
2926
2940
|
async handleOrderCheckoutSubmit(params) {
|
|
@@ -308,12 +308,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
310
|
updateCreateStore() {
|
|
311
|
-
var _a;
|
|
312
311
|
const appPlugin = this.core.getPlugin("app");
|
|
313
312
|
const app = appPlugin == null ? void 0 : appPlugin.getApp();
|
|
314
313
|
if (app) {
|
|
315
314
|
const coreData = app.data.store.getStore().getDataByModel("core");
|
|
316
|
-
if (
|
|
315
|
+
if (coreData == null ? void 0 : coreData.core) {
|
|
317
316
|
const today = (0, import_dayjs.default)();
|
|
318
317
|
if (coreData == null ? void 0 : coreData.core.operating_day_boundary) {
|
|
319
318
|
const operatingDayBoundary = coreData.core.operating_day_boundary;
|
|
@@ -49,6 +49,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
49
49
|
private queuedAutoPaymentSync;
|
|
50
50
|
private autoPaymentSyncFlushing;
|
|
51
51
|
private autoPaymentSyncTimer;
|
|
52
|
+
private salesDetailLoadInFlight;
|
|
53
|
+
private serverOrderChangeUnsubscribe;
|
|
54
|
+
private serverOrderChangeHydrateInFlight;
|
|
52
55
|
constructor(name?: string, version?: string);
|
|
53
56
|
/**
|
|
54
57
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -69,6 +72,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
69
72
|
* 记录错误日志
|
|
70
73
|
*/
|
|
71
74
|
private logError;
|
|
75
|
+
private isCurrentSalesOrderRecord;
|
|
76
|
+
private syncCurrentSalesDetailFromServerOrderChange;
|
|
77
|
+
private registerServerOrderChangeSync;
|
|
72
78
|
private hydrateOrderPaymentNames;
|
|
73
79
|
get payment(): PaymentModule | undefined;
|
|
74
80
|
private getCurrentOrderCustomerId;
|
|
@@ -45,6 +45,7 @@ __reExport(BaseSales_exports, require("./types"), module.exports);
|
|
|
45
45
|
var import_Quotation = require("../../modules/Quotation");
|
|
46
46
|
var import_transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
|
|
47
47
|
var import_quotationPrice = require("./utils/quotationPrice");
|
|
48
|
+
var SERVER_ORDER_CHANGED_EVENT = "order:onOrdersChanged";
|
|
48
49
|
function isBaseSalesManualProductDiscountProduct(product) {
|
|
49
50
|
var _a, _b;
|
|
50
51
|
return ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_manual_discount) === true || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.is_manual_discount) === 1 || ((product == null ? void 0 : product.discount_list) || []).some((item) => (item == null ? void 0 : item.type) === "product");
|
|
@@ -82,6 +83,18 @@ function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
|
82
83
|
return "unique_payment_number";
|
|
83
84
|
return null;
|
|
84
85
|
}
|
|
86
|
+
function isSameBaseSalesOrderRecord(left, right) {
|
|
87
|
+
if (!left || !right || typeof left !== "object" || typeof right !== "object")
|
|
88
|
+
return false;
|
|
89
|
+
const leftIdentities = new Set(
|
|
90
|
+
[left.order_id, left.id, left.external_sale_number, left.order_number].filter((value) => value !== void 0 && value !== null && value !== "").map(String)
|
|
91
|
+
);
|
|
92
|
+
if (leftIdentities.size === 0)
|
|
93
|
+
return false;
|
|
94
|
+
return [right.order_id, right.id, right.external_sale_number, right.order_number].some(
|
|
95
|
+
(value) => value !== void 0 && value !== null && value !== "" && leftIdentities.has(String(value))
|
|
96
|
+
);
|
|
97
|
+
}
|
|
85
98
|
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
86
99
|
var _a;
|
|
87
100
|
const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a[metadataKey]) ?? (item == null ? void 0 : item[metadataKey]);
|
|
@@ -159,6 +172,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
159
172
|
this.queuedAutoPaymentSync = false;
|
|
160
173
|
this.autoPaymentSyncFlushing = false;
|
|
161
174
|
this.autoPaymentSyncTimer = null;
|
|
175
|
+
this.salesDetailLoadInFlight = false;
|
|
176
|
+
this.serverOrderChangeUnsubscribe = null;
|
|
177
|
+
this.serverOrderChangeHydrateInFlight = null;
|
|
162
178
|
}
|
|
163
179
|
/**
|
|
164
180
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -223,6 +239,53 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
223
239
|
});
|
|
224
240
|
}
|
|
225
241
|
}
|
|
242
|
+
isCurrentSalesOrderRecord(order) {
|
|
243
|
+
var _a, _b;
|
|
244
|
+
const currentTempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
245
|
+
const currentRecords = [
|
|
246
|
+
currentTempOrder,
|
|
247
|
+
this.currentSalesDetail
|
|
248
|
+
].filter(Boolean);
|
|
249
|
+
return currentRecords.some((record) => isSameBaseSalesOrderRecord(record, order));
|
|
250
|
+
}
|
|
251
|
+
async syncCurrentSalesDetailFromServerOrderChange(payload) {
|
|
252
|
+
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] : [];
|
|
253
|
+
if (this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)
|
|
254
|
+
return;
|
|
255
|
+
const changedOrder = changedOrders.find(
|
|
256
|
+
(order) => this.isCurrentSalesOrderRecord(order)
|
|
257
|
+
);
|
|
258
|
+
if (!changedOrder)
|
|
259
|
+
return;
|
|
260
|
+
if (!this.store.order)
|
|
261
|
+
return;
|
|
262
|
+
this.serverOrderChangeHydrateInFlight = (async () => {
|
|
263
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(changedOrder, {
|
|
264
|
+
recalcOnHydrate: false
|
|
265
|
+
});
|
|
266
|
+
this.currentSalesDetail = sales;
|
|
267
|
+
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
268
|
+
})();
|
|
269
|
+
try {
|
|
270
|
+
await this.serverOrderChangeHydrateInFlight;
|
|
271
|
+
} finally {
|
|
272
|
+
this.serverOrderChangeHydrateInFlight = null;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
registerServerOrderChangeSync() {
|
|
276
|
+
var _a, _b;
|
|
277
|
+
(_a = this.serverOrderChangeUnsubscribe) == null ? void 0 : _a.call(this);
|
|
278
|
+
const effects = (_b = this.core) == null ? void 0 : _b.effects;
|
|
279
|
+
if (!effects || typeof effects.on !== "function")
|
|
280
|
+
return;
|
|
281
|
+
this.serverOrderChangeUnsubscribe = effects.on(SERVER_ORDER_CHANGED_EVENT, (payload) => {
|
|
282
|
+
void this.syncCurrentSalesDetailFromServerOrderChange(payload).catch((error) => {
|
|
283
|
+
this.logError("sync sales detail from server order change failed", {
|
|
284
|
+
error: error instanceof Error ? error.message : String(error)
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
226
289
|
hydrateOrderPaymentNames(payments) {
|
|
227
290
|
if (!payments.length)
|
|
228
291
|
return [];
|
|
@@ -637,9 +700,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
637
700
|
);
|
|
638
701
|
}
|
|
639
702
|
await this.getPaymentMethodsAsync();
|
|
703
|
+
this.registerServerOrderChangeSync();
|
|
640
704
|
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
641
705
|
}
|
|
642
706
|
async destroy() {
|
|
707
|
+
var _a;
|
|
708
|
+
(_a = this.serverOrderChangeUnsubscribe) == null ? void 0 : _a.call(this);
|
|
709
|
+
this.serverOrderChangeUnsubscribe = null;
|
|
643
710
|
Object.keys(this.store).forEach((key) => {
|
|
644
711
|
if (this.reusedSharedSubModuleNames.has(key))
|
|
645
712
|
return;
|
|
@@ -666,30 +733,35 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
666
733
|
async loadSalesDetail(orderIdOrParams) {
|
|
667
734
|
if (!this.store.order)
|
|
668
735
|
throw new Error("order 模块未初始化");
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
736
|
+
this.salesDetailLoadInFlight = true;
|
|
737
|
+
try {
|
|
738
|
+
const params = typeof orderIdOrParams === "object" ? orderIdOrParams : { orderId: orderIdOrParams };
|
|
739
|
+
const externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
740
|
+
const preloadedSalesDetail = params.preloadedSalesDetail;
|
|
741
|
+
const lookup = params.orderId ?? externalSaleNumber ?? params.orderNumber ?? (preloadedSalesDetail == null ? void 0 : preloadedSalesDetail.order_id) ?? (preloadedSalesDetail == null ? void 0 : preloadedSalesDetail.external_sale_number) ?? (preloadedSalesDetail == null ? void 0 : preloadedSalesDetail.order_number);
|
|
742
|
+
if (!preloadedSalesDetail && (lookup === void 0 || lookup === null || lookup === "")) {
|
|
743
|
+
throw new Error("加载销售详情需要 orderId、externalSaleNumber 或 orderNumber");
|
|
744
|
+
}
|
|
745
|
+
const loadedRecord = preloadedSalesDetail ?? await this.store.order.getSalesOrderByLookup({
|
|
746
|
+
lookup,
|
|
747
|
+
forceRemote: params.forceRemote
|
|
748
|
+
});
|
|
749
|
+
if (!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200)) {
|
|
750
|
+
const message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || `加载销售详情失败: ${lookup}`;
|
|
751
|
+
throw new Error(message);
|
|
752
|
+
}
|
|
753
|
+
const remoteRecord = preloadedSalesDetail ?? loadedRecord.data;
|
|
754
|
+
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
755
|
+
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
|
|
756
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(record, {
|
|
757
|
+
recalcOnHydrate: false
|
|
758
|
+
});
|
|
759
|
+
this.currentSalesDetail = sales;
|
|
760
|
+
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
761
|
+
return sales;
|
|
762
|
+
} finally {
|
|
763
|
+
this.salesDetailLoadInFlight = false;
|
|
764
|
+
}
|
|
693
765
|
}
|
|
694
766
|
/** 获取当前已加载的销售详情(只读快照)。未加载过则返回 null。 */
|
|
695
767
|
getSalesOrder() {
|
|
@@ -1696,15 +1768,17 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1696
1768
|
return this.store.order.discardPendingVoucherPayments();
|
|
1697
1769
|
}
|
|
1698
1770
|
getWalletProductList() {
|
|
1699
|
-
var _a, _b
|
|
1771
|
+
var _a, _b;
|
|
1700
1772
|
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
1701
1773
|
if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
|
|
1702
1774
|
return [];
|
|
1703
|
-
const
|
|
1704
|
-
const walletProducts = products.map((product) => {
|
|
1775
|
+
const walletProducts = tempOrder == null ? void 0 : tempOrder.products.map((product) => {
|
|
1705
1776
|
const metadata = product.metadata || {};
|
|
1777
|
+
const rawHolderId = product.holder_id ?? metadata.holder_id;
|
|
1778
|
+
const holderIdValue = Array.isArray(rawHolderId) ? rawHolderId[0] : rawHolderId;
|
|
1779
|
+
const holder_id = Number.isInteger(Number(holderIdValue)) ? Number(holderIdValue) : void 0;
|
|
1706
1780
|
return {
|
|
1707
|
-
product_id: product.product_id,
|
|
1781
|
+
product_id: product.product_id || 0,
|
|
1708
1782
|
product_variant_id: String(product.product_variant_id ?? ""),
|
|
1709
1783
|
quantity: product.num || 1,
|
|
1710
1784
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
@@ -1712,7 +1786,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1712
1786
|
tax_fee: product.tax_fee,
|
|
1713
1787
|
selling_price: Number(product.selling_price || 0),
|
|
1714
1788
|
discount_list: product.discount_list || [],
|
|
1715
|
-
holder_id
|
|
1789
|
+
holder_id,
|
|
1716
1790
|
original_price: product.original_price,
|
|
1717
1791
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
1718
1792
|
main_product_selling_price: metadata.main_product_selling_price ?? product.selling_price,
|
|
@@ -88,7 +88,8 @@ function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
|
88
88
|
price: bundleItem.price ?? unitStr,
|
|
89
89
|
bundle_selling_price: unitStr,
|
|
90
90
|
original_price: bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? unitStr,
|
|
91
|
-
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option)
|
|
91
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option),
|
|
92
|
+
discount_list: preferPriceField ? [] : bundleItem.discount_list
|
|
92
93
|
};
|
|
93
94
|
normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
|
|
94
95
|
if ((normalizedItem.price_type ?? normalizedItem.custom_price_type) === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
|
|
@@ -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>;
|
|
@@ -1551,42 +1551,30 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1551
1551
|
source_id: idempotencyKey
|
|
1552
1552
|
});
|
|
1553
1553
|
}
|
|
1554
|
-
//
|
|
1555
|
-
async
|
|
1554
|
+
// 触发核销
|
|
1555
|
+
async handleRedeem(params) {
|
|
1556
1556
|
var _a, _b, _c;
|
|
1557
|
+
const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
1558
|
+
const status = params.is_checkin ? "used" : "unused";
|
|
1557
1559
|
this.logger.addLog({
|
|
1558
1560
|
type: "info",
|
|
1559
|
-
title: "[BookingTicket]
|
|
1561
|
+
title: "[BookingTicket] handleRedeem",
|
|
1560
1562
|
metadata: {
|
|
1561
|
-
voucher_ids:
|
|
1562
|
-
|
|
1563
|
+
voucher_ids: voucherIds,
|
|
1564
|
+
status
|
|
1563
1565
|
}
|
|
1564
1566
|
});
|
|
1565
|
-
const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
1566
1567
|
const voucherIdSet = new Set(voucherIds);
|
|
1567
1568
|
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
1568
1569
|
const vouchers = (tempOrder == null ? void 0 : tempOrder.vouchers) || ((_c = this.store.order) == null ? void 0 : _c.getVouchers()) || [];
|
|
1569
|
-
const batchMetadata = [];
|
|
1570
1570
|
let hasUpdatedVoucher = false;
|
|
1571
1571
|
const nextVouchers = vouchers.map((voucher) => {
|
|
1572
|
-
var _a2;
|
|
1573
1572
|
if (!voucherIdSet.has(voucher.voucher_id))
|
|
1574
1573
|
return voucher;
|
|
1575
1574
|
hasUpdatedVoucher = true;
|
|
1576
|
-
const metadata = {
|
|
1577
|
-
...voucher.metadata || {},
|
|
1578
|
-
ticket: {
|
|
1579
|
-
...((_a2 = voucher.metadata) == null ? void 0 : _a2.ticket) || {},
|
|
1580
|
-
is_checkin: params.is_checkin
|
|
1581
|
-
}
|
|
1582
|
-
};
|
|
1583
|
-
batchMetadata.push({
|
|
1584
|
-
voucher_id: voucher.voucher_id,
|
|
1585
|
-
metadata
|
|
1586
|
-
});
|
|
1587
1575
|
return {
|
|
1588
1576
|
...voucher,
|
|
1589
|
-
|
|
1577
|
+
status
|
|
1590
1578
|
};
|
|
1591
1579
|
});
|
|
1592
1580
|
if (tempOrder && hasUpdatedVoucher) {
|
|
@@ -1596,7 +1584,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1596
1584
|
});
|
|
1597
1585
|
}
|
|
1598
1586
|
this.core.effects.emit(`${this.name}:onVouchersChange`, {});
|
|
1599
|
-
if (
|
|
1587
|
+
if (voucherIds.length === 0) {
|
|
1600
1588
|
return {
|
|
1601
1589
|
code: 200,
|
|
1602
1590
|
status: true,
|
|
@@ -1608,8 +1596,9 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1608
1596
|
const externalSaleNumber = (tempOrder == null ? void 0 : tempOrder.external_sale_number) || (identity == null ? void 0 : identity.externalSaleNumber) || void 0;
|
|
1609
1597
|
const orderId = (tempOrder == null ? void 0 : tempOrder.order_id) ?? (identity == null ? void 0 : identity.orderId) ?? void 0;
|
|
1610
1598
|
const orderLookup = externalSaleNumber || orderId || (identity == null ? void 0 : identity.orderNumber) || (identity == null ? void 0 : identity.shopOrderNumber) || (identity == null ? void 0 : identity.shopFullOrderNumber) || void 0;
|
|
1611
|
-
return this.request.post("/machinecode/batch
|
|
1612
|
-
|
|
1599
|
+
return this.request.post("/machinecode/batch", {
|
|
1600
|
+
ids: voucherIds,
|
|
1601
|
+
status,
|
|
1613
1602
|
order_lookup: orderLookup,
|
|
1614
1603
|
order_id: orderId,
|
|
1615
1604
|
external_sale_number: externalSaleNumber
|