@pisell/pisellos 2.0.21 → 2.0.23
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 +25 -5
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/index.d.ts +7 -0
- package/dist/modules/ProductList/index.js +63 -29
- package/dist/solution/BookingByStep/index.d.ts +21 -3
- package/dist/solution/BookingByStep/index.js +281 -81
- package/dist/solution/BookingByStep/utils/resources.d.ts +22 -2
- package/dist/solution/BookingByStep/utils/resources.js +8 -4
- 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 +17 -5
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/ProductList/index.d.ts +7 -0
- package/lib/modules/ProductList/index.js +19 -0
- package/lib/solution/BookingByStep/index.d.ts +21 -3
- package/lib/solution/BookingByStep/index.js +233 -48
- package/lib/solution/BookingByStep/utils/resources.d.ts +22 -2
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- 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
|
* 折扣
|
|
@@ -41,12 +41,14 @@ export declare const formatProductToCartItem: (params: {
|
|
|
41
41
|
product: ProductData;
|
|
42
42
|
bundle?: any;
|
|
43
43
|
options?: any;
|
|
44
|
+
product_variant_id?: number;
|
|
44
45
|
}) => CartItem;
|
|
45
46
|
export declare const formatProductToCartItemOrigin: (params: {
|
|
46
47
|
cartItem: CartItem;
|
|
47
48
|
product: ProductData;
|
|
48
49
|
bundle?: any;
|
|
49
50
|
options?: any;
|
|
51
|
+
product_variant_id?: number;
|
|
50
52
|
}) => any;
|
|
51
53
|
/**
|
|
52
54
|
* 格式化折扣到购物车
|
|
@@ -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,14 +61,17 @@ 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) {
|
|
@@ -74,13 +83,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
74
83
|
item._origin.duration = duration;
|
|
75
84
|
item._origin.sub_type = durationType;
|
|
76
85
|
}
|
|
77
|
-
|
|
86
|
+
// 零售都视为普通商品
|
|
87
|
+
if (order.type === 'virtual') {
|
|
88
|
+
var _order$relation_forms;
|
|
89
|
+
order.relation_products.push(item._origin.product);
|
|
90
|
+
var relationForms = item._origin.relation_forms || [];
|
|
91
|
+
(_order$relation_forms = order.relation_forms).push.apply(_order$relation_forms, _toConsumableArray(relationForms));
|
|
92
|
+
delete item._origin.relation_forms;
|
|
93
|
+
} else {
|
|
94
|
+
order.bookings.push(item._origin);
|
|
95
|
+
}
|
|
78
96
|
if (item !== null && item !== void 0 && item.deposit) {
|
|
79
97
|
is_deposit = 1;
|
|
80
98
|
}
|
|
81
99
|
});
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
if (order.type === 'appointment_booking') {
|
|
101
|
+
var firstCartItem = params.cartItems[0];
|
|
102
|
+
order.schedule_date = firstCartItem.start_date + ' ' + firstCartItem.start_time + ':00';
|
|
103
|
+
}
|
|
84
104
|
order.is_deposit = is_deposit;
|
|
85
105
|
}
|
|
86
106
|
return order;
|
|
@@ -7,9 +7,16 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
7
7
|
protected defaultName: string;
|
|
8
8
|
protected defaultVersion: string;
|
|
9
9
|
private store;
|
|
10
|
+
private request;
|
|
10
11
|
constructor(name?: string, version?: string);
|
|
11
12
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
12
13
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
14
|
+
loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
|
|
15
|
+
ids?: number[];
|
|
16
|
+
customer_id?: number;
|
|
17
|
+
schedule_date?: string;
|
|
18
|
+
channel?: string;
|
|
19
|
+
}): Promise<any>;
|
|
13
20
|
getProducts(): Promise<ProductData[]>;
|
|
14
21
|
getProduct(id: number): Promise<Product | undefined>;
|
|
15
22
|
addProduct(products: ProductData[]): Promise<void>;
|
|
@@ -30,6 +30,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
30
30
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'productList');
|
|
31
31
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
32
32
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
33
34
|
return _this;
|
|
34
35
|
}
|
|
35
36
|
_createClass(ProductList, [{
|
|
@@ -51,7 +52,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
51
52
|
this.store.productMap = new Map();
|
|
52
53
|
this.store.selectProducts = [];
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
+
this.request = core.getPlugin('request');
|
|
56
|
+
case 4:
|
|
55
57
|
case "end":
|
|
56
58
|
return _context.stop();
|
|
57
59
|
}
|
|
@@ -95,22 +97,54 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
95
97
|
return storeChange;
|
|
96
98
|
}()
|
|
97
99
|
}, {
|
|
98
|
-
key: "
|
|
100
|
+
key: "loadProductsPrice",
|
|
99
101
|
value: function () {
|
|
100
|
-
var
|
|
102
|
+
var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
103
|
+
var _ref$ids, ids, customer_id, schedule_date, channel, productsData;
|
|
101
104
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
102
105
|
while (1) switch (_context3.prev = _context3.next) {
|
|
103
106
|
case 0:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
_ref$ids = _ref.ids, ids = _ref$ids === void 0 ? [] : _ref$ids, customer_id = _ref.customer_id, schedule_date = _ref.schedule_date, channel = _ref.channel;
|
|
108
|
+
_context3.next = 3;
|
|
109
|
+
return this.request.post("/product/query/price", {
|
|
110
|
+
ids: ids,
|
|
111
|
+
customer_id: customer_id,
|
|
112
|
+
schedule_date: schedule_date,
|
|
113
|
+
channel: channel
|
|
114
|
+
}, {
|
|
115
|
+
useCache: true
|
|
116
|
+
});
|
|
108
117
|
case 3:
|
|
118
|
+
productsData = _context3.sent;
|
|
119
|
+
return _context3.abrupt("return", productsData.data);
|
|
120
|
+
case 5:
|
|
109
121
|
case "end":
|
|
110
122
|
return _context3.stop();
|
|
111
123
|
}
|
|
112
124
|
}, _callee3, this);
|
|
113
125
|
}));
|
|
126
|
+
function loadProductsPrice(_x5) {
|
|
127
|
+
return _loadProductsPrice.apply(this, arguments);
|
|
128
|
+
}
|
|
129
|
+
return loadProductsPrice;
|
|
130
|
+
}()
|
|
131
|
+
}, {
|
|
132
|
+
key: "getProducts",
|
|
133
|
+
value: function () {
|
|
134
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
135
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
136
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
_context4.next = 2;
|
|
139
|
+
return this.core.effects.emit(ProductListHooks.onGetProducts, this.store.list);
|
|
140
|
+
case 2:
|
|
141
|
+
return _context4.abrupt("return", cloneDeep(this.store.list));
|
|
142
|
+
case 3:
|
|
143
|
+
case "end":
|
|
144
|
+
return _context4.stop();
|
|
145
|
+
}
|
|
146
|
+
}, _callee4, this);
|
|
147
|
+
}));
|
|
114
148
|
function getProducts() {
|
|
115
149
|
return _getProducts.apply(this, arguments);
|
|
116
150
|
}
|
|
@@ -119,29 +153,29 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
119
153
|
}, {
|
|
120
154
|
key: "getProduct",
|
|
121
155
|
value: function () {
|
|
122
|
-
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
156
|
+
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
|
|
123
157
|
var product;
|
|
124
|
-
return _regeneratorRuntime().wrap(function
|
|
125
|
-
while (1) switch (
|
|
158
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
159
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
126
160
|
case 0:
|
|
127
|
-
|
|
161
|
+
_context5.next = 2;
|
|
128
162
|
return this.core.effects.emit(ProductListHooks.onGetProduct, this.store.list);
|
|
129
163
|
case 2:
|
|
130
164
|
product = this.store.productMap.get("".concat(id));
|
|
131
165
|
if (!product) {
|
|
132
|
-
|
|
166
|
+
_context5.next = 5;
|
|
133
167
|
break;
|
|
134
168
|
}
|
|
135
|
-
return
|
|
169
|
+
return _context5.abrupt("return", product);
|
|
136
170
|
case 5:
|
|
137
|
-
return
|
|
171
|
+
return _context5.abrupt("return", undefined);
|
|
138
172
|
case 6:
|
|
139
173
|
case "end":
|
|
140
|
-
return
|
|
174
|
+
return _context5.stop();
|
|
141
175
|
}
|
|
142
|
-
},
|
|
176
|
+
}, _callee5, this);
|
|
143
177
|
}));
|
|
144
|
-
function getProduct(
|
|
178
|
+
function getProduct(_x6) {
|
|
145
179
|
return _getProduct.apply(this, arguments);
|
|
146
180
|
}
|
|
147
181
|
return getProduct;
|
|
@@ -149,10 +183,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
149
183
|
}, {
|
|
150
184
|
key: "addProduct",
|
|
151
185
|
value: function () {
|
|
152
|
-
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
186
|
+
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(products) {
|
|
153
187
|
var _this3 = this;
|
|
154
|
-
return _regeneratorRuntime().wrap(function
|
|
155
|
-
while (1) switch (
|
|
188
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
189
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
156
190
|
case 0:
|
|
157
191
|
// 加到 list 以后上面的storeChange 会自动初始化商品详情的 module 实例
|
|
158
192
|
// list 需要根据 id 去重
|
|
@@ -172,11 +206,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
172
206
|
this.storeChange();
|
|
173
207
|
case 3:
|
|
174
208
|
case "end":
|
|
175
|
-
return
|
|
209
|
+
return _context6.stop();
|
|
176
210
|
}
|
|
177
|
-
},
|
|
211
|
+
}, _callee6, this);
|
|
178
212
|
}));
|
|
179
|
-
function addProduct(
|
|
213
|
+
function addProduct(_x7) {
|
|
180
214
|
return _addProduct.apply(this, arguments);
|
|
181
215
|
}
|
|
182
216
|
return addProduct;
|
|
@@ -184,18 +218,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
184
218
|
}, {
|
|
185
219
|
key: "selectProducts",
|
|
186
220
|
value: function () {
|
|
187
|
-
var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
188
|
-
return _regeneratorRuntime().wrap(function
|
|
189
|
-
while (1) switch (
|
|
221
|
+
var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(products) {
|
|
222
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
223
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
190
224
|
case 0:
|
|
191
225
|
this.store.selectProducts = products;
|
|
192
226
|
case 1:
|
|
193
227
|
case "end":
|
|
194
|
-
return
|
|
228
|
+
return _context7.stop();
|
|
195
229
|
}
|
|
196
|
-
},
|
|
230
|
+
}, _callee7, this);
|
|
197
231
|
}));
|
|
198
|
-
function selectProducts(
|
|
232
|
+
function selectProducts(_x8) {
|
|
199
233
|
return _selectProducts.apply(this, arguments);
|
|
200
234
|
}
|
|
201
235
|
return selectProducts;
|
|
@@ -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;
|
|
@@ -186,10 +189,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
186
189
|
private getScheduleDataByIds;
|
|
187
190
|
openProductDetail(productId: number): Promise<void>;
|
|
188
191
|
closeProductDetail(): void;
|
|
189
|
-
getTimeslotBySchedule({ date, scheduleIds, resources, }: {
|
|
192
|
+
getTimeslotBySchedule({ date, scheduleIds, resources, product }: {
|
|
190
193
|
date: string;
|
|
191
194
|
scheduleIds?: number[];
|
|
192
195
|
resources?: ProductResourceItem[];
|
|
196
|
+
product?: ProductData;
|
|
193
197
|
}): {
|
|
194
198
|
start_time: string;
|
|
195
199
|
end_time: string;
|
|
@@ -207,5 +211,19 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
207
211
|
}): void;
|
|
208
212
|
setOtherData(key: string, value: any): void;
|
|
209
213
|
getOtherData(key: string): any;
|
|
210
|
-
getProductTypeById(id: number): Promise<"
|
|
214
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
215
|
+
/**
|
|
216
|
+
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
217
|
+
*
|
|
218
|
+
* @param {string} cartItemId
|
|
219
|
+
* @param {string} resourceCode
|
|
220
|
+
* @return {*}
|
|
221
|
+
* @memberof BookingByStepImpl
|
|
222
|
+
*/
|
|
223
|
+
getResourcesByCartItemAndCode(cartItemId: string, resourceCode: string): any;
|
|
224
|
+
getAvailableDateForSession(params?: {
|
|
225
|
+
startDate?: string;
|
|
226
|
+
endDate?: string;
|
|
227
|
+
type?: 'month';
|
|
228
|
+
}): Promise<ITime[]>;
|
|
211
229
|
}
|