@pisell/pisellos 2.2.143 → 2.2.145
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/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +24 -5
- package/dist/model/strategy/adapter/walletPass/locales.js +6 -6
- package/dist/server/modules/order/utils/filterBookings.js +20 -3
- package/dist/server/modules/order/utils/filterOrders.js +6 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +16 -5
- package/lib/model/strategy/adapter/walletPass/locales.js +6 -6
- package/lib/server/modules/order/utils/filterBookings.js +30 -3
- package/lib/server/modules/order/utils/filterOrders.js +14 -3
- package/package.json +1 -1
|
@@ -8,10 +8,12 @@ export declare class WalletPassEvaluator {
|
|
|
8
8
|
private engine;
|
|
9
9
|
private strategyConfigs;
|
|
10
10
|
private locale;
|
|
11
|
+
private otherParams;
|
|
11
12
|
constructor();
|
|
12
13
|
setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
|
|
13
14
|
getStrategyConfigs(): StrategyConfig[];
|
|
14
15
|
setLocale(locale: string): void;
|
|
16
|
+
setOtherParams(otherParams: any): void;
|
|
15
17
|
getText(key: string): string;
|
|
16
18
|
/**
|
|
17
19
|
* 搜索券的格式
|
|
@@ -35,12 +35,22 @@ var FIELD_REASON_CODE_MAP = {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* 金额类型 field 集合(需要在文案前拼货币符号)
|
|
39
|
+
*/
|
|
40
|
+
var AMOUNT_FIELDS = new Set(['orderTotalAmount', 'applicableProductTotalAmount']);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 用阈值与货币符号替换文案中的占位符
|
|
44
|
+
* 支持占位符:{value} / ${value} / {currency}
|
|
39
45
|
*/
|
|
40
46
|
function formatReason(template, value) {
|
|
47
|
+
var currency = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
41
48
|
if (!template) return template;
|
|
42
|
-
var
|
|
43
|
-
|
|
49
|
+
var v = value === undefined || value === null ? '' : String(value);
|
|
50
|
+
var c = currency === undefined || currency === null ? '' : String(currency);
|
|
51
|
+
// 注意:必须先替换 value,再替换 currency
|
|
52
|
+
// 否则 currency 注入的 "$" 会被后续的 /\$\{value\}/ 正则误吞
|
|
53
|
+
return template.replace(/\$\{value\}/g, v).replace(/\{value\}/g, v).replace(/\{currency\}/g, c);
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
/**
|
|
@@ -53,6 +63,7 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
53
63
|
_defineProperty(this, "engine", void 0);
|
|
54
64
|
_defineProperty(this, "strategyConfigs", []);
|
|
55
65
|
_defineProperty(this, "locale", 'en');
|
|
66
|
+
_defineProperty(this, "otherParams", {});
|
|
56
67
|
this.engine = new StrategyEngine({
|
|
57
68
|
debug: false,
|
|
58
69
|
enableTrace: false
|
|
@@ -76,6 +87,11 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
76
87
|
value: function setLocale(locale) {
|
|
77
88
|
this.locale = locale;
|
|
78
89
|
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "setOtherParams",
|
|
92
|
+
value: function setOtherParams(otherParams) {
|
|
93
|
+
this.otherParams = otherParams;
|
|
94
|
+
}
|
|
79
95
|
}, {
|
|
80
96
|
key: "getText",
|
|
81
97
|
value: function getText(key) {
|
|
@@ -210,7 +226,7 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
210
226
|
strategyResult: evaluationResult
|
|
211
227
|
});
|
|
212
228
|
} else {
|
|
213
|
-
var _evaluationResult$mat, _evaluationResult$mat2;
|
|
229
|
+
var _evaluationResult$mat, _evaluationResult$mat2, _this$otherParams, _this$otherParams$get, _this$otherParams2;
|
|
214
230
|
// 优先根据失败的 field 映射到具体的 reasonCode(更精确的失败原因)
|
|
215
231
|
var reasonCode = 'not_meet_the_required_conditions';
|
|
216
232
|
var thresholdValue = undefined;
|
|
@@ -231,7 +247,9 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
231
247
|
reasonCode = codeMapping[evaluationResult.code] || 'not_meet_the_required_conditions';
|
|
232
248
|
}
|
|
233
249
|
var rawText = this.getText(reasonCode);
|
|
234
|
-
|
|
250
|
+
// 金额类型字段:从 otherParams.getData 取货币符号;非金额或取不到则留空
|
|
251
|
+
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')) || '' : '';
|
|
252
|
+
var reason = thresholdValue !== undefined ? formatReason(rawText, thresholdValue, currency) : rawText;
|
|
235
253
|
results.push({
|
|
236
254
|
voucher: voucher,
|
|
237
255
|
isApplicable: false,
|
|
@@ -479,6 +497,7 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
479
497
|
}, {
|
|
480
498
|
key: "calculateApplicableProducts",
|
|
481
499
|
value: function calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
|
|
500
|
+
console.log(products, 'products1234');
|
|
482
501
|
var total = 0;
|
|
483
502
|
var count = 0;
|
|
484
503
|
|
|
@@ -6,8 +6,8 @@ export var locales = {
|
|
|
6
6
|
'max_passes_per_item_reached': '该商品已达到卡券使用上限',
|
|
7
7
|
'not_available_for_this_channel': '当前渠道不可使用',
|
|
8
8
|
'not_valid_for_this_order_type': '当前订单类型不适用',
|
|
9
|
-
'order_total_amount_not_enough': '订单满
|
|
10
|
-
'applicable_product_total_amount_not_enough': '适用商品满
|
|
9
|
+
'order_total_amount_not_enough': '订单满 {currency}{value} 才可用',
|
|
10
|
+
'applicable_product_total_amount_not_enough': '适用商品满 {currency}{value} 才可用',
|
|
11
11
|
'applicable_product_count_not_enough': '至少购买 {value} 件适用商品才可用'
|
|
12
12
|
},
|
|
13
13
|
'en': {
|
|
@@ -17,8 +17,8 @@ export var locales = {
|
|
|
17
17
|
'max_passes_per_item_reached': 'Max passes per item reached.',
|
|
18
18
|
'not_available_for_this_channel': 'Not available for this channel.',
|
|
19
19
|
'not_valid_for_this_order_type': 'Not valid for this order type.',
|
|
20
|
-
'order_total_amount_not_enough': 'Spend
|
|
21
|
-
'applicable_product_total_amount_not_enough': '
|
|
20
|
+
'order_total_amount_not_enough': 'Spend {currency}{value} to use',
|
|
21
|
+
'applicable_product_total_amount_not_enough': '{currency}{value} on eligible items',
|
|
22
22
|
'applicable_product_count_not_enough': 'Buy {value} eligible items to use'
|
|
23
23
|
},
|
|
24
24
|
'zh-HK': {
|
|
@@ -28,8 +28,8 @@ export var locales = {
|
|
|
28
28
|
'max_passes_per_item_reached': '該商品已達卡券使用上限',
|
|
29
29
|
'not_available_for_this_channel': '當前渠道不可使用',
|
|
30
30
|
'not_valid_for_this_order_type': '當前訂單類型不適用',
|
|
31
|
-
'order_total_amount_not_enough': '訂單滿
|
|
32
|
-
'applicable_product_total_amount_not_enough': '適用商品滿
|
|
31
|
+
'order_total_amount_not_enough': '訂單滿 {currency}{value} 才可用',
|
|
32
|
+
'applicable_product_total_amount_not_enough': '適用商品滿 {currency}{value} 才可用',
|
|
33
33
|
'applicable_product_count_not_enough': '至少購買 {value} 件適用商品才可用'
|
|
34
34
|
}
|
|
35
35
|
};
|
|
@@ -9,6 +9,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
9
9
|
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; }
|
|
10
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
11
|
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); }
|
|
12
|
+
import dayjs from 'dayjs';
|
|
12
13
|
/** 预约状态:协议 appointment_status 优先,兼容历史 status */
|
|
13
14
|
function getBookingAppointmentStatus(booking) {
|
|
14
15
|
var _ref, _booking$appointment_;
|
|
@@ -22,7 +23,23 @@ function getBookingAppointmentStatus(booking) {
|
|
|
22
23
|
function toTimestamp(value) {
|
|
23
24
|
if (value === undefined || value === null || value === '') return 0;
|
|
24
25
|
if (typeof value === 'number') return value;
|
|
25
|
-
|
|
26
|
+
// 使用 dayjs 按本地时区解析,避免 new Date("YYYY-MM-DD") 被当作 UTC 0 点
|
|
27
|
+
var d = dayjs(value);
|
|
28
|
+
return d.isValid() ? d.valueOf() : 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 日期范围端点解析:纯日期串自动对齐到当天起止边界(本地时区) */
|
|
32
|
+
var DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
33
|
+
function toRangeBoundary(value, isEnd) {
|
|
34
|
+
if (value === undefined || value === null || value === '') return 0;
|
|
35
|
+
if (typeof value === 'number') return value;
|
|
36
|
+
var str = String(value).trim();
|
|
37
|
+
var d = dayjs(str);
|
|
38
|
+
if (!d.isValid()) return 0;
|
|
39
|
+
if (DATE_ONLY_RE.test(str)) {
|
|
40
|
+
return (isEnd ? d.endOf('day') : d.startOf('day')).valueOf();
|
|
41
|
+
}
|
|
42
|
+
return d.valueOf();
|
|
26
43
|
}
|
|
27
44
|
|
|
28
45
|
/**
|
|
@@ -39,8 +56,8 @@ function bookingDateTimeString(datePart, timePart) {
|
|
|
39
56
|
}
|
|
40
57
|
function parseDateRange(range) {
|
|
41
58
|
if (!Array.isArray(range) || range.length < 2) return null;
|
|
42
|
-
var start =
|
|
43
|
-
var end =
|
|
59
|
+
var start = toRangeBoundary(range[0], false);
|
|
60
|
+
var end = toRangeBoundary(range[1], true);
|
|
44
61
|
if (!start && !end) return null;
|
|
45
62
|
return [start, end];
|
|
46
63
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
1
2
|
/**
|
|
2
3
|
* 订单过滤函数
|
|
3
4
|
* @param orders 原始订单列表
|
|
@@ -347,9 +348,11 @@ export function filterOrders(orders, filters) {
|
|
|
347
348
|
|
|
348
349
|
// start_time / end_time - 创建时间范围
|
|
349
350
|
if (safeFilters.start_time || safeFilters.end_time) {
|
|
350
|
-
|
|
351
|
+
// 统一用 dayjs 按本地时区解析,避免 new Date("YYYY-MM-DD") 被当作 UTC 0 点
|
|
352
|
+
// 与含时分的本地时间字符串比较时产生时区错位
|
|
353
|
+
var orderTime = order.created_at ? typeof order.created_at === 'number' ? order.created_at : dayjs(String(order.created_at)).valueOf() : 0;
|
|
351
354
|
if (safeFilters.start_time) {
|
|
352
|
-
var startTs =
|
|
355
|
+
var startTs = dayjs(safeFilters.start_time).startOf('day').valueOf();
|
|
353
356
|
if (orderTime < startTs) {
|
|
354
357
|
rejected.push({
|
|
355
358
|
order_id: order.order_id,
|
|
@@ -364,8 +367,7 @@ export function filterOrders(orders, filters) {
|
|
|
364
367
|
}
|
|
365
368
|
}
|
|
366
369
|
if (safeFilters.end_time) {
|
|
367
|
-
|
|
368
|
-
var endTs = new Date(safeFilters.end_time).getTime() + 86400000 - 1;
|
|
370
|
+
var endTs = dayjs(safeFilters.end_time).endOf('day').valueOf();
|
|
369
371
|
if (orderTime > endTs) {
|
|
370
372
|
rejected.push({
|
|
371
373
|
order_id: order.order_id,
|
|
@@ -8,10 +8,12 @@ export declare class WalletPassEvaluator {
|
|
|
8
8
|
private engine;
|
|
9
9
|
private strategyConfigs;
|
|
10
10
|
private locale;
|
|
11
|
+
private otherParams;
|
|
11
12
|
constructor();
|
|
12
13
|
setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
|
|
13
14
|
getStrategyConfigs(): StrategyConfig[];
|
|
14
15
|
setLocale(locale: string): void;
|
|
16
|
+
setOtherParams(otherParams: any): void;
|
|
15
17
|
getText(key: string): string;
|
|
16
18
|
/**
|
|
17
19
|
* 搜索券的格式
|
|
@@ -50,16 +50,22 @@ var FIELD_REASON_CODE_MAP = {
|
|
|
50
50
|
applicableProductTotalAmount: "applicable_product_total_amount_not_enough",
|
|
51
51
|
applicableProductCount: "applicable_product_count_not_enough"
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
var AMOUNT_FIELDS = /* @__PURE__ */ new Set([
|
|
54
|
+
"orderTotalAmount",
|
|
55
|
+
"applicableProductTotalAmount"
|
|
56
|
+
]);
|
|
57
|
+
function formatReason(template, value, currency = "") {
|
|
54
58
|
if (!template)
|
|
55
59
|
return template;
|
|
56
|
-
const
|
|
57
|
-
|
|
60
|
+
const v = value === void 0 || value === null ? "" : String(value);
|
|
61
|
+
const c = currency === void 0 || currency === null ? "" : String(currency);
|
|
62
|
+
return template.replace(/\$\{value\}/g, v).replace(/\{value\}/g, v).replace(/\{currency\}/g, c);
|
|
58
63
|
}
|
|
59
64
|
var WalletPassEvaluator = class {
|
|
60
65
|
constructor() {
|
|
61
66
|
this.strategyConfigs = [];
|
|
62
67
|
this.locale = "en";
|
|
68
|
+
this.otherParams = {};
|
|
63
69
|
this.engine = new import__.StrategyEngine({
|
|
64
70
|
debug: false,
|
|
65
71
|
enableTrace: false
|
|
@@ -75,6 +81,9 @@ var WalletPassEvaluator = class {
|
|
|
75
81
|
setLocale(locale) {
|
|
76
82
|
this.locale = locale;
|
|
77
83
|
}
|
|
84
|
+
setOtherParams(otherParams) {
|
|
85
|
+
this.otherParams = otherParams;
|
|
86
|
+
}
|
|
78
87
|
getText(key) {
|
|
79
88
|
var _a, _b;
|
|
80
89
|
return (_b = (_a = import_locales.locales) == null ? void 0 : _a[this.locale]) == null ? void 0 : _b[key];
|
|
@@ -112,7 +121,7 @@ var WalletPassEvaluator = class {
|
|
|
112
121
|
* 评估可用的 vouchers
|
|
113
122
|
*/
|
|
114
123
|
evaluate(input) {
|
|
115
|
-
var _a, _b, _c, _d, _e;
|
|
124
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
116
125
|
const { orderTotalAmount, products, vouchers, strategyConfigs } = input;
|
|
117
126
|
const productIds = products.map((p) => p.product_id);
|
|
118
127
|
const results = [];
|
|
@@ -204,7 +213,8 @@ var WalletPassEvaluator = class {
|
|
|
204
213
|
reasonCode = codeMapping[evaluationResult.code] || "not_meet_the_required_conditions";
|
|
205
214
|
}
|
|
206
215
|
const rawText = this.getText(reasonCode);
|
|
207
|
-
const
|
|
216
|
+
const currency = failedField && AMOUNT_FIELDS.has(failedField) ? ((_g = (_f = this.otherParams) == null ? void 0 : _f.getData) == null ? void 0 : _g.call(_f, "shop_symbol")) || "" : "";
|
|
217
|
+
const reason = thresholdValue !== void 0 ? formatReason(rawText, thresholdValue, currency) : rawText;
|
|
208
218
|
results.push({
|
|
209
219
|
voucher,
|
|
210
220
|
isApplicable: false,
|
|
@@ -405,6 +415,7 @@ var WalletPassEvaluator = class {
|
|
|
405
415
|
* 计算适用商品的总金额和数量
|
|
406
416
|
*/
|
|
407
417
|
calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
|
|
418
|
+
console.log(products, "products1234");
|
|
408
419
|
let total = 0;
|
|
409
420
|
let count = 0;
|
|
410
421
|
if (applicableProductIds !== null && applicableProductIds.length === 0) {
|
|
@@ -30,8 +30,8 @@ var locales = {
|
|
|
30
30
|
"max_passes_per_item_reached": "该商品已达到卡券使用上限",
|
|
31
31
|
"not_available_for_this_channel": "当前渠道不可使用",
|
|
32
32
|
"not_valid_for_this_order_type": "当前订单类型不适用",
|
|
33
|
-
"order_total_amount_not_enough": "订单满
|
|
34
|
-
"applicable_product_total_amount_not_enough": "适用商品满
|
|
33
|
+
"order_total_amount_not_enough": "订单满 {currency}{value} 才可用",
|
|
34
|
+
"applicable_product_total_amount_not_enough": "适用商品满 {currency}{value} 才可用",
|
|
35
35
|
"applicable_product_count_not_enough": "至少购买 {value} 件适用商品才可用"
|
|
36
36
|
},
|
|
37
37
|
"en": {
|
|
@@ -41,8 +41,8 @@ var locales = {
|
|
|
41
41
|
"max_passes_per_item_reached": "Max passes per item reached.",
|
|
42
42
|
"not_available_for_this_channel": "Not available for this channel.",
|
|
43
43
|
"not_valid_for_this_order_type": "Not valid for this order type.",
|
|
44
|
-
"order_total_amount_not_enough": "Spend
|
|
45
|
-
"applicable_product_total_amount_not_enough": "
|
|
44
|
+
"order_total_amount_not_enough": "Spend {currency}{value} to use",
|
|
45
|
+
"applicable_product_total_amount_not_enough": "{currency}{value} on eligible items",
|
|
46
46
|
"applicable_product_count_not_enough": "Buy {value} eligible items to use"
|
|
47
47
|
},
|
|
48
48
|
"zh-HK": {
|
|
@@ -52,8 +52,8 @@ var locales = {
|
|
|
52
52
|
"max_passes_per_item_reached": "該商品已達卡券使用上限",
|
|
53
53
|
"not_available_for_this_channel": "當前渠道不可使用",
|
|
54
54
|
"not_valid_for_this_order_type": "當前訂單類型不適用",
|
|
55
|
-
"order_total_amount_not_enough": "訂單滿
|
|
56
|
-
"applicable_product_total_amount_not_enough": "適用商品滿
|
|
55
|
+
"order_total_amount_not_enough": "訂單滿 {currency}{value} 才可用",
|
|
56
|
+
"applicable_product_total_amount_not_enough": "適用商品滿 {currency}{value} 才可用",
|
|
57
57
|
"applicable_product_count_not_enough": "至少購買 {value} 件適用商品才可用"
|
|
58
58
|
}
|
|
59
59
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/server/modules/order/utils/filterBookings.ts
|
|
@@ -26,6 +36,7 @@ __export(filterBookings_exports, {
|
|
|
26
36
|
sortBookings: () => sortBookings
|
|
27
37
|
});
|
|
28
38
|
module.exports = __toCommonJS(filterBookings_exports);
|
|
39
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
29
40
|
function getBookingAppointmentStatus(booking) {
|
|
30
41
|
return String(booking.appointment_status ?? booking.status ?? "");
|
|
31
42
|
}
|
|
@@ -34,7 +45,23 @@ function toTimestamp(value) {
|
|
|
34
45
|
return 0;
|
|
35
46
|
if (typeof value === "number")
|
|
36
47
|
return value;
|
|
37
|
-
|
|
48
|
+
const d = (0, import_dayjs.default)(value);
|
|
49
|
+
return d.isValid() ? d.valueOf() : 0;
|
|
50
|
+
}
|
|
51
|
+
var DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
52
|
+
function toRangeBoundary(value, isEnd) {
|
|
53
|
+
if (value === void 0 || value === null || value === "")
|
|
54
|
+
return 0;
|
|
55
|
+
if (typeof value === "number")
|
|
56
|
+
return value;
|
|
57
|
+
const str = String(value).trim();
|
|
58
|
+
const d = (0, import_dayjs.default)(str);
|
|
59
|
+
if (!d.isValid())
|
|
60
|
+
return 0;
|
|
61
|
+
if (DATE_ONLY_RE.test(str)) {
|
|
62
|
+
return (isEnd ? d.endOf("day") : d.startOf("day")).valueOf();
|
|
63
|
+
}
|
|
64
|
+
return d.valueOf();
|
|
38
65
|
}
|
|
39
66
|
function bookingDateTimeString(datePart, timePart) {
|
|
40
67
|
const d = (datePart ?? "").trim();
|
|
@@ -47,8 +74,8 @@ function bookingDateTimeString(datePart, timePart) {
|
|
|
47
74
|
function parseDateRange(range) {
|
|
48
75
|
if (!Array.isArray(range) || range.length < 2)
|
|
49
76
|
return null;
|
|
50
|
-
const start =
|
|
51
|
-
const end =
|
|
77
|
+
const start = toRangeBoundary(range[0], false);
|
|
78
|
+
const end = toRangeBoundary(range[1], true);
|
|
52
79
|
if (!start && !end)
|
|
53
80
|
return null;
|
|
54
81
|
return [start, end];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/server/modules/order/utils/filterOrders.ts
|
|
@@ -22,6 +32,7 @@ __export(filterOrders_exports, {
|
|
|
22
32
|
filterOrders: () => filterOrders
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(filterOrders_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
25
36
|
function filterOrders(orders, filters) {
|
|
26
37
|
const safeFilters = filters || {};
|
|
27
38
|
if (!orders || !Array.isArray(orders)) {
|
|
@@ -316,9 +327,9 @@ function filterOrders(orders, filters) {
|
|
|
316
327
|
}
|
|
317
328
|
}
|
|
318
329
|
if (safeFilters.start_time || safeFilters.end_time) {
|
|
319
|
-
const orderTime = order.created_at ? typeof order.created_at === "number" ? order.created_at :
|
|
330
|
+
const orderTime = order.created_at ? typeof order.created_at === "number" ? order.created_at : (0, import_dayjs.default)(String(order.created_at)).valueOf() : 0;
|
|
320
331
|
if (safeFilters.start_time) {
|
|
321
|
-
const startTs =
|
|
332
|
+
const startTs = (0, import_dayjs.default)(safeFilters.start_time).startOf("day").valueOf();
|
|
322
333
|
if (orderTime < startTs) {
|
|
323
334
|
rejected.push({
|
|
324
335
|
order_id: order.order_id,
|
|
@@ -333,7 +344,7 @@ function filterOrders(orders, filters) {
|
|
|
333
344
|
}
|
|
334
345
|
}
|
|
335
346
|
if (safeFilters.end_time) {
|
|
336
|
-
const endTs =
|
|
347
|
+
const endTs = (0, import_dayjs.default)(safeFilters.end_time).endOf("day").valueOf();
|
|
337
348
|
if (orderTime > endTs) {
|
|
338
349
|
rejected.push({
|
|
339
350
|
order_id: order.order_id,
|