@pisell/pisellos 0.0.97 → 0.0.99
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/modules/ProductList/index.d.ts +7 -0
- package/dist/modules/ProductList/index.js +63 -29
- package/dist/solution/BookingByStep/index.d.ts +2 -1
- package/dist/solution/BookingByStep/index.js +70 -58
- package/lib/modules/ProductList/index.d.ts +7 -0
- package/lib/modules/ProductList/index.js +19 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -1
- package/lib/solution/BookingByStep/index.js +29 -19
- package/package.json +1 -1
|
@@ -7,9 +7,16 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
7
7
|
protected defaultName: string;
|
|
8
8
|
protected defaultVersion: string;
|
|
9
9
|
private store;
|
|
10
|
+
private request;
|
|
10
11
|
constructor(name?: string, version?: string);
|
|
11
12
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
12
13
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
14
|
+
loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
|
|
15
|
+
ids?: number[];
|
|
16
|
+
customer_id?: number;
|
|
17
|
+
schedule_date?: string;
|
|
18
|
+
channel?: string;
|
|
19
|
+
}): Promise<any>;
|
|
13
20
|
getProducts(): Promise<ProductData[]>;
|
|
14
21
|
getProduct(id: number): Promise<Product | undefined>;
|
|
15
22
|
addProduct(products: ProductData[]): Promise<void>;
|
|
@@ -30,6 +30,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
30
30
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'productList');
|
|
31
31
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
32
32
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
33
34
|
return _this;
|
|
34
35
|
}
|
|
35
36
|
_createClass(ProductList, [{
|
|
@@ -51,7 +52,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
51
52
|
this.store.productMap = new Map();
|
|
52
53
|
this.store.selectProducts = [];
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
+
this.request = core.getPlugin('request');
|
|
56
|
+
case 4:
|
|
55
57
|
case "end":
|
|
56
58
|
return _context.stop();
|
|
57
59
|
}
|
|
@@ -95,22 +97,54 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
95
97
|
return storeChange;
|
|
96
98
|
}()
|
|
97
99
|
}, {
|
|
98
|
-
key: "
|
|
100
|
+
key: "loadProductsPrice",
|
|
99
101
|
value: function () {
|
|
100
|
-
var
|
|
102
|
+
var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
103
|
+
var _ref$ids, ids, customer_id, schedule_date, channel, productsData;
|
|
101
104
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
102
105
|
while (1) switch (_context3.prev = _context3.next) {
|
|
103
106
|
case 0:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
_ref$ids = _ref.ids, ids = _ref$ids === void 0 ? [] : _ref$ids, customer_id = _ref.customer_id, schedule_date = _ref.schedule_date, channel = _ref.channel;
|
|
108
|
+
_context3.next = 3;
|
|
109
|
+
return this.request.post("/product/query/price", {
|
|
110
|
+
ids: ids,
|
|
111
|
+
customer_id: customer_id,
|
|
112
|
+
schedule_date: schedule_date,
|
|
113
|
+
channel: channel
|
|
114
|
+
}, {
|
|
115
|
+
useCache: true
|
|
116
|
+
});
|
|
108
117
|
case 3:
|
|
118
|
+
productsData = _context3.sent;
|
|
119
|
+
return _context3.abrupt("return", productsData.data);
|
|
120
|
+
case 5:
|
|
109
121
|
case "end":
|
|
110
122
|
return _context3.stop();
|
|
111
123
|
}
|
|
112
124
|
}, _callee3, this);
|
|
113
125
|
}));
|
|
126
|
+
function loadProductsPrice(_x5) {
|
|
127
|
+
return _loadProductsPrice.apply(this, arguments);
|
|
128
|
+
}
|
|
129
|
+
return loadProductsPrice;
|
|
130
|
+
}()
|
|
131
|
+
}, {
|
|
132
|
+
key: "getProducts",
|
|
133
|
+
value: function () {
|
|
134
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
135
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
136
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
_context4.next = 2;
|
|
139
|
+
return this.core.effects.emit(ProductListHooks.onGetProducts, this.store.list);
|
|
140
|
+
case 2:
|
|
141
|
+
return _context4.abrupt("return", cloneDeep(this.store.list));
|
|
142
|
+
case 3:
|
|
143
|
+
case "end":
|
|
144
|
+
return _context4.stop();
|
|
145
|
+
}
|
|
146
|
+
}, _callee4, this);
|
|
147
|
+
}));
|
|
114
148
|
function getProducts() {
|
|
115
149
|
return _getProducts.apply(this, arguments);
|
|
116
150
|
}
|
|
@@ -119,29 +153,29 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
119
153
|
}, {
|
|
120
154
|
key: "getProduct",
|
|
121
155
|
value: function () {
|
|
122
|
-
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
156
|
+
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
|
|
123
157
|
var product;
|
|
124
|
-
return _regeneratorRuntime().wrap(function
|
|
125
|
-
while (1) switch (
|
|
158
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
159
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
126
160
|
case 0:
|
|
127
|
-
|
|
161
|
+
_context5.next = 2;
|
|
128
162
|
return this.core.effects.emit(ProductListHooks.onGetProduct, this.store.list);
|
|
129
163
|
case 2:
|
|
130
164
|
product = this.store.productMap.get("".concat(id));
|
|
131
165
|
if (!product) {
|
|
132
|
-
|
|
166
|
+
_context5.next = 5;
|
|
133
167
|
break;
|
|
134
168
|
}
|
|
135
|
-
return
|
|
169
|
+
return _context5.abrupt("return", product);
|
|
136
170
|
case 5:
|
|
137
|
-
return
|
|
171
|
+
return _context5.abrupt("return", undefined);
|
|
138
172
|
case 6:
|
|
139
173
|
case "end":
|
|
140
|
-
return
|
|
174
|
+
return _context5.stop();
|
|
141
175
|
}
|
|
142
|
-
},
|
|
176
|
+
}, _callee5, this);
|
|
143
177
|
}));
|
|
144
|
-
function getProduct(
|
|
178
|
+
function getProduct(_x6) {
|
|
145
179
|
return _getProduct.apply(this, arguments);
|
|
146
180
|
}
|
|
147
181
|
return getProduct;
|
|
@@ -149,10 +183,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
149
183
|
}, {
|
|
150
184
|
key: "addProduct",
|
|
151
185
|
value: function () {
|
|
152
|
-
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
186
|
+
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(products) {
|
|
153
187
|
var _this3 = this;
|
|
154
|
-
return _regeneratorRuntime().wrap(function
|
|
155
|
-
while (1) switch (
|
|
188
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
189
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
156
190
|
case 0:
|
|
157
191
|
// 加到 list 以后上面的storeChange 会自动初始化商品详情的 module 实例
|
|
158
192
|
// list 需要根据 id 去重
|
|
@@ -172,11 +206,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
172
206
|
this.storeChange();
|
|
173
207
|
case 3:
|
|
174
208
|
case "end":
|
|
175
|
-
return
|
|
209
|
+
return _context6.stop();
|
|
176
210
|
}
|
|
177
|
-
},
|
|
211
|
+
}, _callee6, this);
|
|
178
212
|
}));
|
|
179
|
-
function addProduct(
|
|
213
|
+
function addProduct(_x7) {
|
|
180
214
|
return _addProduct.apply(this, arguments);
|
|
181
215
|
}
|
|
182
216
|
return addProduct;
|
|
@@ -184,18 +218,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
184
218
|
}, {
|
|
185
219
|
key: "selectProducts",
|
|
186
220
|
value: function () {
|
|
187
|
-
var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
188
|
-
return _regeneratorRuntime().wrap(function
|
|
189
|
-
while (1) switch (
|
|
221
|
+
var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(products) {
|
|
222
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
223
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
190
224
|
case 0:
|
|
191
225
|
this.store.selectProducts = products;
|
|
192
226
|
case 1:
|
|
193
227
|
case "end":
|
|
194
|
-
return
|
|
228
|
+
return _context7.stop();
|
|
195
229
|
}
|
|
196
|
-
},
|
|
230
|
+
}, _callee7, this);
|
|
197
231
|
}));
|
|
198
|
-
function selectProducts(
|
|
232
|
+
function selectProducts(_x8) {
|
|
199
233
|
return _selectProducts.apply(this, arguments);
|
|
200
234
|
}
|
|
201
235
|
return selectProducts;
|
|
@@ -186,10 +186,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
186
186
|
private getScheduleDataByIds;
|
|
187
187
|
openProductDetail(productId: number): Promise<void>;
|
|
188
188
|
closeProductDetail(): void;
|
|
189
|
-
getTimeslotBySchedule({ date, scheduleIds, resources, }: {
|
|
189
|
+
getTimeslotBySchedule({ date, scheduleIds, resources, product }: {
|
|
190
190
|
date: string;
|
|
191
191
|
scheduleIds?: number[];
|
|
192
192
|
resources?: ProductResourceItem[];
|
|
193
|
+
product?: ProductData;
|
|
193
194
|
}): {
|
|
194
195
|
start_time: string;
|
|
195
196
|
end_time: string;
|
|
@@ -203,8 +203,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
203
203
|
key: "loadProducts",
|
|
204
204
|
value: function () {
|
|
205
205
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
206
|
-
var _schedule_ids
|
|
207
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, userPlugin, customer_id, productsData;
|
|
206
|
+
var _schedule_ids;
|
|
207
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, userPlugin, customer_id, _userPlugin$get, productsData;
|
|
208
208
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
209
209
|
while (1) switch (_context2.prev = _context2.next) {
|
|
210
210
|
case 0:
|
|
@@ -222,11 +222,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
userPlugin = this.core.getPlugin('user');
|
|
225
|
-
customer_id =
|
|
226
|
-
|
|
225
|
+
customer_id = undefined;
|
|
226
|
+
try {
|
|
227
|
+
customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error(error);
|
|
230
|
+
}
|
|
231
|
+
// 如果没传schedule_date,则从
|
|
232
|
+
_context2.next = 7;
|
|
227
233
|
return this.request.post("/product/query", {
|
|
228
234
|
open_quotation: 1,
|
|
229
|
-
open_bundle:
|
|
235
|
+
open_bundle: 0,
|
|
230
236
|
extension_type: ['product_appointment', 'appointment_ticket', 'session_product', 'session_ticket'],
|
|
231
237
|
with: ['category', 'collection', 'resourceRelation'],
|
|
232
238
|
status: 'published',
|
|
@@ -242,11 +248,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
242
248
|
}, {
|
|
243
249
|
useCache: true
|
|
244
250
|
});
|
|
245
|
-
case
|
|
251
|
+
case 7:
|
|
246
252
|
productsData = _context2.sent;
|
|
247
253
|
this.store.products.addProduct(productsData.data.list);
|
|
248
254
|
return _context2.abrupt("return", productsData.data.list);
|
|
249
|
-
case
|
|
255
|
+
case 10:
|
|
250
256
|
case "end":
|
|
251
257
|
return _context2.stop();
|
|
252
258
|
}
|
|
@@ -307,58 +313,62 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
307
313
|
key: "updateQuotationPriceAndCart",
|
|
308
314
|
value: function () {
|
|
309
315
|
var _updateQuotationPriceAndCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(date) {
|
|
310
|
-
var
|
|
311
|
-
|
|
312
|
-
var dateRange, scheduleIds, scheduleList, cartItems, _iterator, _step, _loop;
|
|
316
|
+
var _this3 = this;
|
|
317
|
+
var cartItems, userPlugin, customer_id, _userPlugin$get2, res, _iterator, _step, _loop;
|
|
313
318
|
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
314
319
|
while (1) switch (_context5.prev = _context5.next) {
|
|
315
320
|
case 0:
|
|
316
|
-
dateRange = this.store.date.getDateRange();
|
|
317
|
-
scheduleIds = [];
|
|
318
|
-
if (dateRange.length) {
|
|
319
|
-
scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
|
|
320
|
-
scheduleIds = scheduleList.filter(function (n) {
|
|
321
|
-
return n.date === dateRange[0].date;
|
|
322
|
-
}).flatMap(function (n) {
|
|
323
|
-
return n.schedule_id;
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
_context5.next = 5;
|
|
327
|
-
return this.loadProducts(_objectSpread(_objectSpread({}, (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.productModuleParams), {}, {
|
|
328
|
-
scheduleIds: scheduleIds,
|
|
329
|
-
schedule_date: date
|
|
330
|
-
}));
|
|
331
|
-
case 5:
|
|
332
321
|
// 更新完商品数据以后,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
333
322
|
cartItems = this.store.cart.getItems();
|
|
334
323
|
if (!cartItems.length) {
|
|
335
|
-
_context5.next =
|
|
324
|
+
_context5.next = 25;
|
|
336
325
|
break;
|
|
337
326
|
}
|
|
327
|
+
userPlugin = this.core.getPlugin('user');
|
|
328
|
+
customer_id = undefined;
|
|
329
|
+
try {
|
|
330
|
+
customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get2 = userPlugin.get()) === null || _userPlugin$get2 === void 0 ? void 0 : _userPlugin$get2.id;
|
|
331
|
+
} catch (error) {
|
|
332
|
+
console.error(error);
|
|
333
|
+
}
|
|
334
|
+
_context5.next = 7;
|
|
335
|
+
return this.store.products.loadProductsPrice({
|
|
336
|
+
ids: cartItems.map(function (n) {
|
|
337
|
+
return n.id;
|
|
338
|
+
}),
|
|
339
|
+
schedule_date: date,
|
|
340
|
+
customer_id: customer_id
|
|
341
|
+
});
|
|
342
|
+
case 7:
|
|
343
|
+
res = _context5.sent;
|
|
338
344
|
_iterator = _createForOfIteratorHelper(cartItems);
|
|
339
|
-
_context5.prev =
|
|
345
|
+
_context5.prev = 9;
|
|
340
346
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
341
347
|
var _bundle;
|
|
342
|
-
var item, targetProduct, productInfo, bundle;
|
|
348
|
+
var item, targetProduct, cartProduct, productInfo, bundle;
|
|
343
349
|
return _regeneratorRuntime().wrap(function _loop$(_context4) {
|
|
344
350
|
while (1) switch (_context4.prev = _context4.next) {
|
|
345
351
|
case 0:
|
|
346
352
|
item = _step.value;
|
|
347
|
-
|
|
353
|
+
targetProduct = res.find(function (n) {
|
|
354
|
+
return n.id === item.id;
|
|
355
|
+
});
|
|
356
|
+
_context4.next = 4;
|
|
348
357
|
return _this3.store.products.getProduct(item.id);
|
|
349
|
-
case
|
|
350
|
-
|
|
351
|
-
productInfo =
|
|
358
|
+
case 4:
|
|
359
|
+
cartProduct = _context4.sent;
|
|
360
|
+
productInfo = cartProduct === null || cartProduct === void 0 ? void 0 : cartProduct.getData();
|
|
352
361
|
bundle = item._bundleOrigin;
|
|
362
|
+
productInfo.price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.price;
|
|
363
|
+
productInfo.base_price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.base_price;
|
|
353
364
|
bundle = (_bundle = bundle) === null || _bundle === void 0 ? void 0 : _bundle.map(function (n) {
|
|
354
|
-
var
|
|
355
|
-
//
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return m.group_id === n.id;
|
|
365
|
+
var _targetProduct$bundle;
|
|
366
|
+
// 更新 bundle 的价格
|
|
367
|
+
var targetBundle = targetProduct === null || targetProduct === void 0 || (_targetProduct$bundle = targetProduct.bundle_group) === null || _targetProduct$bundle === void 0 ? void 0 : _targetProduct$bundle.find(function (m) {
|
|
368
|
+
return m.id === n.group_id;
|
|
359
369
|
});
|
|
360
370
|
if (targetBundle) {
|
|
361
|
-
var targetBundleItem = targetBundle.
|
|
371
|
+
var targetBundleItem = targetBundle.bundle_item.find(function (m) {
|
|
362
372
|
return m.id === n.id;
|
|
363
373
|
});
|
|
364
374
|
if (targetBundleItem) {
|
|
@@ -375,40 +385,40 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
375
385
|
product: productInfo,
|
|
376
386
|
bundle: bundle
|
|
377
387
|
});
|
|
378
|
-
case
|
|
388
|
+
case 11:
|
|
379
389
|
case "end":
|
|
380
390
|
return _context4.stop();
|
|
381
391
|
}
|
|
382
392
|
}, _loop);
|
|
383
393
|
});
|
|
384
394
|
_iterator.s();
|
|
385
|
-
case
|
|
395
|
+
case 12:
|
|
386
396
|
if ((_step = _iterator.n()).done) {
|
|
387
|
-
_context5.next =
|
|
397
|
+
_context5.next = 16;
|
|
388
398
|
break;
|
|
389
399
|
}
|
|
390
|
-
return _context5.delegateYield(_loop(), "t0",
|
|
391
|
-
case
|
|
392
|
-
_context5.next =
|
|
400
|
+
return _context5.delegateYield(_loop(), "t0", 14);
|
|
401
|
+
case 14:
|
|
402
|
+
_context5.next = 12;
|
|
393
403
|
break;
|
|
394
|
-
case
|
|
395
|
-
_context5.next =
|
|
404
|
+
case 16:
|
|
405
|
+
_context5.next = 21;
|
|
396
406
|
break;
|
|
397
|
-
case
|
|
398
|
-
_context5.prev =
|
|
399
|
-
_context5.t1 = _context5["catch"](
|
|
407
|
+
case 18:
|
|
408
|
+
_context5.prev = 18;
|
|
409
|
+
_context5.t1 = _context5["catch"](9);
|
|
400
410
|
_iterator.e(_context5.t1);
|
|
401
|
-
case
|
|
402
|
-
_context5.prev =
|
|
411
|
+
case 21:
|
|
412
|
+
_context5.prev = 21;
|
|
403
413
|
_iterator.f();
|
|
404
|
-
return _context5.finish(
|
|
405
|
-
case 23:
|
|
406
|
-
;
|
|
414
|
+
return _context5.finish(21);
|
|
407
415
|
case 24:
|
|
416
|
+
;
|
|
417
|
+
case 25:
|
|
408
418
|
case "end":
|
|
409
419
|
return _context5.stop();
|
|
410
420
|
}
|
|
411
|
-
}, _callee4, this, [[
|
|
421
|
+
}, _callee4, this, [[9, 18, 21, 24]]);
|
|
412
422
|
}));
|
|
413
423
|
function updateQuotationPriceAndCart(_x5) {
|
|
414
424
|
return _updateQuotationPriceAndCart.apply(this, arguments);
|
|
@@ -2265,9 +2275,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2265
2275
|
var _this$store$currentPr2;
|
|
2266
2276
|
var date = _ref12.date,
|
|
2267
2277
|
scheduleIds = _ref12.scheduleIds,
|
|
2268
|
-
resources = _ref12.resources
|
|
2278
|
+
resources = _ref12.resources,
|
|
2279
|
+
product = _ref12.product;
|
|
2269
2280
|
var targetProduct = this.store.currentProduct;
|
|
2270
|
-
|
|
2281
|
+
// 如果外面传递了product 优先用外面的
|
|
2282
|
+
var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
|
|
2271
2283
|
var targetSchedules = [];
|
|
2272
2284
|
// 如果外面传递了 scheduleIds,优先取入参
|
|
2273
2285
|
if (scheduleIds !== null && scheduleIds !== void 0 && scheduleIds.length) {
|
|
@@ -7,9 +7,16 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
7
7
|
protected defaultName: string;
|
|
8
8
|
protected defaultVersion: string;
|
|
9
9
|
private store;
|
|
10
|
+
private request;
|
|
10
11
|
constructor(name?: string, version?: string);
|
|
11
12
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
12
13
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
14
|
+
loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
|
|
15
|
+
ids?: number[];
|
|
16
|
+
customer_id?: number;
|
|
17
|
+
schedule_date?: string;
|
|
18
|
+
channel?: string;
|
|
19
|
+
}): Promise<any>;
|
|
13
20
|
getProducts(): Promise<ProductData[]>;
|
|
14
21
|
getProduct(id: number): Promise<Product | undefined>;
|
|
15
22
|
addProduct(products: ProductData[]): Promise<void>;
|
|
@@ -47,6 +47,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
47
47
|
this.store.productMap = /* @__PURE__ */ new Map();
|
|
48
48
|
this.store.selectProducts = [];
|
|
49
49
|
}
|
|
50
|
+
this.request = core.getPlugin("request");
|
|
50
51
|
}
|
|
51
52
|
async storeChange(path, value) {
|
|
52
53
|
var _a;
|
|
@@ -63,6 +64,24 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
66
|
}
|
|
67
|
+
async loadProductsPrice({
|
|
68
|
+
ids = [],
|
|
69
|
+
customer_id,
|
|
70
|
+
schedule_date,
|
|
71
|
+
channel
|
|
72
|
+
}) {
|
|
73
|
+
const productsData = await this.request.post(
|
|
74
|
+
`/product/query/price`,
|
|
75
|
+
{
|
|
76
|
+
ids,
|
|
77
|
+
customer_id,
|
|
78
|
+
schedule_date,
|
|
79
|
+
channel
|
|
80
|
+
},
|
|
81
|
+
{ useCache: true }
|
|
82
|
+
);
|
|
83
|
+
return productsData.data;
|
|
84
|
+
}
|
|
66
85
|
async getProducts() {
|
|
67
86
|
await this.core.effects.emit(
|
|
68
87
|
import_types.ProductListHooks.onGetProducts,
|
|
@@ -186,10 +186,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
186
186
|
private getScheduleDataByIds;
|
|
187
187
|
openProductDetail(productId: number): Promise<void>;
|
|
188
188
|
closeProductDetail(): void;
|
|
189
|
-
getTimeslotBySchedule({ date, scheduleIds, resources, }: {
|
|
189
|
+
getTimeslotBySchedule({ date, scheduleIds, resources, product }: {
|
|
190
190
|
date: string;
|
|
191
191
|
scheduleIds?: number[];
|
|
192
192
|
resources?: ProductResourceItem[];
|
|
193
|
+
product?: ProductData;
|
|
193
194
|
}): {
|
|
194
195
|
start_time: string;
|
|
195
196
|
end_time: string;
|
|
@@ -171,12 +171,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
let userPlugin = this.core.getPlugin("user");
|
|
174
|
-
let customer_id =
|
|
174
|
+
let customer_id = void 0;
|
|
175
|
+
try {
|
|
176
|
+
customer_id = (_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.error(error);
|
|
179
|
+
}
|
|
175
180
|
const productsData = await this.request.post(
|
|
176
181
|
`/product/query`,
|
|
177
182
|
{
|
|
178
183
|
open_quotation: 1,
|
|
179
|
-
open_bundle:
|
|
184
|
+
open_bundle: 0,
|
|
180
185
|
extension_type: [
|
|
181
186
|
"product_appointment",
|
|
182
187
|
"appointment_ticket",
|
|
@@ -220,28 +225,32 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
220
225
|
}
|
|
221
226
|
async updateQuotationPriceAndCart(date) {
|
|
222
227
|
var _a;
|
|
223
|
-
const dateRange = this.store.date.getDateRange();
|
|
224
|
-
let scheduleIds = [];
|
|
225
|
-
if (dateRange.length) {
|
|
226
|
-
const scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
|
|
227
|
-
scheduleIds = scheduleList.filter((n) => n.date === dateRange[0].date).flatMap((n) => n.schedule_id);
|
|
228
|
-
}
|
|
229
|
-
await this.loadProducts({
|
|
230
|
-
...(_a = this.otherParams) == null ? void 0 : _a.productModuleParams,
|
|
231
|
-
scheduleIds,
|
|
232
|
-
schedule_date: date
|
|
233
|
-
});
|
|
234
228
|
const cartItems = this.store.cart.getItems();
|
|
235
229
|
if (cartItems.length) {
|
|
230
|
+
let userPlugin = this.core.getPlugin("user");
|
|
231
|
+
let customer_id = void 0;
|
|
232
|
+
try {
|
|
233
|
+
customer_id = (_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id;
|
|
234
|
+
} catch (error) {
|
|
235
|
+
console.error(error);
|
|
236
|
+
}
|
|
237
|
+
const res = await this.store.products.loadProductsPrice({
|
|
238
|
+
ids: cartItems.map((n) => n.id),
|
|
239
|
+
schedule_date: date,
|
|
240
|
+
customer_id
|
|
241
|
+
});
|
|
236
242
|
for (const item of cartItems) {
|
|
237
|
-
const targetProduct =
|
|
238
|
-
const
|
|
243
|
+
const targetProduct = res.find((n) => n.id === item.id);
|
|
244
|
+
const cartProduct = await this.store.products.getProduct(item.id);
|
|
245
|
+
const productInfo = cartProduct == null ? void 0 : cartProduct.getData();
|
|
239
246
|
let bundle = item._bundleOrigin;
|
|
247
|
+
productInfo.price = targetProduct == null ? void 0 : targetProduct.price;
|
|
248
|
+
productInfo.base_price = targetProduct == null ? void 0 : targetProduct.base_price;
|
|
240
249
|
bundle = bundle == null ? void 0 : bundle.map((n) => {
|
|
241
250
|
var _a2;
|
|
242
|
-
const targetBundle = (_a2 =
|
|
251
|
+
const targetBundle = (_a2 = targetProduct == null ? void 0 : targetProduct.bundle_group) == null ? void 0 : _a2.find((m) => m.id === n.group_id);
|
|
243
252
|
if (targetBundle) {
|
|
244
|
-
const targetBundleItem = targetBundle.
|
|
253
|
+
const targetBundleItem = targetBundle.bundle_item.find((m) => m.id === n.id);
|
|
245
254
|
if (targetBundleItem) {
|
|
246
255
|
return {
|
|
247
256
|
...n,
|
|
@@ -1525,11 +1534,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1525
1534
|
getTimeslotBySchedule({
|
|
1526
1535
|
date,
|
|
1527
1536
|
scheduleIds,
|
|
1528
|
-
resources
|
|
1537
|
+
resources,
|
|
1538
|
+
product
|
|
1529
1539
|
}) {
|
|
1530
1540
|
var _a, _b, _c;
|
|
1531
1541
|
const targetProduct = this.store.currentProduct;
|
|
1532
|
-
const targetProductData = targetProduct == null ? void 0 : targetProduct.getData();
|
|
1542
|
+
const targetProductData = product || (targetProduct == null ? void 0 : targetProduct.getData());
|
|
1533
1543
|
let targetSchedules = [];
|
|
1534
1544
|
if (scheduleIds == null ? void 0 : scheduleIds.length) {
|
|
1535
1545
|
targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|