@pisell/pisellos 0.0.480 → 0.0.481
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.js +7 -0
- package/dist/effects/index.d.ts +2 -2
- package/dist/effects/index.js +34 -81
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/walletPass/type.d.ts +9 -2
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +6 -6
- package/dist/model/strategy/adapter/walletPass/utils.js +104 -77
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Discount/index.d.ts +6 -2
- package/dist/modules/Discount/index.js +14 -8
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +18 -13
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +774 -649
- package/dist/modules/Payment/walletpass.js +44 -17
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/index.d.ts +3 -0
- package/dist/modules/ProductList/index.js +9 -7
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +37 -31
- package/dist/modules/Rules/types.d.ts +2 -2
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +15 -2
- package/dist/plugins/app-types/app/app.d.ts +1 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +107 -2
- package/dist/server/index.js +1507 -279
- package/dist/server/modules/index.d.ts +6 -0
- package/dist/server/modules/index.js +7 -0
- package/dist/server/modules/menu/index.d.ts +19 -0
- package/dist/server/modules/menu/index.js +221 -71
- package/dist/server/modules/order/index.d.ts +87 -0
- package/dist/server/modules/order/index.js +916 -0
- package/dist/server/modules/order/types.d.ts +530 -0
- package/dist/server/modules/order/types.js +141 -0
- package/dist/server/modules/order/utils/filterBookings.d.ts +6 -0
- package/dist/server/modules/order/utils/filterBookings.js +350 -0
- package/dist/server/modules/order/utils/filterOrders.d.ts +15 -0
- package/dist/server/modules/order/utils/filterOrders.js +226 -0
- package/dist/server/modules/products/index.d.ts +117 -5
- package/dist/server/modules/products/index.js +1450 -240
- package/dist/server/modules/products/types.d.ts +25 -1
- package/dist/server/modules/products/types.js +3 -0
- package/dist/server/modules/resource/index.d.ts +86 -0
- package/dist/server/modules/resource/index.js +1128 -0
- package/dist/server/modules/resource/types.d.ts +121 -0
- package/dist/server/modules/resource/types.js +47 -0
- package/dist/server/modules/schedule/index.d.ts +19 -0
- package/dist/server/modules/schedule/index.js +229 -68
- package/dist/server/utils/product.d.ts +5 -0
- package/dist/server/utils/product.js +71 -31
- package/dist/solution/BookingTicket/index.d.ts +10 -2
- package/dist/solution/BookingTicket/index.js +41 -28
- package/dist/solution/BookingTicket/utils/scan/index.js +1 -1
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +286 -188
- package/dist/solution/Checkout/utils/index.d.ts +2 -1
- package/dist/solution/Checkout/utils/index.js +6 -4
- package/dist/solution/RegisterAndLogin/config.js +340 -1
- package/dist/solution/Sales/index.d.ts +96 -0
- package/dist/solution/Sales/index.js +566 -0
- package/dist/solution/Sales/types.d.ts +67 -0
- package/dist/solution/Sales/types.js +26 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +35 -22
- package/dist/solution/ShopDiscount/types.d.ts +6 -0
- package/dist/solution/ShopDiscount/utils.d.ts +9 -0
- package/dist/solution/ShopDiscount/utils.js +21 -27
- package/dist/solution/index.d.ts +2 -1
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +5 -0
- package/lib/core/index.d.ts +3 -2
- package/lib/core/index.js +4 -0
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +22 -31
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/walletPass/type.d.ts +9 -2
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +6 -6
- package/lib/model/strategy/adapter/walletPass/utils.js +113 -49
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/index.d.ts +6 -2
- package/lib/modules/Discount/index.js +3 -1
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +20 -18
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +134 -66
- package/lib/modules/Payment/walletpass.js +23 -4
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/ProductList/index.d.ts +3 -0
- package/lib/modules/ProductList/index.js +2 -2
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +69 -73
- package/lib/modules/Rules/types.d.ts +2 -2
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +11 -0
- package/lib/plugins/app-types/app/app.d.ts +1 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +107 -2
- package/lib/server/index.js +773 -51
- package/lib/server/modules/index.d.ts +6 -0
- package/lib/server/modules/index.js +16 -2
- package/lib/server/modules/menu/index.d.ts +19 -0
- package/lib/server/modules/menu/index.js +121 -2
- package/lib/server/modules/order/index.d.ts +87 -0
- package/lib/server/modules/order/index.js +543 -0
- package/lib/server/modules/order/types.d.ts +530 -0
- package/lib/server/modules/order/types.js +34 -0
- package/lib/server/modules/order/utils/filterBookings.d.ts +6 -0
- package/lib/server/modules/order/utils/filterBookings.js +320 -0
- package/lib/server/modules/order/utils/filterOrders.d.ts +15 -0
- package/lib/server/modules/order/utils/filterOrders.js +197 -0
- package/lib/server/modules/products/index.d.ts +117 -5
- package/lib/server/modules/products/index.js +799 -62
- package/lib/server/modules/products/types.d.ts +25 -1
- package/lib/server/modules/products/types.js +1 -0
- package/lib/server/modules/resource/index.d.ts +86 -0
- package/lib/server/modules/resource/index.js +557 -0
- package/lib/server/modules/resource/types.d.ts +121 -0
- package/lib/server/modules/resource/types.js +35 -0
- package/lib/server/modules/schedule/index.d.ts +19 -0
- package/lib/server/modules/schedule/index.js +141 -12
- package/lib/server/utils/product.d.ts +5 -0
- package/lib/server/utils/product.js +56 -27
- package/lib/solution/BookingTicket/index.d.ts +10 -2
- package/lib/solution/BookingTicket/index.js +10 -2
- package/lib/solution/BookingTicket/utils/scan/index.js +0 -1
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +399 -331
- package/lib/solution/Checkout/utils/index.d.ts +2 -1
- package/lib/solution/Checkout/utils/index.js +6 -4
- package/lib/solution/RegisterAndLogin/config.js +266 -1
- package/lib/solution/Sales/index.d.ts +96 -0
- package/lib/solution/Sales/index.js +416 -0
- package/lib/solution/Sales/types.d.ts +67 -0
- package/lib/solution/Sales/types.js +35 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -6
- package/lib/solution/ShopDiscount/types.d.ts +6 -0
- package/lib/solution/ShopDiscount/utils.d.ts +9 -0
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/lib/solution/index.d.ts +2 -1
- package/lib/solution/index.js +4 -2
- package/lib/types/index.d.ts +5 -0
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, PluginOptions, Module, ModuleOptions, PisellCore, PisellOSOptions, BusinessContext, ModuleContextConfig, InitializeServerOptions } from '../types';
|
|
1
|
+
import { Plugin, PluginOptions, Module, ModuleOptions, PisellCore, PisellOSOptions, BusinessContext, ModuleContextConfig, ServerOptions, InitializeServerOptions } from '../types';
|
|
2
2
|
import { EffectsManager } from '../effects';
|
|
3
3
|
/**
|
|
4
4
|
* pisell OS 核心实现
|
|
@@ -11,7 +11,7 @@ declare class PisellOSCore implements PisellCore {
|
|
|
11
11
|
private debug;
|
|
12
12
|
context: BusinessContext;
|
|
13
13
|
server: any;
|
|
14
|
-
|
|
14
|
+
serverOptions?: ServerOptions;
|
|
15
15
|
constructor(options?: PisellOSOptions);
|
|
16
16
|
private initialize;
|
|
17
17
|
/**
|
|
@@ -29,6 +29,7 @@ declare class PisellOSCore implements PisellCore {
|
|
|
29
29
|
getModuleExports<T = any>(name: string): T | null;
|
|
30
30
|
hasModule(name: string): boolean;
|
|
31
31
|
destroy(): Promise<void>;
|
|
32
|
+
setContext(ctx: Partial<BusinessContext>): void;
|
|
32
33
|
/**
|
|
33
34
|
* 验证上下文参数
|
|
34
35
|
*/
|
package/dist/core/index.js
CHANGED
|
@@ -403,6 +403,13 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
403
403
|
}
|
|
404
404
|
return destroy;
|
|
405
405
|
}()
|
|
406
|
+
}, {
|
|
407
|
+
key: "setContext",
|
|
408
|
+
value: function setContext(ctx) {
|
|
409
|
+
this.context = _objectSpread(_objectSpread({}, this.context), ctx);
|
|
410
|
+
this.log("\u4E0A\u4E0B\u6587\u5DF2\u66F4\u65B0: ".concat(JSON.stringify(Object.keys(ctx))));
|
|
411
|
+
}
|
|
412
|
+
|
|
406
413
|
/**
|
|
407
414
|
* 验证上下文参数
|
|
408
415
|
*/
|
package/dist/effects/index.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ type EffectCallback = (payload: any) => void | Promise<void | {
|
|
|
5
5
|
type UnsubscribeFunction = () => void;
|
|
6
6
|
declare class EffectsManager {
|
|
7
7
|
private listeners;
|
|
8
|
-
on(event: string, callback: EffectCallback
|
|
8
|
+
on(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
9
9
|
only(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
10
10
|
off(event: string, callback: EffectCallback): void;
|
|
11
11
|
offByModuleDestroy(module: string): void;
|
|
12
|
-
once(event: string, callback: EffectCallback
|
|
12
|
+
once(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
13
13
|
emit(event: string, payload: any): Promise<{
|
|
14
14
|
status: boolean;
|
|
15
15
|
data: any;
|
package/dist/effects/index.js
CHANGED
|
@@ -1,11 +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 _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; } } }; }
|
|
3
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
-
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."); }
|
|
5
|
-
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); }
|
|
6
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
-
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; }
|
|
9
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; }
|
|
10
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); } }
|
|
11
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); }); }; }
|
|
@@ -26,12 +19,9 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
26
19
|
value: function on(event, callback) {
|
|
27
20
|
var _this$listeners$get,
|
|
28
21
|
_this = this;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
callback: callback,
|
|
33
|
-
force: force
|
|
34
|
-
});
|
|
22
|
+
if (!this.listeners.has(event)) this.listeners.set(event, new Set());
|
|
23
|
+
(_this$listeners$get = this.listeners.get(event)) === null || _this$listeners$get === void 0 || _this$listeners$get.add(callback);
|
|
24
|
+
|
|
35
25
|
// 返回取消函数
|
|
36
26
|
return function () {
|
|
37
27
|
_this.off(event, callback);
|
|
@@ -42,16 +32,18 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
42
32
|
}, {
|
|
43
33
|
key: "only",
|
|
44
34
|
value: function only(event, callback) {
|
|
45
|
-
var _this$listeners$
|
|
35
|
+
var _this$listeners$get3,
|
|
46
36
|
_this2 = this;
|
|
47
37
|
// 清除该事件的所有现有监听器
|
|
48
|
-
this.listeners.
|
|
38
|
+
if (this.listeners.has(event)) {
|
|
39
|
+
var _this$listeners$get2;
|
|
40
|
+
(_this$listeners$get2 = this.listeners.get(event)) === null || _this$listeners$get2 === void 0 || _this$listeners$get2.clear();
|
|
41
|
+
} else {
|
|
42
|
+
this.listeners.set(event, new Set());
|
|
43
|
+
}
|
|
49
44
|
|
|
50
45
|
// 添加新的监听器
|
|
51
|
-
(_this$listeners$
|
|
52
|
-
callback: callback,
|
|
53
|
-
force: false
|
|
54
|
-
});
|
|
46
|
+
(_this$listeners$get3 = this.listeners.get(event)) === null || _this$listeners$get3 === void 0 || _this$listeners$get3.add(callback);
|
|
55
47
|
|
|
56
48
|
// 返回取消函数
|
|
57
49
|
return function () {
|
|
@@ -61,14 +53,8 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
61
53
|
}, {
|
|
62
54
|
key: "off",
|
|
63
55
|
value: function off(event, callback) {
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
for (var index = eventListeners.length - 1; index >= 0; index--) {
|
|
67
|
-
if (eventListeners[index].callback !== callback) continue;
|
|
68
|
-
eventListeners.splice(index, 1);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
if (!eventListeners.length) this.listeners.delete(event);
|
|
56
|
+
var _this$listeners$get4;
|
|
57
|
+
(_this$listeners$get4 = this.listeners.get(event)) === null || _this$listeners$get4 === void 0 || _this$listeners$get4.delete(callback);
|
|
72
58
|
}
|
|
73
59
|
|
|
74
60
|
// 模块销毁时,删除所有以模块名开头的监听
|
|
@@ -86,7 +72,6 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
86
72
|
key: "once",
|
|
87
73
|
value: function once(event, callback) {
|
|
88
74
|
var _this4 = this;
|
|
89
|
-
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
90
75
|
var wrapper = /*#__PURE__*/function () {
|
|
91
76
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(payload) {
|
|
92
77
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -108,19 +93,18 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
108
93
|
}();
|
|
109
94
|
|
|
110
95
|
// 调用修改后的on方法,它会返回取消函数
|
|
111
|
-
return this.on(event, wrapper
|
|
96
|
+
return this.on(event, wrapper);
|
|
112
97
|
}
|
|
113
98
|
}, {
|
|
114
99
|
key: "emit",
|
|
115
100
|
value: function () {
|
|
116
101
|
var _emit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(event, payload) {
|
|
117
|
-
var
|
|
118
|
-
var callbacks, forceCallbacks, topNormalListener, targetCallbacks;
|
|
102
|
+
var callbacks, res, isAllPass;
|
|
119
103
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
120
104
|
while (1) switch (_context3.prev = _context3.next) {
|
|
121
105
|
case 0:
|
|
122
106
|
callbacks = this.listeners.get(event);
|
|
123
|
-
if (callbacks
|
|
107
|
+
if (callbacks) {
|
|
124
108
|
_context3.next = 3;
|
|
125
109
|
break;
|
|
126
110
|
}
|
|
@@ -129,71 +113,40 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
129
113
|
data: []
|
|
130
114
|
});
|
|
131
115
|
case 3:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
topNormalListener = (_reverse$find = _toConsumableArray(callbacks).reverse().find(function (listener) {
|
|
138
|
-
return !listener.force;
|
|
139
|
-
})) === null || _reverse$find === void 0 ? void 0 : _reverse$find.callback;
|
|
140
|
-
targetCallbacks = topNormalListener ? [].concat(_toConsumableArray(forceCallbacks), [topNormalListener]) : forceCallbacks;
|
|
141
|
-
return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
142
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
|
|
143
|
-
var res, _iterator, _step, cb, result, isAllPass;
|
|
116
|
+
res = [];
|
|
117
|
+
_context3.next = 6;
|
|
118
|
+
return Promise.all(Array.from(callbacks).reverse().map( /*#__PURE__*/function () {
|
|
119
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(cb) {
|
|
120
|
+
var result;
|
|
144
121
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
145
122
|
while (1) switch (_context2.prev = _context2.next) {
|
|
146
123
|
case 0:
|
|
147
|
-
|
|
148
|
-
_iterator = _createForOfIteratorHelper(targetCallbacks);
|
|
149
|
-
_context2.prev = 2;
|
|
150
|
-
_iterator.s();
|
|
151
|
-
case 4:
|
|
152
|
-
if ((_step = _iterator.n()).done) {
|
|
153
|
-
_context2.next = 12;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
cb = _step.value;
|
|
157
|
-
_context2.next = 8;
|
|
124
|
+
_context2.next = 2;
|
|
158
125
|
return cb(payload);
|
|
159
|
-
case
|
|
126
|
+
case 2:
|
|
160
127
|
result = _context2.sent;
|
|
161
128
|
if (result !== undefined && _typeof(result) === 'object' && 'status' in result) {
|
|
162
129
|
res.push(result);
|
|
163
130
|
}
|
|
164
|
-
case
|
|
165
|
-
_context2.next = 4;
|
|
166
|
-
break;
|
|
167
|
-
case 12:
|
|
168
|
-
_context2.next = 17;
|
|
169
|
-
break;
|
|
170
|
-
case 14:
|
|
171
|
-
_context2.prev = 14;
|
|
172
|
-
_context2.t0 = _context2["catch"](2);
|
|
173
|
-
_iterator.e(_context2.t0);
|
|
174
|
-
case 17:
|
|
175
|
-
_context2.prev = 17;
|
|
176
|
-
_iterator.f();
|
|
177
|
-
return _context2.finish(17);
|
|
178
|
-
case 20:
|
|
179
|
-
isAllPass = res.every(function (r) {
|
|
180
|
-
return (r === null || r === void 0 ? void 0 : r.status) !== false;
|
|
181
|
-
});
|
|
182
|
-
resolve({
|
|
183
|
-
status: isAllPass,
|
|
184
|
-
data: res
|
|
185
|
-
});
|
|
186
|
-
case 22:
|
|
131
|
+
case 4:
|
|
187
132
|
case "end":
|
|
188
133
|
return _context2.stop();
|
|
189
134
|
}
|
|
190
|
-
}, _callee2
|
|
135
|
+
}, _callee2);
|
|
191
136
|
}));
|
|
192
137
|
return function (_x4) {
|
|
193
138
|
return _ref2.apply(this, arguments);
|
|
194
139
|
};
|
|
195
140
|
}()));
|
|
196
|
-
case
|
|
141
|
+
case 6:
|
|
142
|
+
isAllPass = res.every(function (r) {
|
|
143
|
+
return (r === null || r === void 0 ? void 0 : r.status) !== false;
|
|
144
|
+
});
|
|
145
|
+
return _context3.abrupt("return", {
|
|
146
|
+
status: isAllPass,
|
|
147
|
+
data: res
|
|
148
|
+
});
|
|
149
|
+
case 8:
|
|
197
150
|
case "end":
|
|
198
151
|
return _context3.stop();
|
|
199
152
|
}
|
|
@@ -719,7 +719,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
719
719
|
unitProducts.push({
|
|
720
720
|
product: product,
|
|
721
721
|
price: product.price,
|
|
722
|
-
productId: product.id
|
|
722
|
+
productId: product.id,
|
|
723
|
+
sourceAvailableQty: availableQty
|
|
723
724
|
});
|
|
724
725
|
}
|
|
725
726
|
}
|
|
@@ -736,8 +737,13 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
736
737
|
};
|
|
737
738
|
}
|
|
738
739
|
|
|
739
|
-
// 2.
|
|
740
|
+
// 2. 排序:优先选择来源数量是 x 倍数的商品(可完整凑组不拆分),然后按价格从高到低
|
|
740
741
|
unitProducts.sort(function (a, b) {
|
|
742
|
+
// 优先级1:来源购物车项数量是 x 的倍数的排前面(这些商品可以完整凑组,避免拆分)
|
|
743
|
+
var aIsMultiple = a.sourceAvailableQty > 0 && a.sourceAvailableQty % x === 0 ? 1 : 0;
|
|
744
|
+
var bIsMultiple = b.sourceAvailableQty > 0 && b.sourceAvailableQty % x === 0 ? 1 : 0;
|
|
745
|
+
if (aIsMultiple !== bIsMultiple) return bIsMultiple - aIsMultiple;
|
|
746
|
+
// 优先级2:按价格从高到低(优先使用高价商品)
|
|
741
747
|
return b.price - a.price;
|
|
742
748
|
});
|
|
743
749
|
|
|
@@ -833,7 +839,10 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
833
839
|
var totalAllocated = allocatedPrices.reduce(function (sum, p) {
|
|
834
840
|
return sum.plus(p);
|
|
835
841
|
}, new Decimal(0));
|
|
836
|
-
|
|
842
|
+
// 取促销价和原价的最小值,避免促销反而加价
|
|
843
|
+
var productOriginalAmount = new Decimal(_product.price).mul(promoQty);
|
|
844
|
+
var actualTotal = Decimal.min(totalAllocated, productOriginalAmount);
|
|
845
|
+
var finalPricePerUnit = this.formatPrice(actualTotal.div(promoQty));
|
|
837
846
|
result.push(_objectSpread(_objectSpread({}, _product), {}, {
|
|
838
847
|
quantity: promoQty,
|
|
839
848
|
finalPrice: finalPricePerUnit,
|
|
@@ -843,9 +852,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
843
852
|
isSplit: false,
|
|
844
853
|
matchedBundleIndex: matchedBundleIndex
|
|
845
854
|
}));
|
|
846
|
-
var productOriginalAmount = new Decimal(_product.price).mul(promoQty);
|
|
847
855
|
originalAmount = originalAmount.plus(productOriginalAmount);
|
|
848
|
-
finalAmount = finalAmount.plus(
|
|
856
|
+
finalAmount = finalAmount.plus(actualTotal);
|
|
849
857
|
} else if (promoQty === 0 && remainingQty > 0) {
|
|
850
858
|
// 全部不参与促销:保留原 id,finalPrice = 原价
|
|
851
859
|
result.push(_objectSpread(_objectSpread({}, _product), {}, {
|
|
@@ -865,7 +873,10 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
865
873
|
var _totalAllocated = allocatedPrices.reduce(function (sum, p) {
|
|
866
874
|
return sum.plus(p);
|
|
867
875
|
}, new Decimal(0));
|
|
868
|
-
|
|
876
|
+
// 取促销价和原价的最小值,避免促销反而加价
|
|
877
|
+
var promoOriginalAmount = new Decimal(_product.price).mul(promoQty);
|
|
878
|
+
var _actualTotal = Decimal.min(_totalAllocated, promoOriginalAmount);
|
|
879
|
+
var _finalPricePerUnit = this.formatPrice(_actualTotal.div(promoQty));
|
|
869
880
|
result.push(_objectSpread(_objectSpread({}, _product), {}, {
|
|
870
881
|
id: this.generateRandomId(),
|
|
871
882
|
originalId: _product.id,
|
|
@@ -877,9 +888,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
877
888
|
matchedBundleIndex: matchedBundleIndex,
|
|
878
889
|
isSplit: true
|
|
879
890
|
}));
|
|
880
|
-
var promoOriginalAmount = new Decimal(_product.price).mul(promoQty);
|
|
881
891
|
originalAmount = originalAmount.plus(promoOriginalAmount);
|
|
882
|
-
finalAmount = finalAmount.plus(
|
|
892
|
+
finalAmount = finalAmount.plus(_actualTotal);
|
|
883
893
|
|
|
884
894
|
// 不参与促销的部分:保留原 id
|
|
885
895
|
result.push(_objectSpread(_objectSpread({}, _product), {}, {
|
|
@@ -898,11 +908,74 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
898
908
|
// 更新已处理数量
|
|
899
909
|
processedQuantityMap.set(_key, _processedQty + _availableQty);
|
|
900
910
|
}
|
|
911
|
+
|
|
912
|
+
// 8. 尾差调整:确保促销商品的 finalPrice × quantity 之和精确等于 groupPrice × groupCount
|
|
901
913
|
} catch (err) {
|
|
902
914
|
_iterator13.e(err);
|
|
903
915
|
} finally {
|
|
904
916
|
_iterator13.f();
|
|
905
917
|
}
|
|
918
|
+
if (groupCount > 0) {
|
|
919
|
+
var expectedPromoTotal = new Decimal(groupPrice).mul(groupCount);
|
|
920
|
+
var promoItems = result.filter(function (p) {
|
|
921
|
+
return p.inPromotion;
|
|
922
|
+
});
|
|
923
|
+
var actualPromoTotal = new Decimal(0);
|
|
924
|
+
var _iterator14 = _createForOfIteratorHelper(promoItems),
|
|
925
|
+
_step14;
|
|
926
|
+
try {
|
|
927
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
928
|
+
var _p = _step14.value;
|
|
929
|
+
actualPromoTotal = actualPromoTotal.plus(new Decimal(_p.finalPrice).mul(_p.quantity));
|
|
930
|
+
}
|
|
931
|
+
} catch (err) {
|
|
932
|
+
_iterator14.e(err);
|
|
933
|
+
} finally {
|
|
934
|
+
_iterator14.f();
|
|
935
|
+
}
|
|
936
|
+
var roundingDiff = actualPromoTotal.minus(expectedPromoTotal);
|
|
937
|
+
if (!roundingDiff.eq(0)) {
|
|
938
|
+
// 优先找 quantity=1 的促销商品调整(差额直接加减到单价上)
|
|
939
|
+
var adjustTarget = promoItems.find(function (p) {
|
|
940
|
+
return p.quantity === 1;
|
|
941
|
+
});
|
|
942
|
+
if (adjustTarget) {
|
|
943
|
+
adjustTarget.finalPrice = this.formatPrice(new Decimal(adjustTarget.finalPrice).minus(roundingDiff));
|
|
944
|
+
} else if (promoItems.length > 0) {
|
|
945
|
+
// 没有 quantity=1 的促销商品,从最后一个促销商品中拆出1件做尾差调整
|
|
946
|
+
var lastPromo = promoItems[promoItems.length - 1];
|
|
947
|
+
var adjustedUnitPrice = this.formatPrice(new Decimal(lastPromo.finalPrice).minus(roundingDiff));
|
|
948
|
+
|
|
949
|
+
// 原商品减少1件
|
|
950
|
+
lastPromo.quantity -= 1;
|
|
951
|
+
lastPromo.isSplit = true;
|
|
952
|
+
|
|
953
|
+
// 拆出1件用调整后的价格
|
|
954
|
+
result.push(_objectSpread(_objectSpread({}, lastPromo), {}, {
|
|
955
|
+
id: this.generateRandomId(),
|
|
956
|
+
originalId: lastPromo.originalId || lastPromo.id,
|
|
957
|
+
quantity: 1,
|
|
958
|
+
finalPrice: adjustedUnitPrice,
|
|
959
|
+
isSplit: true
|
|
960
|
+
}));
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// 重新计算 finalAmount
|
|
964
|
+
finalAmount = new Decimal(0);
|
|
965
|
+
var _iterator15 = _createForOfIteratorHelper(result),
|
|
966
|
+
_step15;
|
|
967
|
+
try {
|
|
968
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
969
|
+
var p = _step15.value;
|
|
970
|
+
finalAmount = finalAmount.plus(new Decimal(p.finalPrice).mul(p.quantity));
|
|
971
|
+
}
|
|
972
|
+
} catch (err) {
|
|
973
|
+
_iterator15.e(err);
|
|
974
|
+
} finally {
|
|
975
|
+
_iterator15.f();
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
906
979
|
return {
|
|
907
980
|
products: result,
|
|
908
981
|
originalAmount: originalAmount.toNumber(),
|
|
@@ -937,11 +1010,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
937
1010
|
// 对于 bundle 子商品匹配,促销数量 = 主商品数量 × bundle子商品数量
|
|
938
1011
|
var totalPromoQty = 0;
|
|
939
1012
|
var productInfoMap = new Map();
|
|
940
|
-
var
|
|
941
|
-
|
|
1013
|
+
var _iterator16 = _createForOfIteratorHelper(groupProducts),
|
|
1014
|
+
_step16;
|
|
942
1015
|
try {
|
|
943
|
-
for (
|
|
944
|
-
var product =
|
|
1016
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
1017
|
+
var product = _step16.value;
|
|
945
1018
|
var key = this.getProductKey(product);
|
|
946
1019
|
var processedQty = processedQuantityMap.get(key) || 0;
|
|
947
1020
|
var availableQty = product.quantity - processedQty;
|
|
@@ -967,18 +1040,18 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
967
1040
|
|
|
968
1041
|
// 2. 判断是否满足促销条件
|
|
969
1042
|
} catch (err) {
|
|
970
|
-
|
|
1043
|
+
_iterator16.e(err);
|
|
971
1044
|
} finally {
|
|
972
|
-
|
|
1045
|
+
_iterator16.f();
|
|
973
1046
|
}
|
|
974
1047
|
var isFulfilled = totalPromoQty >= buyQuantity;
|
|
975
1048
|
|
|
976
1049
|
// 3. 生成商品结果(第二次遍历)
|
|
977
|
-
var
|
|
978
|
-
|
|
1050
|
+
var _iterator17 = _createForOfIteratorHelper(groupProducts),
|
|
1051
|
+
_step17;
|
|
979
1052
|
try {
|
|
980
|
-
for (
|
|
981
|
-
var _product2 =
|
|
1053
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
1054
|
+
var _product2 = _step17.value;
|
|
982
1055
|
var _key2 = this.getProductKey(_product2);
|
|
983
1056
|
var info = productInfoMap.get(_key2);
|
|
984
1057
|
if (!info || info.availableQty <= 0) continue;
|
|
@@ -1006,9 +1079,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1006
1079
|
|
|
1007
1080
|
// 4. 计算赠品数量(使用促销数量)
|
|
1008
1081
|
} catch (err) {
|
|
1009
|
-
|
|
1082
|
+
_iterator17.e(err);
|
|
1010
1083
|
} finally {
|
|
1011
|
-
|
|
1084
|
+
_iterator17.f();
|
|
1012
1085
|
}
|
|
1013
1086
|
var giftCount = 0;
|
|
1014
1087
|
if (isFulfilled) {
|
|
@@ -1037,11 +1110,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1037
1110
|
key: "getRemainingProducts",
|
|
1038
1111
|
value: function getRemainingProducts(allProducts, processedQuantityMap) {
|
|
1039
1112
|
var result = [];
|
|
1040
|
-
var
|
|
1041
|
-
|
|
1113
|
+
var _iterator18 = _createForOfIteratorHelper(allProducts),
|
|
1114
|
+
_step18;
|
|
1042
1115
|
try {
|
|
1043
|
-
for (
|
|
1044
|
-
var product =
|
|
1116
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
1117
|
+
var product = _step18.value;
|
|
1045
1118
|
var key = this.getProductKey(product);
|
|
1046
1119
|
var processedQty = processedQuantityMap.get(key) || 0;
|
|
1047
1120
|
var remainingQty = product.quantity - processedQty;
|
|
@@ -1056,9 +1129,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1056
1129
|
}
|
|
1057
1130
|
}
|
|
1058
1131
|
} catch (err) {
|
|
1059
|
-
|
|
1132
|
+
_iterator18.e(err);
|
|
1060
1133
|
} finally {
|
|
1061
|
-
|
|
1134
|
+
_iterator18.f();
|
|
1062
1135
|
}
|
|
1063
1136
|
return result;
|
|
1064
1137
|
}
|
|
@@ -41,7 +41,7 @@ export interface Voucher {
|
|
|
41
41
|
allowCrossProduct: boolean;
|
|
42
42
|
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
43
43
|
applicableProductLimit: number;
|
|
44
|
-
/**
|
|
44
|
+
/** 单订单行每单位可用同一 Wallet Pass 券次数;该行总券次上限 = maxPassesPerItem × 该行 quantity(按行唯一键区分)。0 表示不限制。 */
|
|
45
45
|
maxPassesPerItem: number;
|
|
46
46
|
};
|
|
47
47
|
}
|
|
@@ -50,6 +50,10 @@ export interface Voucher {
|
|
|
50
50
|
*/
|
|
51
51
|
export interface Product {
|
|
52
52
|
product_id: number;
|
|
53
|
+
/** 订单明细 id,参与行唯一键兜底解析 */
|
|
54
|
+
id?: number;
|
|
55
|
+
/** 行级唯一串,参与行唯一键解析 */
|
|
56
|
+
product_unique_string?: string;
|
|
53
57
|
price: number;
|
|
54
58
|
quantity: number;
|
|
55
59
|
name?: string;
|
|
@@ -61,6 +65,9 @@ export interface Product {
|
|
|
61
65
|
/** 主商品税费 */
|
|
62
66
|
tax_fee: number;
|
|
63
67
|
metadata: {
|
|
68
|
+
/** 行唯一标识,优先用于 Wallet Pass 按行配额 */
|
|
69
|
+
product_unique?: string;
|
|
70
|
+
unique_identification_number?: string;
|
|
64
71
|
main_product_attached_bundle_tax_fee?: number;
|
|
65
72
|
main_product_attached_bundle_surcharge_fee?: number;
|
|
66
73
|
surcharge_rounding_remainder?: number;
|
|
@@ -132,7 +139,7 @@ export interface EvaluatorInput {
|
|
|
132
139
|
allowCrossProduct: boolean;
|
|
133
140
|
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
134
141
|
applicableProductLimit: number;
|
|
135
|
-
/**
|
|
142
|
+
/** 单订单行每单位可用同一 Wallet Pass 券次数;行总上限 = maxPassesPerItem × 该行 quantity(按行唯一键计)。0 表示不限制。 */
|
|
136
143
|
maxPassesPerItem: number;
|
|
137
144
|
}>[];
|
|
138
145
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Product, Voucher } from './type';
|
|
2
|
+
/** 订单商品数量 */
|
|
3
|
+
export declare const getProductQuantity: (product: any) => any;
|
|
4
|
+
/**
|
|
5
|
+
* 订单商品行唯一键,用于 maxPassesPerItem 按行、按件配额(同 SPU 不同规格视为不同行)。
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveWalletPassLineKey(product: any, indexInOrder: number): string;
|
|
2
8
|
export declare const getApplicableProductIds: (voucher: Voucher) => number[] | null;
|
|
3
9
|
/**
|
|
4
10
|
* 优惠券处理函数
|
|
@@ -64,12 +70,6 @@ export declare const getBundleItemDiscountDifference: (bundleItem: any) => numbe
|
|
|
64
70
|
* @returns 子商品总价格(不含舍入余数)
|
|
65
71
|
*/
|
|
66
72
|
export declare const getBundleItemPrice: (bundleItem: any, parentQuantity: number, isDeductTaxAndFee: boolean) => number;
|
|
67
|
-
/**
|
|
68
|
-
* 获取商品数量
|
|
69
|
-
* @param product 商品
|
|
70
|
-
* @returns 商品数量
|
|
71
|
-
*/
|
|
72
|
-
export declare const getProductQuantity: (product: any) => any;
|
|
73
73
|
export declare const getBundleItemIsOriginalPrice: (item: any) => boolean;
|
|
74
74
|
export declare const getBundleItemIsMarkupPrice: (item: any) => boolean;
|
|
75
75
|
export declare const getBundleItemIsDiscountPrice: (item: any) => boolean;
|