微调了AbstractAccount的定义

This commit is contained in:
Xu Chang 2025-02-08 09:32:04 +08:00
parent 157e41d9f4
commit 77cc2fec3b
69 changed files with 758 additions and 89 deletions

View File

@ -1,4 +1,4 @@
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { Checker } from 'oak-domain/lib/types';
import { RuntimeCxt } from '../types/RuntimeCxt';
declare const checkers: Checker<EntityDict, keyof EntityDict, RuntimeCxt>[];

View File

@ -1,4 +1,4 @@
import { PayChannel } from "../../../types/Pay";
import { PayChannel } from "@project/types/Pay";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, boolean, {
accountId: string;
depositMinCent: number;

View File

@ -1,7 +1,7 @@
import React from 'react';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import { PayChannel, PayChannels } from '../../../types/Pay';
import { PayChannel, PayChannels } from '@project/types/Pay';
export default function render(props: WebComponentProps<EntityDict, 'deposit', false, {
depositMax: number;
price: number;

View File

@ -1,7 +1,7 @@
import React from 'react';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import { PayChannel, PayChannels } from '../../../types/Pay';
import { PayChannel, PayChannels } from '@project/types/Pay';
export default function render(props: WebComponentProps<EntityDict, 'deposit', false, {
depositMax: number;
price: number;

View File

@ -2,7 +2,7 @@ import React from 'react';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import { AccountPayConfig } from '../../../types/PayConfig';
import { PayChannel, PayChannels } from '../../../types/Pay';
import { PayChannel, PayChannels } from '@project/types/Pay';
export default function Render(props: WebComponentProps<EntityDict, 'order', false, {
accountId?: string;
accountAvailMax: number;

View File

@ -2,7 +2,7 @@ import React from 'react';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import { AccountPayConfig } from '../../../types/PayConfig';
import { PayChannel, PayChannels } from '../../../types/Pay';
import { PayChannel, PayChannels } from '@project/types/Pay';
export default function Render(props: WebComponentProps<EntityDict, 'order', false, {
accountId?: string;
accountAvailMax: number;

View File

@ -1,5 +1,5 @@
/// <reference types="react" />
import { PayChannelOption } from "../../../types/Pay";
import { PayChannelOption } from "@project/types/Pay";
export default function Render(props: {
data: {
channel?: string;

View File

@ -1,5 +1,5 @@
/// <reference types="react" />
import { PayChannelOption } from "../../../types/Pay";
import { PayChannelOption } from "@project/types/Pay";
export default function Render(props: {
data: {
channel?: string;

View File

@ -1,4 +1,4 @@
import { AccountPayConfig } from '../../../../types/PayConfig';
import { AccountPayConfig } from '@project/types/PayConfig';
import React from 'react';
export default function Account(props: {
config: AccountPayConfig;

View File

@ -1,5 +1,5 @@
import React from 'react';
import { OfflinePayConfig } from '../../../../types/PayConfig';
import { OfflinePayConfig } from '@project/types/PayConfig';
export default function Offline(props: {
config: OfflinePayConfig;
update: (config: Omit<OfflinePayConfig, 'channel'>) => void;

View File

@ -1,4 +1,4 @@
import { WechatPayConfig } from '../../../../types/PayConfig';
import { WechatPayConfig } from '@project/types/PayConfig';
import React from 'react';
export default function WechatPay(props: {
config: WechatPayConfig;

View File

@ -1,7 +1,7 @@
import React from 'react';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import { SysAccountOperType } from '../../../types/sysAccountOper';
import { SysAccountOperType } from '@project/types/sysAccountOper';
type SAOType = SysAccountOperType | 'all';
export default function Render(props: WebComponentProps<EntityDict, 'accountOper', true, {
sysAccountOpers?: Array<{

5
es/endpoints/wechatPay.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { Endpoint } from 'oak-domain/lib/types/Endpoint';
import { EntityDict } from '../oak-app-domain';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
export declare const payNotify: Endpoint<EntityDict, BackendRuntimeContext<EntityDict>>;
export declare const refundNotify: Endpoint<EntityDict, BackendRuntimeContext<EntityDict>>;

19
es/endpoints/wechatPay.js Normal file
View File

@ -0,0 +1,19 @@
import { payNotify as payNotifyFn, refundNotify as refundNotifyFn } from '../utils/pay';
export const payNotify = {
name: '微信支付回调',
method: 'post',
params: ['payId'],
fn: async (context, params, headers, req, body) => {
const { payId } = params;
return payNotifyFn(context, body, payId, headers);
},
};
export const refundNotify = {
name: '微信退款回调',
method: 'post',
params: ['refundId'],
fn: async (context, params, headers, req, body) => {
const { refundId } = params;
return refundNotifyFn(context, body, refundId, headers);
},
};

View File

@ -1,4 +1,4 @@
import { Boolean, Int, Decimal } from 'oak-domain/lib/types/DataType';
import { Price, Boolean, Int, Decimal } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { EntityDesc } from 'oak-domain/lib/types';
export interface Schema extends EntityShape {
@ -7,6 +7,7 @@ export interface Schema extends EntityShape {
refundCompensateRatio?: Int<4>;
allowWithdrawTransfer: Boolean;
withdrawTransferLossRatio?: Decimal<4, 2>;
price: Price;
}
export type Action = 'pay' | 'refund' | 'deposit' | 'withdraw' | 'tax';
export declare const entityDesc: EntityDesc<Schema, Action>;

View File

@ -8,7 +8,8 @@ export const entityDesc = {
refundGapDays: '(支付后)允许退款的天数',
refundCompensateRatio: '退款补偿百分比',
allowWithdrawTransfer: '允许提现转账',
withdrawTransferLossRatio: '提现转账费率(百分数)'
withdrawTransferLossRatio: '提现转账费率(百分数)',
price: '余额',
},
action: {
pay: '支付',

View File

@ -1,4 +1,4 @@
import { String, Text, Price, Boolean } from 'oak-domain/lib/types/DataType';
import { String, Text, Boolean } from 'oak-domain/lib/types/DataType';
import { EntityDesc } from 'oak-domain/lib/types';
import { Schema as System } from './System';
import { Schema as Pay } from './Pay';
@ -13,7 +13,6 @@ export interface Schema extends AbstractAccount {
allowDeposit: Boolean;
allowPay: Boolean;
system: System;
price: Price;
pays: Pay[];
opers: SysAccountOper[];
channels: WithdrawChannel[];

View File

@ -1,4 +1,4 @@
import { String, Text, Price, Boolean } from 'oak-domain/lib/types/DataType';
import { String, Text, Boolean } from 'oak-domain/lib/types/DataType';
import { EntityDesc } from 'oak-domain/lib/types';
import { Schema as WechatPay } from './WechatPay';
import { Schema as System } from './System';
@ -11,7 +11,6 @@ export interface Schema extends AbstractAccount {
publicKeyFilePath: Text;
privateKeyFilePath: Text;
apiV3Key: String<32>;
price: Price;
system: System;
opers: SysAccountOper[];
channels: WithdrawChannel[];

View File

@ -33,6 +33,10 @@ export const desc = {
precision: 4,
scale: 2
}
},
price: {
notNull: true,
type: "money"
}
},
actionType: "crud",

View File

@ -1,13 +1,14 @@
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
import { Decimal, Int, Boolean } from "oak-domain/lib/types/DataType";
import { Decimal, Int, Boolean, Price } from "oak-domain/lib/types/DataType";
export type OpSchema = EntityShape & {
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundCompensateRatio?: Int<4> | null;
allowWithdrawTransfer: Boolean;
withdrawTransferLossRatio?: Decimal<4, 2> | null;
price: Price;
} & {
[A in ExpressionKey]?: any;
};
@ -22,6 +23,7 @@ export type OpFilter = {
refundCompensateRatio: Q_NumberValue;
allowWithdrawTransfer: Q_BooleanValue;
withdrawTransferLossRatio: Q_NumberValue;
price: Q_NumberValue;
} & ExprOp<OpAttr | string>;
export type OpProjection = {
"#id"?: NodeId;
@ -35,6 +37,7 @@ export type OpProjection = {
refundCompensateRatio?: number;
allowWithdrawTransfer?: number;
withdrawTransferLossRatio?: number;
price?: number;
} & Partial<ExprOp<OpAttr | string>>;
export type OpSortAttr = Partial<{
id: number;
@ -46,6 +49,7 @@ export type OpSortAttr = Partial<{
refundCompensateRatio: number;
allowWithdrawTransfer: number;
withdrawTransferLossRatio: number;
price: number;
[k: string]: any;
} | ExprOp<OpAttr | string>>;
export type OpAction = OakMakeAction<Action | string>;

View File

@ -5,7 +5,8 @@
"refundGapDays": "(支付后)允许退款的天数",
"refundCompensateRatio": "退款补偿百分比",
"allowWithdrawTransfer": "允许提现转账",
"withdrawTransferLossRatio": "提现转账费率(百分数)"
"withdrawTransferLossRatio": "提现转账费率(百分数)",
"price": "余额"
},
"action": {
"pay": "支付",

View File

@ -40,7 +40,7 @@ export const desc = {
notNull: true,
type: "varchar",
params: {
length: 12
length: 32
}
},
domainId: {

View File

@ -85,7 +85,7 @@ export type OpSchema = EntityShape & {
style?: Style | null;
dangerousVersions: Versions;
warningVersions: Versions;
soaVersion: String<12>;
soaVersion: String<32>;
domainId?: ForeignKey<"domain"> | null;
} & {
[A in ExpressionKey]?: any;

View File

@ -34,6 +34,10 @@ export const desc = {
scale: 2
}
},
price: {
notNull: true,
type: "money"
},
type: {
notNull: true,
type: "enum",
@ -67,10 +71,6 @@ export const desc = {
type: "ref",
ref: "system"
},
price: {
notNull: true,
type: "money"
},
enabled: {
notNull: true,
type: "boolean"

View File

@ -2,13 +2,14 @@ import { ForeignKey } from "oak-domain/lib/types/DataType";
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
import { Decimal, Int, Boolean, String, Text, Price } from "oak-domain/lib/types/DataType";
import { Decimal, Int, Boolean, Price, String, Text } from "oak-domain/lib/types/DataType";
export type OpSchema = EntityShape & {
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundCompensateRatio?: Int<4> | null;
allowWithdrawTransfer: Boolean;
withdrawTransferLossRatio?: Decimal<4, 2> | null;
price: Price;
type: "bank" | "alipay" | "wechat" | "shouqianba" | "others";
channel?: String<32> | null;
name?: String<64> | null;
@ -16,7 +17,6 @@ export type OpSchema = EntityShape & {
allowDeposit: Boolean;
allowPay: Boolean;
systemId: ForeignKey<"system">;
price: Price;
enabled: Boolean;
} & {
[A in ExpressionKey]?: any;
@ -32,6 +32,7 @@ export type OpFilter = {
refundCompensateRatio: Q_NumberValue;
allowWithdrawTransfer: Q_BooleanValue;
withdrawTransferLossRatio: Q_NumberValue;
price: Q_NumberValue;
type: Q_EnumValue<"bank" | "alipay" | "wechat" | "shouqianba" | "others">;
channel: Q_StringValue;
name: Q_StringValue;
@ -39,7 +40,6 @@ export type OpFilter = {
allowDeposit: Q_BooleanValue;
allowPay: Q_BooleanValue;
systemId: Q_StringValue;
price: Q_NumberValue;
enabled: Q_BooleanValue;
} & ExprOp<OpAttr | string>;
export type OpProjection = {
@ -54,6 +54,7 @@ export type OpProjection = {
refundCompensateRatio?: number;
allowWithdrawTransfer?: number;
withdrawTransferLossRatio?: number;
price?: number;
type?: number;
channel?: number;
name?: number;
@ -61,7 +62,6 @@ export type OpProjection = {
allowDeposit?: number;
allowPay?: number;
systemId?: number;
price?: number;
enabled?: number;
} & Partial<ExprOp<OpAttr | string>>;
export type OpSortAttr = Partial<{
@ -74,13 +74,13 @@ export type OpSortAttr = Partial<{
refundCompensateRatio: number;
allowWithdrawTransfer: number;
withdrawTransferLossRatio: number;
price: number;
type: number;
channel: number;
name: number;
qrCode: number;
allowDeposit: number;
allowPay: number;
price: number;
enabled: number;
[k: string]: any;
} | ExprOp<OpAttr | string>>;

View File

@ -34,6 +34,10 @@ export const desc = {
scale: 2
}
},
price: {
notNull: true,
type: "money"
},
wechatPayId: {
notNull: true,
type: "ref",
@ -61,10 +65,6 @@ export const desc = {
length: 32
}
},
price: {
notNull: true,
type: "money"
},
systemId: {
notNull: true,
type: "ref",

View File

@ -2,19 +2,19 @@ import { ForeignKey } from "oak-domain/lib/types/DataType";
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
import { Decimal, Int, Boolean, String, Text, Price } from "oak-domain/lib/types/DataType";
import { Decimal, Int, Boolean, Price, String, Text } from "oak-domain/lib/types/DataType";
export type OpSchema = EntityShape & {
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundCompensateRatio?: Int<4> | null;
allowWithdrawTransfer: Boolean;
withdrawTransferLossRatio?: Decimal<4, 2> | null;
price: Price;
wechatPayId: ForeignKey<"wechatPay">;
mchId: String<128>;
publicKeyFilePath: Text;
privateKeyFilePath: Text;
apiV3Key: String<32>;
price: Price;
systemId: ForeignKey<"system">;
enabled: Boolean;
} & {
@ -31,12 +31,12 @@ export type OpFilter = {
refundCompensateRatio: Q_NumberValue;
allowWithdrawTransfer: Q_BooleanValue;
withdrawTransferLossRatio: Q_NumberValue;
price: Q_NumberValue;
wechatPayId: Q_StringValue;
mchId: Q_StringValue;
publicKeyFilePath: Q_StringValue;
privateKeyFilePath: Q_StringValue;
apiV3Key: Q_StringValue;
price: Q_NumberValue;
systemId: Q_StringValue;
enabled: Q_BooleanValue;
} & ExprOp<OpAttr | string>;
@ -52,12 +52,12 @@ export type OpProjection = {
refundCompensateRatio?: number;
allowWithdrawTransfer?: number;
withdrawTransferLossRatio?: number;
price?: number;
wechatPayId?: number;
mchId?: number;
publicKeyFilePath?: number;
privateKeyFilePath?: number;
apiV3Key?: number;
price?: number;
systemId?: number;
enabled?: number;
} & Partial<ExprOp<OpAttr | string>>;
@ -71,11 +71,11 @@ export type OpSortAttr = Partial<{
refundCompensateRatio: number;
allowWithdrawTransfer: number;
withdrawTransferLossRatio: number;
price: number;
mchId: number;
publicKeyFilePath: number;
privateKeyFilePath: number;
apiV3Key: number;
price: number;
enabled: number;
[k: string]: any;
} | ExprOp<OpAttr | string>>;

2
es/ports/index.d.ts vendored
View File

@ -1,5 +1,5 @@
import { Importation, Exportation } from "oak-domain/lib/types/Port";
import { EntityDict } from "../oak-app-domain/index";
import { EntityDict } from "@oak-app-domain";
import { BRC } from '../types/RuntimeCxt';
export declare const importations: Importation<EntityDict, keyof EntityDict, any, BRC>[];
export declare const exportations: Exportation<EntityDict, keyof EntityDict, any, BRC>[];

View File

@ -1,5 +1,5 @@
import { Routine } from 'oak-domain/lib/types/Timer';
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const startRoutines: Array<Routine<EntityDict, keyof EntityDict, BRC>>;
export default startRoutines;

View File

@ -1,5 +1,5 @@
import { Timer } from 'oak-domain/lib/types/Timer';
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const timers: Array<Timer<EntityDict, keyof EntityDict, BRC>>;
export default timers;

View File

@ -1,4 +1,4 @@
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { Trigger } from 'oak-domain/lib/types';
import { BRC } from '../types/RuntimeCxt';
declare const triggers: Trigger<EntityDict, keyof EntityDict, BRC>[];

View File

@ -1,5 +1,5 @@
import { OakException, OpRecord } from 'oak-domain/lib/types';
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
export declare class ExternalPayUtilException<ED extends EntityDict> extends OakException<ED> {
reason: any;
constructor(reason: any, message?: string, _module?: string, params?: Record<string, any>);

View File

@ -1,5 +1,5 @@
import { Watcher } from 'oak-domain/lib/types';
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const watchers: Watcher<EntityDict, keyof EntityDict, BRC>[];
export default watchers;

View File

@ -1,4 +1,4 @@
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { Checker } from 'oak-domain/lib/types';
import { RuntimeCxt } from '../types/RuntimeCxt';
declare const checkers: Checker<EntityDict, keyof EntityDict, RuntimeCxt>[];

View File

@ -0,0 +1,4 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "offlineAccount", true, {
systemId: string;
}>) => React.ReactElement;
export default _default;

View File

@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
entity: 'offlineAccount',
isList: true,
projection: {
id: 1,
type: 1,
channel: 1,
name: 1,
qrCode: 1,
allowDeposit: 1,
allowPay: 1,
systemId: 1,
price: 1,
enabled: 1,
taxLossRatio: 1,
refundCompensateRatio: 1,
refundGapDays: 1,
allowWithdrawTransfer: 1,
withdrawTransferLossRatio: 1,
},
properties: {
systemId: '',
},
filters: [
{
filter() {
const { systemId } = this.props;
return {
systemId,
};
}
}
],
formData({ data, legalActions }) {
return {
accounts: data.map((ele) => {
const { type } = ele;
const color = this.features.style.getColor('offlineAccount', 'type', type);
return {
color,
...ele,
};
}),
canCreate: legalActions?.includes('create'),
oakExecutable: this.tryExecute(),
};
},
actions: ['create', 'update', 'remove'],
});

12
lib/components/pay/detail/index.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import { EntityDict } from "../../../oak-app-domain";
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { StartPayRoutine, JudgeCanPay } from "../../../types/Pay";
export declare function registerFrontendPayRoutine<ED extends EntityDict & BaseEntityDict>(entity: keyof ED, routine: StartPayRoutine, projection: ED['pay']['Projection'], judgeCanPay: JudgeCanPay): void;
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "pay", false, {
onClose: () => void;
onPaid: () => void;
onPayFailure: () => void;
disableAutoPay: boolean;
closeWhenFailure: boolean;
}>) => React.ReactElement;
export default _default;

View File

@ -0,0 +1,327 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerFrontendPayRoutine = void 0;
const tslib_1 = require("tslib");
const money_1 = require("oak-domain/lib/utils/money");
const constants_1 = require("../../../config/constants");
const assert_1 = tslib_1.__importDefault(require("assert"));
const utils_1 = require("oak-frontend-base/es/utils/utils");
const lodash_1 = require("oak-domain/lib/utils/lodash");
const wpProductFrontend_1 = require("../../../utils/wpProductFrontend");
const uuid_1 = require("oak-domain/lib/utils/uuid");
const Exception_1 = require("../../../types/Exception");
const PayRoutineDict = {
wpProduct: {
projection: {
wpProduct: {
id: 1,
type: 1,
},
},
routine: async (pay, features) => {
const { iState, wpProduct, meta } = pay;
switch (wpProduct.type) {
case 'mp': {
if (process.env.OAK_PLATFORM === 'wechatMp') {
const { prepayMeta } = meta;
if (prepayMeta) {
try {
const result = await wx.requestPayment(prepayMeta);
process.env.NODE_ENV === 'development' && console.log(result);
}
catch (err) {
throw new Exception_1.StartPayFailure(err.errMsg.includes('cancel')
? features.locales.t('startPayError.userCancel')
: features.locales.t('startPayError.unknown'));
}
}
else {
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.illegalPrepayData'));
}
}
else {
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.falseEnv', { env: 'wechatMp' }));
}
return;
}
case 'jsapi': {
if (process.env.OAK_PLATFORM === 'web' && utils_1.isWeiXin) {
const { prepayMeta } = meta;
if (prepayMeta) {
const { timeStamp, ...rest } = prepayMeta;
// chooseWXPay文档都找不到了网上查出来这里timestamp的s要小写吐血了
await features.wechatSdk.loadWxAPi('chooseWXPay', {
timestamp: timeStamp,
...rest,
});
}
else {
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.illegalPrepayData'));
}
}
}
default: {
(0, assert_1.default)('尚未实现');
}
}
},
judgeCanPay: wpProductFrontend_1.canStartPay,
}
};
function registerFrontendPayRoutine(entity, routine, projection, judgeCanPay) {
PayRoutineDict[entity] = {
routine,
projection,
judgeCanPay,
};
}
exports.registerFrontendPayRoutine = registerFrontendPayRoutine;
exports.default = OakComponent({
entity: 'pay',
isList: false,
projection: () => {
const baseProjection = {
id: 1,
applicationId: 1,
price: 1,
meta: 1,
iState: 1,
paid: 1,
refunded: 1,
timeoutAt: 1,
forbidRefundAt: 1,
externalId: 1,
orderId: 1,
depositId: 1,
deposit: {
id: 1,
accountId: 1,
price: 1,
loss: 1,
},
order: {
id: 1,
creatorId: 1,
},
entity: 1,
entityId: 1,
creatorId: 1,
phantom3: 1,
};
for (const k in PayRoutineDict) {
(0, lodash_1.merge)(baseProjection, PayRoutineDict[k].projection);
}
return baseProjection;
},
properties: {
onClose: () => undefined,
onPaid: () => undefined,
onPayFailure: () => undefined,
disableAutoPay: false,
closeWhenFailure: false,
},
data: {
showCloseConfirmMp: false,
showChannelSelectMp: false,
unsub: undefined,
},
formData({ data }) {
const application = this.features.application.getApplication();
const iState = data?.iState;
const iStateColor = iState && this.features.style.getColor('pay', 'iState', iState);
const startPayable = iState === 'paying' && !['account', 'offlineAccount'].includes(data.entity) && (PayRoutineDict[data.entity] && PayRoutineDict[data.entity].judgeCanPay(data, this.features));
const payChannels = this.features.pay.getPayChannels();
const offlines = this.features.cache.get('offlineAccount', {
data: {
id: 1,
type: 1,
channel: 1,
name: 1,
qrCode: 1,
},
filter: {
systemId: this.features.application.getApplication().systemId,
}
}).map(ele => {
const color = this.features.style.getColor('offlineAccount', 'type', ele.type);
return {
color,
...ele,
};
});
const offline = offlines?.find(ele => ele.id === data.entityId);
return {
type: data?.orderId ? 'order' : 'deposit',
pay: data,
application,
iStateColor,
closable: !!(data?.["#oakLegalActions"]?.includes('close')),
startPayable,
offline,
offlines,
notSameApp: data && data.applicationId !== application.id && data.entity !== 'offlineAccount',
priceStr: data?.price && (0, money_1.CentToString)(data.price, 2),
oakExecutable: this.tryExecute(),
};
},
features: [{
feature: 'application',
callback() {
this.refreshOfflineAccounts();
}
}],
actions: ['close', 'startPaying', {
action: 'update',
attrs: ['entityId'],
}],
methods: {
refreshOfflineAccounts() {
const { entity } = this.state.pay || {};
if (entity === 'offlineAccount') {
this.features.cache.refresh('offlineAccount', {
data: {
id: 1,
channel: 1,
name: 1,
type: 1,
qrCode: 1,
},
filter: {
systemId: this.features.application.getApplication().systemId,
}
});
}
},
executeMp() {
return this.execute();
},
resetMp() {
return this.clean();
},
closeMp() {
this.setState({
showCloseConfirmMp: true,
});
},
cancelCloseMp() {
this.setState({
showCloseConfirmMp: false,
});
},
async confirmCloseMp() {
await this.execute('close');
this.cancelCloseMp();
const { onClose } = this.props;
onClose && onClose();
},
goBack() {
this.navigateBack();
},
async startPay() {
const { onPaid, onClose, onPayFailure } = this.props;
const { pay } = this.state;
try {
await PayRoutineDict[pay.entity].routine(pay, this.features);
onPaid && onPaid();
}
catch (err) {
if (this.props.closeWhenFailure) {
await this.execute(undefined, undefined, undefined, [
{
entity: 'pay',
operation: {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'close',
data: {},
filter: {
id: this.props.oakId,
},
},
}
]);
onClose && onClose();
}
else {
onPayFailure && onPayFailure();
}
this.features.message.setMessage({
type: 'warning',
content: err.message,
});
}
},
openChannelSelectMp() {
this.setState({
showChannelSelectMp: true,
});
},
closeChannelSelectMp() {
this.setState({
showChannelSelectMp: false,
});
},
async updateOfflineIdMp(touch) {
const { detail } = touch;
const { currentKey } = detail;
const { oakId } = this.props;
if (currentKey) {
await this.execute(undefined, undefined, undefined, [
{
entity: 'pay',
operation: {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'update',
data: {
entity: 'offlineAccount',
entityId: currentKey,
},
filter: {
id: oakId,
},
}
}
]);
this.setState({
showChannelSelectMp: false,
});
}
},
updateExternalIdMp(input) {
const { detail } = input;
this.update({
externalId: detail.value,
});
},
clearExternalIdMp() {
this.update({
externalId: null,
});
}
},
lifetimes: {
async ready() {
const { oakId } = this.props;
(0, assert_1.default)(typeof oakId === 'string');
const unsub = await this.subDataEvents([`${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
this.setState({
unsub,
});
},
detached() {
const { unsub } = this.state;
unsub && unsub();
}
},
listeners: {
startPayable(prev, next) {
if (next.startPayable && !this.props.disableAutoPay) {
this.startPay();
}
},
pay(prev, next) {
if (!prev.pay && next.pay) {
this.refreshOfflineAccounts();
}
}
},
});

View File

@ -0,0 +1,15 @@
import React from 'react';
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict } from '../../../oak-app-domain';
export declare function registerPayChannelComponent<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, component: (option: {
oakPath: string;
systemId: string;
}) => React.ReactElement): void;
export default function render(props: WebComponentProps<EntityDict, 'system', false, {
system: RowWithActions<EntityDict, 'system'>;
operation?: EntityDict['system']['Update'];
serverUrl?: string;
canUpdate?: boolean;
oakExecutable: boolean;
}>): import("react/jsx-runtime").JSX.Element | null;

View File

@ -0,0 +1,122 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerPayChannelComponent = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const antd_1 = require("antd");
const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less"));
const config_1 = tslib_1.__importDefault(require("../../offlineAccount/config"));
const config_2 = tslib_1.__importDefault(require("../../wpAccount/config"));
const PayChannelConfigDict = {
'wpAccount': config_2.default,
};
function registerPayChannelComponent(entity, component) {
PayChannelConfigDict[entity] = component;
}
exports.registerPayChannelComponent = registerPayChannelComponent;
function PayConfig(props) {
const { payConfig, update, t } = props;
const withdrawLoss = payConfig?.withdrawLoss;
const depositLoss = payConfig?.depositLoss;
const updateDepositLoss = (data) => {
update && update({
depositLoss: {
...depositLoss,
...data,
},
withdrawLoss: withdrawLoss || {
conservative: false,
},
});
};
const updateWithdrawLoss = (data) => {
update && update({
depositLoss: depositLoss || {},
withdrawLoss: {
conservative: !!(withdrawLoss?.conservative),
...withdrawLoss,
...data,
},
});
};
return ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", children: [(0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.depositLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t("payConfig.help.depositLoss"), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, disabled: !update, onChange: (value) => {
const ratio = value;
updateDepositLoss({
ratio: ratio || 0
});
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.highest, min: 0, step: 1, disabled: !update, onChange: (value) => {
const highest = value;
updateDepositLoss({
highest: highest || undefined
});
return;
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.lowest, min: 0, step: 1, disabled: !update, onChange: (value) => {
const lowest = value;
updateDepositLoss({
lowest: lowest || undefined
});
return;
} }) })] }) }), (0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.withdrawLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t('payConfig.help.withdrawLoss'), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.conservative'), children: (0, jsx_runtime_1.jsx)(antd_1.Switch, { disabled: !update, value: withdrawLoss?.conservative, onChange: (conservative) => {
updateWithdrawLoss({ conservative });
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, onChange: (value) => {
const ratio = value;
updateWithdrawLoss({
ratio: ratio || 0
});
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.highest, min: 0, step: 1, onChange: (value) => {
const highest = value;
updateWithdrawLoss({
highest: highest || undefined
});
return;
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.lowest, min: 0, step: 1, onChange: (value) => {
const lowest = value;
updateWithdrawLoss({
lowest: lowest || undefined
});
return;
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.trim'), children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { disabled: !!withdrawLoss?.conservative || !update, options: [
{
label: t('payConfig.label.jiao'),
value: 'jiao',
},
{
label: t('payConfig.label.yuan'),
value: 'yuan',
},
{
label: t('payConfig.label.null'),
value: '',
}
], value: withdrawLoss?.trim, onChange: ({ target }) => updateWithdrawLoss({
trim: target.value,
}) }) })] }) })] }));
}
function render(props) {
const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable, canUpdate } = props.data;
const { t, update, clean, execute } = props.methods;
if (system && oakFullpath) {
return ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.container, children: (0, jsx_runtime_1.jsx)(antd_1.Tabs, { className: web_pc_module_less_1.default.tabs, tabPosition: "left", items: [
{
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t('system') })),
key: 'system',
children: ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { vertical: true, children: [(0, jsx_runtime_1.jsx)(PayConfig, { payConfig: system.payConfig, update: canUpdate ? (payConfig) => update({ payConfig }) : undefined, t: t }), (0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", justify: 'end', children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", disabled: oakExecutable !== true, onClick: () => execute(), children: t('common::confirm') }), (0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !oakDirty, onClick: () => clean(), children: t('common::reset') })] })] })),
},
{
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t('offlineAccount:name') })),
key: 'offlineAccount',
children: ((0, jsx_runtime_1.jsx)(config_1.default, { oakPath: `${oakFullpath}.offlineAccount$system`, systemId: system.id })),
},
...Object.keys(PayChannelConfigDict).map((ele) => {
const C = PayChannelConfigDict[ele];
return {
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t(`${ele}:name`) })),
key: ele,
children: (0, jsx_runtime_1.jsx)(C, { oakPath: `${oakFullpath}.${ele}$system`, systemId: system.id })
};
})
] }) }));
}
return null;
}
exports.default = render;

View File

@ -0,0 +1,4 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "wpAccount", true, {
systemId: string;
}>) => React.ReactElement;
export default _default;

View File

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
entity: 'wpAccount',
isList: true,
projection: {
id: 1,
price: 1,
mchId: 1,
enabled: 1,
taxLossRatio: 1,
refundCompensateRatio: 1,
refundGapDays: 1,
allowWithdrawTransfer: 1,
withdrawTransferLossRatio: 1,
},
properties: {
systemId: '',
},
filters: [
{
filter() {
const { systemId } = this.props;
return {
systemId,
};
}
}
],
formData({ data, legalActions }) {
return {
accounts: data,
canCreate: legalActions?.includes('create') && !data?.find(ele => ele.enabled),
oakExecutable: this.tryExecute(),
};
},
actions: ['create', 'update', 'remove'],
});

5
lib/endpoints/wechatPay.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { Endpoint } from 'oak-domain/lib/types/Endpoint';
import { EntityDict } from '../oak-app-domain';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
export declare const payNotify: Endpoint<EntityDict, BackendRuntimeContext<EntityDict>>;
export declare const refundNotify: Endpoint<EntityDict, BackendRuntimeContext<EntityDict>>;

View File

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.refundNotify = exports.payNotify = void 0;
const pay_1 = require("../utils/pay");
exports.payNotify = {
name: '微信支付回调',
method: 'post',
params: ['payId'],
fn: async (context, params, headers, req, body) => {
const { payId } = params;
return (0, pay_1.payNotify)(context, body, payId, headers);
},
};
exports.refundNotify = {
name: '微信退款回调',
method: 'post',
params: ['refundId'],
fn: async (context, params, headers, req, body) => {
const { refundId } = params;
return (0, pay_1.refundNotify)(context, body, refundId, headers);
},
};

View File

@ -1,4 +1,4 @@
import { Boolean, Int, Decimal } from 'oak-domain/lib/types/DataType';
import { Price, Boolean, Int, Decimal } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { EntityDesc } from 'oak-domain/lib/types';
export interface Schema extends EntityShape {
@ -7,6 +7,7 @@ export interface Schema extends EntityShape {
refundCompensateRatio?: Int<4>;
allowWithdrawTransfer: Boolean;
withdrawTransferLossRatio?: Decimal<4, 2>;
price: Price;
}
export type Action = 'pay' | 'refund' | 'deposit' | 'withdraw' | 'tax';
export declare const entityDesc: EntityDesc<Schema, Action>;

View File

@ -11,7 +11,8 @@ exports.entityDesc = {
refundGapDays: '(支付后)允许退款的天数',
refundCompensateRatio: '退款补偿百分比',
allowWithdrawTransfer: '允许提现转账',
withdrawTransferLossRatio: '提现转账费率(百分数)'
withdrawTransferLossRatio: '提现转账费率(百分数)',
price: '余额',
},
action: {
pay: '支付',

View File

@ -1,4 +1,4 @@
import { String, Text, Price, Boolean } from 'oak-domain/lib/types/DataType';
import { String, Text, Boolean } from 'oak-domain/lib/types/DataType';
import { EntityDesc } from 'oak-domain/lib/types';
import { Schema as System } from './System';
import { Schema as Pay } from './Pay';
@ -13,7 +13,6 @@ export interface Schema extends AbstractAccount {
allowDeposit: Boolean;
allowPay: Boolean;
system: System;
price: Price;
pays: Pay[];
opers: SysAccountOper[];
channels: WithdrawChannel[];

View File

@ -1,4 +1,4 @@
import { String, Text, Price, Boolean } from 'oak-domain/lib/types/DataType';
import { String, Text, Boolean } from 'oak-domain/lib/types/DataType';
import { EntityDesc } from 'oak-domain/lib/types';
import { Schema as WechatPay } from './WechatPay';
import { Schema as System } from './System';
@ -11,7 +11,6 @@ export interface Schema extends AbstractAccount {
publicKeyFilePath: Text;
privateKeyFilePath: Text;
apiV3Key: String<32>;
price: Price;
system: System;
opers: SysAccountOper[];
channels: WithdrawChannel[];

View File

@ -36,6 +36,10 @@ exports.desc = {
precision: 4,
scale: 2
}
},
price: {
notNull: true,
type: "money"
}
},
actionType: "crud",

View File

@ -1,13 +1,14 @@
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
import { Decimal, Int, Boolean } from "oak-domain/lib/types/DataType";
import { Decimal, Int, Boolean, Price } from "oak-domain/lib/types/DataType";
export type OpSchema = EntityShape & {
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundCompensateRatio?: Int<4> | null;
allowWithdrawTransfer: Boolean;
withdrawTransferLossRatio?: Decimal<4, 2> | null;
price: Price;
} & {
[A in ExpressionKey]?: any;
};
@ -22,6 +23,7 @@ export type OpFilter = {
refundCompensateRatio: Q_NumberValue;
allowWithdrawTransfer: Q_BooleanValue;
withdrawTransferLossRatio: Q_NumberValue;
price: Q_NumberValue;
} & ExprOp<OpAttr | string>;
export type OpProjection = {
"#id"?: NodeId;
@ -35,6 +37,7 @@ export type OpProjection = {
refundCompensateRatio?: number;
allowWithdrawTransfer?: number;
withdrawTransferLossRatio?: number;
price?: number;
} & Partial<ExprOp<OpAttr | string>>;
export type OpSortAttr = Partial<{
id: number;
@ -46,6 +49,7 @@ export type OpSortAttr = Partial<{
refundCompensateRatio: number;
allowWithdrawTransfer: number;
withdrawTransferLossRatio: number;
price: number;
[k: string]: any;
} | ExprOp<OpAttr | string>>;
export type OpAction = OakMakeAction<Action | string>;

View File

@ -5,7 +5,8 @@
"refundGapDays": "(支付后)允许退款的天数",
"refundCompensateRatio": "退款补偿百分比",
"allowWithdrawTransfer": "允许提现转账",
"withdrawTransferLossRatio": "提现转账费率(百分数)"
"withdrawTransferLossRatio": "提现转账费率(百分数)",
"price": "余额"
},
"action": {
"pay": "支付",

View File

@ -43,7 +43,7 @@ exports.desc = {
notNull: true,
type: "varchar",
params: {
length: 12
length: 32
}
},
domainId: {

View File

@ -85,7 +85,7 @@ export type OpSchema = EntityShape & {
style?: Style | null;
dangerousVersions: Versions;
warningVersions: Versions;
soaVersion: String<12>;
soaVersion: String<32>;
domainId?: ForeignKey<"domain"> | null;
} & {
[A in ExpressionKey]?: any;

View File

@ -37,6 +37,10 @@ exports.desc = {
scale: 2
}
},
price: {
notNull: true,
type: "money"
},
type: {
notNull: true,
type: "enum",
@ -70,10 +74,6 @@ exports.desc = {
type: "ref",
ref: "system"
},
price: {
notNull: true,
type: "money"
},
enabled: {
notNull: true,
type: "boolean"

View File

@ -2,13 +2,14 @@ import { ForeignKey } from "oak-domain/lib/types/DataType";
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
import { Decimal, Int, Boolean, String, Text, Price } from "oak-domain/lib/types/DataType";
import { Decimal, Int, Boolean, Price, String, Text } from "oak-domain/lib/types/DataType";
export type OpSchema = EntityShape & {
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundCompensateRatio?: Int<4> | null;
allowWithdrawTransfer: Boolean;
withdrawTransferLossRatio?: Decimal<4, 2> | null;
price: Price;
type: "bank" | "alipay" | "wechat" | "shouqianba" | "others";
channel?: String<32> | null;
name?: String<64> | null;
@ -16,7 +17,6 @@ export type OpSchema = EntityShape & {
allowDeposit: Boolean;
allowPay: Boolean;
systemId: ForeignKey<"system">;
price: Price;
enabled: Boolean;
} & {
[A in ExpressionKey]?: any;
@ -32,6 +32,7 @@ export type OpFilter = {
refundCompensateRatio: Q_NumberValue;
allowWithdrawTransfer: Q_BooleanValue;
withdrawTransferLossRatio: Q_NumberValue;
price: Q_NumberValue;
type: Q_EnumValue<"bank" | "alipay" | "wechat" | "shouqianba" | "others">;
channel: Q_StringValue;
name: Q_StringValue;
@ -39,7 +40,6 @@ export type OpFilter = {
allowDeposit: Q_BooleanValue;
allowPay: Q_BooleanValue;
systemId: Q_StringValue;
price: Q_NumberValue;
enabled: Q_BooleanValue;
} & ExprOp<OpAttr | string>;
export type OpProjection = {
@ -54,6 +54,7 @@ export type OpProjection = {
refundCompensateRatio?: number;
allowWithdrawTransfer?: number;
withdrawTransferLossRatio?: number;
price?: number;
type?: number;
channel?: number;
name?: number;
@ -61,7 +62,6 @@ export type OpProjection = {
allowDeposit?: number;
allowPay?: number;
systemId?: number;
price?: number;
enabled?: number;
} & Partial<ExprOp<OpAttr | string>>;
export type OpSortAttr = Partial<{
@ -74,13 +74,13 @@ export type OpSortAttr = Partial<{
refundCompensateRatio: number;
allowWithdrawTransfer: number;
withdrawTransferLossRatio: number;
price: number;
type: number;
channel: number;
name: number;
qrCode: number;
allowDeposit: number;
allowPay: number;
price: number;
enabled: number;
[k: string]: any;
} | ExprOp<OpAttr | string>>;

View File

@ -37,6 +37,10 @@ exports.desc = {
scale: 2
}
},
price: {
notNull: true,
type: "money"
},
wechatPayId: {
notNull: true,
type: "ref",
@ -64,10 +68,6 @@ exports.desc = {
length: 32
}
},
price: {
notNull: true,
type: "money"
},
systemId: {
notNull: true,
type: "ref",

View File

@ -2,19 +2,19 @@ import { ForeignKey } from "oak-domain/lib/types/DataType";
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
import { Decimal, Int, Boolean, String, Text, Price } from "oak-domain/lib/types/DataType";
import { Decimal, Int, Boolean, Price, String, Text } from "oak-domain/lib/types/DataType";
export type OpSchema = EntityShape & {
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundCompensateRatio?: Int<4> | null;
allowWithdrawTransfer: Boolean;
withdrawTransferLossRatio?: Decimal<4, 2> | null;
price: Price;
wechatPayId: ForeignKey<"wechatPay">;
mchId: String<128>;
publicKeyFilePath: Text;
privateKeyFilePath: Text;
apiV3Key: String<32>;
price: Price;
systemId: ForeignKey<"system">;
enabled: Boolean;
} & {
@ -31,12 +31,12 @@ export type OpFilter = {
refundCompensateRatio: Q_NumberValue;
allowWithdrawTransfer: Q_BooleanValue;
withdrawTransferLossRatio: Q_NumberValue;
price: Q_NumberValue;
wechatPayId: Q_StringValue;
mchId: Q_StringValue;
publicKeyFilePath: Q_StringValue;
privateKeyFilePath: Q_StringValue;
apiV3Key: Q_StringValue;
price: Q_NumberValue;
systemId: Q_StringValue;
enabled: Q_BooleanValue;
} & ExprOp<OpAttr | string>;
@ -52,12 +52,12 @@ export type OpProjection = {
refundCompensateRatio?: number;
allowWithdrawTransfer?: number;
withdrawTransferLossRatio?: number;
price?: number;
wechatPayId?: number;
mchId?: number;
publicKeyFilePath?: number;
privateKeyFilePath?: number;
apiV3Key?: number;
price?: number;
systemId?: number;
enabled?: number;
} & Partial<ExprOp<OpAttr | string>>;
@ -71,11 +71,11 @@ export type OpSortAttr = Partial<{
refundCompensateRatio: number;
allowWithdrawTransfer: number;
withdrawTransferLossRatio: number;
price: number;
mchId: number;
publicKeyFilePath: number;
privateKeyFilePath: number;
apiV3Key: number;
price: number;
enabled: number;
[k: string]: any;
} | ExprOp<OpAttr | string>>;

View File

@ -1,5 +1,5 @@
import { Importation, Exportation } from "oak-domain/lib/types/Port";
import { EntityDict } from "../oak-app-domain/index";
import { EntityDict } from "@oak-app-domain";
import { BRC } from '../types/RuntimeCxt';
export declare const importations: Importation<EntityDict, keyof EntityDict, any, BRC>[];
export declare const exportations: Exportation<EntityDict, keyof EntityDict, any, BRC>[];

View File

@ -1,5 +1,5 @@
import { Routine } from 'oak-domain/lib/types/Timer';
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const startRoutines: Array<Routine<EntityDict, keyof EntityDict, BRC>>;
export default startRoutines;

View File

@ -1,5 +1,5 @@
import { Timer } from 'oak-domain/lib/types/Timer';
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const timers: Array<Timer<EntityDict, keyof EntityDict, BRC>>;
export default timers;

View File

@ -1,4 +1,4 @@
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { Trigger } from 'oak-domain/lib/types';
import { BRC } from '../types/RuntimeCxt';
declare const triggers: Trigger<EntityDict, keyof EntityDict, BRC>[];

View File

@ -5,7 +5,7 @@ const uuid_1 = require("oak-domain/lib/utils/uuid");
const payClazz_1 = require("../utils/payClazz");
const assert_1 = tslib_1.__importDefault(require("assert"));
const withdraw_1 = require("./withdraw");
const Exception_1 = require("../types/Exception");
const Exception_1 = require("@project/types/Exception");
/**
* 开始退款的逻辑
* @param context

View File

@ -1,5 +1,5 @@
import { OakException, OpRecord } from 'oak-domain/lib/types';
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
export declare class ExternalPayUtilException<ED extends EntityDict> extends OakException<ED> {
reason: any;
constructor(reason: any, message?: string, _module?: string, params?: Record<string, any>);

View File

@ -1,5 +1,5 @@
import { Watcher } from 'oak-domain/lib/types';
import { EntityDict } from '../oak-app-domain/index';
import { EntityDict } from '@oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const watchers: Watcher<EntityDict, keyof EntityDict, BRC>[];
export default watchers;

View File

@ -0,0 +1,27 @@
import { Endpoint } from 'oak-domain/lib/types/Endpoint';
import { EntityDict } from '../oak-app-domain';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { assert } from 'oak-domain/lib/utils/assert';
import { payNotify as payNotifyFn, refundNotify as refundNotifyFn } from '../utils/pay';
export const payNotify: Endpoint<EntityDict, BackendRuntimeContext<EntityDict>> = {
name: '微信支付回调',
method: 'post',
params: ['payId'],
fn: async (context, params, headers, req, body) => {
const { payId } = params;
return payNotifyFn<EntityDict>(context, body, payId, headers);
},
};
export const refundNotify: Endpoint<EntityDict, BackendRuntimeContext<EntityDict>> = {
name: '微信退款回调',
method: 'post',
params: ['refundId'],
fn: async (context, params, headers, req, body) => {
const { refundId } = params;
return refundNotifyFn<EntityDict>(context, body, refundId, headers);
},
};

View File

@ -16,6 +16,7 @@ export interface Schema extends EntityShape {
refundCompensateRatio?: Int<4>; // 退款时渠道返回的tax的比例0~100占原先taxlossRatio的百分比
allowWithdrawTransfer: Boolean; // 渠道是否允许提现
withdrawTransferLossRatio?: Decimal<4, 2>; // 渠道提现的费率,百分数
price: Price; // 渠道帐户中的余额
};
@ -30,7 +31,8 @@ export const entityDesc: EntityDesc<Schema, Action> = {
refundGapDays: '(支付后)允许退款的天数',
refundCompensateRatio: '退款补偿百分比',
allowWithdrawTransfer: '允许提现转账',
withdrawTransferLossRatio: '提现转账费率(百分数)'
withdrawTransferLossRatio: '提现转账费率(百分数)',
price: '余额',
},
action: {
pay: '支付',

View File

@ -23,7 +23,6 @@ export interface Schema extends AbstractAccount {
allowDeposit: Boolean;
allowPay: Boolean;
system: System;
price: Price;
pays: Pay[];
opers: SysAccountOper[];
channels: WithdrawChannel[];

View File

@ -21,7 +21,6 @@ export interface Schema extends AbstractAccount {
publicKeyFilePath: Text;
privateKeyFilePath: Text;
apiV3Key: String<32>;
price: Price;
system: System;
opers: SysAccountOper[];
channels: WithdrawChannel[];

View File

@ -1,7 +1,7 @@
import { registerPayClazzEntity } from './utils/payClazz';
import { registerPayChannelComponent } from './components/payConfig/system/web.pc';
import { registerFrontendPayRoutine } from './components/pay/detail/index';
import { registerApplicationProjection } from './utils/application';
export { registerPayClazzEntity } from './utils/payClazz';
export { registerPayChannelComponent } from './components/payConfig/system/web.pc';
export { registerFrontendPayRoutine } from './components/pay/detail/index';
export { registerApplicationProjection } from './utils/application';
import { EntityDict } from './oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';