@pisell/pisellos 0.0.231 → 0.0.233
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 +18 -9
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Payment/types.d.ts +3 -2
- package/dist/modules/Payment/walletpass.js +15 -9
- package/dist/modules/Schedule/index.d.ts +1 -1
- package/dist/modules/Schedule/index.js +20 -12
- package/dist/solution/BookingByStep/utils/timeslots.js +114 -72
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.d.ts +21 -0
- package/dist/solution/Checkout/index.js +798 -643
- package/dist/solution/Checkout/types.d.ts +14 -0
- package/lib/modules/Order/index.js +13 -6
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Payment/types.d.ts +3 -2
- package/lib/modules/Payment/walletpass.js +13 -9
- package/lib/modules/Schedule/index.d.ts +1 -1
- package/lib/modules/Schedule/index.js +24 -9
- package/lib/solution/BookingByStep/utils/timeslots.js +72 -53
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.d.ts +21 -0
- package/lib/solution/Checkout/index.js +114 -19
- package/lib/solution/Checkout/types.d.ts +14 -0
- package/package.json +1 -1
|
@@ -661,6 +661,20 @@ export interface CheckoutModuleAPI extends Module {
|
|
|
661
661
|
orderId?: string;
|
|
662
662
|
orderUuid?: string;
|
|
663
663
|
}>;
|
|
664
|
+
/**
|
|
665
|
+
* 通过订单ID编辑订单备注
|
|
666
|
+
*
|
|
667
|
+
* 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
|
|
668
|
+
*
|
|
669
|
+
* @param orderId 后端订单ID
|
|
670
|
+
* @param note 新的订单备注
|
|
671
|
+
* @returns 修改结果
|
|
672
|
+
*/
|
|
673
|
+
editOrderNoteByOrderIdAsync(orderId: string | number, note: string): Promise<{
|
|
674
|
+
success: boolean;
|
|
675
|
+
message?: string;
|
|
676
|
+
orderId?: string | number;
|
|
677
|
+
}>;
|
|
664
678
|
}
|
|
665
679
|
/**
|
|
666
680
|
* 结账事件数据类型
|
|
@@ -112,7 +112,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
112
112
|
* @returns 后端返回的订单数据(包含订单ID等)
|
|
113
113
|
*/
|
|
114
114
|
async createOrderByCheckout(params) {
|
|
115
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
116
116
|
console.log("[Order] createOrderByCheckout 开始创建订单:", {
|
|
117
117
|
type: params.type,
|
|
118
118
|
platform: params.platform,
|
|
@@ -136,21 +136,28 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
136
136
|
...params
|
|
137
137
|
// 使用传入的参数覆盖默认值
|
|
138
138
|
};
|
|
139
|
+
if ((_d = orderData.payments) == null ? void 0 : _d.length) {
|
|
140
|
+
orderData.small_ticket_data_flag = 1;
|
|
141
|
+
}
|
|
142
|
+
if (params.order_id) {
|
|
143
|
+
orderData.bookings = [];
|
|
144
|
+
orderData.relation_products = [];
|
|
145
|
+
}
|
|
139
146
|
console.log("[Order] 调用后端接口创建订单:", {
|
|
140
147
|
url: "/order/checkout",
|
|
141
148
|
orderType: orderData.type,
|
|
142
149
|
platform: orderData.platform,
|
|
143
150
|
isDeposit: orderData.is_deposit,
|
|
144
151
|
customerId: orderData.customer_id,
|
|
145
|
-
bookingsCount: ((
|
|
146
|
-
relationProductsCount: ((
|
|
147
|
-
paymentsCount: ((
|
|
148
|
-
paymentsMethods: ((
|
|
152
|
+
bookingsCount: ((_e = orderData.bookings) == null ? void 0 : _e.length) || 0,
|
|
153
|
+
relationProductsCount: ((_f = orderData.relation_products) == null ? void 0 : _f.length) || 0,
|
|
154
|
+
paymentsCount: ((_g = orderData.payments) == null ? void 0 : _g.length) || 0,
|
|
155
|
+
paymentsMethods: ((_h = orderData.payments) == null ? void 0 : _h.map((p) => p.code)) || []
|
|
149
156
|
});
|
|
150
157
|
const response = await this.request.post("/order/checkout", orderData);
|
|
151
158
|
console.log("[Order] 订单创建成功,后端响应:", {
|
|
152
159
|
success: !!response,
|
|
153
|
-
hasOrderId: !!(((
|
|
160
|
+
hasOrderId: !!(((_i = response == null ? void 0 : response.data) == null ? void 0 : _i.order_id) || (response == null ? void 0 : response.order_id))
|
|
154
161
|
});
|
|
155
162
|
return response;
|
|
156
163
|
} catch (error) {
|
|
@@ -509,7 +509,7 @@ export interface WalletDeductionRecommendParams {
|
|
|
509
509
|
/** 前端设置只想要的字段 */
|
|
510
510
|
expect_columns?: string[];
|
|
511
511
|
/** 客户id */
|
|
512
|
-
customer_id
|
|
512
|
+
customer_id?: number;
|
|
513
513
|
/** 订单总计金额 */
|
|
514
514
|
order_expect_amount: number;
|
|
515
515
|
/** 订单小计金额 */
|
|
@@ -517,7 +517,7 @@ export interface WalletDeductionRecommendParams {
|
|
|
517
517
|
/** 订单待支付金额 */
|
|
518
518
|
order_wait_pay_amount: number;
|
|
519
519
|
/** 统计计数用户id */
|
|
520
|
-
order_behavior_count_customer_id
|
|
520
|
+
order_behavior_count_customer_id?: number;
|
|
521
521
|
/** 已选商品 */
|
|
522
522
|
products: {
|
|
523
523
|
/** 商品id */
|
|
@@ -555,6 +555,7 @@ export interface WalletInitBusinessData {
|
|
|
555
555
|
quantity: number;
|
|
556
556
|
selling_price: number;
|
|
557
557
|
}[];
|
|
558
|
+
order_wait_pay_amount?: number;
|
|
558
559
|
}
|
|
559
560
|
/**
|
|
560
561
|
* 查询用户识别码列表请求参数
|
|
@@ -48,15 +48,19 @@ var WalletPassPaymentImpl = class {
|
|
|
48
48
|
* 根据业务数据生成标准的钱包API参数,并存储在模块中
|
|
49
49
|
*/
|
|
50
50
|
generateWalletParams(businessData) {
|
|
51
|
-
const { customer_id, amountInfo, products } = businessData;
|
|
52
|
-
const totalAmount = Number(amountInfo.
|
|
51
|
+
const { customer_id, amountInfo, products, order_wait_pay_amount } = businessData;
|
|
52
|
+
const totalAmount = Number(amountInfo.totalAmount);
|
|
53
|
+
const subTotal = Number(amountInfo.subTotal);
|
|
53
54
|
const walletParams = {
|
|
54
|
-
sale_channel: "
|
|
55
|
-
customer_id:
|
|
55
|
+
sale_channel: "pos",
|
|
56
|
+
customer_id: customer_id || 0,
|
|
57
|
+
// 提供默认值,确保类型为 number
|
|
56
58
|
order_expect_amount: totalAmount,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
// 订单小计金额
|
|
60
|
+
order_product_amount: subTotal,
|
|
61
|
+
// 订单待支付金额
|
|
62
|
+
order_wait_pay_amount: order_wait_pay_amount || totalAmount,
|
|
63
|
+
// order_behavior_count_customer_id: 1,
|
|
60
64
|
products,
|
|
61
65
|
prepare_payments: []
|
|
62
66
|
};
|
|
@@ -135,7 +139,7 @@ var WalletPassPaymentImpl = class {
|
|
|
135
139
|
return this.walletRecommendList;
|
|
136
140
|
} catch (error) {
|
|
137
141
|
console.error("获取钱包推荐列表失败:", error);
|
|
138
|
-
|
|
142
|
+
return [];
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
formatWalletPassList2PreparePayments(list) {
|
|
@@ -164,7 +168,7 @@ var WalletPassPaymentImpl = class {
|
|
|
164
168
|
return this.userIdentificationCodes;
|
|
165
169
|
} catch (error) {
|
|
166
170
|
console.error("获取用户识别码列表失败:", error);
|
|
167
|
-
|
|
171
|
+
return [];
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
174
|
/**
|
|
@@ -30,7 +30,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
30
30
|
* @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
static isInScheduleByDate({ date, schedule }: {
|
|
33
|
+
static isInScheduleByDate({ date, schedule, }: {
|
|
34
34
|
date: string;
|
|
35
35
|
schedule: any;
|
|
36
36
|
}): true | undefined;
|
|
@@ -162,9 +162,12 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
162
162
|
/**
|
|
163
163
|
* 传入一个时间, 判断改时间是否在schedule 内
|
|
164
164
|
* @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
|
|
165
|
-
* @returns
|
|
165
|
+
* @returns
|
|
166
166
|
*/
|
|
167
|
-
static isInScheduleByDate({
|
|
167
|
+
static isInScheduleByDate({
|
|
168
|
+
date,
|
|
169
|
+
schedule
|
|
170
|
+
}) {
|
|
168
171
|
var _a, _b, _c, _d;
|
|
169
172
|
let _schedule = {
|
|
170
173
|
...schedule,
|
|
@@ -173,16 +176,28 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
173
176
|
end_time: (0, import_dayjs.default)(date).add(1, "day").format("YYYY-MM-DD HH:mm:ss")
|
|
174
177
|
};
|
|
175
178
|
if (((_b = (_a = _schedule.repeat_rule) == null ? void 0 : _a.end) == null ? void 0 : _b.type) === "never") {
|
|
176
|
-
_schedule
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
_schedule = {
|
|
180
|
+
..._schedule,
|
|
181
|
+
repeat_rule: {
|
|
182
|
+
..._schedule.repeat_rule,
|
|
183
|
+
end: {
|
|
184
|
+
type: "date",
|
|
185
|
+
end_date: _schedule.end_time,
|
|
186
|
+
occurrence: null
|
|
187
|
+
}
|
|
188
|
+
}
|
|
180
189
|
};
|
|
181
190
|
}
|
|
182
191
|
if (((_d = (_c = _schedule.repeat_rule) == null ? void 0 : _c.end) == null ? void 0 : _d.type) === "date") {
|
|
183
|
-
_schedule
|
|
184
|
-
..._schedule
|
|
185
|
-
|
|
192
|
+
_schedule = {
|
|
193
|
+
..._schedule,
|
|
194
|
+
repeat_rule: {
|
|
195
|
+
..._schedule.repeat_rule,
|
|
196
|
+
end: {
|
|
197
|
+
..._schedule.repeat_rule.end,
|
|
198
|
+
end_date: _schedule.end_time
|
|
199
|
+
}
|
|
200
|
+
}
|
|
186
201
|
};
|
|
187
202
|
}
|
|
188
203
|
const dateRanges = (0, import_utils2.calcScheduleDateRange)({ ..._schedule });
|
|
@@ -83,74 +83,93 @@ function findFastestAvailableResource({
|
|
|
83
83
|
const currentTime = (0, import_dayjs.default)();
|
|
84
84
|
let fastestTime = null;
|
|
85
85
|
let fastestResources = [];
|
|
86
|
+
console.log("[TimeslotUtils] 查找最快可用资源:", {
|
|
87
|
+
currentTime: currentTime.format("YYYY-MM-DD HH:mm:ss"),
|
|
88
|
+
resourceCount: resources.length,
|
|
89
|
+
currentCapacity,
|
|
90
|
+
countMap
|
|
91
|
+
});
|
|
86
92
|
for (const resource of resources) {
|
|
87
93
|
const todayTimes = resource.times.filter((time) => {
|
|
88
|
-
|
|
94
|
+
const isToday = (0, import_dayjs.default)(time.start_at).isSame(currentTime, "day");
|
|
95
|
+
const isStillWorking = (0, import_dayjs.default)(time.end_at).isAfter(currentTime);
|
|
96
|
+
return isToday && isStillWorking;
|
|
89
97
|
});
|
|
90
|
-
if (todayTimes.length === 0)
|
|
98
|
+
if (todayTimes.length === 0) {
|
|
99
|
+
console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 今日无可用时间段`);
|
|
91
100
|
continue;
|
|
92
|
-
|
|
93
|
-
return (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at));
|
|
94
|
-
});
|
|
101
|
+
}
|
|
95
102
|
for (const time of todayTimes) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
const workStartTime = (0, import_dayjs.default)(time.start_at);
|
|
104
|
+
const workEndTime = (0, import_dayjs.default)(time.end_at);
|
|
105
|
+
let nextAvailableTime = currentTime.isBefore(workStartTime) ? workStartTime : currentTime;
|
|
106
|
+
console.log(`[TimeslotUtils] 检查资源 ${resource.id}(${resource.main_field}):`, {
|
|
107
|
+
workTime: `${workStartTime.format("HH:mm")}-${workEndTime.format("HH:mm")}`,
|
|
108
|
+
checkStartTime: nextAvailableTime.format("HH:mm:ss"),
|
|
109
|
+
eventCount: ((_a = time.event_list) == null ? void 0 : _a.length) || 0
|
|
110
|
+
});
|
|
111
|
+
const relevantEvents = ((_b = time.event_list) == null ? void 0 : _b.filter((event) => {
|
|
112
|
+
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
113
|
+
return eventEnd.isAfter(nextAvailableTime);
|
|
114
|
+
})) || [];
|
|
115
|
+
relevantEvents.sort(
|
|
116
|
+
(a, b) => (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at))
|
|
117
|
+
);
|
|
118
|
+
let finalAvailableTime = nextAvailableTime;
|
|
119
|
+
for (const event of relevantEvents) {
|
|
120
|
+
const eventStart = (0, import_dayjs.default)(event.start_at);
|
|
121
|
+
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
122
|
+
console.log(`[TimeslotUtils] 检查事件冲突:`, {
|
|
123
|
+
resourceId: resource.id,
|
|
124
|
+
eventTime: `${eventStart.format("HH:mm")}-${eventEnd.format("HH:mm")}`,
|
|
125
|
+
checkTime: finalAvailableTime.format("HH:mm:ss"),
|
|
126
|
+
pax: event.pax || 1
|
|
102
127
|
});
|
|
103
|
-
if (
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} else if (startTime.isBefore(fastestTime)) {
|
|
108
|
-
fastestTime = startTime;
|
|
109
|
-
fastestResources = [resource];
|
|
128
|
+
if (resource.resourceType === "single" || (resource.capacity || 1) === 1) {
|
|
129
|
+
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(30, "minute"))) {
|
|
130
|
+
finalAvailableTime = eventEnd;
|
|
131
|
+
console.log(`[TimeslotUtils] 发现时间冲突,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
|
|
110
132
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
fastestTime = startTime;
|
|
122
|
-
fastestResources.push(resource);
|
|
123
|
-
} else if (startTime.isBefore(fastestTime)) {
|
|
124
|
-
fastestTime = startTime;
|
|
125
|
-
fastestResources = [resource];
|
|
133
|
+
} else {
|
|
134
|
+
const totalCapacity = resource.capacity || 0;
|
|
135
|
+
const currentUsedCapacity = countMap[resource.id] || 0;
|
|
136
|
+
const eventUsedCapacity = event.pax || 1;
|
|
137
|
+
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(30, "minute"))) {
|
|
138
|
+
const totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
|
|
139
|
+
if (totalRequiredCapacity > totalCapacity) {
|
|
140
|
+
finalAvailableTime = eventEnd;
|
|
141
|
+
console.log(`[TimeslotUtils] 容量不足,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
|
|
142
|
+
}
|
|
126
143
|
}
|
|
127
|
-
break;
|
|
128
144
|
}
|
|
129
145
|
}
|
|
146
|
+
if (finalAvailableTime.isAfter(workEndTime)) {
|
|
147
|
+
console.log(`[TimeslotUtils] 资源 ${resource.id} 可用时间超出工作时间,跳过`);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 最快可用时间: ${finalAvailableTime.format("HH:mm:ss")}`);
|
|
151
|
+
if (!fastestTime || finalAvailableTime.isBefore(fastestTime)) {
|
|
152
|
+
fastestTime = finalAvailableTime;
|
|
153
|
+
fastestResources = [resource];
|
|
154
|
+
console.log(`[TimeslotUtils] 更新最快时间: ${fastestTime.format("HH:mm:ss")}, 资源: ${resource.main_field}`);
|
|
155
|
+
} else if (finalAvailableTime.isSame(fastestTime)) {
|
|
156
|
+
fastestResources.push(resource);
|
|
157
|
+
console.log(`[TimeslotUtils] 添加相同时间资源: ${resource.main_field}`);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
130
160
|
}
|
|
131
161
|
}
|
|
132
|
-
if (!fastestTime || fastestResources.length === 0)
|
|
162
|
+
if (!fastestTime || fastestResources.length === 0) {
|
|
163
|
+
console.log("[TimeslotUtils] 未找到可用资源");
|
|
133
164
|
return null;
|
|
134
|
-
|
|
165
|
+
}
|
|
166
|
+
console.log(`[TimeslotUtils] 找到 ${fastestResources.length} 个最快可用资源,时间: ${fastestTime.format("HH:mm:ss")}`);
|
|
167
|
+
if (fastestResources.length === 1) {
|
|
168
|
+
console.log(`[TimeslotUtils] 返回唯一最快资源: ${fastestResources[0].main_field}`);
|
|
135
169
|
return fastestResources[0];
|
|
136
|
-
let maxIdleTime = 0;
|
|
137
|
-
let selectedResource = null;
|
|
138
|
-
for (const resource of fastestResources) {
|
|
139
|
-
const idleTime = calculateResourceAvailableTime({
|
|
140
|
-
resource,
|
|
141
|
-
timeSlots: {
|
|
142
|
-
start_time: fastestTime.format("HH:mm"),
|
|
143
|
-
end_time: fastestTime.format("HH:mm"),
|
|
144
|
-
start_at: fastestTime,
|
|
145
|
-
end_at: fastestTime
|
|
146
|
-
},
|
|
147
|
-
currentCapacity: (countMap[resource.id] || 0) + currentCapacity
|
|
148
|
-
});
|
|
149
|
-
if (idleTime > maxIdleTime) {
|
|
150
|
-
maxIdleTime = idleTime;
|
|
151
|
-
selectedResource = resource;
|
|
152
|
-
}
|
|
153
170
|
}
|
|
171
|
+
const selectedResource = fastestResources[0];
|
|
172
|
+
console.log(`[TimeslotUtils] 返回多个资源中的第一个: ${selectedResource.main_field}`);
|
|
154
173
|
return selectedResource;
|
|
155
174
|
}
|
|
156
175
|
function filterConditionTimeSlots(times, startTime, endTime) {
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -40,6 +40,9 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
40
40
|
quantity: number;
|
|
41
41
|
selling_price: number;
|
|
42
42
|
}[];
|
|
43
|
+
initWalletData(params?: {
|
|
44
|
+
order_wait_pay_amount: number;
|
|
45
|
+
}): Promise<void>;
|
|
43
46
|
/**
|
|
44
47
|
* 创建本地订单 (前端模拟下单流程)
|
|
45
48
|
*
|
|
@@ -95,6 +98,10 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
95
98
|
* 强制重新从服务器获取支付方式列表,更新本地缓存
|
|
96
99
|
*/
|
|
97
100
|
refreshPaymentMethodsAsync(): Promise<PaymentMethod[]>;
|
|
101
|
+
/**
|
|
102
|
+
* 获取订单原始数据
|
|
103
|
+
*/
|
|
104
|
+
getOrderOriginalData(): any;
|
|
98
105
|
/**
|
|
99
106
|
* 获取当前订单基础信息
|
|
100
107
|
*
|
|
@@ -411,5 +418,19 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
411
418
|
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
412
419
|
cover?: boolean;
|
|
413
420
|
}): Promise<void>;
|
|
421
|
+
/**
|
|
422
|
+
* 通过订单ID编辑订单备注
|
|
423
|
+
*
|
|
424
|
+
* 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
|
|
425
|
+
*
|
|
426
|
+
* @param orderId 后端订单ID
|
|
427
|
+
* @param note 新的订单备注
|
|
428
|
+
* @returns 修改结果
|
|
429
|
+
*/
|
|
430
|
+
editOrderNoteByOrderIdAsync(orderId: string | number, note: string): Promise<{
|
|
431
|
+
success: boolean;
|
|
432
|
+
message?: string;
|
|
433
|
+
orderId?: string | number;
|
|
434
|
+
}>;
|
|
414
435
|
destroy(): Promise<void>;
|
|
415
436
|
}
|
|
@@ -124,14 +124,40 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
124
124
|
if (!this.store.currentOrder) {
|
|
125
125
|
return [];
|
|
126
126
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
const getDiscountListAmount = (list) => {
|
|
128
|
+
return list.reduce((pre, item) => {
|
|
129
|
+
return pre + (item.amount || 0);
|
|
130
|
+
}, 0);
|
|
131
|
+
};
|
|
132
|
+
const productList = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data.bookings.map(
|
|
133
|
+
(item) => ({
|
|
134
|
+
product_id: item.product.product_id,
|
|
135
|
+
product_variant_id: item.product.product_variant_id,
|
|
136
|
+
quantity: item.product.num,
|
|
137
|
+
selling_price: item.product.price - (item.product.discount_amount || 0) - getDiscountListAmount(item.product.discount_list)
|
|
138
|
+
})
|
|
139
|
+
);
|
|
133
140
|
return productList;
|
|
134
141
|
}
|
|
142
|
+
async initWalletData(params) {
|
|
143
|
+
var _a, _b, _c;
|
|
144
|
+
const amountInfo = (_b = (_a = this.store.currentOrder) == null ? void 0 : _a.order_info) == null ? void 0 : _b.amount_breakdown;
|
|
145
|
+
if (!amountInfo) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const walletBusinessData = {
|
|
149
|
+
customer_id: ((_c = this.store.currentCustomer) == null ? void 0 : _c.customer_id) ? Number(this.store.currentCustomer.customer_id) : void 0,
|
|
150
|
+
amountInfo: {
|
|
151
|
+
totalAmount: amountInfo.totalAmount,
|
|
152
|
+
subTotal: amountInfo.subTotal
|
|
153
|
+
},
|
|
154
|
+
products: this.getProductListByOrder(),
|
|
155
|
+
...params
|
|
156
|
+
};
|
|
157
|
+
await this.payment.wallet.initializeWalletDataFromBusinessAsync(
|
|
158
|
+
walletBusinessData
|
|
159
|
+
);
|
|
160
|
+
}
|
|
135
161
|
/**
|
|
136
162
|
* 创建本地订单 (前端模拟下单流程)
|
|
137
163
|
*
|
|
@@ -140,7 +166,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
140
166
|
* 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
|
|
141
167
|
*/
|
|
142
168
|
async createLocalOrderAsync(params) {
|
|
143
|
-
var _a, _b, _c, _d
|
|
169
|
+
var _a, _b, _c, _d;
|
|
144
170
|
try {
|
|
145
171
|
await this.setStatus(import_types.CheckoutStatus.CreatingOrder);
|
|
146
172
|
const validation = await this.validateLocalOrderData(params.orderData);
|
|
@@ -186,17 +212,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
186
212
|
}
|
|
187
213
|
});
|
|
188
214
|
this.store.currentOrder = paymentOrder;
|
|
189
|
-
|
|
190
|
-
customer_id: ((_e = this.store.currentCustomer) == null ? void 0 : _e.customer_id) ? Number(this.store.currentCustomer.customer_id) : void 0,
|
|
191
|
-
amountInfo: {
|
|
192
|
-
totalAmount: amountInfo.totalAmount,
|
|
193
|
-
subTotal: amountInfo.subTotal
|
|
194
|
-
},
|
|
195
|
-
products: this.getProductListByOrder()
|
|
196
|
-
};
|
|
197
|
-
const walletData = await this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
198
|
-
console.log(walletData.walletRecommendList, "walletRecommendList");
|
|
199
|
-
console.log(walletData.userIdentificationCodes, "userIdentificationCodes");
|
|
215
|
+
await this.initWalletData();
|
|
200
216
|
await this.setStatus(import_types.CheckoutStatus.OrderCreated);
|
|
201
217
|
await this.setStep(import_types.CheckoutStep.PaymentMethod);
|
|
202
218
|
if (params.autoPayment) {
|
|
@@ -523,6 +539,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
523
539
|
await this.preloadPaymentMethods();
|
|
524
540
|
return this.store.paymentMethods;
|
|
525
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* 获取订单原始数据
|
|
544
|
+
*/
|
|
545
|
+
getOrderOriginalData() {
|
|
546
|
+
var _a;
|
|
547
|
+
return (_a = this.store.currentOrder) == null ? void 0 : _a.order_info;
|
|
548
|
+
}
|
|
526
549
|
/**
|
|
527
550
|
* 获取当前订单基础信息
|
|
528
551
|
*
|
|
@@ -2029,7 +2052,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2029
2052
|
realOrderId,
|
|
2030
2053
|
virtualOrderId: this.store.currentOrder.order_id,
|
|
2031
2054
|
timestamp: Date.now(),
|
|
2032
|
-
isManual
|
|
2055
|
+
isManual,
|
|
2056
|
+
response: checkoutResponse
|
|
2033
2057
|
});
|
|
2034
2058
|
const finalOrderId = this.store.currentOrder.order_id;
|
|
2035
2059
|
const finalIsVirtual = this.isVirtualOrderId(finalOrderId || "");
|
|
@@ -2090,6 +2114,77 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2090
2114
|
this.otherParams = { ...this.otherParams, ...params };
|
|
2091
2115
|
}
|
|
2092
2116
|
}
|
|
2117
|
+
/**
|
|
2118
|
+
* 通过订单ID编辑订单备注
|
|
2119
|
+
*
|
|
2120
|
+
* 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
|
|
2121
|
+
*
|
|
2122
|
+
* @param orderId 后端订单ID
|
|
2123
|
+
* @param note 新的订单备注
|
|
2124
|
+
* @returns 修改结果
|
|
2125
|
+
*/
|
|
2126
|
+
async editOrderNoteByOrderIdAsync(orderId, note) {
|
|
2127
|
+
try {
|
|
2128
|
+
console.log("[Checkout] 开始编辑订单备注:", {
|
|
2129
|
+
orderId,
|
|
2130
|
+
note,
|
|
2131
|
+
noteLength: note.length
|
|
2132
|
+
});
|
|
2133
|
+
if (!orderId) {
|
|
2134
|
+
return {
|
|
2135
|
+
success: false,
|
|
2136
|
+
message: "订单ID不能为空",
|
|
2137
|
+
orderId
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
const response = await this.request.put(`/shop/order/order/${orderId}/note`, {
|
|
2141
|
+
note
|
|
2142
|
+
});
|
|
2143
|
+
console.log("[Checkout] 订单备注编辑响应:", {
|
|
2144
|
+
orderId,
|
|
2145
|
+
status: response.status,
|
|
2146
|
+
message: response.message,
|
|
2147
|
+
response
|
|
2148
|
+
});
|
|
2149
|
+
if (response.status === true || response.status === 200) {
|
|
2150
|
+
console.log(`[Checkout] 订单 ${orderId} 备注修改成功`);
|
|
2151
|
+
if (this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId))) {
|
|
2152
|
+
console.log("[Checkout] 更新本地订单备注状态");
|
|
2153
|
+
const previousNote = this.getOrderNote();
|
|
2154
|
+
if (this.store.localOrderData) {
|
|
2155
|
+
this.store.localOrderData.shop_note = note;
|
|
2156
|
+
}
|
|
2157
|
+
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderNoteChanged, {
|
|
2158
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
2159
|
+
oldNote: previousNote,
|
|
2160
|
+
newNote: note,
|
|
2161
|
+
timestamp: Date.now()
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
return {
|
|
2165
|
+
success: true,
|
|
2166
|
+
message: response.message || "订单备注修改成功",
|
|
2167
|
+
orderId
|
|
2168
|
+
};
|
|
2169
|
+
} else {
|
|
2170
|
+
const errorMessage = response.message || "订单备注修改失败";
|
|
2171
|
+
console.error(`[Checkout] 订单 ${orderId} 备注修改失败:`, errorMessage);
|
|
2172
|
+
return {
|
|
2173
|
+
success: false,
|
|
2174
|
+
message: errorMessage,
|
|
2175
|
+
orderId
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
} catch (error) {
|
|
2179
|
+
console.error("[Checkout] 编辑订单备注失败:", error);
|
|
2180
|
+
const errorMessage = error instanceof Error ? error.message : "网络错误或服务器异常";
|
|
2181
|
+
return {
|
|
2182
|
+
success: false,
|
|
2183
|
+
message: `编辑订单备注失败: ${errorMessage}`,
|
|
2184
|
+
orderId
|
|
2185
|
+
};
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2093
2188
|
async destroy() {
|
|
2094
2189
|
var _a, _b, _c, _d;
|
|
2095
2190
|
this.payment.wallet.clearAllCache();
|
|
@@ -661,6 +661,20 @@ export interface CheckoutModuleAPI extends Module {
|
|
|
661
661
|
orderId?: string;
|
|
662
662
|
orderUuid?: string;
|
|
663
663
|
}>;
|
|
664
|
+
/**
|
|
665
|
+
* 通过订单ID编辑订单备注
|
|
666
|
+
*
|
|
667
|
+
* 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
|
|
668
|
+
*
|
|
669
|
+
* @param orderId 后端订单ID
|
|
670
|
+
* @param note 新的订单备注
|
|
671
|
+
* @returns 修改结果
|
|
672
|
+
*/
|
|
673
|
+
editOrderNoteByOrderIdAsync(orderId: string | number, note: string): Promise<{
|
|
674
|
+
success: boolean;
|
|
675
|
+
message?: string;
|
|
676
|
+
orderId?: string | number;
|
|
677
|
+
}>;
|
|
664
678
|
}
|
|
665
679
|
/**
|
|
666
680
|
* 结账事件数据类型
|