@pisell/pisellos 2.3.101 → 2.3.103
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/promotion/index.js +9 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +29 -3
- package/dist/modules/Order/index.js +1105 -703
- package/dist/modules/Order/types.d.ts +14 -6
- package/dist/modules/Order/types.js +1 -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 +1 -0
- package/dist/modules/Order/utils.js +63 -24
- package/dist/modules/Product/types.d.ts +23 -0
- 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/solution/BaseSales/index.d.ts +10 -1
- package/dist/solution/BaseSales/index.js +1074 -746
- 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 +2 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- 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/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +31 -2
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +29 -3
- package/lib/modules/Order/index.js +326 -51
- package/lib/modules/Order/types.d.ts +14 -6
- package/lib/modules/Order/types.js +1 -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 +1 -0
- package/lib/modules/Order/utils.js +57 -20
- package/lib/modules/Product/types.d.ts +23 -0
- 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/solution/BaseSales/index.d.ts +10 -1
- package/lib/solution/BaseSales/index.js +228 -20
- 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 +2 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var _excluded = ["custom_product_bundle_map_id"],
|
|
2
2
|
_excluded2 = ["unique_identification_number"],
|
|
3
3
|
_excluded3 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per", "production_code"],
|
|
4
|
-
_excluded4 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id", "notes"],
|
|
5
|
-
_excluded5 = ["collect_pax", "table_occupancy_duration"];
|
|
4
|
+
_excluded4 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id", "payment_status", "notes"],
|
|
5
|
+
_excluded5 = ["collect_pax", "table_occupancy_duration", "cart_settlement_key", "cart_settlement_snapshot", "legal_currency_snapshot"];
|
|
6
6
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
7
7
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
8
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
@@ -823,6 +823,7 @@ function normalizeSubmitProductionCode(value) {
|
|
|
823
823
|
|
|
824
824
|
// 后端 checkout 协议字段 option_group_item_id;tempOrder 内部也保持同一字段名。
|
|
825
825
|
function formatSubmitOptionItems(options) {
|
|
826
|
+
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
826
827
|
if (!Array.isArray(options)) return [];
|
|
827
828
|
return options.map(function (d) {
|
|
828
829
|
var _d$add_price;
|
|
@@ -835,7 +836,11 @@ function formatSubmitOptionItems(options) {
|
|
|
835
836
|
delete option.production_code;
|
|
836
837
|
if (productionCode !== undefined) option.production_code = productionCode;
|
|
837
838
|
var addPrice = (_d$add_price = d === null || d === void 0 ? void 0 : d.add_price) !== null && _d$add_price !== void 0 ? _d$add_price : d === null || d === void 0 ? void 0 : d.price;
|
|
838
|
-
if (
|
|
839
|
+
if (formatOptions.virtualSettlementMode) {
|
|
840
|
+
option.add_price = 0;
|
|
841
|
+
} else if (addPrice !== undefined) {
|
|
842
|
+
option.add_price = String(addPrice);
|
|
843
|
+
}
|
|
839
844
|
delete option.price;
|
|
840
845
|
return option;
|
|
841
846
|
});
|
|
@@ -854,6 +859,7 @@ function toMoneyString(value) {
|
|
|
854
859
|
|
|
855
860
|
// 出站补齐:只输出后端 checkout 协议字段,运行时/详情展示字段不进入 bundle payload。
|
|
856
861
|
function formatSubmitBundleItems(bundle) {
|
|
862
|
+
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
857
863
|
if (!Array.isArray(bundle)) return [];
|
|
858
864
|
return bundle.map(function (b) {
|
|
859
865
|
var _ref25, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref26, _rawBundle$price_type, _ref27, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
|
|
@@ -864,10 +870,10 @@ function formatSubmitBundleItems(bundle) {
|
|
|
864
870
|
|
|
865
871
|
// bundle_selling_price 出站存「正净额」:markdown 为 |price| − Σoptions(如 3.70),
|
|
866
872
|
// markup/原价维持原值;与后端口径一致(price 仍为毛价)。
|
|
867
|
-
var sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
873
|
+
var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
868
874
|
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
869
|
-
var paymentPrice = rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
870
|
-
var priceValue = (_ref25 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref25 !== void 0 ? _ref25 : rawBundle.bundle_selling_price;
|
|
875
|
+
var 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;
|
|
876
|
+
var priceValue = formatOptions.virtualSettlementMode ? 0 : (_ref25 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref25 !== void 0 ? _ref25 : rawBundle.bundle_selling_price;
|
|
871
877
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
872
878
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
873
879
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -876,7 +882,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
876
882
|
var hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
|
|
877
883
|
var productionCode = normalizeSubmitProductionCode(rawBundle.production_code);
|
|
878
884
|
return _objectSpread(_objectSpread({
|
|
879
|
-
is_charge_tax: (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
|
|
885
|
+
is_charge_tax: formatOptions.virtualSettlementMode ? 0 : (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
|
|
880
886
|
bundle_variant_id: (_rawBundle$bundle_var = rawBundle.bundle_variant_id) !== null && _rawBundle$bundle_var !== void 0 ? _rawBundle$bundle_var : 0
|
|
881
887
|
}, productionCode !== undefined ? {
|
|
882
888
|
production_code: productionCode
|
|
@@ -890,7 +896,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
890
896
|
price_type_ext: (_ref27 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref27 !== void 0 ? _ref27 : '',
|
|
891
897
|
bundle_selling_price: sellingPrice,
|
|
892
898
|
bundle_payment_price: paymentPrice,
|
|
893
|
-
option: formatSubmitOptionItems(rawBundle.option),
|
|
899
|
+
option: formatSubmitOptionItems(rawBundle.option, formatOptions),
|
|
894
900
|
bundle_group_id: (_rawBundle$bundle_gro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_group_id) !== null && _rawBundle$bundle_gro !== void 0 ? _rawBundle$bundle_gro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
|
|
895
901
|
bundle_id: (_rawBundle$bundle_id = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_id) !== null && _rawBundle$bundle_id !== void 0 ? _rawBundle$bundle_id : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.id,
|
|
896
902
|
bundle_product_id: (_rawBundle$bundle_pro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_product_id) !== null && _rawBundle$bundle_pro !== void 0 ? _rawBundle$bundle_pro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle._bundle_product_id,
|
|
@@ -898,9 +904,9 @@ function formatSubmitBundleItems(bundle) {
|
|
|
898
904
|
metadata: _objectSpread(_objectSpread(_objectSpread({}, submitMetadata), hasSubmitBundleDiscounts && bundleMapId !== undefined ? {
|
|
899
905
|
custom_product_bundle_map_id: bundleMapId
|
|
900
906
|
} : {}), {}, {
|
|
901
|
-
surcharge_fee: surchargeFee,
|
|
902
|
-
relation_surcharge_ids: relationSurchargeIds,
|
|
903
|
-
product_discount_difference: productDiscountDifference
|
|
907
|
+
surcharge_fee: formatOptions.virtualSettlementMode ? '0.00' : surchargeFee,
|
|
908
|
+
relation_surcharge_ids: formatOptions.virtualSettlementMode ? [] : relationSurchargeIds,
|
|
909
|
+
product_discount_difference: formatOptions.virtualSettlementMode ? '' : productDiscountDifference
|
|
904
910
|
})
|
|
905
911
|
});
|
|
906
912
|
});
|
|
@@ -920,10 +926,11 @@ function formatSubmitBundleItems(bundle) {
|
|
|
920
926
|
* - `metadata.main_product_selling_price`:含 option、含主商品折扣。
|
|
921
927
|
* - `metadata.price_schema_version`:schema 版本号(当前 = 2),用于跨端协商价格口径。
|
|
922
928
|
*
|
|
923
|
-
*
|
|
929
|
+
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
924
930
|
*/
|
|
925
931
|
function normalizeSubmitProduct(product) {
|
|
926
|
-
var _ref29, _submitProduct$bundle, _rawMetadata$product_, _submitProduct$produc, _submitProduct$paymen;
|
|
932
|
+
var _ref29, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
933
|
+
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
927
934
|
var _ref28 = product,
|
|
928
935
|
_runtimeUid = _ref28.unique_identification_number,
|
|
929
936
|
submitProduct = _objectWithoutProperties(_ref28, _excluded2);
|
|
@@ -948,7 +955,7 @@ function normalizeSubmitProduct(product) {
|
|
|
948
955
|
if (rawMetadata.unique_identification_number) {
|
|
949
956
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
950
957
|
}
|
|
951
|
-
var 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'];
|
|
958
|
+
var 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'];
|
|
952
959
|
for (var _i = 0, _priceMetaKeys = priceMetaKeys; _i < _priceMetaKeys.length; _i++) {
|
|
953
960
|
var key = _priceMetaKeys[_i];
|
|
954
961
|
if (rawMetadata[key] !== undefined) {
|
|
@@ -965,10 +972,33 @@ function normalizeSubmitProduct(product) {
|
|
|
965
972
|
if (rawMetadata.holder_config !== undefined) {
|
|
966
973
|
cleanMetadata.holder_config = rawMetadata.holder_config;
|
|
967
974
|
}
|
|
975
|
+
var virtualPrice = toMoneyString((_rawMetadata$selected = (_rawMetadata$selected2 = rawMetadata.selected_settlement_snapshot) === null || _rawMetadata$selected2 === void 0 ? void 0 : _rawMetadata$selected2.price) !== null && _rawMetadata$selected !== void 0 ? _rawMetadata$selected : submitProduct.selling_price);
|
|
976
|
+
if (formatOptions.virtualSettlementMode) {
|
|
977
|
+
Object.assign(cleanMetadata, {
|
|
978
|
+
source_product_price: virtualPrice,
|
|
979
|
+
main_product_original_price: virtualPrice,
|
|
980
|
+
main_product_selling_price: virtualPrice,
|
|
981
|
+
main_product_attached_bundle_selling_price: virtualPrice,
|
|
982
|
+
main_product_attached_bundle_payment_price: virtualPrice,
|
|
983
|
+
main_product_attached_bundle_surcharge_fee: '0.00',
|
|
984
|
+
main_product_attached_bundle_tax_fee: '0.00',
|
|
985
|
+
surcharge_rounding_remainder: '0.00',
|
|
986
|
+
tax_fee_rounding_remainder: '0.00',
|
|
987
|
+
relation_surcharge_ids: [],
|
|
988
|
+
average_discount_amount_rate: '1',
|
|
989
|
+
product_discount_difference: '',
|
|
990
|
+
discountable_flag: 0,
|
|
991
|
+
price_schema_version: 2
|
|
992
|
+
});
|
|
993
|
+
}
|
|
968
994
|
var productSku = _objectSpread(_objectSpread({}, submitProduct.product_sku && _typeof(submitProduct.product_sku) === 'object' ? submitProduct.product_sku : {}), {}, {
|
|
969
|
-
option: formatSubmitOptionItems((_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option)
|
|
995
|
+
option: formatSubmitOptionItems((_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option, formatOptions)
|
|
970
996
|
});
|
|
971
|
-
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, productRest),
|
|
997
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, productRest), formatOptions.virtualSettlementMode ? {
|
|
998
|
+
selling_price: virtualPrice,
|
|
999
|
+
original_price: virtualPrice,
|
|
1000
|
+
is_charge_tax: 0
|
|
1001
|
+
} : {}), productionCode !== undefined ? {
|
|
972
1002
|
production_code: productionCode
|
|
973
1003
|
} : {}), bookingUid ? {
|
|
974
1004
|
booking_uid: bookingUid
|
|
@@ -977,12 +1007,12 @@ function normalizeSubmitProduct(product) {
|
|
|
977
1007
|
} : {}), {}, {
|
|
978
1008
|
product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
|
|
979
1009
|
product_sku: productSku,
|
|
980
|
-
discount_list: collectSubmitProductDiscountList(submitProduct),
|
|
981
|
-
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
1010
|
+
discount_list: formatOptions.virtualSettlementMode ? [] : collectSubmitProductDiscountList(submitProduct),
|
|
1011
|
+
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle, formatOptions),
|
|
982
1012
|
metadata: cleanMetadata,
|
|
983
1013
|
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
984
1014
|
// 由整单折扣均摊层产出;缺省(无折扣)时与 selling_price 同义。
|
|
985
|
-
payment_price: (_submitProduct$paymen = submitProduct.payment_price) !== null && _submitProduct$paymen !== void 0 ? _submitProduct$paymen : submitProduct.selling_price
|
|
1015
|
+
payment_price: formatOptions.virtualSettlementMode ? virtualPrice : (_submitProduct$paymen = submitProduct.payment_price) !== null && _submitProduct$paymen !== void 0 ? _submitProduct$paymen : submitProduct.selling_price
|
|
986
1016
|
});
|
|
987
1017
|
}
|
|
988
1018
|
var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder'];
|
|
@@ -1151,7 +1181,7 @@ export function resolveSubmitOrderType(params) {
|
|
|
1151
1181
|
return 'virtual';
|
|
1152
1182
|
}
|
|
1153
1183
|
export function buildSubmitPayload(params) {
|
|
1154
|
-
var _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref31, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhancedPayload$summ;
|
|
1184
|
+
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref31, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhancedPayload$summ;
|
|
1155
1185
|
var tempOrder = params.tempOrder,
|
|
1156
1186
|
cacheId = params.cacheId,
|
|
1157
1187
|
_params$now = params.now,
|
|
@@ -1164,6 +1194,7 @@ export function buildSubmitPayload(params) {
|
|
|
1164
1194
|
enhance = params.enhance;
|
|
1165
1195
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1166
1196
|
var bookingUuid = createUuidV4();
|
|
1197
|
+
var virtualSettlementMode = ((_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2.settlement_type) === 'virtual_currency';
|
|
1167
1198
|
var _ref30 = tempOrder,
|
|
1168
1199
|
_extend = _ref30._extend,
|
|
1169
1200
|
_relationId = _ref30.relation_id,
|
|
@@ -1183,6 +1214,7 @@ export function buildSubmitPayload(params) {
|
|
|
1183
1214
|
_totalRefundAmount = _ref30.total_refund_amount,
|
|
1184
1215
|
_createDate = _ref30.create_date,
|
|
1185
1216
|
_holderId = _ref30.holder_id,
|
|
1217
|
+
_paymentStatus = _ref30.payment_status,
|
|
1186
1218
|
_notes = _ref30.notes,
|
|
1187
1219
|
tempOrderRest = _objectWithoutProperties(_ref30, _excluded4);
|
|
1188
1220
|
var resolvedBusinessCode = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code;
|
|
@@ -1194,7 +1226,7 @@ export function buildSubmitPayload(params) {
|
|
|
1194
1226
|
tempOrderBusinessCode: tempOrder.business_code,
|
|
1195
1227
|
bookings: tempOrder.bookings
|
|
1196
1228
|
});
|
|
1197
|
-
var payload = _objectSpread(_objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
1229
|
+
var payload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
1198
1230
|
customer_id: (_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : 1,
|
|
1199
1231
|
customer_name: tempOrder.customer_name || 'Walk-In',
|
|
1200
1232
|
country_calling_code: String((_tempOrder$country_ca = tempOrder.country_calling_code) !== null && _tempOrder$country_ca !== void 0 ? _tempOrder$country_ca : ''),
|
|
@@ -1209,8 +1241,10 @@ export function buildSubmitPayload(params) {
|
|
|
1209
1241
|
business_code: resolvedBusinessCode,
|
|
1210
1242
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1211
1243
|
order_sales_channel: (_ref31 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref31 !== void 0 ? _ref31 : 'online_store',
|
|
1212
|
-
status: tempOrder.status || 'normal'
|
|
1213
|
-
|
|
1244
|
+
status: tempOrder.status || 'normal'
|
|
1245
|
+
}, params.includePaymentStatus !== false ? {
|
|
1246
|
+
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
1247
|
+
} : {}), {}, {
|
|
1214
1248
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
1215
1249
|
is_price_include_tax: (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : 1,
|
|
1216
1250
|
currency_format: tempOrder.currency_format || 'symbol_first',
|
|
@@ -1237,6 +1271,9 @@ export function buildSubmitPayload(params) {
|
|
|
1237
1271
|
var _ref32 = tempOrder.metadata || {},
|
|
1238
1272
|
_collectPax = _ref32.collect_pax,
|
|
1239
1273
|
_tableOccupancyDuration = _ref32.table_occupancy_duration,
|
|
1274
|
+
_cartSettlementKey = _ref32.cart_settlement_key,
|
|
1275
|
+
_cartSettlementSnapshot = _ref32.cart_settlement_snapshot,
|
|
1276
|
+
_legalCurrencySnapshot = _ref32.legal_currency_snapshot,
|
|
1240
1277
|
rest = _objectWithoutProperties(_ref32, _excluded5);
|
|
1241
1278
|
return _objectSpread({}, rest);
|
|
1242
1279
|
}()
|
|
@@ -1246,7 +1283,9 @@ export function buildSubmitPayload(params) {
|
|
|
1246
1283
|
})
|
|
1247
1284
|
} : {}), {}, {
|
|
1248
1285
|
products: (tempOrder.products || []).map(function (product) {
|
|
1249
|
-
return normalizeSubmitProduct(product
|
|
1286
|
+
return normalizeSubmitProduct(product, {
|
|
1287
|
+
virtualSettlementMode: virtualSettlementMode
|
|
1288
|
+
});
|
|
1250
1289
|
})
|
|
1251
1290
|
});
|
|
1252
1291
|
if (!enhance) return payload;
|
|
@@ -23,12 +23,25 @@ export interface ProductDataVariant {
|
|
|
23
23
|
module_data_id: number;
|
|
24
24
|
/** 关联 data_variant_rule.id */
|
|
25
25
|
data_variant_rule_id: number;
|
|
26
|
+
/** 多货币结算等业务类型 */
|
|
27
|
+
business_type?: 'multi_currency_settlement' | string;
|
|
28
|
+
/** 数据状态;多货币结算仅处理 enable 记录 */
|
|
29
|
+
status?: 'enable' | 'disable' | string;
|
|
26
30
|
/** 命中策略后覆盖到商品上的字段 */
|
|
27
31
|
data: Record<string, any>;
|
|
28
32
|
created_at: string | null;
|
|
29
33
|
updated_at: string | null;
|
|
30
34
|
deleted_at: string | null;
|
|
31
35
|
}
|
|
36
|
+
export interface ProductSettlementOption extends Record<string, any> {
|
|
37
|
+
settlement_type: 'legal_currency' | 'virtual_currency' | string;
|
|
38
|
+
currency_product_id?: number;
|
|
39
|
+
price: string;
|
|
40
|
+
data_variant_id?: number;
|
|
41
|
+
data_variant_rule_id: number | string;
|
|
42
|
+
available: boolean;
|
|
43
|
+
disabled_reason?: string;
|
|
44
|
+
}
|
|
32
45
|
/**
|
|
33
46
|
* 商品基本信息接口
|
|
34
47
|
*/
|
|
@@ -61,6 +74,8 @@ export interface ProductData {
|
|
|
61
74
|
sum_stock: number;
|
|
62
75
|
/** 商品价格 */
|
|
63
76
|
price: string;
|
|
77
|
+
/** 当前上下文解析出的可选结算货币 */
|
|
78
|
+
available_settlement_options?: ProductSettlementOption[];
|
|
64
79
|
/** 商品原价 */
|
|
65
80
|
original_price: string;
|
|
66
81
|
/** 商品成本价 */
|
|
@@ -239,6 +254,14 @@ export interface ProductData {
|
|
|
239
254
|
option_group_count: number;
|
|
240
255
|
/** 智能定价变体列表,/product/query with dataVariants 返回 */
|
|
241
256
|
data_variants?: ProductDataVariant[];
|
|
257
|
+
/**
|
|
258
|
+
* 商品接口规则计算结果;data_variant_ids 按优先级从高到低排列。
|
|
259
|
+
* 空数组表示规则已经计算完成但没有命中 Data Variant。
|
|
260
|
+
*/
|
|
261
|
+
metadata?: {
|
|
262
|
+
data_variant_ids?: Array<number | string>;
|
|
263
|
+
[key: string]: any;
|
|
264
|
+
};
|
|
242
265
|
/** 服务时长 */
|
|
243
266
|
service_times?: any;
|
|
244
267
|
}
|
|
@@ -30,6 +30,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
30
30
|
taxRate?: number;
|
|
31
31
|
shopDiscount?: string | number;
|
|
32
32
|
channel?: string;
|
|
33
|
+
virtualSettlementMode?: boolean;
|
|
33
34
|
}): Promise<{
|
|
34
35
|
tax_title: string;
|
|
35
36
|
tax_rate: number | undefined;
|
|
@@ -213,11 +213,11 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
213
213
|
value: function () {
|
|
214
214
|
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
215
215
|
var _this$otherParams2, _this$store$surcharge, _ref;
|
|
216
|
-
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, summaryChannel, taxConfig, fatherModuleName, scheduleModuleName, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
216
|
+
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, _params$virtualSettle, virtualSettlementMode, summaryChannel, taxConfig, fatherModuleName, scheduleModuleName, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
217
217
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
218
218
|
while (1) switch (_context4.prev = _context4.next) {
|
|
219
219
|
case 0:
|
|
220
|
-
_params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount, channel = params.channel;
|
|
220
|
+
_params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount, channel = params.channel, _params$virtualSettle = params.virtualSettlementMode, virtualSettlementMode = _params$virtualSettle === void 0 ? false : _params$virtualSettle;
|
|
221
221
|
summaryChannel = channel || this.resolveChannel();
|
|
222
222
|
if (!(summaryChannel !== this.surchargeListChannel)) {
|
|
223
223
|
_context4.next = 5;
|
|
@@ -257,7 +257,8 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
257
257
|
surchargeList: this.store.surchargeList,
|
|
258
258
|
scheduleById: scheduleById,
|
|
259
259
|
isInScheduleByDate: ScheduleModule.isInScheduleByDate,
|
|
260
|
-
shopDiscount: shopDiscount
|
|
260
|
+
shopDiscount: shopDiscount,
|
|
261
|
+
virtualSettlementMode: virtualSettlementMode
|
|
261
262
|
});
|
|
262
263
|
summaryWithTaxMeta = _objectSpread(_objectSpread({}, summary), {}, {
|
|
263
264
|
tax_title: taxConfig.taxTitle || '',
|
|
@@ -1039,12 +1039,32 @@ export function calculateSalesSummary(params) {
|
|
|
1039
1039
|
_params$scheduleById = params.scheduleById,
|
|
1040
1040
|
scheduleById = _params$scheduleById === void 0 ? {} : _params$scheduleById,
|
|
1041
1041
|
isInScheduleByDate = params.isInScheduleByDate,
|
|
1042
|
-
shopDiscount = params.shopDiscount
|
|
1042
|
+
shopDiscount = params.shopDiscount,
|
|
1043
|
+
_params$virtualSettle = params.virtualSettlementMode,
|
|
1044
|
+
virtualSettlementMode = _params$virtualSettle === void 0 ? false : _params$virtualSettle;
|
|
1043
1045
|
if (!(products !== null && products !== void 0 && products.length)) return createEmptySalesSummary();
|
|
1044
1046
|
var summaryProducts = products.filter(function (product) {
|
|
1045
1047
|
return !isGeneratedVoucherProduct(product);
|
|
1046
1048
|
});
|
|
1047
1049
|
if (!summaryProducts.length) return createEmptySalesSummary();
|
|
1050
|
+
if (virtualSettlementMode) {
|
|
1051
|
+
var _productQuantity = summaryProducts.reduce(function (sum, item) {
|
|
1052
|
+
return sum + getSafeNum(item.num);
|
|
1053
|
+
}, 0);
|
|
1054
|
+
var _productAmount = summaryProducts.reduce(function (sum, item) {
|
|
1055
|
+
return sum.plus(toDecimal(item.selling_price).times(getSafeNum(item.num)));
|
|
1056
|
+
}, new Decimal(0));
|
|
1057
|
+
var amount = toFixed2(_productAmount);
|
|
1058
|
+
return _objectSpread(_objectSpread({}, createEmptySalesSummary()), {}, {
|
|
1059
|
+
product_quantity: _productQuantity,
|
|
1060
|
+
product_original_amount: amount,
|
|
1061
|
+
product_amount: amount,
|
|
1062
|
+
product_expect_amount: amount,
|
|
1063
|
+
expect_amount: amount,
|
|
1064
|
+
total_amount: amount,
|
|
1065
|
+
is_price_include_tax: isPriceIncludeTax
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1048
1068
|
var productQuantity = summaryProducts.reduce(function (sum, item) {
|
|
1049
1069
|
return sum + getSafeNum(item.num);
|
|
1050
1070
|
}, 0);
|
|
@@ -4,7 +4,7 @@ import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentS
|
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
5
|
import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from '../../modules/Order/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
|
-
import type { Discount } from '../../modules/Discount/types';
|
|
7
|
+
import type { Discount, VirtualCurrencyAsset } from '../../modules/Discount/types';
|
|
8
8
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
9
9
|
export * from './types';
|
|
10
10
|
import { ProductList } from '../../modules/ProductList';
|
|
@@ -193,6 +193,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
193
193
|
protected setPaymentNumberDevicePrefix(prefix: unknown): void;
|
|
194
194
|
private getPaymentNumberDevicePrefixSync;
|
|
195
195
|
private getPaymentNumberDevicePrefixAsync;
|
|
196
|
+
private isMultiCurrencySettlementEnabled;
|
|
197
|
+
private isActiveVirtualSettlementOrder;
|
|
198
|
+
private isHistoricalVirtualSettlementOrder;
|
|
196
199
|
private syncAppDataToTempOrder;
|
|
197
200
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
198
201
|
destroy(): Promise<void>;
|
|
@@ -253,6 +256,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
253
256
|
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
254
257
|
*/
|
|
255
258
|
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
259
|
+
/** 切换法币 / WalletPass 单位时清空商品、折扣与支付状态,保留客户。 */
|
|
260
|
+
clearOrderForSettlementSwitch(): Promise<OrderTempOrder>;
|
|
256
261
|
getOrderProducts(): import("../../modules/Order/types").OrderProduct[];
|
|
257
262
|
getSummary(): Promise<OrderSummary>;
|
|
258
263
|
private getHistoricalProductDiscountList;
|
|
@@ -263,12 +268,15 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
263
268
|
loadDiscountConfig(params?: {
|
|
264
269
|
customerId?: number;
|
|
265
270
|
action?: 'create' | 'edit';
|
|
271
|
+
force?: boolean;
|
|
266
272
|
}): Promise<{
|
|
267
273
|
productList: Record<string, any>[];
|
|
268
274
|
discountList: Discount[];
|
|
269
275
|
availableWalletIds: number[];
|
|
276
|
+
virtualCurrencyList: VirtualCurrencyAsset[];
|
|
270
277
|
}>;
|
|
271
278
|
getAvailableWalletIds(): number[];
|
|
279
|
+
getVirtualCurrencyList(): VirtualCurrencyAsset[];
|
|
272
280
|
bestDiscount(cb?: (result: any) => void): Promise<{
|
|
273
281
|
productList: Record<string, any>[];
|
|
274
282
|
discountList: Discount[];
|
|
@@ -300,6 +308,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
300
308
|
confirmPendingVoucherPayments?: boolean;
|
|
301
309
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
302
310
|
}): Promise<T>;
|
|
311
|
+
private buildVirtualSettlementSubmitData;
|
|
303
312
|
/**
|
|
304
313
|
* 提交当前 Sales 订单。
|
|
305
314
|
*
|