@pisell/pisellos 1.0.0 → 1.0.2
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/Cart/index.d.ts +0 -14
- package/dist/modules/Cart/index.js +0 -36
- package/dist/modules/Cart/utils/cartProduct.js +1 -10
- package/dist/modules/Date/index.js +6 -57
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +7 -15
- package/dist/modules/Discount/types.d.ts +0 -10
- package/dist/modules/ProductList/index.d.ts +0 -7
- package/dist/modules/ProductList/index.js +39 -102
- package/dist/modules/Rules/index.js +71 -196
- package/dist/modules/Rules/types.d.ts +0 -6
- package/dist/modules/Schedule/index.d.ts +1 -9
- package/dist/modules/Schedule/index.js +2 -122
- package/dist/modules/Schedule/types.d.ts +0 -13
- package/dist/solution/BookingByStep/index.d.ts +30 -120
- package/dist/solution/BookingByStep/index.js +1065 -750
- package/dist/solution/BookingByStep/utils/resources.d.ts +31 -29
- package/dist/solution/BookingByStep/utils/resources.js +94 -39
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +0 -11
- package/dist/solution/BookingByStep/utils/timeslots.js +0 -15
- package/dist/solution/ShopDiscount/index.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +32 -93
- package/lib/modules/Cart/index.d.ts +0 -14
- package/lib/modules/Cart/index.js +0 -32
- package/lib/modules/Cart/utils/cartProduct.js +1 -1
- package/lib/modules/Date/index.js +10 -62
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +6 -18
- package/lib/modules/Discount/types.d.ts +0 -10
- package/lib/modules/ProductList/index.d.ts +0 -7
- package/lib/modules/ProductList/index.js +0 -45
- package/lib/modules/Rules/index.js +56 -147
- package/lib/modules/Rules/types.d.ts +0 -6
- package/lib/modules/Schedule/index.d.ts +1 -9
- package/lib/modules/Schedule/index.js +1 -79
- package/lib/modules/Schedule/types.d.ts +0 -13
- package/lib/solution/BookingByStep/index.d.ts +30 -120
- package/lib/solution/BookingByStep/index.js +581 -392
- package/lib/solution/BookingByStep/utils/resources.d.ts +31 -29
- package/lib/solution/BookingByStep/utils/resources.js +59 -23
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +0 -11
- package/lib/solution/BookingByStep/utils/timeslots.js +0 -7
- package/lib/solution/ShopDiscount/index.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +18 -85
- package/package.json +1 -1
- package/dist/modules/Cart/utils/changePrice.d.ts +0 -3
- package/dist/modules/Cart/utils/changePrice.js +0 -104
- package/dist/solution/BookingByStep/utils/capacity.d.ts +0 -47
- package/dist/solution/BookingByStep/utils/capacity.js +0 -132
- package/lib/modules/Cart/utils/changePrice.d.ts +0 -3
- package/lib/modules/Cart/utils/changePrice.js +0 -78
- package/lib/solution/BookingByStep/utils/capacity.d.ts +0 -47
- package/lib/solution/BookingByStep/utils/capacity.js +0 -106
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
5
4
|
export * from './types';
|
|
6
5
|
/**
|
|
7
6
|
* 购物车模块实现
|
|
@@ -68,17 +67,4 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
68
67
|
clear(): void;
|
|
69
68
|
storeChange(): void;
|
|
70
69
|
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;
|
|
84
70
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
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; }
|
|
4
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
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."); }
|
|
6
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); }
|
|
@@ -27,7 +25,6 @@ import { BaseModule } from "../BaseModule";
|
|
|
27
25
|
import { ECartItemCheckType, ECartItemInfoType } from "./types";
|
|
28
26
|
import { createCartItemOrigin, deleteHolderFromCartItem, deleteRelationFormsFromCartItem, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDateToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatRelationFormsToCartItem, formatResourceToCartItem, getUniqueId, handleVariantProduct } from "./utils";
|
|
29
27
|
import { cloneDeep } from 'lodash-es';
|
|
30
|
-
import { isNormalProduct } from "../Product/utils";
|
|
31
28
|
export * from "./types";
|
|
32
29
|
|
|
33
30
|
/**
|
|
@@ -485,39 +482,6 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
485
482
|
}
|
|
486
483
|
return result;
|
|
487
484
|
}
|
|
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
|
-
}
|
|
521
485
|
}]);
|
|
522
486
|
return CartModule;
|
|
523
487
|
}(BaseModule);
|
|
@@ -191,15 +191,6 @@ export var getProductOriginTotalPrice = function getProductOriginTotalPrice(para
|
|
|
191
191
|
options = params.options;
|
|
192
192
|
var num = (params === null || params === void 0 ? void 0 : params.num) || 1;
|
|
193
193
|
var price = Number(product.original_price);
|
|
194
|
-
|
|
195
|
-
// if (product.discount_list?.length) {
|
|
196
|
-
// price = product.discount_list.reduce((accumulator: any, currentValue: any) => {
|
|
197
|
-
// return (
|
|
198
|
-
// accumulator + Number(currentValue.price) * Number(currentValue.num)
|
|
199
|
-
// );
|
|
200
|
-
// }, price);
|
|
201
|
-
// }
|
|
202
|
-
|
|
203
194
|
if (isNaN(price) || price === 0) {
|
|
204
195
|
return undefined;
|
|
205
196
|
}
|
|
@@ -215,7 +206,7 @@ export var getProductOriginTotalPrice = function getProductOriginTotalPrice(para
|
|
|
215
206
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
216
207
|
}, price);
|
|
217
208
|
}
|
|
218
|
-
return price;
|
|
209
|
+
return price * num;
|
|
219
210
|
};
|
|
220
211
|
|
|
221
212
|
/**
|
|
@@ -1,10 +1,4 @@
|
|
|
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; }
|
|
8
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; }
|
|
9
3
|
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); } }
|
|
10
4
|
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); }); }; }
|
|
@@ -23,7 +17,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
23
17
|
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); }
|
|
24
18
|
import { BaseModule } from "../BaseModule";
|
|
25
19
|
import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
|
|
26
|
-
import cloneDeep from 'lodash-es/cloneDeep';
|
|
27
20
|
export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
28
21
|
_inherits(DateModule, _BaseModule);
|
|
29
22
|
var _super = _createSuper(DateModule);
|
|
@@ -93,37 +86,17 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
93
86
|
key: "getResourceDates",
|
|
94
87
|
value: function () {
|
|
95
88
|
var _getResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
96
|
-
var
|
|
97
|
-
var currentDateList, currentDateListMap, resourceIds, hasResource, dates;
|
|
89
|
+
var dates;
|
|
98
90
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
99
91
|
while (1) switch (_context2.prev = _context2.next) {
|
|
100
92
|
case 0:
|
|
101
|
-
|
|
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;
|
|
93
|
+
_context2.next = 2;
|
|
121
94
|
return this.getResourceAvailableTimeList(params);
|
|
122
|
-
case
|
|
95
|
+
case 2:
|
|
123
96
|
dates = _context2.sent;
|
|
124
|
-
this.
|
|
97
|
+
this.store.dateList = dates;
|
|
125
98
|
return _context2.abrupt("return", dates);
|
|
126
|
-
case
|
|
99
|
+
case 5:
|
|
127
100
|
case "end":
|
|
128
101
|
return _context2.stop();
|
|
129
102
|
}
|
|
@@ -142,31 +115,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
142
115
|
}, {
|
|
143
116
|
key: "setDateList",
|
|
144
117
|
value: function setDateList(dateList) {
|
|
145
|
-
|
|
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;
|
|
118
|
+
this.store.dateList = dateList;
|
|
170
119
|
}
|
|
171
120
|
}, {
|
|
172
121
|
key: "fetchResourceDates",
|
|
@@ -17,7 +17,6 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
17
17
|
loadPrepareConfig(params: {
|
|
18
18
|
action?: 'create';
|
|
19
19
|
with_good_pass: 0 | 1;
|
|
20
|
-
with_discount_card: 0 | 1;
|
|
21
20
|
customer_id: number;
|
|
22
21
|
}): Promise<Discount[]>;
|
|
23
22
|
batchSearch(code: string): Promise<Discount[]>;
|
|
@@ -1,10 +1,4 @@
|
|
|
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; }
|
|
8
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; }
|
|
9
3
|
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); } }
|
|
10
4
|
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); }); }; }
|
|
@@ -24,7 +18,6 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
24
18
|
import { uniqueById } from "../../solution/ShopDiscount/utils";
|
|
25
19
|
import { BaseModule } from "../BaseModule";
|
|
26
20
|
import { DiscountHooks } from "./types";
|
|
27
|
-
import Decimal from 'decimal.js';
|
|
28
21
|
export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
29
22
|
_inherits(DiscountModule, _BaseModule);
|
|
30
23
|
var _super = _createSuper(DiscountModule);
|
|
@@ -120,7 +113,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
120
113
|
key: "loadPrepareConfig",
|
|
121
114
|
value: function () {
|
|
122
115
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
123
|
-
var _prepareConfig$data
|
|
116
|
+
var _prepareConfig$data;
|
|
124
117
|
var prepareConfig, goodPassList;
|
|
125
118
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
126
119
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -129,10 +122,9 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
129
122
|
return this.request.post("/order/prepare/config", params);
|
|
130
123
|
case 2:
|
|
131
124
|
prepareConfig = _context3.sent;
|
|
132
|
-
goodPassList = this.filterEnabledDiscountList(
|
|
133
|
-
this.setDiscountList(goodPassList);
|
|
125
|
+
goodPassList = this.filterEnabledDiscountList((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []) || [];
|
|
134
126
|
return _context3.abrupt("return", goodPassList);
|
|
135
|
-
case
|
|
127
|
+
case 5:
|
|
136
128
|
case "end":
|
|
137
129
|
return _context3.stop();
|
|
138
130
|
}
|
|
@@ -155,7 +147,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
155
147
|
return this.request.get("/machinecode/batch-search", {
|
|
156
148
|
code: code,
|
|
157
149
|
translate_flag: 1,
|
|
158
|
-
|
|
150
|
+
tag: 'good_pass',
|
|
159
151
|
available: 1,
|
|
160
152
|
relation_product: 1
|
|
161
153
|
});
|
|
@@ -178,7 +170,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
178
170
|
key: "filterEnabledDiscountList",
|
|
179
171
|
value: function filterEnabledDiscountList(discountList) {
|
|
180
172
|
return discountList.filter(function (discount) {
|
|
181
|
-
return discount.limit_status === 'enable' &&
|
|
173
|
+
return discount.limit_status === 'enable' && Number((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0) - Number((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0) > 0;
|
|
182
174
|
});
|
|
183
175
|
}
|
|
184
176
|
|
|
@@ -206,8 +198,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
198
|
}
|
|
207
199
|
if (discount.appliedProductDetails) {
|
|
208
200
|
return discount.appliedProductDetails.reduce(function (total, product) {
|
|
209
|
-
var price =
|
|
210
|
-
return
|
|
201
|
+
var price = Number(product === null || product === void 0 ? void 0 : product.amount) || 0;
|
|
202
|
+
return total + price;
|
|
211
203
|
}, 0);
|
|
212
204
|
}
|
|
213
205
|
}
|
|
@@ -27,14 +27,6 @@ interface ApplicableProductDetails {
|
|
|
27
27
|
resource_id: number;
|
|
28
28
|
title: string;
|
|
29
29
|
original_amount: string;
|
|
30
|
-
num: number;
|
|
31
|
-
discount?: {
|
|
32
|
-
product_id?: number;
|
|
33
|
-
original_amount?: string;
|
|
34
|
-
percent?: string;
|
|
35
|
-
resource_id?: number;
|
|
36
|
-
title?: string;
|
|
37
|
-
};
|
|
38
30
|
}
|
|
39
31
|
export interface Discount {
|
|
40
32
|
id: number;
|
|
@@ -68,8 +60,6 @@ export interface Discount {
|
|
|
68
60
|
applicableProductIds?: number[];
|
|
69
61
|
applicableProductDetails: ApplicableProductDetails[];
|
|
70
62
|
appliedProductDetails: ApplicableProductDetails[];
|
|
71
|
-
isDisabledForProductUsed?: boolean;
|
|
72
|
-
amount?: number;
|
|
73
63
|
}
|
|
74
64
|
export interface DiscountState {
|
|
75
65
|
discountList: Discount[];
|
|
@@ -11,13 +11,6 @@ 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>;
|
|
21
14
|
loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
|
|
22
15
|
ids?: number[];
|
|
23
16
|
customer_id?: number;
|
|
@@ -97,78 +97,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
97
97
|
return storeChange;
|
|
98
98
|
}()
|
|
99
99
|
}, {
|
|
100
|
-
key: "
|
|
100
|
+
key: "loadProductsPrice",
|
|
101
101
|
value: function () {
|
|
102
|
-
var
|
|
103
|
-
var _ref$
|
|
102
|
+
var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
103
|
+
var _ref$ids, ids, customer_id, schedule_date, channel, productsData;
|
|
104
104
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
105
105
|
while (1) switch (_context3.prev = _context3.next) {
|
|
106
106
|
case 0:
|
|
107
|
-
_ref$
|
|
108
|
-
|
|
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;
|
|
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;
|
|
172
109
|
return this.request.post("/product/query/price", {
|
|
173
110
|
ids: ids,
|
|
174
111
|
customer_id: customer_id,
|
|
@@ -178,15 +115,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
178
115
|
useCache: true
|
|
179
116
|
});
|
|
180
117
|
case 3:
|
|
181
|
-
productsData =
|
|
182
|
-
return
|
|
118
|
+
productsData = _context3.sent;
|
|
119
|
+
return _context3.abrupt("return", productsData.data);
|
|
183
120
|
case 5:
|
|
184
121
|
case "end":
|
|
185
|
-
return
|
|
122
|
+
return _context3.stop();
|
|
186
123
|
}
|
|
187
|
-
},
|
|
124
|
+
}, _callee3, this);
|
|
188
125
|
}));
|
|
189
|
-
function loadProductsPrice(
|
|
126
|
+
function loadProductsPrice(_x5) {
|
|
190
127
|
return _loadProductsPrice.apply(this, arguments);
|
|
191
128
|
}
|
|
192
129
|
return loadProductsPrice;
|
|
@@ -194,19 +131,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
194
131
|
}, {
|
|
195
132
|
key: "getProducts",
|
|
196
133
|
value: function () {
|
|
197
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
198
|
-
return _regeneratorRuntime().wrap(function
|
|
199
|
-
while (1) switch (
|
|
134
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
135
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
136
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
200
137
|
case 0:
|
|
201
|
-
|
|
138
|
+
_context4.next = 2;
|
|
202
139
|
return this.core.effects.emit(ProductListHooks.onGetProducts, this.store.list);
|
|
203
140
|
case 2:
|
|
204
|
-
return
|
|
141
|
+
return _context4.abrupt("return", cloneDeep(this.store.list));
|
|
205
142
|
case 3:
|
|
206
143
|
case "end":
|
|
207
|
-
return
|
|
144
|
+
return _context4.stop();
|
|
208
145
|
}
|
|
209
|
-
},
|
|
146
|
+
}, _callee4, this);
|
|
210
147
|
}));
|
|
211
148
|
function getProducts() {
|
|
212
149
|
return _getProducts.apply(this, arguments);
|
|
@@ -216,29 +153,29 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
216
153
|
}, {
|
|
217
154
|
key: "getProduct",
|
|
218
155
|
value: function () {
|
|
219
|
-
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
156
|
+
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
|
|
220
157
|
var product;
|
|
221
|
-
return _regeneratorRuntime().wrap(function
|
|
222
|
-
while (1) switch (
|
|
158
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
159
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
223
160
|
case 0:
|
|
224
|
-
|
|
161
|
+
_context5.next = 2;
|
|
225
162
|
return this.core.effects.emit(ProductListHooks.onGetProduct, this.store.list);
|
|
226
163
|
case 2:
|
|
227
164
|
product = this.store.productMap.get("".concat(id));
|
|
228
165
|
if (!product) {
|
|
229
|
-
|
|
166
|
+
_context5.next = 5;
|
|
230
167
|
break;
|
|
231
168
|
}
|
|
232
|
-
return
|
|
169
|
+
return _context5.abrupt("return", product);
|
|
233
170
|
case 5:
|
|
234
|
-
return
|
|
171
|
+
return _context5.abrupt("return", undefined);
|
|
235
172
|
case 6:
|
|
236
173
|
case "end":
|
|
237
|
-
return
|
|
174
|
+
return _context5.stop();
|
|
238
175
|
}
|
|
239
|
-
},
|
|
176
|
+
}, _callee5, this);
|
|
240
177
|
}));
|
|
241
|
-
function getProduct(
|
|
178
|
+
function getProduct(_x6) {
|
|
242
179
|
return _getProduct.apply(this, arguments);
|
|
243
180
|
}
|
|
244
181
|
return getProduct;
|
|
@@ -246,10 +183,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
246
183
|
}, {
|
|
247
184
|
key: "addProduct",
|
|
248
185
|
value: function () {
|
|
249
|
-
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
186
|
+
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(products) {
|
|
250
187
|
var _this3 = this;
|
|
251
|
-
return _regeneratorRuntime().wrap(function
|
|
252
|
-
while (1) switch (
|
|
188
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
189
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
253
190
|
case 0:
|
|
254
191
|
// 加到 list 以后上面的storeChange 会自动初始化商品详情的 module 实例
|
|
255
192
|
// list 需要根据 id 去重
|
|
@@ -269,11 +206,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
269
206
|
this.storeChange();
|
|
270
207
|
case 3:
|
|
271
208
|
case "end":
|
|
272
|
-
return
|
|
209
|
+
return _context6.stop();
|
|
273
210
|
}
|
|
274
|
-
},
|
|
211
|
+
}, _callee6, this);
|
|
275
212
|
}));
|
|
276
|
-
function addProduct(
|
|
213
|
+
function addProduct(_x7) {
|
|
277
214
|
return _addProduct.apply(this, arguments);
|
|
278
215
|
}
|
|
279
216
|
return addProduct;
|
|
@@ -281,18 +218,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
281
218
|
}, {
|
|
282
219
|
key: "selectProducts",
|
|
283
220
|
value: function () {
|
|
284
|
-
var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
285
|
-
return _regeneratorRuntime().wrap(function
|
|
286
|
-
while (1) switch (
|
|
221
|
+
var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(products) {
|
|
222
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
223
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
287
224
|
case 0:
|
|
288
225
|
this.store.selectProducts = products;
|
|
289
226
|
case 1:
|
|
290
227
|
case "end":
|
|
291
|
-
return
|
|
228
|
+
return _context7.stop();
|
|
292
229
|
}
|
|
293
|
-
},
|
|
230
|
+
}, _callee7, this);
|
|
294
231
|
}));
|
|
295
|
-
function selectProducts(
|
|
232
|
+
function selectProducts(_x8) {
|
|
296
233
|
return _selectProducts.apply(this, arguments);
|
|
297
234
|
}
|
|
298
235
|
return selectProducts;
|