@pisell/pisellos 2.3.113 → 2.3.114
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/Payment/index.d.ts +0 -5
- package/dist/modules/Payment/index.js +35 -85
- package/dist/modules/ResourcePlanner/planner.js +9 -5
- package/dist/modules/ResourcePlanner/types.d.ts +2 -1
- package/dist/server/index.js +4 -0
- package/dist/server/modules/payment/index.d.ts +25 -6
- package/dist/server/modules/payment/index.js +660 -133
- package/dist/solution/BaseSales/index.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +1081 -1042
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Payment/index.d.ts +0 -5
- package/lib/modules/Payment/index.js +3 -28
- package/lib/modules/ResourcePlanner/planner.js +9 -5
- package/lib/modules/ResourcePlanner/types.d.ts +2 -1
- package/lib/server/index.js +4 -0
- package/lib/server/modules/payment/index.d.ts +25 -6
- package/lib/server/modules/payment/index.js +350 -78
- package/lib/solution/BaseSales/index.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +14 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -171,11 +171,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
171
171
|
* 获取钱包支付方式
|
|
172
172
|
*/
|
|
173
173
|
getWalletPaymentMethod(): Promise<PaymentMethod | null>;
|
|
174
|
-
/**
|
|
175
|
-
* 确保支付模块所需的数据库表已创建
|
|
176
|
-
*/
|
|
177
|
-
/** @deprecated */
|
|
178
|
-
private ensurePaymentTables;
|
|
179
174
|
/**
|
|
180
175
|
* 获取部分支付的订单
|
|
181
176
|
*/
|
|
@@ -198,10 +198,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
198
198
|
this.app = this.appPlugin.getApp();
|
|
199
199
|
this.dbManager = this.app.dbManager;
|
|
200
200
|
this.logger = this.app.logger;
|
|
201
|
-
|
|
202
|
-
// 确保支付模块所需的对象存储已创建
|
|
203
|
-
// await this.ensurePaymentTables();
|
|
204
|
-
|
|
205
201
|
this.registerNetworkHandlers();
|
|
206
202
|
|
|
207
203
|
// // 预连接数据库
|
|
@@ -1740,7 +1736,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1740
1736
|
case 0:
|
|
1741
1737
|
_context21.prev = 0;
|
|
1742
1738
|
_context21.next = 3;
|
|
1743
|
-
return this.
|
|
1739
|
+
return this.getPayMethodListAsync();
|
|
1744
1740
|
case 3:
|
|
1745
1741
|
payMethods = _context21.sent;
|
|
1746
1742
|
return _context21.abrupt("return", payMethods.find(function (method) {
|
|
@@ -1776,7 +1772,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1776
1772
|
case 0:
|
|
1777
1773
|
_context22.prev = 0;
|
|
1778
1774
|
_context22.next = 3;
|
|
1779
|
-
return this.
|
|
1775
|
+
return this.getPayMethodListAsync();
|
|
1780
1776
|
case 3:
|
|
1781
1777
|
payMethods = _context22.sent;
|
|
1782
1778
|
return _context22.abrupt("return", payMethods.find(function (method) {
|
|
@@ -1812,7 +1808,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1812
1808
|
case 0:
|
|
1813
1809
|
_context23.prev = 0;
|
|
1814
1810
|
_context23.next = 3;
|
|
1815
|
-
return this.
|
|
1811
|
+
return this.getPayMethodListAsync();
|
|
1816
1812
|
case 3:
|
|
1817
1813
|
payMethods = _context23.sent;
|
|
1818
1814
|
return _context23.abrupt("return", payMethods.find(function (method) {
|
|
@@ -1835,82 +1831,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1835
1831
|
return getWalletPaymentMethod;
|
|
1836
1832
|
}()
|
|
1837
1833
|
/**
|
|
1838
|
-
*
|
|
1834
|
+
* 获取部分支付的订单
|
|
1839
1835
|
*/
|
|
1840
1836
|
/** @deprecated */
|
|
1841
1837
|
)
|
|
1842
1838
|
}, {
|
|
1843
|
-
key: "
|
|
1839
|
+
key: "getPartiallyPaidOrdersAsync",
|
|
1844
1840
|
value: (function () {
|
|
1845
|
-
var
|
|
1841
|
+
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1842
|
+
var allOrders;
|
|
1846
1843
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1847
1844
|
while (1) switch (_context24.prev = _context24.next) {
|
|
1848
1845
|
case 0:
|
|
1849
1846
|
_context24.prev = 0;
|
|
1850
1847
|
_context24.next = 3;
|
|
1851
|
-
return this.dbManager.getAll('pay_method');
|
|
1852
|
-
case 3:
|
|
1853
|
-
_context24.next = 9;
|
|
1854
|
-
break;
|
|
1855
|
-
case 5:
|
|
1856
|
-
_context24.prev = 5;
|
|
1857
|
-
_context24.t0 = _context24["catch"](0);
|
|
1858
|
-
console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
|
|
1859
|
-
console.warn('{ name: "pay_method", keyPath: "id" }');
|
|
1860
|
-
case 9:
|
|
1861
|
-
_context24.prev = 9;
|
|
1862
|
-
_context24.next = 12;
|
|
1863
|
-
return this.dbManager.getAll('order');
|
|
1864
|
-
case 12:
|
|
1865
|
-
_context24.next = 18;
|
|
1866
|
-
break;
|
|
1867
|
-
case 14:
|
|
1868
|
-
_context24.prev = 14;
|
|
1869
|
-
_context24.t1 = _context24["catch"](9);
|
|
1870
|
-
console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
|
|
1871
|
-
console.warn('{ name: "order", keyPath: "uuid" }');
|
|
1872
|
-
case 18:
|
|
1873
|
-
case "end":
|
|
1874
|
-
return _context24.stop();
|
|
1875
|
-
}
|
|
1876
|
-
}, _callee24, this, [[0, 5], [9, 14]]);
|
|
1877
|
-
}));
|
|
1878
|
-
function ensurePaymentTables() {
|
|
1879
|
-
return _ensurePaymentTables.apply(this, arguments);
|
|
1880
|
-
}
|
|
1881
|
-
return ensurePaymentTables;
|
|
1882
|
-
}()
|
|
1883
|
-
/**
|
|
1884
|
-
* 获取部分支付的订单
|
|
1885
|
-
*/
|
|
1886
|
-
/** @deprecated */
|
|
1887
|
-
)
|
|
1888
|
-
}, {
|
|
1889
|
-
key: "getPartiallyPaidOrdersAsync",
|
|
1890
|
-
value: (function () {
|
|
1891
|
-
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1892
|
-
var allOrders;
|
|
1893
|
-
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1894
|
-
while (1) switch (_context25.prev = _context25.next) {
|
|
1895
|
-
case 0:
|
|
1896
|
-
_context25.prev = 0;
|
|
1897
|
-
_context25.next = 3;
|
|
1898
1848
|
return this.dbManager.getAll('order');
|
|
1899
1849
|
case 3:
|
|
1900
|
-
allOrders =
|
|
1901
|
-
return
|
|
1850
|
+
allOrders = _context24.sent;
|
|
1851
|
+
return _context24.abrupt("return", allOrders.filter(function (order) {
|
|
1902
1852
|
return order.payment_status === PaymentStatus.PartiallyPaid;
|
|
1903
1853
|
}));
|
|
1904
1854
|
case 7:
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
console.error('[PaymentModule] 获取部分支付订单失败',
|
|
1908
|
-
return
|
|
1855
|
+
_context24.prev = 7;
|
|
1856
|
+
_context24.t0 = _context24["catch"](0);
|
|
1857
|
+
console.error('[PaymentModule] 获取部分支付订单失败', _context24.t0);
|
|
1858
|
+
return _context24.abrupt("return", []);
|
|
1909
1859
|
case 11:
|
|
1910
1860
|
case "end":
|
|
1911
|
-
return
|
|
1861
|
+
return _context24.stop();
|
|
1912
1862
|
}
|
|
1913
|
-
},
|
|
1863
|
+
}, _callee24, this, [[0, 7]]);
|
|
1914
1864
|
}));
|
|
1915
1865
|
function getPartiallyPaidOrdersAsync() {
|
|
1916
1866
|
return _getPartiallyPaidOrdersAsync.apply(this, arguments);
|
|
@@ -1931,17 +1881,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1931
1881
|
}, {
|
|
1932
1882
|
key: "roundAmountAsync",
|
|
1933
1883
|
value: function () {
|
|
1934
|
-
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1884
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(originalAmount, interval, rule) {
|
|
1935
1885
|
var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
|
|
1936
|
-
return _regeneratorRuntime().wrap(function
|
|
1937
|
-
while (1) switch (
|
|
1886
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1887
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1938
1888
|
case 0:
|
|
1939
|
-
|
|
1889
|
+
_context25.prev = 0;
|
|
1940
1890
|
// 参数验证
|
|
1941
1891
|
amount = new Decimal(originalAmount);
|
|
1942
1892
|
roundingInterval = new Decimal(interval);
|
|
1943
1893
|
if (!roundingInterval.lte(0)) {
|
|
1944
|
-
|
|
1894
|
+
_context25.next = 5;
|
|
1945
1895
|
break;
|
|
1946
1896
|
}
|
|
1947
1897
|
throw new Error('舍入间隔必须大于 0');
|
|
@@ -1955,25 +1905,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1955
1905
|
|
|
1956
1906
|
// 计算基础值:x / interval
|
|
1957
1907
|
baseValue = amount.div(roundingInterval);
|
|
1958
|
-
|
|
1959
|
-
|
|
1908
|
+
_context25.t0 = rule;
|
|
1909
|
+
_context25.next = _context25.t0 === RoundingRule.Standard ? 12 : _context25.t0 === 'standard' ? 12 : _context25.t0 === RoundingRule.StandardDown ? 14 : _context25.t0 === 'standard_rounding_midpoint_down' ? 14 : _context25.t0 === RoundingRule.AlwaysUp ? 16 : _context25.t0 === 'always_up' ? 16 : _context25.t0 === RoundingRule.AlwaysDown ? 18 : _context25.t0 === 'always_down' ? 18 : 20;
|
|
1960
1910
|
break;
|
|
1961
1911
|
case 12:
|
|
1962
1912
|
// 标准舍入(中点向上)
|
|
1963
1913
|
roundedValue = this.standardRound(baseValue, true);
|
|
1964
|
-
return
|
|
1914
|
+
return _context25.abrupt("break", 21);
|
|
1965
1915
|
case 14:
|
|
1966
1916
|
// 标准舍入(中点向下)
|
|
1967
1917
|
roundedValue = this.standardRound(baseValue, false);
|
|
1968
|
-
return
|
|
1918
|
+
return _context25.abrupt("break", 21);
|
|
1969
1919
|
case 16:
|
|
1970
1920
|
// 总是向上舍入
|
|
1971
1921
|
roundedValue = baseValue.ceil();
|
|
1972
|
-
return
|
|
1922
|
+
return _context25.abrupt("break", 21);
|
|
1973
1923
|
case 18:
|
|
1974
1924
|
// 总是向下舍入
|
|
1975
1925
|
roundedValue = baseValue.floor();
|
|
1976
|
-
return
|
|
1926
|
+
return _context25.abrupt("break", 21);
|
|
1977
1927
|
case 20:
|
|
1978
1928
|
throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
|
|
1979
1929
|
case 21:
|
|
@@ -1981,10 +1931,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1981
1931
|
finalAmount = roundedValue.mul(roundingInterval);
|
|
1982
1932
|
originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
|
|
1983
1933
|
if (!finalAmount.eq(0)) {
|
|
1984
|
-
|
|
1934
|
+
_context25.next = 25;
|
|
1985
1935
|
break;
|
|
1986
1936
|
}
|
|
1987
|
-
return
|
|
1937
|
+
return _context25.abrupt("return", {
|
|
1988
1938
|
originalAmount: originalAmountStr,
|
|
1989
1939
|
roundedAmount: originalAmountStr,
|
|
1990
1940
|
roundingDifference: '0.00'
|
|
@@ -1993,21 +1943,21 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1993
1943
|
roundedAmountStr = finalAmount.toFixed(2); // 计算舍入差额
|
|
1994
1944
|
roundingDifference = finalAmount.sub(amount);
|
|
1995
1945
|
roundingDifferenceStr = roundingDifference.toFixed(2);
|
|
1996
|
-
return
|
|
1946
|
+
return _context25.abrupt("return", {
|
|
1997
1947
|
originalAmount: originalAmountStr,
|
|
1998
1948
|
roundedAmount: roundedAmountStr,
|
|
1999
1949
|
roundingDifference: roundingDifferenceStr
|
|
2000
1950
|
});
|
|
2001
1951
|
case 31:
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
console.error('[PaymentModule] 金额舍入失败:',
|
|
2005
|
-
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(
|
|
1952
|
+
_context25.prev = 31;
|
|
1953
|
+
_context25.t1 = _context25["catch"](0);
|
|
1954
|
+
console.error('[PaymentModule] 金额舍入失败:', _context25.t1);
|
|
1955
|
+
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context25.t1 instanceof Error ? _context25.t1.message : String(_context25.t1)));
|
|
2006
1956
|
case 35:
|
|
2007
1957
|
case "end":
|
|
2008
|
-
return
|
|
1958
|
+
return _context25.stop();
|
|
2009
1959
|
}
|
|
2010
|
-
},
|
|
1960
|
+
}, _callee25, this, [[0, 31]]);
|
|
2011
1961
|
}));
|
|
2012
1962
|
function roundAmountAsync(_x27, _x28, _x29) {
|
|
2013
1963
|
return _roundAmountAsync.apply(this, arguments);
|
|
@@ -294,12 +294,14 @@ function evaluateCandidateTimeGate(params) {
|
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
296
|
if (policy.type === 'before_start') {
|
|
297
|
-
//
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
//
|
|
297
|
+
// POS fixed-duration candidates use the context's stable opening-minute
|
|
298
|
+
// anchor. Keep that anchored range selectable while it is still active;
|
|
299
|
+
// otherwise a minute refresh turns it into 0 capacity and incorrectly
|
|
300
|
+
// advances a create flow to the next slot. The earlier `past` gate still
|
|
301
|
+
// rejects the anchor once its booking range has ended.
|
|
302
|
+
var isActivePosDurationAnchor = evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration' && !product.isFlexibleDuration && evaluationContext.durationCandidateAnchorAtMs === candidateRange.start;
|
|
301
303
|
var usesMinutePrecision = product.isFlexibleDuration || evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration';
|
|
302
|
-
var hasNotReachedStart = usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start;
|
|
304
|
+
var hasNotReachedStart = isActivePosDurationAnchor || (usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start);
|
|
303
305
|
if (hasNotReachedStart) return null;
|
|
304
306
|
return {
|
|
305
307
|
status: 'unavailable',
|
|
@@ -1437,6 +1439,7 @@ function buildAvailabilityCellIndex(projection) {
|
|
|
1437
1439
|
function buildEvaluationContext(params) {
|
|
1438
1440
|
var _params$resourceIds2;
|
|
1439
1441
|
var evaluatedAt = toDateTime(params.evaluatedAt || params.projection.meta.now, params.projection.meta.timezone);
|
|
1442
|
+
var durationCandidateAnchorAt = toDateTime(params.projection.meta.durationCandidateAnchorAt, params.projection.meta.timezone);
|
|
1440
1443
|
var selectionsByGroupKey = new Map();
|
|
1441
1444
|
(params.requirementSelections || []).forEach(function (selection) {
|
|
1442
1445
|
var _selection$formId;
|
|
@@ -1449,6 +1452,7 @@ function buildEvaluationContext(params) {
|
|
|
1449
1452
|
resourceIdSet: (_params$resourceIds2 = params.resourceIds) !== null && _params$resourceIds2 !== void 0 && _params$resourceIds2.length ? new Set(params.resourceIds.map(String)) : null,
|
|
1450
1453
|
selectionsByGroupKey: selectionsByGroupKey,
|
|
1451
1454
|
useExactDurationCandidateMinute: params.useExactDurationCandidateMinute === true,
|
|
1455
|
+
durationCandidateAnchorAtMs: Number.isFinite(durationCandidateAnchorAt) ? floorToMinute(durationCandidateAnchorAt) : null,
|
|
1452
1456
|
allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true
|
|
1453
1457
|
};
|
|
1454
1458
|
}
|
|
@@ -253,7 +253,8 @@ export interface GetProductTimeRangesRuntimeOptions {
|
|
|
253
253
|
/**
|
|
254
254
|
* Internal POS capability: fixed-duration candidates start from the stable
|
|
255
255
|
* context anchor's current minute instead of rounding up to ten minutes, and
|
|
256
|
-
* that
|
|
256
|
+
* that anchored range remains selectable while active during before-start
|
|
257
|
+
* cutoff evaluation.
|
|
257
258
|
* Other callers keep the legacy alignment and strict second-level cutoff.
|
|
258
259
|
*/
|
|
259
260
|
useExactDurationCandidateMinute?: boolean;
|
package/dist/server/index.js
CHANGED
|
@@ -3542,6 +3542,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3542
3542
|
method: 'get',
|
|
3543
3543
|
path: '/shop/pay/custom-payment/all',
|
|
3544
3544
|
handler: this.handlePaymentMethods.bind(this)
|
|
3545
|
+
}, {
|
|
3546
|
+
method: 'get',
|
|
3547
|
+
path: '/pay/custom-payment/all',
|
|
3548
|
+
handler: this.handlePaymentMethods.bind(this)
|
|
3545
3549
|
}, {
|
|
3546
3550
|
method: 'get',
|
|
3547
3551
|
path: '/shop/quotation/available',
|
|
@@ -7,22 +7,41 @@ export declare class PaymentServerModule extends BaseModule implements Module {
|
|
|
7
7
|
private request;
|
|
8
8
|
private app;
|
|
9
9
|
private logger;
|
|
10
|
+
private dbManager;
|
|
10
11
|
private store;
|
|
11
|
-
private
|
|
12
|
-
private
|
|
12
|
+
private paymentDataSource;
|
|
13
|
+
private initialLoadInFlight;
|
|
14
|
+
private refreshInFlight;
|
|
15
|
+
private hasLoadedPayMethods;
|
|
16
|
+
private hasEmittedLoaded;
|
|
17
|
+
private syncTimer;
|
|
18
|
+
private pendingMessageUuids;
|
|
19
|
+
private queuedTrailingRefresh;
|
|
20
|
+
private trailingMessageUuids;
|
|
13
21
|
constructor(name?: string, version?: string);
|
|
14
22
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
23
|
+
preload(): Promise<void>;
|
|
15
24
|
getPayMethodListAsync(options?: {
|
|
16
25
|
shouldFilter?: boolean;
|
|
17
26
|
}): Promise<PaymentMethod[]>;
|
|
18
|
-
|
|
19
|
-
private
|
|
27
|
+
private ensureInitialPayMethods;
|
|
28
|
+
private initPaymentDataSource;
|
|
29
|
+
private setupPaymentMethodSync;
|
|
30
|
+
private schedulePaymentMethodRefresh;
|
|
31
|
+
private refreshPayMethodsSingleFlight;
|
|
32
|
+
private performRemoteRefresh;
|
|
20
33
|
private fetchRemotePayMethods;
|
|
21
|
-
private
|
|
34
|
+
private loadPayMethodsFromSQLite;
|
|
35
|
+
private replacePayMethodsInSQLite;
|
|
36
|
+
private resolveCurrentShopScope;
|
|
37
|
+
private stripSnapshotFields;
|
|
38
|
+
private arePayMethodsEqual;
|
|
22
39
|
private resolvePayMethods;
|
|
23
40
|
private filterPayMethods;
|
|
24
|
-
private
|
|
41
|
+
private setPayMethodMirror;
|
|
42
|
+
private getErrorMessage;
|
|
25
43
|
private logInfo;
|
|
26
44
|
private logWarning;
|
|
27
45
|
private logError;
|
|
46
|
+
destroy(): void;
|
|
28
47
|
}
|