@pisell/pisellos 0.0.201 → 0.0.205
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 +5 -2
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.d.ts +12 -0
- package/dist/modules/Order/utils.js +33 -0
- package/dist/solution/BookingByStep/index.js +3 -1
- package/lib/modules/Order/index.js +6 -2
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.d.ts +12 -0
- package/lib/modules/Order/utils.js +18 -2
- package/lib/solution/BookingByStep/index.js +14 -5
- 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);
|
|
@@ -64,7 +64,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
64
64
|
var order = {
|
|
65
65
|
type: params.type || 'appointment_booking',
|
|
66
66
|
// 要从外面拿,virtual
|
|
67
|
-
platform: 'H5',
|
|
67
|
+
platform: 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,31 @@ 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
|
+
(_acc$form_id$form_rec = acc[form_id].form_record_ids).push.apply(_acc$form_id$form_rec, _toConsumableArray(ids));
|
|
44
|
+
// 去重
|
|
45
|
+
acc[form_id].form_record_ids = _toConsumableArray(new Set(acc[form_id].form_record_ids));
|
|
46
|
+
return acc;
|
|
47
|
+
}, {}));
|
|
15
48
|
};
|
|
@@ -954,6 +954,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
954
954
|
key: "submitOrder",
|
|
955
955
|
value: function () {
|
|
956
956
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
957
|
+
var _this$otherParams3;
|
|
957
958
|
var cartItems, newCartItems, type;
|
|
958
959
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
959
960
|
while (1) switch (_context19.prev = _context19.next) {
|
|
@@ -989,7 +990,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
989
990
|
return _context19.abrupt("return", this.store.order.submitOrder({
|
|
990
991
|
query: {
|
|
991
992
|
cartItems: newCartItems,
|
|
992
|
-
type: type
|
|
993
|
+
type: type,
|
|
994
|
+
platform: (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform
|
|
993
995
|
}
|
|
994
996
|
}));
|
|
995
997
|
case 6:
|
|
@@ -41,7 +41,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
41
41
|
const order = {
|
|
42
42
|
type: params.type || "appointment_booking",
|
|
43
43
|
// 要从外面拿,virtual
|
|
44
|
-
platform: "H5",
|
|
44
|
+
platform: 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,22 @@ 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
|
+
acc[form_id].form_record_ids.push(...ids);
|
|
52
|
+
acc[form_id].form_record_ids = [...new Set(acc[form_id].form_record_ids)];
|
|
53
|
+
return acc;
|
|
54
|
+
}, {})
|
|
55
|
+
);
|
|
56
|
+
};
|
|
42
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
58
|
0 && (module.exports = {
|
|
44
|
-
generateDuration
|
|
59
|
+
generateDuration,
|
|
60
|
+
mergeRelationForms
|
|
45
61
|
});
|
|
@@ -501,10 +501,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
501
501
|
}
|
|
502
502
|
// 购物车提交订单
|
|
503
503
|
async submitOrder() {
|
|
504
|
+
var _a;
|
|
504
505
|
const cartItems = this.store.cart.getItems();
|
|
505
506
|
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
506
507
|
newCartItems.forEach((item) => {
|
|
507
|
-
var
|
|
508
|
+
var _a2;
|
|
508
509
|
if (item._origin.resources && item._origin.resources.length) {
|
|
509
510
|
item._origin.resources = item._origin.resources.map((n) => {
|
|
510
511
|
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
@@ -514,7 +515,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
514
515
|
return { ...newResourcesItem };
|
|
515
516
|
});
|
|
516
517
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
517
|
-
if (!((
|
|
518
|
+
if (!((_a2 = item._origin) == null ? void 0 : _a2.metadata)) {
|
|
518
519
|
item._origin.metadata = {};
|
|
519
520
|
}
|
|
520
521
|
item._origin.metadata.capacity = formatCapacity;
|
|
@@ -528,7 +529,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
528
529
|
type = "virtual";
|
|
529
530
|
}
|
|
530
531
|
return this.store.order.submitOrder({
|
|
531
|
-
query: {
|
|
532
|
+
query: {
|
|
533
|
+
cartItems: newCartItems,
|
|
534
|
+
type,
|
|
535
|
+
platform: (_a = this.otherParams) == null ? void 0 : _a.platform
|
|
536
|
+
}
|
|
532
537
|
});
|
|
533
538
|
}
|
|
534
539
|
// 拉起支付模块
|
|
@@ -833,7 +838,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
833
838
|
if (!resources.length) {
|
|
834
839
|
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
835
840
|
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
836
|
-
const dateResources = this.store.date.getResourcesListByDate(
|
|
841
|
+
const dateResources = this.store.date.getResourcesListByDate(
|
|
842
|
+
firstDateCartItem.start_date
|
|
843
|
+
);
|
|
837
844
|
resources.push(...dateResources || []);
|
|
838
845
|
} else {
|
|
839
846
|
const dateList = this.store.date.getDateList();
|
|
@@ -1057,7 +1064,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1057
1064
|
if (!AllResources.length) {
|
|
1058
1065
|
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
1059
1066
|
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
1060
|
-
const dateResources = this.store.date.getResourcesListByDate(
|
|
1067
|
+
const dateResources = this.store.date.getResourcesListByDate(
|
|
1068
|
+
firstDateCartItem.start_date
|
|
1069
|
+
);
|
|
1061
1070
|
AllResources.push(...dateResources || []);
|
|
1062
1071
|
} else {
|
|
1063
1072
|
const dateList = this.store.date.getDateList();
|