@pisell/pisellos 2.2.260 → 2.2.261
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/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
- package/dist/modules/Order/index.d.ts +33 -2
- package/dist/modules/Order/index.js +615 -288
- package/dist/modules/Order/types.d.ts +20 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +116 -29
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +4 -3
- package/dist/modules/Rules/index.js +42 -17
- package/dist/modules/Rules/types.d.ts +2 -1
- 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 +3 -50
- package/dist/server/index.js +1075 -1040
- package/dist/server/modules/order/index.d.ts +22 -3
- package/dist/server/modules/order/index.js +398 -316
- package/dist/server/modules/products/index.d.ts +7 -26
- package/dist/server/modules/products/index.js +76 -166
- package/dist/server/modules/products/types.d.ts +0 -14
- package/dist/solution/BaseSales/index.d.ts +22 -2
- package/dist/solution/BaseSales/index.js +995 -701
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +74 -29
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +9 -1
- package/dist/solution/BookingTicket/index.js +153 -6
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.d.ts +33 -2
- package/lib/modules/Order/index.js +402 -64
- package/lib/modules/Order/types.d.ts +20 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +90 -3
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +4 -3
- package/lib/modules/Rules/index.js +27 -7
- package/lib/modules/Rules/types.d.ts +2 -1
- 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 +3 -50
- package/lib/server/index.js +244 -215
- package/lib/server/modules/order/index.d.ts +22 -3
- package/lib/server/modules/order/index.js +103 -53
- package/lib/server/modules/products/index.d.ts +7 -26
- package/lib/server/modules/products/index.js +35 -113
- package/lib/server/modules/products/types.d.ts +0 -14
- package/lib/solution/BaseSales/index.d.ts +22 -2
- package/lib/solution/BaseSales/index.js +246 -60
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +59 -16
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +9 -1
- package/lib/solution/BookingTicket/index.js +101 -0
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -152
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -755
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -282
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -146
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -139
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -564
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -295
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -146
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
|
@@ -30,7 +30,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
30
30
|
protected defaultVersion: string;
|
|
31
31
|
isSolution: boolean;
|
|
32
32
|
protected initializeOptions: ModuleOptions;
|
|
33
|
-
|
|
33
|
+
protected logger: any;
|
|
34
34
|
protected appPlugin: AppPlugin;
|
|
35
35
|
protected store: BaseSalesState;
|
|
36
36
|
protected otherParams: Record<string, any>;
|
|
@@ -46,6 +46,12 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
46
46
|
protected hasManualDiscountSelection: boolean;
|
|
47
47
|
private readonly reusedSharedSubModuleNames;
|
|
48
48
|
private paymentMethodsCache;
|
|
49
|
+
private queuedAutoPaymentSync;
|
|
50
|
+
private autoPaymentSyncFlushing;
|
|
51
|
+
private autoPaymentSyncTimer;
|
|
52
|
+
private salesDetailLoadInFlight;
|
|
53
|
+
private serverOrderChangeUnsubscribe;
|
|
54
|
+
private serverOrderChangeHydrateInFlight;
|
|
49
55
|
constructor(name?: string, version?: string);
|
|
50
56
|
/**
|
|
51
57
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -66,6 +72,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
66
72
|
* 记录错误日志
|
|
67
73
|
*/
|
|
68
74
|
private logError;
|
|
75
|
+
private isCurrentSalesOrderRecord;
|
|
76
|
+
private syncCurrentSalesDetailFromServerOrderChange;
|
|
77
|
+
private registerServerOrderChangeSync;
|
|
69
78
|
private hydrateOrderPaymentNames;
|
|
70
79
|
get payment(): PaymentModule | undefined;
|
|
71
80
|
private getCurrentOrderCustomerId;
|
|
@@ -195,6 +204,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
195
204
|
payments?: OrderPaymentSource[];
|
|
196
205
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
197
206
|
smallTicketDataFlag?: number;
|
|
207
|
+
confirmPendingVoucherPayments?: boolean;
|
|
198
208
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
199
209
|
}): Promise<T>;
|
|
200
210
|
/**
|
|
@@ -207,12 +217,14 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
207
217
|
payments?: OrderPaymentSource[];
|
|
208
218
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
209
219
|
smallTicketDataFlag?: number;
|
|
220
|
+
confirmPendingVoucherPayments?: boolean;
|
|
210
221
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
211
222
|
}): Promise<T>;
|
|
212
223
|
submitTempOrderAsync<T = any>(params?: {
|
|
213
224
|
payments?: OrderPaymentSource[];
|
|
214
225
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
215
226
|
smallTicketDataFlag?: number;
|
|
227
|
+
confirmPendingVoucherPayments?: boolean;
|
|
216
228
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
217
229
|
}): Promise<T>;
|
|
218
230
|
printLocalOrderReceipt<T = any>(lookup?: BaseSalesPrintLocalOrderReceiptParams): Promise<T>;
|
|
@@ -222,6 +234,10 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
222
234
|
getOrderPayments(): OrderPaymentData[];
|
|
223
235
|
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
224
236
|
setOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
|
|
237
|
+
private getPaymentStatusForSync;
|
|
238
|
+
private queueLatestAutoPaymentSync;
|
|
239
|
+
private scheduleQueuedAutoPaymentSyncFlush;
|
|
240
|
+
private flushQueuedAutoPaymentSync;
|
|
225
241
|
/** 追加单个支付项到当前订单。 */
|
|
226
242
|
addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
|
|
227
243
|
/** 更新当前订单中的指定支付项。 */
|
|
@@ -229,7 +245,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
229
245
|
/** 删除当前订单中的指定支付项。 */
|
|
230
246
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
231
247
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
232
|
-
updateVoucherOrderPayments(payments: OrderPaymentSource[]
|
|
248
|
+
updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
|
|
249
|
+
status?: 'paid' | 'payment_pending';
|
|
250
|
+
}): OrderPaymentData[];
|
|
251
|
+
confirmPendingVoucherPayments(): OrderPaymentData[];
|
|
252
|
+
discardPendingVoucherPayments(): OrderPaymentData[];
|
|
233
253
|
private getWalletProductList;
|
|
234
254
|
initWalletData(params?: {
|
|
235
255
|
order_wait_pay_amount?: number;
|
|
@@ -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]);
|
|
@@ -156,6 +169,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
156
169
|
this.hasManualDiscountSelection = false;
|
|
157
170
|
this.reusedSharedSubModuleNames = /* @__PURE__ */ new Set();
|
|
158
171
|
this.paymentMethodsCache = [];
|
|
172
|
+
this.queuedAutoPaymentSync = false;
|
|
173
|
+
this.autoPaymentSyncFlushing = false;
|
|
174
|
+
this.autoPaymentSyncTimer = null;
|
|
175
|
+
this.salesDetailLoadInFlight = false;
|
|
176
|
+
this.serverOrderChangeUnsubscribe = null;
|
|
177
|
+
this.serverOrderChangeHydrateInFlight = null;
|
|
159
178
|
}
|
|
160
179
|
/**
|
|
161
180
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -165,10 +184,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
165
184
|
return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
|
|
166
185
|
}
|
|
167
186
|
getReusableSharedSubModule(moduleName) {
|
|
168
|
-
var _a;
|
|
187
|
+
var _a, _b;
|
|
169
188
|
if (moduleName !== "schedule" && moduleName !== "quotation")
|
|
170
189
|
return null;
|
|
171
|
-
return ((_a = this.core) == null ? void 0 : _a.getModule(moduleName)) || null;
|
|
190
|
+
return ((_b = (_a = this.core) == null ? void 0 : _a.getModule) == null ? void 0 : _b.call(_a, moduleName)) || null;
|
|
172
191
|
}
|
|
173
192
|
isScheduleListLoaded(scheduleModule) {
|
|
174
193
|
if (!scheduleModule)
|
|
@@ -220,6 +239,53 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
220
239
|
});
|
|
221
240
|
}
|
|
222
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
|
+
}
|
|
223
289
|
hydrateOrderPaymentNames(payments) {
|
|
224
290
|
if (!payments.length)
|
|
225
291
|
return [];
|
|
@@ -634,9 +700,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
634
700
|
);
|
|
635
701
|
}
|
|
636
702
|
await this.getPaymentMethodsAsync();
|
|
703
|
+
this.registerServerOrderChangeSync();
|
|
637
704
|
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
638
705
|
}
|
|
639
706
|
async destroy() {
|
|
707
|
+
var _a;
|
|
708
|
+
(_a = this.serverOrderChangeUnsubscribe) == null ? void 0 : _a.call(this);
|
|
709
|
+
this.serverOrderChangeUnsubscribe = null;
|
|
640
710
|
Object.keys(this.store).forEach((key) => {
|
|
641
711
|
if (this.reusedSharedSubModuleNames.has(key))
|
|
642
712
|
return;
|
|
@@ -663,30 +733,35 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
663
733
|
async loadSalesDetail(orderIdOrParams) {
|
|
664
734
|
if (!this.store.order)
|
|
665
735
|
throw new Error("order 模块未初始化");
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
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
|
+
}
|
|
690
765
|
}
|
|
691
766
|
/** 获取当前已加载的销售详情(只读快照)。未加载过则返回 null。 */
|
|
692
767
|
getSalesOrder() {
|
|
@@ -1019,7 +1094,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1019
1094
|
});
|
|
1020
1095
|
}
|
|
1021
1096
|
async loadDiscountConfig(params) {
|
|
1022
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s
|
|
1097
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1023
1098
|
if (!this.store.order)
|
|
1024
1099
|
throw new Error("order 模块未初始化");
|
|
1025
1100
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1090,13 +1165,15 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1090
1165
|
};
|
|
1091
1166
|
}
|
|
1092
1167
|
if (rulesModule) {
|
|
1093
|
-
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.
|
|
1168
|
+
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.form_record) || [];
|
|
1169
|
+
const orderTotalAmount = Number(((_m = orderStore.summary) == null ? void 0 : _m.total_amount) || 0);
|
|
1170
|
+
console.log("[BaseSales.applyDiscountConfig.calcDiscount]");
|
|
1094
1171
|
const result = rulesModule.calcDiscount({
|
|
1095
1172
|
productList: tempOrder.products,
|
|
1096
1173
|
discountList: nextDiscountList,
|
|
1097
1174
|
holders,
|
|
1098
|
-
isFormSubject:
|
|
1099
|
-
orderTotalAmount
|
|
1175
|
+
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1176
|
+
orderTotalAmount
|
|
1100
1177
|
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
1101
1178
|
if (result.productList) {
|
|
1102
1179
|
tempOrder.products = preserveManualProductDiscountProducts(
|
|
@@ -1105,8 +1182,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1105
1182
|
);
|
|
1106
1183
|
}
|
|
1107
1184
|
for (const product of tempOrder.products || []) {
|
|
1108
|
-
const productUid = (
|
|
1109
|
-
const runtimeOrigin = productUid ? (
|
|
1185
|
+
const productUid = (_n = product.metadata) == null ? void 0 : _n.unique_identification_number;
|
|
1186
|
+
const runtimeOrigin = productUid ? (_q = (_p = (_o = tempOrder._extend) == null ? void 0 : _o.productsByUid) == null ? void 0 : _p[productUid]) == null ? void 0 : _q.origin : void 0;
|
|
1110
1187
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1111
1188
|
continue;
|
|
1112
1189
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
@@ -1114,7 +1191,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1114
1191
|
0
|
|
1115
1192
|
);
|
|
1116
1193
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
1117
|
-
const sourcePrice = ((
|
|
1194
|
+
const sourcePrice = ((_r = product.metadata) == null ? void 0 : _r.source_product_price) ?? (((_s = product.metadata) == null ? void 0 : _s.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1118
1195
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1119
1196
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1120
1197
|
if (product.metadata) {
|
|
@@ -1150,7 +1227,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1150
1227
|
};
|
|
1151
1228
|
}
|
|
1152
1229
|
async bestDiscount(cb) {
|
|
1153
|
-
var _a, _b, _c, _d
|
|
1230
|
+
var _a, _b, _c, _d;
|
|
1154
1231
|
if (!this.store.order)
|
|
1155
1232
|
throw new Error("order 模块未初始化");
|
|
1156
1233
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1169,13 +1246,15 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1169
1246
|
};
|
|
1170
1247
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1171
1248
|
if (rulesModule) {
|
|
1172
|
-
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.
|
|
1249
|
+
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.form_record) || [];
|
|
1250
|
+
const orderTotalAmount = Number(((_d = orderStore.summary) == null ? void 0 : _d.total_amount) || 0);
|
|
1251
|
+
console.log("[BaseSales.bestDiscount.calcDiscount]");
|
|
1173
1252
|
result = rulesModule.calcDiscount({
|
|
1174
1253
|
productList: tempOrder.products,
|
|
1175
1254
|
discountList: nextDiscountList,
|
|
1176
1255
|
holders,
|
|
1177
|
-
isFormSubject:
|
|
1178
|
-
orderTotalAmount
|
|
1256
|
+
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1257
|
+
orderTotalAmount
|
|
1179
1258
|
}) || result;
|
|
1180
1259
|
if (result.productList) {
|
|
1181
1260
|
tempOrder.products = preserveManualProductDiscountProducts(
|
|
@@ -1244,16 +1323,19 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1244
1323
|
const orderStore = this.store.order.store || {};
|
|
1245
1324
|
const discountModule = orderStore.discount;
|
|
1246
1325
|
const rulesModule = orderStore.rules;
|
|
1247
|
-
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.
|
|
1326
|
+
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record) || [];
|
|
1248
1327
|
let nextDiscountList = updated;
|
|
1249
1328
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
1250
1329
|
if (rulesModule) {
|
|
1330
|
+
const orderTotalAmount = Number(((_b = orderStore.summary) == null ? void 0 : _b.total_amount) || 0);
|
|
1331
|
+
console.log("[BaseSales.setDiscountSelected.calcDiscount]");
|
|
1251
1332
|
const result = rulesModule.calcDiscount(
|
|
1252
1333
|
{
|
|
1253
1334
|
productList: tempOrder.products,
|
|
1254
1335
|
discountList: updated,
|
|
1255
1336
|
holders,
|
|
1256
|
-
isFormSubject:
|
|
1337
|
+
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product),
|
|
1338
|
+
orderTotalAmount
|
|
1257
1339
|
},
|
|
1258
1340
|
{
|
|
1259
1341
|
discountId: params.discountId,
|
|
@@ -1276,6 +1358,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1276
1358
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1277
1359
|
d.isSelected = false;
|
|
1278
1360
|
d.isManualSelect = true;
|
|
1361
|
+
d.appliedProductDetails = [];
|
|
1279
1362
|
}
|
|
1280
1363
|
}
|
|
1281
1364
|
}
|
|
@@ -1284,16 +1367,32 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1284
1367
|
const selectedResourceIds = new Set(
|
|
1285
1368
|
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1286
1369
|
);
|
|
1370
|
+
const filterSelectedDiscountDetails = (discountList) => (discountList || []).filter((pd) => {
|
|
1371
|
+
var _a2;
|
|
1372
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1373
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1374
|
+
});
|
|
1287
1375
|
for (const product of tempOrder.products) {
|
|
1288
1376
|
const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
|
|
1289
1377
|
const runtimeOrigin = productUid ? (_f = (_e = (_d = tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[productUid]) == null ? void 0 : _f.origin : void 0;
|
|
1290
1378
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1291
1379
|
continue;
|
|
1292
|
-
product.discount_list = (product.discount_list
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1380
|
+
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
1381
|
+
if (Array.isArray(product.product_bundle)) {
|
|
1382
|
+
product.product_bundle = product.product_bundle.map((bundle) => {
|
|
1383
|
+
const nextBundleDiscountList = filterSelectedDiscountDetails(bundle == null ? void 0 : bundle.discount_list);
|
|
1384
|
+
const shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
1385
|
+
const restoredBundlePrice = (bundle == null ? void 0 : bundle.original_price) ?? (bundle == null ? void 0 : bundle.product_price) ?? (bundle == null ? void 0 : bundle.price);
|
|
1386
|
+
return {
|
|
1387
|
+
...bundle,
|
|
1388
|
+
...shouldRestoreBundlePrice ? {
|
|
1389
|
+
price: restoredBundlePrice,
|
|
1390
|
+
bundle_selling_price: restoredBundlePrice
|
|
1391
|
+
} : {},
|
|
1392
|
+
discount_list: nextBundleDiscountList
|
|
1393
|
+
};
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1297
1396
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1298
1397
|
(sum, pd) => sum + (pd.amount || 0),
|
|
1299
1398
|
0
|
|
@@ -1382,6 +1481,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1382
1481
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1383
1482
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1384
1483
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1484
|
+
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1385
1485
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1386
1486
|
};
|
|
1387
1487
|
return this.store.order.submitTempOrder(submitParams);
|
|
@@ -1401,6 +1501,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1401
1501
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1402
1502
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1403
1503
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1504
|
+
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1404
1505
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1405
1506
|
};
|
|
1406
1507
|
return this.store.order.submitTempOrderAsync(submitParams);
|
|
@@ -1469,6 +1570,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1469
1570
|
};
|
|
1470
1571
|
const syncState = this.store.order.getOrderSyncState();
|
|
1471
1572
|
if (params.submitWhenPaid && syncState === "submitting") {
|
|
1573
|
+
this.queueLatestAutoPaymentSync();
|
|
1472
1574
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
1473
1575
|
}
|
|
1474
1576
|
const payments = params.payments || [];
|
|
@@ -1480,14 +1582,28 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1480
1582
|
});
|
|
1481
1583
|
try {
|
|
1482
1584
|
const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
|
|
1483
|
-
|
|
1585
|
+
const latestPayments = this.store.order.getOrderPayments();
|
|
1586
|
+
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1587
|
+
const orderSnapshot = this.store.order.getOrderSnapshot();
|
|
1588
|
+
const syncPayload = {
|
|
1484
1589
|
ok: true,
|
|
1485
1590
|
syncResult,
|
|
1486
|
-
payments:
|
|
1591
|
+
payments: latestPayments,
|
|
1487
1592
|
params: syncParams,
|
|
1488
|
-
amountSnapshot
|
|
1489
|
-
orderSnapshot
|
|
1490
|
-
|
|
1593
|
+
amountSnapshot,
|
|
1594
|
+
orderSnapshot,
|
|
1595
|
+
isFullyPaid: syncResult.isFullyPaid,
|
|
1596
|
+
isOrderFullyPaid: syncResult.isOrderFullyPaid,
|
|
1597
|
+
isDepositFullyPaid: syncResult.isDepositFullyPaid,
|
|
1598
|
+
paymentStage: syncResult.paymentStage,
|
|
1599
|
+
depositAmount: syncResult.depositAmount,
|
|
1600
|
+
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
1601
|
+
};
|
|
1602
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
1603
|
+
if (syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid) {
|
|
1604
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
1605
|
+
}
|
|
1606
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1491
1607
|
return syncResult;
|
|
1492
1608
|
} catch (error) {
|
|
1493
1609
|
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
@@ -1498,6 +1614,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1498
1614
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1499
1615
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1500
1616
|
});
|
|
1617
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1501
1618
|
throw error;
|
|
1502
1619
|
}
|
|
1503
1620
|
}
|
|
@@ -1514,6 +1631,61 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1514
1631
|
throw new Error("order 模块未初始化");
|
|
1515
1632
|
return this.store.order.setOrderPayments(payments);
|
|
1516
1633
|
}
|
|
1634
|
+
getPaymentStatusForSync(payments) {
|
|
1635
|
+
const order = this.store.order;
|
|
1636
|
+
if (!order)
|
|
1637
|
+
throw new Error("order 模块未初始化");
|
|
1638
|
+
const completion = order.getPaymentCompletion(payments);
|
|
1639
|
+
return completion.isOrderFullyPaid ? "paid" : "partially_paid";
|
|
1640
|
+
}
|
|
1641
|
+
queueLatestAutoPaymentSync() {
|
|
1642
|
+
this.queuedAutoPaymentSync = true;
|
|
1643
|
+
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
1644
|
+
}
|
|
1645
|
+
scheduleQueuedAutoPaymentSyncFlush(delay = 100) {
|
|
1646
|
+
if (!this.queuedAutoPaymentSync)
|
|
1647
|
+
return;
|
|
1648
|
+
if (this.autoPaymentSyncTimer)
|
|
1649
|
+
return;
|
|
1650
|
+
this.autoPaymentSyncTimer = setTimeout(() => {
|
|
1651
|
+
this.autoPaymentSyncTimer = null;
|
|
1652
|
+
void this.flushQueuedAutoPaymentSync();
|
|
1653
|
+
}, delay);
|
|
1654
|
+
}
|
|
1655
|
+
async flushQueuedAutoPaymentSync() {
|
|
1656
|
+
if (!this.store.order)
|
|
1657
|
+
return;
|
|
1658
|
+
if (!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)
|
|
1659
|
+
return;
|
|
1660
|
+
if (this.store.order.getOrderSyncState() === "submitting") {
|
|
1661
|
+
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1664
|
+
this.autoPaymentSyncFlushing = true;
|
|
1665
|
+
try {
|
|
1666
|
+
while (this.queuedAutoPaymentSync) {
|
|
1667
|
+
this.queuedAutoPaymentSync = false;
|
|
1668
|
+
const payments = this.store.order.getOrderPayments();
|
|
1669
|
+
if (!payments.length)
|
|
1670
|
+
continue;
|
|
1671
|
+
await this.syncPaymentsToOrder({
|
|
1672
|
+
payments,
|
|
1673
|
+
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
1674
|
+
submitWhenPaid: true,
|
|
1675
|
+
smallTicketDataFlag: 1
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
} catch (error) {
|
|
1679
|
+
this.logError("queued auto sync payments failed", {
|
|
1680
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1681
|
+
});
|
|
1682
|
+
} finally {
|
|
1683
|
+
this.autoPaymentSyncFlushing = false;
|
|
1684
|
+
if (this.queuedAutoPaymentSync) {
|
|
1685
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1517
1689
|
/** 追加单个支付项到当前订单。 */
|
|
1518
1690
|
addOrderPayment(payment) {
|
|
1519
1691
|
var _a;
|
|
@@ -1549,11 +1721,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1549
1721
|
});
|
|
1550
1722
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1551
1723
|
const syncState = this.store.order.getOrderSyncState();
|
|
1552
|
-
if (amountSnapshot
|
|
1553
|
-
|
|
1724
|
+
if (amountSnapshot) {
|
|
1725
|
+
if (syncState === "submitting") {
|
|
1726
|
+
this.queueLatestAutoPaymentSync();
|
|
1727
|
+
return payments;
|
|
1728
|
+
}
|
|
1554
1729
|
void this.syncPaymentsToOrder({
|
|
1555
1730
|
payments,
|
|
1556
|
-
paymentStatus,
|
|
1731
|
+
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
1557
1732
|
submitWhenPaid: true,
|
|
1558
1733
|
smallTicketDataFlag: 1
|
|
1559
1734
|
}).catch((error) => {
|
|
@@ -1561,7 +1736,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1561
1736
|
error: error instanceof Error ? error.message : String(error)
|
|
1562
1737
|
});
|
|
1563
1738
|
});
|
|
1564
|
-
} else {
|
|
1565
1739
|
}
|
|
1566
1740
|
return payments;
|
|
1567
1741
|
}
|
|
@@ -1578,21 +1752,33 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1578
1752
|
return this.store.order.deleteOrderPayment(paymentIdentity);
|
|
1579
1753
|
}
|
|
1580
1754
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
1581
|
-
updateVoucherOrderPayments(payments) {
|
|
1755
|
+
updateVoucherOrderPayments(payments, options) {
|
|
1582
1756
|
if (!this.store.order)
|
|
1583
1757
|
throw new Error("order 模块未初始化");
|
|
1584
|
-
return this.store.order.updateVoucherOrderPayments(payments);
|
|
1758
|
+
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
1759
|
+
}
|
|
1760
|
+
confirmPendingVoucherPayments() {
|
|
1761
|
+
if (!this.store.order)
|
|
1762
|
+
throw new Error("order 模块未初始化");
|
|
1763
|
+
return this.store.order.confirmPendingVoucherPayments();
|
|
1764
|
+
}
|
|
1765
|
+
discardPendingVoucherPayments() {
|
|
1766
|
+
if (!this.store.order)
|
|
1767
|
+
throw new Error("order 模块未初始化");
|
|
1768
|
+
return this.store.order.discardPendingVoucherPayments();
|
|
1585
1769
|
}
|
|
1586
1770
|
getWalletProductList() {
|
|
1587
|
-
var _a, _b
|
|
1771
|
+
var _a, _b;
|
|
1588
1772
|
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
1589
1773
|
if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
|
|
1590
1774
|
return [];
|
|
1591
|
-
const
|
|
1592
|
-
const walletProducts = products.map((product) => {
|
|
1775
|
+
const walletProducts = tempOrder == null ? void 0 : tempOrder.products.map((product) => {
|
|
1593
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;
|
|
1594
1780
|
return {
|
|
1595
|
-
product_id: product.product_id,
|
|
1781
|
+
product_id: product.product_id || 0,
|
|
1596
1782
|
product_variant_id: String(product.product_variant_id ?? ""),
|
|
1597
1783
|
quantity: product.num || 1,
|
|
1598
1784
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
@@ -1600,7 +1786,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1600
1786
|
tax_fee: product.tax_fee,
|
|
1601
1787
|
selling_price: Number(product.selling_price || 0),
|
|
1602
1788
|
discount_list: product.discount_list || [],
|
|
1603
|
-
holder_id
|
|
1789
|
+
holder_id,
|
|
1604
1790
|
original_price: product.original_price,
|
|
1605
1791
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
1606
1792
|
main_product_selling_price: metadata.main_product_selling_price ?? product.selling_price,
|
|
@@ -14,6 +14,7 @@ export declare const BaseSalesHookNames: {
|
|
|
14
14
|
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
15
15
|
readonly onPaymentSyncStart: "onPaymentSyncStart";
|
|
16
16
|
readonly onPaymentSyncEnd: "onPaymentSyncEnd";
|
|
17
|
+
readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
|
|
17
18
|
};
|
|
18
19
|
export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
|
|
19
20
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
@@ -30,7 +30,8 @@ var BaseSalesHookNames = {
|
|
|
30
30
|
onRefresh: "onRefresh",
|
|
31
31
|
onCartValidationChanged: "onCartValidationChanged",
|
|
32
32
|
onPaymentSyncStart: "onPaymentSyncStart",
|
|
33
|
-
onPaymentSyncEnd: "onPaymentSyncEnd"
|
|
33
|
+
onPaymentSyncEnd: "onPaymentSyncEnd",
|
|
34
|
+
onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd"
|
|
34
35
|
};
|
|
35
36
|
function createBaseSalesHook(moduleName, hookName) {
|
|
36
37
|
return `${moduleName}:${hookName}`;
|
|
@@ -78,6 +78,7 @@ export interface CartPromotionEvaluator {
|
|
|
78
78
|
}>;
|
|
79
79
|
hasApplicableStrategy: boolean;
|
|
80
80
|
}>;
|
|
81
|
+
getStrategyConfigs?: () => unknown[];
|
|
81
82
|
}
|
|
82
83
|
/** 单个赠品减量项 */
|
|
83
84
|
export interface GiftReduceItem {
|
|
@@ -267,7 +268,8 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
|
|
|
267
268
|
* 处理购物车的促销计算与赠品差异化。
|
|
268
269
|
*
|
|
269
270
|
* 流程:
|
|
270
|
-
* 1. 分离 main / gift / edit-product
|
|
271
|
+
* 1. 分离 main / gift / edit-product 三类(普通促销下带 `booking_id` 的编辑态商品不参与;
|
|
272
|
+
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
271
273
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
272
274
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
273
275
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|