@pisell/pisellos 3.0.78 → 3.0.79

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 (37) hide show
  1. package/dist/modules/Cart/types.d.ts +2 -0
  2. package/dist/modules/Cart/utils/cartProduct.js +21 -1
  3. package/dist/modules/Cart/utils/changePrice.js +6 -0
  4. package/dist/modules/Date/index.d.ts +1 -1
  5. package/dist/modules/Date/index.js +16 -8
  6. package/dist/modules/Discount/index.d.ts +1 -0
  7. package/dist/modules/Discount/index.js +2 -1
  8. package/dist/modules/Rules/index.js +14 -14
  9. package/dist/modules/Schedule/index.d.ts +9 -0
  10. package/dist/modules/Schedule/index.js +76 -0
  11. package/dist/modules/Summary/index.d.ts +3 -0
  12. package/dist/modules/Summary/index.js +134 -15
  13. package/dist/modules/Summary/types.d.ts +7 -0
  14. package/dist/modules/Summary/utils.d.ts +104 -1
  15. package/dist/modules/Summary/utils.js +1131 -13
  16. package/dist/solution/BookingByStep/index.d.ts +4 -7
  17. package/dist/solution/BookingByStep/index.js +232 -119
  18. package/dist/solution/ShopDiscount/index.js +2 -1
  19. package/lib/modules/Cart/types.d.ts +2 -0
  20. package/lib/modules/Cart/utils/cartProduct.js +16 -1
  21. package/lib/modules/Cart/utils/changePrice.js +5 -0
  22. package/lib/modules/Date/index.d.ts +1 -1
  23. package/lib/modules/Date/index.js +7 -1
  24. package/lib/modules/Discount/index.d.ts +1 -0
  25. package/lib/modules/Discount/index.js +2 -1
  26. package/lib/modules/Rules/index.js +3 -3
  27. package/lib/modules/Schedule/index.d.ts +9 -0
  28. package/lib/modules/Schedule/index.js +60 -0
  29. package/lib/modules/Summary/index.d.ts +3 -0
  30. package/lib/modules/Summary/index.js +61 -2
  31. package/lib/modules/Summary/types.d.ts +7 -0
  32. package/lib/modules/Summary/utils.d.ts +104 -1
  33. package/lib/modules/Summary/utils.js +673 -8
  34. package/lib/solution/BookingByStep/index.d.ts +4 -7
  35. package/lib/solution/BookingByStep/index.js +189 -90
  36. package/lib/solution/ShopDiscount/index.js +2 -1
  37. package/package.json +1 -1
@@ -1,4 +1,7 @@
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 _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); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
2
5
  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
6
  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
7
  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); }); }; }
@@ -15,8 +18,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
15
18
  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; }
16
19
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
20
  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); }
21
+ import Decimal from 'decimal.js';
18
22
  import { BaseModule } from "../BaseModule";
19
- import { calculatePriceDetails } from "./utils";
23
+ import { ScheduleModule } from "../Schedule";
24
+ import { calculatePriceDetails, getSurcharge, getSurchargeAmount, getTax } from "./utils";
20
25
  export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
21
26
  _inherits(SummaryModule, _BaseModule);
22
27
  var _super = _createSuper(SummaryModule);
@@ -62,6 +67,9 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
62
67
  }
63
68
  throw new Error('SummaryModule 需要 shopStore 插件支持');
64
69
  case 9:
70
+ // 加载当前店铺附加费
71
+ this.getSurchargeList();
72
+ case 10:
65
73
  case "end":
66
74
  return _context.stop();
67
75
  }
@@ -73,24 +81,72 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
73
81
  return initialize;
74
82
  }()
75
83
  }, {
76
- key: "getSummary",
84
+ key: "getSurchargeList",
77
85
  value: function () {
78
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(cartItems) {
79
- var _this$shopStore$get;
80
- var shopInfo, summary;
86
+ var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
87
+ var surchargeList;
81
88
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
82
89
  while (1) switch (_context2.prev = _context2.next) {
83
90
  case 0:
84
- shopInfo = ((_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.shop) || {};
85
- summary = calculatePriceDetails(shopInfo, cartItems);
86
- this.store.summary = summary;
87
- return _context2.abrupt("return", this.store.summary);
91
+ _context2.next = 2;
92
+ return this.request.get('/order/custom-surcharge/available/v2', {
93
+ channel: 'online-store',
94
+ is_assemble_product_data: 1,
95
+ is_assemble_schedule_data: 1,
96
+ with: ['relationSchedule']
97
+ });
98
+ case 2:
99
+ surchargeList = _context2.sent;
100
+ this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
88
101
  case 4:
89
102
  case "end":
90
103
  return _context2.stop();
91
104
  }
92
105
  }, _callee2, this);
93
106
  }));
107
+ function getSurchargeList() {
108
+ return _getSurchargeList.apply(this, arguments);
109
+ }
110
+ return getSurchargeList;
111
+ }()
112
+ }, {
113
+ key: "getSummary",
114
+ value: function () {
115
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(cartItems) {
116
+ var _this$shopStore$get;
117
+ var shopInfo, scheduleModule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary;
118
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
119
+ while (1) switch (_context3.prev = _context3.next) {
120
+ case 0:
121
+ shopInfo = ((_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.shop) || {};
122
+ scheduleModule = this.core.getModule('appointmentBooking_schedule');
123
+ needScheduleIds = this.store.surchargeList.map(function (item) {
124
+ return item.available_schedule_ids;
125
+ }).flat();
126
+ scheduleList = scheduleModule === null || scheduleModule === void 0 ? void 0 : scheduleModule.getScheduleListByIds(needScheduleIds);
127
+ scheduleById = {};
128
+ if (Array.isArray(scheduleList)) {
129
+ _iterator = _createForOfIteratorHelper(scheduleList);
130
+ try {
131
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
132
+ item = _step.value;
133
+ scheduleById[item.id] = item;
134
+ }
135
+ } catch (err) {
136
+ _iterator.e(err);
137
+ } finally {
138
+ _iterator.f();
139
+ }
140
+ }
141
+ summary = calculatePriceDetails(shopInfo, cartItems, ScheduleModule === null || ScheduleModule === void 0 ? void 0 : ScheduleModule.isInScheduleByDate, this.store.surchargeList, scheduleById);
142
+ this.store.summary = summary;
143
+ return _context3.abrupt("return", this.store.summary);
144
+ case 9:
145
+ case "end":
146
+ return _context3.stop();
147
+ }
148
+ }, _callee3, this);
149
+ }));
94
150
  function getSummary(_x3) {
95
151
  return _getSummary.apply(this, arguments);
96
152
  }
@@ -104,16 +160,16 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
104
160
  }, {
105
161
  key: "getProtocol",
106
162
  value: (function () {
107
- var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(protocolId) {
108
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
109
- while (1) switch (_context3.prev = _context3.next) {
163
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(protocolId) {
164
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
165
+ while (1) switch (_context4.prev = _context4.next) {
110
166
  case 0:
111
- return _context3.abrupt("return", this.request.get("/shop-policy/".concat(protocolId)));
167
+ return _context4.abrupt("return", this.request.get("/shop-policy/".concat(protocolId)));
112
168
  case 1:
113
169
  case "end":
114
- return _context3.stop();
170
+ return _context4.stop();
115
171
  }
116
- }, _callee3, this);
172
+ }, _callee4, this);
117
173
  }));
118
174
  function getProtocol(_x4) {
119
175
  return _getProtocol.apply(this, arguments);
@@ -132,6 +188,69 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
132
188
  });
133
189
  }
134
190
  }
191
+ }, {
192
+ key: "getTaxforUtils",
193
+ value: function getTaxforUtils(items, shopInfo, subtotal) {
194
+ return getTax({
195
+ service: items,
196
+ bookingDetail: null,
197
+ bookingId: undefined
198
+ }, {
199
+ computed: {
200
+ productExpectAmount: subtotal,
201
+ shopDiscount: 0
202
+ },
203
+ isEdit: false,
204
+ tax_rate: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_rate,
205
+ is_price_include_tax: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.is_price_include_tax
206
+ });
207
+ }
208
+ }, {
209
+ key: "getSurchargeforUtils",
210
+ value: function getSurchargeforUtils(items) {
211
+ // const surchargeList = this.store.surchargeList;
212
+ var scheduleModule = this.core.getModule('appointmentBooking_schedule');
213
+ var needScheduleIds = this.store.surchargeList.map(function (item) {
214
+ return item.available_schedule_ids;
215
+ }).flat();
216
+ var scheduleList = scheduleModule === null || scheduleModule === void 0 ? void 0 : scheduleModule.getScheduleListByIds(needScheduleIds);
217
+ var scheduleById = {};
218
+ if (Array.isArray(scheduleList)) {
219
+ var _iterator2 = _createForOfIteratorHelper(scheduleList),
220
+ _step2;
221
+ try {
222
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
223
+ var item = _step2.value;
224
+ scheduleById[item.id] = item;
225
+ }
226
+ } catch (err) {
227
+ _iterator2.e(err);
228
+ } finally {
229
+ _iterator2.f();
230
+ }
231
+ }
232
+ var surchargeList = getSurcharge({
233
+ service: items,
234
+ addons: [],
235
+ bookingDetail: null,
236
+ bookingId: undefined
237
+ }, {
238
+ isEdit: false,
239
+ isInScheduleByDate: ScheduleModule.isInScheduleByDate,
240
+ surcharge_list: this.store.surchargeList,
241
+ scheduleById: scheduleById
242
+ });
243
+ var surchargeAmount = new Decimal(getSurchargeAmount({
244
+ bookingDetail: null,
245
+ bookingId: undefined
246
+ }, surchargeList, {
247
+ isEdit: false
248
+ }));
249
+ return {
250
+ surchargeList: surchargeList,
251
+ surchargeAmount: surchargeAmount.toFixed(2)
252
+ };
253
+ }
135
254
  }]);
136
255
  return SummaryModule;
137
256
  }(BaseModule);
@@ -1,5 +1,6 @@
1
1
  import { CartItem } from '../Cart/types';
2
2
  export interface ISummaryState {
3
+ surchargeList: any[];
3
4
  summary: {
4
5
  /** 商品总价 */
5
6
  subtotal: string | number;
@@ -11,6 +12,12 @@ export interface ISummaryState {
11
12
  totalTaxFee?: string | number;
12
13
  /** 商品价格是否包含费率 */
13
14
  isPriceIncludeTax?: 0 | 1;
15
+ /** 附加费金额 */
16
+ surchargeAmount?: string | number;
17
+ /** 附加费列表 */
18
+ surcharge?: any[];
19
+ /** 税率 */
20
+ taxRate?: string | number;
14
21
  /** 定金 */
15
22
  deposit?: {
16
23
  /** 定金总价 */
@@ -1,12 +1,57 @@
1
1
  import Decimal from 'decimal.js';
2
2
  import { CartItem } from '../Cart/types';
3
3
  import { ISummaryState } from './types';
4
- export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState['summary'];
4
+ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], isInScheduleByDate: any, surchargeList: any[], scheduleById: Record<string, any>) => ISummaryState['summary'];
5
5
  /**
6
6
  * 获取子商品折扣信息
7
7
  * @param item
8
8
  */
9
9
  export declare const getBundleDiscountList: (bundle: any[]) => any[];
10
+ export declare const calcDiscountListDifference: (discountList: any[]) => any;
11
+ export declare const getProductDiscountProductDiscountDifference: (item: CartItem) => any;
12
+ /**
13
+ * 计算订单税费(折扣前/折扣后),并把单品税费信息回写到商品数据上(用于明细展示/后续计算)。
14
+ *
15
+ * - **折扣前税费**:`originTax`
16
+ * - **折扣后税费**:`tax`(会考虑 `computed.shopDiscount` 对每个商品的分摊影响)
17
+ * - **税率/是否含税**:优先取 `bookingDetail.tax_rate` / `bookingDetail.is_price_include_tax`,取不到再回退到 `options.tax_rate` / `options.is_price_include_tax`
18
+ *
19
+ * **副作用(会修改入参商品对象)**:
20
+ * - 主商品:写入 `item.original_tax_fee` / `item.tax_fee`(四舍五入保留两位)
21
+ * - bundle 原价子商品:写入 `bundleItem.original_tax_fee` / `bundleItem.tax_fee`
22
+ * - 加时商品(`relation_details`):写入 `atItem.tax_fee`
23
+ * - 税费舍入差值:追加到最后一个“含税商品”的 `tax_fee_rounding_remainder` / `original_tax_fee_rounding_remainder`
24
+ *
25
+ * @param params 入参集合(RORO)
26
+ * @param params.service 服务商品数组(主商品)。通常是购物车商品结构(可能包含 `bundle` / `relation_details`)
27
+ * @param params.addons 附加商品数组(可选)。结构同商品数组
28
+ * @param params.bookingDetail 订单详情(编辑/详情场景用于读取后端税率配置),可选
29
+ * @param params.bookingId 订单/预约 ID(编辑/详情场景识别用),可选
30
+ * @param options 计算选项
31
+ * @param options.isEdit 是否处于“编辑中”。当前实现不强依赖该值(历史逻辑保留),但建议按真实状态传入
32
+ * @param options.computed 预计算结果(用于折扣分摊)
33
+ * @param options.computed.productExpectAmount 商品期望总金额(用于按比例分摊折扣)
34
+ * @param options.computed.shopDiscount 店铺折扣总额(用于按比例分摊到商品)
35
+ * @param options.tax_rate 管理端税率(百分比,如 5 表示 5%)。仅当 `bookingDetail.tax_rate` 不存在时生效
36
+ * @param options.is_price_include_tax 是否含税:`0` 不含税、`1` 含税。仅当 `bookingDetail.is_price_include_tax` 不存在时生效
37
+ * @returns 税费汇总(number,金额单位与商品价格一致,四舍五入保留两位)
38
+ * @returns.originTax 折扣前税费合计
39
+ * @returns.tax 折扣后税费合计
40
+ */
41
+ export declare const getTax: ({ service, addons, bookingDetail, bookingId }: {
42
+ service?: any;
43
+ addons?: any;
44
+ bookingDetail?: any;
45
+ bookingId?: number | undefined;
46
+ }, options: {
47
+ isEdit: boolean;
48
+ computed: Record<string, number | string>;
49
+ tax_rate?: number;
50
+ is_price_include_tax?: number;
51
+ } & Record<string, any>) => {
52
+ originTax: number;
53
+ tax: number;
54
+ };
10
55
  /**
11
56
  * 计算商品小计(不含其他费用)
12
57
  * @param items - 购物车商品数组
@@ -32,3 +77,61 @@ export declare const calculateDeposit: (items: CartItem[]) => {
32
77
  protocols: any[];
33
78
  hasDeposit: never;
34
79
  } | undefined;
80
+ /**
81
+ * 计算订单附加费金额(订单级别合计)。
82
+ *
83
+ * - **详情未编辑**(`!options.isEdit && bookingId`)且存在后端详情时:直接返回 `bookingDetail.surcharge_fee`
84
+ * - **新增/编辑**时:对 `surcharge`(通常为 `getSurcharge` 的返回值)按 `item.value` 求和
85
+ *
86
+ * @param params 入参集合(RORO)
87
+ * @param params.bookingDetail 订单详情(详情未编辑时用于读取后端的 `surcharge_fee`),可选
88
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
89
+ * @param surcharge 附加费列表(通常来自 `getSurcharge`),元素结构至少包含 `value: number`
90
+ * @param options 计算选项
91
+ * @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
92
+ * @returns 订单附加费金额(number,金额单位与商品价格一致)
93
+ */
94
+ export declare const getSurchargeAmount: ({ bookingDetail, bookingId }: {
95
+ bookingDetail?: any;
96
+ bookingId?: number | undefined;
97
+ }, surcharge: any[], options: any) => any;
98
+ /**
99
+ * 订单附加费各项信息
100
+ *
101
+ * - **详情未编辑**(`!options.isEdit && bookingId`)时:直接返回 `bookingDetail.surcharge`(后端计算结果)
102
+ * - **新增/编辑**时:按 `options.surcharge_list` 逐条配置计算本次订单的附加费
103
+ *
104
+ * 规则要点:
105
+ * - 匹配范围包含:主商品(`service`)、原价 bundle 子商品(`item.bundle`)、加时商品(`item.relation_details`)、以及 addons(`addons.value`)
106
+ * - 固定附加费 `fixed`:只加一次,再按商品数量分摊(向下取整保留两位),剩余小数会以 `surcharge_rounding_remainder` 形式抹平到最后一个商品
107
+ * - 百分比附加费 `percentage`:按每个商品(价格 * 数量)分别计算再累加
108
+ * - 当 `open_product === 0`:不回写到商品,只在订单级别累加;否则会把单品附加费回写到商品
109
+ *
110
+ * **副作用(可能修改入参商品对象)**:
111
+ * - 当 `open_product !== 0` 时:写入 `item.surcharge_fee`(单品单数量附加费,保留两位、向下取整)
112
+ * - 写入 `item.relation_surcharge_ids`(关联到的 surcharge 配置 id 列表)
113
+ * - 写入 `item.surcharge_rounding_remainder`(用于抹平固定附加费/总额舍入差)
114
+ *
115
+ * @param params 入参集合(RORO)
116
+ * @param params.service 服务商品数组(主商品)。元素可能包含 `bundle` / `relation_details`
117
+ * @param params.addons 附加商品容器。当前实现读取 `addons.value` 作为商品数组(所以通常传 `{ value: CartItem[] }`)
118
+ * @param params.bookingDetail 订单详情(详情未编辑时用于直接取后端的 surcharge 列表),可选
119
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
120
+ * @param options 计算选项
121
+ * @param options.isEdit 是否处于“编辑中”。`false` 且存在 `bookingId` 时会走详情直取逻辑
122
+ * @param options.surcharge_list 附加费配置列表(后端下发)。缺失/为空则返回空数组
123
+ * @param options.isInScheduleByDate 判断日期是否落在某个 schedule 内的方法(通常来自 ScheduleModule)
124
+ * @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
125
+ * @returns 附加费列表(仅返回金额 > 0 的项)
126
+ */
127
+ export declare const getSurcharge: ({ service, addons, bookingDetail, bookingId }: {
128
+ service: any;
129
+ addons: any;
130
+ bookingDetail?: any;
131
+ bookingId?: number | undefined;
132
+ }, options: {
133
+ isEdit: boolean;
134
+ isInScheduleByDate: any;
135
+ surcharge_list?: any[];
136
+ scheduleById?: Record<string, any>;
137
+ } & Record<string, any>) => any;