@pisell/pisellos 2.3.29 → 2.3.31
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.d.ts +27 -8
- package/dist/modules/Order/index.js +736 -473
- package/dist/modules/Order/payment-utils.d.ts +23 -0
- package/dist/modules/Order/payment-utils.js +203 -0
- package/dist/modules/Order/types.d.ts +33 -1
- package/dist/modules/Order/utils.js +4 -4
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +26 -24
- package/dist/modules/Payment/types.js +2 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.js +1850 -1024
- package/dist/server/modules/order/index.d.ts +40 -3
- package/dist/server/modules/order/index.js +1200 -501
- package/dist/server/modules/order/types.d.ts +11 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +33 -3
- package/dist/solution/BaseSales/index.js +609 -322
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -1
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +27 -8
- package/lib/modules/Order/index.js +180 -60
- package/lib/modules/Order/payment-utils.d.ts +23 -0
- package/lib/modules/Order/payment-utils.js +193 -0
- package/lib/modules/Order/types.d.ts +33 -1
- package/lib/modules/Order/utils.js +2 -3
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +26 -24
- package/lib/server/index.d.ts +14 -0
- package/lib/server/index.js +604 -8
- package/lib/server/modules/order/index.d.ts +40 -3
- package/lib/server/modules/order/index.js +434 -31
- package/lib/server/modules/order/types.d.ts +11 -3
- package/lib/solution/BaseSales/index.d.ts +33 -3
- package/lib/solution/BaseSales/index.js +167 -7
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -213,10 +213,12 @@ export interface OrderBookingItem {
|
|
|
213
213
|
[key: string]: unknown;
|
|
214
214
|
}[];
|
|
215
215
|
}
|
|
216
|
-
/** 支付记录 metadata
|
|
216
|
+
/** 支付记录 metadata */
|
|
217
217
|
export interface OrderPaymentMetadata {
|
|
218
|
-
/**
|
|
218
|
+
/** 三方支付交易流水号 */
|
|
219
219
|
unique_payment_number?: string;
|
|
220
|
+
/** 刷卡机设备快照;server 不解析内部字段,仅透传并持久化 */
|
|
221
|
+
card_reader_snapshot?: Record<string, unknown>;
|
|
220
222
|
[key: string]: unknown;
|
|
221
223
|
}
|
|
222
224
|
/**
|
|
@@ -225,6 +227,8 @@ export interface OrderPaymentMetadata {
|
|
|
225
227
|
export interface OrderPaymentItem {
|
|
226
228
|
/** 支付记录 ID;存量/更新时传。来源:OrderPayment.id */
|
|
227
229
|
order_payment_id?: number | null;
|
|
230
|
+
/** 支付项稳定唯一号;历史支付项允许缺失 */
|
|
231
|
+
payment_number?: string;
|
|
228
232
|
/** 支付方式 ID(设备端从本地支付方式配置取详情)。来源:OrderPayment.custom_payment_id */
|
|
229
233
|
custom_payment_id?: number;
|
|
230
234
|
/** 支付方式编码。来源:OrderPayment.payment_method */
|
|
@@ -249,11 +253,13 @@ export interface OrderPaymentItem {
|
|
|
249
253
|
created_at?: string | null;
|
|
250
254
|
/** 手续费配置。来源:OrderPayment.service_charge */
|
|
251
255
|
service_charge?: Record<string, unknown> | null;
|
|
256
|
+
/** 已计算的支付手续费。来源:OrderPayment.service_fee */
|
|
257
|
+
service_fee?: OrderMoneyString;
|
|
252
258
|
/** Wallet Pass 使用单位 */
|
|
253
259
|
wallet_pass_usage_unit?: unknown[] | null;
|
|
254
260
|
/** Wallet Pass 使用值 */
|
|
255
261
|
wallet_pass_use_value?: number | null;
|
|
256
|
-
/**
|
|
262
|
+
/** 元数据;三方支付成功后可含 unique_payment_number */
|
|
257
263
|
metadata?: OrderPaymentMetadata | null;
|
|
258
264
|
}
|
|
259
265
|
/**
|
|
@@ -413,6 +419,8 @@ export interface OrderData {
|
|
|
413
419
|
create_date?: string;
|
|
414
420
|
/** 本地待同步标记:1 表示需要后续同步到云端 */
|
|
415
421
|
need_sync?: 0 | 1 | number;
|
|
422
|
+
/** 本地草稿标记:1 表示仅为 POS 可恢复草稿,不代表已提交云端 */
|
|
423
|
+
is_draft_order?: 0 | 1 | number;
|
|
416
424
|
/** 兼容:部分场景仍使用顶层 total_amount */
|
|
417
425
|
total_amount?: OrderMoneyString | number;
|
|
418
426
|
/** 扩展字段(物流、标签等);使用 any 以便筛选与数据源扩展 */
|
|
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
|
-
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
|
|
5
|
+
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
7
|
import type { Discount } from '../../modules/Discount/types';
|
|
8
8
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
@@ -24,6 +24,19 @@ export interface BaseSalesState {
|
|
|
24
24
|
schedule?: ScheduleModule;
|
|
25
25
|
quotation?: QuotationModule;
|
|
26
26
|
}
|
|
27
|
+
export interface BaseSalesUpdateOrderPaymentOptions extends OrderPaymentUpdateOptions {
|
|
28
|
+
persistDraft?: boolean;
|
|
29
|
+
submitWhenPaid?: boolean;
|
|
30
|
+
forceSubmitIfPaid?: boolean;
|
|
31
|
+
/** 草稿恢复时,允许将新回调字段合并进已 paid 的支付项。 */
|
|
32
|
+
applyUpdatesWhenPaid?: boolean;
|
|
33
|
+
smallTicketDataFlag?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface BaseSalesUpdateOrderPaymentResult extends OrderPaymentUpdateResult {
|
|
36
|
+
draftResult?: unknown;
|
|
37
|
+
draftError?: unknown;
|
|
38
|
+
syncResult?: SyncPaymentsToOrderResult<any>;
|
|
39
|
+
}
|
|
27
40
|
export type BaseSalesPrintLocalOrderReceiptParams = string | number;
|
|
28
41
|
export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
29
42
|
protected defaultName: string;
|
|
@@ -128,6 +141,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
128
141
|
*/
|
|
129
142
|
protected readSessionCacheData(): Record<string, any>;
|
|
130
143
|
protected getAppData<T>(key: string): T | undefined;
|
|
144
|
+
private getPaymentNumberDevicePrefixSync;
|
|
145
|
+
private getPaymentNumberDevicePrefixAsync;
|
|
131
146
|
private syncAppDataToTempOrder;
|
|
132
147
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
133
148
|
destroy(): Promise<void>;
|
|
@@ -240,6 +255,13 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
240
255
|
confirmPendingVoucherPayments?: boolean;
|
|
241
256
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
242
257
|
}): Promise<T>;
|
|
258
|
+
saveSalesOrderDraft<T = any>(params?: {
|
|
259
|
+
platform?: string;
|
|
260
|
+
businessCode?: string;
|
|
261
|
+
channel?: string;
|
|
262
|
+
type?: string;
|
|
263
|
+
enhancePayload?: SubmitPayloadEnhancer;
|
|
264
|
+
}): Promise<T>;
|
|
243
265
|
submitTempOrderAsync<T = any>(params?: {
|
|
244
266
|
payments?: OrderPaymentSource[];
|
|
245
267
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
@@ -258,16 +280,24 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
258
280
|
private queueLatestAutoPaymentSync;
|
|
259
281
|
private scheduleQueuedAutoPaymentSyncFlush;
|
|
260
282
|
private flushQueuedAutoPaymentSync;
|
|
261
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
285
|
+
*/
|
|
262
286
|
addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
|
|
287
|
+
/** 创建新支付项时读取最新设备短号,不缓存运行时设备信息。 */
|
|
288
|
+
addOrderPaymentAsync(payment: OrderPaymentSource): Promise<OrderPaymentData[]>;
|
|
289
|
+
private addOrderPaymentWithDevicePrefix;
|
|
263
290
|
/** 更新当前订单中的指定支付项。 */
|
|
264
|
-
updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any
|
|
291
|
+
updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>, options?: BaseSalesUpdateOrderPaymentOptions): Promise<BaseSalesUpdateOrderPaymentResult>;
|
|
265
292
|
/** 删除当前订单中的指定支付项。 */
|
|
266
293
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
267
294
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
268
295
|
updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
|
|
269
296
|
status?: 'paid' | 'payment_pending';
|
|
270
297
|
}): OrderPaymentData[];
|
|
298
|
+
updateVoucherOrderPaymentsAsync(payments: OrderPaymentSource[], options?: {
|
|
299
|
+
status?: 'paid' | 'payment_pending';
|
|
300
|
+
}): Promise<OrderPaymentData[]>;
|
|
271
301
|
confirmPendingVoucherPayments(): OrderPaymentData[];
|
|
272
302
|
discardPendingVoucherPayments(): OrderPaymentData[];
|
|
273
303
|
private getWalletProductList;
|
|
@@ -40,6 +40,8 @@ var import_decimal = __toESM(require("decimal.js"));
|
|
|
40
40
|
var import_lodash_es = require("lodash-es");
|
|
41
41
|
var import_types2 = require("../BookingByStep/types");
|
|
42
42
|
var import_utils = require("../../modules/Order/utils");
|
|
43
|
+
var import_payment_utils = require("../../modules/Order/payment-utils");
|
|
44
|
+
var import_payment_number = require("../../utils/payment-number");
|
|
43
45
|
var import_orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
44
46
|
var import_dayjs = __toESM(require("dayjs"));
|
|
45
47
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
@@ -77,6 +79,11 @@ function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
|
77
79
|
(discount == null ? void 0 : discount.isEditMode) || (discount == null ? void 0 : discount.isDisabled) || (discount == null ? void 0 : discount.order_discount_id) != null
|
|
78
80
|
);
|
|
79
81
|
}
|
|
82
|
+
function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
83
|
+
if (key === "products" || key === "bookings")
|
|
84
|
+
return "unique_identification_number";
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
80
87
|
var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
|
|
81
88
|
product: "order_detail_id",
|
|
82
89
|
booking: "schedule_event_id",
|
|
@@ -209,6 +216,35 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
|
209
216
|
}
|
|
210
217
|
return normalizedRecord;
|
|
211
218
|
}
|
|
219
|
+
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
220
|
+
var _a;
|
|
221
|
+
const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a[metadataKey]) ?? (item == null ? void 0 : item[metadataKey]);
|
|
222
|
+
if (uid === void 0 || uid === null || uid === "")
|
|
223
|
+
return null;
|
|
224
|
+
return String(uid);
|
|
225
|
+
}
|
|
226
|
+
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
227
|
+
const result = [];
|
|
228
|
+
const indexByUid = /* @__PURE__ */ new Map();
|
|
229
|
+
const appendOrReplaceByUid = (item) => {
|
|
230
|
+
const clonedItem = (0, import_lodash_es.cloneDeep)(item);
|
|
231
|
+
const uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
|
|
232
|
+
if (!uid) {
|
|
233
|
+
result.push(clonedItem);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const existingIndex = indexByUid.get(uid);
|
|
237
|
+
if (existingIndex !== void 0) {
|
|
238
|
+
result[existingIndex] = clonedItem;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
indexByUid.set(uid, result.length);
|
|
242
|
+
result.push(clonedItem);
|
|
243
|
+
};
|
|
244
|
+
currentValue.forEach(appendOrReplaceByUid);
|
|
245
|
+
loadedValue.forEach(appendOrReplaceByUid);
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
212
248
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
213
249
|
const normalizedLoadedRecord = normalizeBaseSalesRecordCollections(
|
|
214
250
|
loadedRecord || {},
|
|
@@ -237,6 +273,15 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
237
273
|
);
|
|
238
274
|
}
|
|
239
275
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
276
|
+
if (key === "payments" || key === "payment") {
|
|
277
|
+
return (0, import_payment_utils.mergeOrderPaymentListsByIdentity)(currentValue, loadedValue, {
|
|
278
|
+
preserveUnmatchedExisting: true
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
const metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
282
|
+
if (metadataKey) {
|
|
283
|
+
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
284
|
+
}
|
|
240
285
|
return [
|
|
241
286
|
...(0, import_lodash_es.cloneDeep)(currentValue),
|
|
242
287
|
...(0, import_lodash_es.cloneDeep)(loadedValue)
|
|
@@ -796,6 +841,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
796
841
|
const coreData = (_f = (_d = (_c = app == null ? void 0 : app.models) == null ? void 0 : _c.getStore) == null ? void 0 : (_e = _d.call(_c)).getDataByModel) == null ? void 0 : _f.call(_e, "core", "core");
|
|
797
842
|
return coreData == null ? void 0 : coreData[key];
|
|
798
843
|
}
|
|
844
|
+
getPaymentNumberDevicePrefixSync() {
|
|
845
|
+
if (!this.appPlugin)
|
|
846
|
+
return "LOCAL";
|
|
847
|
+
return (0, import_payment_number.resolvePaymentNumberDevicePrefixFromDeviceId)((key) => this.getAppData(key));
|
|
848
|
+
}
|
|
849
|
+
getPaymentNumberDevicePrefixAsync() {
|
|
850
|
+
if (!this.appPlugin)
|
|
851
|
+
return Promise.resolve("LOCAL");
|
|
852
|
+
return (0, import_payment_number.resolvePaymentNumberDevicePrefix)((key) => this.getAppData(key));
|
|
853
|
+
}
|
|
799
854
|
syncAppDataToTempOrder(tempOrder) {
|
|
800
855
|
const isPriceIncludeTax = this.getAppData("is_price_include_tax");
|
|
801
856
|
const taxCountryCode = this.getAppData("tax_country_code");
|
|
@@ -1727,6 +1782,20 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1727
1782
|
};
|
|
1728
1783
|
return this.store.order.submitTempOrder(submitParams);
|
|
1729
1784
|
}
|
|
1785
|
+
async saveSalesOrderDraft(params) {
|
|
1786
|
+
var _a, _b, _c, _d;
|
|
1787
|
+
if (!this.store.order) {
|
|
1788
|
+
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1789
|
+
}
|
|
1790
|
+
return this.store.order.saveTempOrderAsDraft({
|
|
1791
|
+
cacheId: this.cacheId,
|
|
1792
|
+
platform: (params == null ? void 0 : params.platform) ?? ((_a = this.otherParams) == null ? void 0 : _a.platform),
|
|
1793
|
+
businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
1794
|
+
channel: (params == null ? void 0 : params.channel) ?? this.getSubmitOrderSalesChannel(),
|
|
1795
|
+
type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
|
|
1796
|
+
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1730
1799
|
async submitTempOrderAsync(params) {
|
|
1731
1800
|
var _a, _b, _c, _d;
|
|
1732
1801
|
if (!this.store.order) {
|
|
@@ -1927,8 +1996,26 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1927
1996
|
}
|
|
1928
1997
|
}
|
|
1929
1998
|
}
|
|
1930
|
-
/**
|
|
1999
|
+
/**
|
|
2000
|
+
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
2001
|
+
*/
|
|
1931
2002
|
addOrderPayment(payment) {
|
|
2003
|
+
const hasPaymentNumber = String(
|
|
2004
|
+
payment.payment_number || ""
|
|
2005
|
+
).trim() !== "";
|
|
2006
|
+
return this.addOrderPaymentWithDevicePrefix(
|
|
2007
|
+
payment,
|
|
2008
|
+
hasPaymentNumber ? "LOCAL" : this.getPaymentNumberDevicePrefixSync()
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
/** 创建新支付项时读取最新设备短号,不缓存运行时设备信息。 */
|
|
2012
|
+
async addOrderPaymentAsync(payment) {
|
|
2013
|
+
const paymentRecord = payment;
|
|
2014
|
+
const hasPaymentNumber = String(paymentRecord.payment_number || "").trim() !== "";
|
|
2015
|
+
const devicePrefix = hasPaymentNumber ? "LOCAL" : await this.getPaymentNumberDevicePrefixAsync();
|
|
2016
|
+
return this.addOrderPaymentWithDevicePrefix(payment, devicePrefix);
|
|
2017
|
+
}
|
|
2018
|
+
addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
1932
2019
|
var _a;
|
|
1933
2020
|
if (!this.store.order)
|
|
1934
2021
|
throw new Error("order 模块未初始化");
|
|
@@ -1945,21 +2032,26 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1945
2032
|
if (shopWalletPassId !== void 0 && shopWalletPassId !== null) {
|
|
1946
2033
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
1947
2034
|
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
2035
|
+
const normalizedPaymentRecord = (0, import_payment_utils.ensureOrderPaymentNumber)(
|
|
2036
|
+
paymentRecord,
|
|
2037
|
+
devicePrefix,
|
|
2038
|
+
import_utils.createUuidV4
|
|
2039
|
+
);
|
|
1951
2040
|
const paymentTimestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
1952
2041
|
const paymentTime = paymentRecord.payment_time ?? paymentTimestamp;
|
|
1953
2042
|
const createdAt = paymentRecord.created_at ?? paymentTimestamp;
|
|
1954
2043
|
const serviceCharge = paymentRecord.service_charge && typeof paymentRecord.service_charge === "object" ? paymentRecord.service_charge : null;
|
|
1955
2044
|
const calculatedServiceFee = serviceCharge ? new import_decimal.default(paymentRecord.origin_amount ?? paymentRecord.amount ?? 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : void 0;
|
|
1956
2045
|
const payments = this.store.order.addOrderPayment({
|
|
1957
|
-
...
|
|
2046
|
+
...normalizedPaymentRecord,
|
|
1958
2047
|
...calculatedServiceFee !== void 0 ? { service_fee: calculatedServiceFee } : {},
|
|
1959
2048
|
metadata,
|
|
1960
2049
|
payment_time: paymentTime,
|
|
1961
2050
|
created_at: createdAt
|
|
1962
2051
|
});
|
|
2052
|
+
if (paymentRecord.status === "payment_pending") {
|
|
2053
|
+
return payments;
|
|
2054
|
+
}
|
|
1963
2055
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1964
2056
|
const syncState = this.store.order.getOrderSyncState();
|
|
1965
2057
|
if (amountSnapshot) {
|
|
@@ -1981,10 +2073,73 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1981
2073
|
return payments;
|
|
1982
2074
|
}
|
|
1983
2075
|
/** 更新当前订单中的指定支付项。 */
|
|
1984
|
-
updateOrderPayment(paymentIdentity, updates) {
|
|
2076
|
+
async updateOrderPayment(paymentIdentity, updates, options = {}) {
|
|
2077
|
+
var _a, _b, _c;
|
|
1985
2078
|
if (!this.store.order)
|
|
1986
2079
|
throw new Error("order 模块未初始化");
|
|
1987
|
-
|
|
2080
|
+
const matchMode = options.matchBy === "compat" || options.matchBy === "legacy" ? "compat" : "payment_number";
|
|
2081
|
+
const previousMatch = (0, import_payment_utils.resolveOrderPaymentIdentity)(
|
|
2082
|
+
this.store.order.getOrderPayments(),
|
|
2083
|
+
paymentIdentity,
|
|
2084
|
+
matchMode
|
|
2085
|
+
);
|
|
2086
|
+
const previousPayment = previousMatch == null ? void 0 : previousMatch.payment;
|
|
2087
|
+
if ((previousPayment == null ? void 0 : previousPayment.status) === "paid" && !options.applyUpdatesWhenPaid) {
|
|
2088
|
+
const currentPayments = this.store.order.getOrderPayments();
|
|
2089
|
+
let syncResult2;
|
|
2090
|
+
if (options.submitWhenPaid && options.forceSubmitIfPaid) {
|
|
2091
|
+
syncResult2 = await this.syncPaymentsToOrder({
|
|
2092
|
+
payments: currentPayments,
|
|
2093
|
+
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
2094
|
+
submitWhenPaid: true,
|
|
2095
|
+
smallTicketDataFlag: options.smallTicketDataFlag ?? 1
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
return {
|
|
2099
|
+
updated: false,
|
|
2100
|
+
payment: previousPayment,
|
|
2101
|
+
payments: currentPayments,
|
|
2102
|
+
summary: ((_a = this.store.order.getOrderAmountSnapshot()) == null ? void 0 : _a.summary) || null,
|
|
2103
|
+
...syncResult2 !== void 0 ? { syncResult: syncResult2 } : {}
|
|
2104
|
+
};
|
|
2105
|
+
}
|
|
2106
|
+
const result = await this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
2107
|
+
matchBy: matchMode
|
|
2108
|
+
});
|
|
2109
|
+
let draftResult;
|
|
2110
|
+
let draftError;
|
|
2111
|
+
if (options.persistDraft !== false) {
|
|
2112
|
+
try {
|
|
2113
|
+
draftResult = await this.saveSalesOrderDraft();
|
|
2114
|
+
} catch (error) {
|
|
2115
|
+
draftError = error;
|
|
2116
|
+
this.logError("updateOrderPayment: 保存支付草稿失败", {
|
|
2117
|
+
paymentIdentity,
|
|
2118
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2119
|
+
});
|
|
2120
|
+
if (!options.submitWhenPaid)
|
|
2121
|
+
throw error;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
const becamePaid = (previousPayment == null ? void 0 : previousPayment.status) !== "paid" && ((_b = result.payment) == null ? void 0 : _b.status) === "paid";
|
|
2125
|
+
const shouldSubmit = Boolean(
|
|
2126
|
+
options.submitWhenPaid && ((_c = result.payment) == null ? void 0 : _c.status) === "paid" && (becamePaid || options.forceSubmitIfPaid)
|
|
2127
|
+
);
|
|
2128
|
+
let syncResult;
|
|
2129
|
+
if (shouldSubmit) {
|
|
2130
|
+
syncResult = await this.syncPaymentsToOrder({
|
|
2131
|
+
payments: result.payments,
|
|
2132
|
+
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
2133
|
+
submitWhenPaid: true,
|
|
2134
|
+
smallTicketDataFlag: options.smallTicketDataFlag ?? 1
|
|
2135
|
+
});
|
|
2136
|
+
}
|
|
2137
|
+
return {
|
|
2138
|
+
...result,
|
|
2139
|
+
...draftResult !== void 0 ? { draftResult } : {},
|
|
2140
|
+
...draftError !== void 0 ? { draftError } : {},
|
|
2141
|
+
...syncResult !== void 0 ? { syncResult } : {}
|
|
2142
|
+
};
|
|
1988
2143
|
}
|
|
1989
2144
|
/** 删除当前订单中的指定支付项。 */
|
|
1990
2145
|
deleteOrderPayment(paymentIdentity) {
|
|
@@ -1998,6 +2153,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1998
2153
|
throw new Error("order 模块未初始化");
|
|
1999
2154
|
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
2000
2155
|
}
|
|
2156
|
+
async updateVoucherOrderPaymentsAsync(payments, options) {
|
|
2157
|
+
if (!this.store.order)
|
|
2158
|
+
throw new Error("order 模块未初始化");
|
|
2159
|
+
return this.store.order.updateVoucherOrderPaymentsAsync(payments, options);
|
|
2160
|
+
}
|
|
2001
2161
|
confirmPendingVoucherPayments() {
|
|
2002
2162
|
if (!this.store.order)
|
|
2003
2163
|
throw new Error("order 模块未初始化");
|
|
@@ -82,8 +82,13 @@ export interface ISalesBooking {
|
|
|
82
82
|
metadata?: Record<string, any> | null;
|
|
83
83
|
[key: string]: any;
|
|
84
84
|
}
|
|
85
|
+
export interface ISalesPaymentMetadata extends Record<string, any> {
|
|
86
|
+
/** 刷卡机设备快照;OS 不解析内部字段 */
|
|
87
|
+
card_reader_snapshot?: Record<string, unknown>;
|
|
88
|
+
}
|
|
85
89
|
export interface ISalesPayment {
|
|
86
90
|
order_payment_id?: number | null;
|
|
91
|
+
payment_number?: string;
|
|
87
92
|
custom_payment_id?: number;
|
|
88
93
|
code?: string;
|
|
89
94
|
name?: string;
|
|
@@ -95,7 +100,7 @@ export interface ISalesPayment {
|
|
|
95
100
|
status?: string;
|
|
96
101
|
payment_time?: string | null;
|
|
97
102
|
service_charge?: Record<string, any> | null;
|
|
98
|
-
metadata?:
|
|
103
|
+
metadata?: ISalesPaymentMetadata | null;
|
|
99
104
|
[key: string]: any;
|
|
100
105
|
}
|
|
101
106
|
export interface ISalesSurcharge {
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 1 | 2 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|
|
@@ -1153,7 +1153,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
/** 读取当前 booking config。 */
|
|
1155
1155
|
getBookingConfig() {
|
|
1156
|
-
|
|
1156
|
+
var _a;
|
|
1157
|
+
return (_a = this.store.bookingContext) == null ? void 0 : _a.getBookingConfig();
|
|
1157
1158
|
}
|
|
1158
1159
|
/** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
|
|
1159
1160
|
setResources(resources) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PaymentNumberAppDataGetter = (key: string) => unknown;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the synchronous fallback without caching runtime device data.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the latest device segment when a new payment number is generated.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/payment-number.ts
|
|
20
|
+
var payment_number_exports = {};
|
|
21
|
+
__export(payment_number_exports, {
|
|
22
|
+
resolvePaymentNumberDevicePrefix: () => resolvePaymentNumberDevicePrefix,
|
|
23
|
+
resolvePaymentNumberDevicePrefixFromDeviceId: () => resolvePaymentNumberDevicePrefixFromDeviceId
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(payment_number_exports);
|
|
26
|
+
function normalizeNonEmptyString(value) {
|
|
27
|
+
if (value === void 0 || value === null)
|
|
28
|
+
return null;
|
|
29
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
30
|
+
return null;
|
|
31
|
+
if (typeof value === "number" && !Number.isFinite(value))
|
|
32
|
+
return null;
|
|
33
|
+
const normalized = String(value).trim();
|
|
34
|
+
return normalized || null;
|
|
35
|
+
}
|
|
36
|
+
function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
|
|
37
|
+
try {
|
|
38
|
+
const deviceId = normalizeNonEmptyString(getAppData("device_id"));
|
|
39
|
+
if (deviceId && deviceId !== "0")
|
|
40
|
+
return deviceId.slice(-2);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
return "LOCAL";
|
|
44
|
+
}
|
|
45
|
+
async function resolvePaymentNumberDevicePrefix(getAppData) {
|
|
46
|
+
try {
|
|
47
|
+
const getAsyncIotDeviceInfo = getAppData("async_iot_device_info");
|
|
48
|
+
if (typeof getAsyncIotDeviceInfo === "function") {
|
|
49
|
+
const info = await getAsyncIotDeviceInfo();
|
|
50
|
+
const shortNumber = normalizeNonEmptyString(
|
|
51
|
+
info == null ? void 0 : info.short_number
|
|
52
|
+
);
|
|
53
|
+
if (shortNumber && shortNumber !== "0")
|
|
54
|
+
return shortNumber;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
return resolvePaymentNumberDevicePrefixFromDeviceId(getAppData);
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
resolvePaymentNumberDevicePrefix,
|
|
63
|
+
resolvePaymentNumberDevicePrefixFromDeviceId
|
|
64
|
+
});
|