@pisell/pisellos 2.2.302 → 2.2.304
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/dist/model/strategy/adapter/itemRule/type.js +19 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +41 -5
- package/dist/modules/Discount/types.d.ts +21 -0
- package/dist/modules/OpenData/index.d.ts +15 -2
- package/dist/modules/OpenData/index.js +307 -19
- package/dist/modules/OpenData/types.d.ts +55 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +21 -1
- package/dist/modules/OpenData/utils.js +138 -0
- package/dist/modules/Order/index.d.ts +50 -7
- package/dist/modules/Order/index.js +1690 -815
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +117 -10
- package/dist/modules/Order/types.js +6 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/dist/modules/Order/utils/virtualSettlement.js +284 -0
- package/dist/modules/Order/utils.d.ts +5 -1
- package/dist/modules/Order/utils.js +138 -33
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +17 -367
- package/dist/modules/Payment/walletpass.js +20 -21
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +2 -1
- package/dist/modules/ProductList/index.js +100 -20
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/modules/Rules/index.d.ts +5 -0
- package/dist/modules/Rules/index.js +30 -14
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/plugins/request.d.ts +2 -1
- package/dist/plugins/request.js +4 -2
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.js +1774 -1285
- package/dist/server/modules/order/types.d.ts +50 -0
- package/dist/server/modules/order/types.js +2 -0
- package/dist/server/utils/small-ticket.d.ts +4 -1
- package/dist/server/utils/small-ticket.js +461 -96
- package/dist/solution/BaseSales/index.d.ts +24 -3
- package/dist/solution/BaseSales/index.js +1484 -873
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +22 -5
- package/dist/solution/BookingTicket/index.js +558 -443
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
- package/dist/solution/RegisterAndLogin/config.js +95 -40
- package/dist/solution/RegisterAndLogin/index.js +4 -1
- package/dist/solution/Sales/index.d.ts +16 -1
- package/dist/solution/Sales/index.js +338 -63
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +31 -27
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +2 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +20 -6
- package/dist/solution/UnifiedBookingSales/index.js +874 -527
- package/dist/solution/UnifiedBookingSales/types.d.ts +21 -2
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +8 -4
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
- package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/lib/model/strategy/adapter/itemRule/type.js +19 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +34 -2
- package/lib/modules/Discount/types.d.ts +21 -0
- package/lib/modules/OpenData/index.d.ts +15 -2
- package/lib/modules/OpenData/index.js +230 -3
- package/lib/modules/OpenData/types.d.ts +55 -0
- package/lib/modules/OpenData/types.js +9 -1
- package/lib/modules/OpenData/utils.d.ts +21 -1
- package/lib/modules/OpenData/utils.js +126 -0
- package/lib/modules/Order/index.d.ts +50 -7
- package/lib/modules/Order/index.js +704 -64
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +117 -10
- package/lib/modules/Order/types.js +5 -1
- package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/lib/modules/Order/utils/virtualSettlement.js +262 -0
- package/lib/modules/Order/utils.d.ts +5 -1
- package/lib/modules/Order/utils.js +127 -21
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +9 -354
- package/lib/modules/Payment/walletpass.js +14 -11
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +2 -1
- package/lib/modules/ProductList/index.js +47 -2
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/modules/Rules/index.d.ts +5 -0
- package/lib/modules/Rules/index.js +22 -12
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +17 -1
- package/lib/plugins/request.d.ts +2 -1
- package/lib/plugins/request.js +3 -2
- package/lib/server/index.d.ts +21 -0
- package/lib/server/index.js +492 -108
- package/lib/server/modules/order/types.d.ts +50 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/server/utils/small-ticket.d.ts +4 -1
- package/lib/server/utils/small-ticket.js +427 -72
- package/lib/solution/BaseSales/index.d.ts +24 -3
- package/lib/solution/BaseSales/index.js +433 -30
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +22 -5
- package/lib/solution/BookingTicket/index.js +60 -15
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/Sales/index.d.ts +16 -1
- package/lib/solution/Sales/index.js +168 -1
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +1 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +20 -6
- package/lib/solution/UnifiedBookingSales/index.js +169 -16
- package/lib/solution/UnifiedBookingSales/types.d.ts +21 -2
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +5 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "buildManualProductDiscountItem", {
|
|
|
9
9
|
return _manualProductDiscount.buildManualProductDiscountItem;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
exports.buildPointCardSnapshotFromWalletPassList = buildPointCardSnapshotFromWalletPassList;
|
|
12
13
|
exports.buildSubmitPayload = buildSubmitPayload;
|
|
13
14
|
exports.calculateOrderProductsDeposit = calculateOrderProductsDeposit;
|
|
14
15
|
exports.clearTempOrderHolderAssignments = clearTempOrderHolderAssignments;
|
|
@@ -67,7 +68,9 @@ exports.mergeOrderProductDisplayFields = mergeOrderProductDisplayFields;
|
|
|
67
68
|
exports.mergeRelationForms = void 0;
|
|
68
69
|
exports.normalizeBookingIsAll = normalizeBookingIsAll;
|
|
69
70
|
exports.normalizeBookingSubType = normalizeBookingSubType;
|
|
71
|
+
exports.normalizeOrderMetaList = normalizeOrderMetaList;
|
|
70
72
|
exports.normalizeOrderProductDiscountList = normalizeOrderProductDiscountList;
|
|
73
|
+
exports.normalizePointCardSnapshotItem = normalizePointCardSnapshotItem;
|
|
71
74
|
exports.normalizeProductSkuOptions = normalizeProductSkuOptions;
|
|
72
75
|
exports.normalizeSubmitBooking = normalizeSubmitBooking;
|
|
73
76
|
exports.normalizeSubmitCollectPaxValue = normalizeSubmitCollectPaxValue;
|
|
@@ -126,8 +129,58 @@ var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
|
126
129
|
var _utils = require("../Holder/utils");
|
|
127
130
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
128
131
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
132
|
+
var _salesNotes = require("./salesNotes");
|
|
129
133
|
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
130
134
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
135
|
+
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
136
|
+
function isPlainObject(value) {
|
|
137
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
138
|
+
}
|
|
139
|
+
function normalizeSnapshotScalar(value) {
|
|
140
|
+
if (value === undefined || value === null) return undefined;
|
|
141
|
+
if (typeof value === 'string') return value.trim() ? value : undefined;
|
|
142
|
+
if (typeof value === 'number') return Number.isFinite(value) ? value : undefined;
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
function normalizePointCardSnapshotItem(value) {
|
|
146
|
+
if (!isPlainObject(value)) return null;
|
|
147
|
+
const id = normalizeSnapshotScalar(value.id);
|
|
148
|
+
if (id === undefined) return null;
|
|
149
|
+
if (String(value.tag || '').trim().toLowerCase() !== POINT_CARD_SNAPSHOT_TAG) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const snapshot = {
|
|
153
|
+
id,
|
|
154
|
+
tag: 'point_card',
|
|
155
|
+
product_name: String(value.product_name ?? ''),
|
|
156
|
+
par_value: String(value.par_value ?? ''),
|
|
157
|
+
used_par_value: String(value.used_par_value ?? '')
|
|
158
|
+
};
|
|
159
|
+
const productId = normalizeSnapshotScalar(value.product_id);
|
|
160
|
+
if (productId !== undefined) {
|
|
161
|
+
snapshot.product_id = productId;
|
|
162
|
+
}
|
|
163
|
+
return snapshot;
|
|
164
|
+
}
|
|
165
|
+
function buildPointCardSnapshotFromWalletPassList(value) {
|
|
166
|
+
if (!Array.isArray(value)) return [];
|
|
167
|
+
return value.reduce((result, item) => {
|
|
168
|
+
const normalized = normalizePointCardSnapshotItem(item);
|
|
169
|
+
if (normalized) result.push(normalized);
|
|
170
|
+
return result;
|
|
171
|
+
}, []);
|
|
172
|
+
}
|
|
173
|
+
function normalizeOrderMetaList(value) {
|
|
174
|
+
if (value === undefined) return undefined;
|
|
175
|
+
if (!isPlainObject(value)) return undefined;
|
|
176
|
+
const normalized = {};
|
|
177
|
+
if (Object.prototype.hasOwnProperty.call(value, 'point_cards_snapshot')) {
|
|
178
|
+
normalized.point_cards_snapshot = buildPointCardSnapshotFromWalletPassList(value.point_cards_snapshot);
|
|
179
|
+
}
|
|
180
|
+
if (Object.keys(normalized).length > 0) return normalized;
|
|
181
|
+
return {};
|
|
182
|
+
}
|
|
183
|
+
|
|
131
184
|
/**
|
|
132
185
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
133
186
|
*
|
|
@@ -863,7 +916,7 @@ function normalizeSubmitProductionCode(value) {
|
|
|
863
916
|
}
|
|
864
917
|
|
|
865
918
|
// 后端 checkout 协议字段 option_group_item_id;tempOrder 内部也保持同一字段名。
|
|
866
|
-
function formatSubmitOptionItems(options) {
|
|
919
|
+
function formatSubmitOptionItems(options, formatOptions = {}) {
|
|
867
920
|
if (!Array.isArray(options)) return [];
|
|
868
921
|
return options.map(d => {
|
|
869
922
|
const option = {
|
|
@@ -876,7 +929,11 @@ function formatSubmitOptionItems(options) {
|
|
|
876
929
|
delete option.production_code;
|
|
877
930
|
if (productionCode !== undefined) option.production_code = productionCode;
|
|
878
931
|
const addPrice = d?.add_price ?? d?.price;
|
|
879
|
-
if (
|
|
932
|
+
if (formatOptions.virtualSettlementMode) {
|
|
933
|
+
option.add_price = 0;
|
|
934
|
+
} else if (addPrice !== undefined) {
|
|
935
|
+
option.add_price = String(addPrice);
|
|
936
|
+
}
|
|
880
937
|
delete option.price;
|
|
881
938
|
return option;
|
|
882
939
|
});
|
|
@@ -893,7 +950,7 @@ function toMoneyString(value) {
|
|
|
893
950
|
}
|
|
894
951
|
|
|
895
952
|
// 出站补齐:只输出后端 checkout 协议字段,运行时/详情展示字段不进入 bundle payload。
|
|
896
|
-
function formatSubmitBundleItems(bundle) {
|
|
953
|
+
function formatSubmitBundleItems(bundle, formatOptions = {}) {
|
|
897
954
|
if (!Array.isArray(bundle)) return [];
|
|
898
955
|
return bundle.map(b => {
|
|
899
956
|
const rawBundle = b && typeof b === 'object' ? b : {};
|
|
@@ -905,10 +962,10 @@ function formatSubmitBundleItems(bundle) {
|
|
|
905
962
|
|
|
906
963
|
// bundle_selling_price 出站存「正净额」:markdown 为 |price| − Σoptions(如 3.70),
|
|
907
964
|
// markup/原价维持原值;与后端口径一致(price 仍为毛价)。
|
|
908
|
-
const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
965
|
+
const sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
909
966
|
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
910
|
-
const paymentPrice = rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
911
|
-
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
967
|
+
const paymentPrice = formatOptions.virtualSettlementMode ? '0.00' : rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
968
|
+
const priceValue = formatOptions.virtualSettlementMode ? 0 : rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
912
969
|
const relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
913
970
|
const surchargeFee = toMoneyString(rawBundle.surcharge_fee ?? existedMetadata.surcharge_fee);
|
|
914
971
|
const productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -917,7 +974,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
917
974
|
const hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
|
|
918
975
|
const productionCode = normalizeSubmitProductionCode(rawBundle.production_code);
|
|
919
976
|
return {
|
|
920
|
-
is_charge_tax: rawBundle.is_charge_tax ?? 0,
|
|
977
|
+
is_charge_tax: formatOptions.virtualSettlementMode ? 0 : rawBundle.is_charge_tax ?? 0,
|
|
921
978
|
bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
|
|
922
979
|
...(productionCode !== undefined ? {
|
|
923
980
|
production_code: productionCode
|
|
@@ -931,7 +988,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
931
988
|
price_type_ext: rawBundle.price_type_ext ?? rawBundle.custom_price_type_ext ?? '',
|
|
932
989
|
bundle_selling_price: sellingPrice,
|
|
933
990
|
bundle_payment_price: paymentPrice,
|
|
934
|
-
option: formatSubmitOptionItems(rawBundle.option),
|
|
991
|
+
option: formatSubmitOptionItems(rawBundle.option, formatOptions),
|
|
935
992
|
bundle_group_id: rawBundle?.bundle_group_id ?? rawBundle?.group_id,
|
|
936
993
|
bundle_id: rawBundle?.bundle_id ?? rawBundle?.id,
|
|
937
994
|
bundle_product_id: rawBundle?.bundle_product_id ?? rawBundle?._bundle_product_id,
|
|
@@ -941,9 +998,9 @@ function formatSubmitBundleItems(bundle) {
|
|
|
941
998
|
...(hasSubmitBundleDiscounts && bundleMapId !== undefined ? {
|
|
942
999
|
custom_product_bundle_map_id: bundleMapId
|
|
943
1000
|
} : {}),
|
|
944
|
-
surcharge_fee: surchargeFee,
|
|
945
|
-
relation_surcharge_ids: relationSurchargeIds,
|
|
946
|
-
product_discount_difference: productDiscountDifference
|
|
1001
|
+
surcharge_fee: formatOptions.virtualSettlementMode ? '0.00' : surchargeFee,
|
|
1002
|
+
relation_surcharge_ids: formatOptions.virtualSettlementMode ? [] : relationSurchargeIds,
|
|
1003
|
+
product_discount_difference: formatOptions.virtualSettlementMode ? '' : productDiscountDifference
|
|
947
1004
|
}
|
|
948
1005
|
};
|
|
949
1006
|
});
|
|
@@ -963,9 +1020,9 @@ function formatSubmitBundleItems(bundle) {
|
|
|
963
1020
|
* - `metadata.main_product_selling_price`:含 option、含主商品折扣。
|
|
964
1021
|
* - `metadata.price_schema_version`:schema 版本号(当前 = 2),用于跨端协商价格口径。
|
|
965
1022
|
*
|
|
966
|
-
*
|
|
1023
|
+
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
967
1024
|
*/
|
|
968
|
-
function normalizeSubmitProduct(product) {
|
|
1025
|
+
function normalizeSubmitProduct(product, formatOptions = {}) {
|
|
969
1026
|
const {
|
|
970
1027
|
unique_identification_number: _runtimeUid,
|
|
971
1028
|
...submitProduct
|
|
@@ -993,7 +1050,7 @@ function normalizeSubmitProduct(product) {
|
|
|
993
1050
|
if (rawMetadata.unique_identification_number) {
|
|
994
1051
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
995
1052
|
}
|
|
996
|
-
const priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price', 'average_discount_amount_rate', 'source_product_price', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder', 'relation_surcharge_ids', 'discountable_flag', 'parent_unique_identification_number', 'product_add_schedule_time'];
|
|
1053
|
+
const priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price', 'average_discount_amount_rate', 'source_product_price', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder', 'relation_surcharge_ids', 'discountable_flag', 'price_schema_version', 'parent_unique_identification_number', 'product_add_schedule_time', 'data_variant_ids'];
|
|
997
1054
|
for (const key of priceMetaKeys) {
|
|
998
1055
|
if (rawMetadata[key] !== undefined) {
|
|
999
1056
|
cleanMetadata[key] = rawMetadata[key];
|
|
@@ -1009,12 +1066,36 @@ function normalizeSubmitProduct(product) {
|
|
|
1009
1066
|
if (rawMetadata.holder_config !== undefined) {
|
|
1010
1067
|
cleanMetadata.holder_config = rawMetadata.holder_config;
|
|
1011
1068
|
}
|
|
1069
|
+
const virtualPrice = toMoneyString(rawMetadata.selected_settlement_snapshot?.price ?? submitProduct.selling_price);
|
|
1070
|
+
if (formatOptions.virtualSettlementMode) {
|
|
1071
|
+
Object.assign(cleanMetadata, {
|
|
1072
|
+
source_product_price: virtualPrice,
|
|
1073
|
+
main_product_original_price: virtualPrice,
|
|
1074
|
+
main_product_selling_price: virtualPrice,
|
|
1075
|
+
main_product_attached_bundle_selling_price: virtualPrice,
|
|
1076
|
+
main_product_attached_bundle_payment_price: virtualPrice,
|
|
1077
|
+
main_product_attached_bundle_surcharge_fee: '0.00',
|
|
1078
|
+
main_product_attached_bundle_tax_fee: '0.00',
|
|
1079
|
+
surcharge_rounding_remainder: '0.00',
|
|
1080
|
+
tax_fee_rounding_remainder: '0.00',
|
|
1081
|
+
relation_surcharge_ids: [],
|
|
1082
|
+
average_discount_amount_rate: '1',
|
|
1083
|
+
product_discount_difference: '',
|
|
1084
|
+
discountable_flag: 0,
|
|
1085
|
+
price_schema_version: 2
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1012
1088
|
const productSku = {
|
|
1013
1089
|
...(submitProduct.product_sku && typeof submitProduct.product_sku === 'object' ? submitProduct.product_sku : {}),
|
|
1014
|
-
option: formatSubmitOptionItems(submitProduct.product_sku?.option)
|
|
1090
|
+
option: formatSubmitOptionItems(submitProduct.product_sku?.option, formatOptions)
|
|
1015
1091
|
};
|
|
1016
1092
|
return {
|
|
1017
1093
|
...productRest,
|
|
1094
|
+
...(formatOptions.virtualSettlementMode ? {
|
|
1095
|
+
selling_price: virtualPrice,
|
|
1096
|
+
original_price: virtualPrice,
|
|
1097
|
+
is_charge_tax: 0
|
|
1098
|
+
} : {}),
|
|
1018
1099
|
...(productionCode !== undefined ? {
|
|
1019
1100
|
production_code: productionCode
|
|
1020
1101
|
} : {}),
|
|
@@ -1026,12 +1107,12 @@ function normalizeSubmitProduct(product) {
|
|
|
1026
1107
|
} : {}),
|
|
1027
1108
|
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
1028
1109
|
product_sku: productSku,
|
|
1029
|
-
discount_list: collectSubmitProductDiscountList(submitProduct),
|
|
1030
|
-
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
1110
|
+
discount_list: formatOptions.virtualSettlementMode ? [] : collectSubmitProductDiscountList(submitProduct),
|
|
1111
|
+
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle, formatOptions),
|
|
1031
1112
|
metadata: cleanMetadata,
|
|
1032
1113
|
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
1033
1114
|
// 由整单折扣均摊层产出;缺省(无折扣)时与 selling_price 同义。
|
|
1034
|
-
payment_price: submitProduct.payment_price ?? submitProduct.selling_price
|
|
1115
|
+
payment_price: formatOptions.virtualSettlementMode ? virtualPrice : submitProduct.payment_price ?? submitProduct.selling_price
|
|
1035
1116
|
};
|
|
1036
1117
|
}
|
|
1037
1118
|
const SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder'];
|
|
@@ -1128,6 +1209,7 @@ function createDefaultTempOrder(params) {
|
|
|
1128
1209
|
request_unique_idempotency_token: '',
|
|
1129
1210
|
vouchers: [],
|
|
1130
1211
|
products: [],
|
|
1212
|
+
notes: [],
|
|
1131
1213
|
bookings: [],
|
|
1132
1214
|
payments: [],
|
|
1133
1215
|
surcharges: [],
|
|
@@ -1137,7 +1219,11 @@ function createDefaultTempOrder(params) {
|
|
|
1137
1219
|
holder: null,
|
|
1138
1220
|
metadata: {},
|
|
1139
1221
|
_extend: {
|
|
1140
|
-
productsByUid: {}
|
|
1222
|
+
productsByUid: {},
|
|
1223
|
+
salesNotesState: {
|
|
1224
|
+
loaded: true,
|
|
1225
|
+
dirty: false
|
|
1226
|
+
}
|
|
1141
1227
|
}
|
|
1142
1228
|
};
|
|
1143
1229
|
}
|
|
@@ -1199,6 +1285,7 @@ function buildSubmitPayload(params) {
|
|
|
1199
1285
|
} = params;
|
|
1200
1286
|
const scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1201
1287
|
const bookingUuid = (0, _orderCollectionIdentity.createUuidV4)();
|
|
1288
|
+
const virtualSettlementMode = tempOrder.metadata?.currency_settlement_config?.settlement_type === 'virtual_currency';
|
|
1202
1289
|
const {
|
|
1203
1290
|
_extend: _extend,
|
|
1204
1291
|
relation_id: _relationId,
|
|
@@ -1213,14 +1300,18 @@ function buildSubmitPayload(params) {
|
|
|
1213
1300
|
start_time: _startTime,
|
|
1214
1301
|
customer: _customer,
|
|
1215
1302
|
discount_list: _discountList,
|
|
1303
|
+
order_meta_list: _orderMetaList,
|
|
1216
1304
|
tax_fee: _rootTaxFee,
|
|
1217
1305
|
total_amount: _totalAmount,
|
|
1218
1306
|
total_refund_amount: _totalRefundAmount,
|
|
1219
1307
|
create_date: _createDate,
|
|
1220
1308
|
holder_id: _holderId,
|
|
1309
|
+
payment_status: _paymentStatus,
|
|
1310
|
+
notes: _notes,
|
|
1221
1311
|
...tempOrderRest
|
|
1222
1312
|
} = tempOrder;
|
|
1223
1313
|
const resolvedBusinessCode = businessCode ?? tempOrder.business_code;
|
|
1314
|
+
const normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1224
1315
|
const submitType = resolveSubmitOrderType({
|
|
1225
1316
|
requestedType: type,
|
|
1226
1317
|
tempOrderType: tempOrder.type,
|
|
@@ -1246,7 +1337,9 @@ function buildSubmitPayload(params) {
|
|
|
1246
1337
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1247
1338
|
order_sales_channel: channel ?? tempOrder.order_sales_channel ?? 'online_store',
|
|
1248
1339
|
status: tempOrder.status || 'normal',
|
|
1249
|
-
|
|
1340
|
+
...(params.includePaymentStatus !== false ? {
|
|
1341
|
+
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
1342
|
+
} : {}),
|
|
1250
1343
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
1251
1344
|
is_price_include_tax: tempOrder.is_price_include_tax ?? 1,
|
|
1252
1345
|
currency_format: tempOrder.currency_format || 'symbol_first',
|
|
@@ -1269,13 +1362,26 @@ function buildSubmitPayload(params) {
|
|
|
1269
1362
|
const {
|
|
1270
1363
|
collect_pax: _collectPax,
|
|
1271
1364
|
table_occupancy_duration: _tableOccupancyDuration,
|
|
1365
|
+
cart_settlement_key: _cartSettlementKey,
|
|
1366
|
+
cart_settlement_snapshot: _cartSettlementSnapshot,
|
|
1367
|
+
legal_currency_snapshot: _legalCurrencySnapshot,
|
|
1272
1368
|
...rest
|
|
1273
1369
|
} = tempOrder.metadata || {};
|
|
1274
1370
|
return {
|
|
1275
1371
|
...rest
|
|
1276
1372
|
};
|
|
1277
1373
|
})(),
|
|
1278
|
-
|
|
1374
|
+
...(tempOrder._extend?.salesNotesState?.dirty ? {
|
|
1375
|
+
notes: (0, _salesNotes.encodeSalesNotes)(tempOrder.notes || [], {
|
|
1376
|
+
allowUnresolvedOrderTarget: true
|
|
1377
|
+
})
|
|
1378
|
+
} : {}),
|
|
1379
|
+
products: (tempOrder.products || []).map(product => normalizeSubmitProduct(product, {
|
|
1380
|
+
virtualSettlementMode
|
|
1381
|
+
})),
|
|
1382
|
+
...(normalizedOrderMetaList !== undefined ? {
|
|
1383
|
+
order_meta_list: normalizedOrderMetaList
|
|
1384
|
+
} : {})
|
|
1279
1385
|
};
|
|
1280
1386
|
if (!enhance) return payload;
|
|
1281
1387
|
const enhancedPayload = enhance(payload, {
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* 现金支付推荐算法
|
|
3
3
|
*
|
|
4
4
|
* 核心原理:
|
|
5
|
-
* 1.
|
|
6
|
-
* 2.
|
|
7
|
-
* 3.
|
|
8
|
-
* 4. 根据组合判断去重,避免扩展组合
|
|
5
|
+
* 1. 第一项始终是精确应付金额
|
|
6
|
+
* 2. 其余推荐只能是严格大于应付金额的真实币种面额
|
|
7
|
+
* 3. 最多推荐三个更高面额
|
|
9
8
|
*/
|
|
10
9
|
/**
|
|
11
10
|
* 常见国家货币面额配置
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
export declare const CURRENCY_DENOMINATIONS: Record<string, number[]>;
|
|
14
13
|
/**
|
|
15
14
|
* 最优支付金额推荐算法
|
|
16
|
-
*
|
|
15
|
+
* 返回精确应付金额,以及最多三个更高的真实币种面额
|
|
17
16
|
*
|
|
18
17
|
* @param targetAmount 目标金额
|
|
19
18
|
* @param denominations 币种面值数组
|