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.
@@ -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' || !amIRoot) {
103
+ if (entity !== 'offlineAccount' && !amIRoot) {
104
104
  setMessage({
105
105
  type: 'error',
106
106
  title: t('cantOperateOnline'),
@@ -87,7 +87,10 @@ const attrUpdateMatrix = {
87
87
  },
88
88
  successAt: {
89
89
  actions: ['succeed'],
90
- }
90
+ },
91
+ externalMeta: {
92
+ actions: ['succeed', 'fail'],
93
+ },
91
94
  },
92
95
  withdraw: {
93
96
  dealLoss: {
@@ -10,6 +10,7 @@ export interface Schema extends EntityShape {
10
10
  loss: Price;
11
11
  pay: Pay;
12
12
  meta?: Object;
13
+ externalMeta?: Object;
13
14
  externalId?: String<128>;
14
15
  price: Price;
15
16
  creator: User;
@@ -16,6 +16,7 @@ export const entityDesc = {
16
16
  loss: '损耗',
17
17
  withdraw: '关联提现',
18
18
  meta: 'metadata',
19
+ externalMeta: '外部meta信息',
19
20
  externalId: '外部退款流水号',
20
21
  iState: '状态',
21
22
  creator: '创建者',
@@ -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;
@@ -17,6 +17,9 @@ export const desc = {
17
17
  meta: {
18
18
  type: "object"
19
19
  },
20
+ externalMeta: {
21
+ type: "object"
22
+ },
20
23
  externalId: {
21
24
  type: "varchar",
22
25
  params: {
@@ -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": "退款失败" } } }
@@ -237,7 +237,9 @@ async function failRefunding(context, refundId) {
237
237
  await context.operate('pay', {
238
238
  id: await generateNewIdAsync(),
239
239
  action,
240
- data: {},
240
+ data: {
241
+ refundable: true,
242
+ },
241
243
  filter: {
242
244
  id: pay.id,
243
245
  }
@@ -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<0 | 1>;
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}/${pay.id}`;
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 { status, success_time } = this.analyzeResult(result);
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 ? { successAt: dayJs(success_time).valueOf() } : undefined];
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
- meta: omit(result, ['mchid',]),
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 {
@@ -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' ? 3600 * 1000 : 60 * 1000;
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状态的订单,同步其真实支付状态',
@@ -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' ? 3600 * 1000 : 60 * 1000;
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, "creatorId" | "accountId">> & {
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, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdrawId" | "withdraw">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdrawId" | "withdraw">>)[] | undefined;
16
- withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdrawId" | "withdraw">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdrawId" | "withdraw">>)[] | undefined;
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, "creatorId" | "accountId">> & {
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, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdrawId" | "withdraw">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdrawId" | "withdraw">>)[] | undefined;
30
- withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdrawId" | "withdraw">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdrawId" | "withdraw">>)[] | undefined;
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, "creatorId" | "accountId">> & {
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, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdrawId" | "withdraw">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdrawId" | "withdraw">>)[] | undefined;
44
- withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdrawId" | "withdraw">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdrawId" | "withdraw">>)[] | undefined;
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, "creatorId" | "accountId">> & {
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, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdrawId" | "withdraw">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdrawId" | "withdraw">>)[] | undefined;
58
- withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdrawId" | "withdraw">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdrawId" | "withdraw">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdrawId" | "withdraw">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdrawId" | "withdraw">>)[] | undefined;
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;
@@ -89,7 +89,10 @@ const attrUpdateMatrix = {
89
89
  },
90
90
  successAt: {
91
91
  actions: ['succeed'],
92
- }
92
+ },
93
+ externalMeta: {
94
+ actions: ['succeed', 'fail'],
95
+ },
93
96
  },
94
97
  withdraw: {
95
98
  dealLoss: {
@@ -10,6 +10,7 @@ export interface Schema extends EntityShape {
10
10
  loss: Price;
11
11
  pay: Pay;
12
12
  meta?: Object;
13
+ externalMeta?: Object;
13
14
  externalId?: String<128>;
14
15
  price: Price;
15
16
  creator: User;
@@ -19,6 +19,7 @@ exports.entityDesc = {
19
19
  loss: '损耗',
20
20
  withdraw: '关联提现',
21
21
  meta: 'metadata',
22
+ externalMeta: '外部meta信息',
22
23
  externalId: '外部退款流水号',
23
24
  iState: '状态',
24
25
  creator: '创建者',
@@ -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;
@@ -20,6 +20,9 @@ exports.desc = {
20
20
  meta: {
21
21
  type: "object"
22
22
  },
23
+ externalMeta: {
24
+ type: "object"
25
+ },
23
26
  externalId: {
24
27
  type: "varchar",
25
28
  params: {
@@ -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": "退款失败" } } }
@@ -240,7 +240,9 @@ async function failRefunding(context, refundId) {
240
240
  await context.operate('pay', {
241
241
  id: await (0, uuid_1.generateNewIdAsync)(),
242
242
  action,
243
- data: {},
243
+ data: {
244
+ refundable: true,
245
+ },
244
246
  filter: {
245
247
  id: pay.id,
246
248
  }
@@ -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}/${pay.id}`;
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 { status, success_time } = this.analyzeResult(result);
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 ? { successAt: (0, dayjs_1.default)(success_time).valueOf() } : undefined];
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
- meta: (0, lodash_1.omit)(result, ['mchid',]),
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 {
@@ -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' ? 3600 * 1000 : 60 * 1000;
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状态的订单,同步其真实支付状态',
@@ -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' ? 3600 * 1000 : 60 * 1000;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-pay-business",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib/**/*",
@@ -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: '创建者',