@pisell/pisellos 0.0.140 → 0.0.142

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.
Files changed (39) hide show
  1. package/dist/modules/Cart/index.d.ts +14 -0
  2. package/dist/modules/Cart/index.js +36 -0
  3. package/dist/modules/Cart/utils/changePrice.d.ts +3 -0
  4. package/dist/modules/Cart/utils/changePrice.js +100 -0
  5. package/dist/modules/Date/index.js +57 -6
  6. package/dist/modules/ProductList/index.d.ts +7 -0
  7. package/dist/modules/ProductList/index.js +102 -39
  8. package/dist/modules/Schedule/index.d.ts +9 -1
  9. package/dist/modules/Schedule/index.js +121 -1
  10. package/dist/modules/Schedule/types.d.ts +13 -0
  11. package/dist/solution/BookingByStep/index.d.ts +120 -30
  12. package/dist/solution/BookingByStep/index.js +739 -1097
  13. package/dist/solution/BookingByStep/utils/capacity.d.ts +47 -0
  14. package/dist/solution/BookingByStep/utils/capacity.js +132 -0
  15. package/dist/solution/BookingByStep/utils/resources.d.ts +21 -29
  16. package/dist/solution/BookingByStep/utils/resources.js +39 -95
  17. package/dist/solution/BookingByStep/utils/timeslots.d.ts +11 -0
  18. package/dist/solution/BookingByStep/utils/timeslots.js +15 -0
  19. package/dist/solution/ShopDiscount/index.js +1 -1
  20. package/lib/modules/Cart/index.d.ts +14 -0
  21. package/lib/modules/Cart/index.js +32 -0
  22. package/lib/modules/Cart/utils/changePrice.d.ts +3 -0
  23. package/lib/modules/Cart/utils/changePrice.js +64 -0
  24. package/lib/modules/Date/index.js +62 -10
  25. package/lib/modules/ProductList/index.d.ts +7 -0
  26. package/lib/modules/ProductList/index.js +45 -0
  27. package/lib/modules/Schedule/index.d.ts +9 -1
  28. package/lib/modules/Schedule/index.js +78 -0
  29. package/lib/modules/Schedule/types.d.ts +13 -0
  30. package/lib/solution/BookingByStep/index.d.ts +120 -30
  31. package/lib/solution/BookingByStep/index.js +361 -580
  32. package/lib/solution/BookingByStep/utils/capacity.d.ts +47 -0
  33. package/lib/solution/BookingByStep/utils/capacity.js +106 -0
  34. package/lib/solution/BookingByStep/utils/resources.d.ts +21 -29
  35. package/lib/solution/BookingByStep/utils/resources.js +21 -58
  36. package/lib/solution/BookingByStep/utils/timeslots.d.ts +11 -0
  37. package/lib/solution/BookingByStep/utils/timeslots.js +7 -0
  38. package/lib/solution/ShopDiscount/index.js +1 -1
  39. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
3
  import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
4
+ import { Account } from '../Account';
4
5
  export * from './types';
5
6
  /**
6
7
  * 购物车模块实现
@@ -67,4 +68,17 @@ export declare class CartModule extends BaseModule implements Module, CartModule
67
68
  clear(): void;
68
69
  storeChange(): void;
69
70
  checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
71
+ /**
72
+ * 基于rowkey 合并商品,目前只有普通商品需要合并
73
+ *
74
+ * @param {string} rowKey
75
+ * @param {number} quantity
76
+ * @return {*}
77
+ * @memberof CartModule
78
+ */
79
+ mergeCartItemByRowKey(params: {
80
+ rowKey?: string;
81
+ quantity?: number;
82
+ account?: Account;
83
+ }): boolean;
70
84
  }
@@ -1,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -25,6 +27,7 @@ import { BaseModule } from "../BaseModule";
25
27
  import { ECartItemCheckType, ECartItemInfoType } from "./types";
26
28
  import { createCartItemOrigin, deleteHolderFromCartItem, deleteRelationFormsFromCartItem, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDateToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatRelationFormsToCartItem, formatResourceToCartItem, getUniqueId, handleVariantProduct } from "./utils";
27
29
  import { cloneDeep } from 'lodash-es';
30
+ import { isNormalProduct } from "../Product/utils";
28
31
  export * from "./types";
29
32
 
30
33
  /**
@@ -482,6 +485,39 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
482
485
  }
483
486
  return result;
484
487
  }
488
+
489
+ /**
490
+ * 基于rowkey 合并商品,目前只有普通商品需要合并
491
+ *
492
+ * @param {string} rowKey
493
+ * @param {number} quantity
494
+ * @return {*}
495
+ * @memberof CartModule
496
+ */
497
+ }, {
498
+ key: "mergeCartItemByRowKey",
499
+ value: function mergeCartItemByRowKey(params) {
500
+ var rowKey = params.rowKey,
501
+ quantity = params.quantity,
502
+ account = params.account;
503
+ var flag = false;
504
+ var cartItems = this.getItems();
505
+ var targetCartItem = cartItems.find(function (n) {
506
+ var _n$_productOrigin;
507
+ return ((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.rowKey) === rowKey;
508
+ });
509
+ var isSameAccount = (account === null || account === void 0 ? void 0 : account.id) === (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id);
510
+ if (rowKey && targetCartItem && isNormalProduct(targetCartItem._productOrigin) && isSameAccount) {
511
+ this.updateItem({
512
+ _id: targetCartItem._id,
513
+ product: _objectSpread(_objectSpread({}, targetCartItem._productOrigin), {}, {
514
+ quantity: (targetCartItem.num || 1) + (quantity || 1)
515
+ })
516
+ });
517
+ flag = true;
518
+ }
519
+ return flag;
520
+ }
485
521
  }]);
486
522
  return CartModule;
487
523
  }(BaseModule);
@@ -0,0 +1,3 @@
1
+ import { Product } from "../../Product";
2
+ import { CartItem, IUpdateItemParams } from "../types";
3
+ export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<Product | undefined>, updateCart: (item: IUpdateItemParams) => void): Promise<void>;
@@ -0,0 +1,100 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
+ export function updateAllCartItemPrice(_x, _x2, _x3, _x4) {
14
+ return _updateAllCartItemPrice.apply(this, arguments);
15
+ }
16
+ function _updateAllCartItemPrice() {
17
+ _updateAllCartItemPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cartItems, priceData, getProduct, updateCart) {
18
+ var _iterator, _step, _loop;
19
+ return _regeneratorRuntime().wrap(function _callee$(_context2) {
20
+ while (1) switch (_context2.prev = _context2.next) {
21
+ case 0:
22
+ _iterator = _createForOfIteratorHelper(cartItems);
23
+ _context2.prev = 1;
24
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
25
+ var _bundle;
26
+ var item, targetProduct, cartProduct, productInfo, bundle;
27
+ return _regeneratorRuntime().wrap(function _loop$(_context) {
28
+ while (1) switch (_context.prev = _context.next) {
29
+ case 0:
30
+ item = _step.value;
31
+ targetProduct = priceData.find(function (n) {
32
+ return n.id === item.id;
33
+ });
34
+ _context.next = 4;
35
+ return getProduct(item.id);
36
+ case 4:
37
+ cartProduct = _context.sent;
38
+ productInfo = cartProduct === null || cartProduct === void 0 ? void 0 : cartProduct.getData();
39
+ bundle = item._bundleOrigin;
40
+ productInfo.price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.price;
41
+ productInfo.base_price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.base_price;
42
+ bundle = (_bundle = bundle) === null || _bundle === void 0 ? void 0 : _bundle.map(function (n) {
43
+ var _targetProduct$bundle;
44
+ // 更新 bundle 的价格
45
+ var targetBundle = targetProduct === null || targetProduct === void 0 || (_targetProduct$bundle = targetProduct.bundle_group) === null || _targetProduct$bundle === void 0 ? void 0 : _targetProduct$bundle.find(function (m) {
46
+ return m.id === n.group_id;
47
+ });
48
+ if (targetBundle) {
49
+ var targetBundleItem = targetBundle.bundle_item.find(function (m) {
50
+ return m.id === n.id;
51
+ });
52
+ if (targetBundleItem) {
53
+ return _objectSpread(_objectSpread({}, n), {}, {
54
+ price: targetBundleItem.price,
55
+ base_price: targetBundleItem.base_price
56
+ });
57
+ }
58
+ }
59
+ return n;
60
+ });
61
+ updateCart({
62
+ _id: item._id,
63
+ product: productInfo,
64
+ bundle: bundle
65
+ });
66
+ case 11:
67
+ case "end":
68
+ return _context.stop();
69
+ }
70
+ }, _loop);
71
+ });
72
+ _iterator.s();
73
+ case 4:
74
+ if ((_step = _iterator.n()).done) {
75
+ _context2.next = 8;
76
+ break;
77
+ }
78
+ return _context2.delegateYield(_loop(), "t0", 6);
79
+ case 6:
80
+ _context2.next = 4;
81
+ break;
82
+ case 8:
83
+ _context2.next = 13;
84
+ break;
85
+ case 10:
86
+ _context2.prev = 10;
87
+ _context2.t1 = _context2["catch"](1);
88
+ _iterator.e(_context2.t1);
89
+ case 13:
90
+ _context2.prev = 13;
91
+ _iterator.f();
92
+ return _context2.finish(13);
93
+ case 16:
94
+ case "end":
95
+ return _context2.stop();
96
+ }
97
+ }, _callee, null, [[1, 10, 13, 16]]);
98
+ }));
99
+ return _updateAllCartItemPrice.apply(this, arguments);
100
+ }
@@ -1,4 +1,10 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
2
8
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -17,6 +23,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
17
23
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
24
  import { BaseModule } from "../BaseModule";
19
25
  import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
26
+ import cloneDeep from 'lodash-es/cloneDeep';
20
27
  export var DateModule = /*#__PURE__*/function (_BaseModule) {
21
28
  _inherits(DateModule, _BaseModule);
22
29
  var _super = _createSuper(DateModule);
@@ -86,17 +93,37 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
86
93
  key: "getResourceDates",
87
94
  value: function () {
88
95
  var _getResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
89
- var dates;
96
+ var _params$query;
97
+ var currentDateList, currentDateListMap, resourceIds, hasResource, dates;
90
98
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
91
99
  while (1) switch (_context2.prev = _context2.next) {
92
100
  case 0:
93
- _context2.next = 2;
101
+ // 发请求之前,做一道检测,看 dateList 里是否有对应日期,且对应日期里是否都有对应 resource_ids 的资源
102
+ currentDateList = this.getDateList() || [];
103
+ currentDateListMap = new Map(currentDateList.map(function (item) {
104
+ return [item.date, item];
105
+ }));
106
+ resourceIds = ((_params$query = params.query) === null || _params$query === void 0 ? void 0 : _params$query.resource_ids) || [];
107
+ hasResource = resourceIds.every(function (id) {
108
+ var _currentItem$resource;
109
+ var currentItem = currentDateListMap.get(id.toString());
110
+ return currentItem === null || currentItem === void 0 || (_currentItem$resource = currentItem.resource) === null || _currentItem$resource === void 0 ? void 0 : _currentItem$resource.some(function (n) {
111
+ return n.id === id;
112
+ });
113
+ });
114
+ if (!hasResource) {
115
+ _context2.next = 6;
116
+ break;
117
+ }
118
+ return _context2.abrupt("return", currentDateList);
119
+ case 6:
120
+ _context2.next = 8;
94
121
  return this.getResourceAvailableTimeList(params);
95
- case 2:
122
+ case 8:
96
123
  dates = _context2.sent;
97
- this.store.dateList = dates;
124
+ this.setDateList(dates);
98
125
  return _context2.abrupt("return", dates);
99
- case 5:
126
+ case 11:
100
127
  case "end":
101
128
  return _context2.stop();
102
129
  }
@@ -115,7 +142,31 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
115
142
  }, {
116
143
  key: "setDateList",
117
144
  value: function setDateList(dateList) {
118
- this.store.dateList = dateList;
145
+ // this.store.dateList = dateList;
146
+ // 并不能直接简单的进行复制
147
+ // 我们需要把每一天的资源都进行一个合并
148
+ var currentDateList = cloneDeep(this.store.dateList) || [];
149
+ dateList.forEach(function (item) {
150
+ var currentItemIndex = currentDateList.findIndex(function (n) {
151
+ return n.date === item.date;
152
+ });
153
+ if (currentItemIndex !== -1) {
154
+ var _item$resource;
155
+ var currentItem = currentDateList[currentItemIndex];
156
+ // 看那一天的数据有没有相同的,把不同的资源合并进去即可
157
+ var newResource = (_item$resource = item.resource) === null || _item$resource === void 0 ? void 0 : _item$resource.filter(function (n) {
158
+ var _currentItem$resource2;
159
+ return !((_currentItem$resource2 = currentItem.resource) !== null && _currentItem$resource2 !== void 0 && _currentItem$resource2.some(function (m) {
160
+ return m.id === n.id;
161
+ }));
162
+ });
163
+ currentItem.resource = [].concat(_toConsumableArray(currentItem.resource || []), _toConsumableArray(newResource || []));
164
+ currentDateList[currentItemIndex] = currentItem;
165
+ } else {
166
+ currentDateList.push(item);
167
+ }
168
+ });
169
+ this.store.dateList = currentDateList;
119
170
  }
120
171
  }, {
121
172
  key: "fetchResourceDates",
@@ -11,6 +11,13 @@ export declare class ProductList extends BaseModule implements Module {
11
11
  constructor(name?: string, version?: string);
12
12
  initialize(core: PisellCore, options: any): Promise<void>;
13
13
  storeChange(path?: string, value?: any): Promise<void>;
14
+ loadProducts({ category_ids, product_ids, collection, schedule_date, cacheId }: {
15
+ category_ids?: number[];
16
+ product_ids?: number[];
17
+ collection?: number | string[];
18
+ schedule_date?: string;
19
+ cacheId?: string;
20
+ }): Promise<any>;
14
21
  loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
15
22
  ids?: number[];
16
23
  customer_id?: number;
@@ -97,15 +97,78 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
97
97
  return storeChange;
98
98
  }()
99
99
  }, {
100
- key: "loadProductsPrice",
100
+ key: "loadProducts",
101
101
  value: function () {
102
- var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
103
- var _ref$ids, ids, customer_id, schedule_date, channel, productsData;
102
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
103
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, cacheId, userPlugin, customer_id, _userPlugin$get, productsData;
104
104
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
105
105
  while (1) switch (_context3.prev = _context3.next) {
106
106
  case 0:
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;
107
+ _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId;
108
+ // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
109
+ // if (!schedule_ids?.length) {
110
+ // const schedule_ids_data = this.store.schedule
111
+ // .getScheduleListByIds(schedule_ids)
112
+ // .map((n) => n.id);
113
+ // if (schedule_ids_data.length) {
114
+ // schedule_ids = schedule_ids_data;
115
+ // } else if (schedule_date) {
116
+ // // 后端说如果 schedule_ids 如果为空,需要给[0]
117
+ // schedule_ids = [0];
118
+ // }
119
+ // }
120
+ userPlugin = this.core.getPlugin('user');
121
+ customer_id = undefined;
122
+ try {
123
+ customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
124
+ } catch (error) {
125
+ console.error(error);
126
+ }
127
+ // 如果没传schedule_date,则从
128
+ _context3.next = 6;
129
+ return this.request.post("/product/query", {
130
+ open_quotation: 1,
131
+ open_bundle: 0,
132
+ exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
133
+ with: ['category', 'collection', 'resourceRelation'],
134
+ status: 'published',
135
+ num: 500,
136
+ skip: 1,
137
+ customer_id: customer_id,
138
+ category_ids: category_ids,
139
+ ids: product_ids,
140
+ collection: collection,
141
+ front_end_cache_id: cacheId,
142
+ // client_schedule_ids: schedule_ids,
143
+ schedule_date: schedule_date
144
+ }, {
145
+ useCache: true
146
+ });
147
+ case 6:
148
+ productsData = _context3.sent;
149
+ this.addProduct(productsData.data.list);
150
+ return _context3.abrupt("return", productsData.data.list);
151
+ case 9:
152
+ case "end":
153
+ return _context3.stop();
154
+ }
155
+ }, _callee3, this);
156
+ }));
157
+ function loadProducts(_x5) {
158
+ return _loadProducts.apply(this, arguments);
159
+ }
160
+ return loadProducts;
161
+ }()
162
+ }, {
163
+ key: "loadProductsPrice",
164
+ value: function () {
165
+ var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref2) {
166
+ var _ref2$ids, ids, customer_id, schedule_date, channel, productsData;
167
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
168
+ while (1) switch (_context4.prev = _context4.next) {
169
+ case 0:
170
+ _ref2$ids = _ref2.ids, ids = _ref2$ids === void 0 ? [] : _ref2$ids, customer_id = _ref2.customer_id, schedule_date = _ref2.schedule_date, channel = _ref2.channel;
171
+ _context4.next = 3;
109
172
  return this.request.post("/product/query/price", {
110
173
  ids: ids,
111
174
  customer_id: customer_id,
@@ -115,15 +178,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
115
178
  useCache: true
116
179
  });
117
180
  case 3:
118
- productsData = _context3.sent;
119
- return _context3.abrupt("return", productsData.data);
181
+ productsData = _context4.sent;
182
+ return _context4.abrupt("return", productsData.data);
120
183
  case 5:
121
184
  case "end":
122
- return _context3.stop();
185
+ return _context4.stop();
123
186
  }
124
- }, _callee3, this);
187
+ }, _callee4, this);
125
188
  }));
126
- function loadProductsPrice(_x5) {
189
+ function loadProductsPrice(_x6) {
127
190
  return _loadProductsPrice.apply(this, arguments);
128
191
  }
129
192
  return loadProductsPrice;
@@ -131,19 +194,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
131
194
  }, {
132
195
  key: "getProducts",
133
196
  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) {
197
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
198
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
199
+ while (1) switch (_context5.prev = _context5.next) {
137
200
  case 0:
138
- _context4.next = 2;
201
+ _context5.next = 2;
139
202
  return this.core.effects.emit(ProductListHooks.onGetProducts, this.store.list);
140
203
  case 2:
141
- return _context4.abrupt("return", cloneDeep(this.store.list));
204
+ return _context5.abrupt("return", cloneDeep(this.store.list));
142
205
  case 3:
143
206
  case "end":
144
- return _context4.stop();
207
+ return _context5.stop();
145
208
  }
146
- }, _callee4, this);
209
+ }, _callee5, this);
147
210
  }));
148
211
  function getProducts() {
149
212
  return _getProducts.apply(this, arguments);
@@ -153,29 +216,29 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
153
216
  }, {
154
217
  key: "getProduct",
155
218
  value: function () {
156
- var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
219
+ var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
157
220
  var product;
158
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
159
- while (1) switch (_context5.prev = _context5.next) {
221
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
222
+ while (1) switch (_context6.prev = _context6.next) {
160
223
  case 0:
161
- _context5.next = 2;
224
+ _context6.next = 2;
162
225
  return this.core.effects.emit(ProductListHooks.onGetProduct, this.store.list);
163
226
  case 2:
164
227
  product = this.store.productMap.get("".concat(id));
165
228
  if (!product) {
166
- _context5.next = 5;
229
+ _context6.next = 5;
167
230
  break;
168
231
  }
169
- return _context5.abrupt("return", product);
232
+ return _context6.abrupt("return", product);
170
233
  case 5:
171
- return _context5.abrupt("return", undefined);
234
+ return _context6.abrupt("return", undefined);
172
235
  case 6:
173
236
  case "end":
174
- return _context5.stop();
237
+ return _context6.stop();
175
238
  }
176
- }, _callee5, this);
239
+ }, _callee6, this);
177
240
  }));
178
- function getProduct(_x6) {
241
+ function getProduct(_x7) {
179
242
  return _getProduct.apply(this, arguments);
180
243
  }
181
244
  return getProduct;
@@ -183,10 +246,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
183
246
  }, {
184
247
  key: "addProduct",
185
248
  value: function () {
186
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(products) {
249
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(products) {
187
250
  var _this3 = this;
188
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
189
- while (1) switch (_context6.prev = _context6.next) {
251
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
252
+ while (1) switch (_context7.prev = _context7.next) {
190
253
  case 0:
191
254
  // 加到 list 以后上面的storeChange 会自动初始化商品详情的 module 实例
192
255
  // list 需要根据 id 去重
@@ -206,11 +269,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
206
269
  this.storeChange();
207
270
  case 3:
208
271
  case "end":
209
- return _context6.stop();
272
+ return _context7.stop();
210
273
  }
211
- }, _callee6, this);
274
+ }, _callee7, this);
212
275
  }));
213
- function addProduct(_x7) {
276
+ function addProduct(_x8) {
214
277
  return _addProduct.apply(this, arguments);
215
278
  }
216
279
  return addProduct;
@@ -218,18 +281,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
218
281
  }, {
219
282
  key: "selectProducts",
220
283
  value: function () {
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) {
284
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(products) {
285
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
286
+ while (1) switch (_context8.prev = _context8.next) {
224
287
  case 0:
225
288
  this.store.selectProducts = products;
226
289
  case 1:
227
290
  case "end":
228
- return _context7.stop();
291
+ return _context8.stop();
229
292
  }
230
- }, _callee7, this);
293
+ }, _callee8, this);
231
294
  }));
232
- function selectProducts(_x8) {
295
+ function selectProducts(_x9) {
233
296
  return _selectProducts.apply(this, arguments);
234
297
  }
235
298
  return selectProducts;
@@ -1,16 +1,24 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { ScheduleModuleAPI, ScheduleAvailabilityDateItem, ScheduleItem } from './types';
3
+ import { ScheduleModuleAPI, ScheduleAvailabilityDateItem, ScheduleItem, LoadScheduleAvailableDateParams } from './types';
4
4
  export declare class ScheduleModule extends BaseModule implements Module, ScheduleModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
7
+ private request;
7
8
  private store;
8
9
  private cacheId;
9
10
  private openCache;
10
11
  private fatherModule;
11
12
  constructor(name?: string, version?: string);
12
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
+ /**
15
+ * 加载当前店铺下所有 schedule
16
+ *
17
+ * @memberof ScheduleModule
18
+ */
19
+ loadAllSchedule(): Promise<void>;
13
20
  setScheduleList(list: ScheduleItem[]): void;
21
+ loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: LoadScheduleAvailableDateParams): Promise<import("../Date/types").ITime[]>;
14
22
  getScheduleListByIds(ids: number[]): ScheduleItem[];
15
23
  setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
16
24
  getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];