@pisell/pisellos 2.2.147 → 2.2.149
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +251 -196
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +31 -4
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesSummary } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 构建金额全为 0 的空 summary。
|
|
4
|
+
* 作为尚未计算金额时的兜底默认值,避免下游因 undefined 报错。
|
|
5
|
+
*/
|
|
6
|
+
export declare function createEmptySummary(): BaseSalesSummary;
|
|
7
|
+
/**
|
|
8
|
+
* 将选项行 / 套餐行归一成稳定 JSON,用于「同 SKU 是否合并」判断。
|
|
9
|
+
* 数组元素先按主键排序再序列化,避免顺序差异导致误判为不同行。
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildProductLineFingerprint(productOptionItem?: unknown, productBundle?: unknown): string;
|
|
12
|
+
export declare function getSafeProductNum(num?: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
|
|
15
|
+
* 与显式 `product_option_item: []` 区分:后者只匹配「无选项」行。
|
|
16
|
+
*/
|
|
17
|
+
export declare function isSkuOnlyDeleteIdentity(x: BaseSalesOrderProductIdentity): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 对外部传入的商品对象做归一化(v2 composite 语义):
|
|
20
|
+
* - 补全可选字段默认值(未传则使用兜底值,避免后续计算时因 undefined 导致异常)
|
|
21
|
+
* - 对 num 调用 getSafeProductNum 做安全处理
|
|
22
|
+
* - 保留 _origin 供后续业务流程(如促销规则)使用
|
|
23
|
+
*
|
|
24
|
+
* 价格字段语义(metadata 权威源 + composite 派生):
|
|
25
|
+
* - `metadata.source_product_price`:主商品/variant 基础价(已应用报价单),**不含 option**、
|
|
26
|
+
* **不含折扣**。是推导 main_product_* 的起点。variant 分支优先读 `metadata.origin.variant[vid].price`。
|
|
27
|
+
* - `metadata.main_product_original_price`:`source + Σ(option.price × option.num)`,**含 option**、
|
|
28
|
+
* **不含折扣**。
|
|
29
|
+
* - `metadata.main_product_selling_price`:`main_product_original_price - 主商品券 per-unit amount`,
|
|
30
|
+
* **含 option**、**含折扣**。
|
|
31
|
+
* - 行级 `selling_price` = `main_product_selling_price + Σ(bundle_selling_price × num)`。
|
|
32
|
+
* - 行级 `original_price` = `main_product_original_price + Σ(bundle 原价 × num)`。
|
|
33
|
+
*
|
|
34
|
+
* 迁移与幂等:
|
|
35
|
+
* - `metadata.price_schema_version === 2` → 已新语义归一化,保留 main_product_* 原值(保留折扣)。
|
|
36
|
+
* - 其它情况(v1 / 缺字段 / 无 metadata)→ 按"main_product_selling_price 曾是 main-only"的旧约定
|
|
37
|
+
* 反推 legacyDiscount,再以新 source + options 基准重算。最终统一打上 `price_schema_version: 2`。
|
|
38
|
+
* - 因此多次 normalize 不会重复叠加 option/bundle。
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeOrderProduct(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity): BaseSalesOrderProduct;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import Decimal from 'decimal.js';
|
|
8
|
+
import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 构建金额全为 0 的空 summary。
|
|
12
|
+
* 作为尚未计算金额时的兜底默认值,避免下游因 undefined 报错。
|
|
13
|
+
*/
|
|
14
|
+
export function createEmptySummary() {
|
|
15
|
+
return {
|
|
16
|
+
product_quantity: 0,
|
|
17
|
+
product_original_amount: '0.00',
|
|
18
|
+
product_amount: '0.00',
|
|
19
|
+
product_expect_amount: '0.00',
|
|
20
|
+
product_tax_fee: '0.00',
|
|
21
|
+
shipping_fee: '0.00',
|
|
22
|
+
shipping_tax_fee: '0.00',
|
|
23
|
+
tax_fee: '0.00',
|
|
24
|
+
surcharge_fee: '0.00',
|
|
25
|
+
discount_amount: '0.00',
|
|
26
|
+
deposit_amount: '0.00',
|
|
27
|
+
expect_amount: '0.00',
|
|
28
|
+
total_amount: '0.00',
|
|
29
|
+
amount_gap: '0.00',
|
|
30
|
+
rounding_amount: '0.00',
|
|
31
|
+
pay_service_charge_amount: '0.00'
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 将选项行 / 套餐行归一成稳定 JSON,用于「同 SKU 是否合并」判断。
|
|
36
|
+
* 数组元素先按主键排序再序列化,避免顺序差异导致误判为不同行。
|
|
37
|
+
*/
|
|
38
|
+
export function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
39
|
+
var optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
|
|
40
|
+
var normalizedOpts = optArr.map(function (item) {
|
|
41
|
+
var _item$price;
|
|
42
|
+
return {
|
|
43
|
+
product_option_item_id: Number(item === null || item === void 0 ? void 0 : item.product_option_item_id) || 0,
|
|
44
|
+
option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
|
|
45
|
+
num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
46
|
+
price: String((_item$price = item === null || item === void 0 ? void 0 : item.price) !== null && _item$price !== void 0 ? _item$price : '')
|
|
47
|
+
};
|
|
48
|
+
}).sort(function (p, q) {
|
|
49
|
+
if (p.product_option_item_id !== q.product_option_item_id) {
|
|
50
|
+
return p.product_option_item_id - q.product_option_item_id;
|
|
51
|
+
}
|
|
52
|
+
if (p.option_group_id !== q.option_group_id) return p.option_group_id - q.option_group_id;
|
|
53
|
+
if (p.num !== q.num) return p.num - q.num;
|
|
54
|
+
return p.price.localeCompare(q.price);
|
|
55
|
+
});
|
|
56
|
+
var bundleArr = Array.isArray(productBundle) ? productBundle : [];
|
|
57
|
+
var normalizedBundles = bundleArr.map(function (item) {
|
|
58
|
+
var _ref, _item$bundle_id;
|
|
59
|
+
return {
|
|
60
|
+
bundle_id: Number((_ref = (_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref !== void 0 ? _ref : 0) || 0,
|
|
61
|
+
product_id: Number(item === null || item === void 0 ? void 0 : item.product_id) || 0,
|
|
62
|
+
num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1
|
|
63
|
+
};
|
|
64
|
+
}).sort(function (p, q) {
|
|
65
|
+
if (p.bundle_id !== q.bundle_id) return p.bundle_id - q.bundle_id;
|
|
66
|
+
if (p.product_id !== q.product_id) return p.product_id - q.product_id;
|
|
67
|
+
return p.num - q.num;
|
|
68
|
+
});
|
|
69
|
+
return JSON.stringify([normalizedOpts, normalizedBundles]);
|
|
70
|
+
}
|
|
71
|
+
export function getSafeProductNum(num) {
|
|
72
|
+
if (!num || Number.isNaN(num)) return 1;
|
|
73
|
+
if (num < 1) return 1;
|
|
74
|
+
return Math.floor(num);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
|
|
79
|
+
* 与显式 `product_option_item: []` 区分:后者只匹配「无选项」行。
|
|
80
|
+
*/
|
|
81
|
+
export function isSkuOnlyDeleteIdentity(x) {
|
|
82
|
+
if (x.identity_key) return false;
|
|
83
|
+
return !('product_option_item' in x) && !('product_bundle' in x);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 对外部传入的商品对象做归一化(v2 composite 语义):
|
|
88
|
+
* - 补全可选字段默认值(未传则使用兜底值,避免后续计算时因 undefined 导致异常)
|
|
89
|
+
* - 对 num 调用 getSafeProductNum 做安全处理
|
|
90
|
+
* - 保留 _origin 供后续业务流程(如促销规则)使用
|
|
91
|
+
*
|
|
92
|
+
* 价格字段语义(metadata 权威源 + composite 派生):
|
|
93
|
+
* - `metadata.source_product_price`:主商品/variant 基础价(已应用报价单),**不含 option**、
|
|
94
|
+
* **不含折扣**。是推导 main_product_* 的起点。variant 分支优先读 `metadata.origin.variant[vid].price`。
|
|
95
|
+
* - `metadata.main_product_original_price`:`source + Σ(option.price × option.num)`,**含 option**、
|
|
96
|
+
* **不含折扣**。
|
|
97
|
+
* - `metadata.main_product_selling_price`:`main_product_original_price - 主商品券 per-unit amount`,
|
|
98
|
+
* **含 option**、**含折扣**。
|
|
99
|
+
* - 行级 `selling_price` = `main_product_selling_price + Σ(bundle_selling_price × num)`。
|
|
100
|
+
* - 行级 `original_price` = `main_product_original_price + Σ(bundle 原价 × num)`。
|
|
101
|
+
*
|
|
102
|
+
* 迁移与幂等:
|
|
103
|
+
* - `metadata.price_schema_version === 2` → 已新语义归一化,保留 main_product_* 原值(保留折扣)。
|
|
104
|
+
* - 其它情况(v1 / 缺字段 / 无 metadata)→ 按"main_product_selling_price 曾是 main-only"的旧约定
|
|
105
|
+
* 反推 legacyDiscount,再以新 source + options 基准重算。最终统一打上 `price_schema_version: 2`。
|
|
106
|
+
* - 因此多次 normalize 不会重复叠加 option/bundle。
|
|
107
|
+
*/
|
|
108
|
+
export function normalizeOrderProduct(product) {
|
|
109
|
+
var _product$metadata, _metadata$origin, _variantList$find, _product$is_charge_ta;
|
|
110
|
+
var metadata = _objectSpread({}, product.metadata || {});
|
|
111
|
+
// 不透明 identity 契约:每条订单行必须带 identity_key。
|
|
112
|
+
// 调用方未传时由 SDK 自动生成 UUID,后续 update/remove 只做严格比对,避免猜测合成 key。
|
|
113
|
+
var resolvedIdentityKey = (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.unique_identification_number ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : createUuidV4();
|
|
114
|
+
metadata.unique_identification_number = resolvedIdentityKey;
|
|
115
|
+
var normalizedBundle = (product.product_bundle || []).map(function (item) {
|
|
116
|
+
var _ref2, _item$bundle_selling_, _ref3, _ref4, _item$price2, _ref5, _item$price_type, _ref6, _item$price_type_ext;
|
|
117
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
118
|
+
bundle_selling_price: (_ref2 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref2 !== void 0 ? _ref2 : '0.00',
|
|
119
|
+
price: (_ref3 = (_ref4 = (_item$price2 = item.price) !== null && _item$price2 !== void 0 ? _item$price2 : item.custom_price) !== null && _ref4 !== void 0 ? _ref4 : item.bundle_selling_price) !== null && _ref3 !== void 0 ? _ref3 : '0.00',
|
|
120
|
+
price_type: (_ref5 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref5 !== void 0 ? _ref5 : '',
|
|
121
|
+
price_type_ext: (_ref6 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref6 !== void 0 ? _ref6 : ''
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
var normalizedOptions = product.product_option_item || [];
|
|
125
|
+
var optionSum = sumOptionUnitPrice(normalizedOptions);
|
|
126
|
+
|
|
127
|
+
// 1) 解析 source_product_price。
|
|
128
|
+
// 优先级:
|
|
129
|
+
// 1) metadata.source_product_price(v2 权威)
|
|
130
|
+
// 2) variantPrice(命中 variant_id,从 metadata.origin.variant[vid].price 读)
|
|
131
|
+
// 3) _origin.price / _origin.base_price(后端语义的基础价)
|
|
132
|
+
// 4) v1 兼容:无 v2 标记但存在 metadata.main_product_original_price(v1 main-only,即旧 source)
|
|
133
|
+
// 5) 入参 original_price(v1 addProduct 约定:original_price 为 pre-discount 基础价)
|
|
134
|
+
// 6) 入参 selling_price(最末兜底,新添加路径 caller 只给 selling_price)
|
|
135
|
+
var isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === '2';
|
|
136
|
+
var variantId = Number(product.product_variant_id || 0);
|
|
137
|
+
var variantList = variantId ? metadata === null || metadata === void 0 || (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.variant : null;
|
|
138
|
+
var variantPrice = Array.isArray(variantList) ? (_variantList$find = variantList.find(function (v) {
|
|
139
|
+
return Number(v === null || v === void 0 ? void 0 : v.id) === variantId;
|
|
140
|
+
})) === null || _variantList$find === void 0 ? void 0 : _variantList$find.price : undefined;
|
|
141
|
+
var resolvedSource = function (_product$_origin, _product$_origin2, _ref7, _product$original_pri) {
|
|
142
|
+
if (metadata.source_product_price !== undefined) {
|
|
143
|
+
return String(metadata.source_product_price);
|
|
144
|
+
}
|
|
145
|
+
if (variantPrice !== undefined && variantPrice !== null) {
|
|
146
|
+
return String(variantPrice);
|
|
147
|
+
}
|
|
148
|
+
var originPrice = (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.price;
|
|
149
|
+
if (originPrice !== undefined && originPrice !== null) {
|
|
150
|
+
return String(originPrice);
|
|
151
|
+
}
|
|
152
|
+
var originBasePrice = (_product$_origin2 = product._origin) === null || _product$_origin2 === void 0 ? void 0 : _product$_origin2.base_price;
|
|
153
|
+
if (originBasePrice !== undefined && originBasePrice !== null) {
|
|
154
|
+
return String(originBasePrice);
|
|
155
|
+
}
|
|
156
|
+
if (!isV2 && metadata.main_product_original_price !== undefined) {
|
|
157
|
+
return String(metadata.main_product_original_price);
|
|
158
|
+
}
|
|
159
|
+
return (_ref7 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref7 !== void 0 ? _ref7 : '0.00';
|
|
160
|
+
}();
|
|
161
|
+
|
|
162
|
+
// 2) 派生 main_product_original_price(含 option、不含折扣)
|
|
163
|
+
var mainOriginalDec = new Decimal(Number(resolvedSource) || 0).plus(optionSum);
|
|
164
|
+
var mainOriginalStr = mainOriginalDec.toDecimalPlaces(2).toFixed(2);
|
|
165
|
+
|
|
166
|
+
// 3) 派生 main_product_selling_price(含 option、含主商品折扣)
|
|
167
|
+
// - v2 数据:直接沿用 metadata.main_product_selling_price(保留折扣)
|
|
168
|
+
// - v1 metadata:main_product_selling_price 旧语义是 main-only(≈ source-level 折后价),
|
|
169
|
+
// 反推 legacyDiscount = main_original(旧) - main_selling(旧),再用新 main_original - legacyDiscount
|
|
170
|
+
// - v1 addProduct 入参:top-level selling_price < original_price 表示主商品折扣;
|
|
171
|
+
// 用差额作为 legacyDiscount 映射到新 main_selling
|
|
172
|
+
// - 其它:视为无折扣,main_selling = main_original
|
|
173
|
+
var mainSellingDec;
|
|
174
|
+
if (isV2 && metadata.main_product_selling_price != null) {
|
|
175
|
+
mainSellingDec = new Decimal(Number(metadata.main_product_selling_price) || 0);
|
|
176
|
+
} else if (metadata.main_product_selling_price != null && metadata.main_product_original_price != null) {
|
|
177
|
+
var legacyOriginal = new Decimal(Number(metadata.main_product_original_price) || 0);
|
|
178
|
+
var legacySelling = new Decimal(Number(metadata.main_product_selling_price) || 0);
|
|
179
|
+
var legacyDiscount = legacyOriginal.minus(legacySelling);
|
|
180
|
+
mainSellingDec = mainOriginalDec.minus(legacyDiscount);
|
|
181
|
+
} else if (product.original_price != null && product.selling_price != null && new Decimal(Number(product.original_price) || 0).greaterThan(new Decimal(Number(product.selling_price) || 0))) {
|
|
182
|
+
var topOriginal = new Decimal(Number(product.original_price) || 0);
|
|
183
|
+
var topSelling = new Decimal(Number(product.selling_price) || 0);
|
|
184
|
+
var _legacyDiscount = topOriginal.minus(topSelling);
|
|
185
|
+
mainSellingDec = mainOriginalDec.minus(_legacyDiscount);
|
|
186
|
+
} else {
|
|
187
|
+
mainSellingDec = mainOriginalDec;
|
|
188
|
+
}
|
|
189
|
+
var mainSellingStr = mainSellingDec.toDecimalPlaces(2).toFixed(2);
|
|
190
|
+
|
|
191
|
+
// 4) 落盘 metadata:三字段 + schema 版本 sentinel
|
|
192
|
+
metadata.source_product_price = resolvedSource;
|
|
193
|
+
metadata.main_product_original_price = mainOriginalStr;
|
|
194
|
+
metadata.main_product_selling_price = mainSellingStr;
|
|
195
|
+
metadata.price_schema_version = 2;
|
|
196
|
+
|
|
197
|
+
// 5) 合成行级 composite(main 已含 option,本步只叠 bundle)
|
|
198
|
+
var composedSellingPrice = composeLinePrice({
|
|
199
|
+
mainPrice: mainSellingStr,
|
|
200
|
+
bundle: normalizedBundle
|
|
201
|
+
});
|
|
202
|
+
var composedOriginalPrice = composeLinePrice({
|
|
203
|
+
mainPrice: mainOriginalStr,
|
|
204
|
+
bundle: normalizedBundle,
|
|
205
|
+
useOriginalBundle: true
|
|
206
|
+
});
|
|
207
|
+
return {
|
|
208
|
+
order_detail_id: product.order_detail_id || null,
|
|
209
|
+
product_id: product.product_id,
|
|
210
|
+
num: getSafeProductNum(product.num),
|
|
211
|
+
product_variant_id: product.product_variant_id,
|
|
212
|
+
product_option_item: normalizedOptions,
|
|
213
|
+
selling_price: composedSellingPrice,
|
|
214
|
+
original_price: composedOriginalPrice,
|
|
215
|
+
tax_fee: product.tax_fee || '0.00',
|
|
216
|
+
is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
217
|
+
discount_list: product.discount_list || [],
|
|
218
|
+
product_bundle: normalizedBundle,
|
|
219
|
+
metadata: metadata,
|
|
220
|
+
note: product.note != null ? String(product.note) : ''
|
|
221
|
+
};
|
|
222
|
+
}
|
|
@@ -148,6 +148,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
148
148
|
taxTitle?: string | undefined;
|
|
149
149
|
totalTaxFee?: string | number | undefined;
|
|
150
150
|
isPriceIncludeTax?: 0 | 1 | undefined;
|
|
151
|
+
surchargeAmount?: string | number | undefined;
|
|
152
|
+
surcharge?: any[] | undefined;
|
|
153
|
+
taxRate?: string | number | undefined;
|
|
151
154
|
deposit?: {
|
|
152
155
|
total?: string | number | undefined;
|
|
153
156
|
policies?: import("../../modules/Summary/types").IProtocol[] | undefined;
|
|
@@ -300,6 +303,16 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
300
303
|
errorList: any[];
|
|
301
304
|
};
|
|
302
305
|
getTimeSlotByAllResources(resources_code: string): any[];
|
|
306
|
+
getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }: {
|
|
307
|
+
resources_code: string;
|
|
308
|
+
startDate: string;
|
|
309
|
+
endDate: string;
|
|
310
|
+
}): Promise<{
|
|
311
|
+
date: string;
|
|
312
|
+
status: string;
|
|
313
|
+
week: string;
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
|
+
}[]>;
|
|
303
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
304
317
|
private getScheduleDataByIds;
|
|
305
318
|
openProductDetail(productId: number): Promise<void>;
|
|
@@ -317,6 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
317
330
|
count: number;
|
|
318
331
|
left: number;
|
|
319
332
|
summaryCount: number;
|
|
333
|
+
status: "lots_of_space" | "filling_up_fast" | "sold_out";
|
|
320
334
|
}[];
|
|
321
335
|
/**
|
|
322
336
|
* 找到多个资源的公共可用时间段
|