@pisell/pisellos 2.0.70 → 2.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/modules/Cart/utils/cartProduct.js +9 -2
  2. package/dist/modules/Date/index.d.ts +17 -0
  3. package/dist/modules/Date/index.js +96 -4
  4. package/dist/modules/Discount/types.d.ts +3 -0
  5. package/dist/modules/Order/index.js +4 -2
  6. package/dist/modules/Order/types.d.ts +1 -0
  7. package/dist/modules/ProductList/index.js +10 -2
  8. package/dist/modules/Rules/index.js +41 -12
  9. package/dist/plugins/request.d.ts +1 -0
  10. package/dist/solution/BookingByStep/index.d.ts +37 -5
  11. package/dist/solution/BookingByStep/index.js +1172 -113
  12. package/dist/solution/BookingByStep/utils/capacity.d.ts +29 -1
  13. package/dist/solution/BookingByStep/utils/capacity.js +250 -5
  14. package/dist/solution/BookingByStep/utils/resources.d.ts +15 -0
  15. package/dist/solution/BookingByStep/utils/resources.js +1 -1
  16. package/dist/solution/BookingByStep/utils/stock.d.ts +29 -0
  17. package/dist/solution/BookingByStep/utils/stock.js +126 -0
  18. package/dist/solution/RegisterAndLogin/config.d.ts +87 -0
  19. package/dist/solution/RegisterAndLogin/config.js +794 -0
  20. package/dist/solution/RegisterAndLogin/index.d.ts +189 -0
  21. package/dist/solution/RegisterAndLogin/index.js +2667 -0
  22. package/dist/solution/RegisterAndLogin/types.d.ts +445 -0
  23. package/dist/solution/RegisterAndLogin/types.js +231 -0
  24. package/dist/solution/RegisterAndLogin/utils.d.ts +95 -0
  25. package/dist/solution/RegisterAndLogin/utils.js +322 -0
  26. package/dist/solution/ShopDiscount/index.js +27 -9
  27. package/dist/solution/ShopDiscount/utils.d.ts +11 -0
  28. package/dist/solution/ShopDiscount/utils.js +29 -0
  29. package/dist/solution/index.d.ts +1 -0
  30. package/dist/solution/index.js +2 -1
  31. package/lib/modules/Cart/utils/cartProduct.js +9 -2
  32. package/lib/modules/Date/index.d.ts +17 -0
  33. package/lib/modules/Date/index.js +67 -0
  34. package/lib/modules/Discount/types.d.ts +3 -0
  35. package/lib/modules/Order/index.js +5 -2
  36. package/lib/modules/Order/types.d.ts +1 -0
  37. package/lib/modules/ProductList/index.js +9 -1
  38. package/lib/modules/Rules/index.js +27 -7
  39. package/lib/plugins/request.d.ts +1 -0
  40. package/lib/solution/BookingByStep/index.d.ts +37 -5
  41. package/lib/solution/BookingByStep/index.js +703 -46
  42. package/lib/solution/BookingByStep/utils/capacity.d.ts +29 -1
  43. package/lib/solution/BookingByStep/utils/capacity.js +183 -4
  44. package/lib/solution/BookingByStep/utils/resources.d.ts +15 -0
  45. package/lib/solution/BookingByStep/utils/resources.js +2 -0
  46. package/lib/solution/BookingByStep/utils/stock.d.ts +29 -0
  47. package/lib/solution/BookingByStep/utils/stock.js +89 -0
  48. package/lib/solution/RegisterAndLogin/config.d.ts +87 -0
  49. package/lib/solution/RegisterAndLogin/config.js +596 -0
  50. package/lib/solution/RegisterAndLogin/index.d.ts +189 -0
  51. package/lib/solution/RegisterAndLogin/index.js +1593 -0
  52. package/lib/solution/RegisterAndLogin/types.d.ts +445 -0
  53. package/lib/solution/RegisterAndLogin/types.js +78 -0
  54. package/lib/solution/RegisterAndLogin/utils.d.ts +95 -0
  55. package/lib/solution/RegisterAndLogin/utils.js +279 -0
  56. package/lib/solution/ShopDiscount/index.js +9 -0
  57. package/lib/solution/ShopDiscount/utils.d.ts +11 -0
  58. package/lib/solution/ShopDiscount/utils.js +24 -0
  59. package/lib/solution/index.d.ts +1 -0
  60. package/lib/solution/index.js +3 -1
  61. package/package.json +1 -1
@@ -12,6 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
12
12
  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); }
13
13
  import Decimal from 'decimal.js';
14
14
  import { isNormalProduct } from "../../Product/utils";
15
+ import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
15
16
 
16
17
  /**
17
18
  * @title 处理组合商品
@@ -192,8 +193,14 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
192
193
  // 不是商品券则代表折扣卡,计算打折后的价格
193
194
  // 一个商品折扣卡只能存在于一张
194
195
  if (currentValue.type !== 'good_pass') {
195
- var discountPrice = new Decimal(100).minus(currentValue.discount.percent || 0).div(100).mul(new Decimal(price || 0)).toFixed(2);
196
- price = Number(discountPrice);
196
+ var _currentValue$discoun;
197
+ price = getDiscountAmount({
198
+ tag: currentValue.type,
199
+ par_value: currentValue.discount.percent,
200
+ metadata: {
201
+ discount_card_type: currentValue === null || currentValue === void 0 || (_currentValue$discoun = currentValue.discount) === null || _currentValue$discoun === void 0 ? void 0 : _currentValue$discoun.discount_card_type
202
+ }
203
+ }, price, price);
197
204
  }
198
205
  });
199
206
  }
@@ -17,6 +17,23 @@ export declare class DateModule extends BaseModule implements Module, DateModule
17
17
  getDateList(): ITime[];
18
18
  setDateList(dateList: ITime[]): void;
19
19
  fetchResourceDates(params: IGetAvailableTimeListParams): Promise<any>;
20
+ /**
21
+ * 将时间向上取整到下一个10分钟整数
22
+ *
23
+ * @param time dayjs 时间对象
24
+ * @returns 向上取整后的时间字符串 (YYYY-MM-DD HH:mm 格式)
25
+ */
26
+ private roundUpToNext10Minutes;
27
+ /**
28
+ * 校正资源时间段数据
29
+ *
30
+ * 如果时间段的 start_at 早于资源的 start_time,将其同步为 start_time 的下一个10分钟整数
31
+ * 如果修正后 end_at 也早于修正后的 start_time,则删除该时间段
32
+ *
33
+ * @param resourcesData 资源数据数组
34
+ * @returns 校正后的资源数据数组
35
+ */
36
+ private correctResourceTimeSlots;
20
37
  getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
21
38
  clearDateRange(): void;
22
39
  storeChange(): void;
@@ -1,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -21,6 +23,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
21
23
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
23
25
  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); }
26
+ import dayjs from 'dayjs';
24
27
  import { BaseModule } from "../BaseModule";
25
28
  import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
26
29
  import cloneDeep from 'lodash-es/cloneDeep';
@@ -204,22 +207,111 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
204
207
  });
205
208
  case 6:
206
209
  res = _context3.sent;
210
+ // 校正资源时间段数据
211
+ if (res !== null && res !== void 0 && res.data && Array.isArray(res.data)) {
212
+ res.data = this.correctResourceTimeSlots(res.data);
213
+ }
207
214
  return _context3.abrupt("return", res);
208
- case 10:
209
- _context3.prev = 10;
215
+ case 11:
216
+ _context3.prev = 11;
210
217
  _context3.t0 = _context3["catch"](3);
211
218
  console.error(_context3.t0);
212
- case 13:
219
+ case 14:
213
220
  case "end":
214
221
  return _context3.stop();
215
222
  }
216
- }, _callee3, this, [[3, 10]]);
223
+ }, _callee3, this, [[3, 11]]);
217
224
  }));
218
225
  function fetchResourceDates(_x4) {
219
226
  return _fetchResourceDates.apply(this, arguments);
220
227
  }
221
228
  return fetchResourceDates;
222
229
  }()
230
+ /**
231
+ * 将时间向上取整到下一个10分钟整数
232
+ *
233
+ * @param time dayjs 时间对象
234
+ * @returns 向上取整后的时间字符串 (YYYY-MM-DD HH:mm 格式)
235
+ */
236
+ }, {
237
+ key: "roundUpToNext10Minutes",
238
+ value: function roundUpToNext10Minutes(time) {
239
+ var minutes = time.minute();
240
+ var remainder = minutes % 10;
241
+ if (remainder === 0) {
242
+ // 如果已经是10分钟的整数,保持不变
243
+ return time.format('YYYY-MM-DD HH:mm');
244
+ } else {
245
+ // 向上取整到下一个10分钟
246
+ var minutesToAdd = 10 - remainder;
247
+ var roundedTime = time.add(minutesToAdd, 'minute');
248
+ return roundedTime.format('YYYY-MM-DD HH:mm');
249
+ }
250
+ }
251
+
252
+ /**
253
+ * 校正资源时间段数据
254
+ *
255
+ * 如果时间段的 start_at 早于资源的 start_time,将其同步为 start_time 的下一个10分钟整数
256
+ * 如果修正后 end_at 也早于修正后的 start_time,则删除该时间段
257
+ *
258
+ * @param resourcesData 资源数据数组
259
+ * @returns 校正后的资源数据数组
260
+ */
261
+ }, {
262
+ key: "correctResourceTimeSlots",
263
+ value: function correctResourceTimeSlots(resourcesData) {
264
+ var _this2 = this;
265
+ return resourcesData.map(function (resource) {
266
+ // 检查资源是否有 times 数组和 start_time
267
+ if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
268
+ return resource;
269
+ }
270
+ // 如果resource.advanced 为 null 或者 resource.advanced.unit 为 0,则不进行修正
271
+ if (!resource.advanced || resource.advanced.unit === 0) {
272
+ return resource;
273
+ }
274
+ var resourceStartTime = dayjs(resource.start_time);
275
+
276
+ // 过滤和修正时间段
277
+ var correctedTimes = resource.times.map(function (timeSlot) {
278
+ if (!timeSlot.start_at || !timeSlot.end_at) {
279
+ return timeSlot;
280
+ }
281
+ var startAt = dayjs(timeSlot.start_at);
282
+ var endAt = dayjs(timeSlot.end_at);
283
+
284
+ // 如果 start_at 早于资源的 start_time,需要修正
285
+ if (startAt.isBefore(resourceStartTime)) {
286
+ // 将 start_time 向上取整到下一个10分钟整数
287
+ var roundedStartTime = _this2.roundUpToNext10Minutes(resourceStartTime);
288
+ var roundedStartTimeDayjs = dayjs(roundedStartTime);
289
+ console.log("[DateModule] \u4FEE\u6B63\u65F6\u95F4\u6BB5\u5F00\u59CB\u65F6\u95F4: ".concat(timeSlot.start_at, " -> ").concat(roundedStartTime, " (\u8D44\u6E90ID: ").concat(resource.id, ", \u539F\u59CBstart_time: ").concat(resource.start_time, ")"));
290
+
291
+ // 将 start_at 修正为向上取整后的时间
292
+ var correctedTimeSlot = _objectSpread(_objectSpread({}, timeSlot), {}, {
293
+ start_at: roundedStartTime
294
+ });
295
+
296
+ // 检查修正后的 end_at 是否也早于修正后的 start_time
297
+ if (endAt.isBefore(roundedStartTimeDayjs)) {
298
+ console.log("[DateModule] \u65F6\u95F4\u6BB5\u65E0\u6548\uFF0C\u5C06\u88AB\u5220\u9664: ".concat(timeSlot.start_at, " - ").concat(timeSlot.end_at, " (\u8D44\u6E90ID: ").concat(resource.id, ", \u4FEE\u6B63\u540Estart_time: ").concat(roundedStartTime, ")"));
299
+ return null; // 标记为删除
300
+ }
301
+ return correctedTimeSlot;
302
+ }
303
+
304
+ // 不需要修正的时间段直接返回
305
+ return timeSlot;
306
+ }).filter(function (timeSlot) {
307
+ return timeSlot !== null;
308
+ }); // 过滤掉被删除的时间段
309
+
310
+ return _objectSpread(_objectSpread({}, resource), {}, {
311
+ times: correctedTimes
312
+ });
313
+ });
314
+ }
223
315
  }, {
224
316
  key: "getResourceAvailableTimeList",
225
317
  value: function () {
@@ -70,6 +70,9 @@ export interface Discount {
70
70
  limited_relation_product_data: Limitedrelationproductdata;
71
71
  balance: string;
72
72
  format_title: Formattitle;
73
+ metadata?: {
74
+ discount_card_type?: 'fixed_amount' | 'percent';
75
+ };
73
76
  product: Product;
74
77
  type: "product" | 'good_pass';
75
78
  resource_id?: number;
@@ -5,6 +5,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
5
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
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
+ 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; }
9
+ 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; }
8
10
  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
11
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
12
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -61,7 +63,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
61
63
  }, {
62
64
  key: "createOrder",
63
65
  value: function createOrder(params) {
64
- var order = {
66
+ var order = _objectSpread({
65
67
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
66
68
  // 要从外面拿,virtual
67
69
  platform: (params === null || params === void 0 ? void 0 : params.platform) === 'pc' ? 'PC' : 'H5',
@@ -73,7 +75,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
73
75
  is_deposit: 0,
74
76
  relation_products: [],
75
77
  relation_forms: []
76
- };
78
+ }, (params === null || params === void 0 ? void 0 : params.extraData) || {});
77
79
  var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
78
80
  if (params.cartItems.length > 0) {
79
81
  params.cartItems.forEach(function (item) {
@@ -16,6 +16,7 @@ export interface CommitOrderParams {
16
16
  cartItems: CartItem[];
17
17
  type: 'virtual' | 'appointment_booking';
18
18
  platform?: 'pc' | 'h5';
19
+ extraData?: Record<string, any>;
19
20
  };
20
21
  }
21
22
  /**
@@ -132,7 +132,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
132
132
  schedule_date: schedule_date,
133
133
  with_schedule: with_schedule,
134
134
  schedule_datetime: schedule_datetime,
135
- application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel
135
+ application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel,
136
+ is_eject: 1
136
137
  }, {
137
138
  useCache: true
138
139
  });
@@ -141,9 +142,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
141
142
  sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
142
143
  return Number(b.sort) - Number(a.sort);
143
144
  });
145
+ if (sortedList.length) {
146
+ sortedList.forEach(function (n) {
147
+ if (n.is_eject !== 1 && n['schedule.ids'] && n['schedule.ids'].length) {
148
+ n.is_eject = 1;
149
+ }
150
+ });
151
+ }
144
152
  this.addProduct(sortedList);
145
153
  return _context3.abrupt("return", sortedList);
146
- case 10:
154
+ case 11:
147
155
  case "end":
148
156
  return _context3.stop();
149
157
  }
@@ -25,7 +25,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
25
25
  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); }
26
26
  import { BaseModule } from "../BaseModule";
27
27
  import { RulesHooks } from "./types";
28
- import { uniqueById } from "../../solution/ShopDiscount/utils";
28
+ import { uniqueById, getDiscountAmount } from "../../solution/ShopDiscount/utils";
29
29
  import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
30
30
  import Decimal from 'decimal.js';
31
31
  import { isBoolean } from 'lodash-es';
@@ -189,8 +189,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
189
189
  });
190
190
 
191
191
  // 优惠力度排序,传进来的数据里可能有商品券,也可能有优惠券
192
- // 商品券(n.tag=good_pass)视为最优惠(免费),折扣券(n.tag=product_discount_card)按照n.par_value排序
193
- // 如果最后拍出来商品券有多个,或者说没有商品券,但是有多个相同折扣的折扣券(比如 6 折券有 3张),则按照过期时间(n.expire_time)排序
192
+ // 1. 商品券(n.tag=good_pass)视为最优惠(免费)
193
+ // 2. 折扣券(n.tag=product_discount_card)按照新的优先级排序:
194
+ // - 固定金额优先于百分比(固定金额 > 百分比)
195
+ // - 固定金额内部:金额越大越优先
196
+ // - 百分比内部:折扣越大越优先(par_value越小越优先)
197
+ // 3. 相同类型和金额的情况下,按照过期时间(n.expire_time)排序
194
198
  var sortedDiscountList = _toConsumableArray(filteredDiscountList).sort(function (a, b) {
195
199
  // 1. 商品券优先级最高
196
200
  if (a.tag === 'good_pass' && b.tag !== 'good_pass') return -1;
@@ -201,13 +205,34 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
201
205
  // 都是商品券,按照过期时间排序
202
206
  return compareByExpireTime(a, b);
203
207
  } else if (a.tag === 'product_discount_card' && b.tag === 'product_discount_card') {
204
- // 都是折扣券,按照par_value排序(折扣越大越优先,即par_value越小越优先)
205
- if (a.par_value !== b.par_value) {
206
- var valueA = new Decimal(100).minus(a.par_value || 0);
207
- var valueB = new Decimal(100).minus(b.par_value || 0);
208
- return valueA.minus(valueB).toNumber();
208
+ var _a$metadata, _b$metadata;
209
+ // 都是折扣券,按照新的优先级排序:固定金额优先于百分比
210
+ var typeA = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 ? void 0 : _a$metadata.discount_card_type) || 'percent'; // 默认为百分比
211
+ var typeB = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 ? void 0 : _b$metadata.discount_card_type) || 'percent'; // 默认为百分比
212
+
213
+ // 1. 固定金额优先于百分比
214
+ if (typeA === 'fixed_amount' && typeB === 'percent') return -1;
215
+ if (typeA === 'percent' && typeB === 'fixed_amount') return 1;
216
+
217
+ // 2. 都是固定金额时,金额越大越优先
218
+ if (typeA === 'fixed_amount' && typeB === 'fixed_amount') {
219
+ if (a.par_value !== b.par_value) {
220
+ var valueA = new Decimal(a.par_value || 0);
221
+ var valueB = new Decimal(b.par_value || 0);
222
+ return valueB.minus(valueA).toNumber(); // 金额大的在前
223
+ }
209
224
  }
210
- // 相同折扣的情况下,按照过期时间排序
225
+
226
+ // 3. 都是百分比时,折扣越大越优先(par_value越小越优先)
227
+ if (typeA === 'percent' && typeB === 'percent') {
228
+ if (a.par_value !== b.par_value) {
229
+ var _valueA = new Decimal(100).minus(a.par_value || 0);
230
+ var _valueB = new Decimal(100).minus(b.par_value || 0);
231
+ return _valueB.minus(_valueA).toNumber(); // 折扣大的在前
232
+ }
233
+ }
234
+
235
+ // 相同类型和金额的情况下,按照过期时间排序
211
236
  return compareByExpireTime(a, b);
212
237
  }
213
238
 
@@ -291,7 +316,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
291
316
 
292
317
  // 判断优惠券是否适用于该商品
293
318
  if (isAvailableProduct && isLimitedProduct) {
294
- var _discountApplicabilit;
319
+ var _discountApplicabilit, _discount$metadata;
295
320
  // 记录此优惠券适用的商品
296
321
  (_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
297
322
 
@@ -303,6 +328,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
303
328
  type: discountType,
304
329
  tag: discountType,
305
330
  discount: {
331
+ discount_card_type: discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type,
332
+ fixed_amount: product.price,
306
333
  resource_id: discount.id,
307
334
  title: discount.format_title,
308
335
  original_amount: product.origin_total,
@@ -435,7 +462,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
435
462
  }));
436
463
  }
437
464
  for (var i = 0; i < splitCount; i++) {
438
- var _product$discount_lis11, _originProduct$_produ;
465
+ var _product$discount_lis11, _originProduct$_produ, _selectedDiscount$met;
439
466
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
440
467
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
441
468
  // 标记优惠券为已使用
@@ -456,12 +483,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
456
483
  }
457
484
 
458
485
  // 计算使用折扣卡/商品券以后,单个商品的总 total
459
- var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(productOriginTotal).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(productOriginTotal)).toNumber();
486
+ var targetProductTotal = getDiscountAmount(_selectedDiscount, productOriginTotal, product.price);
460
487
  var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
461
488
  var discountDetail = {
462
489
  amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
463
490
  type: discountType,
464
491
  discount: {
492
+ discount_card_type: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met = _selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
493
+ fixed_amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
465
494
  resource_id: _selectedDiscount.id,
466
495
  title: _selectedDiscount.format_title,
467
496
  original_amount: productOriginTotal,
@@ -49,6 +49,7 @@ export interface RequestOptions {
49
49
  responseType?: 'json' | 'text' | 'arraybuffer' | 'blob';
50
50
  withCredentials?: boolean;
51
51
  useCache?: boolean;
52
+ customToast?: () => void;
52
53
  }
53
54
  /**
54
55
  * 响应接口
@@ -166,7 +166,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
166
166
  * @returns boolean
167
167
  */
168
168
  checkBeforeSubmitOrder(type: 'holder' | 'account'): boolean;
169
- submitOrder(): Promise<void>;
169
+ submitOrder(extraData?: Record<string, any>): Promise<void>;
170
170
  pay(): Promise<void>;
171
171
  getPayInfo(): Promise<void>;
172
172
  setOtherParams(params: Record<string, any>, { cover }?: {
@@ -180,7 +180,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
180
180
  * @param {ProductData} productData
181
181
  * @memberof BookingByStepImpl
182
182
  */
183
- storeProduct(productData: ProductData): Promise<void>;
183
+ storeProduct(productData: ProductData): {
184
+ success: boolean;
185
+ errorCode?: string;
186
+ };
184
187
  /**
185
188
  * 往购物车加商品数据
186
189
  *
@@ -203,7 +206,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
203
206
  endTime: string;
204
207
  } | null;
205
208
  account?: Account | null;
206
- }): void;
209
+ }): {
210
+ success: boolean;
211
+ errorCode?: string;
212
+ };
207
213
  /**
208
214
  * 添加完购物车以后做的一些检测,比如日期是否在同一天
209
215
  *
@@ -294,8 +300,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
294
300
  };
295
301
  getTimeSlotByAllResources(resources_code: string): any[];
296
302
  submitTimeSlot(timeSlots: TimeSliceItem): void;
297
- clearCache(): void;
298
- clearCacheByModule(module: string): void;
299
303
  private getScheduleDataByIds;
300
304
  openProductDetail(productId: number): Promise<void>;
301
305
  closeProductDetail(): void;
@@ -312,6 +316,30 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
312
316
  count: number;
313
317
  left: number;
314
318
  }[];
319
+ /**
320
+ * 找到多个资源的公共可用时间段
321
+ */
322
+ private findCommonAvailableTimeSlots;
323
+ checkMaxDurationCapacity(): {
324
+ success: boolean;
325
+ minAvailableCount: number;
326
+ };
327
+ /**
328
+ * 将 ProductData 转换为 CartItem,但不添加到购物车
329
+ * 参考 addProductToCart 方法的实现
330
+ */
331
+ private convertProductToCartItem;
332
+ checkMaxDurationCapacityForDetailNums({ product, date, account, }: {
333
+ product: ProductData;
334
+ date?: {
335
+ startTime: string;
336
+ endTime: string;
337
+ } | null;
338
+ account?: Account | null;
339
+ }): {
340
+ success: boolean;
341
+ minAvailableCount: number;
342
+ };
315
343
  setOtherData(key: string, value: any): void;
316
344
  getOtherData(key: string): any;
317
345
  getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
@@ -346,4 +374,8 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
346
374
  isCartHasDurationProduct(): boolean;
347
375
  isTargetNormalProduct(product: ProductData): boolean;
348
376
  isTargetCartIdNormalProduct(id: string): boolean | undefined;
377
+ /**
378
+ * 获取联系信息
379
+ */
380
+ getContactInfo(params: any): Promise<any>;
349
381
  }