@pisell/pisellos 3.0.47 → 3.0.50
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 +6 -3
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.d.ts +12 -0
- package/dist/modules/Order/utils.js +39 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +9 -4
- package/lib/modules/Order/index.js +7 -3
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.d.ts +12 -0
- package/lib/modules/Order/utils.js +19 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +16 -7
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
22
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
23
23
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
24
|
import { BaseModule } from "../BaseModule";
|
|
25
|
-
import { generateDuration } from "./utils";
|
|
25
|
+
import { generateDuration, mergeRelationForms } from "./utils";
|
|
26
26
|
import { isNormalProduct } from "../Product/utils";
|
|
27
27
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
28
28
|
_inherits(OrderModule, _BaseModule);
|
|
@@ -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: [],
|
|
@@ -92,6 +92,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
92
92
|
(_order$relation_forms = order.relation_forms).push.apply(_order$relation_forms, _toConsumableArray(relationForms));
|
|
93
93
|
delete item._origin.relation_forms;
|
|
94
94
|
} else {
|
|
95
|
+
// 合并关联表单
|
|
96
|
+
var _relationForms = mergeRelationForms(item._origin.relation_forms || []);
|
|
97
|
+
item._origin.relation_forms = _relationForms;
|
|
95
98
|
order.bookings.push(item._origin);
|
|
96
99
|
}
|
|
97
100
|
if (item !== null && item !== void 0 && item.deposit) {
|
|
@@ -8,3 +8,15 @@ export declare const generateDuration: (cartItem: CartItem) => {
|
|
|
8
8
|
duration: number;
|
|
9
9
|
durationType: string;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* 合并关联表单
|
|
13
|
+
* @param relationForms 关联表单
|
|
14
|
+
* @returns 合并后的关联表单
|
|
15
|
+
*/
|
|
16
|
+
export declare const mergeRelationForms: (relationForms: {
|
|
17
|
+
form_id: number;
|
|
18
|
+
form_record_ids: number[];
|
|
19
|
+
}[]) => {
|
|
20
|
+
form_id: number;
|
|
21
|
+
form_record_ids: number[];
|
|
22
|
+
}[];
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
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."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
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; }
|
|
1
7
|
import dayjs from "dayjs";
|
|
2
8
|
/**
|
|
3
9
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
@@ -12,4 +18,37 @@ export var generateDuration = function generateDuration(cartItem) {
|
|
|
12
18
|
duration: duration,
|
|
13
19
|
durationType: 'minutes'
|
|
14
20
|
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 合并关联表单
|
|
25
|
+
* @param relationForms 关联表单
|
|
26
|
+
* @returns 合并后的关联表单
|
|
27
|
+
*/
|
|
28
|
+
export var mergeRelationForms = function mergeRelationForms(relationForms) {
|
|
29
|
+
return Object.values(relationForms.reduce(function (acc, cur) {
|
|
30
|
+
var _acc$form_id$form_rec;
|
|
31
|
+
var form_id = cur.form_id,
|
|
32
|
+
form_record_ids = cur.form_record_ids;
|
|
33
|
+
// 如果 acc 中没有 form_id,则初始化一个空数组
|
|
34
|
+
if (!acc[form_id]) {
|
|
35
|
+
acc[form_id] = {
|
|
36
|
+
form_id: form_id,
|
|
37
|
+
form_record_ids: []
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 兼容 form_record_id 可能是数组或单个数字
|
|
42
|
+
var ids = Array.isArray(form_record_ids) ? form_record_ids : [form_record_ids];
|
|
43
|
+
// 过滤掉空值(null、undefined等)
|
|
44
|
+
var validIds = ids.filter(function (id) {
|
|
45
|
+
return id != null;
|
|
46
|
+
});
|
|
47
|
+
(_acc$form_id$form_rec = acc[form_id].form_record_ids).push.apply(_acc$form_id$form_rec, _toConsumableArray(validIds));
|
|
48
|
+
// 去重
|
|
49
|
+
acc[form_id].form_record_ids = _toConsumableArray(new Set(acc[form_id].form_record_ids));
|
|
50
|
+
return acc;
|
|
51
|
+
}, {})).filter(function (item) {
|
|
52
|
+
return item.form_record_ids.length > 0;
|
|
53
|
+
}); // 过滤掉没有有效记录的表单
|
|
15
54
|
};
|
|
@@ -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: [],
|
|
@@ -65,6 +65,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
65
65
|
order.relation_forms.push(...relationForms);
|
|
66
66
|
delete item._origin.relation_forms;
|
|
67
67
|
} else {
|
|
68
|
+
const relationForms = (0, import_utils.mergeRelationForms)(item._origin.relation_forms || []);
|
|
69
|
+
item._origin.relation_forms = relationForms;
|
|
68
70
|
order.bookings.push(item._origin);
|
|
69
71
|
}
|
|
70
72
|
if (item == null ? void 0 : item.deposit) {
|
|
@@ -72,7 +74,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
72
74
|
}
|
|
73
75
|
});
|
|
74
76
|
if (order.type === "appointment_booking") {
|
|
75
|
-
const firstAppointmentCartItem = (_a = params.cartItems.filter(
|
|
77
|
+
const firstAppointmentCartItem = (_a = params.cartItems.filter(
|
|
78
|
+
(n) => !(0, import_utils2.isNormalProduct)(n._productOrigin)
|
|
79
|
+
)) == null ? void 0 : _a[0];
|
|
76
80
|
if (firstAppointmentCartItem) {
|
|
77
81
|
order.schedule_date = firstAppointmentCartItem.start_date + " " + firstAppointmentCartItem.start_time + ":00";
|
|
78
82
|
}
|
|
@@ -8,3 +8,15 @@ export declare const generateDuration: (cartItem: CartItem) => {
|
|
|
8
8
|
duration: number;
|
|
9
9
|
durationType: string;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* 合并关联表单
|
|
13
|
+
* @param relationForms 关联表单
|
|
14
|
+
* @returns 合并后的关联表单
|
|
15
|
+
*/
|
|
16
|
+
export declare const mergeRelationForms: (relationForms: {
|
|
17
|
+
form_id: number;
|
|
18
|
+
form_record_ids: number[];
|
|
19
|
+
}[]) => {
|
|
20
|
+
form_id: number;
|
|
21
|
+
form_record_ids: number[];
|
|
22
|
+
}[];
|
|
@@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/modules/Order/utils.ts
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
|
-
generateDuration: () => generateDuration
|
|
32
|
+
generateDuration: () => generateDuration,
|
|
33
|
+
mergeRelationForms: () => mergeRelationForms
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(utils_exports);
|
|
35
36
|
var import_dayjs = __toESM(require("dayjs"));
|
|
@@ -39,7 +40,23 @@ var generateDuration = (cartItem) => {
|
|
|
39
40
|
const duration = endDate.diff(startDate, "minutes");
|
|
40
41
|
return { duration, durationType: "minutes" };
|
|
41
42
|
};
|
|
43
|
+
var mergeRelationForms = (relationForms) => {
|
|
44
|
+
return Object.values(
|
|
45
|
+
relationForms.reduce((acc, cur) => {
|
|
46
|
+
const { form_id, form_record_ids } = cur;
|
|
47
|
+
if (!acc[form_id]) {
|
|
48
|
+
acc[form_id] = { form_id, form_record_ids: [] };
|
|
49
|
+
}
|
|
50
|
+
const ids = Array.isArray(form_record_ids) ? form_record_ids : [form_record_ids];
|
|
51
|
+
const validIds = ids.filter((id) => id != null);
|
|
52
|
+
acc[form_id].form_record_ids.push(...validIds);
|
|
53
|
+
acc[form_id].form_record_ids = [...new Set(acc[form_id].form_record_ids)];
|
|
54
|
+
return acc;
|
|
55
|
+
}, {})
|
|
56
|
+
).filter((item) => item.form_record_ids.length > 0);
|
|
57
|
+
};
|
|
42
58
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
59
|
0 && (module.exports = {
|
|
44
|
-
generateDuration
|
|
60
|
+
generateDuration,
|
|
61
|
+
mergeRelationForms
|
|
45
62
|
});
|
|
@@ -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
|
// 拉起支付模块
|
|
@@ -827,7 +832,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
827
832
|
if (!resources.length) {
|
|
828
833
|
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
829
834
|
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
830
|
-
const dateResources = this.store.date.getResourcesListByDate(
|
|
835
|
+
const dateResources = this.store.date.getResourcesListByDate(
|
|
836
|
+
firstDateCartItem.start_date
|
|
837
|
+
);
|
|
831
838
|
resources.push(...dateResources || []);
|
|
832
839
|
} else {
|
|
833
840
|
const dateList = this.store.date.getDateList();
|
|
@@ -1051,7 +1058,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1051
1058
|
if (!AllResources.length) {
|
|
1052
1059
|
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
1053
1060
|
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
1054
|
-
const dateResources = this.store.date.getResourcesListByDate(
|
|
1061
|
+
const dateResources = this.store.date.getResourcesListByDate(
|
|
1062
|
+
firstDateCartItem.start_date
|
|
1063
|
+
);
|
|
1055
1064
|
AllResources.push(...dateResources || []);
|
|
1056
1065
|
} else {
|
|
1057
1066
|
const dateList = this.store.date.getDateList();
|