@pisell/pisellos 2.2.259 → 2.2.260
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/dataVariant/adapter.d.ts +49 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
- package/dist/modules/Order/index.d.ts +1 -32
- package/dist/modules/Order/index.js +288 -615
- package/dist/modules/Order/types.d.ts +2 -20
- package/dist/modules/Order/utils.d.ts +0 -4
- package/dist/modules/Order/utils.js +28 -114
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +3 -8
- package/dist/modules/Rules/types.d.ts +1 -2
- package/dist/modules/SalesSummary/index.d.ts +3 -7
- package/dist/modules/SalesSummary/index.js +39 -67
- package/dist/modules/SalesSummary/types.d.ts +0 -1
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/SurchargeList/index.d.ts +4 -6
- package/dist/modules/SurchargeList/index.js +39 -62
- package/dist/modules/SurchargeList/types.d.ts +2 -6
- package/dist/server/index.d.ts +50 -3
- package/dist/server/index.js +1040 -1075
- package/dist/server/modules/order/index.d.ts +3 -22
- package/dist/server/modules/order/index.js +316 -398
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +166 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +2 -22
- package/dist/solution/BaseSales/index.js +701 -995
- package/dist/solution/BaseSales/types.d.ts +0 -1
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -8
- package/dist/solution/BookingTicket/index.js +6 -153
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
- package/lib/modules/Order/index.d.ts +1 -32
- package/lib/modules/Order/index.js +64 -402
- package/lib/modules/Order/types.d.ts +2 -20
- package/lib/modules/Order/utils.d.ts +0 -4
- package/lib/modules/Order/utils.js +2 -84
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +3 -4
- package/lib/modules/Rules/types.d.ts +1 -2
- package/lib/modules/SalesSummary/index.d.ts +3 -7
- package/lib/modules/SalesSummary/index.js +11 -28
- package/lib/modules/SalesSummary/types.d.ts +0 -1
- package/lib/modules/SalesSummary/utils.js +0 -2
- package/lib/modules/SurchargeList/index.d.ts +4 -6
- package/lib/modules/SurchargeList/index.js +21 -41
- package/lib/modules/SurchargeList/types.d.ts +2 -6
- package/lib/server/index.d.ts +50 -3
- package/lib/server/index.js +215 -244
- package/lib/server/modules/order/index.d.ts +3 -22
- package/lib/server/modules/order/index.js +53 -103
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +113 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +2 -22
- package/lib/solution/BaseSales/index.js +60 -246
- package/lib/solution/BaseSales/types.d.ts +0 -1
- package/lib/solution/BaseSales/types.js +1 -2
- 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 +0 -8
- package/lib/solution/BookingTicket/index.js +0 -101
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
|
@@ -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
|
+
private logger;
|
|
34
34
|
protected appPlugin: AppPlugin;
|
|
35
35
|
protected store: BaseSalesState;
|
|
36
36
|
protected otherParams: Record<string, any>;
|
|
@@ -46,12 +46,6 @@ 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;
|
|
55
49
|
constructor(name?: string, version?: string);
|
|
56
50
|
/**
|
|
57
51
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -72,9 +66,6 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
72
66
|
* 记录错误日志
|
|
73
67
|
*/
|
|
74
68
|
private logError;
|
|
75
|
-
private isCurrentSalesOrderRecord;
|
|
76
|
-
private syncCurrentSalesDetailFromServerOrderChange;
|
|
77
|
-
private registerServerOrderChangeSync;
|
|
78
69
|
private hydrateOrderPaymentNames;
|
|
79
70
|
get payment(): PaymentModule | undefined;
|
|
80
71
|
private getCurrentOrderCustomerId;
|
|
@@ -204,7 +195,6 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
204
195
|
payments?: OrderPaymentSource[];
|
|
205
196
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
206
197
|
smallTicketDataFlag?: number;
|
|
207
|
-
confirmPendingVoucherPayments?: boolean;
|
|
208
198
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
209
199
|
}): Promise<T>;
|
|
210
200
|
/**
|
|
@@ -217,14 +207,12 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
217
207
|
payments?: OrderPaymentSource[];
|
|
218
208
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
219
209
|
smallTicketDataFlag?: number;
|
|
220
|
-
confirmPendingVoucherPayments?: boolean;
|
|
221
210
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
222
211
|
}): Promise<T>;
|
|
223
212
|
submitTempOrderAsync<T = any>(params?: {
|
|
224
213
|
payments?: OrderPaymentSource[];
|
|
225
214
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
226
215
|
smallTicketDataFlag?: number;
|
|
227
|
-
confirmPendingVoucherPayments?: boolean;
|
|
228
216
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
229
217
|
}): Promise<T>;
|
|
230
218
|
printLocalOrderReceipt<T = any>(lookup?: BaseSalesPrintLocalOrderReceiptParams): Promise<T>;
|
|
@@ -234,10 +222,6 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
234
222
|
getOrderPayments(): OrderPaymentData[];
|
|
235
223
|
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
236
224
|
setOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
|
|
237
|
-
private getPaymentStatusForSync;
|
|
238
|
-
private queueLatestAutoPaymentSync;
|
|
239
|
-
private scheduleQueuedAutoPaymentSyncFlush;
|
|
240
|
-
private flushQueuedAutoPaymentSync;
|
|
241
225
|
/** 追加单个支付项到当前订单。 */
|
|
242
226
|
addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
|
|
243
227
|
/** 更新当前订单中的指定支付项。 */
|
|
@@ -245,11 +229,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
245
229
|
/** 删除当前订单中的指定支付项。 */
|
|
246
230
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
247
231
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
248
|
-
updateVoucherOrderPayments(payments: OrderPaymentSource[]
|
|
249
|
-
status?: 'paid' | 'payment_pending';
|
|
250
|
-
}): OrderPaymentData[];
|
|
251
|
-
confirmPendingVoucherPayments(): OrderPaymentData[];
|
|
252
|
-
discardPendingVoucherPayments(): OrderPaymentData[];
|
|
232
|
+
updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
|
|
253
233
|
private getWalletProductList;
|
|
254
234
|
initWalletData(params?: {
|
|
255
235
|
order_wait_pay_amount?: number;
|
|
@@ -45,7 +45,6 @@ __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";
|
|
49
48
|
function isBaseSalesManualProductDiscountProduct(product) {
|
|
50
49
|
var _a, _b;
|
|
51
50
|
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");
|
|
@@ -83,18 +82,6 @@ function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
|
83
82
|
return "unique_payment_number";
|
|
84
83
|
return null;
|
|
85
84
|
}
|
|
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
|
-
}
|
|
98
85
|
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
99
86
|
var _a;
|
|
100
87
|
const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a[metadataKey]) ?? (item == null ? void 0 : item[metadataKey]);
|
|
@@ -169,12 +156,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
169
156
|
this.hasManualDiscountSelection = false;
|
|
170
157
|
this.reusedSharedSubModuleNames = /* @__PURE__ */ new Set();
|
|
171
158
|
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;
|
|
178
159
|
}
|
|
179
160
|
/**
|
|
180
161
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -184,10 +165,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
184
165
|
return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
|
|
185
166
|
}
|
|
186
167
|
getReusableSharedSubModule(moduleName) {
|
|
187
|
-
var _a
|
|
168
|
+
var _a;
|
|
188
169
|
if (moduleName !== "schedule" && moduleName !== "quotation")
|
|
189
170
|
return null;
|
|
190
|
-
return ((
|
|
171
|
+
return ((_a = this.core) == null ? void 0 : _a.getModule(moduleName)) || null;
|
|
191
172
|
}
|
|
192
173
|
isScheduleListLoaded(scheduleModule) {
|
|
193
174
|
if (!scheduleModule)
|
|
@@ -239,53 +220,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
239
220
|
});
|
|
240
221
|
}
|
|
241
222
|
}
|
|
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
|
-
}
|
|
289
223
|
hydrateOrderPaymentNames(payments) {
|
|
290
224
|
if (!payments.length)
|
|
291
225
|
return [];
|
|
@@ -700,13 +634,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
700
634
|
);
|
|
701
635
|
}
|
|
702
636
|
await this.getPaymentMethodsAsync();
|
|
703
|
-
this.registerServerOrderChangeSync();
|
|
704
637
|
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
705
638
|
}
|
|
706
639
|
async destroy() {
|
|
707
|
-
var _a;
|
|
708
|
-
(_a = this.serverOrderChangeUnsubscribe) == null ? void 0 : _a.call(this);
|
|
709
|
-
this.serverOrderChangeUnsubscribe = null;
|
|
710
640
|
Object.keys(this.store).forEach((key) => {
|
|
711
641
|
if (this.reusedSharedSubModuleNames.has(key))
|
|
712
642
|
return;
|
|
@@ -733,35 +663,30 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
733
663
|
async loadSalesDetail(orderIdOrParams) {
|
|
734
664
|
if (!this.store.order)
|
|
735
665
|
throw new Error("order 模块未初始化");
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
761
|
-
return sales;
|
|
762
|
-
} finally {
|
|
763
|
-
this.salesDetailLoadInFlight = false;
|
|
764
|
-
}
|
|
666
|
+
const params = typeof orderIdOrParams === "object" ? orderIdOrParams : { orderId: orderIdOrParams };
|
|
667
|
+
const externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
668
|
+
const preloadedSalesDetail = params.preloadedSalesDetail;
|
|
669
|
+
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);
|
|
670
|
+
if (!preloadedSalesDetail && (lookup === void 0 || lookup === null || lookup === "")) {
|
|
671
|
+
throw new Error("加载销售详情需要 orderId、externalSaleNumber 或 orderNumber");
|
|
672
|
+
}
|
|
673
|
+
const loadedRecord = preloadedSalesDetail ?? await this.store.order.getSalesOrderByLookup({
|
|
674
|
+
lookup,
|
|
675
|
+
forceRemote: params.forceRemote
|
|
676
|
+
});
|
|
677
|
+
if (!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200)) {
|
|
678
|
+
const message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || `加载销售详情失败: ${lookup}`;
|
|
679
|
+
throw new Error(message);
|
|
680
|
+
}
|
|
681
|
+
const remoteRecord = preloadedSalesDetail ?? loadedRecord.data;
|
|
682
|
+
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
683
|
+
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
|
|
684
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(record, {
|
|
685
|
+
recalcOnHydrate: false
|
|
686
|
+
});
|
|
687
|
+
this.currentSalesDetail = sales;
|
|
688
|
+
await this.core.effects.emit(`${this.name}:onSalesOrderLoaded`, { sales });
|
|
689
|
+
return sales;
|
|
765
690
|
}
|
|
766
691
|
/** 获取当前已加载的销售详情(只读快照)。未加载过则返回 null。 */
|
|
767
692
|
getSalesOrder() {
|
|
@@ -1094,7 +1019,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1094
1019
|
});
|
|
1095
1020
|
}
|
|
1096
1021
|
async loadDiscountConfig(params) {
|
|
1097
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1022
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1098
1023
|
if (!this.store.order)
|
|
1099
1024
|
throw new Error("order 模块未初始化");
|
|
1100
1025
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1165,15 +1090,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1165
1090
|
};
|
|
1166
1091
|
}
|
|
1167
1092
|
if (rulesModule) {
|
|
1168
|
-
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.
|
|
1169
|
-
const orderTotalAmount = Number(((_m = orderStore.summary) == null ? void 0 : _m.total_amount) || 0);
|
|
1170
|
-
console.log("[BaseSales.applyDiscountConfig.calcDiscount]");
|
|
1093
|
+
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
1171
1094
|
const result = rulesModule.calcDiscount({
|
|
1172
1095
|
productList: tempOrder.products,
|
|
1173
1096
|
discountList: nextDiscountList,
|
|
1174
1097
|
holders,
|
|
1175
|
-
isFormSubject: (
|
|
1176
|
-
orderTotalAmount
|
|
1098
|
+
isFormSubject: !!((_m = tempOrder.holder) == null ? void 0 : _m.type) && tempOrder.holder.type === "form",
|
|
1099
|
+
orderTotalAmount: Number(((_n = orderStore.summary) == null ? void 0 : _n.total_amount) || 0)
|
|
1177
1100
|
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
1178
1101
|
if (result.productList) {
|
|
1179
1102
|
tempOrder.products = preserveManualProductDiscountProducts(
|
|
@@ -1182,8 +1105,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1182
1105
|
);
|
|
1183
1106
|
}
|
|
1184
1107
|
for (const product of tempOrder.products || []) {
|
|
1185
|
-
const productUid = (
|
|
1186
|
-
const runtimeOrigin = productUid ? (
|
|
1108
|
+
const productUid = (_o = product.metadata) == null ? void 0 : _o.unique_identification_number;
|
|
1109
|
+
const runtimeOrigin = productUid ? (_r = (_q = (_p = tempOrder._extend) == null ? void 0 : _p.productsByUid) == null ? void 0 : _q[productUid]) == null ? void 0 : _r.origin : void 0;
|
|
1187
1110
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1188
1111
|
continue;
|
|
1189
1112
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
@@ -1191,7 +1114,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1191
1114
|
0
|
|
1192
1115
|
);
|
|
1193
1116
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
|
|
1194
|
-
const sourcePrice = ((
|
|
1117
|
+
const sourcePrice = ((_s = product.metadata) == null ? void 0 : _s.source_product_price) ?? (((_t = product.metadata) == null ? void 0 : _t.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");
|
|
1195
1118
|
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1196
1119
|
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1197
1120
|
if (product.metadata) {
|
|
@@ -1227,7 +1150,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1227
1150
|
};
|
|
1228
1151
|
}
|
|
1229
1152
|
async bestDiscount(cb) {
|
|
1230
|
-
var _a, _b, _c, _d;
|
|
1153
|
+
var _a, _b, _c, _d, _e;
|
|
1231
1154
|
if (!this.store.order)
|
|
1232
1155
|
throw new Error("order 模块未初始化");
|
|
1233
1156
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
@@ -1246,15 +1169,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1246
1169
|
};
|
|
1247
1170
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1248
1171
|
if (rulesModule) {
|
|
1249
|
-
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.
|
|
1250
|
-
const orderTotalAmount = Number(((_d = orderStore.summary) == null ? void 0 : _d.total_amount) || 0);
|
|
1251
|
-
console.log("[BaseSales.bestDiscount.calcDiscount]");
|
|
1172
|
+
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
1252
1173
|
result = rulesModule.calcDiscount({
|
|
1253
1174
|
productList: tempOrder.products,
|
|
1254
1175
|
discountList: nextDiscountList,
|
|
1255
1176
|
holders,
|
|
1256
|
-
isFormSubject: (
|
|
1257
|
-
orderTotalAmount
|
|
1177
|
+
isFormSubject: !!((_d = tempOrder.holder) == null ? void 0 : _d.type) && tempOrder.holder.type === "form",
|
|
1178
|
+
orderTotalAmount: Number(((_e = orderStore.summary) == null ? void 0 : _e.total_amount) || 0)
|
|
1258
1179
|
}) || result;
|
|
1259
1180
|
if (result.productList) {
|
|
1260
1181
|
tempOrder.products = preserveManualProductDiscountProducts(
|
|
@@ -1323,19 +1244,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1323
1244
|
const orderStore = this.store.order.store || {};
|
|
1324
1245
|
const discountModule = orderStore.discount;
|
|
1325
1246
|
const rulesModule = orderStore.rules;
|
|
1326
|
-
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.
|
|
1247
|
+
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
1327
1248
|
let nextDiscountList = updated;
|
|
1328
1249
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
1329
1250
|
if (rulesModule) {
|
|
1330
|
-
const orderTotalAmount = Number(((_b = orderStore.summary) == null ? void 0 : _b.total_amount) || 0);
|
|
1331
|
-
console.log("[BaseSales.setDiscountSelected.calcDiscount]");
|
|
1332
1251
|
const result = rulesModule.calcDiscount(
|
|
1333
1252
|
{
|
|
1334
1253
|
productList: tempOrder.products,
|
|
1335
1254
|
discountList: updated,
|
|
1336
1255
|
holders,
|
|
1337
|
-
isFormSubject: (
|
|
1338
|
-
orderTotalAmount
|
|
1256
|
+
isFormSubject: !!((_b = tempOrder.holder) == null ? void 0 : _b.type) && tempOrder.holder.type === "form"
|
|
1339
1257
|
},
|
|
1340
1258
|
{
|
|
1341
1259
|
discountId: params.discountId,
|
|
@@ -1358,7 +1276,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1358
1276
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1359
1277
|
d.isSelected = false;
|
|
1360
1278
|
d.isManualSelect = true;
|
|
1361
|
-
d.appliedProductDetails = [];
|
|
1362
1279
|
}
|
|
1363
1280
|
}
|
|
1364
1281
|
}
|
|
@@ -1367,32 +1284,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1367
1284
|
const selectedResourceIds = new Set(
|
|
1368
1285
|
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1369
1286
|
);
|
|
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
|
-
});
|
|
1375
1287
|
for (const product of tempOrder.products) {
|
|
1376
1288
|
const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
|
|
1377
1289
|
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;
|
|
1378
1290
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1379
1291
|
continue;
|
|
1380
|
-
product.discount_list =
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
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
|
-
}
|
|
1292
|
+
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1293
|
+
var _a2;
|
|
1294
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1295
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1296
|
+
});
|
|
1396
1297
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1397
1298
|
(sum, pd) => sum + (pd.amount || 0),
|
|
1398
1299
|
0
|
|
@@ -1481,7 +1382,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1481
1382
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1482
1383
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1483
1384
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1484
|
-
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1485
1385
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1486
1386
|
};
|
|
1487
1387
|
return this.store.order.submitTempOrder(submitParams);
|
|
@@ -1501,7 +1401,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1501
1401
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1502
1402
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1503
1403
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1504
|
-
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1505
1404
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1506
1405
|
};
|
|
1507
1406
|
return this.store.order.submitTempOrderAsync(submitParams);
|
|
@@ -1570,7 +1469,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1570
1469
|
};
|
|
1571
1470
|
const syncState = this.store.order.getOrderSyncState();
|
|
1572
1471
|
if (params.submitWhenPaid && syncState === "submitting") {
|
|
1573
|
-
this.queueLatestAutoPaymentSync();
|
|
1574
1472
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
1575
1473
|
}
|
|
1576
1474
|
const payments = params.payments || [];
|
|
@@ -1582,28 +1480,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1582
1480
|
});
|
|
1583
1481
|
try {
|
|
1584
1482
|
const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
|
|
1585
|
-
|
|
1586
|
-
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1587
|
-
const orderSnapshot = this.store.order.getOrderSnapshot();
|
|
1588
|
-
const syncPayload = {
|
|
1483
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1589
1484
|
ok: true,
|
|
1590
1485
|
syncResult,
|
|
1591
|
-
payments:
|
|
1486
|
+
payments: this.store.order.getOrderPayments(),
|
|
1592
1487
|
params: syncParams,
|
|
1593
|
-
amountSnapshot,
|
|
1594
|
-
orderSnapshot
|
|
1595
|
-
|
|
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);
|
|
1488
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1489
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1490
|
+
});
|
|
1607
1491
|
return syncResult;
|
|
1608
1492
|
} catch (error) {
|
|
1609
1493
|
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
@@ -1614,7 +1498,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1614
1498
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1615
1499
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1616
1500
|
});
|
|
1617
|
-
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1618
1501
|
throw error;
|
|
1619
1502
|
}
|
|
1620
1503
|
}
|
|
@@ -1631,61 +1514,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1631
1514
|
throw new Error("order 模块未初始化");
|
|
1632
1515
|
return this.store.order.setOrderPayments(payments);
|
|
1633
1516
|
}
|
|
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
|
-
}
|
|
1689
1517
|
/** 追加单个支付项到当前订单。 */
|
|
1690
1518
|
addOrderPayment(payment) {
|
|
1691
1519
|
var _a;
|
|
@@ -1721,14 +1549,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1721
1549
|
});
|
|
1722
1550
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1723
1551
|
const syncState = this.store.order.getOrderSyncState();
|
|
1724
|
-
if (amountSnapshot) {
|
|
1725
|
-
|
|
1726
|
-
this.queueLatestAutoPaymentSync();
|
|
1727
|
-
return payments;
|
|
1728
|
-
}
|
|
1552
|
+
if (amountSnapshot && syncState !== "submitting") {
|
|
1553
|
+
const paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? "paid" : "partially_paid";
|
|
1729
1554
|
void this.syncPaymentsToOrder({
|
|
1730
1555
|
payments,
|
|
1731
|
-
paymentStatus
|
|
1556
|
+
paymentStatus,
|
|
1732
1557
|
submitWhenPaid: true,
|
|
1733
1558
|
smallTicketDataFlag: 1
|
|
1734
1559
|
}).catch((error) => {
|
|
@@ -1736,6 +1561,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1736
1561
|
error: error instanceof Error ? error.message : String(error)
|
|
1737
1562
|
});
|
|
1738
1563
|
});
|
|
1564
|
+
} else {
|
|
1739
1565
|
}
|
|
1740
1566
|
return payments;
|
|
1741
1567
|
}
|
|
@@ -1752,33 +1578,21 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1752
1578
|
return this.store.order.deleteOrderPayment(paymentIdentity);
|
|
1753
1579
|
}
|
|
1754
1580
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
1755
|
-
updateVoucherOrderPayments(payments
|
|
1581
|
+
updateVoucherOrderPayments(payments) {
|
|
1756
1582
|
if (!this.store.order)
|
|
1757
1583
|
throw new Error("order 模块未初始化");
|
|
1758
|
-
return this.store.order.updateVoucherOrderPayments(payments
|
|
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();
|
|
1584
|
+
return this.store.order.updateVoucherOrderPayments(payments);
|
|
1769
1585
|
}
|
|
1770
1586
|
getWalletProductList() {
|
|
1771
|
-
var _a, _b;
|
|
1587
|
+
var _a, _b, _c;
|
|
1772
1588
|
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
1773
1589
|
if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
|
|
1774
1590
|
return [];
|
|
1775
|
-
const
|
|
1591
|
+
const products = (_c = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _c.filter((n) => n.product_id);
|
|
1592
|
+
const walletProducts = products.map((product) => {
|
|
1776
1593
|
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;
|
|
1780
1594
|
return {
|
|
1781
|
-
product_id: product.product_id
|
|
1595
|
+
product_id: product.product_id,
|
|
1782
1596
|
product_variant_id: String(product.product_variant_id ?? ""),
|
|
1783
1597
|
quantity: product.num || 1,
|
|
1784
1598
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
@@ -1786,7 +1600,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1786
1600
|
tax_fee: product.tax_fee,
|
|
1787
1601
|
selling_price: Number(product.selling_price || 0),
|
|
1788
1602
|
discount_list: product.discount_list || [],
|
|
1789
|
-
holder_id,
|
|
1603
|
+
holder_id: product.holder_id ?? metadata.holder_id,
|
|
1790
1604
|
original_price: product.original_price,
|
|
1791
1605
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
1792
1606
|
main_product_selling_price: metadata.main_product_selling_price ?? product.selling_price,
|
|
@@ -14,7 +14,6 @@ export declare const BaseSalesHookNames: {
|
|
|
14
14
|
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
15
15
|
readonly onPaymentSyncStart: "onPaymentSyncStart";
|
|
16
16
|
readonly onPaymentSyncEnd: "onPaymentSyncEnd";
|
|
17
|
-
readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
|
|
18
17
|
};
|
|
19
18
|
export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
|
|
20
19
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
@@ -30,8 +30,7 @@ var BaseSalesHookNames = {
|
|
|
30
30
|
onRefresh: "onRefresh",
|
|
31
31
|
onCartValidationChanged: "onCartValidationChanged",
|
|
32
32
|
onPaymentSyncStart: "onPaymentSyncStart",
|
|
33
|
-
onPaymentSyncEnd: "onPaymentSyncEnd"
|
|
34
|
-
onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd"
|
|
33
|
+
onPaymentSyncEnd: "onPaymentSyncEnd"
|
|
35
34
|
};
|
|
36
35
|
function createBaseSalesHook(moduleName, hookName) {
|
|
37
36
|
return `${moduleName}:${hookName}`;
|
|
@@ -88,8 +88,7 @@ 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)
|
|
92
|
-
discount_list: preferPriceField ? [] : bundleItem.discount_list
|
|
91
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option)
|
|
93
92
|
};
|
|
94
93
|
normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
|
|
95
94
|
if ((normalizedItem.price_type ?? normalizedItem.custom_price_type) === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
|
|
@@ -130,9 +129,10 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
130
129
|
payload.price ?? payload.selling_price ?? (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price),
|
|
131
130
|
"0.00"
|
|
132
131
|
);
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
const lineCompositeTotal = toPriceString(
|
|
133
|
+
payload.line_total ?? payload.total ?? ((_c = payload._extend) == null ? void 0 : _c.total),
|
|
134
|
+
sourceProductPrice
|
|
135
|
+
);
|
|
136
136
|
const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
|
|
137
137
|
const productOptionItem = (0, import_utils.normalizeProductSkuOptions)(
|
|
138
138
|
normalizeOptionItems(
|
|
@@ -180,7 +180,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
180
180
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(productOptionItem).toNumber();
|
|
181
181
|
const mainProductOriginalPrice = toPriceString(Number(sourceProductPrice) + optionSum);
|
|
182
182
|
const bundleOnlyComposite = (0, import_utils.composeLinePrice)({ mainPrice: 0, bundle: productBundle });
|
|
183
|
-
const derivedMainSelling =
|
|
183
|
+
const derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
|
|
184
184
|
const mainProductSellingPrice = toPriceString(
|
|
185
185
|
Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice)
|
|
186
186
|
);
|