@pisell/pisellos 2.2.264 → 2.2.266
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/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +41 -10
- package/dist/modules/Order/index.js +1379 -810
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +49 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +410 -0
- package/dist/modules/Order/utils.d.ts +4 -3
- package/dist/modules/Order/utils.js +61 -64
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +26 -24
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +2 -8
- package/dist/modules/Rules/index.js +55 -9
- package/dist/modules/Rules/types.d.ts +10 -1
- package/dist/server/index.d.ts +71 -0
- package/dist/server/index.js +2504 -1187
- package/dist/server/modules/order/index.d.ts +56 -5
- package/dist/server/modules/order/index.js +1718 -834
- package/dist/server/modules/order/types.d.ts +15 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/server/modules/products/index.d.ts +31 -8
- package/dist/server/modules/products/index.js +549 -390
- package/dist/server/modules/products/types.d.ts +18 -0
- package/dist/solution/BaseSales/index.d.ts +67 -4
- package/dist/solution/BaseSales/index.js +1476 -792
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +94 -54
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +41 -10
- package/lib/modules/Order/index.js +514 -122
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +49 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +418 -0
- package/lib/modules/Order/utils.d.ts +4 -3
- package/lib/modules/Order/utils.js +26 -20
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +26 -24
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +2 -8
- package/lib/modules/Rules/index.js +57 -6
- package/lib/modules/Rules/types.d.ts +10 -1
- package/lib/server/index.d.ts +71 -0
- package/lib/server/index.js +1002 -52
- package/lib/server/modules/order/index.d.ts +56 -5
- package/lib/server/modules/order/index.js +798 -148
- package/lib/server/modules/order/types.d.ts +15 -3
- package/lib/server/modules/products/index.d.ts +31 -8
- package/lib/server/modules/products/index.js +134 -35
- package/lib/server/modules/products/types.d.ts +18 -0
- package/lib/solution/BaseSales/index.d.ts +67 -4
- package/lib/solution/BaseSales/index.js +496 -50
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +39 -11
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -756,7 +756,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
756
756
|
key: "loadPrepareConfig",
|
|
757
757
|
value: function () {
|
|
758
758
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
759
|
-
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, orderId, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
759
|
+
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, orderId, customerId, prepareConfigResult, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
760
760
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
761
761
|
while (1) switch (_context9.prev = _context9.next) {
|
|
762
762
|
case 0:
|
|
@@ -777,7 +777,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
777
777
|
order_id: orderId
|
|
778
778
|
} : {}));
|
|
779
779
|
case 5:
|
|
780
|
-
|
|
780
|
+
prepareConfigResult = _context9.sent;
|
|
781
|
+
goodPassList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList) || [];
|
|
781
782
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
782
783
|
return item.isScan;
|
|
783
784
|
}); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
|
|
@@ -789,35 +790,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
789
790
|
});
|
|
790
791
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
791
792
|
this.store.originalDiscountList = newDiscountList;
|
|
792
|
-
_context9.next =
|
|
793
|
+
_context9.next = 14;
|
|
793
794
|
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
|
|
794
|
-
case
|
|
795
|
+
case 14:
|
|
795
796
|
// 根据当前预约时间过滤优惠券列表
|
|
796
797
|
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
797
798
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
798
799
|
this.setDiscountList(filteredDiscountList || []);
|
|
799
800
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
800
|
-
_context9.next =
|
|
801
|
+
_context9.next = 21;
|
|
801
802
|
break;
|
|
802
803
|
}
|
|
803
804
|
_result3 = this.calcDiscount(this.store.productList);
|
|
804
|
-
_context9.next =
|
|
805
|
+
_context9.next = 21;
|
|
805
806
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
806
|
-
case
|
|
807
|
-
_context9.next =
|
|
807
|
+
case 21:
|
|
808
|
+
_context9.next = 23;
|
|
808
809
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
809
|
-
case
|
|
810
|
-
_context9.next =
|
|
810
|
+
case 23:
|
|
811
|
+
_context9.next = 28;
|
|
811
812
|
break;
|
|
812
|
-
case
|
|
813
|
-
_context9.prev =
|
|
813
|
+
case 25:
|
|
814
|
+
_context9.prev = 25;
|
|
814
815
|
_context9.t0 = _context9["catch"](0);
|
|
815
816
|
console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
|
|
816
|
-
case
|
|
817
|
+
case 28:
|
|
817
818
|
case "end":
|
|
818
819
|
return _context9.stop();
|
|
819
820
|
}
|
|
820
|
-
}, _callee9, this, [[0,
|
|
821
|
+
}, _callee9, this, [[0, 25]]);
|
|
821
822
|
}));
|
|
822
823
|
function loadPrepareConfig(_x9) {
|
|
823
824
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PaymentNumberAppDataGetter = (key: string) => unknown;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the synchronous fallback without caching runtime device data.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the latest device segment when a new payment number is generated.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
function normalizeNonEmptyString(value) {
|
|
6
|
+
if (value === undefined || value === null) return null;
|
|
7
|
+
if (typeof value !== 'string' && typeof value !== 'number') return null;
|
|
8
|
+
if (typeof value === 'number' && !Number.isFinite(value)) return null;
|
|
9
|
+
var normalized = String(value).trim();
|
|
10
|
+
return normalized || null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the synchronous fallback without caching runtime device data.
|
|
15
|
+
*/
|
|
16
|
+
export function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
|
|
17
|
+
try {
|
|
18
|
+
var deviceId = normalizeNonEmptyString(getAppData('device_id'));
|
|
19
|
+
if (deviceId && deviceId !== '0') return deviceId.slice(-2);
|
|
20
|
+
} catch (_unused) {
|
|
21
|
+
// The stable LOCAL prefix is the final fallback.
|
|
22
|
+
}
|
|
23
|
+
return 'LOCAL';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the latest device segment when a new payment number is generated.
|
|
28
|
+
*/
|
|
29
|
+
export function resolvePaymentNumberDevicePrefix(_x) {
|
|
30
|
+
return _resolvePaymentNumberDevicePrefix.apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
function _resolvePaymentNumberDevicePrefix() {
|
|
33
|
+
_resolvePaymentNumberDevicePrefix = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(getAppData) {
|
|
34
|
+
var getAsyncIotDeviceInfo, info, shortNumber;
|
|
35
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
36
|
+
while (1) switch (_context.prev = _context.next) {
|
|
37
|
+
case 0:
|
|
38
|
+
_context.prev = 0;
|
|
39
|
+
getAsyncIotDeviceInfo = getAppData('async_iot_device_info');
|
|
40
|
+
if (!(typeof getAsyncIotDeviceInfo === 'function')) {
|
|
41
|
+
_context.next = 9;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
_context.next = 5;
|
|
45
|
+
return getAsyncIotDeviceInfo();
|
|
46
|
+
case 5:
|
|
47
|
+
info = _context.sent;
|
|
48
|
+
shortNumber = normalizeNonEmptyString(info === null || info === void 0 ? void 0 : info.short_number);
|
|
49
|
+
if (!(shortNumber && shortNumber !== '0')) {
|
|
50
|
+
_context.next = 9;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return _context.abrupt("return", shortNumber);
|
|
54
|
+
case 9:
|
|
55
|
+
_context.next = 13;
|
|
56
|
+
break;
|
|
57
|
+
case 11:
|
|
58
|
+
_context.prev = 11;
|
|
59
|
+
_context.t0 = _context["catch"](0);
|
|
60
|
+
case 13:
|
|
61
|
+
return _context.abrupt("return", resolvePaymentNumberDevicePrefixFromDeviceId(getAppData));
|
|
62
|
+
case 14:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context.stop();
|
|
65
|
+
}
|
|
66
|
+
}, _callee, null, [[0, 11]]);
|
|
67
|
+
}));
|
|
68
|
+
return _resolvePaymentNumberDevicePrefix.apply(this, arguments);
|
|
69
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { EvaluationResult, RuntimeContext } from '../../type';
|
|
2
|
+
import type { BusinessAdapter } from '../type';
|
|
3
|
+
import type { DataVariantBusinessData, DataVariantProduct } from './type';
|
|
4
|
+
/**
|
|
5
|
+
* Data Variant 适配器。
|
|
6
|
+
*
|
|
7
|
+
* 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
|
|
8
|
+
*/
|
|
9
|
+
export declare class DataVariantAdapter implements BusinessAdapter {
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
/**
|
|
13
|
+
* 准备批量全局上下文。
|
|
14
|
+
*
|
|
15
|
+
* 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
|
|
16
|
+
*/
|
|
17
|
+
prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
|
|
18
|
+
/**
|
|
19
|
+
* 准备全局预计算上下文。
|
|
20
|
+
*/
|
|
21
|
+
prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
|
|
22
|
+
/**
|
|
23
|
+
* 准备单商品上下文。
|
|
24
|
+
*
|
|
25
|
+
* 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
|
|
26
|
+
*/
|
|
27
|
+
prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
|
|
28
|
+
transformResult(result: EvaluationResult): EvaluationResult;
|
|
29
|
+
formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
|
|
30
|
+
result: EvaluationResult;
|
|
31
|
+
businessData?: DataVariantBusinessData;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* 构建 menu_match 使用的轻量商品对象。
|
|
35
|
+
*
|
|
36
|
+
* collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
|
|
37
|
+
*/
|
|
38
|
+
buildProductValue(product: DataVariantProduct): {
|
|
39
|
+
id: number;
|
|
40
|
+
product_variant_id: number;
|
|
41
|
+
collection_ids: number[];
|
|
42
|
+
};
|
|
43
|
+
private toNumber;
|
|
44
|
+
/**
|
|
45
|
+
* 归一化客户 id:无效值返回 undefined,有效值统一为 number。
|
|
46
|
+
*/
|
|
47
|
+
private normalizeCustomerId;
|
|
48
|
+
private normalizeNumberArray;
|
|
49
|
+
}
|
|
50
|
+
export default DataVariantAdapter;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/model/strategy/adapter/dataVariant/adapter.ts
|
|
20
|
+
var adapter_exports = {};
|
|
21
|
+
__export(adapter_exports, {
|
|
22
|
+
DataVariantAdapter: () => DataVariantAdapter,
|
|
23
|
+
default: () => adapter_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(adapter_exports);
|
|
26
|
+
var DataVariantAdapter = class {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.name = "DataVariantAdapter";
|
|
29
|
+
this.version = "1.0.0";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 准备批量全局上下文。
|
|
33
|
+
*
|
|
34
|
+
* 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
|
|
35
|
+
*/
|
|
36
|
+
prepareContext(businessData) {
|
|
37
|
+
return this.prepareGlobalContext(businessData);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 准备全局预计算上下文。
|
|
41
|
+
*/
|
|
42
|
+
prepareGlobalContext(businessData) {
|
|
43
|
+
const {
|
|
44
|
+
products,
|
|
45
|
+
scheduleDateTime,
|
|
46
|
+
channel,
|
|
47
|
+
orderType,
|
|
48
|
+
businessCode,
|
|
49
|
+
customerId,
|
|
50
|
+
availableWalletIds,
|
|
51
|
+
custom
|
|
52
|
+
} = businessData;
|
|
53
|
+
const normalizedCustomerId = this.normalizeCustomerId(customerId);
|
|
54
|
+
const normalizedAvailableWalletIds = this.normalizeNumberArray(availableWalletIds ?? (custom == null ? void 0 : custom.available_wallet_ids));
|
|
55
|
+
const resolvedBusinessCode = businessCode || (custom == null ? void 0 : custom.business_code) || (custom == null ? void 0 : custom.businessCode) || "";
|
|
56
|
+
return {
|
|
57
|
+
entities: {
|
|
58
|
+
products
|
|
59
|
+
},
|
|
60
|
+
attributes: {
|
|
61
|
+
...custom,
|
|
62
|
+
schedule: scheduleDateTime || "",
|
|
63
|
+
channel: channel || (custom == null ? void 0 : custom.channel) || "",
|
|
64
|
+
orderType: orderType || (custom == null ? void 0 : custom.orderType) || (custom == null ? void 0 : custom.order_type) || "",
|
|
65
|
+
// snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
|
|
66
|
+
customer_id: normalizedCustomerId,
|
|
67
|
+
customerId: normalizedCustomerId,
|
|
68
|
+
available_wallet_ids: normalizedAvailableWalletIds,
|
|
69
|
+
availableWalletIds: normalizedAvailableWalletIds,
|
|
70
|
+
business_code: resolvedBusinessCode
|
|
71
|
+
},
|
|
72
|
+
metadata: {
|
|
73
|
+
timestamp: Date.now()
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 准备单商品上下文。
|
|
79
|
+
*
|
|
80
|
+
* 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
|
|
81
|
+
*/
|
|
82
|
+
prepareProductContext(businessData, product) {
|
|
83
|
+
const base = this.prepareGlobalContext(businessData);
|
|
84
|
+
const productValue = this.buildProductValue(product);
|
|
85
|
+
return {
|
|
86
|
+
...base,
|
|
87
|
+
entities: {
|
|
88
|
+
...base.entities,
|
|
89
|
+
currentProduct: product
|
|
90
|
+
},
|
|
91
|
+
attributes: {
|
|
92
|
+
...base.attributes,
|
|
93
|
+
product: productValue,
|
|
94
|
+
productIdAndVariantId: {
|
|
95
|
+
product_id: productValue.id,
|
|
96
|
+
product_variant_id: productValue.product_variant_id
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
transformResult(result) {
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
formatConfig(result, businessData) {
|
|
105
|
+
return { result, businessData };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 构建 menu_match 使用的轻量商品对象。
|
|
109
|
+
*
|
|
110
|
+
* collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
|
|
111
|
+
*/
|
|
112
|
+
buildProductValue(product) {
|
|
113
|
+
const productId = this.toNumber(product.id ?? product.product_id);
|
|
114
|
+
const variantId = this.toNumber(
|
|
115
|
+
product.product_variant_id ?? product.variant_id
|
|
116
|
+
);
|
|
117
|
+
const collectionIds = Array.isArray(product.collection) ? product.collection.map((item) => this.toNumber(item == null ? void 0 : item.id)).filter((id) => id > 0) : [];
|
|
118
|
+
return {
|
|
119
|
+
id: productId,
|
|
120
|
+
product_variant_id: variantId,
|
|
121
|
+
collection_ids: collectionIds
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
toNumber(value) {
|
|
125
|
+
const parsed = Number(value);
|
|
126
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 归一化客户 id:无效值返回 undefined,有效值统一为 number。
|
|
130
|
+
*/
|
|
131
|
+
normalizeCustomerId(value) {
|
|
132
|
+
if (value === void 0 || value === null || value === "") {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
const parsed = Number(value);
|
|
136
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
137
|
+
}
|
|
138
|
+
normalizeNumberArray(value) {
|
|
139
|
+
if (!Array.isArray(value))
|
|
140
|
+
return [];
|
|
141
|
+
const ids = value.map((item) => Number(item)).filter((item) => Number.isFinite(item) && item > 0);
|
|
142
|
+
return Array.from(new Set(ids));
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var adapter_default = DataVariantAdapter;
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
DataVariantAdapter
|
|
149
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ConditionRule, StrategyConfig } from '../../type';
|
|
2
|
+
import type { ConditionScope, DataVariantBusinessData, DataVariantMenu, DataVariantRuleMetadata, MenuScope, ResolvedDataVariantResult } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* Data Variant 评估器。
|
|
5
|
+
*
|
|
6
|
+
* 当前阶段只提供策略模型能力和示例验证,不接入 ProductList 业务链路。
|
|
7
|
+
*/
|
|
8
|
+
export declare class DataVariantEvaluator {
|
|
9
|
+
private adapter;
|
|
10
|
+
private strategyConfigs;
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* 设置策略配置列表,仅保留 metadata.type === 'data_variant' 的策略。
|
|
14
|
+
*/
|
|
15
|
+
setStrategyConfigs(configs: StrategyConfig[]): void;
|
|
16
|
+
getStrategyConfigs(): StrategyConfig<DataVariantRuleMetadata>[];
|
|
17
|
+
/**
|
|
18
|
+
* 批量解析商品 Data Variant。
|
|
19
|
+
*
|
|
20
|
+
* 先执行全局预计算,再只针对商品自身 data_variants 引用到的规则做商品级判断。
|
|
21
|
+
*/
|
|
22
|
+
resolveProducts(businessData: DataVariantBusinessData): ResolvedDataVariantResult;
|
|
23
|
+
/**
|
|
24
|
+
* 根据 operator/field 判断条件是否依赖当前商品。
|
|
25
|
+
*/
|
|
26
|
+
getConditionScope(rule: ConditionRule): ConditionScope;
|
|
27
|
+
/**
|
|
28
|
+
* 将餐牌 partyroom_package 预构建为 Map/Set 索引。
|
|
29
|
+
*/
|
|
30
|
+
buildMenuScopeMap(menuList: DataVariantMenu[]): Map<number, MenuScope>;
|
|
31
|
+
/**
|
|
32
|
+
* 从当前策略中所有 schedule_match.value 绑定的 schedule_id 提取时间点。
|
|
33
|
+
*
|
|
34
|
+
* 这里不依赖餐牌,只读取策略配置和调用方传入的 scheduleList。
|
|
35
|
+
*/
|
|
36
|
+
buildScheduleTimePoints(strategyConfigs: StrategyConfig<DataVariantRuleMetadata>[], scheduleList: NonNullable<DataVariantBusinessData['scheduleList']>): string[];
|
|
37
|
+
private buildGlobalEffectiveRuleMap;
|
|
38
|
+
private resolveProduct;
|
|
39
|
+
/**
|
|
40
|
+
* 解析套餐子商品上的 Data Variant 覆盖。
|
|
41
|
+
*
|
|
42
|
+
* bundle_item 以 bundle_product_id / bundle_variant_id 作为商品身份参与 product_match 等条件判断。
|
|
43
|
+
*/
|
|
44
|
+
private resolveProductBundleItems;
|
|
45
|
+
/**
|
|
46
|
+
* 将 bundle_item 转为 DataVariantProduct 并评估 data_variants。
|
|
47
|
+
*/
|
|
48
|
+
private resolveBundleItem;
|
|
49
|
+
/**
|
|
50
|
+
* bundle_item 的商品身份映射:bundle_product_id + bundle_variant_id。
|
|
51
|
+
*/
|
|
52
|
+
private toBundleItemDataVariantProduct;
|
|
53
|
+
/**
|
|
54
|
+
* 仅回写命中的字段,避免污染 bundle_item 的结构字段。
|
|
55
|
+
*/
|
|
56
|
+
private mergeBundleItemResolvedData;
|
|
57
|
+
private evaluateProductRules;
|
|
58
|
+
/**
|
|
59
|
+
* 拆分策略条件。
|
|
60
|
+
*
|
|
61
|
+
* 当前 MVP 支持顶层 and 原子条件拆分;复杂条件保守地放到商品级完整判断。
|
|
62
|
+
*/
|
|
63
|
+
private splitStrategyConfig;
|
|
64
|
+
private createEngine;
|
|
65
|
+
private evaluateScheduleMatch;
|
|
66
|
+
private evaluateMenuMatch;
|
|
67
|
+
private evaluateArrayIntersects;
|
|
68
|
+
private collectScheduleIdsFromStrategies;
|
|
69
|
+
private extractTimePointsFromSchedules;
|
|
70
|
+
private addDateTimePoint;
|
|
71
|
+
private addRawTimePoint;
|
|
72
|
+
private extractTimeFromDateTime;
|
|
73
|
+
private normalizeTime;
|
|
74
|
+
private timeToMinutes;
|
|
75
|
+
private isProductInMenuScope;
|
|
76
|
+
private mergeMatchedVariants;
|
|
77
|
+
private getProductDataVariants;
|
|
78
|
+
private normalizeStrategyConfigs;
|
|
79
|
+
private isStrategyActive;
|
|
80
|
+
private getStrategyPriority;
|
|
81
|
+
private createAlwaysTrueConditions;
|
|
82
|
+
private flattenConditionRules;
|
|
83
|
+
private isConditionGroup;
|
|
84
|
+
private normalizeNumberArray;
|
|
85
|
+
private normalizeComparableArray;
|
|
86
|
+
private buildProductKey;
|
|
87
|
+
private toNumber;
|
|
88
|
+
}
|
|
89
|
+
export default DataVariantEvaluator;
|