@pisell/pisellos 2.0.55 → 2.0.56
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/Order/index.js +2 -2
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Rules/index.js +5 -5
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +9 -4
- package/lib/modules/Order/index.js +5 -3
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Rules/index.js +4 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +16 -7
- package/package.json +2 -2
|
@@ -62,9 +62,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
62
62
|
key: "createOrder",
|
|
63
63
|
value: function createOrder(params) {
|
|
64
64
|
var order = {
|
|
65
|
-
type: params.type || 'appointment_booking',
|
|
65
|
+
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
66
66
|
// 要从外面拿,virtual
|
|
67
|
-
platform: 'H5',
|
|
67
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) === 'pc' ? 'PC' : 'H5',
|
|
68
68
|
sales_channel: 'my_pisel',
|
|
69
69
|
order_sales_channel: 'online_store',
|
|
70
70
|
bookings: [],
|
|
@@ -429,7 +429,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
429
429
|
}));
|
|
430
430
|
}
|
|
431
431
|
for (var _i = 0; _i < splitCount; _i++) {
|
|
432
|
-
var
|
|
432
|
+
var _product$discount_lis11, _originProduct$_produ;
|
|
433
433
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
434
434
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[_i];
|
|
435
435
|
// 标记优惠券为已使用
|
|
@@ -440,14 +440,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
440
440
|
|
|
441
441
|
// 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
|
|
442
442
|
var productOriginTotal = product.origin_total || product.total || 0;
|
|
443
|
+
// 如果当前 product 有 discount_list,则先从 origin_total 拿
|
|
444
|
+
if ((_product$discount_lis11 = product.discount_list) !== null && _product$discount_lis11 !== void 0 && _product$discount_lis11.length && product.origin_total) {
|
|
445
|
+
productOriginTotal = product.origin_total;
|
|
446
|
+
}
|
|
443
447
|
// 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
|
|
444
448
|
if (Number((originProduct === null || originProduct === void 0 || (_originProduct$_produ = originProduct._productInit) === null || _originProduct$_produ === void 0 ? void 0 : _originProduct$_produ.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
445
449
|
productOriginTotal = product.total;
|
|
446
450
|
}
|
|
447
|
-
// 如果当前 product 有 discount_list,则必须从 origin_total 拿
|
|
448
|
-
if ((_product$discount_lis11 = product.discount_list) !== null && _product$discount_lis11 !== void 0 && _product$discount_lis11.length && product.origin_total) {
|
|
449
|
-
productOriginTotal = product.origin_total;
|
|
450
|
-
}
|
|
451
451
|
|
|
452
452
|
// 计算使用折扣卡/商品券以后,单个商品的总 total
|
|
453
453
|
var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(productOriginTotal).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(productOriginTotal)).toNumber();
|
|
@@ -21,6 +21,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
21
21
|
private otherParams;
|
|
22
22
|
private cacheId;
|
|
23
23
|
private otherData;
|
|
24
|
+
private platform;
|
|
24
25
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
25
26
|
initStep(stepList: (keyof BookingByStepState)[]): void;
|
|
26
27
|
getCurrentStep(): {
|
|
@@ -61,15 +61,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
61
61
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
62
62
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
63
63
|
_defineProperty(_assertThisInitialized(_this), "otherData", {});
|
|
64
|
+
// 提供给 UI 层的临时数据存储,会进缓存
|
|
65
|
+
_defineProperty(_assertThisInitialized(_this), "platform", void 0);
|
|
64
66
|
return _this;
|
|
65
67
|
}
|
|
66
68
|
_createClass(BookingByStepImpl, [{
|
|
67
69
|
key: "initialize",
|
|
68
|
-
value: //
|
|
70
|
+
value: // 平台类型,用于判断是 PC / H5
|
|
69
71
|
function () {
|
|
70
72
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
71
73
|
var _this$otherParams,
|
|
72
74
|
_this$otherParams2,
|
|
75
|
+
_this$otherParams3,
|
|
73
76
|
_this2 = this;
|
|
74
77
|
var targetCacheData, sessionData, _data$this$otherParam, data, moduleArr;
|
|
75
78
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -99,7 +102,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
99
102
|
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
100
103
|
targetCacheData = {};
|
|
101
104
|
this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
|
|
102
|
-
|
|
105
|
+
this.platform = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform;
|
|
106
|
+
if ((_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.cacheId) {
|
|
103
107
|
sessionData = this.window.sessionStorage.getItem(this.name);
|
|
104
108
|
if (sessionData) {
|
|
105
109
|
data = JSON.parse(sessionData); // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
|
|
@@ -128,7 +132,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
128
132
|
});
|
|
129
133
|
this.store.schedule.loadAllSchedule();
|
|
130
134
|
this.core.effects.emit(BookingByStepHooks.onInited, {});
|
|
131
|
-
case
|
|
135
|
+
case 19:
|
|
132
136
|
case "end":
|
|
133
137
|
return _context.stop();
|
|
134
138
|
}
|
|
@@ -989,7 +993,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
989
993
|
return _context19.abrupt("return", this.store.order.submitOrder({
|
|
990
994
|
query: {
|
|
991
995
|
cartItems: newCartItems,
|
|
992
|
-
type: type
|
|
996
|
+
type: type,
|
|
997
|
+
platform: this.platform
|
|
993
998
|
}
|
|
994
999
|
}));
|
|
995
1000
|
case 6:
|
|
@@ -39,9 +39,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
39
39
|
createOrder(params) {
|
|
40
40
|
var _a;
|
|
41
41
|
const order = {
|
|
42
|
-
type: params.type || "appointment_booking",
|
|
42
|
+
type: (params == null ? void 0 : params.type) || "appointment_booking",
|
|
43
43
|
// 要从外面拿,virtual
|
|
44
|
-
platform: "H5",
|
|
44
|
+
platform: (params == null ? void 0 : params.platform) === "pc" ? "PC" : "H5",
|
|
45
45
|
sales_channel: "my_pisel",
|
|
46
46
|
order_sales_channel: "online_store",
|
|
47
47
|
bookings: [],
|
|
@@ -72,7 +72,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
if (order.type === "appointment_booking") {
|
|
75
|
-
const firstAppointmentCartItem = (_a = params.cartItems.filter(
|
|
75
|
+
const firstAppointmentCartItem = (_a = params.cartItems.filter(
|
|
76
|
+
(n) => !(0, import_utils2.isNormalProduct)(n._productOrigin)
|
|
77
|
+
)) == null ? void 0 : _a[0];
|
|
76
78
|
if (firstAppointmentCartItem) {
|
|
77
79
|
order.schedule_date = firstAppointmentCartItem.start_date + " " + firstAppointmentCartItem.start_time + ":00";
|
|
78
80
|
}
|
|
@@ -302,12 +302,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
302
302
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
303
303
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
304
304
|
let productOriginTotal = product.origin_total || product.total || 0;
|
|
305
|
-
if (
|
|
306
|
-
productOriginTotal = product.total;
|
|
307
|
-
}
|
|
308
|
-
if (((_h = product.discount_list) == null ? void 0 : _h.length) && product.origin_total) {
|
|
305
|
+
if (((_g = product.discount_list) == null ? void 0 : _g.length) && product.origin_total) {
|
|
309
306
|
productOriginTotal = product.origin_total;
|
|
310
307
|
}
|
|
308
|
+
if (Number(((_h = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _h.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
309
|
+
productOriginTotal = product.total;
|
|
310
|
+
}
|
|
311
311
|
const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(productOriginTotal)).toNumber();
|
|
312
312
|
const discountDetail = {
|
|
313
313
|
amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
|
|
@@ -21,6 +21,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
21
21
|
private otherParams;
|
|
22
22
|
private cacheId;
|
|
23
23
|
private otherData;
|
|
24
|
+
private platform;
|
|
24
25
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
25
26
|
initStep(stepList: (keyof BookingByStepState)[]): void;
|
|
26
27
|
getCurrentStep(): {
|
|
@@ -58,9 +58,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
58
58
|
this.otherParams = {};
|
|
59
59
|
this.otherData = {};
|
|
60
60
|
}
|
|
61
|
-
//
|
|
61
|
+
// 平台类型,用于判断是 PC / H5
|
|
62
62
|
async initialize(core, options) {
|
|
63
|
-
var _a, _b, _c, _d;
|
|
63
|
+
var _a, _b, _c, _d, _e;
|
|
64
64
|
this.core = core;
|
|
65
65
|
this.store = options.store || {};
|
|
66
66
|
this.otherParams = options.otherParams || {};
|
|
@@ -76,12 +76,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
76
76
|
}
|
|
77
77
|
let targetCacheData = {};
|
|
78
78
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
79
|
-
|
|
79
|
+
this.platform = (_b = this.otherParams) == null ? void 0 : _b.platform;
|
|
80
|
+
if ((_c = this.otherParams) == null ? void 0 : _c.cacheId) {
|
|
80
81
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
81
82
|
if (sessionData) {
|
|
82
83
|
const data = JSON.parse(sessionData);
|
|
83
84
|
targetCacheData = data[this.otherParams.cacheId];
|
|
84
|
-
this.otherData = ((
|
|
85
|
+
this.otherData = ((_e = (_d = data[this.otherParams.cacheId]) == null ? void 0 : _d[this.name]) == null ? void 0 : _e["otherData"]) || {};
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
const moduleArr = [
|
|
@@ -529,7 +530,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
529
530
|
type = "virtual";
|
|
530
531
|
}
|
|
531
532
|
return this.store.order.submitOrder({
|
|
532
|
-
query: {
|
|
533
|
+
query: {
|
|
534
|
+
cartItems: newCartItems,
|
|
535
|
+
type,
|
|
536
|
+
platform: this.platform
|
|
537
|
+
}
|
|
533
538
|
});
|
|
534
539
|
}
|
|
535
540
|
// 拉起支付模块
|
|
@@ -834,7 +839,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
834
839
|
if (!resources.length) {
|
|
835
840
|
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
836
841
|
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
837
|
-
const dateResources = this.store.date.getResourcesListByDate(
|
|
842
|
+
const dateResources = this.store.date.getResourcesListByDate(
|
|
843
|
+
firstDateCartItem.start_date
|
|
844
|
+
);
|
|
838
845
|
resources.push(...dateResources || []);
|
|
839
846
|
} else {
|
|
840
847
|
const dateList = this.store.date.getDateList();
|
|
@@ -1058,7 +1065,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1058
1065
|
if (!AllResources.length) {
|
|
1059
1066
|
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
1060
1067
|
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
1061
|
-
const dateResources = this.store.date.getResourcesListByDate(
|
|
1068
|
+
const dateResources = this.store.date.getResourcesListByDate(
|
|
1069
|
+
firstDateCartItem.start_date
|
|
1070
|
+
);
|
|
1062
1071
|
AllResources.push(...dateResources || []);
|
|
1063
1072
|
} else {
|
|
1064
1073
|
const dateList = this.store.date.getDateList();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.56",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -67,4 +67,4 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
}
|