@pisell/pisellos 2.3.108 → 2.3.110
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/OpenData/index.d.ts +1 -1
- package/dist/modules/OpenData/index.js +19 -11
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +22 -21
- package/dist/server/index.js +4 -5
- package/dist/server/utils/small-ticket.d.ts +7 -5
- package/dist/server/utils/small-ticket.js +653 -138
- package/dist/solution/BaseSales/index.js +62 -42
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +548 -485
- package/dist/utils/os-private-payload.d.ts +5 -0
- package/dist/utils/os-private-payload.js +17 -0
- package/lib/modules/OpenData/index.d.ts +1 -1
- package/lib/modules/OpenData/index.js +9 -1
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +15 -18
- package/lib/server/index.js +4 -5
- package/lib/server/utils/small-ticket.d.ts +7 -5
- package/lib/server/utils/small-ticket.js +504 -65
- package/lib/solution/BaseSales/index.js +16 -2
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +32 -3
- package/lib/utils/os-private-payload.d.ts +5 -0
- package/lib/utils/os-private-payload.js +22 -0
- package/package.json +1 -1
|
@@ -3282,10 +3282,24 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3282
3282
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3283
3283
|
const beforePayments = (0, _lodashEs.cloneDeep)(this.store.order.getOrderPayments());
|
|
3284
3284
|
const pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
3285
|
+
const amountSnapshot = this.store.order.getOrderAmountSnapshot?.();
|
|
3285
3286
|
if (pendingWalletAmount.lte(0)) {
|
|
3286
|
-
|
|
3287
|
+
this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
|
|
3288
|
+
amountGap: amountSnapshot?.amountGap
|
|
3289
|
+
});
|
|
3290
|
+
const submitResult = await this.submitSalesOrder({
|
|
3291
|
+
smallTicketDataFlag: 1
|
|
3292
|
+
});
|
|
3293
|
+
if (isRejectedSalesSubmitResult(submitResult)) {
|
|
3294
|
+
throw new Error(getSalesSubmitErrorMessage(submitResult, '订单提交失败'));
|
|
3295
|
+
}
|
|
3296
|
+
const latestAmountSnapshot = this.store.order.getOrderAmountSnapshot?.();
|
|
3297
|
+
return {
|
|
3298
|
+
submitResult,
|
|
3299
|
+
payments: this.store.order.getOrderPayments(),
|
|
3300
|
+
isOrderFullyPaid: new _decimal.default(latestAmountSnapshot?.amountGap || 0).lte(0)
|
|
3301
|
+
};
|
|
3287
3302
|
}
|
|
3288
|
-
const amountSnapshot = this.store.order.getOrderAmountSnapshot?.();
|
|
3289
3303
|
const effectiveAmountDue = _decimal.default.max(new _decimal.default(amountSnapshot?.amountGap || 0).minus(pendingWalletAmount), 0);
|
|
3290
3304
|
if (effectiveAmountDue.gt(0.01)) {
|
|
3291
3305
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
@@ -45,6 +45,12 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
45
45
|
*/
|
|
46
46
|
protected createSubModule(moduleName: string): Module | null;
|
|
47
47
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
48
|
+
private getInjectedOpenDataConfig;
|
|
49
|
+
/**
|
|
50
|
+
* 在解决方案对外 ready 前准备 Invoice Document;失败只降级模板,不阻断销售。
|
|
51
|
+
* 已由页面取得的 OpenData 直接交给模块接管,没有注入数据时再走 target-scoped 加载。
|
|
52
|
+
*/
|
|
53
|
+
private prepareInvoiceTemplateAtSolutionReady;
|
|
48
54
|
protected getBookingTicketBusinessCode(): string | null;
|
|
49
55
|
private getIdGeneratorPlugin;
|
|
50
56
|
private loadOpenDataConfig;
|
|
@@ -193,10 +193,37 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
193
193
|
throw new Error('bookingTicket解决方案需要 request 插件支持');
|
|
194
194
|
}
|
|
195
195
|
this.platform = this.otherParams?.platform;
|
|
196
|
+
await this.prepareInvoiceTemplateAtSolutionReady(this.getInjectedOpenDataConfig());
|
|
196
197
|
await this.configureIdGeneratorFromOpenData();
|
|
197
198
|
}
|
|
199
|
+
getInjectedOpenDataConfig() {
|
|
200
|
+
const openData = this.otherParams?.openData;
|
|
201
|
+
return openData && typeof openData === 'object' && !Array.isArray(openData) ? openData : undefined;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 在解决方案对外 ready 前准备 Invoice Document;失败只降级模板,不阻断销售。
|
|
206
|
+
* 已由页面取得的 OpenData 直接交给模块接管,没有注入数据时再走 target-scoped 加载。
|
|
207
|
+
*/
|
|
208
|
+
async prepareInvoiceTemplateAtSolutionReady(injectedOpenData) {
|
|
209
|
+
const businessCode = this.getBookingTicketBusinessCode();
|
|
210
|
+
if (!businessCode || !this.store.openData) return;
|
|
211
|
+
const channel = this.getSubmitOrderSalesChannel();
|
|
212
|
+
const target = `${businessCode}+${channel}`;
|
|
213
|
+
try {
|
|
214
|
+
if (injectedOpenData && typeof this.store.openData.ensureInvoiceTemplateSettings === 'function') {
|
|
215
|
+
this.openDataTarget = target;
|
|
216
|
+
await this.store.openData.ensureInvoiceTemplateSettings(target, injectedOpenData);
|
|
217
|
+
this.otherParams.openData = injectedOpenData;
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
await this.loadOpenDataConfig();
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.warn('[BookingTicket] Invoice 模板预加载失败,使用默认配置', error);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
198
225
|
getBookingTicketBusinessCode() {
|
|
199
|
-
const candidates = [this.otherParams?.businessCode, this.otherParams?.business_code, this.getOrderHeader()?.business_code, this.store.order?.getTempOrder()?.business_code, this.getSalesOrder()?.raw?.business_code];
|
|
226
|
+
const candidates = [this.otherParams?.businessCode, this.otherParams?.business_code, this.getOrderHeader()?.business_code, typeof this.store.order?.getTempOrder === 'function' ? this.store.order.getTempOrder()?.business_code : undefined, this.getSalesOrder()?.raw?.business_code];
|
|
200
227
|
for (const candidate of candidates) {
|
|
201
228
|
if (candidate === undefined || candidate === null) continue;
|
|
202
229
|
const normalized = String(candidate).trim();
|
|
@@ -1784,10 +1811,12 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1784
1811
|
await super.setOtherParams(params, {
|
|
1785
1812
|
cover
|
|
1786
1813
|
});
|
|
1814
|
+
const invoiceContextChanged = params?.businessCode !== undefined || params?.business_code !== undefined || params?.channel !== undefined || params?.platform !== undefined || Object.prototype.hasOwnProperty.call(params, 'openData');
|
|
1815
|
+
if (invoiceContextChanged) {
|
|
1816
|
+
await this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
|
|
1817
|
+
}
|
|
1787
1818
|
if (params?.businessCode !== undefined || params?.business_code !== undefined) {
|
|
1788
1819
|
await this.configureIdGeneratorFromOpenData();
|
|
1789
|
-
} else if (params?.channel !== undefined) {
|
|
1790
|
-
await this.loadOpenDataConfig();
|
|
1791
1820
|
}
|
|
1792
1821
|
}
|
|
1793
1822
|
getDeviceTaskPlugin() {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.stripOsPrivatePayloadFields = stripOsPrivatePayloadFields;
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
8
|
+
const OS_PRIVATE_FIELD_PREFIX = '_os_';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Remove top-level fields reserved for communication with the PisellOS proxy.
|
|
12
|
+
* Nested business payloads are intentionally left untouched.
|
|
13
|
+
*/
|
|
14
|
+
function stripOsPrivatePayloadFields(data) {
|
|
15
|
+
const next = (0, _lodashEs.cloneDeep)(data);
|
|
16
|
+
if (!next || typeof next !== 'object' || Array.isArray(next)) return next;
|
|
17
|
+
const record = next;
|
|
18
|
+
Object.keys(record).forEach(key => {
|
|
19
|
+
if (key.startsWith(OS_PRIVATE_FIELD_PREFIX)) delete record[key];
|
|
20
|
+
});
|
|
21
|
+
return next;
|
|
22
|
+
}
|