oak-pay-business 2.5.3 → 2.5.4
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/es/checkers/accountOper.js +1 -1
- package/es/triggers/pay.js +11 -5
- package/lib/checkers/accountOper.js +1 -1
- package/lib/triggers/pay.js +11 -5
- package/package.json +12 -10
- package/lib/components/offlineAccount/config/index.d.ts +0 -4
- package/lib/components/offlineAccount/config/index.js +0 -50
- package/lib/components/pay/detail/index.d.ts +0 -12
- package/lib/components/pay/detail/index.js +0 -326
- package/lib/components/payConfig/system/web.pc.d.ts +0 -14
- package/lib/components/payConfig/system/web.pc.js +0 -122
- package/lib/components/wpAccount/config/index.d.ts +0 -4
- package/lib/components/wpAccount/config/index.js +0 -37
|
@@ -27,7 +27,7 @@ const checkers = [
|
|
|
27
27
|
}
|
|
28
28
|
switch (type) {
|
|
29
29
|
case 'consume': {
|
|
30
|
-
if (totalPlus
|
|
30
|
+
if (totalPlus > 0 || availPlus > 0 || totalPlus > availPlus) {
|
|
31
31
|
throw new OakInputIllegalException('accountOper', ['availPlus'], 'accountOper为consume时,其totalPlus/availPlus必须为0或负数,且totalPlus的绝对值要更大');
|
|
32
32
|
}
|
|
33
33
|
break;
|
package/es/triggers/pay.js
CHANGED
|
@@ -20,7 +20,13 @@ async function changeOrderStateByPay(filter, context, option) {
|
|
|
20
20
|
paid: 1,
|
|
21
21
|
refunded: 1,
|
|
22
22
|
iState: 1,
|
|
23
|
+
entity: 1,
|
|
23
24
|
},
|
|
25
|
+
filter: {
|
|
26
|
+
iState: {
|
|
27
|
+
$ne: 'closed',
|
|
28
|
+
}
|
|
29
|
+
}
|
|
24
30
|
},
|
|
25
31
|
},
|
|
26
32
|
filter,
|
|
@@ -71,7 +77,7 @@ async function changeOrderStateByPay(filter, context, option) {
|
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
else if (hasRefunding) {
|
|
74
|
-
assert(!hasPaying && payPaid === orderPrice && payRefunded
|
|
80
|
+
assert(!hasPaying && payPaid === orderPrice && payRefunded <= orderPrice);
|
|
75
81
|
if (orderIState !== 'refunding' || orderRefunded !== payRefunded) {
|
|
76
82
|
await context.operate('order', {
|
|
77
83
|
id: await generateNewIdAsync(),
|
|
@@ -85,9 +91,9 @@ async function changeOrderStateByPay(filter, context, option) {
|
|
|
85
91
|
}, option);
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
|
-
else if (payRefunded) {
|
|
94
|
+
else if (payRefunded > 0 || (pays?.length === 1 && pays?.[0].entity === 'account' && orderPrice === 0 && pays?.[0].iState === 'refunded')) {
|
|
89
95
|
// 已经在退款流程当中
|
|
90
|
-
assert(payPaid === orderPrice
|
|
96
|
+
assert(payPaid === orderPrice);
|
|
91
97
|
const iState = payPaid === orderPrice ? 'refunded' : 'partiallyRefunded';
|
|
92
98
|
if (orderIState !== iState || orderRefunded !== payRefunded) {
|
|
93
99
|
const action = payRefunded === orderPrice ? 'refundAll' : 'refundPartially';
|
|
@@ -103,9 +109,9 @@ async function changeOrderStateByPay(filter, context, option) {
|
|
|
103
109
|
}, option);
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
|
-
else if (payPaid) {
|
|
112
|
+
else if (payPaid > 0 || (pays?.length === 1 && pays?.[0].entity === 'account' && orderPrice === 0 && pays?.[0].iState === 'paid')) {
|
|
107
113
|
// 在支付流程当中
|
|
108
|
-
|
|
114
|
+
// 存在已完成的pay更新order的paid和iState
|
|
109
115
|
assert(orderRefunded === 0);
|
|
110
116
|
const iState = payPaid === orderPrice ? 'paid' : 'partiallyPaid';
|
|
111
117
|
if (orderIState !== iState || orderPaid !== payPaid) {
|
|
@@ -30,7 +30,7 @@ const checkers = [
|
|
|
30
30
|
}
|
|
31
31
|
switch (type) {
|
|
32
32
|
case 'consume': {
|
|
33
|
-
if (totalPlus
|
|
33
|
+
if (totalPlus > 0 || availPlus > 0 || totalPlus > availPlus) {
|
|
34
34
|
throw new types_1.OakInputIllegalException('accountOper', ['availPlus'], 'accountOper为consume时,其totalPlus/availPlus必须为0或负数,且totalPlus的绝对值要更大');
|
|
35
35
|
}
|
|
36
36
|
break;
|
package/lib/triggers/pay.js
CHANGED
|
@@ -23,7 +23,13 @@ async function changeOrderStateByPay(filter, context, option) {
|
|
|
23
23
|
paid: 1,
|
|
24
24
|
refunded: 1,
|
|
25
25
|
iState: 1,
|
|
26
|
+
entity: 1,
|
|
26
27
|
},
|
|
28
|
+
filter: {
|
|
29
|
+
iState: {
|
|
30
|
+
$ne: 'closed',
|
|
31
|
+
}
|
|
32
|
+
}
|
|
27
33
|
},
|
|
28
34
|
},
|
|
29
35
|
filter,
|
|
@@ -74,7 +80,7 @@ async function changeOrderStateByPay(filter, context, option) {
|
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
else if (hasRefunding) {
|
|
77
|
-
(0, assert_1.default)(!hasPaying && payPaid === orderPrice && payRefunded
|
|
83
|
+
(0, assert_1.default)(!hasPaying && payPaid === orderPrice && payRefunded <= orderPrice);
|
|
78
84
|
if (orderIState !== 'refunding' || orderRefunded !== payRefunded) {
|
|
79
85
|
await context.operate('order', {
|
|
80
86
|
id: await (0, uuid_1.generateNewIdAsync)(),
|
|
@@ -88,9 +94,9 @@ async function changeOrderStateByPay(filter, context, option) {
|
|
|
88
94
|
}, option);
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
|
-
else if (payRefunded) {
|
|
97
|
+
else if (payRefunded > 0 || (pays?.length === 1 && pays?.[0].entity === 'account' && orderPrice === 0 && pays?.[0].iState === 'refunded')) {
|
|
92
98
|
// 已经在退款流程当中
|
|
93
|
-
(0, assert_1.default)(payPaid === orderPrice
|
|
99
|
+
(0, assert_1.default)(payPaid === orderPrice);
|
|
94
100
|
const iState = payPaid === orderPrice ? 'refunded' : 'partiallyRefunded';
|
|
95
101
|
if (orderIState !== iState || orderRefunded !== payRefunded) {
|
|
96
102
|
const action = payRefunded === orderPrice ? 'refundAll' : 'refundPartially';
|
|
@@ -106,9 +112,9 @@ async function changeOrderStateByPay(filter, context, option) {
|
|
|
106
112
|
}, option);
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
|
-
else if (payPaid) {
|
|
115
|
+
else if (payPaid > 0 || (pays?.length === 1 && pays?.[0].entity === 'account' && orderPrice === 0 && pays?.[0].iState === 'paid')) {
|
|
110
116
|
// 在支付流程当中
|
|
111
|
-
|
|
117
|
+
// 存在已完成的pay更新order的paid和iState
|
|
112
118
|
(0, assert_1.default)(orderRefunded === 0);
|
|
113
119
|
const iState = payPaid === orderPrice ? 'paid' : 'partiallyPaid';
|
|
114
120
|
if (orderIState !== iState || orderPaid !== payPaid) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-pay-business",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib/**/*",
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
"copy-wxs": "copyfiles -u 1 src/**/*.wxs es/",
|
|
19
19
|
"copy-xml": "copyfiles -u 1 src/**/*.xml es/",
|
|
20
20
|
"copy-wxml": "copyfiles -u 1 src/**/*.wxml es/",
|
|
21
|
+
"clean-lib-components": "rimraf lib/components",
|
|
21
22
|
"prebuild": "npm run make:locale",
|
|
22
|
-
"build": "tsc -p tsconfig.lib.json && tsc -p tsconfig.es.json && tsc-alias -p tsconfig.lib.json && tsc-alias -p tsconfig.es.json && npm run copy-js && npm run copy-less && npm run copy-wxs && npm run copy-svg && npm run copy-xml && npm run copy-wxml",
|
|
23
|
+
"build": "tsc -p tsconfig.lib.json && tsc -p tsconfig.es.json && tsc-alias -p tsconfig.lib.json && tsc-alias -p tsconfig.es.json && npm run copy-js && npm run copy-less && npm run copy-wxs && npm run copy-svg && npm run copy-xml && npm run copy-wxml && npm run clean-lib-components",
|
|
23
24
|
"build:analyze": "tsc -p tsconfig.es.json --diagnostics",
|
|
24
25
|
"prepare": "rimraf node_modules/react & rimraf node_modules/react-native & rimraf node_modules/react-dom & rimraf node_modules/react-router & rimraf node_modules/react-router-dom"
|
|
25
26
|
},
|
|
@@ -29,19 +30,20 @@
|
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"classnames": "^2.3.1",
|
|
31
32
|
"dayjs": "^1.11.5",
|
|
32
|
-
"oak-domain": "^5.1.
|
|
33
|
-
"oak-frontend-base": "^5.3.
|
|
34
|
-
"oak-general-business": "~5.5.
|
|
33
|
+
"oak-domain": "^5.1.9",
|
|
34
|
+
"oak-frontend-base": "^5.3.18",
|
|
35
|
+
"oak-general-business": "~5.5.7",
|
|
35
36
|
"wechat-pay-nodejs": "^0.2.3"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
|
-
|
|
39
|
-
"antd": ">=5.
|
|
39
|
+
"@ant-design/icons": ">=5.3.4",
|
|
40
|
+
"antd": ">=5.11.0",
|
|
40
41
|
"antd-mobile": ">=5.33.0",
|
|
41
42
|
"antd-mobile-icons": ">=0.3.0",
|
|
42
|
-
"react": "
|
|
43
|
-
"react-dom": "
|
|
44
|
-
"react-native": ">=0.72.
|
|
43
|
+
"react": ">=18.2.0",
|
|
44
|
+
"react-dom": ">=18.2.0",
|
|
45
|
+
"react-native": ">=0.72.7",
|
|
46
|
+
"react-router": ">=6.3.0",
|
|
45
47
|
"react-router-dom": ">=6.3.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = OakComponent({
|
|
4
|
-
entity: 'offlineAccount',
|
|
5
|
-
isList: true,
|
|
6
|
-
projection: {
|
|
7
|
-
id: 1,
|
|
8
|
-
type: 1,
|
|
9
|
-
channel: 1,
|
|
10
|
-
name: 1,
|
|
11
|
-
qrCode: 1,
|
|
12
|
-
allowDeposit: 1,
|
|
13
|
-
allowPay: 1,
|
|
14
|
-
systemId: 1,
|
|
15
|
-
price: 1,
|
|
16
|
-
enabled: 1,
|
|
17
|
-
taxLossRatio: 1,
|
|
18
|
-
refundCompensateRatio: 1,
|
|
19
|
-
refundGapDays: 1,
|
|
20
|
-
allowWithdrawTransfer: 1,
|
|
21
|
-
withdrawTransferLossRatio: 1,
|
|
22
|
-
},
|
|
23
|
-
properties: {
|
|
24
|
-
systemId: '',
|
|
25
|
-
},
|
|
26
|
-
filters: [
|
|
27
|
-
{
|
|
28
|
-
filter() {
|
|
29
|
-
const { systemId } = this.props;
|
|
30
|
-
return {
|
|
31
|
-
systemId,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
formData({ data, legalActions }) {
|
|
37
|
-
return {
|
|
38
|
-
accounts: data.map((ele) => {
|
|
39
|
-
const { type } = ele;
|
|
40
|
-
const color = this.features.style.getColor('offlineAccount', 'type', type);
|
|
41
|
-
return {
|
|
42
|
-
color,
|
|
43
|
-
...ele,
|
|
44
|
-
};
|
|
45
|
-
}),
|
|
46
|
-
canCreate: legalActions?.includes('create'),
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
actions: ['create', 'update', 'remove'],
|
|
50
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EntityDict } from "../../../oak-app-domain";
|
|
2
|
-
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
|
|
3
|
-
import { StartPayRoutine, JudgeCanPay } from "../../../types/Pay";
|
|
4
|
-
export declare function registerFrontendPayRoutine<ED extends EntityDict & BaseEntityDict>(entity: keyof ED, routine: StartPayRoutine, projection: ED['pay']['Selection']['data'], judgeCanPay: JudgeCanPay): void;
|
|
5
|
-
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "pay", false, {
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
onPaid: () => void;
|
|
8
|
-
onPayFailure: () => void;
|
|
9
|
-
disableAutoPay: boolean;
|
|
10
|
-
closeWhenFailure: boolean;
|
|
11
|
-
}>) => React.ReactElement;
|
|
12
|
-
export default _default;
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerFrontendPayRoutine = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const money_1 = require("oak-domain/lib/utils/money");
|
|
6
|
-
const constants_1 = require("../../../config/constants");
|
|
7
|
-
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
8
|
-
const utils_1 = require("oak-frontend-base/es/utils/utils");
|
|
9
|
-
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
|
10
|
-
const wpProductFrontend_1 = require("../../../utils/wpProductFrontend");
|
|
11
|
-
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
|
12
|
-
const Exception_1 = require("../../../types/Exception");
|
|
13
|
-
const PayRoutineDict = {
|
|
14
|
-
wpProduct: {
|
|
15
|
-
projection: {
|
|
16
|
-
wpProduct: {
|
|
17
|
-
id: 1,
|
|
18
|
-
type: 1,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
routine: async (pay, features) => {
|
|
22
|
-
const { iState, wpProduct, meta } = pay;
|
|
23
|
-
switch (wpProduct.type) {
|
|
24
|
-
case 'mp': {
|
|
25
|
-
if (process.env.OAK_PLATFORM === 'wechatMp') {
|
|
26
|
-
const { prepayMeta } = meta;
|
|
27
|
-
if (prepayMeta) {
|
|
28
|
-
try {
|
|
29
|
-
const result = await wx.requestPayment(prepayMeta);
|
|
30
|
-
process.env.NODE_ENV === 'development' && console.log(result);
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
throw new Exception_1.StartPayFailure(err.errMsg.includes('cancel')
|
|
34
|
-
? features.locales.t('startPayError.userCancel')
|
|
35
|
-
: features.locales.t('startPayError.unknown'));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.illegalPrepayData'));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.falseEnv', { env: 'wechatMp' }));
|
|
44
|
-
}
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
case 'jsapi': {
|
|
48
|
-
if (process.env.OAK_PLATFORM === 'web' && utils_1.isWeiXin) {
|
|
49
|
-
const { prepayMeta } = meta;
|
|
50
|
-
if (prepayMeta) {
|
|
51
|
-
const { timeStamp, ...rest } = prepayMeta;
|
|
52
|
-
// chooseWXPay文档都找不到了,网上查出来这里timestamp的s要小写,吐血了
|
|
53
|
-
await features.wechatSdk.loadWxAPi('chooseWXPay', {
|
|
54
|
-
timestamp: timeStamp,
|
|
55
|
-
...rest,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.illegalPrepayData'));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
default: {
|
|
64
|
-
(0, assert_1.default)('尚未实现');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
judgeCanPay: wpProductFrontend_1.canStartPay,
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
function registerFrontendPayRoutine(entity, routine, projection, judgeCanPay) {
|
|
72
|
-
PayRoutineDict[entity] = {
|
|
73
|
-
routine,
|
|
74
|
-
projection,
|
|
75
|
-
judgeCanPay,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
exports.registerFrontendPayRoutine = registerFrontendPayRoutine;
|
|
79
|
-
exports.default = OakComponent({
|
|
80
|
-
entity: 'pay',
|
|
81
|
-
isList: false,
|
|
82
|
-
projection: () => {
|
|
83
|
-
const baseProjection = {
|
|
84
|
-
id: 1,
|
|
85
|
-
applicationId: 1,
|
|
86
|
-
price: 1,
|
|
87
|
-
meta: 1,
|
|
88
|
-
iState: 1,
|
|
89
|
-
paid: 1,
|
|
90
|
-
refunded: 1,
|
|
91
|
-
timeoutAt: 1,
|
|
92
|
-
forbidRefundAt: 1,
|
|
93
|
-
externalId: 1,
|
|
94
|
-
orderId: 1,
|
|
95
|
-
depositId: 1,
|
|
96
|
-
deposit: {
|
|
97
|
-
id: 1,
|
|
98
|
-
accountId: 1,
|
|
99
|
-
price: 1,
|
|
100
|
-
loss: 1,
|
|
101
|
-
},
|
|
102
|
-
order: {
|
|
103
|
-
id: 1,
|
|
104
|
-
creatorId: 1,
|
|
105
|
-
},
|
|
106
|
-
entity: 1,
|
|
107
|
-
entityId: 1,
|
|
108
|
-
creatorId: 1,
|
|
109
|
-
phantom3: 1,
|
|
110
|
-
};
|
|
111
|
-
for (const k in PayRoutineDict) {
|
|
112
|
-
(0, lodash_1.merge)(baseProjection, PayRoutineDict[k].projection);
|
|
113
|
-
}
|
|
114
|
-
return baseProjection;
|
|
115
|
-
},
|
|
116
|
-
properties: {
|
|
117
|
-
onClose: () => undefined,
|
|
118
|
-
onPaid: () => undefined,
|
|
119
|
-
onPayFailure: () => undefined,
|
|
120
|
-
disableAutoPay: false,
|
|
121
|
-
closeWhenFailure: false,
|
|
122
|
-
},
|
|
123
|
-
data: {
|
|
124
|
-
showCloseConfirmMp: false,
|
|
125
|
-
showChannelSelectMp: false,
|
|
126
|
-
unsub: undefined,
|
|
127
|
-
},
|
|
128
|
-
formData({ data }) {
|
|
129
|
-
const application = this.features.application.getApplication();
|
|
130
|
-
const iState = data?.iState;
|
|
131
|
-
const iStateColor = iState && this.features.style.getColor('pay', 'iState', iState);
|
|
132
|
-
const startPayable = iState === 'paying' && !['account', 'offlineAccount'].includes(data.entity) && (PayRoutineDict[data.entity] && PayRoutineDict[data.entity].judgeCanPay(data, this.features));
|
|
133
|
-
const payChannels = this.features.pay.getPayChannels();
|
|
134
|
-
const offlines = this.features.cache.get('offlineAccount', {
|
|
135
|
-
data: {
|
|
136
|
-
id: 1,
|
|
137
|
-
type: 1,
|
|
138
|
-
channel: 1,
|
|
139
|
-
name: 1,
|
|
140
|
-
qrCode: 1,
|
|
141
|
-
},
|
|
142
|
-
filter: {
|
|
143
|
-
systemId: this.features.application.getApplication().systemId,
|
|
144
|
-
}
|
|
145
|
-
}).map(ele => {
|
|
146
|
-
const color = this.features.style.getColor('offlineAccount', 'type', ele.type);
|
|
147
|
-
return {
|
|
148
|
-
color,
|
|
149
|
-
...ele,
|
|
150
|
-
};
|
|
151
|
-
});
|
|
152
|
-
const offline = offlines?.find(ele => ele.id === data.entityId);
|
|
153
|
-
return {
|
|
154
|
-
type: data?.orderId ? 'order' : 'deposit',
|
|
155
|
-
pay: data,
|
|
156
|
-
application,
|
|
157
|
-
iStateColor,
|
|
158
|
-
closable: !!(data?.["#oakLegalActions"]?.includes('close')),
|
|
159
|
-
startPayable,
|
|
160
|
-
offline,
|
|
161
|
-
offlines,
|
|
162
|
-
notSameApp: data && data.applicationId !== application.id && data.entity !== 'offlineAccount',
|
|
163
|
-
priceStr: data?.price && (0, money_1.CentToString)(data.price, 2),
|
|
164
|
-
};
|
|
165
|
-
},
|
|
166
|
-
features: [{
|
|
167
|
-
feature: 'application',
|
|
168
|
-
callback() {
|
|
169
|
-
this.refreshOfflineAccounts();
|
|
170
|
-
}
|
|
171
|
-
}],
|
|
172
|
-
actions: ['close', 'startPaying', {
|
|
173
|
-
action: 'update',
|
|
174
|
-
attrs: ['entityId'],
|
|
175
|
-
}],
|
|
176
|
-
methods: {
|
|
177
|
-
refreshOfflineAccounts() {
|
|
178
|
-
const { entity } = this.state.pay || {};
|
|
179
|
-
if (entity === 'offlineAccount') {
|
|
180
|
-
this.features.cache.refresh('offlineAccount', {
|
|
181
|
-
data: {
|
|
182
|
-
id: 1,
|
|
183
|
-
channel: 1,
|
|
184
|
-
name: 1,
|
|
185
|
-
type: 1,
|
|
186
|
-
qrCode: 1,
|
|
187
|
-
},
|
|
188
|
-
filter: {
|
|
189
|
-
systemId: this.features.application.getApplication().systemId,
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
executeMp() {
|
|
195
|
-
return this.execute();
|
|
196
|
-
},
|
|
197
|
-
resetMp() {
|
|
198
|
-
return this.clean();
|
|
199
|
-
},
|
|
200
|
-
closeMp() {
|
|
201
|
-
this.setState({
|
|
202
|
-
showCloseConfirmMp: true,
|
|
203
|
-
});
|
|
204
|
-
},
|
|
205
|
-
cancelCloseMp() {
|
|
206
|
-
this.setState({
|
|
207
|
-
showCloseConfirmMp: false,
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
async confirmCloseMp() {
|
|
211
|
-
await this.execute('close');
|
|
212
|
-
this.cancelCloseMp();
|
|
213
|
-
const { onClose } = this.props;
|
|
214
|
-
onClose && onClose();
|
|
215
|
-
},
|
|
216
|
-
goBack() {
|
|
217
|
-
this.navigateBack();
|
|
218
|
-
},
|
|
219
|
-
async startPay() {
|
|
220
|
-
const { onPaid, onClose, onPayFailure } = this.props;
|
|
221
|
-
const { pay } = this.state;
|
|
222
|
-
try {
|
|
223
|
-
await PayRoutineDict[pay.entity].routine(pay, this.features);
|
|
224
|
-
onPaid && onPaid();
|
|
225
|
-
}
|
|
226
|
-
catch (err) {
|
|
227
|
-
if (this.props.closeWhenFailure) {
|
|
228
|
-
await this.execute(undefined, undefined, undefined, [
|
|
229
|
-
{
|
|
230
|
-
entity: 'pay',
|
|
231
|
-
operation: {
|
|
232
|
-
id: await (0, uuid_1.generateNewIdAsync)(),
|
|
233
|
-
action: 'close',
|
|
234
|
-
data: {},
|
|
235
|
-
filter: {
|
|
236
|
-
id: this.props.oakId,
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
}
|
|
240
|
-
]);
|
|
241
|
-
onClose && onClose();
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
onPayFailure && onPayFailure();
|
|
245
|
-
}
|
|
246
|
-
this.features.message.setMessage({
|
|
247
|
-
type: 'warning',
|
|
248
|
-
content: err.message,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
openChannelSelectMp() {
|
|
253
|
-
this.setState({
|
|
254
|
-
showChannelSelectMp: true,
|
|
255
|
-
});
|
|
256
|
-
},
|
|
257
|
-
closeChannelSelectMp() {
|
|
258
|
-
this.setState({
|
|
259
|
-
showChannelSelectMp: false,
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
async updateOfflineIdMp(touch) {
|
|
263
|
-
const { detail } = touch;
|
|
264
|
-
const { currentKey } = detail;
|
|
265
|
-
const { oakId } = this.props;
|
|
266
|
-
if (currentKey) {
|
|
267
|
-
await this.execute(undefined, undefined, undefined, [
|
|
268
|
-
{
|
|
269
|
-
entity: 'pay',
|
|
270
|
-
operation: {
|
|
271
|
-
id: await (0, uuid_1.generateNewIdAsync)(),
|
|
272
|
-
action: 'update',
|
|
273
|
-
data: {
|
|
274
|
-
entity: 'offlineAccount',
|
|
275
|
-
entityId: currentKey,
|
|
276
|
-
},
|
|
277
|
-
filter: {
|
|
278
|
-
id: oakId,
|
|
279
|
-
},
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
]);
|
|
283
|
-
this.setState({
|
|
284
|
-
showChannelSelectMp: false,
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
updateExternalIdMp(input) {
|
|
289
|
-
const { detail } = input;
|
|
290
|
-
this.update({
|
|
291
|
-
externalId: detail.value,
|
|
292
|
-
});
|
|
293
|
-
},
|
|
294
|
-
clearExternalIdMp() {
|
|
295
|
-
this.update({
|
|
296
|
-
externalId: null,
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
lifetimes: {
|
|
301
|
-
async ready() {
|
|
302
|
-
const { oakId } = this.props;
|
|
303
|
-
(0, assert_1.default)(typeof oakId === 'string');
|
|
304
|
-
const unsub = await this.subDataEvents([`${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
|
|
305
|
-
this.setState({
|
|
306
|
-
unsub,
|
|
307
|
-
});
|
|
308
|
-
},
|
|
309
|
-
detached() {
|
|
310
|
-
const { unsub } = this.state;
|
|
311
|
-
unsub && unsub();
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
listeners: {
|
|
315
|
-
startPayable(prev, next) {
|
|
316
|
-
if (next.startPayable && !this.props.disableAutoPay) {
|
|
317
|
-
this.startPay();
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
pay(prev, next) {
|
|
321
|
-
if (!prev.pay && next.pay) {
|
|
322
|
-
this.refreshOfflineAccounts();
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
|
|
3
|
-
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
|
|
4
|
-
import { EntityDict } from '../../../oak-app-domain';
|
|
5
|
-
export declare function registerPayChannelComponent<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, component: (option: {
|
|
6
|
-
oakPath: string;
|
|
7
|
-
systemId: string;
|
|
8
|
-
}) => React.ReactElement): void;
|
|
9
|
-
export default function render(props: WebComponentProps<EntityDict, 'system', false, {
|
|
10
|
-
system: RowWithActions<EntityDict, 'system'>;
|
|
11
|
-
operation?: EntityDict['system']['Update'];
|
|
12
|
-
serverUrl?: string;
|
|
13
|
-
canUpdate?: boolean;
|
|
14
|
-
}>): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerPayChannelComponent = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const antd_1 = require("antd");
|
|
7
|
-
const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less"));
|
|
8
|
-
const config_1 = tslib_1.__importDefault(require("../../offlineAccount/config"));
|
|
9
|
-
const config_2 = tslib_1.__importDefault(require("../../wpAccount/config"));
|
|
10
|
-
const PayChannelConfigDict = {
|
|
11
|
-
'wpAccount': config_2.default,
|
|
12
|
-
};
|
|
13
|
-
function registerPayChannelComponent(entity, component) {
|
|
14
|
-
PayChannelConfigDict[entity] = component;
|
|
15
|
-
}
|
|
16
|
-
exports.registerPayChannelComponent = registerPayChannelComponent;
|
|
17
|
-
function PayConfig(props) {
|
|
18
|
-
const { payConfig, update, t } = props;
|
|
19
|
-
const withdrawLoss = payConfig?.withdrawLoss;
|
|
20
|
-
const depositLoss = payConfig?.depositLoss;
|
|
21
|
-
const updateDepositLoss = (data) => {
|
|
22
|
-
update && update({
|
|
23
|
-
depositLoss: {
|
|
24
|
-
...depositLoss,
|
|
25
|
-
...data,
|
|
26
|
-
},
|
|
27
|
-
withdrawLoss: withdrawLoss || {
|
|
28
|
-
conservative: false,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
const updateWithdrawLoss = (data) => {
|
|
33
|
-
update && update({
|
|
34
|
-
depositLoss: depositLoss || {},
|
|
35
|
-
withdrawLoss: {
|
|
36
|
-
conservative: !!(withdrawLoss?.conservative),
|
|
37
|
-
...withdrawLoss,
|
|
38
|
-
...data,
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", children: [(0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.depositLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t("payConfig.help.depositLoss"), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, disabled: !update, onChange: (value) => {
|
|
43
|
-
const ratio = value;
|
|
44
|
-
updateDepositLoss({
|
|
45
|
-
ratio: ratio || 0
|
|
46
|
-
});
|
|
47
|
-
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.highest, min: 0, step: 1, disabled: !update, onChange: (value) => {
|
|
48
|
-
const highest = value;
|
|
49
|
-
updateDepositLoss({
|
|
50
|
-
highest: highest || undefined
|
|
51
|
-
});
|
|
52
|
-
return;
|
|
53
|
-
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.lowest, min: 0, step: 1, disabled: !update, onChange: (value) => {
|
|
54
|
-
const lowest = value;
|
|
55
|
-
updateDepositLoss({
|
|
56
|
-
lowest: lowest || undefined
|
|
57
|
-
});
|
|
58
|
-
return;
|
|
59
|
-
} }) })] }) }), (0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.withdrawLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t('payConfig.help.withdrawLoss'), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.conservative'), children: (0, jsx_runtime_1.jsx)(antd_1.Switch, { disabled: !update, value: withdrawLoss?.conservative, onChange: (conservative) => {
|
|
60
|
-
updateWithdrawLoss({ conservative });
|
|
61
|
-
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, onChange: (value) => {
|
|
62
|
-
const ratio = value;
|
|
63
|
-
updateWithdrawLoss({
|
|
64
|
-
ratio: ratio || 0
|
|
65
|
-
});
|
|
66
|
-
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.highest, min: 0, step: 1, onChange: (value) => {
|
|
67
|
-
const highest = value;
|
|
68
|
-
updateWithdrawLoss({
|
|
69
|
-
highest: highest || undefined
|
|
70
|
-
});
|
|
71
|
-
return;
|
|
72
|
-
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.lowest, min: 0, step: 1, onChange: (value) => {
|
|
73
|
-
const lowest = value;
|
|
74
|
-
updateWithdrawLoss({
|
|
75
|
-
lowest: lowest || undefined
|
|
76
|
-
});
|
|
77
|
-
return;
|
|
78
|
-
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.trim'), children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { disabled: !!withdrawLoss?.conservative || !update, options: [
|
|
79
|
-
{
|
|
80
|
-
label: t('payConfig.label.jiao'),
|
|
81
|
-
value: 'jiao',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
label: t('payConfig.label.yuan'),
|
|
85
|
-
value: 'yuan',
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
label: t('payConfig.label.null'),
|
|
89
|
-
value: '',
|
|
90
|
-
}
|
|
91
|
-
], value: withdrawLoss?.trim, onChange: ({ target }) => updateWithdrawLoss({
|
|
92
|
-
trim: target.value,
|
|
93
|
-
}) }) })] }) })] }));
|
|
94
|
-
}
|
|
95
|
-
function render(props) {
|
|
96
|
-
const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable, canUpdate } = props.data;
|
|
97
|
-
const { t, update, clean, execute } = props.methods;
|
|
98
|
-
if (system && oakFullpath) {
|
|
99
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.container, children: (0, jsx_runtime_1.jsx)(antd_1.Tabs, { className: web_pc_module_less_1.default.tabs, tabPosition: "left", items: [
|
|
100
|
-
{
|
|
101
|
-
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t('system') })),
|
|
102
|
-
key: 'system',
|
|
103
|
-
children: ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { vertical: true, children: [(0, jsx_runtime_1.jsx)(PayConfig, { payConfig: system.payConfig, update: canUpdate ? (payConfig) => update({ payConfig }) : undefined, t: t }), (0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", justify: 'end', children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", disabled: oakExecutable !== true, onClick: () => execute(), children: t('common::confirm') }), (0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !oakDirty, onClick: () => clean(), children: t('common::reset') })] })] })),
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t('offlineAccount:name') })),
|
|
107
|
-
key: 'offlineAccount',
|
|
108
|
-
children: ((0, jsx_runtime_1.jsx)(config_1.default, { oakPath: `${oakFullpath}.offlineAccount$system`, systemId: system.id })),
|
|
109
|
-
},
|
|
110
|
-
...Object.keys(PayChannelConfigDict).map((ele) => {
|
|
111
|
-
const C = PayChannelConfigDict[ele];
|
|
112
|
-
return {
|
|
113
|
-
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t(`${ele}:name`) })),
|
|
114
|
-
key: 'ele',
|
|
115
|
-
children: (0, jsx_runtime_1.jsx)(C, { oakPath: `${oakFullpath}.${ele}$system`, systemId: system.id })
|
|
116
|
-
};
|
|
117
|
-
})
|
|
118
|
-
] }) }));
|
|
119
|
-
}
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
exports.default = render;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = OakComponent({
|
|
4
|
-
entity: 'wpAccount',
|
|
5
|
-
isList: true,
|
|
6
|
-
projection: {
|
|
7
|
-
id: 1,
|
|
8
|
-
price: 1,
|
|
9
|
-
mchId: 1,
|
|
10
|
-
enabled: 1,
|
|
11
|
-
taxLossRatio: 1,
|
|
12
|
-
refundCompensateRatio: 1,
|
|
13
|
-
refundGapDays: 1,
|
|
14
|
-
allowWithdrawTransfer: 1,
|
|
15
|
-
withdrawTransferLossRatio: 1,
|
|
16
|
-
},
|
|
17
|
-
properties: {
|
|
18
|
-
systemId: '',
|
|
19
|
-
},
|
|
20
|
-
filters: [
|
|
21
|
-
{
|
|
22
|
-
filter() {
|
|
23
|
-
const { systemId } = this.props;
|
|
24
|
-
return {
|
|
25
|
-
systemId,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
formData({ data, legalActions }) {
|
|
31
|
-
return {
|
|
32
|
-
accounts: data,
|
|
33
|
-
canCreate: legalActions?.includes('create') && !data?.find(ele => ele.enabled),
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
actions: ['create', 'update', 'remove'],
|
|
37
|
-
});
|