继续更新一些支付实测的小问题

This commit is contained in:
Xu Chang 2024-07-12 21:07:26 +08:00
parent 7bf529cf5f
commit 18678f3944
28 changed files with 87 additions and 38 deletions

View File

@ -87,7 +87,10 @@ const attrUpdateMatrix = {
},
successAt: {
actions: ['succeed'],
}
},
externalMeta: {
actions: ['succeed', 'fail'],
},
},
withdraw: {
dealLoss: {

View File

@ -10,6 +10,7 @@ export interface Schema extends EntityShape {
loss: Price;
pay: Pay;
meta?: Object;
externalMeta?: Object;
externalId?: String<128>;
price: Price;
creator: User;

View File

@ -16,6 +16,7 @@ export const entityDesc = {
loss: '损耗',
withdraw: '关联提现',
meta: 'metadata',
externalMeta: '外部meta信息',
externalId: '外部退款流水号',
iState: '状态',
creator: '创建者',

View File

@ -14,6 +14,7 @@ export type OpSchema = EntityShape & {
loss: Price;
payId: ForeignKey<"pay">;
meta?: Object | null;
externalMeta?: Object | null;
externalId?: String<128> | null;
price: Price;
creatorId: ForeignKey<"user">;
@ -27,6 +28,7 @@ export type Schema = EntityShape & {
loss: Price;
payId: ForeignKey<"pay">;
meta?: Object | null;
externalMeta?: Object | null;
externalId?: String<128> | null;
price: Price;
creatorId: ForeignKey<"user">;
@ -54,6 +56,7 @@ type AttrFilter = {
payId: Q_StringValue;
pay: Pay.Filter;
meta: Object;
externalMeta: Object;
externalId: Q_StringValue;
price: Q_NumberValue;
creatorId: Q_StringValue;
@ -78,6 +81,7 @@ export type Projection = {
payId?: number;
pay?: Pay.Projection;
meta?: number | Object;
externalMeta?: number | Object;
externalId?: number;
price?: number;
creatorId?: number;

View File

@ -17,6 +17,9 @@ export const desc = {
meta: {
type: "object"
},
externalMeta: {
type: "object"
},
externalId: {
type: "varchar",
params: {

View File

@ -1 +1 @@
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作", "successAt": "退款成功时间" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalMeta": "外部meta信息", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作", "successAt": "退款成功时间" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }

View File

@ -237,7 +237,9 @@ async function failRefunding(context, refundId) {
await context.operate('pay', {
id: await generateNewIdAsync(),
action,
data: {},
data: {
refundable: true,
},
filter: {
id: pay.id,
}

View File

@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
* @param context
* @param refunds
*/
export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>;
export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
export default triggers;

View File

@ -55,7 +55,7 @@ export default class WechatPay extends WechatPayDebug {
const { id, price, pay } = refund;
const serverUrl = context.composeAccessPath();
const endpoint = this.refundNotifyUrl;
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${pay.id}`;
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${id}`;
const result = await this.wechatPay.createRefund({
out_trade_no: compressTo32(pay.id),
out_refund_no: compressTo32(id),
@ -73,7 +73,8 @@ export default class WechatPay extends WechatPayDebug {
}
async getRefundState(refund) {
const result = await this.wechatPay.queryRefundByOutRefundNo(compressTo32(refund.id));
const { status, success_time } = this.analyzeResult(result);
const externalMeta = this.analyzeResult(result);
const { status, success_time } = externalMeta;
/**
* 退款状态 退款到银行发现用户的卡作废或者冻结了导致原路退款银行卡失败可前往商户平台pay.weixin.qq.com-交易中心手动处理此笔退款
可选取值
@ -83,7 +84,10 @@ export default class WechatPay extends WechatPayDebug {
ABNORMAL: 退款异常
*/
const iState = REFUND_STATE_MATRIX[status];
return [iState, success_time ? { successAt: dayJs(success_time).valueOf() } : undefined];
return [iState, success_time ? {
successAt: success_time ? dayJs(success_time).valueOf() : undefined,
externalMeta,
} : undefined];
}
analyzeResult(result) {
const { success, data, } = result;
@ -358,9 +362,10 @@ export default class WechatPay extends WechatPayDebug {
const iState = REFUND_STATE_MATRIX[refund_status];
assert(iState);
const extra = {
meta: omit(result, ['mchid',]),
externalMeta: omit(result, ['mchid',]),
};
if (iState === 'successful') {
assert(success_time);
extra.successAt = dayJs(success_time).valueOf();
}
return {

View File

@ -1,6 +1,6 @@
import { fullPayProjection, refreshPayState } from '../utils/pay';
import { mergeOperationResult } from 'oak-domain/lib/utils/operationResult';
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 3600 * 1000 : 60 * 1000;
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
const watchers = [
{
name: '对paying状态的订单同步其真实支付状态',

View File

@ -2,7 +2,7 @@ import { getPayClazz } from '../utils/payClazz';
import assert from 'assert';
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
import { mergeOperationResult } from 'oak-domain/lib/utils/operationResult';
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 3600 * 1000 : 60 * 1000;
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
const watchers = [
{
name: '对refund状态的退款同步其真实退款状态',

View File

@ -3,7 +3,7 @@ export declare function getWithdrawCreateData(params: {
accountId: string;
price: number;
withdrawAccountId?: string;
}, context: BRC): Promise<(Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "creatorId" | "accountId">> & {
}, context: BRC): Promise<(Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
id: string;
} & {
accountId: string;
@ -12,12 +12,12 @@ export declare function getWithdrawCreateData(params: {
creatorId: string;
creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
} & {
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;
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;
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;
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;
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;
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;
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;
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "creatorId" | "accountId">> & {
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
id: string;
} & {
accountId: string;
@ -26,12 +26,12 @@ export declare function getWithdrawCreateData(params: {
creator?: undefined;
creatorId: string;
} & {
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;
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;
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;
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;
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;
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;
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;
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "creatorId" | "accountId">> & {
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
id: string;
} & {
account?: undefined;
@ -40,12 +40,12 @@ export declare function getWithdrawCreateData(params: {
creatorId: string;
creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
} & {
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;
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;
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;
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;
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;
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;
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;
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "creatorId" | "accountId">> & {
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
id: string;
} & {
account?: undefined;
@ -54,8 +54,8 @@ export declare function getWithdrawCreateData(params: {
creator?: undefined;
creatorId: string;
} & {
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;
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;
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;
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;
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;
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;
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;

View File

@ -89,7 +89,10 @@ const attrUpdateMatrix = {
},
successAt: {
actions: ['succeed'],
}
},
externalMeta: {
actions: ['succeed', 'fail'],
},
},
withdraw: {
dealLoss: {

View File

@ -10,6 +10,7 @@ export interface Schema extends EntityShape {
loss: Price;
pay: Pay;
meta?: Object;
externalMeta?: Object;
externalId?: String<128>;
price: Price;
creator: User;

View File

@ -19,6 +19,7 @@ exports.entityDesc = {
loss: '损耗',
withdraw: '关联提现',
meta: 'metadata',
externalMeta: '外部meta信息',
externalId: '外部退款流水号',
iState: '状态',
creator: '创建者',

View File

@ -14,6 +14,7 @@ export type OpSchema = EntityShape & {
loss: Price;
payId: ForeignKey<"pay">;
meta?: Object | null;
externalMeta?: Object | null;
externalId?: String<128> | null;
price: Price;
creatorId: ForeignKey<"user">;
@ -27,6 +28,7 @@ export type Schema = EntityShape & {
loss: Price;
payId: ForeignKey<"pay">;
meta?: Object | null;
externalMeta?: Object | null;
externalId?: String<128> | null;
price: Price;
creatorId: ForeignKey<"user">;
@ -54,6 +56,7 @@ type AttrFilter = {
payId: Q_StringValue;
pay: Pay.Filter;
meta: Object;
externalMeta: Object;
externalId: Q_StringValue;
price: Q_NumberValue;
creatorId: Q_StringValue;
@ -78,6 +81,7 @@ export type Projection = {
payId?: number;
pay?: Pay.Projection;
meta?: number | Object;
externalMeta?: number | Object;
externalId?: number;
price?: number;
creatorId?: number;

View File

@ -20,6 +20,9 @@ exports.desc = {
meta: {
type: "object"
},
externalMeta: {
type: "object"
},
externalId: {
type: "varchar",
params: {

View File

@ -1 +1 @@
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作", "successAt": "退款成功时间" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalMeta": "外部meta信息", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作", "successAt": "退款成功时间" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }

View File

@ -240,7 +240,9 @@ async function failRefunding(context, refundId) {
await context.operate('pay', {
id: await (0, uuid_1.generateNewIdAsync)(),
action,
data: {},
data: {
refundable: true,
},
filter: {
id: pay.id,
}

View File

@ -58,7 +58,7 @@ class WechatPay extends WechatPay_debug_1.default {
const { id, price, pay } = refund;
const serverUrl = context.composeAccessPath();
const endpoint = this.refundNotifyUrl;
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${pay.id}`;
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${id}`;
const result = await this.wechatPay.createRefund({
out_trade_no: (0, uuid_1.compressTo32)(pay.id),
out_refund_no: (0, uuid_1.compressTo32)(id),
@ -76,7 +76,8 @@ class WechatPay extends WechatPay_debug_1.default {
}
async getRefundState(refund) {
const result = await this.wechatPay.queryRefundByOutRefundNo((0, uuid_1.compressTo32)(refund.id));
const { status, success_time } = this.analyzeResult(result);
const externalMeta = this.analyzeResult(result);
const { status, success_time } = externalMeta;
/**
* 退款状态 退款到银行发现用户的卡作废或者冻结了导致原路退款银行卡失败可前往商户平台pay.weixin.qq.com-交易中心手动处理此笔退款
可选取值
@ -86,7 +87,10 @@ class WechatPay extends WechatPay_debug_1.default {
ABNORMAL: 退款异常
*/
const iState = REFUND_STATE_MATRIX[status];
return [iState, success_time ? { successAt: (0, dayjs_1.default)(success_time).valueOf() } : undefined];
return [iState, success_time ? {
successAt: success_time ? (0, dayjs_1.default)(success_time).valueOf() : undefined,
externalMeta,
} : undefined];
}
analyzeResult(result) {
const { success, data, } = result;
@ -361,9 +365,10 @@ class WechatPay extends WechatPay_debug_1.default {
const iState = REFUND_STATE_MATRIX[refund_status];
(0, assert_1.default)(iState);
const extra = {
meta: (0, lodash_1.omit)(result, ['mchid',]),
externalMeta: (0, lodash_1.omit)(result, ['mchid',]),
};
if (iState === 'successful') {
(0, assert_1.default)(success_time);
extra.successAt = (0, dayjs_1.default)(success_time).valueOf();
}
return {

View File

@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
const pay_1 = require("../utils/pay");
const operationResult_1 = require("oak-domain/lib/utils/operationResult");
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 3600 * 1000 : 60 * 1000;
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
const watchers = [
{
name: '对paying状态的订单同步其真实支付状态',

View File

@ -5,7 +5,7 @@ const payClazz_1 = require("../utils/payClazz");
const assert_1 = tslib_1.__importDefault(require("assert"));
const uuid_1 = require("oak-domain/lib/utils/uuid");
const operationResult_1 = require("oak-domain/lib/utils/operationResult");
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 3600 * 1000 : 60 * 1000;
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
const watchers = [
{
name: '对refund状态的退款同步其真实退款状态',

View File

@ -92,7 +92,10 @@ const attrUpdateMatrix: AttrUpdateMatrix<EntityDict> = {
},
successAt: {
actions: ['succeed'],
}
},
externalMeta: {
actions: ['succeed', 'fail'],
},
},
withdraw: {
dealLoss: {

View File

@ -18,6 +18,7 @@ export interface Schema extends EntityShape {
loss: Price;
pay: Pay;
meta?: Object,
externalMeta?: Object,
externalId?: String<128>;
price: Price;
creator: User;
@ -50,6 +51,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
loss: '损耗',
withdraw: '关联提现',
meta: 'metadata',
externalMeta: '外部meta信息',
externalId: '外部退款流水号',
iState: '状态',
creator: '创建者',

View File

@ -263,6 +263,7 @@ async function failRefunding(context: BRC, refundId: string) {
id: await generateNewIdAsync(),
action,
data: {
refundable: true,
},
filter: {
id: pay!.id!,

View File

@ -72,7 +72,7 @@ export default class WechatPay extends WechatPayDebug implements PayClazz {
const { id, price, pay } = refund;
const serverUrl = context.composeAccessPath();
const endpoint = this.refundNotifyUrl;
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${pay.id}`;
const refundNotifyUrl = `${serverUrl}/endpoint/${endpoint}/${id}`;
const result = await this.wechatPay.createRefund({
out_trade_no: compressTo32(pay.id),
out_refund_no: compressTo32(id),
@ -91,7 +91,8 @@ export default class WechatPay extends WechatPayDebug implements PayClazz {
async getRefundState(refund: OpRefund): Promise<[string | null | undefined, RefundUpdateData | undefined]> {
const result = await this.wechatPay.queryRefundByOutRefundNo(compressTo32(refund.id!));
const { status, success_time } = this.analyzeResult(result);
const externalMeta = this.analyzeResult(result);
const { status, success_time } = externalMeta;
/**
* 退 退退pay.weixin.qq.com-退
@ -102,7 +103,10 @@ export default class WechatPay extends WechatPayDebug implements PayClazz {
*/
const iState = REFUND_STATE_MATRIX[status];
return [iState, success_time ? { successAt: dayJs(success_time).valueOf() } : undefined];
return [iState, success_time ? {
successAt: success_time ? dayJs(success_time).valueOf() : undefined,
externalMeta,
} : undefined];
}
private analyzeResult<R extends any>(result: ApiResult<R>) {
@ -435,10 +439,11 @@ export default class WechatPay extends WechatPayDebug implements PayClazz {
assert(iState);
const extra: RefundUpdateData = {
meta: omit(result, ['mchid', ]),
externalMeta: omit(result, ['mchid', ]),
};
if (iState === 'successful') {
assert(success_time);
extra.successAt = dayJs(success_time).valueOf();
}

View File

@ -5,7 +5,7 @@ import { fullPayProjection, refreshPayState } from '../utils/pay';
import { OperationResult } from 'oak-domain/lib/types';
import { mergeOperationResult } from 'oak-domain/lib/utils/operationResult';
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 3600 * 1000 : 60 * 1000;
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
const watchers: Watcher<EntityDict, 'pay', BRC>[] = [
{

View File

@ -8,7 +8,7 @@ import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
import { OperationResult } from 'oak-domain/lib/types';
import { mergeOperationResult } from 'oak-domain/lib/utils/operationResult';
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 3600 * 1000 : 60 * 1000;
const QUERY_PAYING_STATE_GAP = process.env.NODE_ENV === 'production' ? 600 * 1000 : 60 * 1000;
const watchers: Watcher<EntityDict, 'refund', BRC>[] = [
{