@pisell/pisellos 2.2.272 → 2.2.274
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/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -7
- 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/index.js +9 -0
- 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 +16 -12
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +0 -8
- package/dist/modules/Order/index.d.ts +12 -31
- 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 +39 -55
- package/dist/modules/SalesSummary/utils.js +7 -1
- 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 +25 -59
- package/dist/solution/BaseSales/index.js +490 -767
- 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.d.ts +5 -21
- package/dist/solution/BookingTicket/index.js +49 -126
- 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/dist/types/index.d.ts +0 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -4
- 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 +49 -0
- 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 +5 -2
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +0 -5
- package/lib/modules/Order/index.d.ts +12 -31
- 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 +22 -41
- package/lib/modules/SalesSummary/utils.js +5 -1
- 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 +25 -59
- package/lib/solution/BaseSales/index.js +79 -246
- 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.d.ts +5 -21
- package/lib/solution/BookingTicket/index.js +8 -59
- 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/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- 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
|
@@ -319,6 +319,24 @@ export interface ReplaceTempOrderOptions {
|
|
|
319
319
|
saveDraft?: boolean;
|
|
320
320
|
}
|
|
321
321
|
export type AddProductBookingInput = Record<string, any>;
|
|
322
|
+
/**
|
|
323
|
+
* 添加商品行时的顺序控制。
|
|
324
|
+
* 默认追加到 products 尾部;预约数量同步可插入到既有预约组的最新行之后,
|
|
325
|
+
* 避免步进器修改数量改变该组展示位置。
|
|
326
|
+
*/
|
|
327
|
+
export interface AddProductToOrderOptions {
|
|
328
|
+
insertAfterProductUid?: string;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 删除商品后的可选位置保持策略。
|
|
332
|
+
* 预约合并行减量时仍删除最新真实行,再把剩余代表行移动到被删除代表行原位置。
|
|
333
|
+
*/
|
|
334
|
+
export interface RemoveProductsFromOrderOptions {
|
|
335
|
+
preserveDisplayPosition?: {
|
|
336
|
+
remainingProductUid: string;
|
|
337
|
+
anchorProductUid: string;
|
|
338
|
+
};
|
|
339
|
+
}
|
|
322
340
|
/** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 unique_identification_number / 选项指纹等 */
|
|
323
341
|
export interface UpdateOrderProductParams {
|
|
324
342
|
product_id: number | null;
|
|
@@ -468,8 +486,6 @@ export interface SubmitSalesOrderParams {
|
|
|
468
486
|
export interface PaymentItemData {
|
|
469
487
|
/** 当前支付项的唯一 ID */
|
|
470
488
|
uuid: string;
|
|
471
|
-
/** 支付项稳定唯一号 */
|
|
472
|
-
payment_number?: string;
|
|
473
489
|
/** 当前支付方式付出去多少钱 */
|
|
474
490
|
amount: string;
|
|
475
491
|
/** 支付类型代码 */
|
|
@@ -492,22 +508,13 @@ export interface PaymentItemData {
|
|
|
492
508
|
export interface OrderPaymentMetadata {
|
|
493
509
|
rounding_rule?: Record<string, any>;
|
|
494
510
|
unique_payment_number?: string;
|
|
495
|
-
/** 刷卡机设备快照;OS 不解析内部字段,仅透传并持久化 */
|
|
496
|
-
card_reader_snapshot?: Record<string, unknown>;
|
|
497
511
|
shop_wallet_pass_id?: number | string;
|
|
498
512
|
actual_paid_amount?: number | string;
|
|
499
513
|
change_given_amount?: number | string;
|
|
500
|
-
transactions?: OrderPaymentTransaction[];
|
|
501
514
|
[key: string]: any;
|
|
502
515
|
}
|
|
503
|
-
export interface OrderPaymentTransaction {
|
|
504
|
-
number: string;
|
|
505
|
-
status: 'success' | 'fail';
|
|
506
|
-
}
|
|
507
516
|
export interface OrderPaymentData {
|
|
508
517
|
order_payment_id?: number | string;
|
|
509
|
-
/** 支付项稳定唯一号;历史支付项允许缺失 */
|
|
510
|
-
payment_number?: string;
|
|
511
518
|
amount: string;
|
|
512
519
|
code: string;
|
|
513
520
|
custom_payment_id: number;
|
|
@@ -534,15 +541,6 @@ export interface OrderPaymentData {
|
|
|
534
541
|
created_at?: string;
|
|
535
542
|
updated_at?: string;
|
|
536
543
|
}
|
|
537
|
-
export interface OrderPaymentUpdateOptions {
|
|
538
|
-
matchBy?: 'payment_number' | 'compat' | 'legacy';
|
|
539
|
-
}
|
|
540
|
-
export interface OrderPaymentUpdateResult {
|
|
541
|
-
updated: boolean;
|
|
542
|
-
payment: OrderPaymentData | null;
|
|
543
|
-
payments: OrderPaymentData[];
|
|
544
|
-
summary: OrderSummary | null;
|
|
545
|
-
}
|
|
546
544
|
export type OrderPaymentSource = PaymentItem | OrderPaymentData | Record<string, any>;
|
|
547
545
|
export interface MapOrderPaymentsOptions {
|
|
548
546
|
includeVoided?: boolean;
|
|
@@ -693,14 +691,6 @@ export interface OrderModuleAPI {
|
|
|
693
691
|
channel?: string;
|
|
694
692
|
type?: string;
|
|
695
693
|
}) => OrderSubmitPayload;
|
|
696
|
-
saveTempOrderAsDraft: <T = any>(params?: {
|
|
697
|
-
cacheId?: string;
|
|
698
|
-
platform?: string;
|
|
699
|
-
businessCode?: string;
|
|
700
|
-
channel?: string;
|
|
701
|
-
type?: string;
|
|
702
|
-
enhancePayload?: SubmitPayloadEnhancer;
|
|
703
|
-
}) => Promise<T>;
|
|
704
694
|
applyLocalPrintOrderNumbers: (order?: Record<string, any> | null) => Promise<OrderTempOrder>;
|
|
705
695
|
getTempOrderNote: () => string;
|
|
706
696
|
updateTempOrderNote: {
|
|
@@ -713,15 +703,15 @@ export interface OrderModuleAPI {
|
|
|
713
703
|
updateTempOrderCustomer: (customer: UpdateTempOrderCustomerInput) => OrderSnapshot['customer'];
|
|
714
704
|
updateTempOrderBuzzer: (buzzer: string) => string;
|
|
715
705
|
updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
|
|
716
|
-
addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput) => Promise<OrderProduct[]>;
|
|
706
|
+
addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions) => Promise<OrderProduct[]>;
|
|
717
707
|
updateOrderProduct: (params: UpdateOrderProductParams) => Promise<OrderProduct[]>;
|
|
718
708
|
/** 批量更新购物车行,末尾仅触发一次促销重算与 summary 刷新 */
|
|
719
709
|
updateOrderProducts: (paramsList: UpdateOrderProductParams[]) => Promise<OrderProduct[]>;
|
|
720
710
|
updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<OrderProduct[]>;
|
|
721
711
|
updateOrderBooking: (params: UpdateOrderBookingParams) => any[];
|
|
722
|
-
removeProductFromOrder: (identity: OrderProductIdentity) => Promise<OrderProduct[]>;
|
|
712
|
+
removeProductFromOrder: (identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
|
|
723
713
|
/** 批量删除购物车行,末尾仅触发一次促销重算与 summary 刷新 */
|
|
724
|
-
removeProductsFromOrder: (identities: OrderProductIdentity[]) => Promise<OrderProduct[]>;
|
|
714
|
+
removeProductsFromOrder: (identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
|
|
725
715
|
/** @deprecated no-op;OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
726
716
|
persistTempOrder: () => void;
|
|
727
717
|
/**
|
|
@@ -758,15 +748,11 @@ export interface OrderModuleAPI {
|
|
|
758
748
|
getOrderPayments: () => OrderPaymentData[];
|
|
759
749
|
setOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
|
|
760
750
|
addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
|
|
761
|
-
|
|
762
|
-
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>, options?: OrderPaymentUpdateOptions) => Promise<OrderPaymentUpdateResult>;
|
|
751
|
+
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
|
|
763
752
|
deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
|
|
764
753
|
updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
|
|
765
754
|
status?: 'paid' | 'payment_pending';
|
|
766
755
|
}) => OrderPaymentData[];
|
|
767
|
-
updateVoucherOrderPaymentsAsync: (payments: OrderPaymentSource[], options?: {
|
|
768
|
-
status?: 'paid' | 'payment_pending';
|
|
769
|
-
}) => Promise<OrderPaymentData[]>;
|
|
770
756
|
confirmPendingVoucherPayments: (options?: {
|
|
771
757
|
persist?: boolean;
|
|
772
758
|
recalculateSummary?: boolean;
|
|
@@ -220,9 +220,6 @@ function normalizeOrderCollection(kind, items, options) {
|
|
|
220
220
|
const persistentId = getOrderCollectionPersistentId(kind, item);
|
|
221
221
|
let uid = getOrderCollectionUid(kind, item);
|
|
222
222
|
if (!uid) {
|
|
223
|
-
if (kind === "payment" && !isBlankOrderCollectionIdentity(item == null ? void 0 : item.payment_number)) {
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
223
|
uid = persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
|
|
227
224
|
item = setOrderCollectionUid(kind, item, uid);
|
|
228
225
|
result[index] = item;
|
|
@@ -444,12 +444,7 @@ function resolveEffectivePerUnitDiscount(product) {
|
|
|
444
444
|
(sum, discount) => sum + Number((discount == null ? void 0 : discount.amount) || 0),
|
|
445
445
|
0
|
|
446
446
|
);
|
|
447
|
-
const hasPromoDiscountItem = discountList.some(
|
|
448
|
-
(item) => {
|
|
449
|
-
var _a, _b;
|
|
450
|
-
return (item == null ? void 0 : item.type) === "promotion" || (item == null ? void 0 : item.type) === "product" && ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
451
|
-
}
|
|
452
|
-
);
|
|
447
|
+
const hasPromoDiscountItem = discountList.some((item) => (item == null ? void 0 : item.type) === "promotion");
|
|
453
448
|
if (hasPromoDiscountItem)
|
|
454
449
|
return fromList;
|
|
455
450
|
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
@@ -970,9 +965,6 @@ function buildSubmitPayload(params) {
|
|
|
970
965
|
...tempOrderRest,
|
|
971
966
|
customer_id: tempOrder.customer_id ?? 1,
|
|
972
967
|
customer_name: tempOrder.customer_name || "Walk-In",
|
|
973
|
-
country_calling_code: String(tempOrder.country_calling_code ?? ""),
|
|
974
|
-
phone: String(tempOrder.phone ?? ""),
|
|
975
|
-
email: String(tempOrder.email ?? ""),
|
|
976
968
|
order_number: tempOrder.order_number ?? null,
|
|
977
969
|
shop_order_number: tempOrder.shop_order_number ?? null,
|
|
978
970
|
shop_full_order_number: tempOrder.shop_full_order_number ?? null,
|
|
@@ -1028,7 +1020,9 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1028
1020
|
const item = paymentItem;
|
|
1029
1021
|
const customPaymentId = item.custom_payment_id ?? item.id;
|
|
1030
1022
|
const metadata = item.metadata && typeof item.metadata === "object" ? { ...item.metadata } : {};
|
|
1031
|
-
|
|
1023
|
+
if (item.uuid && !metadata.unique_payment_number) {
|
|
1024
|
+
metadata.unique_payment_number = String(item.uuid);
|
|
1025
|
+
}
|
|
1032
1026
|
const paymentMetadataKeys = [
|
|
1033
1027
|
"rounding_rule",
|
|
1034
1028
|
"shop_wallet_pass_id",
|
|
@@ -1045,7 +1039,6 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1045
1039
|
const createdAt = item.created_at ?? timestamp;
|
|
1046
1040
|
return {
|
|
1047
1041
|
...item.order_payment_id !== void 0 ? { order_payment_id: item.order_payment_id } : {},
|
|
1048
|
-
...paymentNumber !== void 0 && paymentNumber !== null && paymentNumber !== "" ? { payment_number: String(paymentNumber) } : {},
|
|
1049
1042
|
amount: String(item.amount ?? "0.00"),
|
|
1050
1043
|
code: String(item.code || ""),
|
|
1051
1044
|
custom_payment_id: Number(customPaymentId ?? 0),
|
|
@@ -20,7 +20,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
20
20
|
protected defaultVersion: string;
|
|
21
21
|
request: RequestPlugin;
|
|
22
22
|
private app;
|
|
23
|
-
private appPlugin;
|
|
24
23
|
private store;
|
|
25
24
|
window: WindowPlugin;
|
|
26
25
|
private dbManager;
|
|
@@ -41,7 +40,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
41
40
|
* paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
|
|
42
41
|
*/
|
|
43
42
|
updateOtherParams(params: Record<string, any>): void;
|
|
44
|
-
private getPaymentNumberAppData;
|
|
45
43
|
/**
|
|
46
44
|
* 记录信息日志
|
|
47
45
|
*/
|
|
@@ -31,9 +31,6 @@ var import_cash = require("./cash");
|
|
|
31
31
|
var import_eftpos = require("./eftpos");
|
|
32
32
|
var import_walletpass = require("./walletpass");
|
|
33
33
|
var import_decimal = require("decimal.js");
|
|
34
|
-
var import_payment_utils = require("../Order/payment-utils");
|
|
35
|
-
var import_utils2 = require("../Order/utils");
|
|
36
|
-
var import_payment_number = require("../../utils/payment-number");
|
|
37
34
|
__reExport(Payment_exports, require("./types"), module.exports);
|
|
38
35
|
function formatAmount(amount) {
|
|
39
36
|
try {
|
|
@@ -115,15 +112,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
115
112
|
this.store = options.store;
|
|
116
113
|
this.otherParams = options.otherParams || {};
|
|
117
114
|
this.request = core.getPlugin("request");
|
|
118
|
-
|
|
115
|
+
const appPlugin = core.getPlugin("app");
|
|
119
116
|
this.window = core.getPlugin("window");
|
|
120
117
|
if (!this.request) {
|
|
121
118
|
throw new Error("支付模块需要 request 插件支持");
|
|
122
119
|
}
|
|
123
|
-
if (!
|
|
120
|
+
if (!appPlugin) {
|
|
124
121
|
throw new Error("支付模块需要 app 插件支持");
|
|
125
122
|
}
|
|
126
|
-
this.app =
|
|
123
|
+
this.app = appPlugin.getApp();
|
|
127
124
|
this.dbManager = this.app.dbManager;
|
|
128
125
|
this.logger = this.app.logger;
|
|
129
126
|
this.registerNetworkHandlers();
|
|
@@ -139,14 +136,6 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
139
136
|
updateOtherParams(params) {
|
|
140
137
|
this.otherParams = params || {};
|
|
141
138
|
}
|
|
142
|
-
getPaymentNumberAppData(key) {
|
|
143
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
144
|
-
const getData = (_b = (_a = this.appPlugin) == null ? void 0 : _a.getData) == null ? void 0 : _b.call(_a);
|
|
145
|
-
if (typeof getData === "function")
|
|
146
|
-
return getData(key);
|
|
147
|
-
const coreData = (_g = (_e = (_d = (_c = this.app) == null ? void 0 : _c.models) == null ? void 0 : _d.getStore) == null ? void 0 : (_f = _e.call(_d)).getDataByModel) == null ? void 0 : _g.call(_f, "core", "core");
|
|
148
|
-
return coreData == null ? void 0 : coreData[key];
|
|
149
|
-
}
|
|
150
139
|
/**
|
|
151
140
|
* 记录信息日志
|
|
152
141
|
*/
|
|
@@ -532,20 +521,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
532
521
|
});
|
|
533
522
|
throw new Error(warningMessage);
|
|
534
523
|
}
|
|
535
|
-
|
|
524
|
+
let paymentUuid;
|
|
525
|
+
if ((_a = paymentItem.metadata) == null ? void 0 : _a.unique_payment_number) {
|
|
526
|
+
paymentUuid = paymentItem.metadata.unique_payment_number;
|
|
527
|
+
} else {
|
|
528
|
+
paymentUuid = (0, import_utils.getUniqueId)("payment_");
|
|
529
|
+
}
|
|
536
530
|
const currentTime = formatDateTime(/* @__PURE__ */ new Date());
|
|
537
|
-
const hasPaymentNumber = String(paymentItem.payment_number || "").trim() !== "";
|
|
538
|
-
const paymentNumberDevicePrefix = hasPaymentNumber ? "LOCAL" : await (0, import_payment_number.resolvePaymentNumberDevicePrefix)(
|
|
539
|
-
(key) => this.getPaymentNumberAppData(key)
|
|
540
|
-
);
|
|
541
|
-
const paymentNumber = (0, import_payment_utils.ensureOrderPaymentNumber)(
|
|
542
|
-
paymentItem,
|
|
543
|
-
paymentNumberDevicePrefix,
|
|
544
|
-
import_utils2.createUuidV4
|
|
545
|
-
).payment_number;
|
|
546
531
|
const newPaymentItem = {
|
|
547
532
|
uuid: paymentUuid,
|
|
548
|
-
payment_number: paymentNumber,
|
|
549
533
|
custom_payment_id: normalizeCustomPaymentId(paymentItem),
|
|
550
534
|
name: paymentItem.name,
|
|
551
535
|
code: paymentItem.code,
|
|
@@ -565,8 +549,10 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
565
549
|
updated_at: currentTime,
|
|
566
550
|
// 更新时间
|
|
567
551
|
metadata: {
|
|
568
|
-
...paymentItem.metadata
|
|
552
|
+
...paymentItem.metadata,
|
|
569
553
|
// 保留传入的所有 metadata 字段
|
|
554
|
+
unique_payment_number: paymentUuid
|
|
555
|
+
// 设置唯一支付号为支付项的 uuid
|
|
570
556
|
}
|
|
571
557
|
};
|
|
572
558
|
order.payment.push(newPaymentItem);
|
|
@@ -781,12 +767,6 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
781
767
|
if ("amount" in formattedParams && formattedParams.amount !== void 0) {
|
|
782
768
|
formattedParams.amount = formatAmount(formattedParams.amount);
|
|
783
769
|
}
|
|
784
|
-
if (formattedParams.metadata && typeof formattedParams.metadata === "object") {
|
|
785
|
-
formattedParams.metadata = {
|
|
786
|
-
...paymentItem.metadata || {},
|
|
787
|
-
...formattedParams.metadata
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
770
|
Object.assign(paymentItem, formattedParams);
|
|
791
771
|
this.recalculateOrderAmount(order);
|
|
792
772
|
await this.dbManager.update("order", order);
|
|
@@ -844,7 +824,6 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
844
824
|
const paymentData = {
|
|
845
825
|
payments: order.payment.map((payment) => ({
|
|
846
826
|
uuid: payment.uuid,
|
|
847
|
-
payment_number: payment.payment_number,
|
|
848
827
|
amount: payment.amount,
|
|
849
828
|
code: payment.code,
|
|
850
829
|
custom_payment_id: payment.custom_payment_id,
|
|
@@ -1088,7 +1067,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
1088
1067
|
roundedValue = this.standardRound(baseValue, true);
|
|
1089
1068
|
break;
|
|
1090
1069
|
case import_types.RoundingRule.StandardDown:
|
|
1091
|
-
case "
|
|
1070
|
+
case "standard_rounding_midpoint_down":
|
|
1092
1071
|
roundedValue = this.standardRound(baseValue, false);
|
|
1093
1072
|
break;
|
|
1094
1073
|
case import_types.RoundingRule.AlwaysUp:
|
|
@@ -40,11 +40,11 @@ export declare enum RoundingRule {
|
|
|
40
40
|
/** 标准舍入(中点向上) */
|
|
41
41
|
Standard = "standard_rounding",
|
|
42
42
|
/** 标准舍入(中点向下) */
|
|
43
|
-
StandardDown = "
|
|
43
|
+
StandardDown = "standard_rounding_midpoint_down",
|
|
44
44
|
/** 总是向上舍入 */
|
|
45
|
-
AlwaysUp = "
|
|
45
|
+
AlwaysUp = "round_up",
|
|
46
46
|
/** 总是向下舍入 */
|
|
47
|
-
AlwaysDown = "
|
|
47
|
+
AlwaysDown = "round_down"
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 舍入结果
|
|
@@ -87,30 +87,12 @@ export interface PaymentMethod {
|
|
|
87
87
|
/** 其他配置信息 */
|
|
88
88
|
[key: string]: any;
|
|
89
89
|
}
|
|
90
|
-
/** 支付项扩展元数据 */
|
|
91
|
-
export interface PaymentItemMetadata {
|
|
92
|
-
/** 钱箱 ID */
|
|
93
|
-
shop_wallet_pass_id?: string;
|
|
94
|
-
/** 三方支付交易流水号 */
|
|
95
|
-
unique_payment_number?: string;
|
|
96
|
-
/** 刷卡机设备快照;PaymentModule 不解析内部字段 */
|
|
97
|
-
card_reader_snapshot?: Record<string, unknown>;
|
|
98
|
-
/** rounding 规则 */
|
|
99
|
-
rounding_rule?: any;
|
|
100
|
-
/** 实付金额(现金支付时的实际给出金额) */
|
|
101
|
-
actual_paid_amount?: number;
|
|
102
|
-
/** 找零金额(现金支付时的找零金额) */
|
|
103
|
-
change_given_amount?: number;
|
|
104
|
-
[key: string]: unknown;
|
|
105
|
-
}
|
|
106
90
|
/**
|
|
107
91
|
* 支付项
|
|
108
92
|
*/
|
|
109
93
|
export interface PaymentItem {
|
|
110
94
|
/** 当前支付项的唯一 ID */
|
|
111
95
|
uuid: string;
|
|
112
|
-
/** 支付项稳定唯一号 */
|
|
113
|
-
payment_number?: string;
|
|
114
96
|
/** 当前支付方式付出去多少钱 */
|
|
115
97
|
amount: string;
|
|
116
98
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -128,7 +110,18 @@ export interface PaymentItem {
|
|
|
128
110
|
/** Wallet Pass 本次使用值 */
|
|
129
111
|
wallet_pass_use_value?: string | number | null;
|
|
130
112
|
/** 拓展参数字段 */
|
|
131
|
-
metadata?:
|
|
113
|
+
metadata?: {
|
|
114
|
+
/** 钱箱 ID */
|
|
115
|
+
shop_wallet_pass_id?: string;
|
|
116
|
+
/** 唯一支付号 */
|
|
117
|
+
unique_payment_number?: string;
|
|
118
|
+
/** rouding规则 */
|
|
119
|
+
rounding_rule?: any;
|
|
120
|
+
/** 实付金额(现金支付时的实际给出金额) */
|
|
121
|
+
actual_paid_amount?: number;
|
|
122
|
+
/** 找零金额(现金支付时的找零金额) */
|
|
123
|
+
change_given_amount?: number;
|
|
124
|
+
};
|
|
132
125
|
/** rouding金额 */
|
|
133
126
|
rounding_amount?: string;
|
|
134
127
|
/** 三方支付手续费 */
|
|
@@ -235,10 +228,6 @@ export interface UpdateOrderParams {
|
|
|
235
228
|
* 支付项输入类型(允许 amount 为数字)
|
|
236
229
|
*/
|
|
237
230
|
export interface PaymentItemInput {
|
|
238
|
-
/** 调用方已有的支付项运行态 UUID;存在时复用为 payment_number 的唯一号段 */
|
|
239
|
-
uuid?: string;
|
|
240
|
-
/** 支付项稳定唯一号 */
|
|
241
|
-
payment_number?: string;
|
|
242
231
|
/** 当前支付方式付出去多少钱 */
|
|
243
232
|
amount: string | number;
|
|
244
233
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -267,7 +256,18 @@ export interface PaymentItemInput {
|
|
|
267
256
|
/** 订单支付类型 */
|
|
268
257
|
order_payment_type?: 'normal' | 'deposit';
|
|
269
258
|
/** 扩展参数字段 */
|
|
270
|
-
metadata?:
|
|
259
|
+
metadata?: {
|
|
260
|
+
/** 钱箱 ID */
|
|
261
|
+
shop_wallet_pass_id?: string;
|
|
262
|
+
/** 唯一支付号 */
|
|
263
|
+
unique_payment_number?: string;
|
|
264
|
+
/** rounding规则 */
|
|
265
|
+
rounding_rule?: any;
|
|
266
|
+
/** 实付金额(现金支付时的实际给出金额) */
|
|
267
|
+
actual_paid_amount?: number;
|
|
268
|
+
/** 找零金额(现金支付时的找零金额) */
|
|
269
|
+
change_given_amount?: number;
|
|
270
|
+
};
|
|
271
271
|
/** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
272
272
|
created_at?: string;
|
|
273
273
|
/** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
@@ -302,8 +302,6 @@ export interface PaymentUpdateFields {
|
|
|
302
302
|
voucher_id?: string;
|
|
303
303
|
/** 该支付项是否已经同步给后端服务器(只有网络请求成功后才为true) */
|
|
304
304
|
isSynced?: boolean;
|
|
305
|
-
/** 支付项扩展元数据;更新时与原 metadata 浅合并 */
|
|
306
|
-
metadata?: PaymentItemMetadata;
|
|
307
305
|
/** 同步错误信息(业务错误时记录错误信息,用于区分"未同步"和"同步失败") */
|
|
308
306
|
syncError?: {
|
|
309
307
|
error: string;
|
|
@@ -51,9 +51,9 @@ var TaskRunStatus = /* @__PURE__ */ ((TaskRunStatus2) => {
|
|
|
51
51
|
})(TaskRunStatus || {});
|
|
52
52
|
var RoundingRule = /* @__PURE__ */ ((RoundingRule2) => {
|
|
53
53
|
RoundingRule2["Standard"] = "standard_rounding";
|
|
54
|
-
RoundingRule2["StandardDown"] = "
|
|
55
|
-
RoundingRule2["AlwaysUp"] = "
|
|
56
|
-
RoundingRule2["AlwaysDown"] = "
|
|
54
|
+
RoundingRule2["StandardDown"] = "standard_rounding_midpoint_down";
|
|
55
|
+
RoundingRule2["AlwaysUp"] = "round_up";
|
|
56
|
+
RoundingRule2["AlwaysDown"] = "round_down";
|
|
57
57
|
return RoundingRule2;
|
|
58
58
|
})(RoundingRule || {});
|
|
59
59
|
var RoundingInterval = /* @__PURE__ */ ((RoundingInterval2) => {
|
|
@@ -35,7 +35,6 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
35
35
|
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
36
36
|
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
37
37
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
38
|
-
private isItemRewardProductDiscount;
|
|
39
38
|
private getUnavailableReason;
|
|
40
39
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
41
40
|
discountList: Discount[];
|
|
@@ -167,16 +167,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
167
167
|
resolveDiscountListForManualOverride(discountList) {
|
|
168
168
|
return this.excludeDiscountListByType(discountList, "promotion");
|
|
169
169
|
}
|
|
170
|
-
isItemRewardProductDiscount(product) {
|
|
171
|
-
var _a;
|
|
172
|
-
const discountList = Array.isArray(product == null ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
173
|
-
return ((_a = product == null ? void 0 : product._promotion) == null ? void 0 : _a.actionType) === "ITEM_REWARD" && discountList.some(
|
|
174
|
-
(item) => {
|
|
175
|
-
var _a2, _b;
|
|
176
|
-
return (item == null ? void 0 : item.type) === "product" && ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
177
|
-
}
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
170
|
// 获取券不可用的原因
|
|
181
171
|
getUnavailableReason(discountList, productList) {
|
|
182
172
|
var _a;
|
|
@@ -238,7 +228,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
238
228
|
const discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
239
229
|
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ["good_pass", "discount_card", "product_discount_card"].includes(discountType);
|
|
240
230
|
};
|
|
241
|
-
const
|
|
231
|
+
const resolveReapplyBookingDiscountPercent = (originProduct, selectedDiscount) => {
|
|
242
232
|
var _a2;
|
|
243
233
|
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount))
|
|
244
234
|
return void 0;
|
|
@@ -312,7 +302,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
312
302
|
bundleIndex,
|
|
313
303
|
// 虚拟商品属性
|
|
314
304
|
price: Number(bundleItem.price || 0),
|
|
315
|
-
|
|
305
|
+
// 新增商品运行态通常带 _bundle_product_id;订单 hydrate 后只有
|
|
306
|
+
// bundle_product_id。Change time 必须兼容两种结构,否则 bundle
|
|
307
|
+
// 子项无法命中折扣卡的 limited_relation_product_data.product_ids。
|
|
308
|
+
id: bundleItem._bundle_product_id ?? bundleItem.bundle_product_id ?? bundleItem.product_id,
|
|
316
309
|
_id: `${product._id}_bundle_${bundleIndex}`,
|
|
317
310
|
parentId: product._id,
|
|
318
311
|
num: bundleItem.num || 1,
|
|
@@ -509,9 +502,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
509
502
|
startDate: (_a2 = flatItem.parentProduct) == null ? void 0 : _a2.startDate
|
|
510
503
|
};
|
|
511
504
|
}
|
|
512
|
-
if (this.isItemRewardProductDiscount(product)) {
|
|
513
|
-
return false;
|
|
514
|
-
}
|
|
515
505
|
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.length) && ((_c = product == null ? void 0 : product.discount_list) == null ? void 0 : _c.every((d) => d.id && ["good_pass", "discount_card", "product_discount_card"].includes(d.tag || d.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && !!((_e = (_d = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _d.discount_list) == null ? void 0 : _e.length) && ((_g = (_f = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _f.discount_list) == null ? void 0 : _g.every((d) => d.id)));
|
|
516
506
|
if (!isAvailableProduct) {
|
|
517
507
|
return false;
|
|
@@ -637,7 +627,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
637
627
|
};
|
|
638
628
|
originProduct = flatItem.originProduct;
|
|
639
629
|
}
|
|
640
|
-
const isItemRewardProductDiscount = this.isItemRewardProductDiscount(product);
|
|
641
630
|
addModeDiscount.forEach((discount) => {
|
|
642
631
|
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
643
632
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
@@ -661,7 +650,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
661
650
|
].includes(discount2.tag || discount2.type)
|
|
662
651
|
))) : !((flatItem == null ? void 0 : flatItem.booking_id) && !!((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) == null ? void 0 : _d.length) && ((_f = (_e = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _e.discount_list) == null ? void 0 : _f.every((discount2) => discount2.id)));
|
|
663
652
|
const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
|
|
664
|
-
if (isAvailableProduct &&
|
|
653
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && ((_g = discount.config) == null ? void 0 : _g.isAvailable)) {
|
|
665
654
|
(_h = discountApplicability.get(discount.id)) == null ? void 0 : _h.push(product.id);
|
|
666
655
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
667
656
|
const discountType = discount.tag || discount.type;
|
|
@@ -772,20 +761,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
772
761
|
if (isPersistedProduct && hasExistingWalletDiscount) {
|
|
773
762
|
if (flatItem.type === "main") {
|
|
774
763
|
processedProductsMap.set(product._id, [originProduct]);
|
|
775
|
-
} else {
|
|
776
|
-
processedFlatItemsMap.set(flatItem._id, [
|
|
777
|
-
{
|
|
778
|
-
...flatItem,
|
|
779
|
-
processed: true
|
|
780
|
-
}
|
|
781
|
-
]);
|
|
782
764
|
}
|
|
783
765
|
return;
|
|
784
766
|
}
|
|
785
767
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
786
768
|
var _a3, _b2, _c2, _d2;
|
|
787
|
-
if (this.isItemRewardProductDiscount(product))
|
|
788
|
-
return false;
|
|
789
769
|
const discountType = discount.tag || discount.type;
|
|
790
770
|
const currentOriginUid = getOriginProductUid(originProduct);
|
|
791
771
|
const isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
|
|
@@ -855,17 +835,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
855
835
|
}
|
|
856
836
|
return false;
|
|
857
837
|
});
|
|
858
|
-
const
|
|
859
|
-
const discountType = discount.tag || discount.type;
|
|
860
|
-
return String(discount.id) === String(options.discountId) && ["discount_card", "product_discount_card"].includes(discountType);
|
|
861
|
-
}) : void 0;
|
|
862
|
-
const scannedSelectedDiscountCard = applicableDiscounts.find(
|
|
838
|
+
const selectedDiscountCard = applicableDiscounts.find(
|
|
863
839
|
(n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass"
|
|
864
840
|
);
|
|
865
|
-
const selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
866
841
|
const selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
867
842
|
let isManualDiscount = false;
|
|
868
|
-
let isItemRewardProductDiscount = false;
|
|
869
843
|
if (flatItem.type === "main") {
|
|
870
844
|
isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : ((_g = product.discount_list) == null ? void 0 : _g.some((item) => item.type === "product")) || product.total != product.origin_total && (product.bundle || []).every(
|
|
871
845
|
(item) => {
|
|
@@ -876,8 +850,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
876
850
|
_i,
|
|
877
851
|
(item) => item.type === "product"
|
|
878
852
|
)));
|
|
879
|
-
|
|
880
|
-
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
853
|
+
if (product.inPromotion) {
|
|
881
854
|
isManualDiscount = false;
|
|
882
855
|
}
|
|
883
856
|
} else {
|
|
@@ -991,7 +964,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
991
964
|
} else {
|
|
992
965
|
let total = product.inPromotion ? ((_w = product == null ? void 0 : product._promotion) == null ? void 0 : _w.finalPrice) ?? product.origin_total ?? product.total : product.origin_total ?? product.total;
|
|
993
966
|
let main_product_selling_price = product.price;
|
|
994
|
-
if ((product.discount_list || []).some((item) => item.type === "promotion") ||
|
|
967
|
+
if ((product.discount_list || []).some((item) => item.type === "promotion") || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
995
968
|
total = product.total ?? product.origin_total;
|
|
996
969
|
main_product_selling_price = product.main_product_selling_price ?? main_product_selling_price;
|
|
997
970
|
}
|
|
@@ -999,8 +972,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
999
972
|
this.hooks.setProduct(originProduct, {
|
|
1000
973
|
...isManualDiscount ? {
|
|
1001
974
|
price: product.price,
|
|
1002
|
-
main_product_selling_price:
|
|
1003
|
-
...isItemRewardProductDiscount ? { total } : {}
|
|
975
|
+
main_product_selling_price: product.price
|
|
1004
976
|
} : {
|
|
1005
977
|
_id: product._id.split("___")[0] + "___" + index,
|
|
1006
978
|
total,
|
|
@@ -1084,8 +1056,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1084
1056
|
amount = productAllocation.discountAmount;
|
|
1085
1057
|
productDiscountDifference = productAllocation.difference;
|
|
1086
1058
|
mainProductSellingPrice = Math.max(new import_decimal.default(product.price).minus(amount).toNumber(), 0);
|
|
1087
|
-
} else if (
|
|
1088
|
-
const percent =
|
|
1059
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount2) !== void 0) {
|
|
1060
|
+
const percent = resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount2);
|
|
1089
1061
|
reapplyDiscountPercent = new import_decimal.default(percent).toFixed(2);
|
|
1090
1062
|
mainProductSellingPrice = new import_decimal.default(product.price || 0).mul(new import_decimal.default(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1091
1063
|
amount = new import_decimal.default(product.price).minus(mainProductSellingPrice).toNumber();
|
|
@@ -1258,10 +1230,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1258
1230
|
let targetProductTotal;
|
|
1259
1231
|
let fixedAmountPerItem;
|
|
1260
1232
|
let productDiscountDifference;
|
|
1233
|
+
let reapplyDiscountPercent;
|
|
1261
1234
|
if (isOrderLevel && productAllocation) {
|
|
1262
1235
|
fixedAmountPerItem = productAllocation.discountAmount;
|
|
1263
1236
|
productDiscountDifference = productAllocation.difference;
|
|
1264
1237
|
targetProductTotal = Math.max(new import_decimal.default(productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
|
|
1238
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount2) !== void 0) {
|
|
1239
|
+
const percent = resolveReapplyBookingDiscountPercent(
|
|
1240
|
+
originProduct,
|
|
1241
|
+
selectedDiscount2
|
|
1242
|
+
);
|
|
1243
|
+
reapplyDiscountPercent = new import_decimal.default(percent).toFixed(2);
|
|
1244
|
+
targetProductTotal = new import_decimal.default(productOriginTotal).mul(new import_decimal.default(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1245
|
+
fixedAmountPerItem = new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber();
|
|
1265
1246
|
} else {
|
|
1266
1247
|
targetProductTotal = (0, import_utils.getDiscountAmount)(
|
|
1267
1248
|
selectedDiscount2,
|
|
@@ -1283,7 +1264,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1283
1264
|
title: selectedDiscount2.format_title,
|
|
1284
1265
|
original_amount: product.original_price,
|
|
1285
1266
|
product_id: product.id || product.product_id,
|
|
1286
|
-
percent: selectedDiscount2.par_value,
|
|
1267
|
+
percent: reapplyDiscountPercent ?? selectedDiscount2.par_value,
|
|
1287
1268
|
discount_product_id: selectedDiscount2.product_id
|
|
1288
1269
|
},
|
|
1289
1270
|
metadata: {
|
|
@@ -99,7 +99,11 @@ function getUnitOriginalTotal(product) {
|
|
|
99
99
|
function isGeneratedVoucherProduct(product) {
|
|
100
100
|
const record = product;
|
|
101
101
|
const metadata = (record == null ? void 0 : record.metadata) || {};
|
|
102
|
-
|
|
102
|
+
const isGeneratedChild = metadata.parent_order_detail_id !== void 0 || metadata.gift_card_type !== void 0;
|
|
103
|
+
if (isGeneratedChild)
|
|
104
|
+
return true;
|
|
105
|
+
const isPersisted = (record == null ? void 0 : record.order_detail_id) !== void 0 && (record == null ? void 0 : record.order_detail_id) !== null;
|
|
106
|
+
return (record == null ? void 0 : record.extension_type) === "product_voucher" && !isPersisted;
|
|
103
107
|
}
|
|
104
108
|
function buildSurchargeServiceItems(products) {
|
|
105
109
|
return products.map((product) => {
|
package/lib/server/index.d.ts
CHANGED
|
@@ -57,7 +57,6 @@ declare class Server {
|
|
|
57
57
|
private readonly BOOKING_REMOTE_CACHE_MAX_ENTRIES;
|
|
58
58
|
private salesSearchSubscribers;
|
|
59
59
|
private deviceTaskActionsRegistered;
|
|
60
|
-
private localPaymentUpdateQueues;
|
|
61
60
|
private floorPlanQuerySubscribers;
|
|
62
61
|
private moduleRegistry;
|
|
63
62
|
constructor(core: PisellCore);
|
|
@@ -121,8 +120,6 @@ declare class Server {
|
|
|
121
120
|
private handleSyncSalesTask;
|
|
122
121
|
private runCheckoutSync;
|
|
123
122
|
private omitCheckoutSyncMode;
|
|
124
|
-
private buildRemoteCheckoutData;
|
|
125
|
-
private mergeCheckoutSyncPayments;
|
|
126
123
|
private persistSyncedCheckoutOrder;
|
|
127
124
|
/**
|
|
128
125
|
* 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
|
|
@@ -456,18 +453,6 @@ declare class Server {
|
|
|
456
453
|
*/
|
|
457
454
|
private handleUpdateLocalOrder;
|
|
458
455
|
private handleOrderSalesCheckout;
|
|
459
|
-
private handleOrderSalesDraft;
|
|
460
|
-
private createLocalPaymentOperationId;
|
|
461
|
-
private buildLocalPaymentOrderLogContext;
|
|
462
|
-
private isValidLocalPaymentDecimal;
|
|
463
|
-
private getInvalidLocalPaymentSurchargeFields;
|
|
464
|
-
private buildLocalPaymentSurchargeUpdate;
|
|
465
|
-
private handleGetLocalPayment;
|
|
466
|
-
private handleUpdateLocalPayment;
|
|
467
|
-
private runLocalPaymentUpdateInQueue;
|
|
468
|
-
private processLocalPaymentUpdate;
|
|
469
|
-
private processSuccessfulLocalPayment;
|
|
470
|
-
private sanitizeLocalRecoveryOrder;
|
|
471
456
|
private handleOrderCheckout;
|
|
472
457
|
private getDeviceTaskPlugin;
|
|
473
458
|
private getIdGeneratorPlugin;
|
|
@@ -495,7 +480,6 @@ declare class Server {
|
|
|
495
480
|
private syncMachinecodeRedeemStatusToLocalOrder;
|
|
496
481
|
private handleOrderCheckoutSubmit;
|
|
497
482
|
private handleSyncCheckoutSubmit;
|
|
498
|
-
private handleOrderDraftSubmit;
|
|
499
483
|
private handlePendingSyncCheckoutOrder;
|
|
500
484
|
private buildPendingSyncCheckoutOrder;
|
|
501
485
|
private shouldBuildSmallTicketData;
|