oak-pay-business 2.2.8 → 2.2.9
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/components/refund/list/web.pc.js +1 -1
- package/es/configuration/attrUpdateMatrix.js +4 -1
- package/es/entities/Refund.d.ts +1 -0
- package/es/entities/Refund.js +1 -0
- package/es/oak-app-domain/Refund/Schema.d.ts +4 -0
- package/es/oak-app-domain/Refund/Storage.js +3 -0
- package/es/oak-app-domain/Refund/locales/zh_CN.json +1 -1
- package/es/triggers/refund.js +3 -1
- package/es/triggers/withdraw.d.ts +1 -1
- package/es/utils/payClazz/WechatPay/WechatPay.js +9 -4
- package/es/watchers/pay.js +1 -1
- package/es/watchers/refund.js +1 -1
- package/lib/aspects/withdraw.d.ts +12 -12
- package/lib/configuration/attrUpdateMatrix.js +4 -1
- package/lib/entities/Refund.d.ts +1 -0
- package/lib/entities/Refund.js +1 -0
- package/lib/oak-app-domain/Refund/Schema.d.ts +4 -0
- package/lib/oak-app-domain/Refund/Storage.js +3 -0
- package/lib/oak-app-domain/Refund/locales/zh_CN.json +1 -1
- package/lib/triggers/refund.js +3 -1
- package/lib/utils/payClazz/WechatPay/WechatPay.js +9 -4
- package/lib/watchers/pay.js +1 -1
- package/lib/watchers/refund.js +1 -1
- package/package.json +1 -1
- package/src/entities/Refund.ts +2 -0
|
@@ -100,7 +100,7 @@ export default function Render(props) {
|
|
|
100
100
|
]} onAction={(row, action) => {
|
|
101
101
|
const { entity } = row.pay;
|
|
102
102
|
assert(entity !== 'account');
|
|
103
|
-
if (entity !== 'offlineAccount'
|
|
103
|
+
if (entity !== 'offlineAccount' && !amIRoot) {
|
|
104
104
|
setMessage({
|
|
105
105
|
type: 'error',
|
|
106
106
|
title: t('cantOperateOnline'),
|
package/es/entities/Refund.d.ts
CHANGED
package/es/entities/Refund.js
CHANGED
|
@@ -14,6 +14,7 @@ export type OpSchema = EntityShape & {
|
|
|
14
14
|
loss: Price;
|
|
15
15
|
payId: ForeignKey<"pay">;
|
|
16
16
|
meta?: Object | null;
|
|
17
|
+
externalMeta?: Object | null;
|
|
17
18
|
externalId?: String<128> | null;
|
|
18
19
|
price: Price;
|
|
19
20
|
creatorId: ForeignKey<"user">;
|
|
@@ -27,6 +28,7 @@ export type Schema = EntityShape & {
|
|
|
27
28
|
loss: Price;
|
|
28
29
|
payId: ForeignKey<"pay">;
|
|
29
30
|
meta?: Object | null;
|
|
31
|
+
externalMeta?: Object | null;
|
|
30
32
|
externalId?: String<128> | null;
|
|
31
33
|
price: Price;
|
|
32
34
|
creatorId: ForeignKey<"user">;
|
|
@@ -54,6 +56,7 @@ type AttrFilter = {
|
|
|
54
56
|
payId: Q_StringValue;
|
|
55
57
|
pay: Pay.Filter;
|
|
56
58
|
meta: Object;
|
|
59
|
+
externalMeta: Object;
|
|
57
60
|
externalId: Q_StringValue;
|
|
58
61
|
price: Q_NumberValue;
|
|
59
62
|
creatorId: Q_StringValue;
|
|
@@ -78,6 +81,7 @@ export type Projection = {
|
|
|
78
81
|
payId?: number;
|
|
79
82
|
pay?: Pay.Projection;
|
|
80
83
|
meta?: number | Object;
|
|
84
|
+
externalMeta?: number | Object;
|
|
81
85
|
externalId?: number;
|
|
82
86
|
price?: number;
|
|
83
87
|
creatorId?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作", "successAt": "退款成功时间" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }
|
|
1
|
+
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalMeta": "外部meta信息", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作", "successAt": "退款成功时间" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }
|
package/es/triggers/refund.js
CHANGED
|
@@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
|
|
|
6
6
|
* @param context
|
|
7
7
|
* @param refunds
|
|
8
8
|
*/
|
|
9
|
-
export declare function updateWithdrawState(context: BRC, id: string): Promise<
|
|
9
|
+
export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
|
|
10
10
|
declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
|
|
11
11
|
export default triggers;
|
|
@@ -55,7 +55,7 @@ export default class WechatPay extends WechatPayDebug {
|
|
|
55
55
|
const { id, price, pay } = refund;
|
|
56
56
|
const serverUrl = context.composeAccessPath();
|
|
57
57
|
const endpoint = this.refundNotifyUrl;
|
|
58
|
-
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${
|
|
58
|
+
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${id}`;
|
|
59
59
|
const result = await this.wechatPay.createRefund({
|
|
60
60
|
out_trade_no: compressTo32(pay.id),
|
|
61
61
|
out_refund_no: compressTo32(id),
|
|
@@ -73,7 +73,8 @@ export default class WechatPay extends WechatPayDebug {
|
|
|
73
73
|
}
|
|
74
74
|
async getRefundState(refund) {
|
|
75
75
|
const result = await this.wechatPay.queryRefundByOutRefundNo(compressTo32(refund.id));
|
|
76
|
-
const
|
|
76
|
+
const externalMeta = this.analyzeResult(result);
|
|
77
|
+
const { status, success_time } = externalMeta;
|
|
77
78
|
/**
|
|
78
79
|
* 【退款状态】 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。
|
|
79
80
|
可选取值:
|
|
@@ -83,7 +84,10 @@ export default class WechatPay extends WechatPayDebug {
|
|
|
83
84
|
ABNORMAL: 退款异常
|
|
84
85
|
*/
|
|
85
86
|
const iState = REFUND_STATE_MATRIX[status];
|
|
86
|
-
return [iState, success_time ? {
|
|
87
|
+
return [iState, success_time ? {
|
|
88
|
+
successAt: success_time ? dayJs(success_time).valueOf() : undefined,
|
|
89
|
+
externalMeta,
|
|
90
|
+
} : undefined];
|
|
87
91
|
}
|
|
88
92
|
analyzeResult(result) {
|
|
89
93
|
const { success, data, } = result;
|
|
@@ -358,9 +362,10 @@ export default class WechatPay extends WechatPayDebug {
|
|
|
358
362
|
const iState = REFUND_STATE_MATRIX[refund_status];
|
|
359
363
|
assert(iState);
|
|
360
364
|
const extra = {
|
|
361
|
-
|
|
365
|
+
externalMeta: omit(result, ['mchid',]),
|
|
362
366
|
};
|
|
363
367
|
if (iState === 'successful') {
|
|
368
|
+
assert(success_time);
|
|
364
369
|
extra.successAt = dayJs(success_time).valueOf();
|
|
365
370
|
}
|
|
366
371
|
return {
|
package/es/watchers/pay.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fullPayProjection, refreshPayState } from '../utils/pay';
|
|
2
2
|
import { mergeOperationResult } from 'oak-domain/lib/utils/operationResult';
|
|
3
|
-
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ?
|
|
3
|
+
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
|
|
4
4
|
const watchers = [
|
|
5
5
|
{
|
|
6
6
|
name: '对paying状态的订单,同步其真实支付状态',
|
package/es/watchers/refund.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getPayClazz } from '../utils/payClazz';
|
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
|
4
4
|
import { mergeOperationResult } from 'oak-domain/lib/utils/operationResult';
|
|
5
|
-
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ?
|
|
5
|
+
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
|
|
6
6
|
const watchers = [
|
|
7
7
|
{
|
|
8
8
|
name: '对refund状态的退款,同步其真实退款状态',
|
|
@@ -3,7 +3,7 @@ export declare function getWithdrawCreateData(params: {
|
|
|
3
3
|
accountId: string;
|
|
4
4
|
price: number;
|
|
5
5
|
withdrawAccountId?: string;
|
|
6
|
-
}, context: BRC): Promise<(Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "
|
|
6
|
+
}, context: BRC): Promise<(Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
|
7
7
|
id: string;
|
|
8
8
|
} & {
|
|
9
9
|
accountId: string;
|
|
@@ -12,12 +12,12 @@ export declare function getWithdrawCreateData(params: {
|
|
|
12
12
|
creatorId: string;
|
|
13
13
|
creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
|
|
14
14
|
} & {
|
|
15
|
-
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "
|
|
16
|
-
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "
|
|
15
|
+
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
|
16
|
+
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
|
17
17
|
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
18
18
|
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
19
19
|
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
20
|
-
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "
|
|
20
|
+
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
|
21
21
|
id: string;
|
|
22
22
|
} & {
|
|
23
23
|
accountId: string;
|
|
@@ -26,12 +26,12 @@ export declare function getWithdrawCreateData(params: {
|
|
|
26
26
|
creator?: undefined;
|
|
27
27
|
creatorId: string;
|
|
28
28
|
} & {
|
|
29
|
-
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "
|
|
30
|
-
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "
|
|
29
|
+
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
|
30
|
+
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
|
31
31
|
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
32
32
|
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
33
33
|
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
34
|
-
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "
|
|
34
|
+
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
|
35
35
|
id: string;
|
|
36
36
|
} & {
|
|
37
37
|
account?: undefined;
|
|
@@ -40,12 +40,12 @@ export declare function getWithdrawCreateData(params: {
|
|
|
40
40
|
creatorId: string;
|
|
41
41
|
creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
|
|
42
42
|
} & {
|
|
43
|
-
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "
|
|
44
|
-
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "
|
|
43
|
+
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
|
44
|
+
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
|
45
45
|
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
46
46
|
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
47
47
|
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
48
|
-
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "
|
|
48
|
+
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
|
49
49
|
id: string;
|
|
50
50
|
} & {
|
|
51
51
|
account?: undefined;
|
|
@@ -54,8 +54,8 @@ export declare function getWithdrawCreateData(params: {
|
|
|
54
54
|
creator?: undefined;
|
|
55
55
|
creatorId: string;
|
|
56
56
|
} & {
|
|
57
|
-
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "
|
|
58
|
-
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "
|
|
57
|
+
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
|
58
|
+
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
|
59
59
|
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
60
60
|
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
|
61
61
|
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
package/lib/entities/Refund.d.ts
CHANGED
package/lib/entities/Refund.js
CHANGED
|
@@ -14,6 +14,7 @@ export type OpSchema = EntityShape & {
|
|
|
14
14
|
loss: Price;
|
|
15
15
|
payId: ForeignKey<"pay">;
|
|
16
16
|
meta?: Object | null;
|
|
17
|
+
externalMeta?: Object | null;
|
|
17
18
|
externalId?: String<128> | null;
|
|
18
19
|
price: Price;
|
|
19
20
|
creatorId: ForeignKey<"user">;
|
|
@@ -27,6 +28,7 @@ export type Schema = EntityShape & {
|
|
|
27
28
|
loss: Price;
|
|
28
29
|
payId: ForeignKey<"pay">;
|
|
29
30
|
meta?: Object | null;
|
|
31
|
+
externalMeta?: Object | null;
|
|
30
32
|
externalId?: String<128> | null;
|
|
31
33
|
price: Price;
|
|
32
34
|
creatorId: ForeignKey<"user">;
|
|
@@ -54,6 +56,7 @@ type AttrFilter = {
|
|
|
54
56
|
payId: Q_StringValue;
|
|
55
57
|
pay: Pay.Filter;
|
|
56
58
|
meta: Object;
|
|
59
|
+
externalMeta: Object;
|
|
57
60
|
externalId: Q_StringValue;
|
|
58
61
|
price: Q_NumberValue;
|
|
59
62
|
creatorId: Q_StringValue;
|
|
@@ -78,6 +81,7 @@ export type Projection = {
|
|
|
78
81
|
payId?: number;
|
|
79
82
|
pay?: Pay.Projection;
|
|
80
83
|
meta?: number | Object;
|
|
84
|
+
externalMeta?: number | Object;
|
|
81
85
|
externalId?: number;
|
|
82
86
|
price?: number;
|
|
83
87
|
creatorId?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作", "successAt": "退款成功时间" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }
|
|
1
|
+
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalMeta": "外部meta信息", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作", "successAt": "退款成功时间" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }
|
package/lib/triggers/refund.js
CHANGED
|
@@ -58,7 +58,7 @@ class WechatPay extends WechatPay_debug_1.default {
|
|
|
58
58
|
const { id, price, pay } = refund;
|
|
59
59
|
const serverUrl = context.composeAccessPath();
|
|
60
60
|
const endpoint = this.refundNotifyUrl;
|
|
61
|
-
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${
|
|
61
|
+
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${id}`;
|
|
62
62
|
const result = await this.wechatPay.createRefund({
|
|
63
63
|
out_trade_no: (0, uuid_1.compressTo32)(pay.id),
|
|
64
64
|
out_refund_no: (0, uuid_1.compressTo32)(id),
|
|
@@ -76,7 +76,8 @@ class WechatPay extends WechatPay_debug_1.default {
|
|
|
76
76
|
}
|
|
77
77
|
async getRefundState(refund) {
|
|
78
78
|
const result = await this.wechatPay.queryRefundByOutRefundNo((0, uuid_1.compressTo32)(refund.id));
|
|
79
|
-
const
|
|
79
|
+
const externalMeta = this.analyzeResult(result);
|
|
80
|
+
const { status, success_time } = externalMeta;
|
|
80
81
|
/**
|
|
81
82
|
* 【退款状态】 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。
|
|
82
83
|
可选取值:
|
|
@@ -86,7 +87,10 @@ class WechatPay extends WechatPay_debug_1.default {
|
|
|
86
87
|
ABNORMAL: 退款异常
|
|
87
88
|
*/
|
|
88
89
|
const iState = REFUND_STATE_MATRIX[status];
|
|
89
|
-
return [iState, success_time ? {
|
|
90
|
+
return [iState, success_time ? {
|
|
91
|
+
successAt: success_time ? (0, dayjs_1.default)(success_time).valueOf() : undefined,
|
|
92
|
+
externalMeta,
|
|
93
|
+
} : undefined];
|
|
90
94
|
}
|
|
91
95
|
analyzeResult(result) {
|
|
92
96
|
const { success, data, } = result;
|
|
@@ -361,9 +365,10 @@ class WechatPay extends WechatPay_debug_1.default {
|
|
|
361
365
|
const iState = REFUND_STATE_MATRIX[refund_status];
|
|
362
366
|
(0, assert_1.default)(iState);
|
|
363
367
|
const extra = {
|
|
364
|
-
|
|
368
|
+
externalMeta: (0, lodash_1.omit)(result, ['mchid',]),
|
|
365
369
|
};
|
|
366
370
|
if (iState === 'successful') {
|
|
371
|
+
(0, assert_1.default)(success_time);
|
|
367
372
|
extra.successAt = (0, dayjs_1.default)(success_time).valueOf();
|
|
368
373
|
}
|
|
369
374
|
return {
|
package/lib/watchers/pay.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const pay_1 = require("../utils/pay");
|
|
4
4
|
const operationResult_1 = require("oak-domain/lib/utils/operationResult");
|
|
5
|
-
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ?
|
|
5
|
+
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
|
|
6
6
|
const watchers = [
|
|
7
7
|
{
|
|
8
8
|
name: '对paying状态的订单,同步其真实支付状态',
|
package/lib/watchers/refund.js
CHANGED
|
@@ -5,7 +5,7 @@ const payClazz_1 = require("../utils/payClazz");
|
|
|
5
5
|
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
6
|
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
|
7
7
|
const operationResult_1 = require("oak-domain/lib/utils/operationResult");
|
|
8
|
-
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ?
|
|
8
|
+
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
|
|
9
9
|
const watchers = [
|
|
10
10
|
{
|
|
11
11
|
name: '对refund状态的退款,同步其真实退款状态',
|
package/package.json
CHANGED
package/src/entities/Refund.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface Schema extends EntityShape {
|
|
|
18
18
|
loss: Price;
|
|
19
19
|
pay: Pay;
|
|
20
20
|
meta?: Object,
|
|
21
|
+
externalMeta?: Object,
|
|
21
22
|
externalId?: String<128>;
|
|
22
23
|
price: Price;
|
|
23
24
|
creator: User;
|
|
@@ -50,6 +51,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
|
|
|
50
51
|
loss: '损耗',
|
|
51
52
|
withdraw: '关联提现',
|
|
52
53
|
meta: 'metadata',
|
|
54
|
+
externalMeta: '外部meta信息',
|
|
53
55
|
externalId: '外部退款流水号',
|
|
54
56
|
iState: '状态',
|
|
55
57
|
creator: '创建者',
|