@pisell/pisellos 0.10.7 → 0.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +0 -1
- 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/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +18 -12
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- 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 +32 -6
- package/dist/modules/Order/index.js +1165 -819
- package/dist/modules/Order/types.d.ts +32 -4
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/dist/modules/Order/utils/virtualSettlement.js +271 -0
- package/dist/modules/Order/utils.js +89 -48
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +4 -1
- package/dist/modules/Payment/walletpass.d.ts +11 -0
- package/dist/modules/Payment/walletpass.js +235 -60
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +15 -2
- package/dist/modules/ProductList/index.js +92 -13
- package/dist/modules/Rules/index.js +125 -52
- 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 +28 -2
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +894 -781
- package/dist/server/modules/order/index.d.ts +2 -0
- package/dist/server/modules/order/index.js +261 -96
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +41 -7
- package/dist/solution/BaseSales/index.js +1405 -974
- package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +79 -13
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +3 -3
- package/dist/solution/BookingTicket/index.d.ts +5 -1
- package/dist/solution/BookingTicket/index.js +221 -162
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/index.js +25 -64
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +51 -39
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -1
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +37 -3
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +32 -6
- package/lib/modules/Order/index.js +518 -148
- package/lib/modules/Order/types.d.ts +32 -4
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/lib/modules/Order/utils/virtualSettlement.js +300 -0
- package/lib/modules/Order/utils.js +65 -21
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +5 -1
- package/lib/modules/Payment/walletpass.d.ts +11 -0
- package/lib/modules/Payment/walletpass.js +198 -17
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +15 -2
- package/lib/modules/ProductList/index.js +85 -3
- package/lib/modules/Rules/index.js +100 -20
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +10 -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 +30 -2
- package/lib/server/index.d.ts +15 -0
- package/lib/server/index.js +105 -14
- package/lib/server/modules/order/index.d.ts +2 -0
- package/lib/server/modules/order/index.js +75 -5
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +41 -7
- package/lib/solution/BaseSales/index.js +325 -39
- package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +62 -12
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +3 -3
- package/lib/solution/BookingTicket/index.d.ts +5 -1
- package/lib/solution/BookingTicket/index.js +31 -6
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/index.js +17 -54
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +35 -26
- package/package.json +1 -1
|
@@ -35,6 +35,10 @@ export interface DataVariantItem {
|
|
|
35
35
|
module_data_id?: number;
|
|
36
36
|
/** 关联策略模型 metadata.id / data_variant_rule.id */
|
|
37
37
|
data_variant_rule_id: number | string;
|
|
38
|
+
/** 业务类型;多货币结算候选不会走普通字段覆盖 */
|
|
39
|
+
business_type?: 'multi_currency_settlement' | string;
|
|
40
|
+
/** 数据状态;多货币结算仅处理 enable 记录 */
|
|
41
|
+
status?: 'enable' | 'disable' | string;
|
|
38
42
|
/** 命中策略后需要覆盖到商品上的字段 */
|
|
39
43
|
data: Record<string, any>;
|
|
40
44
|
created_at?: string | null;
|
|
@@ -53,11 +57,30 @@ export interface DataVariantProduct {
|
|
|
53
57
|
id?: number | string;
|
|
54
58
|
[key: string]: any;
|
|
55
59
|
}>;
|
|
60
|
+
/**
|
|
61
|
+
* 商品接口已经完成规则计算时返回的命中结果。
|
|
62
|
+
* 数组按 Data Variant 优先级从高到低排列;空数组表示已计算但无命中。
|
|
63
|
+
*/
|
|
64
|
+
metadata?: {
|
|
65
|
+
data_variant_ids?: Array<number | string>;
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
};
|
|
56
68
|
/** 后端 /product/query with dataVariants 返回的智能定价变体列表 */
|
|
57
69
|
data_variants?: DataVariantItem[];
|
|
70
|
+
/** 当前上下文解析后的可选结算货币,不覆盖商品原始多货币配置 */
|
|
71
|
+
available_settlement_options?: AvailableSettlementOption[];
|
|
58
72
|
_dataVariant?: DataVariantAppliedInfo;
|
|
59
73
|
[key: string]: any;
|
|
60
74
|
}
|
|
75
|
+
export interface AvailableSettlementOption extends Record<string, any> {
|
|
76
|
+
settlement_type: 'legal_currency' | 'virtual_currency' | string;
|
|
77
|
+
currency_product_id?: number;
|
|
78
|
+
price: string;
|
|
79
|
+
data_variant_id?: number;
|
|
80
|
+
data_variant_rule_id: number | string;
|
|
81
|
+
available: boolean;
|
|
82
|
+
disabled_reason?: string;
|
|
83
|
+
}
|
|
61
84
|
/**
|
|
62
85
|
* 餐牌商品配置项。
|
|
63
86
|
*/
|
|
@@ -131,6 +154,8 @@ export interface MatchedDataVariant {
|
|
|
131
154
|
*/
|
|
132
155
|
export interface DataVariantAppliedInfo {
|
|
133
156
|
appliedRuleIds: string[];
|
|
157
|
+
/** 本地策略实际应用的 Data Variant ID,按优先级从高到低排列。 */
|
|
158
|
+
appliedVariantIds?: Array<number | string>;
|
|
134
159
|
appliedFields: string[];
|
|
135
160
|
original: DataVariantProduct;
|
|
136
161
|
}
|
|
@@ -257,7 +257,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
257
257
|
var rawText = this.getText(reasonCode);
|
|
258
258
|
// 金额类型字段:从 otherParams.getData 取货币符号;非金额或取不到则留空
|
|
259
259
|
var currency = failedField && AMOUNT_FIELDS.has(failedField) ? ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 || (_this$otherParams$get = (_this$otherParams2 = _this$otherParams).getData) === null || _this$otherParams$get === void 0 ? void 0 : _this$otherParams$get.call(_this$otherParams2, 'shop_symbol')) || '' : '';
|
|
260
|
-
console.log(currency, 'currency12345');
|
|
261
260
|
var reason = thresholdValue !== undefined ? formatReason(rawText, thresholdValue, currency) : rawText;
|
|
262
261
|
results.push({
|
|
263
262
|
voucher: voucher,
|
|
@@ -506,7 +505,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
506
505
|
}, {
|
|
507
506
|
key: "calculateApplicableProducts",
|
|
508
507
|
value: function calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
|
|
509
|
-
console.log(products, 'products1234');
|
|
510
508
|
var total = 0;
|
|
511
509
|
var count = 0;
|
|
512
510
|
|
|
@@ -26,6 +26,11 @@ export interface Voucher {
|
|
|
26
26
|
recommended_usage_amount: number;
|
|
27
27
|
/** 后端计算推荐使用金额(仅商品) 不包含税费附加费 */
|
|
28
28
|
recommended_pure_product_usage_amount: number;
|
|
29
|
+
/**
|
|
30
|
+
* 扫码资产自身可供前端重新计算的金额基准。
|
|
31
|
+
* 后端 recommended_usage_amount 会包含当前已选券上下文,取消勾选后不能继续把它当作资产永久上限。
|
|
32
|
+
*/
|
|
33
|
+
_wallet_asset_recalculation_base_amount?: number;
|
|
29
34
|
/** 实际抵扣金额 */
|
|
30
35
|
actualDeduction: number;
|
|
31
36
|
/** 抵扣详情 */
|
|
@@ -1,9 +1,4 @@
|
|
|
1
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
2
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -11,7 +6,25 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
11
6
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
7
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
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); }
|
|
14
14
|
import Decimal from 'decimal.js';
|
|
15
|
+
var DEFAULT_WALLET_PASS_CALCULATION_CONFIG = {
|
|
16
|
+
maxDeductionAmount: 99999,
|
|
17
|
+
maxUsagePerOrder: 0,
|
|
18
|
+
allowCrossProduct: true,
|
|
19
|
+
applicableProductLimit: 0,
|
|
20
|
+
deductTaxAndFee: true,
|
|
21
|
+
maxPassesPerItem: 0,
|
|
22
|
+
deductOptionPrice: false
|
|
23
|
+
};
|
|
24
|
+
function getWalletPassCalculationConfig(voucher) {
|
|
25
|
+
return _objectSpread(_objectSpread({}, DEFAULT_WALLET_PASS_CALCULATION_CONFIG), (voucher === null || voucher === void 0 ? void 0 : voucher.config) || {});
|
|
26
|
+
}
|
|
27
|
+
|
|
15
28
|
/** 订单商品数量 */
|
|
16
29
|
export var getProductQuantity = function getProductQuantity(product) {
|
|
17
30
|
return product.quantity || product.product_quantity || 1;
|
|
@@ -72,12 +85,22 @@ function applyMaxPassUsageIncrements(usageMap, walletPassProductId, maxPassesPer
|
|
|
72
85
|
// 辅助函数:根据 deductTaxAndFee 配置获取推荐使用金额
|
|
73
86
|
var getRecommendedAmount = function getRecommendedAmount(voucher) {
|
|
74
87
|
var _config$deductTaxAndF;
|
|
75
|
-
console.log('voucher312', voucher);
|
|
76
88
|
var config = voucher.config,
|
|
77
89
|
recommended_usage_amount = voucher.recommended_usage_amount,
|
|
78
90
|
recommended_pure_product_usage_amount = voucher.recommended_pure_product_usage_amount;
|
|
79
91
|
var deductTaxAndFee = (_config$deductTaxAndF = config === null || config === void 0 ? void 0 : config.deductTaxAndFee) !== null && _config$deductTaxAndF !== void 0 ? _config$deductTaxAndF : true; // 默认开启抵扣税费
|
|
80
92
|
|
|
93
|
+
// 扫码接口的 recommended_* 金额包含搜索时已选券的上下文,可能只是当时的
|
|
94
|
+
// 剩余可抵扣额。取消其他券后,前端重算需要回到资产自身金额基准,再由
|
|
95
|
+
// 剩余订单金额、适用商品金额和策略上限重新裁剪。
|
|
96
|
+
var rawRecalculationBaseAmount = voucher._wallet_asset_recalculation_base_amount;
|
|
97
|
+
if (rawRecalculationBaseAmount !== undefined && rawRecalculationBaseAmount !== null) {
|
|
98
|
+
var recalculationBaseAmount = Number(rawRecalculationBaseAmount);
|
|
99
|
+
if (Number.isFinite(recalculationBaseAmount) && recalculationBaseAmount >= 0) {
|
|
100
|
+
return recalculationBaseAmount;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
81
104
|
// 如果开启抵扣税费,使用 recommended_usage_amount(包含税费)
|
|
82
105
|
// 如果关闭抵扣税费,使用 recommended_pure_product_usage_amount(仅商品金额)
|
|
83
106
|
return deductTaxAndFee ? recommended_usage_amount : recommended_pure_product_usage_amount !== null && recommended_pure_product_usage_amount !== void 0 ? recommended_pure_product_usage_amount : recommended_usage_amount;
|
|
@@ -166,8 +189,6 @@ var getApplicableProducts = function getApplicableProducts(voucher, productsData
|
|
|
166
189
|
* @returns 返回推荐券列表和全部列表,每个券包含 _available_max_amount 和 _unified_available_status
|
|
167
190
|
*/
|
|
168
191
|
export function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
169
|
-
console.log(products, 'products123');
|
|
170
|
-
|
|
171
192
|
// 拆分商品数据,同时维护含税和不含税两个金额池
|
|
172
193
|
// remainingAmountWithTax: 含税费的剩余可抵扣金额
|
|
173
194
|
// remainingAmountPure: 纯商品金额(不含税费)的剩余可抵扣金额
|
|
@@ -285,7 +306,6 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
285
306
|
// 辅助函数:判断券是否可用,返回可用性和原因代码
|
|
286
307
|
var isVoucherAvailable = function isVoucherAvailable(voucher, productsData, usedVoucherCounts, itemPassUsage) {
|
|
287
308
|
var config = voucher.config,
|
|
288
|
-
id = voucher.id,
|
|
289
309
|
product_id = voucher.product_id;
|
|
290
310
|
|
|
291
311
|
// 根据 deductTaxAndFee 配置获取推荐金额
|
|
@@ -659,6 +679,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
659
679
|
var productsForCalc = expandProductsWithBundleItems(products, true);
|
|
660
680
|
var remainingOrderAmount = new Decimal(orderTotalAmount);
|
|
661
681
|
var selectedWithDetails = [];
|
|
682
|
+
var usedVoucherCounts = new Map();
|
|
662
683
|
|
|
663
684
|
// 追踪每个 Wallet Pass 商品对每个订单商品行的已使用卡券次数(按行唯一键)
|
|
664
685
|
var itemPassUsageMap = new Map();
|
|
@@ -678,15 +699,26 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
678
699
|
// 第一步:按顺序应用已选中的券,计算实际抵扣
|
|
679
700
|
selectedVouchers.forEach(function (selectedVoucher) {
|
|
680
701
|
var _selectedVoucher$_ava;
|
|
681
|
-
var
|
|
682
|
-
|
|
702
|
+
var product_id = selectedVoucher.product_id;
|
|
703
|
+
var config = getWalletPassCalculationConfig(selectedVoucher);
|
|
683
704
|
var maxDeductionAmount = config.maxDeductionAmount,
|
|
705
|
+
maxUsagePerOrder = config.maxUsagePerOrder,
|
|
684
706
|
allowCrossProduct = config.allowCrossProduct,
|
|
685
707
|
applicableProductLimit = config.applicableProductLimit,
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
708
|
+
deductTaxAndFee = config.deductTaxAndFee,
|
|
709
|
+
maxPassesPerItem = config.maxPassesPerItem;
|
|
710
|
+
var usedCount = usedVoucherCounts.get(product_id) || 0;
|
|
711
|
+
if (maxUsagePerOrder > 0 && usedCount >= maxUsagePerOrder) {
|
|
712
|
+
selectedWithDetails.push(_objectSpread(_objectSpread({}, selectedVoucher), {}, {
|
|
713
|
+
config: config,
|
|
714
|
+
actualDeduction: 0,
|
|
715
|
+
deductionDetails: [],
|
|
716
|
+
_available_max_amount: 0,
|
|
717
|
+
_unified_available_status: 0,
|
|
718
|
+
reasonCode: 'usage_limit_reached'
|
|
719
|
+
}));
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
690
722
|
|
|
691
723
|
// 根据券的配置选择使用哪个单价字段和金额字段
|
|
692
724
|
var unitPriceField = deductTaxAndFee ? 'unitPriceWithTax' : 'unitPricePure';
|
|
@@ -702,6 +734,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
702
734
|
if (applicableProducts.length === 0) {
|
|
703
735
|
// 无适用商品,跳过
|
|
704
736
|
selectedWithDetails.push(_objectSpread(_objectSpread({}, selectedVoucher), {}, {
|
|
737
|
+
config: config,
|
|
705
738
|
actualDeduction: 0,
|
|
706
739
|
deductionDetails: [],
|
|
707
740
|
_available_max_amount: 0,
|
|
@@ -798,6 +831,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
798
831
|
remainingOrderAmount = remainingOrderAmount.minus(totalDeducted);
|
|
799
832
|
applyMaxPassUsageIncrements(itemPassUsageMap, selectedVoucher.product_id, maxPassesPerItem, deductionDetails);
|
|
800
833
|
selectedWithDetails.push(_objectSpread(_objectSpread({}, selectedVoucher), {}, {
|
|
834
|
+
config: config,
|
|
801
835
|
actualDeduction: totalDeducted.toNumber(),
|
|
802
836
|
// 转换为数字
|
|
803
837
|
deductionDetails: deductionDetails,
|
|
@@ -805,16 +839,15 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
805
839
|
// 转换为数字
|
|
806
840
|
_unified_available_status: totalDeducted.greaterThan(0) ? 1 : 0
|
|
807
841
|
}));
|
|
842
|
+
if (totalDeducted.greaterThan(0)) {
|
|
843
|
+
usedVoucherCounts.set(product_id, usedCount + 1);
|
|
844
|
+
}
|
|
808
845
|
});
|
|
809
846
|
|
|
810
847
|
// 第二步:为所有券重新计算 _available_max_amount 和 _unified_available_status
|
|
811
848
|
var selectedIds = new Set(selectedVouchers.map(function (v) {
|
|
812
849
|
return v.id;
|
|
813
850
|
}));
|
|
814
|
-
var usedVoucherCounts = new Map();
|
|
815
|
-
selectedVouchers.forEach(function (v) {
|
|
816
|
-
usedVoucherCounts.set(v.product_id, (usedVoucherCounts.get(v.product_id) || 0) + 1);
|
|
817
|
-
});
|
|
818
851
|
var allWithUpdatedStatus = allVouchers.map(function (voucher) {
|
|
819
852
|
// 如果是已选中的券,使用详细计算结果
|
|
820
853
|
if (selectedIds.has(voucher.id)) {
|
|
@@ -825,16 +858,13 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
825
858
|
}
|
|
826
859
|
|
|
827
860
|
// 未选中的券,重新计算其可用状态
|
|
828
|
-
var
|
|
829
|
-
|
|
830
|
-
product_id = voucher.product_id;
|
|
861
|
+
var product_id = voucher.product_id;
|
|
862
|
+
var config = getWalletPassCalculationConfig(voucher);
|
|
831
863
|
var maxDeductionAmount = config.maxDeductionAmount,
|
|
832
864
|
allowCrossProduct = config.allowCrossProduct,
|
|
833
865
|
applicableProductLimit = config.applicableProductLimit,
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
_config$maxPassesPerI2 = config.maxPassesPerItem,
|
|
837
|
-
maxPassesPerItem = _config$maxPassesPerI2 === void 0 ? 0 : _config$maxPassesPerI2;
|
|
866
|
+
deductTaxAndFee = config.deductTaxAndFee,
|
|
867
|
+
maxPassesPerItem = config.maxPassesPerItem;
|
|
838
868
|
|
|
839
869
|
// 根据券的配置选择使用哪个单价字段和金额字段
|
|
840
870
|
var unitPriceField = deductTaxAndFee ? 'unitPriceWithTax' : 'unitPricePure';
|
|
@@ -929,6 +959,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
929
959
|
}
|
|
930
960
|
}
|
|
931
961
|
return _objectSpread(_objectSpread({}, voucher), {}, {
|
|
962
|
+
config: config,
|
|
932
963
|
_available_max_amount: calculatedMaxAmount.toNumber(),
|
|
933
964
|
// 转换为数字
|
|
934
965
|
_unified_available_status: isAvailable ? 1 : 0
|
|
@@ -134,9 +134,11 @@ function resolveMainProductPrice(product, fallback) {
|
|
|
134
134
|
}
|
|
135
135
|
function mapOrderBundleToOtherBundle(bundle) {
|
|
136
136
|
return bundle.map(function (item) {
|
|
137
|
-
var _ref7, _item$original_price;
|
|
137
|
+
var _ref7, _ref8, _item$original_price;
|
|
138
138
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
139
|
-
|
|
139
|
+
// 后端历史订单可能没有 original_price;此时 price 是折前毛价,
|
|
140
|
+
// bundle_selling_price 已包含折扣,不能把它当成编辑时的新原价。
|
|
141
|
+
original_price: (_ref7 = (_ref8 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.product_price) !== null && _ref8 !== void 0 ? _ref8 : item.price) !== null && _ref7 !== void 0 ? _ref7 : item.bundle_selling_price
|
|
140
142
|
});
|
|
141
143
|
});
|
|
142
144
|
}
|
|
@@ -167,10 +169,10 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
167
169
|
});
|
|
168
170
|
if (relationIdsByForm.size === 0) return undefined;
|
|
169
171
|
return {
|
|
170
|
-
resources: Array.from(relationIdsByForm.entries()).map(function (
|
|
171
|
-
var
|
|
172
|
-
formId =
|
|
173
|
-
relationIds =
|
|
172
|
+
resources: Array.from(relationIdsByForm.entries()).map(function (_ref9) {
|
|
173
|
+
var _ref10 = _slicedToArray(_ref9, 2),
|
|
174
|
+
formId = _ref10[0],
|
|
175
|
+
relationIds = _ref10[1];
|
|
174
176
|
return {
|
|
175
177
|
id: formId,
|
|
176
178
|
status: 1,
|
|
@@ -190,7 +192,7 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
190
192
|
* 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
|
|
191
193
|
*/
|
|
192
194
|
export function buildCacheItemFromOrderLine(input) {
|
|
193
|
-
var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num,
|
|
195
|
+
var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$bundle_edit, _product$product_vari, _product$num, _ref11, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref12, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref13, _booking$id;
|
|
194
196
|
var product = input.product,
|
|
195
197
|
booking = input.booking,
|
|
196
198
|
sourceProduct = input.sourceProduct;
|
|
@@ -208,12 +210,14 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
208
210
|
var productTitle = resolveProductTitle(product, booking, sourceProduct);
|
|
209
211
|
var productCover = resolveProductCover(product, booking, sourceProduct);
|
|
210
212
|
var productOptionString = buildProductOptionStringFromOrderLine(product);
|
|
213
|
+
var hasBundle = Array.isArray(product.product_bundle) && product.product_bundle.length > 0;
|
|
214
|
+
var bundleEdit = (_product$bundle_edit = product.bundle_edit) !== null && _product$bundle_edit !== void 0 ? _product$bundle_edit : hasBundle ? 0 : undefined;
|
|
211
215
|
var other = {
|
|
212
216
|
product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
|
|
213
217
|
option: getProductSkuOptions(product),
|
|
214
218
|
bundle: mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : [])
|
|
215
219
|
};
|
|
216
|
-
var extend = _objectSpread({
|
|
220
|
+
var extend = _objectSpread(_objectSpread({
|
|
217
221
|
start_date: startDate ? dayjs(startDate) : undefined,
|
|
218
222
|
end_date: endDate ? dayjs(endDate) : undefined,
|
|
219
223
|
startDate: startDate ? dayjs(startDate) : undefined,
|
|
@@ -225,7 +229,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
225
229
|
quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
|
|
226
230
|
product_name: productTitle,
|
|
227
231
|
product_cover: productCover,
|
|
228
|
-
note: (
|
|
232
|
+
note: (_ref11 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref11 !== void 0 ? _ref11 : '',
|
|
229
233
|
price: mainProductPrice,
|
|
230
234
|
total: selling,
|
|
231
235
|
origin_total: original,
|
|
@@ -235,7 +239,9 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
235
239
|
other: other,
|
|
236
240
|
like_status: booking.like_status || 'common',
|
|
237
241
|
discount_reason: resolveManualDiscountMessage(product.discount_list, (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.product_discount_reason) || undefined
|
|
238
|
-
},
|
|
242
|
+
}, bundleEdit !== undefined ? {
|
|
243
|
+
bundle_edit: bundleEdit
|
|
244
|
+
} : {}), productOptionString ? {
|
|
239
245
|
product_option_string: productOptionString
|
|
240
246
|
} : {});
|
|
241
247
|
var manualDiscount = (product.discount_list || []).find(function (d) {
|
|
@@ -260,7 +266,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
260
266
|
var base = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
261
267
|
id: resolvedId,
|
|
262
268
|
product_id: resolvedId,
|
|
263
|
-
extension_type: (
|
|
269
|
+
extension_type: (_ref12 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref12 !== void 0 ? _ref12 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
|
|
264
270
|
title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
|
|
265
271
|
price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
|
|
266
272
|
selling_price: product.selling_price,
|
|
@@ -274,7 +280,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
274
280
|
new: 0,
|
|
275
281
|
autoClose: false,
|
|
276
282
|
order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
|
|
277
|
-
booking_id: (
|
|
283
|
+
booking_id: (_ref13 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref13 !== void 0 ? _ref13 : 0
|
|
278
284
|
});
|
|
279
285
|
if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
|
|
280
286
|
base.capacity = sourceProduct.capacity;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
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
2
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
6
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
8
|
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; }
|
|
@@ -8,12 +10,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
8
10
|
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; }
|
|
9
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
12
|
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); }
|
|
11
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
13
|
import dayjs from 'dayjs';
|
|
18
14
|
import { formatResources, getResourceByIds, getSumCapacity, getUsableTime, setDefaultCapacitys, setDefaultResource } from "./resources";
|
|
19
15
|
import { hasActualResourceSelection, productNeedsResourceExtend } from "./resourceSelection";
|
|
@@ -81,9 +77,9 @@ export function getTimeObj(params) {
|
|
|
81
77
|
useStartTime: useStartTime,
|
|
82
78
|
ctx: ctx
|
|
83
79
|
});
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
var _sliceDayIntoFiveMinu = sliceDayIntoFiveMinutes(ctx === null || ctx === void 0 || (_ctx$bookingConfig2 = ctx.bookingConfig) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.config) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.basic) === null || _ctx$bookingConfig2 === void 0 ? void 0 : _ctx$bookingConfig2.service_time, isMultiDay),
|
|
81
|
+
timeSlices = _sliceDayIntoFiveMinu.timeSlices,
|
|
82
|
+
durationSlicesBasedOnTime = _sliceDayIntoFiveMinu.durationSlicesBasedOnTime;
|
|
87
83
|
if (flexibleOption) {
|
|
88
84
|
durationSlicesBasedOnTime.unshift(flexibleOption);
|
|
89
85
|
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
1
7
|
import dayjs from 'dayjs';
|
|
2
8
|
import { getDurationValue } from "./flexible";
|
|
9
|
+
var timeSlicesCache = new Map();
|
|
10
|
+
function copyTimeSlices(result) {
|
|
11
|
+
return {
|
|
12
|
+
timeSlices: _toConsumableArray(result.timeSlices),
|
|
13
|
+
durationSlicesBasedOnTime: _toConsumableArray(result.durationSlicesBasedOnTime)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
/**
|
|
4
18
|
* 把一天切成等长时间槽,输出 timeSlices(开始时间标签)与 durationSlicesBasedOnTime(基于切片的时长选项)。
|
|
5
19
|
*
|
|
@@ -10,9 +24,12 @@ import { getDurationValue } from "./flexible";
|
|
|
10
24
|
* @param isDay 是否跨日预约(true 时按 1~30 天切片)
|
|
11
25
|
*/
|
|
12
26
|
export function sliceDayIntoFiveMinutes(config, isDay) {
|
|
27
|
+
var timeSlice = config && config.value || 5;
|
|
28
|
+
var cacheKey = isDay ? 'days' : "minutes:".concat(timeSlice);
|
|
29
|
+
var cached = timeSlicesCache.get(cacheKey);
|
|
30
|
+
if (cached) return copyTimeSlices(cached);
|
|
13
31
|
var startTime = dayjs().startOf('day');
|
|
14
32
|
var endTime = dayjs().endOf('day');
|
|
15
|
-
var timeSlice = config && config.value || 5;
|
|
16
33
|
var timeSlices = [];
|
|
17
34
|
var durationSlicesBasedOnTime = [];
|
|
18
35
|
var currentTime = startTime;
|
|
@@ -29,10 +46,12 @@ export function sliceDayIntoFiveMinutes(config, isDay) {
|
|
|
29
46
|
});
|
|
30
47
|
currentDay += 1;
|
|
31
48
|
}
|
|
32
|
-
|
|
49
|
+
var _result = {
|
|
33
50
|
timeSlices: timeSlices,
|
|
34
51
|
durationSlicesBasedOnTime: durationSlicesBasedOnTime
|
|
35
52
|
};
|
|
53
|
+
timeSlicesCache.set(cacheKey, _result);
|
|
54
|
+
return copyTimeSlices(_result);
|
|
36
55
|
}
|
|
37
56
|
while (currentTime.isBefore(endTime)) {
|
|
38
57
|
timeSlices.push({
|
|
@@ -47,10 +66,12 @@ export function sliceDayIntoFiveMinutes(config, isDay) {
|
|
|
47
66
|
});
|
|
48
67
|
currentTime = nextTime;
|
|
49
68
|
}
|
|
50
|
-
|
|
69
|
+
var result = {
|
|
51
70
|
timeSlices: timeSlices,
|
|
52
71
|
durationSlicesBasedOnTime: durationSlicesBasedOnTime
|
|
53
72
|
};
|
|
73
|
+
timeSlicesCache.set(cacheKey, result);
|
|
74
|
+
return copyTimeSlices(result);
|
|
54
75
|
}
|
|
55
76
|
|
|
56
77
|
/**
|
|
@@ -44,6 +44,10 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
44
44
|
* 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
|
|
45
45
|
*/
|
|
46
46
|
queryCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* 查询单个客户详情,不写入 customerList / pagination 状态。
|
|
49
|
+
*/
|
|
50
|
+
queryCustomerDetail(id: string | number): Promise<ShopCustomer | null>;
|
|
47
51
|
/**
|
|
48
52
|
* 获取客户列表
|
|
49
53
|
* @param params 查询参数
|