@pisell/pisellos 0.0.16 → 0.0.18
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/AccountList/index.js +37 -30
- package/dist/modules/Cart/index.d.ts +4 -0
- package/dist/modules/Cart/index.js +12 -0
- package/dist/modules/Cart/utils.js +14 -0
- package/dist/modules/Rules/index.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +111 -129
- package/lib/modules/AccountList/index.js +6 -5
- package/lib/modules/Cart/index.d.ts +4 -0
- package/lib/modules/Cart/index.js +7 -0
- package/lib/modules/Cart/utils.js +14 -0
- package/lib/modules/Rules/index.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +19 -2
- package/package.json +1 -1
|
@@ -63,6 +63,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
63
63
|
this.core = core;
|
|
64
64
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
65
65
|
this.store.accounts = [];
|
|
66
|
+
this.store.accountList = [];
|
|
66
67
|
if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.accountList)) {
|
|
67
68
|
recordList = options.initialState.accountList || [];
|
|
68
69
|
recordList.forEach(function (account) {
|
|
@@ -78,7 +79,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
78
79
|
if (options !== null && options !== void 0 && (_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
|
|
79
80
|
this.fatherModule = options.otherParams.fatherModule;
|
|
80
81
|
}
|
|
81
|
-
case
|
|
82
|
+
case 7:
|
|
82
83
|
case "end":
|
|
83
84
|
return _context.stop();
|
|
84
85
|
}
|
|
@@ -103,40 +104,40 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
103
104
|
if (!this.store.accounts.some(function (a) {
|
|
104
105
|
return a.getId() === account.id;
|
|
105
106
|
})) {
|
|
106
|
-
_context2.next =
|
|
107
|
+
_context2.next = 6;
|
|
107
108
|
break;
|
|
108
109
|
}
|
|
109
110
|
throw new Error("Account with id ".concat(account.id, " already exists"));
|
|
110
|
-
case
|
|
111
|
+
case 6:
|
|
111
112
|
this.store.accountList.push(account);
|
|
112
113
|
accountModule = new AccountModule("account_".concat(account.id));
|
|
113
114
|
this.core.registerModule(accountModule);
|
|
114
115
|
accountModule.setAccountInfo(account);
|
|
115
116
|
this.store.accounts = [].concat(_toConsumableArray(this.store.accounts), [accountModule]);
|
|
116
|
-
_context2.next =
|
|
117
|
+
_context2.next = 13;
|
|
117
118
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
118
|
-
case
|
|
119
|
+
case 13:
|
|
119
120
|
if (this.store.accounts.length === 1) {
|
|
120
121
|
this.setActiveAccount(accountModule.getId());
|
|
121
122
|
}
|
|
122
|
-
_context2.next =
|
|
123
|
+
_context2.next = 22;
|
|
123
124
|
break;
|
|
124
|
-
case
|
|
125
|
-
_context2.prev =
|
|
125
|
+
case 16:
|
|
126
|
+
_context2.prev = 16;
|
|
126
127
|
_context2.t0 = _context2["catch"](0);
|
|
127
128
|
console.error(_context2.t0);
|
|
128
129
|
this.store.error = _context2.t0 instanceof Error ? _context2.t0.message : 'Failed to add account';
|
|
129
|
-
_context2.next =
|
|
130
|
+
_context2.next = 22;
|
|
130
131
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
131
|
-
case
|
|
132
|
-
_context2.prev =
|
|
132
|
+
case 22:
|
|
133
|
+
_context2.prev = 22;
|
|
133
134
|
this.store.isLoading = false;
|
|
134
|
-
return _context2.finish(
|
|
135
|
-
case
|
|
135
|
+
return _context2.finish(22);
|
|
136
|
+
case 25:
|
|
136
137
|
case "end":
|
|
137
138
|
return _context2.stop();
|
|
138
139
|
}
|
|
139
|
-
}, _callee2, this, [[0,
|
|
140
|
+
}, _callee2, this, [[0, 16, 22, 25]]);
|
|
140
141
|
}));
|
|
141
142
|
function addAccount(_x3) {
|
|
142
143
|
return _addAccount.apply(this, arguments);
|
|
@@ -147,7 +148,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
147
148
|
key: "updateAccount",
|
|
148
149
|
value: function () {
|
|
149
150
|
var _updateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id, updates) {
|
|
150
|
-
var account;
|
|
151
|
+
var account, index;
|
|
151
152
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
152
153
|
while (1) switch (_context3.prev = _context3.next) {
|
|
153
154
|
case 0:
|
|
@@ -162,31 +163,37 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
162
163
|
throw new Error("Account with id ".concat(id, " not found"));
|
|
163
164
|
case 6:
|
|
164
165
|
account.setAccountInfo(updates);
|
|
165
|
-
this.store.accountList.forEach(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
// this.store.accountList.forEach(account => {
|
|
167
|
+
// if (account.id === id) {
|
|
168
|
+
// Object.assign(account, updates)
|
|
169
|
+
// }
|
|
170
|
+
// })
|
|
171
|
+
index = this.store.accountList.findIndex(function (account) {
|
|
172
|
+
return account.id === id;
|
|
169
173
|
});
|
|
170
|
-
|
|
174
|
+
if (index !== -1) {
|
|
175
|
+
this.store.accountList[index] = updates;
|
|
176
|
+
}
|
|
177
|
+
_context3.next = 11;
|
|
171
178
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
172
|
-
case
|
|
173
|
-
_context3.next =
|
|
179
|
+
case 11:
|
|
180
|
+
_context3.next = 18;
|
|
174
181
|
break;
|
|
175
|
-
case
|
|
176
|
-
_context3.prev =
|
|
182
|
+
case 13:
|
|
183
|
+
_context3.prev = 13;
|
|
177
184
|
_context3.t0 = _context3["catch"](0);
|
|
178
185
|
this.store.error = _context3.t0 instanceof Error ? _context3.t0.message : 'Failed to update account';
|
|
179
|
-
_context3.next =
|
|
186
|
+
_context3.next = 18;
|
|
180
187
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
181
|
-
case
|
|
182
|
-
_context3.prev =
|
|
188
|
+
case 18:
|
|
189
|
+
_context3.prev = 18;
|
|
183
190
|
this.store.isLoading = false;
|
|
184
|
-
return _context3.finish(
|
|
185
|
-
case
|
|
191
|
+
return _context3.finish(18);
|
|
192
|
+
case 21:
|
|
186
193
|
case "end":
|
|
187
194
|
return _context3.stop();
|
|
188
195
|
}
|
|
189
|
-
}, _callee3, this, [[0,
|
|
196
|
+
}, _callee3, this, [[0, 13, 18, 21]]);
|
|
190
197
|
}));
|
|
191
198
|
function updateAccount(_x4, _x5) {
|
|
192
199
|
return _updateAccount.apply(this, arguments);
|
|
@@ -63,6 +63,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
63
63
|
this.store = options.store;
|
|
64
64
|
if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
|
|
65
65
|
this.store.list = options.initialState.list;
|
|
66
|
+
this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
|
|
66
67
|
} else {
|
|
67
68
|
this.store.list = [];
|
|
68
69
|
}
|
|
@@ -284,6 +285,17 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
284
285
|
return this.store.list;
|
|
285
286
|
}
|
|
286
287
|
|
|
288
|
+
/**
|
|
289
|
+
* 获取购物车商品--通过购物车 id 获取单条
|
|
290
|
+
*/
|
|
291
|
+
}, {
|
|
292
|
+
key: "getItem",
|
|
293
|
+
value: function getItem(id) {
|
|
294
|
+
return this.store.list.find(function (item) {
|
|
295
|
+
return item._id === id;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
287
299
|
/**
|
|
288
300
|
* 根据账户ID获取购物车
|
|
289
301
|
*/
|
|
@@ -206,6 +206,13 @@ export var formatResourceToCartItem = function formatResourceToCartItem(params)
|
|
|
206
206
|
cartItem.end_date = dayjs(firstResource.endTime).format("YYYY-MM-DD");
|
|
207
207
|
cartItem.end_time = dayjs(firstResource.endTime).format("HH:mm");
|
|
208
208
|
}
|
|
209
|
+
} else {
|
|
210
|
+
cartItem.resource_id = undefined;
|
|
211
|
+
cartItem.relation_form_name = undefined;
|
|
212
|
+
cartItem.start_date = undefined;
|
|
213
|
+
cartItem.start_time = undefined;
|
|
214
|
+
cartItem.end_date = undefined;
|
|
215
|
+
cartItem.end_time = undefined;
|
|
209
216
|
}
|
|
210
217
|
var oringin = formatResourceToCartItemOrigin(params);
|
|
211
218
|
cartItem._origin = oringin;
|
|
@@ -241,6 +248,13 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
|
|
|
241
248
|
origin.end_date = dayjs(endTime).format("YYYY-MM-DD");
|
|
242
249
|
origin.end_time = dayjs(endTime).format("HH:mm");
|
|
243
250
|
}
|
|
251
|
+
} else if ((resources === null || resources === void 0 ? void 0 : resources.length) === 0) {
|
|
252
|
+
origin.resources = [];
|
|
253
|
+
origin.select_date = null;
|
|
254
|
+
origin.start_date = null;
|
|
255
|
+
origin.start_time = null;
|
|
256
|
+
origin.end_date = null;
|
|
257
|
+
origin.end_time = null;
|
|
244
258
|
}
|
|
245
259
|
return origin;
|
|
246
260
|
};
|
|
@@ -208,7 +208,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
208
208
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
209
209
|
|
|
210
210
|
// 判断优惠券是否适用于该商品
|
|
211
|
-
if (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
|
|
211
|
+
if (!(product !== null && product !== void 0 && product.booking_id) && (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id))) {
|
|
212
212
|
var _discountApplicabilit;
|
|
213
213
|
// 记录此优惠券适用的商品
|
|
214
214
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -40,7 +40,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
40
40
|
setDateRange(dateRange: ITime[]): Promise<void>;
|
|
41
41
|
clearDateRange(): void;
|
|
42
42
|
getDateRange(): Promise<ITime[]>;
|
|
43
|
-
getCart():
|
|
43
|
+
getCart(): CartItem[];
|
|
44
44
|
getAvailableDate(params?: {
|
|
45
45
|
products?: ProductData[];
|
|
46
46
|
startDate?: string;
|
|
@@ -81,39 +81,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
81
81
|
if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.cacheId) {
|
|
82
82
|
sessionData = this.window.sessionStorage.getItem(this.name);
|
|
83
83
|
if (sessionData) {
|
|
84
|
-
data = JSON.parse(sessionData); // sessionData
|
|
85
|
-
// {
|
|
86
|
-
// "123123123": {
|
|
87
|
-
// "step": {
|
|
88
|
-
// stepList: [],
|
|
89
|
-
// currentStep: {},
|
|
90
|
-
// currentStepIndex: 0
|
|
91
|
-
// }
|
|
92
|
-
// "cart": {
|
|
93
|
-
// "list": []
|
|
94
|
-
// },
|
|
95
|
-
// "accountList": {
|
|
96
|
-
// "accounts": []
|
|
97
|
-
// },
|
|
98
|
-
// "date": {
|
|
99
|
-
// "dateList": [],
|
|
100
|
-
// "dateRange": []
|
|
101
|
-
// },
|
|
102
|
-
// "summary": {
|
|
103
|
-
// "subtotal": 1,
|
|
104
|
-
// "total": 1,
|
|
105
|
-
// "taxTitle": 1;
|
|
106
|
-
// "totalTaxFee": 1
|
|
107
|
-
// "isPriceIncludeTax": 1
|
|
108
|
-
// }
|
|
109
|
-
// }
|
|
110
|
-
// }
|
|
111
|
-
// 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
|
|
84
|
+
data = JSON.parse(sessionData); // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
|
|
112
85
|
// 如果匹配到了,则把 sessionData 里的数据按模块塞到 store 里去
|
|
113
86
|
targetCacheData = data[this.otherParams.cacheId];
|
|
114
87
|
}
|
|
115
88
|
}
|
|
116
|
-
moduleArr = ["cart", "summary", "step", "products", "date", "
|
|
89
|
+
moduleArr = ["accountList", "cart", "summary", "step", "products", "date", "order", "payment"];
|
|
117
90
|
moduleArr.forEach(function (step) {
|
|
118
91
|
var targetModule = createModule(step, _this2.name);
|
|
119
92
|
if (targetModule) {
|
|
@@ -385,27 +358,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
385
358
|
}()
|
|
386
359
|
}, {
|
|
387
360
|
key: "getCart",
|
|
388
|
-
value: function () {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return _context8.abrupt("return", this.store.cart.getItems());
|
|
394
|
-
case 1:
|
|
395
|
-
case "end":
|
|
396
|
-
return _context8.stop();
|
|
397
|
-
}
|
|
398
|
-
}, _callee8, this);
|
|
399
|
-
}));
|
|
400
|
-
function getCart() {
|
|
401
|
-
return _getCart.apply(this, arguments);
|
|
402
|
-
}
|
|
403
|
-
return getCart;
|
|
404
|
-
}() // 获取商品/服务的可用日期
|
|
361
|
+
value: function getCart() {
|
|
362
|
+
return this.store.cart.getItems();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// 获取商品/服务的可用日期
|
|
405
366
|
}, {
|
|
406
367
|
key: "getAvailableDate",
|
|
407
368
|
value: function () {
|
|
408
|
-
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
369
|
+
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
409
370
|
var _this$otherParams2, _this$otherParams3;
|
|
410
371
|
var params,
|
|
411
372
|
products,
|
|
@@ -419,11 +380,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
419
380
|
rules,
|
|
420
381
|
resourcesMap,
|
|
421
382
|
res,
|
|
422
|
-
|
|
423
|
-
return _regeneratorRuntime().wrap(function
|
|
424
|
-
while (1) switch (
|
|
383
|
+
_args8 = arguments;
|
|
384
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
385
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
425
386
|
case 0:
|
|
426
|
-
params =
|
|
387
|
+
params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
|
|
427
388
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
428
389
|
products = params.products, startDate = params.startDate, endDate = params.endDate;
|
|
429
390
|
tempProducts = products || this.store.cart.getItems().map(function (p) {
|
|
@@ -432,16 +393,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
432
393
|
tempStartDate = startDate || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 || (_this$otherParams2 = _this$otherParams2.dateRange) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2[0]);
|
|
433
394
|
tempEndDate = endDate || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 || (_this$otherParams3 = _this$otherParams3.dateRange) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3[1]);
|
|
434
395
|
if (tempProducts.length) {
|
|
435
|
-
|
|
396
|
+
_context8.next = 7;
|
|
436
397
|
break;
|
|
437
398
|
}
|
|
438
|
-
return
|
|
399
|
+
return _context8.abrupt("return", []);
|
|
439
400
|
case 7:
|
|
440
401
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
441
402
|
_ref3 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref3.resourceIds, rules = _ref3.rules, resourcesMap = _ref3.resourcesMap;
|
|
442
403
|
console.log("resourceIds", tempProducts);
|
|
443
404
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
444
|
-
|
|
405
|
+
_context8.next = 12;
|
|
445
406
|
return this.store.date.getMonthDates({
|
|
446
407
|
query: {
|
|
447
408
|
start_date: tempStartDate,
|
|
@@ -451,13 +412,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
451
412
|
rules: rules
|
|
452
413
|
});
|
|
453
414
|
case 12:
|
|
454
|
-
res =
|
|
455
|
-
return
|
|
415
|
+
res = _context8.sent;
|
|
416
|
+
return _context8.abrupt("return", res);
|
|
456
417
|
case 14:
|
|
457
418
|
case "end":
|
|
458
|
-
return
|
|
419
|
+
return _context8.stop();
|
|
459
420
|
}
|
|
460
|
-
},
|
|
421
|
+
}, _callee8, this);
|
|
461
422
|
}));
|
|
462
423
|
function getAvailableDate() {
|
|
463
424
|
return _getAvailableDate.apply(this, arguments);
|
|
@@ -470,22 +431,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
470
431
|
}, {
|
|
471
432
|
key: "getSummary",
|
|
472
433
|
value: (function () {
|
|
473
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
434
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
474
435
|
var cartItems, summary;
|
|
475
|
-
return _regeneratorRuntime().wrap(function
|
|
476
|
-
while (1) switch (
|
|
436
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
437
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
477
438
|
case 0:
|
|
478
439
|
cartItems = this.store.cart.getItems();
|
|
479
|
-
|
|
440
|
+
_context9.next = 3;
|
|
480
441
|
return this.store.summary.getSummary(cartItems);
|
|
481
442
|
case 3:
|
|
482
|
-
summary =
|
|
483
|
-
return
|
|
443
|
+
summary = _context9.sent;
|
|
444
|
+
return _context9.abrupt("return", summary);
|
|
484
445
|
case 5:
|
|
485
446
|
case "end":
|
|
486
|
-
return
|
|
447
|
+
return _context9.stop();
|
|
487
448
|
}
|
|
488
|
-
},
|
|
449
|
+
}, _callee9, this);
|
|
489
450
|
}));
|
|
490
451
|
function getSummary() {
|
|
491
452
|
return _getSummary.apply(this, arguments);
|
|
@@ -496,16 +457,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
496
457
|
}, {
|
|
497
458
|
key: "getProducts",
|
|
498
459
|
value: function () {
|
|
499
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
500
|
-
return _regeneratorRuntime().wrap(function
|
|
501
|
-
while (1) switch (
|
|
460
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
461
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
462
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
502
463
|
case 0:
|
|
503
|
-
return
|
|
464
|
+
return _context10.abrupt("return", this.store.products.getProducts());
|
|
504
465
|
case 1:
|
|
505
466
|
case "end":
|
|
506
|
-
return
|
|
467
|
+
return _context10.stop();
|
|
507
468
|
}
|
|
508
|
-
},
|
|
469
|
+
}, _callee10, this);
|
|
509
470
|
}));
|
|
510
471
|
function getProducts() {
|
|
511
472
|
return _getProducts.apply(this, arguments);
|
|
@@ -515,15 +476,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
515
476
|
}, {
|
|
516
477
|
key: "setLoginAccount",
|
|
517
478
|
value: function () {
|
|
518
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
479
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(accountId, accountInfo) {
|
|
519
480
|
var _this4 = this;
|
|
520
481
|
var account, cartItems;
|
|
521
|
-
return _regeneratorRuntime().wrap(function
|
|
522
|
-
while (1) switch (
|
|
482
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
483
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
523
484
|
case 0:
|
|
524
485
|
account = this.store.accountList.getAccount(accountId);
|
|
525
486
|
if (!account) {
|
|
526
|
-
|
|
487
|
+
_context11.next = 7;
|
|
527
488
|
break;
|
|
528
489
|
}
|
|
529
490
|
account.setAccountInfo(accountInfo);
|
|
@@ -537,15 +498,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
537
498
|
});
|
|
538
499
|
}
|
|
539
500
|
});
|
|
540
|
-
|
|
501
|
+
_context11.next = 8;
|
|
541
502
|
break;
|
|
542
503
|
case 7:
|
|
543
504
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
544
505
|
case 8:
|
|
545
506
|
case "end":
|
|
546
|
-
return
|
|
507
|
+
return _context11.stop();
|
|
547
508
|
}
|
|
548
|
-
},
|
|
509
|
+
}, _callee11, this);
|
|
549
510
|
}));
|
|
550
511
|
function setLoginAccount(_x7, _x8) {
|
|
551
512
|
return _setLoginAccount.apply(this, arguments);
|
|
@@ -555,14 +516,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
555
516
|
}, {
|
|
556
517
|
key: "generateCartData",
|
|
557
518
|
value: function () {
|
|
558
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
559
|
-
return _regeneratorRuntime().wrap(function
|
|
560
|
-
while (1) switch (
|
|
519
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
520
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
521
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
561
522
|
case 0:
|
|
562
523
|
case "end":
|
|
563
|
-
return
|
|
524
|
+
return _context12.stop();
|
|
564
525
|
}
|
|
565
|
-
},
|
|
526
|
+
}, _callee12);
|
|
566
527
|
}));
|
|
567
528
|
function generateCartData() {
|
|
568
529
|
return _generateCartData.apply(this, arguments);
|
|
@@ -572,10 +533,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
572
533
|
}, {
|
|
573
534
|
key: "submitOrder",
|
|
574
535
|
value: function () {
|
|
575
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
536
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
576
537
|
var cartItems;
|
|
577
|
-
return _regeneratorRuntime().wrap(function
|
|
578
|
-
while (1) switch (
|
|
538
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
539
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
579
540
|
case 0:
|
|
580
541
|
cartItems = this.store.cart.getItems(); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
581
542
|
cartItems.forEach(function (item) {
|
|
@@ -587,16 +548,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
587
548
|
return _objectSpread({}, newResourcesItem);
|
|
588
549
|
});
|
|
589
550
|
});
|
|
590
|
-
return
|
|
551
|
+
return _context13.abrupt("return", this.store.order.commitOrder({
|
|
591
552
|
query: {
|
|
592
553
|
cartItems: cartItems
|
|
593
554
|
}
|
|
594
555
|
}));
|
|
595
556
|
case 3:
|
|
596
557
|
case "end":
|
|
597
|
-
return
|
|
558
|
+
return _context13.stop();
|
|
598
559
|
}
|
|
599
|
-
},
|
|
560
|
+
}, _callee13, this);
|
|
600
561
|
}));
|
|
601
562
|
function submitOrder() {
|
|
602
563
|
return _submitOrder.apply(this, arguments);
|
|
@@ -606,14 +567,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
606
567
|
}, {
|
|
607
568
|
key: "pay",
|
|
608
569
|
value: function () {
|
|
609
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
610
|
-
return _regeneratorRuntime().wrap(function
|
|
611
|
-
while (1) switch (
|
|
570
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
571
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
572
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
612
573
|
case 0:
|
|
613
574
|
case "end":
|
|
614
|
-
return
|
|
575
|
+
return _context14.stop();
|
|
615
576
|
}
|
|
616
|
-
},
|
|
577
|
+
}, _callee14);
|
|
617
578
|
}));
|
|
618
579
|
function pay() {
|
|
619
580
|
return _pay.apply(this, arguments);
|
|
@@ -623,14 +584,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
623
584
|
}, {
|
|
624
585
|
key: "getPayInfo",
|
|
625
586
|
value: function () {
|
|
626
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
627
|
-
return _regeneratorRuntime().wrap(function
|
|
628
|
-
while (1) switch (
|
|
587
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
588
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
589
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
629
590
|
case 0:
|
|
630
591
|
case "end":
|
|
631
|
-
return
|
|
592
|
+
return _context15.stop();
|
|
632
593
|
}
|
|
633
|
-
},
|
|
594
|
+
}, _callee15);
|
|
634
595
|
}));
|
|
635
596
|
function getPayInfo() {
|
|
636
597
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -640,15 +601,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
640
601
|
}, {
|
|
641
602
|
key: "setOtherParams",
|
|
642
603
|
value: function () {
|
|
643
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
604
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
644
605
|
var _ref4,
|
|
645
606
|
_ref4$cover,
|
|
646
607
|
cover,
|
|
647
|
-
|
|
648
|
-
return _regeneratorRuntime().wrap(function
|
|
649
|
-
while (1) switch (
|
|
608
|
+
_args16 = arguments;
|
|
609
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
610
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
650
611
|
case 0:
|
|
651
|
-
_ref4 =
|
|
612
|
+
_ref4 = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
|
|
652
613
|
if (cover) {
|
|
653
614
|
this.otherParams = params;
|
|
654
615
|
} else {
|
|
@@ -656,9 +617,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
656
617
|
}
|
|
657
618
|
case 2:
|
|
658
619
|
case "end":
|
|
659
|
-
return
|
|
620
|
+
return _context16.stop();
|
|
660
621
|
}
|
|
661
|
-
},
|
|
622
|
+
}, _callee16, this);
|
|
662
623
|
}));
|
|
663
624
|
function setOtherParams(_x9) {
|
|
664
625
|
return _setOtherParams.apply(this, arguments);
|
|
@@ -668,16 +629,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
668
629
|
}, {
|
|
669
630
|
key: "getOtherParams",
|
|
670
631
|
value: function () {
|
|
671
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
672
|
-
return _regeneratorRuntime().wrap(function
|
|
673
|
-
while (1) switch (
|
|
632
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
633
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
634
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
674
635
|
case 0:
|
|
675
|
-
return
|
|
636
|
+
return _context17.abrupt("return", this.otherParams);
|
|
676
637
|
case 1:
|
|
677
638
|
case "end":
|
|
678
|
-
return
|
|
639
|
+
return _context17.stop();
|
|
679
640
|
}
|
|
680
|
-
},
|
|
641
|
+
}, _callee17, this);
|
|
681
642
|
}));
|
|
682
643
|
function getOtherParams() {
|
|
683
644
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -687,7 +648,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
687
648
|
}, {
|
|
688
649
|
key: "updateCart",
|
|
689
650
|
value: function updateCart(params) {
|
|
651
|
+
var _this5 = this;
|
|
690
652
|
this.store.cart.updateItem(params);
|
|
653
|
+
var targetCartItem = this.store.cart.getItem(params._id);
|
|
654
|
+
if (!targetCartItem) {
|
|
655
|
+
throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
656
|
+
}
|
|
657
|
+
// 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,则要把选择了相同资源的 product._origin.resources 给去除
|
|
658
|
+
var cartItems = this.store.cart.getItems();
|
|
659
|
+
cartItems.forEach(function (item) {
|
|
660
|
+
if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
|
|
661
|
+
var _item$_origin$resourc;
|
|
662
|
+
var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
|
|
663
|
+
return !targetCartItem._origin.resources.some(function (targetRes) {
|
|
664
|
+
return targetRes.id === m.id;
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
_this5.store.cart.updateItem({
|
|
668
|
+
_id: item._id,
|
|
669
|
+
resources: resources
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
});
|
|
691
673
|
}
|
|
692
674
|
|
|
693
675
|
// 删除购物车里某个商品
|
|
@@ -717,10 +699,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
717
699
|
}, {
|
|
718
700
|
key: "batchUpdateCart",
|
|
719
701
|
value: function batchUpdateCart(paramsList) {
|
|
720
|
-
var
|
|
702
|
+
var _this6 = this;
|
|
721
703
|
var cartItems = [];
|
|
722
704
|
paramsList.forEach(function (params) {
|
|
723
|
-
var cartItem =
|
|
705
|
+
var cartItem = _this6.store.cart.formatCartItem(params);
|
|
724
706
|
cartItems.push(cartItem);
|
|
725
707
|
});
|
|
726
708
|
this.store.cart.batchSetItems(cartItems);
|
|
@@ -1003,7 +985,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1003
985
|
}, {
|
|
1004
986
|
key: "autoSelectAllProductResources",
|
|
1005
987
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1006
|
-
var
|
|
988
|
+
var _this7 = this;
|
|
1007
989
|
var dateRange = this.store.date.getDateRange();
|
|
1008
990
|
var resources = [];
|
|
1009
991
|
dateRange.forEach(function (n) {
|
|
@@ -1013,27 +995,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1013
995
|
// 一个账号一个账号处理
|
|
1014
996
|
var errorList = [];
|
|
1015
997
|
this.store.accountList.getAccounts().forEach(function (account) {
|
|
1016
|
-
var cartItems =
|
|
998
|
+
var cartItems = _this7.store.cart.getCartByAccount(account.getId());
|
|
1017
999
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1018
|
-
var allCartItems =
|
|
1000
|
+
var allCartItems = _this7.store.cart.getItems();
|
|
1019
1001
|
cartItems.forEach(function (item) {
|
|
1020
1002
|
if (timeSlots) {
|
|
1021
1003
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1022
|
-
var res =
|
|
1004
|
+
var res = _this7.autoSelectAccountResources({
|
|
1023
1005
|
holder_id: item.holder_id,
|
|
1024
1006
|
resources_code: resources_code,
|
|
1025
1007
|
timeSlots: timeSlots
|
|
1026
1008
|
});
|
|
1027
1009
|
if (res !== null && res !== void 0 && res.selectedResource) {
|
|
1028
|
-
console.log(
|
|
1029
|
-
|
|
1010
|
+
console.log(_this7.store.cart.getItems());
|
|
1011
|
+
_this7.store.cart.updateItem({
|
|
1030
1012
|
_id: item._id,
|
|
1031
1013
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
1032
1014
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1033
1015
|
return existingRes.form_id !== res.selectedResource.form_id;
|
|
1034
1016
|
})), [res.selectedResource])
|
|
1035
1017
|
});
|
|
1036
|
-
console.log(
|
|
1018
|
+
console.log(_this7.store.cart.getItems());
|
|
1037
1019
|
} else {
|
|
1038
1020
|
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
1039
1021
|
errorList.push(item._id);
|
|
@@ -1047,7 +1029,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1047
1029
|
return n.code === resources_code;
|
|
1048
1030
|
})) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
|
|
1049
1031
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1050
|
-
|
|
1032
|
+
_this7.store.cart.updateItem({
|
|
1051
1033
|
_id: item._id,
|
|
1052
1034
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1053
1035
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -1068,20 +1050,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1068
1050
|
}, {
|
|
1069
1051
|
key: "getTimeSlotByAllResources",
|
|
1070
1052
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1071
|
-
var
|
|
1053
|
+
var _this8 = this;
|
|
1072
1054
|
var dateRange = this.store.date.getDateRange();
|
|
1073
1055
|
// 取出购物车中所有一已选择的第一步资源
|
|
1074
1056
|
var resources = [];
|
|
1075
1057
|
var cartItems = this.store.cart.getItems();
|
|
1076
1058
|
var resourceIds = [];
|
|
1077
1059
|
cartItems.forEach(function (item) {
|
|
1078
|
-
var _item$_productOrigin2, _item$_origin$
|
|
1060
|
+
var _item$_productOrigin2, _item$_origin$resourc2;
|
|
1079
1061
|
(_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.product_resource) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.resources) === null || _item$_productOrigin2 === void 0 || _item$_productOrigin2.forEach(function (n) {
|
|
1080
1062
|
if (n.code === resources_code) {
|
|
1081
1063
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1082
1064
|
}
|
|
1083
1065
|
});
|
|
1084
|
-
(_item$_origin$
|
|
1066
|
+
(_item$_origin$resourc2 = item._origin.resources) === null || _item$_origin$resourc2 === void 0 || _item$_origin$resourc2.forEach(function (n) {
|
|
1085
1067
|
resourceIds.push(n.relation_id);
|
|
1086
1068
|
});
|
|
1087
1069
|
});
|
|
@@ -1090,7 +1072,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1090
1072
|
// duration = 不同账号的最长时间
|
|
1091
1073
|
this.store.accountList.getAccounts().forEach(function (account) {
|
|
1092
1074
|
var accountDuration = 0;
|
|
1093
|
-
var cartItems =
|
|
1075
|
+
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1094
1076
|
cartItems.forEach(function (item) {
|
|
1095
1077
|
var _item$_productOrigin$, _item$_productOrigin3;
|
|
1096
1078
|
accountDuration += (_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0;
|
|
@@ -1138,7 +1120,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1138
1120
|
}, {
|
|
1139
1121
|
key: "submitTimeSlot",
|
|
1140
1122
|
value: function submitTimeSlot(timeSlots) {
|
|
1141
|
-
var
|
|
1123
|
+
var _this9 = this;
|
|
1142
1124
|
var cartItems = this.store.cart.getItems();
|
|
1143
1125
|
cartItems.forEach(function (item) {
|
|
1144
1126
|
var newResources = cloneDeep(item._origin.resources);
|
|
@@ -1148,7 +1130,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1148
1130
|
n.endTime = dayjs(n.startTime).add((_item$_productOrigin$2 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref8 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.type) !== null && _ref8 !== void 0 ? _ref8 : "minutes").format("YYYY-MM-DD HH:mm");
|
|
1149
1131
|
delete n.times;
|
|
1150
1132
|
});
|
|
1151
|
-
|
|
1133
|
+
_this9.store.cart.updateItem({
|
|
1152
1134
|
_id: item._id,
|
|
1153
1135
|
resources: newResources
|
|
1154
1136
|
});
|
|
@@ -45,6 +45,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
45
45
|
this.core = core;
|
|
46
46
|
this.store = options == null ? void 0 : options.store;
|
|
47
47
|
this.store.accounts = [];
|
|
48
|
+
this.store.accountList = [];
|
|
48
49
|
if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.accountList)) {
|
|
49
50
|
const recordList = options.initialState.accountList || [];
|
|
50
51
|
recordList.forEach((account) => {
|
|
@@ -67,6 +68,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
67
68
|
this.store.error = null;
|
|
68
69
|
if (this.store.accounts.some((a) => a.getId() === account.id)) {
|
|
69
70
|
throw new Error(`Account with id ${account.id} already exists`);
|
|
71
|
+
return;
|
|
70
72
|
}
|
|
71
73
|
this.store.accountList.push(account);
|
|
72
74
|
const accountModule = new import_Account.AccountModule(`account_${account.id}`);
|
|
@@ -94,11 +96,10 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
94
96
|
throw new Error(`Account with id ${id} not found`);
|
|
95
97
|
}
|
|
96
98
|
account.setAccountInfo(updates);
|
|
97
|
-
this.store.accountList.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
99
|
+
const index = this.store.accountList.findIndex((account2) => account2.id === id);
|
|
100
|
+
if (index !== -1) {
|
|
101
|
+
this.store.accountList[index] = updates;
|
|
102
|
+
}
|
|
102
103
|
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
103
104
|
} catch (error) {
|
|
104
105
|
this.store.error = error instanceof Error ? error.message : "Failed to update account";
|
|
@@ -44,6 +44,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
44
44
|
this.store = options.store;
|
|
45
45
|
if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
|
|
46
46
|
this.store.list = options.initialState.list;
|
|
47
|
+
this.core.effects.emit(`${this.name}:changed`, this.store.list);
|
|
47
48
|
} else {
|
|
48
49
|
this.store.list = [];
|
|
49
50
|
}
|
|
@@ -144,6 +145,12 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
144
145
|
getItems() {
|
|
145
146
|
return this.store.list;
|
|
146
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* 获取购物车商品--通过购物车 id 获取单条
|
|
150
|
+
*/
|
|
151
|
+
getItem(id) {
|
|
152
|
+
return this.store.list.find((item) => item._id === id);
|
|
153
|
+
}
|
|
147
154
|
/**
|
|
148
155
|
* 根据账户ID获取购物车
|
|
149
156
|
*/
|
|
@@ -195,6 +195,13 @@ var formatResourceToCartItem = (params) => {
|
|
|
195
195
|
cartItem.end_date = (0, import_dayjs.default)(firstResource.endTime).format("YYYY-MM-DD");
|
|
196
196
|
cartItem.end_time = (0, import_dayjs.default)(firstResource.endTime).format("HH:mm");
|
|
197
197
|
}
|
|
198
|
+
} else {
|
|
199
|
+
cartItem.resource_id = void 0;
|
|
200
|
+
cartItem.relation_form_name = void 0;
|
|
201
|
+
cartItem.start_date = void 0;
|
|
202
|
+
cartItem.start_time = void 0;
|
|
203
|
+
cartItem.end_date = void 0;
|
|
204
|
+
cartItem.end_time = void 0;
|
|
198
205
|
}
|
|
199
206
|
const oringin = formatResourceToCartItemOrigin(params);
|
|
200
207
|
cartItem._origin = oringin;
|
|
@@ -226,6 +233,13 @@ var formatResourceToCartItemOrigin = (params) => {
|
|
|
226
233
|
origin.end_date = (0, import_dayjs.default)(endTime).format("YYYY-MM-DD");
|
|
227
234
|
origin.end_time = (0, import_dayjs.default)(endTime).format("HH:mm");
|
|
228
235
|
}
|
|
236
|
+
} else if ((resources == null ? void 0 : resources.length) === 0) {
|
|
237
|
+
origin.resources = [];
|
|
238
|
+
origin.select_date = null;
|
|
239
|
+
origin.start_date = null;
|
|
240
|
+
origin.start_time = null;
|
|
241
|
+
origin.end_date = null;
|
|
242
|
+
origin.end_time = null;
|
|
229
243
|
}
|
|
230
244
|
return origin;
|
|
231
245
|
};
|
|
@@ -132,7 +132,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
132
132
|
addModeDiscount.forEach((discount) => {
|
|
133
133
|
var _a;
|
|
134
134
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
135
|
-
if (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
|
|
135
|
+
if (!(product == null ? void 0 : product.booking_id) && (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id))) {
|
|
136
136
|
(_a = discountApplicability.get(discount.id)) == null ? void 0 : _a.push(product.id);
|
|
137
137
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
138
138
|
applicableProducts.push({
|
|
@@ -40,7 +40,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
40
40
|
setDateRange(dateRange: ITime[]): Promise<void>;
|
|
41
41
|
clearDateRange(): void;
|
|
42
42
|
getDateRange(): Promise<ITime[]>;
|
|
43
|
-
getCart():
|
|
43
|
+
getCart(): CartItem[];
|
|
44
44
|
getAvailableDate(params?: {
|
|
45
45
|
products?: ProductData[];
|
|
46
46
|
startDate?: string;
|
|
@@ -68,12 +68,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
const moduleArr = [
|
|
71
|
+
"accountList",
|
|
71
72
|
"cart",
|
|
72
73
|
"summary",
|
|
73
74
|
"step",
|
|
74
75
|
"products",
|
|
75
76
|
"date",
|
|
76
|
-
"accountList",
|
|
77
77
|
"order",
|
|
78
78
|
"payment"
|
|
79
79
|
];
|
|
@@ -195,7 +195,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
195
195
|
async getDateRange() {
|
|
196
196
|
return this.store.date.getDateRange();
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
getCart() {
|
|
199
199
|
return this.store.cart.getItems();
|
|
200
200
|
}
|
|
201
201
|
// 获取商品/服务的可用日期
|
|
@@ -287,6 +287,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
287
287
|
// 更新购物车
|
|
288
288
|
updateCart(params) {
|
|
289
289
|
this.store.cart.updateItem(params);
|
|
290
|
+
const targetCartItem = this.store.cart.getItem(params._id);
|
|
291
|
+
if (!targetCartItem) {
|
|
292
|
+
throw new Error(`没有找到${params._id}购物车商品`);
|
|
293
|
+
}
|
|
294
|
+
const cartItems = this.store.cart.getItems();
|
|
295
|
+
cartItems.forEach((item) => {
|
|
296
|
+
var _a;
|
|
297
|
+
if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
|
|
298
|
+
const resources = (_a = item._origin.resources) == null ? void 0 : _a.filter(
|
|
299
|
+
(m) => !targetCartItem._origin.resources.some((targetRes) => targetRes.id === m.id)
|
|
300
|
+
);
|
|
301
|
+
this.store.cart.updateItem({
|
|
302
|
+
_id: item._id,
|
|
303
|
+
resources
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
});
|
|
290
307
|
}
|
|
291
308
|
// 删除购物车里某个商品
|
|
292
309
|
deleteCart(cartItemId) {
|