@pisell/pisellos 2.2.94 → 2.2.96
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.d.ts +1 -0
- package/dist/core/index.js +7 -0
- package/dist/modules/Customer/index.d.ts +1 -0
- package/dist/modules/Customer/index.js +28 -12
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/server/index.d.ts +6 -1
- package/dist/server/index.js +40 -17
- package/dist/server/modules/order/index.js +1 -1
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/server/modules/order/utils/filterBookings.js +1 -1
- package/dist/server/modules/products/index.d.ts +19 -24
- package/dist/server/modules/products/index.js +429 -600
- package/dist/server/modules/products/types.d.ts +1 -0
- package/dist/server/utils/product.d.ts +4 -0
- package/dist/server/utils/product.js +34 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/Sales/index.d.ts +1 -1
- package/dist/solution/Sales/index.js +79 -23
- package/dist/solution/Sales/types.d.ts +6 -4
- package/dist/types/index.d.ts +2 -0
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js +4 -0
- package/lib/modules/Customer/index.d.ts +1 -0
- package/lib/modules/Customer/index.js +21 -6
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/server/index.d.ts +6 -1
- package/lib/server/index.js +33 -13
- package/lib/server/modules/order/index.js +1 -1
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/server/modules/order/utils/filterBookings.js +1 -1
- package/lib/server/modules/products/index.d.ts +19 -24
- package/lib/server/modules/products/index.js +151 -150
- package/lib/server/modules/products/types.d.ts +1 -0
- package/lib/server/utils/product.d.ts +4 -0
- package/lib/server/utils/product.js +27 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/Sales/index.d.ts +1 -1
- package/lib/solution/Sales/index.js +73 -15
- package/lib/solution/Sales/types.d.ts +6 -4
- package/lib/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -403,6 +403,13 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
403
403
|
}
|
|
404
404
|
return destroy;
|
|
405
405
|
}()
|
|
406
|
+
}, {
|
|
407
|
+
key: "setContext",
|
|
408
|
+
value: function setContext(ctx) {
|
|
409
|
+
this.context = _objectSpread(_objectSpread({}, this.context), ctx);
|
|
410
|
+
this.log("\u4E0A\u4E0B\u6587\u5DF2\u66F4\u65B0: ".concat(JSON.stringify(Object.keys(ctx))));
|
|
411
|
+
}
|
|
412
|
+
|
|
406
413
|
/**
|
|
407
414
|
* 验证上下文参数
|
|
408
415
|
*/
|
|
@@ -9,6 +9,7 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
9
9
|
private cacheId;
|
|
10
10
|
private openCache;
|
|
11
11
|
private fatherModule;
|
|
12
|
+
private otherParams;
|
|
12
13
|
constructor(name?: string, version?: string);
|
|
13
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
14
15
|
/**
|
|
@@ -56,6 +56,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
56
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
57
57
|
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
58
58
|
_defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
|
|
59
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
59
60
|
return _this;
|
|
60
61
|
}
|
|
61
62
|
_createClass(CustomerModule, [{
|
|
@@ -70,6 +71,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
70
71
|
this.core = core;
|
|
71
72
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
72
73
|
this.request = this.core.getPlugin('request');
|
|
74
|
+
this.otherParams = (options === null || options === void 0 ? void 0 : options.otherParams) || {};
|
|
73
75
|
|
|
74
76
|
// 初始化状态
|
|
75
77
|
if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.customerList)) {
|
|
@@ -112,7 +114,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
112
114
|
if (options !== null && options !== void 0 && (_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
|
|
113
115
|
this.fatherModule = options.otherParams.fatherModule;
|
|
114
116
|
}
|
|
115
|
-
case
|
|
117
|
+
case 14:
|
|
116
118
|
case "end":
|
|
117
119
|
return _context.stop();
|
|
118
120
|
}
|
|
@@ -132,7 +134,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
132
134
|
key: "fetchCustomerListData",
|
|
133
135
|
value: (function () {
|
|
134
136
|
var _fetchCustomerListData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
135
|
-
var _res$data, _res$data2;
|
|
137
|
+
var _this$otherParams, _res$data, _this$otherParams2, _customerList2, _res$data2;
|
|
136
138
|
var params,
|
|
137
139
|
url,
|
|
138
140
|
_params$skip,
|
|
@@ -140,16 +142,21 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
142
|
_params$num,
|
|
141
143
|
num,
|
|
142
144
|
search,
|
|
143
|
-
|
|
145
|
+
_otherParams,
|
|
144
146
|
queryParams,
|
|
145
147
|
res,
|
|
148
|
+
_customerList,
|
|
149
|
+
_customerList3,
|
|
146
150
|
_args2 = arguments;
|
|
147
151
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
148
152
|
while (1) switch (_context2.prev = _context2.next) {
|
|
149
153
|
case 0:
|
|
150
154
|
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
151
|
-
url = '/customer/select-list';
|
|
152
|
-
|
|
155
|
+
url = '/customer/select-list'; // 如果是加盟子店铺,则使用加盟商的客户列表接口
|
|
156
|
+
if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.isFranchisee) {
|
|
157
|
+
url = '/franchisee/customer/select-list';
|
|
158
|
+
}
|
|
159
|
+
_params$skip = params.skip, skip = _params$skip === void 0 ? 1 : _params$skip, _params$num = params.num, num = _params$num === void 0 ? DEFAULT_PAGE_SIZE : _params$num, search = params.search, _otherParams = _objectWithoutProperties(params, _excluded);
|
|
153
160
|
queryParams = _objectSpread(_objectSpread({
|
|
154
161
|
skip: skip,
|
|
155
162
|
num: num,
|
|
@@ -159,29 +166,38 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
159
166
|
search_wallet_pass_flag: 1
|
|
160
167
|
}, search && {
|
|
161
168
|
search: search
|
|
162
|
-
}),
|
|
163
|
-
_context2.next =
|
|
169
|
+
}), _otherParams);
|
|
170
|
+
_context2.next = 7;
|
|
164
171
|
return this.request.get(url, queryParams, {
|
|
165
172
|
cache: {
|
|
166
173
|
mode: RequestModeENUM.REMOTE_LOCAL,
|
|
167
174
|
type: "memory"
|
|
168
175
|
}
|
|
169
176
|
});
|
|
170
|
-
case
|
|
177
|
+
case 7:
|
|
171
178
|
res = _context2.sent;
|
|
172
179
|
if (!((res === null || res === void 0 ? void 0 : res.code) !== 200)) {
|
|
173
|
-
_context2.next =
|
|
180
|
+
_context2.next = 10;
|
|
174
181
|
break;
|
|
175
182
|
}
|
|
176
183
|
throw new Error(res === null || res === void 0 ? void 0 : res.message);
|
|
177
|
-
case
|
|
184
|
+
case 10:
|
|
185
|
+
// 如果是加盟子店铺,查询的接口返回的数据都是总店的客户数据,需要加上标识
|
|
186
|
+
_customerList = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
|
|
187
|
+
if ((_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.isFranchisee && ((_customerList2 = _customerList) === null || _customerList2 === void 0 ? void 0 : _customerList2.length) > 0) {
|
|
188
|
+
_customerList = (_customerList3 = _customerList) === null || _customerList3 === void 0 ? void 0 : _customerList3.map(function (item) {
|
|
189
|
+
return _objectSpread(_objectSpread({}, item || {}), {}, {
|
|
190
|
+
is_franchisor_customer: 1 // 标识是总店的客户
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
}
|
|
178
194
|
return _context2.abrupt("return", {
|
|
179
|
-
customerList:
|
|
195
|
+
customerList: _customerList,
|
|
180
196
|
total: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.count) || 0,
|
|
181
197
|
page: skip,
|
|
182
198
|
pageSize: num
|
|
183
199
|
});
|
|
184
|
-
case
|
|
200
|
+
case 13:
|
|
185
201
|
case "end":
|
|
186
202
|
return _context2.stop();
|
|
187
203
|
}
|
|
@@ -23,7 +23,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
23
23
|
*/
|
|
24
24
|
private logError;
|
|
25
25
|
createOrder(params: CommitOrderParams['query']): {
|
|
26
|
-
type: "
|
|
26
|
+
type: "appointment_booking" | "virtual";
|
|
27
27
|
platform: string;
|
|
28
28
|
sales_channel: string;
|
|
29
29
|
order_sales_channel: string;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -167,7 +167,7 @@ declare class Server {
|
|
|
167
167
|
*/
|
|
168
168
|
private handleUnsubscribeOrderQuery;
|
|
169
169
|
/**
|
|
170
|
-
* 判断预约查询的
|
|
170
|
+
* 判断预约查询的 sales_time_between 起始日期是否为今天
|
|
171
171
|
*/
|
|
172
172
|
private isBookingQueryForToday;
|
|
173
173
|
/**
|
|
@@ -201,11 +201,16 @@ declare class Server {
|
|
|
201
201
|
/**
|
|
202
202
|
* 商品查询的核心计算逻辑(编排 Products、Menu、Schedule 模块)
|
|
203
203
|
* 供 handleProductQuery 首次返回及 pubsub 变更推送复用
|
|
204
|
+
* @param context 查询上下文
|
|
205
|
+
* @param options 可选参数
|
|
206
|
+
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
204
207
|
*/
|
|
205
208
|
private computeProductQueryResult;
|
|
206
209
|
/**
|
|
207
210
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
208
211
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|
|
212
|
+
* @param options 可选参数
|
|
213
|
+
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
209
214
|
*/
|
|
210
215
|
private recomputeAndNotifyProductQuery;
|
|
211
216
|
/**
|
package/dist/server/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import { perfMark } from "./utils/product";
|
|
|
29
29
|
import { OrderModule } from "./modules/order";
|
|
30
30
|
import { OrderHooks } from "./modules/order/types";
|
|
31
31
|
import { filterOrders } from "./modules/order/utils/filterOrders";
|
|
32
|
-
import { filterBookingsFromOrders, sortBookings
|
|
32
|
+
import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/filterBookings";
|
|
33
33
|
|
|
34
34
|
// 重新导出类型供外部使用
|
|
35
35
|
|
|
@@ -977,8 +977,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
977
977
|
});
|
|
978
978
|
case 14:
|
|
979
979
|
// 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
|
|
980
|
-
this.core.effects.on(ProductsHooks.onProductsSyncCompleted, function () {
|
|
981
|
-
_this3.recomputeAndNotifyProductQuery(
|
|
980
|
+
this.core.effects.on(ProductsHooks.onProductsSyncCompleted, function (payload) {
|
|
981
|
+
_this3.recomputeAndNotifyProductQuery({
|
|
982
|
+
changedIds: payload === null || payload === void 0 ? void 0 : payload.changedIds
|
|
983
|
+
});
|
|
982
984
|
});
|
|
983
985
|
|
|
984
986
|
// 订单 / 预约本地数据变更时,向订阅者推送最新列表
|
|
@@ -1380,10 +1382,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1380
1382
|
key: "isBookingQueryForToday",
|
|
1381
1383
|
value:
|
|
1382
1384
|
/**
|
|
1383
|
-
* 判断预约查询的
|
|
1385
|
+
* 判断预约查询的 sales_time_between 起始日期是否为今天
|
|
1384
1386
|
*/
|
|
1385
1387
|
function isBookingQueryForToday(data) {
|
|
1386
|
-
var range = data === null || data === void 0 ? void 0 : data.
|
|
1388
|
+
var range = data === null || data === void 0 ? void 0 : data.sales_time_between;
|
|
1387
1389
|
if (!Array.isArray(range) || range.length < 1) return true;
|
|
1388
1390
|
var startDateStr = String(range[0]).split('T')[0].split(' ')[0];
|
|
1389
1391
|
var todayStr = dayjs().format('YYYY-MM-DD');
|
|
@@ -1420,6 +1422,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1420
1422
|
_context17.prev = 3;
|
|
1421
1423
|
_context17.next = 6;
|
|
1422
1424
|
return this.app.request.get('/shop/order/sales', _objectSpread(_objectSpread({}, data), {}, {
|
|
1425
|
+
form_record_ids: undefined,
|
|
1423
1426
|
with: ["all"]
|
|
1424
1427
|
}), {
|
|
1425
1428
|
isShopApi: true
|
|
@@ -1427,15 +1430,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
1427
1430
|
case 6:
|
|
1428
1431
|
response = _context17.sent;
|
|
1429
1432
|
rawList = (_ref23 = (_response$data$list = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) !== null && _response$data$list !== void 0 ? _response$data$list : response === null || response === void 0 ? void 0 : response.list) !== null && _ref23 !== void 0 ? _ref23 : [];
|
|
1430
|
-
list =
|
|
1433
|
+
list = filterBookingsFromOrders(rawList, data);
|
|
1431
1434
|
this.logInfo('fetchBookingListFromAPI: API 返回并拆分完成', {
|
|
1432
1435
|
rawCount: rawList.length,
|
|
1433
|
-
flattenedCount: list.
|
|
1436
|
+
flattenedCount: list.count
|
|
1434
1437
|
});
|
|
1435
1438
|
return _context17.abrupt("return", {
|
|
1436
1439
|
code: 200,
|
|
1437
1440
|
data: _objectSpread(_objectSpread({}, response.data), {}, {
|
|
1438
|
-
list: list
|
|
1441
|
+
list: (list === null || list === void 0 ? void 0 : list.list) || []
|
|
1439
1442
|
}),
|
|
1440
1443
|
message: '',
|
|
1441
1444
|
status: true
|
|
@@ -1586,15 +1589,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1586
1589
|
/**
|
|
1587
1590
|
* 商品查询的核心计算逻辑(编排 Products、Menu、Schedule 模块)
|
|
1588
1591
|
* 供 handleProductQuery 首次返回及 pubsub 变更推送复用
|
|
1592
|
+
* @param context 查询上下文
|
|
1593
|
+
* @param options 可选参数
|
|
1594
|
+
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
1589
1595
|
*/
|
|
1590
1596
|
)
|
|
1591
1597
|
}, {
|
|
1592
1598
|
key: "computeProductQueryResult",
|
|
1593
1599
|
value: (function () {
|
|
1594
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(context) {
|
|
1600
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(context, options) {
|
|
1595
1601
|
var _menu_list_ids$length3,
|
|
1596
1602
|
_this5 = this;
|
|
1597
|
-
var tTotal, menu_list_ids, schedule_date, schedule_datetime, activeMenuList, tMenu, menuList, tPrice, allProductsWithPrice, tFilter, filteredProducts, tSort;
|
|
1603
|
+
var tTotal, menu_list_ids, schedule_date, schedule_datetime, activeMenuList, tMenu, menuList, tPrice, allProductsWithPrice, tFilter, filteredProducts, tStatus, beforeStatusCount, tSort;
|
|
1598
1604
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1599
1605
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1600
1606
|
case 0:
|
|
@@ -1603,7 +1609,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1603
1609
|
this.logInfo('computeProductQueryResult 开始', {
|
|
1604
1610
|
menuListIdsCount: (_menu_list_ids$length3 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length3 !== void 0 ? _menu_list_ids$length3 : 0,
|
|
1605
1611
|
schedule_datetime: schedule_datetime,
|
|
1606
|
-
schedule_date: schedule_date
|
|
1612
|
+
schedule_date: schedule_date,
|
|
1613
|
+
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
1607
1614
|
});
|
|
1608
1615
|
if (this.products) {
|
|
1609
1616
|
_context20.next = 6;
|
|
@@ -1661,6 +1668,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1661
1668
|
_context20.next = 17;
|
|
1662
1669
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
1663
1670
|
scheduleModule: this.getSchedule()
|
|
1671
|
+
}, {
|
|
1672
|
+
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
1664
1673
|
});
|
|
1665
1674
|
case 17:
|
|
1666
1675
|
allProductsWithPrice = _context20.sent;
|
|
@@ -1673,6 +1682,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
1673
1682
|
before: allProductsWithPrice.length,
|
|
1674
1683
|
after: filteredProducts.length
|
|
1675
1684
|
});
|
|
1685
|
+
tStatus = performance.now();
|
|
1686
|
+
beforeStatusCount = filteredProducts.length;
|
|
1687
|
+
filteredProducts = filteredProducts.filter(function (p) {
|
|
1688
|
+
return ((p === null || p === void 0 ? void 0 : p.status) || "published") === 'published';
|
|
1689
|
+
});
|
|
1690
|
+
perfMark('computeQuery.filterByStatus', performance.now() - tStatus, {
|
|
1691
|
+
before: beforeStatusCount,
|
|
1692
|
+
after: filteredProducts.length
|
|
1693
|
+
});
|
|
1676
1694
|
tSort = performance.now();
|
|
1677
1695
|
filteredProducts = filteredProducts.sort(function (a, b) {
|
|
1678
1696
|
var sortDiff = Number(b.sort) - Number(a.sort);
|
|
@@ -1701,13 +1719,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1701
1719
|
message: '',
|
|
1702
1720
|
status: true
|
|
1703
1721
|
});
|
|
1704
|
-
case
|
|
1722
|
+
case 32:
|
|
1705
1723
|
case "end":
|
|
1706
1724
|
return _context20.stop();
|
|
1707
1725
|
}
|
|
1708
1726
|
}, _callee20, this);
|
|
1709
1727
|
}));
|
|
1710
|
-
function computeProductQueryResult(_x23) {
|
|
1728
|
+
function computeProductQueryResult(_x23, _x24) {
|
|
1711
1729
|
return _computeProductQueryResult.apply(this, arguments);
|
|
1712
1730
|
}
|
|
1713
1731
|
return computeProductQueryResult;
|
|
@@ -1715,12 +1733,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1715
1733
|
/**
|
|
1716
1734
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
1717
1735
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|
|
1736
|
+
* @param options 可选参数
|
|
1737
|
+
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
1718
1738
|
*/
|
|
1719
1739
|
)
|
|
1720
1740
|
}, {
|
|
1721
1741
|
key: "recomputeAndNotifyProductQuery",
|
|
1722
1742
|
value: (function () {
|
|
1723
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1743
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(options) {
|
|
1724
1744
|
var _iterator3, _step3, _step3$value, subscriberId, subscriber, result, errorMessage;
|
|
1725
1745
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1726
1746
|
while (1) switch (_context21.prev = _context21.next) {
|
|
@@ -1732,7 +1752,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1732
1752
|
return _context21.abrupt("return");
|
|
1733
1753
|
case 2:
|
|
1734
1754
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
1735
|
-
subscriberCount: this.productQuerySubscribers.size
|
|
1755
|
+
subscriberCount: this.productQuerySubscribers.size,
|
|
1756
|
+
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
1736
1757
|
});
|
|
1737
1758
|
_iterator3 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
1738
1759
|
_context21.prev = 4;
|
|
@@ -1745,7 +1766,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
1745
1766
|
_step3$value = _slicedToArray(_step3.value, 2), subscriberId = _step3$value[0], subscriber = _step3$value[1];
|
|
1746
1767
|
_context21.prev = 8;
|
|
1747
1768
|
_context21.next = 11;
|
|
1748
|
-
return this.computeProductQueryResult(subscriber.context
|
|
1769
|
+
return this.computeProductQueryResult(subscriber.context, {
|
|
1770
|
+
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
1771
|
+
});
|
|
1749
1772
|
case 11:
|
|
1750
1773
|
result = _context21.sent;
|
|
1751
1774
|
subscriber.callback(result);
|
|
@@ -1782,7 +1805,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1782
1805
|
}
|
|
1783
1806
|
}, _callee21, this, [[4, 24, 27, 30], [8, 16]]);
|
|
1784
1807
|
}));
|
|
1785
|
-
function recomputeAndNotifyProductQuery() {
|
|
1808
|
+
function recomputeAndNotifyProductQuery(_x25) {
|
|
1786
1809
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
1787
1810
|
}
|
|
1788
1811
|
return recomputeAndNotifyProductQuery;
|
|
@@ -54,7 +54,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
54
54
|
_defineProperty(_assertThisInitialized(_this), "orderDataSource", void 0);
|
|
55
55
|
_defineProperty(_assertThisInitialized(_this), "pendingSyncMessages", []);
|
|
56
56
|
_defineProperty(_assertThisInitialized(_this), "syncTimer", void 0);
|
|
57
|
-
_defineProperty(_assertThisInitialized(_this), "ORDER_SYNC_DEBOUNCE_MS",
|
|
57
|
+
_defineProperty(_assertThisInitialized(_this), "ORDER_SYNC_DEBOUNCE_MS", 5000);
|
|
58
58
|
// Map<resource_id, OrderId[]> 资源到订单的倒排索引
|
|
59
59
|
_defineProperty(_assertThisInitialized(_this), "resourceIdIndex", new Map());
|
|
60
60
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
@@ -438,7 +438,7 @@ export interface BookingFilters {
|
|
|
438
438
|
payment_method?: string[];
|
|
439
439
|
business_code?: string;
|
|
440
440
|
appointment_status?: string[];
|
|
441
|
-
|
|
441
|
+
sales_time_between?: string[];
|
|
442
442
|
/**
|
|
443
443
|
* 仅保留「预约开始时刻」大于等于该时间的条目。
|
|
444
444
|
* 预约时刻由 start_date 与 start_time 拼接解析(与 order_by start_at 一致)。
|
|
@@ -71,7 +71,7 @@ function prepareFilters(f) {
|
|
|
71
71
|
customerIdStr: hasCustomerId ? String(f.customer_id) : '',
|
|
72
72
|
hasBusinessCode: !!f.business_code,
|
|
73
73
|
businessCode: f.business_code,
|
|
74
|
-
bookingTimeRange: parseDateRange(f.
|
|
74
|
+
bookingTimeRange: parseDateRange(f.sales_time_between),
|
|
75
75
|
createdAtRange: parseDateRange(f.created_at_between),
|
|
76
76
|
updatedAtRange: parseDateRange(f.updated_at_between),
|
|
77
77
|
numberRange: parseNumberRange(f.number_between),
|
|
@@ -53,14 +53,20 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
53
53
|
* 缓存的是已经应用了价格的完整商品列表,避免重复转换
|
|
54
54
|
* @param schedule_date 日期
|
|
55
55
|
* @param extraContext 额外的上下文数据(可选,由 Server 层传入)
|
|
56
|
+
* @param options 可选参数
|
|
57
|
+
* @param options.changedIds 变更的商品 IDs,非空时仅对这些商品增量执行 prepare 并更新缓存
|
|
56
58
|
* @returns 应用了价格的商品列表
|
|
57
59
|
*/
|
|
58
|
-
getProductsWithPrice(schedule_date: string, extraContext?: Partial<ProductFormatterContext
|
|
60
|
+
getProductsWithPrice(schedule_date: string, extraContext?: Partial<ProductFormatterContext>, options?: {
|
|
61
|
+
changedIds?: number[];
|
|
62
|
+
}): Promise<ProductData[]>;
|
|
59
63
|
/**
|
|
60
64
|
* 准备带价格的商品数据(通过格式化器流程处理)
|
|
61
65
|
* @param schedule_date 日期
|
|
62
66
|
* @param extraContext 额外的上下文数据(可选)
|
|
63
|
-
* @
|
|
67
|
+
* @param options 可选参数
|
|
68
|
+
* @param options.productIds 指定商品 IDs,仅处理这些商品;不传则处理全量
|
|
69
|
+
* @returns 处理后的商品列表
|
|
64
70
|
* @private
|
|
65
71
|
*/
|
|
66
72
|
private prepareProductsWithPrice;
|
|
@@ -156,11 +162,6 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
156
162
|
* 用于 pubsub 同步 create / update / batch_update 场景
|
|
157
163
|
*/
|
|
158
164
|
refreshProducts(): Promise<ProductData[]>;
|
|
159
|
-
/**
|
|
160
|
-
* 局部更新指定商品的报价单价格
|
|
161
|
-
* 遍历所有已缓存的日期,为目标商品重新获取价格并覆盖到缓存中
|
|
162
|
-
*/
|
|
163
|
-
updateProductPriceByIds(ids: number[]): Promise<void>;
|
|
164
165
|
/**
|
|
165
166
|
* 清空缓存
|
|
166
167
|
*/
|
|
@@ -202,15 +203,18 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
202
203
|
*
|
|
203
204
|
* product 模块:
|
|
204
205
|
* - operation === 'delete' → 本地删除
|
|
205
|
-
* -
|
|
206
|
-
* -
|
|
207
|
-
* -
|
|
206
|
+
* - change_types 包含 price → 仅收集变更 IDs(不拉商品数据)
|
|
207
|
+
* - 有 body → body 完整数据直接覆盖本地
|
|
208
|
+
* - 其他 → SSE 增量拉取
|
|
208
209
|
*
|
|
209
|
-
* product_collection / product_category
|
|
210
|
+
* product_collection / product_category:
|
|
210
211
|
* - 按 relation_product_ids SSE 拉取受影响商品
|
|
211
|
-
* - product_quotation 额外刷新报价单价格缓存
|
|
212
212
|
*
|
|
213
|
-
*
|
|
213
|
+
* product_quotation:
|
|
214
|
+
* - 报价单变更影响范围大,直接清除价格缓存走全量重建
|
|
215
|
+
*
|
|
216
|
+
* 处理完成后 emit onProductsSyncCompleted(携带 changedIds),
|
|
217
|
+
* Server 层监听该事件后对变更商品增量执行 prepareProductsWithPrice 并更新缓存
|
|
214
218
|
*/
|
|
215
219
|
private processProductSyncMessages;
|
|
216
220
|
/**
|
|
@@ -221,7 +225,8 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
221
225
|
/**
|
|
222
226
|
* 将 body 完整数据直接覆盖到本地 store(不调用报价单接口)
|
|
223
227
|
* 已存在的 → 直接替换;不存在的 → 追加
|
|
224
|
-
* 同时更新 Map 缓存、IndexDB
|
|
228
|
+
* 同时更新 Map 缓存、IndexDB,触发 onProductsChanged
|
|
229
|
+
* 价格缓存由 processProductSyncMessages 末尾统一清除
|
|
225
230
|
*/
|
|
226
231
|
private applyBodyUpdatesToStore;
|
|
227
232
|
/**
|
|
@@ -230,16 +235,6 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
230
235
|
* 同时更新 store.map、IndexDB,触发 onProductsChanged
|
|
231
236
|
*/
|
|
232
237
|
private mergeProductsToStore;
|
|
233
|
-
/**
|
|
234
|
-
* 增量更新价格缓存中变更的商品
|
|
235
|
-
* 对每个已缓存的日期 key:替换/追加最新商品数据,重新拉取这些 ID 的价格并应用
|
|
236
|
-
*/
|
|
237
|
-
private updatePriceCacheForProducts;
|
|
238
|
-
/**
|
|
239
|
-
* 全量重新拉取报价单价格并重建价格缓存
|
|
240
|
-
* 遍历当前已缓存的所有日期 key,对每个日期重新调用 loadProductsPrice
|
|
241
|
-
*/
|
|
242
|
-
private refreshAllPriceCache;
|
|
243
238
|
/**
|
|
244
239
|
* 静默全量刷新:后台重新拉取全量 SSE 数据并更新本地
|
|
245
240
|
* 拿到完整数据后一次性替换 store,清除价格缓存,触发 onProductsSyncCompleted
|