@pisell/pisellos 2.2.197 → 2.2.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +7 -3
- package/dist/modules/Cart/utils/cartProduct.js +11 -1
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Order/index.d.ts +16 -0
- package/dist/modules/Order/index.js +1232 -568
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.d.ts +33 -2
- package/dist/modules/Order/utils.js +112 -55
- package/dist/modules/Payment/walletpass.js +14 -7
- package/dist/modules/SalesSummary/utils.js +394 -149
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +294 -190
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +536 -317
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +2 -1
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +19 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/types.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +26 -9
- package/dist/solution/VenueBooking/index.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -1
- package/lib/modules/Cart/utils/cartProduct.js +11 -1
- package/lib/modules/Cart/utils/changePrice.js +12 -20
- package/lib/modules/Order/index.d.ts +16 -0
- package/lib/modules/Order/index.js +525 -18
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.d.ts +33 -2
- package/lib/modules/Order/utils.js +44 -9
- package/lib/modules/Payment/walletpass.js +7 -3
- package/lib/modules/SalesSummary/utils.js +256 -46
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +82 -3
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +106 -4
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +2 -1
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/types.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +28 -10
- package/lib/solution/VenueBooking/index.js +2 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
|
-
import { CartItem } from "../Cart";
|
|
2
|
+
import type { CartItem } from "../Cart";
|
|
3
3
|
import type { OrderProductDiscountItem, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder } from './types';
|
|
4
4
|
import type { RulesParamsHooks } from '../Rules/types';
|
|
5
5
|
import type { MapOrderPaymentsOptions, OrderPaymentData, OrderPaymentSource } from './types';
|
|
@@ -21,10 +21,20 @@ export declare function composeLinePrice(params: {
|
|
|
21
21
|
bundle?: Array<{
|
|
22
22
|
bundle_selling_price?: any;
|
|
23
23
|
price?: any;
|
|
24
|
+
custom_price?: any;
|
|
24
25
|
num?: any;
|
|
25
26
|
quantity?: any;
|
|
26
27
|
original_price?: any;
|
|
27
28
|
product_price?: any;
|
|
29
|
+
price_type?: any;
|
|
30
|
+
price_type_ext?: any;
|
|
31
|
+
custom_price_type?: any;
|
|
32
|
+
custom_price_type_ext?: any;
|
|
33
|
+
option?: Array<{
|
|
34
|
+
add_price?: any;
|
|
35
|
+
price?: any;
|
|
36
|
+
num?: any;
|
|
37
|
+
}>;
|
|
28
38
|
}> | null;
|
|
29
39
|
useOriginalBundle?: boolean;
|
|
30
40
|
}): string;
|
|
@@ -43,6 +53,27 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
43
53
|
price?: any;
|
|
44
54
|
num?: any;
|
|
45
55
|
}> | null): Decimal;
|
|
56
|
+
/**
|
|
57
|
+
* 判定套餐子商品是否为 markdown(减价)类型。
|
|
58
|
+
* 与后端口径一致:price_type='markdown' 且 price_type_ext 非 'product_price'(原价子商品)。
|
|
59
|
+
*/
|
|
60
|
+
export declare function isMarkdownBundle(bundle: Record<string, any> | null | undefined): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 套餐子商品对「行价」的带符号单位贡献(与后端 markdown 口径对齐)。
|
|
63
|
+
*
|
|
64
|
+
* - markdown(减价):净额 = |catalog 毛价| − Σ(option.add_price×num),**取负**(行内减)。
|
|
65
|
+
* catalog 毛价优先 `price`/`custom_price`(避免读已落净额的 `bundle_selling_price` 造成 option 二次扣减);
|
|
66
|
+
* 仅当毛价缺失(历史/hydrate 仅剩净额)时退回 `bundle_selling_price`,且此时不再扣 option。
|
|
67
|
+
* - markup(加价)/原价子商品:维持 `+(bundle_selling_price ?? price)`,行为不变。
|
|
68
|
+
*/
|
|
69
|
+
export declare function getBundleSignedUnit(bundle: Record<string, any> | null | undefined, options?: {
|
|
70
|
+
useOriginal?: boolean;
|
|
71
|
+
}): Decimal;
|
|
72
|
+
/**
|
|
73
|
+
* 套餐子商品 `bundle_selling_price` 的存储净额(正值幅度)。
|
|
74
|
+
* markdown 取净额绝对值(3.70);markup/原价维持原值。
|
|
75
|
+
*/
|
|
76
|
+
export declare function getBundleSellingMagnitude(bundle: Record<string, any> | null | undefined): Decimal;
|
|
46
77
|
/**
|
|
47
78
|
* OrderModule 默认 Rules 钩子工厂。
|
|
48
79
|
*
|
|
@@ -55,7 +86,7 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
55
86
|
* 不含折扣。**权威源**。
|
|
56
87
|
* - `metadata.main_product_original_price` = source + Σ(option.price × option.num)(含 option、不含折扣)。
|
|
57
88
|
* - `metadata.main_product_selling_price` = main_original − 主商品券 per-unit amount(含 option、含折扣)。
|
|
58
|
-
* - `payment_price`:出站 payload
|
|
89
|
+
* - `payment_price`:出站 payload 中为行 composite 已减整单折扣均摊价(无折扣时与 `selling_price` 同义)。
|
|
59
90
|
*
|
|
60
91
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
61
92
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
@@ -44,11 +44,14 @@ __export(utils_exports, {
|
|
|
44
44
|
formatV1Product: () => formatV1Product,
|
|
45
45
|
generateDuration: () => generateDuration,
|
|
46
46
|
getAllDiscountList: () => getAllDiscountList,
|
|
47
|
+
getBundleSellingMagnitude: () => getBundleSellingMagnitude,
|
|
48
|
+
getBundleSignedUnit: () => getBundleSignedUnit,
|
|
47
49
|
getOrderProductLineUid: () => getOrderProductLineUid,
|
|
48
50
|
getProductSkuOptions: () => getProductSkuOptions,
|
|
49
51
|
hasAssignedHolderId: () => hasAssignedHolderId,
|
|
50
52
|
indexOrderProductsByUid: () => indexOrderProductsByUid,
|
|
51
53
|
isEmptyOrderProductDisplayValue: () => isEmptyOrderProductDisplayValue,
|
|
54
|
+
isMarkdownBundle: () => isMarkdownBundle,
|
|
52
55
|
isTempOrder: () => isTempOrder,
|
|
53
56
|
mapPaymentItemToOrderPayment: () => mapPaymentItemToOrderPayment,
|
|
54
57
|
mapPaymentItemsToOrderPayments: () => mapPaymentItemsToOrderPayments,
|
|
@@ -85,11 +88,10 @@ function composeLinePrice(params) {
|
|
|
85
88
|
let total = new import_decimal.default(Number(mainPrice) || 0);
|
|
86
89
|
if (Array.isArray(bundle)) {
|
|
87
90
|
for (const item of bundle) {
|
|
88
|
-
const
|
|
89
|
-
const price = new import_decimal.default(Number(rawPrice) || 0);
|
|
91
|
+
const signedUnit = getBundleSignedUnit(item, { useOriginal: useOriginalBundle });
|
|
90
92
|
const rawNum = (item == null ? void 0 : item.num) ?? (item == null ? void 0 : item.quantity) ?? 1;
|
|
91
93
|
const num = new import_decimal.default(Number(rawNum) || 0);
|
|
92
|
-
total = total.plus(
|
|
94
|
+
total = total.plus(signedUnit.times(num));
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
return total.toDecimalPlaces(2).toFixed(2);
|
|
@@ -129,6 +131,33 @@ function sumOptionUnitPrice(options) {
|
|
|
129
131
|
}
|
|
130
132
|
return total;
|
|
131
133
|
}
|
|
134
|
+
function isMarkdownBundle(bundle) {
|
|
135
|
+
if (!bundle || typeof bundle !== "object")
|
|
136
|
+
return false;
|
|
137
|
+
const ext = bundle.price_type_ext ?? bundle.custom_price_type_ext;
|
|
138
|
+
const type = bundle.price_type ?? bundle.custom_price_type;
|
|
139
|
+
return type === "markdown" && ext !== "product_price";
|
|
140
|
+
}
|
|
141
|
+
function getBundleSignedUnit(bundle, options) {
|
|
142
|
+
if (!bundle || typeof bundle !== "object")
|
|
143
|
+
return new import_decimal.default(0);
|
|
144
|
+
const useOriginal = (options == null ? void 0 : options.useOriginal) ?? false;
|
|
145
|
+
if (isMarkdownBundle(bundle)) {
|
|
146
|
+
const catalog = useOriginal ? bundle.original_price ?? bundle.product_price ?? bundle.custom_price ?? bundle.base_price ?? bundle.price : bundle.custom_price ?? bundle.product_price ?? bundle.original_price ?? bundle.base_price ?? bundle.price;
|
|
147
|
+
if (catalog !== void 0 && catalog !== null && catalog !== "") {
|
|
148
|
+
const raw = new import_decimal.default(Number(catalog) || 0);
|
|
149
|
+
if (raw.lt(0))
|
|
150
|
+
return raw;
|
|
151
|
+
return raw.minus(sumOptionUnitPrice(bundle.option)).negated();
|
|
152
|
+
}
|
|
153
|
+
return new import_decimal.default(Number(bundle.bundle_selling_price) || 0).abs().negated();
|
|
154
|
+
}
|
|
155
|
+
const rawPrice = useOriginal ? bundle.original_price ?? bundle.product_price ?? bundle.price : bundle.bundle_selling_price ?? bundle.price;
|
|
156
|
+
return new import_decimal.default(Number(rawPrice) || 0);
|
|
157
|
+
}
|
|
158
|
+
function getBundleSellingMagnitude(bundle) {
|
|
159
|
+
return getBundleSignedUnit(bundle).abs();
|
|
160
|
+
}
|
|
132
161
|
function resolveRulesManualDiscountFlag(metadata) {
|
|
133
162
|
if (!metadata)
|
|
134
163
|
return void 0;
|
|
@@ -472,9 +501,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
472
501
|
return bundle.map((b) => {
|
|
473
502
|
const rawBundle = b && typeof b === "object" ? b : {};
|
|
474
503
|
const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
|
|
475
|
-
const sellingPrice =
|
|
476
|
-
|
|
477
|
-
);
|
|
504
|
+
const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
505
|
+
const paymentPrice = rawBundle.bundle_payment_price !== void 0 && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== "" ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
478
506
|
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
479
507
|
const relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
480
508
|
const surchargeFee = toMoneyString(
|
|
@@ -496,6 +524,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
496
524
|
price_type: rawBundle.price_type ?? rawBundle.custom_price_type ?? "",
|
|
497
525
|
price_type_ext: rawBundle.price_type_ext ?? rawBundle.custom_price_type_ext ?? "",
|
|
498
526
|
bundle_selling_price: sellingPrice,
|
|
527
|
+
bundle_payment_price: paymentPrice,
|
|
499
528
|
option: formatSubmitOptionItems(rawBundle.option),
|
|
500
529
|
bundle_group_id: (rawBundle == null ? void 0 : rawBundle.bundle_group_id) ?? (rawBundle == null ? void 0 : rawBundle.group_id),
|
|
501
530
|
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
@@ -532,6 +561,9 @@ function normalizeSubmitProduct(product) {
|
|
|
532
561
|
const priceMetaKeys = [
|
|
533
562
|
"main_product_original_price",
|
|
534
563
|
"main_product_selling_price",
|
|
564
|
+
"main_product_attached_bundle_selling_price",
|
|
565
|
+
"main_product_attached_bundle_payment_price",
|
|
566
|
+
"average_discount_amount_rate",
|
|
535
567
|
"source_product_price",
|
|
536
568
|
"main_product_attached_bundle_surcharge_fee",
|
|
537
569
|
"main_product_attached_bundle_tax_fee",
|
|
@@ -566,9 +598,9 @@ function normalizeSubmitProduct(product) {
|
|
|
566
598
|
discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
|
|
567
599
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
568
600
|
metadata: cleanMetadata,
|
|
569
|
-
// 出站兼容:后端消费 payment_price
|
|
570
|
-
//
|
|
571
|
-
payment_price: submitProduct.selling_price
|
|
601
|
+
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
602
|
+
// 由整单折扣均摊层产出;缺省(无折扣)时与 selling_price 同义。
|
|
603
|
+
payment_price: submitProduct.payment_price ?? submitProduct.selling_price
|
|
572
604
|
};
|
|
573
605
|
}
|
|
574
606
|
var SUBMIT_BOOKING_METADATA_WHITELIST = [
|
|
@@ -953,11 +985,14 @@ function indexOrderProductsByUid(products) {
|
|
|
953
985
|
formatV1Product,
|
|
954
986
|
generateDuration,
|
|
955
987
|
getAllDiscountList,
|
|
988
|
+
getBundleSellingMagnitude,
|
|
989
|
+
getBundleSignedUnit,
|
|
956
990
|
getOrderProductLineUid,
|
|
957
991
|
getProductSkuOptions,
|
|
958
992
|
hasAssignedHolderId,
|
|
959
993
|
indexOrderProductsByUid,
|
|
960
994
|
isEmptyOrderProductDisplayValue,
|
|
995
|
+
isMarkdownBundle,
|
|
961
996
|
isTempOrder,
|
|
962
997
|
mapPaymentItemToOrderPayment,
|
|
963
998
|
mapPaymentItemsToOrderPayments,
|
|
@@ -296,18 +296,22 @@ var WalletPassPaymentImpl = class {
|
|
|
296
296
|
return (0, import_utils.formatWalletPassList2PreparePayments)(list);
|
|
297
297
|
}
|
|
298
298
|
async getUserIdentificationCodeListAsync(params) {
|
|
299
|
-
var _a, _b;
|
|
299
|
+
var _a, _b, _c;
|
|
300
300
|
try {
|
|
301
301
|
const newParams = {
|
|
302
302
|
...this.walletParams,
|
|
303
303
|
...params
|
|
304
304
|
};
|
|
305
|
+
if (!((_a = newParams.products) == null ? void 0 : _a.length)) {
|
|
306
|
+
this.paymentModule.logInfo("[WalletPass] 商品列表为空,跳过获取用户识别码列表");
|
|
307
|
+
return [];
|
|
308
|
+
}
|
|
305
309
|
this.paymentModule.logInfo("[WalletPass] 开始获取用户识别码列表", {
|
|
306
310
|
customer_id: newParams.customer_id,
|
|
307
311
|
available: newParams.available,
|
|
308
|
-
prepare_payments_count: ((
|
|
312
|
+
prepare_payments_count: ((_b = newParams.prepare_payments) == null ? void 0 : _b.length) || 0,
|
|
309
313
|
filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
|
|
310
|
-
payment_order_id: (
|
|
314
|
+
payment_order_id: (_c = this.walletParams) == null ? void 0 : _c.payment_order_id
|
|
311
315
|
});
|
|
312
316
|
const response = await this.paymentModule.request.post(
|
|
313
317
|
"/machinecode/prepare/deduction",
|