@pisell/pisellos 0.0.103 → 0.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Cart/index.js +29 -3
- package/dist/modules/Cart/types.d.ts +6 -0
- package/dist/modules/Cart/utils.d.ts +2 -0
- package/dist/modules/Cart/utils.js +30 -3
- package/dist/modules/Order/index.d.ts +3 -1
- package/dist/modules/Order/index.js +26 -5
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +10 -2
- package/dist/solution/BookingByStep/index.js +106 -30
- package/lib/modules/Cart/index.js +20 -2
- package/lib/modules/Cart/types.d.ts +6 -0
- package/lib/modules/Cart/utils.d.ts +2 -0
- package/lib/modules/Cart/utils.js +22 -5
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +18 -5
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +10 -2
- package/lib/solution/BookingByStep/index.js +70 -25
- package/package.json +1 -1
|
@@ -112,7 +112,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
112
112
|
key: "addItem",
|
|
113
113
|
value: (function () {
|
|
114
114
|
var _addItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
115
|
-
var account, product, bundle, options, date, cartItem, items;
|
|
115
|
+
var account, product, bundle, options, date, cartItem, targetVariant, items;
|
|
116
116
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
117
117
|
while (1) switch (_context2.prev = _context2.next) {
|
|
118
118
|
case 0:
|
|
@@ -122,6 +122,18 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
122
122
|
_origin: createCartItemOrigin()
|
|
123
123
|
};
|
|
124
124
|
if (product) {
|
|
125
|
+
// 判断组合商品,然后直接修改 product 里的价格和 is_charge_tax
|
|
126
|
+
if (product.product_variant_id) {
|
|
127
|
+
// 还需要判断 能从 variant 里找到对应的组合规格信息,才可以替换
|
|
128
|
+
targetVariant = product.variant.find(function (n) {
|
|
129
|
+
return n.id === product.product_variant_id;
|
|
130
|
+
});
|
|
131
|
+
if (targetVariant) {
|
|
132
|
+
product.price = targetVariant.price;
|
|
133
|
+
product.original_price = targetVariant.original_price;
|
|
134
|
+
product.is_charge_tax = targetVariant.is_charge_tax;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
125
137
|
cartItem._productOrigin = cloneDeep(product);
|
|
126
138
|
cartItem._productInit = cloneDeep(product);
|
|
127
139
|
cartItem._bundleOrigin = cloneDeep(bundle);
|
|
@@ -130,7 +142,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
130
142
|
cartItem: cartItem,
|
|
131
143
|
product: product,
|
|
132
144
|
bundle: bundle,
|
|
133
|
-
options: options
|
|
145
|
+
options: options,
|
|
146
|
+
product_variant_id: product.product_variant_id
|
|
134
147
|
});
|
|
135
148
|
}
|
|
136
149
|
if (account) {
|
|
@@ -234,6 +247,18 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
234
247
|
tempCartItem = cartItem;
|
|
235
248
|
}
|
|
236
249
|
if (product) {
|
|
250
|
+
// 判断组合商品,然后直接修改 product 里的价格和 is_charge_tax
|
|
251
|
+
if (product.product_variant_id) {
|
|
252
|
+
// 还需要判断 能从 variant 里找到对应的组合规格信息,才可以替换
|
|
253
|
+
var targetVariant = product.variant.find(function (n) {
|
|
254
|
+
return n.id === product.product_variant_id;
|
|
255
|
+
});
|
|
256
|
+
if (targetVariant) {
|
|
257
|
+
product.price = targetVariant.price;
|
|
258
|
+
product.original_price = targetVariant.original_price;
|
|
259
|
+
product.is_charge_tax = targetVariant.is_charge_tax;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
237
262
|
tempCartItem._productOrigin = cloneDeep(product);
|
|
238
263
|
tempCartItem._bundleOrigin = cloneDeep(bundle);
|
|
239
264
|
tempCartItem._optionsOrigin = cloneDeep(options);
|
|
@@ -241,7 +266,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
241
266
|
cartItem: tempCartItem,
|
|
242
267
|
product: product,
|
|
243
268
|
bundle: bundle,
|
|
244
|
-
options: options
|
|
269
|
+
options: options,
|
|
270
|
+
product_variant_id: product.product_variant_id
|
|
245
271
|
});
|
|
246
272
|
}
|
|
247
273
|
if (discounts) {
|
|
@@ -140,6 +140,8 @@ export interface CartItem {
|
|
|
140
140
|
_bundleOrigin?: any[];
|
|
141
141
|
/** 商品规格原始数据 */
|
|
142
142
|
_optionsOrigin?: any[];
|
|
143
|
+
/** 商品规格组合字符串,提供给 UI 展示的 */
|
|
144
|
+
product_option_string?: string;
|
|
143
145
|
}
|
|
144
146
|
/**
|
|
145
147
|
* 购物车状态接口
|
|
@@ -168,6 +170,8 @@ export interface IAddItemParams {
|
|
|
168
170
|
/** 结束时间 */
|
|
169
171
|
endTime: string;
|
|
170
172
|
};
|
|
173
|
+
/** 商品组合规格ID */
|
|
174
|
+
product_variant_id?: number;
|
|
171
175
|
}
|
|
172
176
|
/**
|
|
173
177
|
* 更新购物车信息参数
|
|
@@ -209,6 +213,8 @@ export interface IUpdateItemParams {
|
|
|
209
213
|
/** 关联表单记录ID */
|
|
210
214
|
form_record_ids: number[];
|
|
211
215
|
}[];
|
|
216
|
+
/** 商品组合规格ID */
|
|
217
|
+
product_variant_id?: number;
|
|
212
218
|
}
|
|
213
219
|
/**
|
|
214
220
|
* 折扣
|
|
@@ -40,12 +40,14 @@ export declare const formatProductToCartItem: (params: {
|
|
|
40
40
|
product: ProductData;
|
|
41
41
|
bundle?: any;
|
|
42
42
|
options?: any;
|
|
43
|
+
product_variant_id?: number;
|
|
43
44
|
}) => CartItem;
|
|
44
45
|
export declare const formatProductToCartItemOrigin: (params: {
|
|
45
46
|
cartItem: CartItem;
|
|
46
47
|
product: ProductData;
|
|
47
48
|
bundle?: any;
|
|
48
49
|
options?: any;
|
|
50
|
+
product_variant_id?: number;
|
|
49
51
|
}) => any;
|
|
50
52
|
/**
|
|
51
53
|
* 格式化折扣到购物车
|
|
@@ -79,7 +79,8 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
79
79
|
var cartItem = params.cartItem,
|
|
80
80
|
product = params.product,
|
|
81
81
|
bundle = params.bundle,
|
|
82
|
-
options = params.options
|
|
82
|
+
options = params.options,
|
|
83
|
+
product_variant_id = params.product_variant_id;
|
|
83
84
|
var num = 1; // 当前按照单个商品加入购物车
|
|
84
85
|
if (product) {
|
|
85
86
|
cartItem.id = product === null || product === void 0 ? void 0 : product.id;
|
|
@@ -110,6 +111,31 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
110
111
|
if (options !== null && options !== void 0 && options.length) {
|
|
111
112
|
cartItem.options = formatOptions(options);
|
|
112
113
|
}
|
|
114
|
+
// 拼装出 product_option_string
|
|
115
|
+
if (product_variant_id) {
|
|
116
|
+
var _product$variant$find;
|
|
117
|
+
var sku_key = (_product$variant$find = product.variant.find(function (n) {
|
|
118
|
+
return n.id === product_variant_id;
|
|
119
|
+
})) === null || _product$variant$find === void 0 ? void 0 : _product$variant$find.sku_key;
|
|
120
|
+
if (sku_key) {
|
|
121
|
+
var sku_key_arr = sku_key.split('_');
|
|
122
|
+
var product_option_string = [];
|
|
123
|
+
sku_key_arr.forEach(function (item) {
|
|
124
|
+
var _targetVariantGroup$v;
|
|
125
|
+
var keyMap = item.split(':');
|
|
126
|
+
var targetVariantGroup = product.variant_group.find(function (n) {
|
|
127
|
+
return String(n.position_id) === keyMap[0];
|
|
128
|
+
});
|
|
129
|
+
var targetVariantItem = targetVariantGroup === null || targetVariantGroup === void 0 || (_targetVariantGroup$v = targetVariantGroup.variant_item) === null || _targetVariantGroup$v === void 0 ? void 0 : _targetVariantGroup$v.find(function (n) {
|
|
130
|
+
return String(n.position_id) === keyMap[1];
|
|
131
|
+
});
|
|
132
|
+
if (targetVariantGroup && targetVariantItem) {
|
|
133
|
+
product_option_string.push("".concat(targetVariantGroup.name, ":").concat(targetVariantItem.name));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
cartItem.product_option_string = product_option_string.join(', ');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
113
139
|
|
|
114
140
|
// 如果商品有定金规则,则计算定金
|
|
115
141
|
if ((product === null || product === void 0 || (_product$custom_depos = product.custom_deposit_data) === null || _product$custom_depos === void 0 ? void 0 : _product$custom_depos.has_deposit) == 1) {
|
|
@@ -129,14 +155,15 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
|
|
|
129
155
|
var cartItem = params.cartItem,
|
|
130
156
|
product = params.product,
|
|
131
157
|
bundle = params.bundle,
|
|
132
|
-
options = params.options
|
|
158
|
+
options = params.options,
|
|
159
|
+
product_variant_id = params.product_variant_id;
|
|
133
160
|
var origin = cartItem._origin;
|
|
134
161
|
if (product) {
|
|
135
162
|
var _origin$product, _origin$product2, _product$duration, _product$duration2;
|
|
136
163
|
origin.product = _objectSpread(_objectSpread({}, origin.product || {}), {}, {
|
|
137
164
|
num: 1,
|
|
138
165
|
product_id: product.id,
|
|
139
|
-
product_variant_id:
|
|
166
|
+
product_variant_id: product_variant_id || 0,
|
|
140
167
|
product_bundle: ((_origin$product = origin.product) === null || _origin$product === void 0 ? void 0 : _origin$product.product_bundle) || [],
|
|
141
168
|
product_option_item: ((_origin$product2 = origin.product) === null || _origin$product2 === void 0 ? void 0 : _origin$product2.product_option_item) || []
|
|
142
169
|
});
|
|
@@ -10,7 +10,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
10
10
|
constructor(name?: string, version?: string);
|
|
11
11
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
12
12
|
createOrder(params: CommitOrderParams['query']): {
|
|
13
|
-
type:
|
|
13
|
+
type: "virtual" | "appointment_booking";
|
|
14
14
|
platform: string;
|
|
15
15
|
sales_channel: string;
|
|
16
16
|
order_sales_channel: string;
|
|
@@ -18,6 +18,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
18
18
|
shop_note: string;
|
|
19
19
|
schedule_date: string;
|
|
20
20
|
is_deposit: number;
|
|
21
|
+
relation_products: any[];
|
|
22
|
+
relation_forms: any[];
|
|
21
23
|
};
|
|
22
24
|
checkBeforeSubmitOrder(params: {
|
|
23
25
|
cartItems: CartItem[];
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
2
8
|
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
9
|
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
10
|
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); }); }; }
|
|
@@ -55,18 +61,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
55
61
|
key: "createOrder",
|
|
56
62
|
value: function createOrder(params) {
|
|
57
63
|
var order = {
|
|
58
|
-
type: 'appointment_booking',
|
|
64
|
+
type: params.type || 'appointment_booking',
|
|
65
|
+
// 要从外面拿,virtual
|
|
59
66
|
platform: 'H5',
|
|
60
67
|
sales_channel: 'my_pisel',
|
|
61
68
|
order_sales_channel: 'online_store',
|
|
62
69
|
bookings: [],
|
|
63
70
|
shop_note: '',
|
|
64
71
|
schedule_date: '',
|
|
65
|
-
is_deposit: 0
|
|
72
|
+
is_deposit: 0,
|
|
73
|
+
relation_products: [],
|
|
74
|
+
relation_forms: []
|
|
66
75
|
};
|
|
67
76
|
var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
|
|
68
77
|
if (params.cartItems.length > 0) {
|
|
69
78
|
params.cartItems.forEach(function (item) {
|
|
79
|
+
var _item$_productOrigin;
|
|
70
80
|
if (!item._origin.duration) {
|
|
71
81
|
var _generateDuration = generateDuration(item),
|
|
72
82
|
duration = _generateDuration.duration,
|
|
@@ -74,13 +84,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
74
84
|
item._origin.duration = duration;
|
|
75
85
|
item._origin.sub_type = durationType;
|
|
76
86
|
}
|
|
77
|
-
|
|
87
|
+
// 如果 item.extension_type === normal,视为普通商品
|
|
88
|
+
if (((_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.extension_type) === 'normal') {
|
|
89
|
+
var _order$relation_forms;
|
|
90
|
+
order.relation_products.push(item._origin.product);
|
|
91
|
+
var relationForms = item._origin.relation_forms || [];
|
|
92
|
+
(_order$relation_forms = order.relation_forms).push.apply(_order$relation_forms, _toConsumableArray(relationForms));
|
|
93
|
+
delete item._origin.relation_forms;
|
|
94
|
+
} else {
|
|
95
|
+
order.bookings.push(item._origin);
|
|
96
|
+
}
|
|
78
97
|
if (item !== null && item !== void 0 && item.deposit) {
|
|
79
98
|
is_deposit = 1;
|
|
80
99
|
}
|
|
81
100
|
});
|
|
82
|
-
|
|
83
|
-
|
|
101
|
+
if (order.type === 'appointment_booking') {
|
|
102
|
+
var firstCartItem = params.cartItems[0];
|
|
103
|
+
order.schedule_date = firstCartItem.start_date + ' ' + firstCartItem.start_time + ':00';
|
|
104
|
+
}
|
|
84
105
|
order.is_deposit = is_deposit;
|
|
85
106
|
}
|
|
86
107
|
return order;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -167,7 +167,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
167
167
|
holder_id: string;
|
|
168
168
|
resources_code: string | number;
|
|
169
169
|
timeSlots?: TimeSliceItem;
|
|
170
|
-
countMap: Record<number,
|
|
170
|
+
countMap: Record<number, {
|
|
171
|
+
pax: number;
|
|
172
|
+
time: TimeSliceItem;
|
|
173
|
+
}[]>;
|
|
171
174
|
capacity?: number;
|
|
172
175
|
}): {
|
|
173
176
|
selectedResource: any;
|
|
@@ -208,7 +211,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
208
211
|
}): void;
|
|
209
212
|
setOtherData(key: string, value: any): void;
|
|
210
213
|
getOtherData(key: string): any;
|
|
211
|
-
getProductTypeById(id: number): Promise<"
|
|
214
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
212
215
|
/**
|
|
213
216
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
214
217
|
*
|
|
@@ -218,4 +221,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
218
221
|
* @memberof BookingByStepImpl
|
|
219
222
|
*/
|
|
220
223
|
getResourcesByCartItemAndCode(cartItemId: string, resourceCode: string): any;
|
|
224
|
+
getAvailableDateForSession(params?: {
|
|
225
|
+
startDate?: string;
|
|
226
|
+
endDate?: string;
|
|
227
|
+
type?: 'month';
|
|
228
|
+
}): Promise<ITime[]>;
|
|
221
229
|
}
|
|
@@ -233,7 +233,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
233
233
|
return this.request.post("/product/query", {
|
|
234
234
|
open_quotation: 1,
|
|
235
235
|
open_bundle: 0,
|
|
236
|
-
extension_type: ['product_appointment', 'appointment_ticket', 'session_product', 'session_ticket'],
|
|
236
|
+
extension_type: ['product_appointment', 'appointment_ticket', 'session_product', 'session_ticket', 'normal'],
|
|
237
237
|
with: ['category', 'collection', 'resourceRelation'],
|
|
238
238
|
status: 'published',
|
|
239
239
|
num: 500,
|
|
@@ -1060,40 +1060,44 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1060
1060
|
key: "submitOrder",
|
|
1061
1061
|
value: function () {
|
|
1062
1062
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1063
|
-
var cartItems, newCartItems;
|
|
1063
|
+
var cartItems, newCartItems, type;
|
|
1064
1064
|
return _regeneratorRuntime().wrap(function _callee21$(_context22) {
|
|
1065
1065
|
while (1) switch (_context22.prev = _context22.next) {
|
|
1066
1066
|
case 0:
|
|
1067
1067
|
cartItems = this.store.cart.getItems();
|
|
1068
1068
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
1069
1069
|
newCartItems.forEach(function (item) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
item._origin.metadata
|
|
1070
|
+
if (item._origin.resources && item._origin.resources.length) {
|
|
1071
|
+
var _item$_productOrigin, _item$_origin;
|
|
1072
|
+
item._origin.resources = item._origin.resources.map(function (n) {
|
|
1073
|
+
var newResourcesItem = cloneDeep(n);
|
|
1074
|
+
delete newResourcesItem.id;
|
|
1075
|
+
delete newResourcesItem.main_field;
|
|
1076
|
+
delete newResourcesItem.resourceType;
|
|
1077
|
+
return _objectSpread({}, newResourcesItem);
|
|
1078
|
+
});
|
|
1079
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
1080
|
+
capacity: (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.capacity,
|
|
1081
|
+
product_bundle: item._origin.product.product_bundle
|
|
1082
|
+
});
|
|
1083
|
+
var currentCapacity = getSumCapacity({
|
|
1084
|
+
capacity: formatCapacity
|
|
1085
|
+
});
|
|
1086
|
+
if (!((_item$_origin = item._origin) !== null && _item$_origin !== void 0 && _item$_origin.metadata)) {
|
|
1087
|
+
item._origin.metadata = {};
|
|
1088
|
+
}
|
|
1089
|
+
item._origin.metadata.capacity = formatCapacity;
|
|
1090
|
+
item._origin.number = currentCapacity;
|
|
1087
1091
|
}
|
|
1088
|
-
item._origin.metadata.capacity = formatCapacity;
|
|
1089
|
-
item._origin.number = currentCapacity;
|
|
1090
1092
|
});
|
|
1093
|
+
type = this.otherParams.isRetailTemplate ? 'virtual' : 'appointment_booking';
|
|
1091
1094
|
return _context22.abrupt("return", this.store.order.submitOrder({
|
|
1092
1095
|
query: {
|
|
1093
|
-
cartItems: newCartItems
|
|
1096
|
+
cartItems: newCartItems,
|
|
1097
|
+
type: type
|
|
1094
1098
|
}
|
|
1095
1099
|
}));
|
|
1096
|
-
case
|
|
1100
|
+
case 5:
|
|
1097
1101
|
case "end":
|
|
1098
1102
|
return _context22.stop();
|
|
1099
1103
|
}
|
|
@@ -1796,7 +1800,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1796
1800
|
// resourcesUseableMap[n.id] = false;
|
|
1797
1801
|
// continue
|
|
1798
1802
|
// }
|
|
1799
|
-
|
|
1803
|
+
// const recordCount = countMap[n.id] || 0;
|
|
1800
1804
|
// n.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1801
1805
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1802
1806
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
@@ -1807,13 +1811,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1807
1811
|
if (mTimes.length === 0) {
|
|
1808
1812
|
return 0; // continue
|
|
1809
1813
|
}
|
|
1814
|
+
// 计算在时间片内有交集的预约容量总和
|
|
1815
|
+
var totalCapacity = (countMap[n.id] || []).reduce(function (sum, item) {
|
|
1816
|
+
var hasOverlap = !dayjs(item.time.start_at).isAfter(dayjs(timeSlots.start_at)) && !dayjs(item.time.end_at).isBefore(dayjs(timeSlots.end_at));
|
|
1817
|
+
return hasOverlap ? sum + item.pax : sum;
|
|
1818
|
+
}, 0);
|
|
1810
1819
|
var canUseTime = mTimes.find(function (item) {
|
|
1811
1820
|
var _cartItem$_productOri10;
|
|
1812
1821
|
var res = getIsUsableByTimeItem({
|
|
1813
1822
|
timeSlice: timeSlots,
|
|
1814
1823
|
time: item,
|
|
1815
1824
|
resource: n,
|
|
1816
|
-
currentCount:
|
|
1825
|
+
currentCount: totalCapacity + (capacity || 0),
|
|
1817
1826
|
resourcesUseableMap: resourcesUseableMap,
|
|
1818
1827
|
cut_off_time: (_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.cut_off_time
|
|
1819
1828
|
});
|
|
@@ -1884,6 +1893,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1884
1893
|
// 一个账号一个账号处理
|
|
1885
1894
|
var errorList = [];
|
|
1886
1895
|
var selectResourcesMap = {};
|
|
1896
|
+
var selectResourcesWithTimeSlots = {};
|
|
1887
1897
|
var accountList = this.store.accountList.getAccounts();
|
|
1888
1898
|
var selectForCartResources = function selectForCartResources(cartItems) {
|
|
1889
1899
|
var recordTimeSlots = cloneDeep(timeSlots);
|
|
@@ -1916,8 +1926,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1916
1926
|
var currentResourceConfig = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.product_resource) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.resources) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.find(function (n) {
|
|
1917
1927
|
return n.code === resources_code;
|
|
1918
1928
|
});
|
|
1929
|
+
var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
|
|
1919
1930
|
// 只有 duration 类商品需要这个操作
|
|
1920
|
-
if (index !== 0 && recordTimeSlots &&
|
|
1931
|
+
if (index !== 0 && recordTimeSlots && resourceBookingType === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration) {
|
|
1921
1932
|
var _item$_productOrigin$, _item$_productOrigin6, _ref9, _item$_productOrigin7, _item$_productOrigin$2, _item$_productOrigin8, _ref10, _item$_productOrigin9;
|
|
1922
1933
|
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
|
|
1923
1934
|
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
@@ -1934,7 +1945,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1934
1945
|
holder_id: item.holder_id,
|
|
1935
1946
|
resources_code: resources_code,
|
|
1936
1947
|
timeSlots: recordTimeSlots,
|
|
1937
|
-
countMap:
|
|
1948
|
+
countMap: selectResourcesWithTimeSlots,
|
|
1938
1949
|
capacity: currentCapacity
|
|
1939
1950
|
});
|
|
1940
1951
|
// // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
@@ -1942,10 +1953,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1942
1953
|
// return
|
|
1943
1954
|
// }
|
|
1944
1955
|
if (res !== null && res !== void 0 && res.selectedResource) {
|
|
1945
|
-
if (!
|
|
1946
|
-
|
|
1956
|
+
if (!selectResourcesWithTimeSlots[res.selectedResource.id]) {
|
|
1957
|
+
selectResourcesWithTimeSlots[res.selectedResource.id] = [{
|
|
1958
|
+
pax: currentCapacity,
|
|
1959
|
+
time: recordTimeSlots
|
|
1960
|
+
}];
|
|
1947
1961
|
} else {
|
|
1948
|
-
|
|
1962
|
+
selectResourcesWithTimeSlots[res.selectedResource.id].push({
|
|
1963
|
+
pax: currentCapacity,
|
|
1964
|
+
time: recordTimeSlots
|
|
1965
|
+
});
|
|
1949
1966
|
}
|
|
1950
1967
|
res.selectedResource.capacity = currentCapacity;
|
|
1951
1968
|
checkSubResourcesCapacity(res.selectedResource);
|
|
@@ -2584,6 +2601,65 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2584
2601
|
}
|
|
2585
2602
|
return targetResource.renderList;
|
|
2586
2603
|
}
|
|
2604
|
+
}, {
|
|
2605
|
+
key: "getAvailableDateForSession",
|
|
2606
|
+
value: function () {
|
|
2607
|
+
var _getAvailableDateForSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
2608
|
+
var params,
|
|
2609
|
+
startDate,
|
|
2610
|
+
endDate,
|
|
2611
|
+
type,
|
|
2612
|
+
tempProducts,
|
|
2613
|
+
_ref15,
|
|
2614
|
+
resourceIds,
|
|
2615
|
+
rules,
|
|
2616
|
+
resourcesMap,
|
|
2617
|
+
res,
|
|
2618
|
+
_args29 = arguments;
|
|
2619
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
2620
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2621
|
+
case 0:
|
|
2622
|
+
params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
|
|
2623
|
+
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
2624
|
+
startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
2625
|
+
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
2626
|
+
startDate = dayjs().format('YYYY-MM-DD');
|
|
2627
|
+
}
|
|
2628
|
+
// 不管前端传什么 endDate 默认查一个月的,以今天为开始日期。用于找到一个月内最近可用的日期
|
|
2629
|
+
endDate = dayjs().add(1, 'month').format('YYYY-MM-DD');
|
|
2630
|
+
tempProducts = []; // 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
2631
|
+
if (this.store.currentProduct) {
|
|
2632
|
+
tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct.getData()), {}, {
|
|
2633
|
+
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
2634
|
+
})];
|
|
2635
|
+
}
|
|
2636
|
+
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
2637
|
+
_ref15 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref15.resourceIds, rules = _ref15.rules, resourcesMap = _ref15.resourcesMap;
|
|
2638
|
+
this.otherParams.currentResourcesMap = resourcesMap;
|
|
2639
|
+
_context29.next = 10;
|
|
2640
|
+
return this.store.date.getResourceDates({
|
|
2641
|
+
query: {
|
|
2642
|
+
start_date: startDate || '',
|
|
2643
|
+
end_date: endDate || '',
|
|
2644
|
+
resource_ids: resourceIds
|
|
2645
|
+
},
|
|
2646
|
+
rules: rules,
|
|
2647
|
+
type: type
|
|
2648
|
+
});
|
|
2649
|
+
case 10:
|
|
2650
|
+
res = _context29.sent;
|
|
2651
|
+
return _context29.abrupt("return", res);
|
|
2652
|
+
case 12:
|
|
2653
|
+
case "end":
|
|
2654
|
+
return _context29.stop();
|
|
2655
|
+
}
|
|
2656
|
+
}, _callee28, this);
|
|
2657
|
+
}));
|
|
2658
|
+
function getAvailableDateForSession() {
|
|
2659
|
+
return _getAvailableDateForSession.apply(this, arguments);
|
|
2660
|
+
}
|
|
2661
|
+
return getAvailableDateForSession;
|
|
2662
|
+
}()
|
|
2587
2663
|
}]);
|
|
2588
2664
|
return BookingByStepImpl;
|
|
2589
2665
|
}(BaseModule);
|
|
@@ -76,6 +76,14 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
76
76
|
_origin: (0, import_utils.createCartItemOrigin)()
|
|
77
77
|
};
|
|
78
78
|
if (product) {
|
|
79
|
+
if (product.product_variant_id) {
|
|
80
|
+
const targetVariant = product.variant.find((n) => n.id === product.product_variant_id);
|
|
81
|
+
if (targetVariant) {
|
|
82
|
+
product.price = targetVariant.price;
|
|
83
|
+
product.original_price = targetVariant.original_price;
|
|
84
|
+
product.is_charge_tax = targetVariant.is_charge_tax;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
79
87
|
cartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
|
|
80
88
|
cartItem._productInit = (0, import_lodash_es.cloneDeep)(product);
|
|
81
89
|
cartItem._bundleOrigin = (0, import_lodash_es.cloneDeep)(bundle);
|
|
@@ -84,7 +92,8 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
84
92
|
cartItem,
|
|
85
93
|
product,
|
|
86
94
|
bundle,
|
|
87
|
-
options
|
|
95
|
+
options,
|
|
96
|
+
product_variant_id: product.product_variant_id
|
|
88
97
|
});
|
|
89
98
|
}
|
|
90
99
|
if (account) {
|
|
@@ -140,6 +149,14 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
140
149
|
tempCartItem = cartItem;
|
|
141
150
|
}
|
|
142
151
|
if (product) {
|
|
152
|
+
if (product.product_variant_id) {
|
|
153
|
+
const targetVariant = product.variant.find((n) => n.id === product.product_variant_id);
|
|
154
|
+
if (targetVariant) {
|
|
155
|
+
product.price = targetVariant.price;
|
|
156
|
+
product.original_price = targetVariant.original_price;
|
|
157
|
+
product.is_charge_tax = targetVariant.is_charge_tax;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
143
160
|
tempCartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
|
|
144
161
|
tempCartItem._bundleOrigin = (0, import_lodash_es.cloneDeep)(bundle);
|
|
145
162
|
tempCartItem._optionsOrigin = (0, import_lodash_es.cloneDeep)(options);
|
|
@@ -147,7 +164,8 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
147
164
|
cartItem: tempCartItem,
|
|
148
165
|
product,
|
|
149
166
|
bundle,
|
|
150
|
-
options
|
|
167
|
+
options,
|
|
168
|
+
product_variant_id: product.product_variant_id
|
|
151
169
|
});
|
|
152
170
|
}
|
|
153
171
|
if (discounts) {
|
|
@@ -140,6 +140,8 @@ export interface CartItem {
|
|
|
140
140
|
_bundleOrigin?: any[];
|
|
141
141
|
/** 商品规格原始数据 */
|
|
142
142
|
_optionsOrigin?: any[];
|
|
143
|
+
/** 商品规格组合字符串,提供给 UI 展示的 */
|
|
144
|
+
product_option_string?: string;
|
|
143
145
|
}
|
|
144
146
|
/**
|
|
145
147
|
* 购物车状态接口
|
|
@@ -168,6 +170,8 @@ export interface IAddItemParams {
|
|
|
168
170
|
/** 结束时间 */
|
|
169
171
|
endTime: string;
|
|
170
172
|
};
|
|
173
|
+
/** 商品组合规格ID */
|
|
174
|
+
product_variant_id?: number;
|
|
171
175
|
}
|
|
172
176
|
/**
|
|
173
177
|
* 更新购物车信息参数
|
|
@@ -209,6 +213,8 @@ export interface IUpdateItemParams {
|
|
|
209
213
|
/** 关联表单记录ID */
|
|
210
214
|
form_record_ids: number[];
|
|
211
215
|
}[];
|
|
216
|
+
/** 商品组合规格ID */
|
|
217
|
+
product_variant_id?: number;
|
|
212
218
|
}
|
|
213
219
|
/**
|
|
214
220
|
* 折扣
|
|
@@ -40,12 +40,14 @@ export declare const formatProductToCartItem: (params: {
|
|
|
40
40
|
product: ProductData;
|
|
41
41
|
bundle?: any;
|
|
42
42
|
options?: any;
|
|
43
|
+
product_variant_id?: number;
|
|
43
44
|
}) => CartItem;
|
|
44
45
|
export declare const formatProductToCartItemOrigin: (params: {
|
|
45
46
|
cartItem: CartItem;
|
|
46
47
|
product: ProductData;
|
|
47
48
|
bundle?: any;
|
|
48
49
|
options?: any;
|
|
50
|
+
product_variant_id?: number;
|
|
49
51
|
}) => any;
|
|
50
52
|
/**
|
|
51
53
|
* 格式化折扣到购物车
|
|
@@ -109,8 +109,8 @@ var createCartItemOrigin = () => {
|
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
var formatProductToCartItem = (params) => {
|
|
112
|
-
var _a;
|
|
113
|
-
const { cartItem, product, bundle, options } = params;
|
|
112
|
+
var _a, _b;
|
|
113
|
+
const { cartItem, product, bundle, options, product_variant_id } = params;
|
|
114
114
|
const num = 1;
|
|
115
115
|
if (product) {
|
|
116
116
|
cartItem.id = product == null ? void 0 : product.id;
|
|
@@ -136,7 +136,24 @@ var formatProductToCartItem = (params) => {
|
|
|
136
136
|
if (options == null ? void 0 : options.length) {
|
|
137
137
|
cartItem.options = formatOptions(options);
|
|
138
138
|
}
|
|
139
|
-
if (
|
|
139
|
+
if (product_variant_id) {
|
|
140
|
+
const sku_key = (_a = product.variant.find((n) => n.id === product_variant_id)) == null ? void 0 : _a.sku_key;
|
|
141
|
+
if (sku_key) {
|
|
142
|
+
const sku_key_arr = sku_key.split("_");
|
|
143
|
+
const product_option_string = [];
|
|
144
|
+
sku_key_arr.forEach((item) => {
|
|
145
|
+
var _a2;
|
|
146
|
+
const keyMap = item.split(":");
|
|
147
|
+
const targetVariantGroup = product.variant_group.find((n) => String(n.position_id) === keyMap[0]);
|
|
148
|
+
const targetVariantItem = (_a2 = targetVariantGroup == null ? void 0 : targetVariantGroup.variant_item) == null ? void 0 : _a2.find((n) => String(n.position_id) === keyMap[1]);
|
|
149
|
+
if (targetVariantGroup && targetVariantItem) {
|
|
150
|
+
product_option_string.push(`${targetVariantGroup.name}:${targetVariantItem.name}`);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
cartItem.product_option_string = product_option_string.join(", ");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (((_b = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _b.has_deposit) == 1) {
|
|
140
157
|
cartItem.deposit = getProductDeposit({
|
|
141
158
|
cartItem,
|
|
142
159
|
product,
|
|
@@ -151,14 +168,14 @@ var formatProductToCartItem = (params) => {
|
|
|
151
168
|
};
|
|
152
169
|
var formatProductToCartItemOrigin = (params) => {
|
|
153
170
|
var _a, _b, _c, _d;
|
|
154
|
-
const { cartItem, product, bundle, options } = params;
|
|
171
|
+
const { cartItem, product, bundle, options, product_variant_id } = params;
|
|
155
172
|
let origin = cartItem._origin;
|
|
156
173
|
if (product) {
|
|
157
174
|
origin.product = {
|
|
158
175
|
...origin.product || {},
|
|
159
176
|
num: 1,
|
|
160
177
|
product_id: product.id,
|
|
161
|
-
product_variant_id:
|
|
178
|
+
product_variant_id: product_variant_id || 0,
|
|
162
179
|
product_bundle: ((_a = origin.product) == null ? void 0 : _a.product_bundle) || [],
|
|
163
180
|
product_option_item: ((_b = origin.product) == null ? void 0 : _b.product_option_item) || []
|
|
164
181
|
};
|
|
@@ -10,7 +10,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
10
10
|
constructor(name?: string, version?: string);
|
|
11
11
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
12
12
|
createOrder(params: CommitOrderParams['query']): {
|
|
13
|
-
type:
|
|
13
|
+
type: "virtual" | "appointment_booking";
|
|
14
14
|
platform: string;
|
|
15
15
|
sales_channel: string;
|
|
16
16
|
order_sales_channel: string;
|
|
@@ -18,6 +18,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
18
18
|
shop_note: string;
|
|
19
19
|
schedule_date: string;
|
|
20
20
|
is_deposit: number;
|
|
21
|
+
relation_products: any[];
|
|
22
|
+
relation_forms: any[];
|
|
21
23
|
};
|
|
22
24
|
checkBeforeSubmitOrder(params: {
|
|
23
25
|
cartItems: CartItem[];
|
|
@@ -37,30 +37,43 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
37
37
|
}
|
|
38
38
|
createOrder(params) {
|
|
39
39
|
const order = {
|
|
40
|
-
type: "appointment_booking",
|
|
40
|
+
type: params.type || "appointment_booking",
|
|
41
|
+
// 要从外面拿,virtual
|
|
41
42
|
platform: "H5",
|
|
42
43
|
sales_channel: "my_pisel",
|
|
43
44
|
order_sales_channel: "online_store",
|
|
44
45
|
bookings: [],
|
|
45
46
|
shop_note: "",
|
|
46
47
|
schedule_date: "",
|
|
47
|
-
is_deposit: 0
|
|
48
|
+
is_deposit: 0,
|
|
49
|
+
relation_products: [],
|
|
50
|
+
relation_forms: []
|
|
48
51
|
};
|
|
49
52
|
let is_deposit = 0;
|
|
50
53
|
if (params.cartItems.length > 0) {
|
|
51
54
|
params.cartItems.forEach((item) => {
|
|
55
|
+
var _a;
|
|
52
56
|
if (!item._origin.duration) {
|
|
53
57
|
const { duration, durationType } = (0, import_utils.generateDuration)(item);
|
|
54
58
|
item._origin.duration = duration;
|
|
55
59
|
item._origin.sub_type = durationType;
|
|
56
60
|
}
|
|
57
|
-
|
|
61
|
+
if (((_a = item._productOrigin) == null ? void 0 : _a.extension_type) === "normal") {
|
|
62
|
+
order.relation_products.push(item._origin.product);
|
|
63
|
+
const relationForms = item._origin.relation_forms || [];
|
|
64
|
+
order.relation_forms.push(...relationForms);
|
|
65
|
+
delete item._origin.relation_forms;
|
|
66
|
+
} else {
|
|
67
|
+
order.bookings.push(item._origin);
|
|
68
|
+
}
|
|
58
69
|
if (item == null ? void 0 : item.deposit) {
|
|
59
70
|
is_deposit = 1;
|
|
60
71
|
}
|
|
61
72
|
});
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
if (order.type === "appointment_booking") {
|
|
74
|
+
const firstCartItem = params.cartItems[0];
|
|
75
|
+
order.schedule_date = firstCartItem.start_date + " " + firstCartItem.start_time + ":00";
|
|
76
|
+
}
|
|
64
77
|
order.is_deposit = is_deposit;
|
|
65
78
|
}
|
|
66
79
|
return order;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -167,7 +167,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
167
167
|
holder_id: string;
|
|
168
168
|
resources_code: string | number;
|
|
169
169
|
timeSlots?: TimeSliceItem;
|
|
170
|
-
countMap: Record<number,
|
|
170
|
+
countMap: Record<number, {
|
|
171
|
+
pax: number;
|
|
172
|
+
time: TimeSliceItem;
|
|
173
|
+
}[]>;
|
|
171
174
|
capacity?: number;
|
|
172
175
|
}): {
|
|
173
176
|
selectedResource: any;
|
|
@@ -208,7 +211,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
208
211
|
}): void;
|
|
209
212
|
setOtherData(key: string, value: any): void;
|
|
210
213
|
getOtherData(key: string): any;
|
|
211
|
-
getProductTypeById(id: number): Promise<"
|
|
214
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
212
215
|
/**
|
|
213
216
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
214
217
|
*
|
|
@@ -218,4 +221,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
218
221
|
* @memberof BookingByStepImpl
|
|
219
222
|
*/
|
|
220
223
|
getResourcesByCartItemAndCode(cartItemId: string, resourceCode: string): any;
|
|
224
|
+
getAvailableDateForSession(params?: {
|
|
225
|
+
startDate?: string;
|
|
226
|
+
endDate?: string;
|
|
227
|
+
type?: 'month';
|
|
228
|
+
}): Promise<ITime[]>;
|
|
221
229
|
}
|
|
@@ -186,7 +186,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
186
186
|
"product_appointment",
|
|
187
187
|
"appointment_ticket",
|
|
188
188
|
"session_product",
|
|
189
|
-
"session_ticket"
|
|
189
|
+
"session_ticket",
|
|
190
|
+
"normal"
|
|
190
191
|
],
|
|
191
192
|
with: ["category", "collection", "resourceRelation"],
|
|
192
193
|
status: "published",
|
|
@@ -534,25 +535,28 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
534
535
|
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
535
536
|
newCartItems.forEach((item) => {
|
|
536
537
|
var _a, _b;
|
|
537
|
-
item._origin.resources
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
item._origin.metadata
|
|
538
|
+
if (item._origin.resources && item._origin.resources.length) {
|
|
539
|
+
item._origin.resources = item._origin.resources.map((n) => {
|
|
540
|
+
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
541
|
+
delete newResourcesItem.id;
|
|
542
|
+
delete newResourcesItem.main_field;
|
|
543
|
+
delete newResourcesItem.resourceType;
|
|
544
|
+
return { ...newResourcesItem };
|
|
545
|
+
});
|
|
546
|
+
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
547
|
+
capacity: (_a = item._productOrigin) == null ? void 0 : _a.capacity,
|
|
548
|
+
product_bundle: item._origin.product.product_bundle
|
|
549
|
+
});
|
|
550
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
551
|
+
if (!((_b = item._origin) == null ? void 0 : _b.metadata)) {
|
|
552
|
+
item._origin.metadata = {};
|
|
553
|
+
}
|
|
554
|
+
item._origin.metadata.capacity = formatCapacity;
|
|
555
|
+
item._origin.number = currentCapacity;
|
|
551
556
|
}
|
|
552
|
-
item._origin.metadata.capacity = formatCapacity;
|
|
553
|
-
item._origin.number = currentCapacity;
|
|
554
557
|
});
|
|
555
|
-
|
|
558
|
+
const type = this.otherParams.isRetailTemplate ? "virtual" : "appointment_booking";
|
|
559
|
+
return this.store.order.submitOrder({ query: { cartItems: newCartItems, type } });
|
|
556
560
|
}
|
|
557
561
|
// 拉起支付模块
|
|
558
562
|
async pay() {
|
|
@@ -1134,20 +1138,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1134
1138
|
if (timeSlots) {
|
|
1135
1139
|
let targetResource = null;
|
|
1136
1140
|
for (const n of resources) {
|
|
1137
|
-
const recordCount = countMap[n.id] || 0;
|
|
1138
1141
|
const mTimes = n.times.filter((n2) => {
|
|
1139
1142
|
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(timeSlots.start_at)) && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(timeSlots.end_at));
|
|
1140
1143
|
});
|
|
1141
1144
|
if (mTimes.length === 0) {
|
|
1142
1145
|
continue;
|
|
1143
1146
|
}
|
|
1147
|
+
const totalCapacity = (countMap[n.id] || []).reduce((sum, item) => {
|
|
1148
|
+
const hasOverlap = !(0, import_dayjs.default)(item.time.start_at).isAfter((0, import_dayjs.default)(timeSlots.start_at)) && !(0, import_dayjs.default)(item.time.end_at).isBefore((0, import_dayjs.default)(timeSlots.end_at));
|
|
1149
|
+
return hasOverlap ? sum + item.pax : sum;
|
|
1150
|
+
}, 0);
|
|
1144
1151
|
const canUseTime = mTimes.find((item) => {
|
|
1145
1152
|
var _a2;
|
|
1146
1153
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1147
1154
|
timeSlice: timeSlots,
|
|
1148
1155
|
time: item,
|
|
1149
1156
|
resource: n,
|
|
1150
|
-
currentCount:
|
|
1157
|
+
currentCount: totalCapacity + (capacity || 0),
|
|
1151
1158
|
resourcesUseableMap,
|
|
1152
1159
|
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
1153
1160
|
});
|
|
@@ -1198,6 +1205,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1198
1205
|
}
|
|
1199
1206
|
const errorList = [];
|
|
1200
1207
|
const selectResourcesMap = {};
|
|
1208
|
+
const selectResourcesWithTimeSlots = {};
|
|
1201
1209
|
const accountList = this.store.accountList.getAccounts();
|
|
1202
1210
|
const selectForCartResources = (cartItems2) => {
|
|
1203
1211
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
@@ -1218,7 +1226,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1218
1226
|
}
|
|
1219
1227
|
if (recordTimeSlots) {
|
|
1220
1228
|
const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find((n) => n.code === resources_code);
|
|
1221
|
-
|
|
1229
|
+
const resourceBookingType = (currentResourceConfig == null ? void 0 : currentResourceConfig.type) || "single";
|
|
1230
|
+
if (index !== 0 && recordTimeSlots && resourceBookingType === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
|
|
1222
1231
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1223
1232
|
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) ?? 0,
|
|
1224
1233
|
((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.type) ?? "minutes"
|
|
@@ -1239,14 +1248,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1239
1248
|
holder_id: item.holder_id,
|
|
1240
1249
|
resources_code,
|
|
1241
1250
|
timeSlots: recordTimeSlots,
|
|
1242
|
-
countMap:
|
|
1251
|
+
countMap: selectResourcesWithTimeSlots,
|
|
1243
1252
|
capacity: currentCapacity
|
|
1244
1253
|
});
|
|
1245
1254
|
if (res == null ? void 0 : res.selectedResource) {
|
|
1246
|
-
if (!
|
|
1247
|
-
|
|
1255
|
+
if (!selectResourcesWithTimeSlots[res.selectedResource.id]) {
|
|
1256
|
+
selectResourcesWithTimeSlots[res.selectedResource.id] = [
|
|
1257
|
+
{
|
|
1258
|
+
pax: currentCapacity,
|
|
1259
|
+
time: recordTimeSlots
|
|
1260
|
+
}
|
|
1261
|
+
];
|
|
1248
1262
|
} else {
|
|
1249
|
-
|
|
1263
|
+
selectResourcesWithTimeSlots[res.selectedResource.id].push({
|
|
1264
|
+
pax: currentCapacity,
|
|
1265
|
+
time: recordTimeSlots
|
|
1266
|
+
});
|
|
1250
1267
|
}
|
|
1251
1268
|
res.selectedResource.capacity = currentCapacity;
|
|
1252
1269
|
(0, import_resources.checkSubResourcesCapacity)(res.selectedResource);
|
|
@@ -1816,6 +1833,34 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1816
1833
|
}
|
|
1817
1834
|
return targetResource.renderList;
|
|
1818
1835
|
}
|
|
1836
|
+
async getAvailableDateForSession(params = {}) {
|
|
1837
|
+
let { startDate, endDate, type } = params;
|
|
1838
|
+
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
1839
|
+
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
1840
|
+
}
|
|
1841
|
+
endDate = (0, import_dayjs.default)().add(1, "month").format("YYYY-MM-DD");
|
|
1842
|
+
let tempProducts = [];
|
|
1843
|
+
if (this.store.currentProduct) {
|
|
1844
|
+
tempProducts = [
|
|
1845
|
+
{
|
|
1846
|
+
...this.store.currentProduct.getData(),
|
|
1847
|
+
_schedule: this.store.currentProduct.getOtherParams()["schedule"]
|
|
1848
|
+
}
|
|
1849
|
+
];
|
|
1850
|
+
}
|
|
1851
|
+
const { resourceIds, rules, resourcesMap } = (0, import_products.getAvailableProductResources)(tempProducts) || {};
|
|
1852
|
+
this.otherParams.currentResourcesMap = resourcesMap;
|
|
1853
|
+
const res = await this.store.date.getResourceDates({
|
|
1854
|
+
query: {
|
|
1855
|
+
start_date: startDate || "",
|
|
1856
|
+
end_date: endDate || "",
|
|
1857
|
+
resource_ids: resourceIds
|
|
1858
|
+
},
|
|
1859
|
+
rules,
|
|
1860
|
+
type
|
|
1861
|
+
});
|
|
1862
|
+
return res;
|
|
1863
|
+
}
|
|
1819
1864
|
};
|
|
1820
1865
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1821
1866
|
0 && (module.exports = {
|