@pisell/pisellos 2.2.266 → 2.2.268
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/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/Order/index.d.ts +13 -32
- package/dist/modules/Order/index.js +562 -778
- package/dist/modules/Order/types.d.ts +22 -36
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +50 -79
- package/dist/modules/Payment/types.d.ts +27 -29
- package/dist/modules/Payment/types.js +3 -5
- package/dist/modules/Rules/index.d.ts +0 -1
- package/dist/modules/Rules/index.js +14 -34
- package/dist/server/index.d.ts +0 -16
- package/dist/server/index.js +1036 -1933
- package/dist/server/modules/order/index.d.ts +4 -49
- package/dist/server/modules/order/index.js +695 -1574
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +14 -58
- package/dist/solution/BaseSales/index.js +398 -713
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +29 -35
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.js +19 -30
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Order/index.d.ts +13 -32
- package/lib/modules/Order/index.js +142 -201
- package/lib/modules/Order/types.d.ts +22 -36
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +13 -34
- package/lib/modules/Payment/types.d.ts +27 -29
- package/lib/modules/Payment/types.js +3 -3
- package/lib/modules/Rules/index.d.ts +0 -1
- package/lib/modules/Rules/index.js +4 -23
- package/lib/server/index.d.ts +0 -16
- package/lib/server/index.js +18 -670
- package/lib/server/modules/order/index.d.ts +4 -49
- package/lib/server/modules/order/index.js +66 -657
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +14 -58
- package/lib/solution/BaseSales/index.js +41 -241
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +3 -6
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.js +0 -8
- package/package.json +2 -2
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -213,12 +213,10 @@ export interface OrderBookingItem {
|
|
|
213
213
|
[key: string]: unknown;
|
|
214
214
|
}[];
|
|
215
215
|
}
|
|
216
|
-
/** 支付记录 metadata */
|
|
216
|
+
/** 支付记录 metadata,常含 unique_payment_number */
|
|
217
217
|
export interface OrderPaymentMetadata {
|
|
218
|
-
/**
|
|
218
|
+
/** 设备端本地支付唯一标识 */
|
|
219
219
|
unique_payment_number?: string;
|
|
220
|
-
/** 刷卡机设备快照;server 不解析内部字段,仅透传并持久化 */
|
|
221
|
-
card_reader_snapshot?: Record<string, unknown>;
|
|
222
220
|
[key: string]: unknown;
|
|
223
221
|
}
|
|
224
222
|
/**
|
|
@@ -227,8 +225,6 @@ export interface OrderPaymentMetadata {
|
|
|
227
225
|
export interface OrderPaymentItem {
|
|
228
226
|
/** 支付记录 ID;存量/更新时传。来源:OrderPayment.id */
|
|
229
227
|
order_payment_id?: number | null;
|
|
230
|
-
/** 支付项稳定唯一号;历史支付项允许缺失 */
|
|
231
|
-
payment_number?: string;
|
|
232
228
|
/** 支付方式 ID(设备端从本地支付方式配置取详情)。来源:OrderPayment.custom_payment_id */
|
|
233
229
|
custom_payment_id?: number;
|
|
234
230
|
/** 支付方式编码。来源:OrderPayment.payment_method */
|
|
@@ -253,13 +249,11 @@ export interface OrderPaymentItem {
|
|
|
253
249
|
created_at?: string | null;
|
|
254
250
|
/** 手续费配置。来源:OrderPayment.service_charge */
|
|
255
251
|
service_charge?: Record<string, unknown> | null;
|
|
256
|
-
/** 已计算的支付手续费。来源:OrderPayment.service_fee */
|
|
257
|
-
service_fee?: OrderMoneyString;
|
|
258
252
|
/** Wallet Pass 使用单位 */
|
|
259
253
|
wallet_pass_usage_unit?: unknown[] | null;
|
|
260
254
|
/** Wallet Pass 使用值 */
|
|
261
255
|
wallet_pass_use_value?: number | null;
|
|
262
|
-
/**
|
|
256
|
+
/** 元数据;含 unique_payment_number。来源:OrderPayment.metadata */
|
|
263
257
|
metadata?: OrderPaymentMetadata | null;
|
|
264
258
|
}
|
|
265
259
|
/**
|
|
@@ -419,8 +413,6 @@ export interface OrderData {
|
|
|
419
413
|
create_date?: string;
|
|
420
414
|
/** 本地待同步标记:1 表示需要后续同步到云端 */
|
|
421
415
|
need_sync?: 0 | 1 | number;
|
|
422
|
-
/** 本地草稿标记:1 表示仅为 POS 可恢复草稿,不代表已提交云端 */
|
|
423
|
-
is_draft_order?: 0 | 1 | number;
|
|
424
416
|
/** 兼容:部分场景仍使用顶层 total_amount */
|
|
425
417
|
total_amount?: OrderMoneyString | number;
|
|
426
418
|
/** 扩展字段(物流、标签等);使用 any 以便筛选与数据源扩展 */
|
|
@@ -2,14 +2,14 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
|
-
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData,
|
|
5
|
+
import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions } from '../../modules/Order/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
7
|
import type { Discount } from '../../modules/Discount/types';
|
|
8
8
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
9
9
|
export * from './types';
|
|
10
10
|
import { ProductList } from '../../modules/ProductList';
|
|
11
11
|
import { PaymentModule } from '../../modules/Payment';
|
|
12
|
-
import type { PaymentMethod } from '../../modules/Payment/types';
|
|
12
|
+
import type { PaymentMethod, RoundingResult } from '../../modules/Payment/types';
|
|
13
13
|
import type { SalesSummaryModule } from '../../modules/SalesSummary';
|
|
14
14
|
import type { ScheduleModule } from '../../modules/Schedule';
|
|
15
15
|
import { QuotationModule } from '../../modules/Quotation';
|
|
@@ -24,19 +24,6 @@ export interface BaseSalesState {
|
|
|
24
24
|
schedule?: ScheduleModule;
|
|
25
25
|
quotation?: QuotationModule;
|
|
26
26
|
}
|
|
27
|
-
export interface BaseSalesUpdateOrderPaymentOptions extends OrderPaymentUpdateOptions {
|
|
28
|
-
persistDraft?: boolean;
|
|
29
|
-
submitWhenPaid?: boolean;
|
|
30
|
-
forceSubmitIfPaid?: boolean;
|
|
31
|
-
/** 草稿恢复时,允许将新回调字段合并进已 paid 的支付项。 */
|
|
32
|
-
applyUpdatesWhenPaid?: boolean;
|
|
33
|
-
smallTicketDataFlag?: number;
|
|
34
|
-
}
|
|
35
|
-
export interface BaseSalesUpdateOrderPaymentResult extends OrderPaymentUpdateResult {
|
|
36
|
-
draftResult?: unknown;
|
|
37
|
-
draftError?: unknown;
|
|
38
|
-
syncResult?: SyncPaymentsToOrderResult<any>;
|
|
39
|
-
}
|
|
40
27
|
export type BaseSalesPrintLocalOrderReceiptParams = string | number;
|
|
41
28
|
export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
42
29
|
protected defaultName: string;
|
|
@@ -48,11 +35,6 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
48
35
|
protected store: BaseSalesState;
|
|
49
36
|
protected otherParams: Record<string, any>;
|
|
50
37
|
protected cacheId: string | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
53
|
-
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
54
|
-
*/
|
|
55
|
-
protected paymentNumberDevicePrefix: string | null;
|
|
56
38
|
/**
|
|
57
39
|
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
58
40
|
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
@@ -146,13 +128,6 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
146
128
|
*/
|
|
147
129
|
protected readSessionCacheData(): Record<string, any>;
|
|
148
130
|
protected getAppData<T>(key: string): T | undefined;
|
|
149
|
-
/**
|
|
150
|
-
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
151
|
-
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
152
|
-
*/
|
|
153
|
-
protected setPaymentNumberDevicePrefix(prefix: unknown): void;
|
|
154
|
-
private getPaymentNumberDevicePrefixSync;
|
|
155
|
-
private getPaymentNumberDevicePrefixAsync;
|
|
156
131
|
private syncAppDataToTempOrder;
|
|
157
132
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
158
133
|
destroy(): Promise<void>;
|
|
@@ -265,13 +240,6 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
265
240
|
confirmPendingVoucherPayments?: boolean;
|
|
266
241
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
267
242
|
}): Promise<T>;
|
|
268
|
-
saveSalesOrderDraft<T = any>(params?: {
|
|
269
|
-
platform?: string;
|
|
270
|
-
businessCode?: string;
|
|
271
|
-
channel?: string;
|
|
272
|
-
type?: string;
|
|
273
|
-
enhancePayload?: SubmitPayloadEnhancer;
|
|
274
|
-
}): Promise<T>;
|
|
275
243
|
submitTempOrderAsync<T = any>(params?: {
|
|
276
244
|
payments?: OrderPaymentSource[];
|
|
277
245
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
@@ -290,27 +258,16 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
290
258
|
private queueLatestAutoPaymentSync;
|
|
291
259
|
private scheduleQueuedAutoPaymentSyncFlush;
|
|
292
260
|
private flushQueuedAutoPaymentSync;
|
|
293
|
-
/**
|
|
294
|
-
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
295
|
-
*/
|
|
261
|
+
/** 追加单个支付项到当前订单。 */
|
|
296
262
|
addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
|
|
297
|
-
/**
|
|
298
|
-
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
299
|
-
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
300
|
-
*/
|
|
301
|
-
addOrderPaymentAsync(payment: OrderPaymentSource): Promise<OrderPaymentData[]>;
|
|
302
|
-
private addOrderPaymentWithDevicePrefix;
|
|
303
263
|
/** 更新当前订单中的指定支付项。 */
|
|
304
|
-
updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any
|
|
264
|
+
updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>): OrderPaymentData[];
|
|
305
265
|
/** 删除当前订单中的指定支付项。 */
|
|
306
266
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
307
267
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
308
268
|
updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
|
|
309
269
|
status?: 'paid' | 'payment_pending';
|
|
310
270
|
}): OrderPaymentData[];
|
|
311
|
-
updateVoucherOrderPaymentsAsync(payments: OrderPaymentSource[], options?: {
|
|
312
|
-
status?: 'paid' | 'payment_pending';
|
|
313
|
-
}): Promise<OrderPaymentData[]>;
|
|
314
271
|
confirmPendingVoucherPayments(): OrderPaymentData[];
|
|
315
272
|
discardPendingVoucherPayments(): OrderPaymentData[];
|
|
316
273
|
private getWalletProductList;
|
|
@@ -333,16 +290,15 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
333
290
|
getPaymentMethodsAsync(): Promise<PaymentMethod[]>;
|
|
334
291
|
/** 同步读取初始化时缓存的支付方式列表。 */
|
|
335
292
|
getPaymentMethods(): PaymentMethod[];
|
|
336
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
|
|
295
|
+
*
|
|
296
|
+
* 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
|
|
297
|
+
* otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
|
|
298
|
+
*/
|
|
337
299
|
roundAmount(params: {
|
|
338
300
|
amount: string | number;
|
|
339
|
-
|
|
340
|
-
rule?: 'standard_rounding' | 'standard_down' | 'always_up' | 'always_down' | string;
|
|
341
|
-
}): {
|
|
342
|
-
originalAmount: string;
|
|
343
|
-
roundedAmount: string;
|
|
344
|
-
roundingDifference: string;
|
|
345
|
-
};
|
|
301
|
+
}): Promise<RoundingResult>;
|
|
346
302
|
/**
|
|
347
303
|
* 发送支付链接。
|
|
348
304
|
*
|
|
@@ -359,7 +315,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
359
315
|
getQuotationCustomerScopeInfo(): BaseSalesQuotationCustomerScopeInfo;
|
|
360
316
|
shouldRecalculateProductBookingPricesForContextChange(params: BaseSalesPriceRecalculationContextChange): boolean;
|
|
361
317
|
calculateProductBookingPrices(paramsList: BaseSalesCalculateProductBookingPriceParams[]): Promise<BaseSalesProductBookingPriceResult[]>;
|
|
362
|
-
addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
318
|
+
addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
363
319
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
364
320
|
updateOrderProducts(paramsList: UpdateOrderProductParams[]): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
365
321
|
updateOrderProductQuantity(params: BaseSalesUpdateOrderProductQuantityParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
@@ -375,8 +331,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
375
331
|
* @example
|
|
376
332
|
* await baseSales.removeProductsFromOrder([identityA, identityB]);
|
|
377
333
|
*/
|
|
378
|
-
removeProductsFromOrder(identities: BaseSalesOrderProductIdentity[]): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
379
|
-
removeProductFromOrder(identity: BaseSalesOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
334
|
+
removeProductsFromOrder(identities: BaseSalesOrderProductIdentity[], options?: RemoveProductsFromOrderOptions): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
335
|
+
removeProductFromOrder(identity: BaseSalesOrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
380
336
|
/**
|
|
381
337
|
* 注入促销评估器到底层 OrderModule。
|
|
382
338
|
*
|
|
@@ -40,8 +40,6 @@ var import_decimal = __toESM(require("decimal.js"));
|
|
|
40
40
|
var import_lodash_es = require("lodash-es");
|
|
41
41
|
var import_types2 = require("../BookingByStep/types");
|
|
42
42
|
var import_utils = require("../../modules/Order/utils");
|
|
43
|
-
var import_payment_utils = require("../../modules/Order/payment-utils");
|
|
44
|
-
var import_payment_number = require("../../utils/payment-number");
|
|
45
43
|
var import_orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
46
44
|
var import_dayjs = __toESM(require("dayjs"));
|
|
47
45
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
@@ -79,11 +77,6 @@ function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
|
79
77
|
(discount == null ? void 0 : discount.isEditMode) || (discount == null ? void 0 : discount.isDisabled) || (discount == null ? void 0 : discount.order_discount_id) != null
|
|
80
78
|
);
|
|
81
79
|
}
|
|
82
|
-
function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
83
|
-
if (key === "products" || key === "bookings")
|
|
84
|
-
return "unique_identification_number";
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
80
|
var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
|
|
88
81
|
product: "order_detail_id",
|
|
89
82
|
booking: "schedule_event_id",
|
|
@@ -157,15 +150,6 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
|
|
|
157
150
|
return kind === "product" ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
|
|
158
151
|
}
|
|
159
152
|
function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
|
|
160
|
-
if (kind === "payment") {
|
|
161
|
-
return (0, import_payment_utils.mergeOrderPaymentListsByIdentity)(
|
|
162
|
-
currentValue,
|
|
163
|
-
incomingValue,
|
|
164
|
-
strategy === "preserve-local" ? { preserveUnmatchedExisting: true } : {
|
|
165
|
-
preserveUnmatchedExistingWhen: (payment) => (0, import_payment_utils.isIdentifiedPendingOrderPayment)(payment) || !(0, import_orderCollectionIdentity.getOrderCollectionPersistentId)("payment", payment)
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
153
|
const currentItems = (0, import_orderCollectionIdentity.normalizeOrderCollection)(kind, currentValue, {
|
|
170
154
|
ensureUid: false
|
|
171
155
|
}).items;
|
|
@@ -225,35 +209,6 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
|
225
209
|
}
|
|
226
210
|
return normalizedRecord;
|
|
227
211
|
}
|
|
228
|
-
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
229
|
-
var _a;
|
|
230
|
-
const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a[metadataKey]) ?? (item == null ? void 0 : item[metadataKey]);
|
|
231
|
-
if (uid === void 0 || uid === null || uid === "")
|
|
232
|
-
return null;
|
|
233
|
-
return String(uid);
|
|
234
|
-
}
|
|
235
|
-
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
236
|
-
const result = [];
|
|
237
|
-
const indexByUid = /* @__PURE__ */ new Map();
|
|
238
|
-
const appendOrReplaceByUid = (item) => {
|
|
239
|
-
const clonedItem = (0, import_lodash_es.cloneDeep)(item);
|
|
240
|
-
const uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
|
|
241
|
-
if (!uid) {
|
|
242
|
-
result.push(clonedItem);
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
const existingIndex = indexByUid.get(uid);
|
|
246
|
-
if (existingIndex !== void 0) {
|
|
247
|
-
result[existingIndex] = clonedItem;
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
indexByUid.set(uid, result.length);
|
|
251
|
-
result.push(clonedItem);
|
|
252
|
-
};
|
|
253
|
-
currentValue.forEach(appendOrReplaceByUid);
|
|
254
|
-
loadedValue.forEach(appendOrReplaceByUid);
|
|
255
|
-
return result;
|
|
256
|
-
}
|
|
257
212
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
258
213
|
const normalizedLoadedRecord = normalizeBaseSalesRecordCollections(
|
|
259
214
|
loadedRecord || {},
|
|
@@ -282,15 +237,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
282
237
|
);
|
|
283
238
|
}
|
|
284
239
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
285
|
-
if (key === "payments" || key === "payment") {
|
|
286
|
-
return (0, import_payment_utils.mergeOrderPaymentListsByIdentity)(currentValue, loadedValue, {
|
|
287
|
-
preserveUnmatchedExisting: true
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
const metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
291
|
-
if (metadataKey) {
|
|
292
|
-
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
293
|
-
}
|
|
294
240
|
return [
|
|
295
241
|
...(0, import_lodash_es.cloneDeep)(currentValue),
|
|
296
242
|
...(0, import_lodash_es.cloneDeep)(loadedValue)
|
|
@@ -309,18 +255,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
309
255
|
(0, import_orderCollectionIdentity.applyOrderCollectionUidRemaps)(mergedRecord, uidRemaps)
|
|
310
256
|
);
|
|
311
257
|
}
|
|
312
|
-
function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
313
|
-
if (!sourceRecord || typeof sourceRecord !== "object")
|
|
314
|
-
return sourceRecord;
|
|
315
|
-
const record = { ...sourceRecord };
|
|
316
|
-
if (Array.isArray(sourceRecord.payments)) {
|
|
317
|
-
record.payments = sourceRecord.payments.filter((payment) => !(0, import_payment_utils.isPendingOrderPayment)(payment));
|
|
318
|
-
}
|
|
319
|
-
if (Array.isArray(sourceRecord.payment)) {
|
|
320
|
-
record.payment = sourceRecord.payment.filter((payment) => !(0, import_payment_utils.isPendingOrderPayment)(payment));
|
|
321
|
-
}
|
|
322
|
-
return record;
|
|
323
|
-
}
|
|
324
258
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
325
259
|
constructor(name, version) {
|
|
326
260
|
super(name, version);
|
|
@@ -332,11 +266,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
332
266
|
order: void 0
|
|
333
267
|
};
|
|
334
268
|
this.otherParams = {};
|
|
335
|
-
/**
|
|
336
|
-
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
337
|
-
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
338
|
-
*/
|
|
339
|
-
this.paymentNumberDevicePrefix = null;
|
|
340
269
|
// 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
|
|
341
270
|
this.currentSalesDetail = null;
|
|
342
271
|
this.discountConfigCacheKey = null;
|
|
@@ -867,27 +796,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
867
796
|
const coreData = (_f = (_d = (_c = app == null ? void 0 : app.models) == null ? void 0 : _c.getStore) == null ? void 0 : (_e = _d.call(_c)).getDataByModel) == null ? void 0 : _f.call(_e, "core", "core");
|
|
868
797
|
return coreData == null ? void 0 : coreData[key];
|
|
869
798
|
}
|
|
870
|
-
/**
|
|
871
|
-
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
872
|
-
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
873
|
-
*/
|
|
874
|
-
setPaymentNumberDevicePrefix(prefix) {
|
|
875
|
-
const normalized = String(prefix ?? "").trim();
|
|
876
|
-
this.paymentNumberDevicePrefix = normalized || null;
|
|
877
|
-
}
|
|
878
|
-
getPaymentNumberDevicePrefixSync() {
|
|
879
|
-
if (!this.appPlugin)
|
|
880
|
-
return "LOCAL";
|
|
881
|
-
return (0, import_payment_number.resolvePaymentNumberDevicePrefixFromDeviceId)((key) => this.getAppData(key));
|
|
882
|
-
}
|
|
883
|
-
getPaymentNumberDevicePrefixAsync() {
|
|
884
|
-
if (!this.appPlugin)
|
|
885
|
-
return Promise.resolve("LOCAL");
|
|
886
|
-
if (this.paymentNumberDevicePrefix) {
|
|
887
|
-
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
888
|
-
}
|
|
889
|
-
return (0, import_payment_number.resolvePaymentNumberDevicePrefix)((key) => this.getAppData(key));
|
|
890
|
-
}
|
|
891
799
|
syncAppDataToTempOrder(tempOrder) {
|
|
892
800
|
const isPriceIncludeTax = this.getAppData("is_price_include_tax");
|
|
893
801
|
const taxCountryCode = this.getAppData("tax_country_code");
|
|
@@ -928,7 +836,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
928
836
|
var _a, _b;
|
|
929
837
|
this.core = core;
|
|
930
838
|
this.initializeOptions = options || {};
|
|
931
|
-
this.paymentNumberDevicePrefix = null;
|
|
932
839
|
this.otherParams = options.otherParams || {};
|
|
933
840
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
934
841
|
this.reusedSharedSubModuleNames.clear();
|
|
@@ -990,7 +897,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
990
897
|
}
|
|
991
898
|
});
|
|
992
899
|
this.currentSalesDetail = null;
|
|
993
|
-
this.paymentNumberDevicePrefix = null;
|
|
994
900
|
this.queuedServerOrderChanges = [];
|
|
995
901
|
this.salesDetailLoadSequence += 1;
|
|
996
902
|
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
@@ -1024,16 +930,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1024
930
|
const message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || `加载销售详情失败: ${lookup}`;
|
|
1025
931
|
throw new Error(message);
|
|
1026
932
|
}
|
|
1027
|
-
const remoteRecord =
|
|
1028
|
-
preloadedSalesDetail ?? loadedRecord.data
|
|
1029
|
-
);
|
|
933
|
+
const remoteRecord = preloadedSalesDetail ?? loadedRecord.data;
|
|
1030
934
|
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1031
|
-
const
|
|
935
|
+
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(
|
|
1032
936
|
currentTempOrder,
|
|
1033
937
|
remoteRecord,
|
|
1034
938
|
"preserve-local"
|
|
1035
939
|
) : remoteRecord;
|
|
1036
|
-
const record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
|
|
1037
940
|
return await this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1038
941
|
} finally {
|
|
1039
942
|
this.salesDetailLoadInFlightCount = Math.max(
|
|
@@ -1824,20 +1727,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1824
1727
|
};
|
|
1825
1728
|
return this.store.order.submitTempOrder(submitParams);
|
|
1826
1729
|
}
|
|
1827
|
-
async saveSalesOrderDraft(params) {
|
|
1828
|
-
var _a, _b, _c, _d;
|
|
1829
|
-
if (!this.store.order) {
|
|
1830
|
-
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1831
|
-
}
|
|
1832
|
-
return this.store.order.saveTempOrderAsDraft({
|
|
1833
|
-
cacheId: this.cacheId,
|
|
1834
|
-
platform: (params == null ? void 0 : params.platform) ?? ((_a = this.otherParams) == null ? void 0 : _a.platform),
|
|
1835
|
-
businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
1836
|
-
channel: (params == null ? void 0 : params.channel) ?? this.getSubmitOrderSalesChannel(),
|
|
1837
|
-
type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
|
|
1838
|
-
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
1730
|
async submitTempOrderAsync(params) {
|
|
1842
1731
|
var _a, _b, _c, _d;
|
|
1843
1732
|
if (!this.store.order) {
|
|
@@ -2038,29 +1927,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2038
1927
|
}
|
|
2039
1928
|
}
|
|
2040
1929
|
}
|
|
2041
|
-
/**
|
|
2042
|
-
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
2043
|
-
*/
|
|
1930
|
+
/** 追加单个支付项到当前订单。 */
|
|
2044
1931
|
addOrderPayment(payment) {
|
|
2045
|
-
const hasPaymentNumber = String(
|
|
2046
|
-
payment.payment_number || ""
|
|
2047
|
-
).trim() !== "";
|
|
2048
|
-
return this.addOrderPaymentWithDevicePrefix(
|
|
2049
|
-
payment,
|
|
2050
|
-
hasPaymentNumber ? "LOCAL" : this.getPaymentNumberDevicePrefixSync()
|
|
2051
|
-
);
|
|
2052
|
-
}
|
|
2053
|
-
/**
|
|
2054
|
-
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
2055
|
-
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
2056
|
-
*/
|
|
2057
|
-
async addOrderPaymentAsync(payment) {
|
|
2058
|
-
const paymentRecord = payment;
|
|
2059
|
-
const hasPaymentNumber = String(paymentRecord.payment_number || "").trim() !== "";
|
|
2060
|
-
const devicePrefix = hasPaymentNumber ? "LOCAL" : await this.getPaymentNumberDevicePrefixAsync();
|
|
2061
|
-
return this.addOrderPaymentWithDevicePrefix(payment, devicePrefix);
|
|
2062
|
-
}
|
|
2063
|
-
addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
2064
1932
|
var _a;
|
|
2065
1933
|
if (!this.store.order)
|
|
2066
1934
|
throw new Error("order 模块未初始化");
|
|
@@ -2077,26 +1945,21 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2077
1945
|
if (shopWalletPassId !== void 0 && shopWalletPassId !== null) {
|
|
2078
1946
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
2079
1947
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
import_utils.createUuidV4
|
|
2084
|
-
);
|
|
1948
|
+
if (!metadata.unique_payment_number) {
|
|
1949
|
+
metadata.unique_payment_number = (0, import_utils.createUuidV4)();
|
|
1950
|
+
}
|
|
2085
1951
|
const paymentTimestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
2086
1952
|
const paymentTime = paymentRecord.payment_time ?? paymentTimestamp;
|
|
2087
1953
|
const createdAt = paymentRecord.created_at ?? paymentTimestamp;
|
|
2088
1954
|
const serviceCharge = paymentRecord.service_charge && typeof paymentRecord.service_charge === "object" ? paymentRecord.service_charge : null;
|
|
2089
1955
|
const calculatedServiceFee = serviceCharge ? new import_decimal.default(paymentRecord.origin_amount ?? paymentRecord.amount ?? 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : void 0;
|
|
2090
1956
|
const payments = this.store.order.addOrderPayment({
|
|
2091
|
-
...
|
|
1957
|
+
...paymentRecord,
|
|
2092
1958
|
...calculatedServiceFee !== void 0 ? { service_fee: calculatedServiceFee } : {},
|
|
2093
1959
|
metadata,
|
|
2094
1960
|
payment_time: paymentTime,
|
|
2095
1961
|
created_at: createdAt
|
|
2096
1962
|
});
|
|
2097
|
-
if (paymentRecord.status === "payment_pending") {
|
|
2098
|
-
return payments;
|
|
2099
|
-
}
|
|
2100
1963
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2101
1964
|
const syncState = this.store.order.getOrderSyncState();
|
|
2102
1965
|
if (amountSnapshot) {
|
|
@@ -2118,73 +1981,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2118
1981
|
return payments;
|
|
2119
1982
|
}
|
|
2120
1983
|
/** 更新当前订单中的指定支付项。 */
|
|
2121
|
-
|
|
2122
|
-
var _a, _b, _c;
|
|
1984
|
+
updateOrderPayment(paymentIdentity, updates) {
|
|
2123
1985
|
if (!this.store.order)
|
|
2124
1986
|
throw new Error("order 模块未初始化");
|
|
2125
|
-
|
|
2126
|
-
const previousMatch = (0, import_payment_utils.resolveOrderPaymentIdentity)(
|
|
2127
|
-
this.store.order.getOrderPayments(),
|
|
2128
|
-
paymentIdentity,
|
|
2129
|
-
matchMode
|
|
2130
|
-
);
|
|
2131
|
-
const previousPayment = previousMatch == null ? void 0 : previousMatch.payment;
|
|
2132
|
-
if ((previousPayment == null ? void 0 : previousPayment.status) === "paid" && !options.applyUpdatesWhenPaid) {
|
|
2133
|
-
const currentPayments = this.store.order.getOrderPayments();
|
|
2134
|
-
let syncResult2;
|
|
2135
|
-
if (options.submitWhenPaid && options.forceSubmitIfPaid) {
|
|
2136
|
-
syncResult2 = await this.syncPaymentsToOrder({
|
|
2137
|
-
payments: currentPayments,
|
|
2138
|
-
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
2139
|
-
submitWhenPaid: true,
|
|
2140
|
-
smallTicketDataFlag: options.smallTicketDataFlag ?? 1
|
|
2141
|
-
});
|
|
2142
|
-
}
|
|
2143
|
-
return {
|
|
2144
|
-
updated: false,
|
|
2145
|
-
payment: previousPayment,
|
|
2146
|
-
payments: currentPayments,
|
|
2147
|
-
summary: ((_a = this.store.order.getOrderAmountSnapshot()) == null ? void 0 : _a.summary) || null,
|
|
2148
|
-
...syncResult2 !== void 0 ? { syncResult: syncResult2 } : {}
|
|
2149
|
-
};
|
|
2150
|
-
}
|
|
2151
|
-
const result = await this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
2152
|
-
matchBy: matchMode
|
|
2153
|
-
});
|
|
2154
|
-
let draftResult;
|
|
2155
|
-
let draftError;
|
|
2156
|
-
if (options.persistDraft !== false) {
|
|
2157
|
-
try {
|
|
2158
|
-
draftResult = await this.saveSalesOrderDraft();
|
|
2159
|
-
} catch (error) {
|
|
2160
|
-
draftError = error;
|
|
2161
|
-
this.logError("updateOrderPayment: 保存支付草稿失败", {
|
|
2162
|
-
paymentIdentity,
|
|
2163
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2164
|
-
});
|
|
2165
|
-
if (!options.submitWhenPaid)
|
|
2166
|
-
throw error;
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
const becamePaid = (previousPayment == null ? void 0 : previousPayment.status) !== "paid" && ((_b = result.payment) == null ? void 0 : _b.status) === "paid";
|
|
2170
|
-
const shouldSubmit = Boolean(
|
|
2171
|
-
options.submitWhenPaid && ((_c = result.payment) == null ? void 0 : _c.status) === "paid" && (becamePaid || options.forceSubmitIfPaid)
|
|
2172
|
-
);
|
|
2173
|
-
let syncResult;
|
|
2174
|
-
if (shouldSubmit) {
|
|
2175
|
-
syncResult = await this.syncPaymentsToOrder({
|
|
2176
|
-
payments: result.payments,
|
|
2177
|
-
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
2178
|
-
submitWhenPaid: true,
|
|
2179
|
-
smallTicketDataFlag: options.smallTicketDataFlag ?? 1
|
|
2180
|
-
});
|
|
2181
|
-
}
|
|
2182
|
-
return {
|
|
2183
|
-
...result,
|
|
2184
|
-
...draftResult !== void 0 ? { draftResult } : {},
|
|
2185
|
-
...draftError !== void 0 ? { draftError } : {},
|
|
2186
|
-
...syncResult !== void 0 ? { syncResult } : {}
|
|
2187
|
-
};
|
|
1987
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates);
|
|
2188
1988
|
}
|
|
2189
1989
|
/** 删除当前订单中的指定支付项。 */
|
|
2190
1990
|
deleteOrderPayment(paymentIdentity) {
|
|
@@ -2198,11 +1998,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2198
1998
|
throw new Error("order 模块未初始化");
|
|
2199
1999
|
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
2200
2000
|
}
|
|
2201
|
-
async updateVoucherOrderPaymentsAsync(payments, options) {
|
|
2202
|
-
if (!this.store.order)
|
|
2203
|
-
throw new Error("order 模块未初始化");
|
|
2204
|
-
return this.store.order.updateVoucherOrderPaymentsAsync(payments, options);
|
|
2205
|
-
}
|
|
2206
2001
|
confirmPendingVoucherPayments() {
|
|
2207
2002
|
if (!this.store.order)
|
|
2208
2003
|
throw new Error("order 模块未初始化");
|
|
@@ -2349,28 +2144,33 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2349
2144
|
getPaymentMethods() {
|
|
2350
2145
|
return [...this.paymentMethodsCache];
|
|
2351
2146
|
}
|
|
2352
|
-
/**
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2147
|
+
/**
|
|
2148
|
+
* 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
|
|
2149
|
+
*
|
|
2150
|
+
* 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
|
|
2151
|
+
* otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
|
|
2152
|
+
*/
|
|
2153
|
+
async roundAmount(params) {
|
|
2154
|
+
var _a, _b, _c;
|
|
2155
|
+
const amount = params.amount;
|
|
2156
|
+
const cashManualPayment = this.paymentMethodsCache.find(
|
|
2157
|
+
(paymentMethod) => paymentMethod.code === "CASHMANUAL"
|
|
2158
|
+
);
|
|
2159
|
+
if (!((_a = cashManualPayment == null ? void 0 : cashManualPayment.metadata) == null ? void 0 : _a.order_rounding_switch)) {
|
|
2160
|
+
return {
|
|
2161
|
+
originalAmount: amount.toString(),
|
|
2162
|
+
roundedAmount: amount.toString(),
|
|
2163
|
+
roundingDifference: "0.00"
|
|
2164
|
+
};
|
|
2367
2165
|
}
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2166
|
+
if (!this.payment) {
|
|
2167
|
+
throw new Error("payment 模块未初始化");
|
|
2168
|
+
}
|
|
2169
|
+
return this.payment.roundAmountAsync(
|
|
2170
|
+
amount,
|
|
2171
|
+
(_b = this.otherParams.order_rounding_setting) == null ? void 0 : _b.interval,
|
|
2172
|
+
(_c = this.otherParams.order_rounding_setting) == null ? void 0 : _c.type
|
|
2173
|
+
);
|
|
2374
2174
|
}
|
|
2375
2175
|
/**
|
|
2376
2176
|
* 发送支付链接。
|
|
@@ -2540,11 +2340,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2540
2340
|
});
|
|
2541
2341
|
});
|
|
2542
2342
|
}
|
|
2543
|
-
async addProductToOrder(product, booking) {
|
|
2343
|
+
async addProductToOrder(product, booking, options) {
|
|
2544
2344
|
try {
|
|
2545
2345
|
if (!this.store.order)
|
|
2546
2346
|
throw new Error("order 模块未初始化");
|
|
2547
|
-
const products = await this.store.order.addProductToOrder(product, booking);
|
|
2347
|
+
const products = await this.store.order.addProductToOrder(product, booking, options);
|
|
2548
2348
|
return products;
|
|
2549
2349
|
} catch (error) {
|
|
2550
2350
|
throw error;
|
|
@@ -2620,17 +2420,17 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2620
2420
|
* @example
|
|
2621
2421
|
* await baseSales.removeProductsFromOrder([identityA, identityB]);
|
|
2622
2422
|
*/
|
|
2623
|
-
async removeProductsFromOrder(identities) {
|
|
2423
|
+
async removeProductsFromOrder(identities, options) {
|
|
2624
2424
|
try {
|
|
2625
2425
|
if (!this.store.order)
|
|
2626
2426
|
throw new Error("order 模块未初始化");
|
|
2627
|
-
return await this.store.order.removeProductsFromOrder(identities);
|
|
2427
|
+
return await this.store.order.removeProductsFromOrder(identities, options);
|
|
2628
2428
|
} catch (error) {
|
|
2629
2429
|
throw error;
|
|
2630
2430
|
}
|
|
2631
2431
|
}
|
|
2632
|
-
async removeProductFromOrder(identity) {
|
|
2633
|
-
return this.removeProductsFromOrder([identity]);
|
|
2432
|
+
async removeProductFromOrder(identity, options) {
|
|
2433
|
+
return this.removeProductsFromOrder([identity], options);
|
|
2634
2434
|
}
|
|
2635
2435
|
// ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
|
|
2636
2436
|
/**
|
|
@@ -78,7 +78,6 @@ export interface CartPromotionEvaluator {
|
|
|
78
78
|
}>;
|
|
79
79
|
hasApplicableStrategy: boolean;
|
|
80
80
|
}>;
|
|
81
|
-
getStrategyConfigs?: () => unknown[];
|
|
82
81
|
}
|
|
83
82
|
/** 单个赠品减量项 */
|
|
84
83
|
export interface GiftReduceItem {
|
|
@@ -268,8 +267,7 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
|
|
|
268
267
|
* 处理购物车的促销计算与赠品差异化。
|
|
269
268
|
*
|
|
270
269
|
* 流程:
|
|
271
|
-
* 1. 分离 main / gift / edit-product
|
|
272
|
-
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
270
|
+
* 1. 分离 main / gift / edit-product 三类(带 `booking_id` 的编辑态商品不参与促销)
|
|
273
271
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
274
272
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
275
273
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|