编译的一些问题

This commit is contained in:
Xu Chang 2024-06-07 14:57:01 +08:00
parent d99b94d214
commit adaf42bce6
61 changed files with 454 additions and 443 deletions

View File

@ -1,4 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const checkers = [];
const checkers = [
{
entity: 'account',
type: 'row',
filter: {
system: {
account$entity: {
"#sqp": 'not in',
},
},
},
action: 'create',
}
];
exports.default = checkers;

View File

@ -84,6 +84,12 @@ const checkers = [
}
break;
}
case 'tax': {
if (totalPlus >= 0 || availPlus >= 0 || totalPlus !== availPlus) {
throw new types_1.OakInputIllegalException('accountOper', ['totalPlus', 'availPlus'], 'accountOper为tax时其totalPlus/availPlus必须为负且相等');
}
break;
}
default: {
(0, assert_1.default)(false);
break;

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

@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.registerPayChannelComponent = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
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"));
@ -15,12 +14,94 @@ 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({
depositLoss: {
...depositLoss,
...data,
},
withdrawLoss: withdrawLoss || {
conservative: !!(withdrawLoss?.conservative),
},
});
};
const updateWithdrawLoss = (data) => {
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, 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, 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, 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, { 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, 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, 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, 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, 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 } = props.data;
const { t, update, setMessage, execute } = props.methods;
const [key, setKey] = (0, react_1.useState)('');
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: (payConfig) => update({ payConfig }), 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',

View File

@ -8,9 +8,7 @@ exports.default = OakComponent({
price: 1,
mchId: 1,
refundGapDays: 1,
refundLossRatio: 1,
refundLossFloor: 1,
taxlossRatio: 1,
taxLossRatio: 1,
enabled: 1,
},
formData({ data, legalActions }) {

View File

@ -110,12 +110,18 @@ const attrUpdateMatrix = {
enabled: {
actions: ['update'],
},
taxlossRatio: {
taxLossRatio: {
actions: ['update'],
},
depositLossRatio: {
actions: ['update'],
},
refundCompensateRatio: {
actions: ['update'],
},
refundGapDays: {
actions: ['update'],
},
price: {
actions: ['pay', 'refund', 'deposit', 'withdraw', 'tax'],
},
@ -136,7 +142,7 @@ const attrUpdateMatrix = {
wechatPay: {
actions: ['update'],
},
taxlossRatio: {
taxLossRatio: {
actions: ['update'],
},
depositLossRatio: {

View File

@ -117,8 +117,9 @@ const i18ns = [
"shouqianba": "请将二维码解析后的字符串填入",
"others": "请将二维码解析后的字符串填入"
},
"taxlossRatio": "渠道收款时收取的手续费百分比0.6代表千分之六",
"depositLossRatio": "充值时收取的手续费百分比0.6代表千分之六"
"taxLossRatio": "渠道收款时收取的手续费百分比0.6代表千分之六",
"refundGapDays": "超过这个天数后将无法退款",
"refundCompensateRatio": "渠道退款时返回的手续费比例50代表渠道将返回当时收取的手续费的一半"
},
"help": {
"allowDeposit": "是否允许用户在系统中主动向此账号发起充值",
@ -231,9 +232,26 @@ const i18ns = [
module: "oak-pay-business",
position: "src/components/payConfig/system",
data: {
"system": "系统配置",
"appsBelow": "以下为application",
"mayLossUpdate": "%{name}上的更新可能会丢失,请尽快保存"
"system": "系统相关配置",
"help": "说明",
"payConfig": {
"label": {
"depositLoss": "充值手续费",
"withdrawLoss": "提现手续费",
"conservative": "保守策略",
"ratio": "按比例",
"lowest": "最低(分)",
"highest": "最高(分)",
"trim": "去尾",
"jiao": "角",
"yuan": "元",
"null": "不去尾"
},
"help": {
"depositLoss": "若不配置手续费用户充值时渠道的手续费损失将被计算到system关联的账户之中",
"withdrawLoss": "若配置为保守策略系统将自动计算渠道的损耗在system账户不贴现的前提下让用户可提现的额度最大化"
}
}
}
},
{
@ -474,14 +492,13 @@ const i18ns = [
"placeholder": {
"privateKeyFilePath": "服务器上存放apiclient_key.pem的路径注意访问权限",
"publicKeyFilePath": "服务器上存放apiclient_cert.pem的路径注意访问权限",
"taxlossRatio": "微信支付收取的手续费百分比一般为0.6(代表千分之六)",
"taxLossRatio": "微信支付收取的手续费百分比一般为0.6(代表千分之六)",
"refundCompensateRatio": "渠道退款时返回的手续费比例50代表渠道将返回当时收取的手续费的一半",
"depositLossRatio": "充值收取的手续费百分比一般为0.6(代表千分之六)",
"payNotifyUrl": "endpoint",
"refundNotifyUrl": "endpoint",
"apiV3Key": "需要登录商户后台获取",
"refundGapDays": "超过这个天数后无法退款",
"refundLossRatio": "退款时将按这个百分比扣除损耗0.6就代表千分之六)",
"refundLossFloor": "退款时按位向下取整(如按元取整,则忽略角位和分位)"
"refundGapDays": "超过这个天数后无法退款"
},
"wechatPayIsShared": "以上配置是全局的,请谨慎修改"
}
@ -508,7 +525,7 @@ const i18ns = [
position: "src/components/wpProduct/upsert",
data: {
"placeholder": {
"taxlossRatio": "如果配置了产品的手续费,则覆盖微信支付账号上配置的手续费"
"taxLossRatio": "如果配置了产品的手续费,则覆盖微信支付账号上配置的手续费"
}
}
},
@ -578,7 +595,9 @@ const i18ns = [
},
"deposit": {
"lossReason": {
"ratio": "按百分比%{value}%扣除"
"ratio": "按百分比%{value}%扣除",
"highest": "按单笔充值最高手续费%{value}扣除",
"lowest": "按单笔充值最低手续费%{value}扣除"
}
}
}

View File

@ -2,13 +2,9 @@ import { 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 {
taxlossRatio: Decimal<4, 2>;
depositLossRatio?: Decimal<4, 2>;
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4>;
refundLossRatio?: Decimal<4, 2>;
refundLossFloor?: 'yuan' | 'jiao';
refundCompensateRatio?: Int<4>;
}
export type Action = 'pay' | 'refund' | 'deposit' | 'withdraw' | 'tax';
export declare const entityDesc: EntityDesc<Schema, Action, '', {
refundLossFloor: NonNullable<Schema['refundLossFloor']>;
}>;
export declare const entityDesc: EntityDesc<Schema, Action>;

View File

@ -7,17 +7,9 @@ exports.entityDesc = {
zh_CN: {
name: '抽象支付帐号',
attr: {
taxlossRatio: '渠道手续费(百分比)',
depositLossRatio: '充值损耗百分比',
taxLossRatio: '渠道手续费(百分比)',
refundGapDays: '(支付后)允许退款的天数',
refundLossRatio: '退款损耗百分比',
refundLossFloor: '退款向下取整位数',
},
v: {
refundLossFloor: {
yuan: '元',
jiao: '角'
},
refundCompensateRatio: '退款补偿百分比',
},
action: {
pay: '支付',
@ -29,12 +21,6 @@ exports.entityDesc = {
},
},
style: {
color: {
refundLossFloor: {
yuan: '#FFFF00',
jiao: '#00FF00'
}
},
icon: {
pay: '',
refund: '',

View File

@ -2,7 +2,7 @@ import { String, Price } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { EntityDesc } from 'oak-domain/lib/types';
import { Schema as Account } from './Account';
type Type = 'deposit' | 'withdraw' | 'consume' | 'loan' | 'repay' | 'withdrawBack' | 'earn' | 'encash' | 'cutoffRefundable';
type Type = 'deposit' | 'withdraw' | 'consume' | 'loan' | 'repay' | 'withdrawBack' | 'earn' | 'encash' | 'cutoffRefundable' | 'tax';
export interface Schema extends EntityShape {
account: Account;
type: Type;

View File

@ -25,6 +25,7 @@ exports.entityDesc = {
withdrawBack: '提现失败',
earn: '赚取',
encash: '兑现',
tax: '渠道费',
cutoffRefundable: '削减可自由退额度'
},
},
@ -41,6 +42,7 @@ exports.entityDesc = {
repay: '#82E0AA',
earn: '#FF3333',
encash: '#FF3399',
tax: '#A569BD',
cutoffRefundable: '#2E4053',
}
}

View File

@ -1,9 +1,4 @@
<<<<<<< HEAD
import { String, Text, Price, Boolean } from 'oak-domain/lib/types/DataType';
=======
import { String, Text, Price, Boolean, Decimal } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
import { EntityDesc } from 'oak-domain/lib/types';
import { Schema as System } from './System';
import { Schema as Pay } from './Pay';
@ -12,8 +7,6 @@ import { Schema as AbstractAccount } from './AbstractAccount';
export interface Schema extends AbstractAccount {
type: 'bank' | 'alipay' | 'wechat' | 'shouqianba' | 'others';
channel?: String<32>;
taxlossRatio?: Decimal<4, 2>;
depositLossRatio?: Decimal<4, 2>;
name?: String<64>;
qrCode?: Text;
allowDeposit: Boolean;

View File

@ -11,14 +11,9 @@ exports.entityDesc = {
channel: '通道',
name: '用户/帐号',
qrCode: '收款二维码',
taxlossRatio: '商户号手续费(百分比)',
depositLossRatio: '充值损耗百分比',
<<<<<<< HEAD
taxLossRatio: '商户号手续费(百分比)',
refundCompensateRatio: '退款补偿百分比',
refundGapDays: '(支付后)允许退款的天数',
refundLossRatio: '退款损耗百分比',
refundLossFloor: '退款向下取整位数',
=======
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
allowDeposit: '允许主动充值',
allowPay: '允许主动支付',
system: '所属系统',

View File

@ -2,8 +2,24 @@ import { EntityDesc } from 'oak-domain/lib/types/EntityDesc';
import { Schema as System } from 'oak-general-business/lib/entities/System';
import { Schema as Account } from './Account';
import { Schema as WithdrawAccount } from './WithdrawAccount';
type PayConfig = {
withdrawLoss: {
conservative: boolean;
ratio?: number;
lowest?: number;
highest?: number;
trim?: "jiao" | "yuan";
};
depositLoss: {
ratio?: number;
lowest?: number;
highest?: number;
};
};
export interface Schema extends System {
accounts: Account[];
withdrawAccounts: WithdrawAccount[];
payConfig?: PayConfig;
}
export declare const entityDesc: EntityDesc<Schema>;
export {};

View File

@ -10,6 +10,7 @@ exports.entityDesc = {
name: '名称',
description: '描述',
config: '设置',
payConfig: '支付相关设置',
platform: '平台',
super: '超级系统',
folder: '代码目录名',

View File

@ -16,6 +16,4 @@ export interface Schema extends AbstractAccount {
enabled: Boolean;
}
export type Action = 'pay' | 'refund' | 'deposit' | 'withdraw' | 'tax';
export declare const entityDesc: EntityDesc<Schema, Action, '', {
refundLossFloor: NonNullable<Schema['refundLossFloor']>;
}>;
export declare const entityDesc: EntityDesc<Schema, Action>;

View File

@ -8,11 +8,9 @@ exports.entityDesc = {
name: '微信支付帐号',
attr: {
wechatPay: '微信支付',
taxlossRatio: '商户号手续费(百分比)',
depositLossRatio: '充值损耗百分比',
taxLossRatio: '商户号手续费(百分比)',
refundCompensateRatio: '退款补偿百分比',
refundGapDays: '(支付后)允许退款的天数',
refundLossRatio: '退款损耗百分比',
refundLossFloor: '退款向下取整位数',
mchId: '商户号',
publicKeyFilePath: '公钥文件路径',
privateKeyFilePath: '私钥文件路径',
@ -22,12 +20,6 @@ exports.entityDesc = {
opers: '操作记录',
enabled: '是否启用',
},
v: {
refundLossFloor: {
yuan: '元',
jiao: '角'
},
},
action: {
pay: '支付',
refund: '退款',
@ -38,12 +30,6 @@ exports.entityDesc = {
},
},
style: {
color: {
refundLossFloor: {
yuan: '#FFFF00',
jiao: '#00FF00'
}
},
icon: {
pay: '',
refund: '',

View File

@ -7,7 +7,7 @@ import { Schema as Pay } from './Pay';
export interface Schema extends EntityShape {
wpAccount: WpAccount;
type: 'native' | 'mp' | 'jsapi' | 'h5' | 'app';
taxlossRatio?: Decimal<4, 2>;
taxLossRatio?: Decimal<4, 2>;
application: Application;
enabled: Boolean;
pays: Pay[];

View File

@ -11,7 +11,7 @@ exports.entityDesc = {
type: '类型',
application: '关联应用',
enabled: '有效中',
taxlossRatio: '产品手续费(百分比)',
taxLossRatio: '产品手续费(百分比)',
pays: '支付',
},
v: {

View File

@ -52,7 +52,7 @@ class Pay extends oak_frontend_base_1.Feature {
}
calcDepositLoss(price, channel) {
const { entity, entityId } = channel;
return (0, pay_1.getDepositLoss)(price, entity, entityId, this.application.getApplication());
return (0, pay_1.getDepositLoss)(price, this.application.getApplication());
}
getDepositRatio(channel) {
throw new Error('method not implemented');

View File

@ -58,7 +58,9 @@
},
"deposit": {
"lossReason": {
"ratio": "按百分比%{value}%扣除"
"ratio": "按百分比%{value}%扣除",
"highest": "按单笔充值最高手续费%{value}扣除",
"lowest": "按单笔充值最低手续费%{value}扣除"
}
}
}

View File

@ -1,22 +1,18 @@
import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { Q_DateValue, Q_NumberValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
import { Decimal, Int } from "oak-domain/lib/types/DataType";
export type OpSchema = EntityShape & {
taxlossRatio: Decimal<4, 2>;
depositLossRatio?: Decimal<4, 2> | null;
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundLossRatio?: Decimal<4, 2> | null;
refundLossFloor?: ("yuan" | "jiao") | null;
refundCompensateRatio?: Int<4> | null;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
taxlossRatio: Decimal<4, 2>;
depositLossRatio?: Decimal<4, 2> | null;
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundLossRatio?: Decimal<4, 2> | null;
refundLossFloor?: ("yuan" | "jiao") | null;
refundCompensateRatio?: Int<4> | null;
} & {
[A in ExpressionKey]?: any;
};
@ -25,11 +21,9 @@ type AttrFilter = {
$$createAt$$: Q_DateValue;
$$seq$$: Q_NumberValue;
$$updateAt$$: Q_DateValue;
taxlossRatio: Q_NumberValue;
depositLossRatio: Q_NumberValue;
taxLossRatio: Q_NumberValue;
refundGapDays: Q_NumberValue;
refundLossRatio: Q_NumberValue;
refundLossFloor: Q_EnumValue<"yuan" | "jiao">;
refundCompensateRatio: Q_NumberValue;
};
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
export type Projection = {
@ -39,11 +33,9 @@ export type Projection = {
$$createAt$$?: number;
$$updateAt$$?: number;
$$seq$$?: number;
taxlossRatio?: number;
depositLossRatio?: number;
taxLossRatio?: number;
refundGapDays?: number;
refundLossRatio?: number;
refundLossFloor?: number;
refundCompensateRatio?: number;
} & Partial<ExprOp<OpAttr | string>>;
type AbstractAccountIdProjection = OneOf<{
id: number;
@ -57,15 +49,11 @@ export type SortAttr = {
} | {
$$updateAt$$: number;
} | {
taxlossRatio: number;
} | {
depositLossRatio: number;
taxLossRatio: number;
} | {
refundGapDays: number;
} | {
refundLossRatio: number;
} | {
refundLossFloor: number;
refundCompensateRatio: number;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>;

View File

@ -4,7 +4,7 @@ exports.desc = void 0;
const Action_1 = require("./Action");
exports.desc = {
attributes: {
taxlossRatio: {
taxLossRatio: {
notNull: true,
type: "decimal",
params: {
@ -12,13 +12,6 @@ exports.desc = {
scale: 2
}
},
depositLossRatio: {
type: "decimal",
params: {
precision: 4,
scale: 2
}
},
refundGapDays: {
type: "int",
params: {
@ -26,16 +19,12 @@ exports.desc = {
signed: true
}
},
refundLossRatio: {
type: "decimal",
refundCompensateRatio: {
type: "int",
params: {
precision: 4,
scale: 2
width: 4,
signed: true
}
},
refundLossFloor: {
type: "enum",
enumeration: ["yuan", "jiao"]
}
},
actionType: "crud",

View File

@ -2,12 +2,6 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.style = void 0;
exports.style = {
color: {
refundLossFloor: {
yuan: '#FFFF00',
jiao: '#00FF00'
}
},
icon: {
pay: '',
refund: '',

View File

@ -1 +1 @@
{ "name": "抽象支付帐号", "attr": { "taxlossRatio": "渠道手续费(百分比)", "depositLossRatio": "充值损耗百分比", "refundGapDays": "(支付后)允许退款的天数", "refundLossRatio": "退款损耗百分比", "refundLossFloor": "退款向下取整位数" }, "v": { "refundLossFloor": { "yuan": "元", "jiao": "角" } }, "action": { "pay": "支付", "refund": "退款", "deposit": "充值", "withdraw": "提现", "tax": "渠道费" } }
{ "name": "抽象支付帐号", "attr": { "taxLossRatio": "渠道手续费(百分比)", "refundGapDays": "(支付后)允许退款的天数", "refundCompensateRatio": "退款补偿百分比" }, "action": { "pay": "支付", "refund": "退款", "deposit": "充值", "withdraw": "提现", "tax": "渠道费" } }

View File

@ -155,7 +155,6 @@ export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
<<<<<<< HEAD
export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "ofSystemId">> & (({
ofSystemId?: never;
ofSystem: System.CreateSingleOperation;
@ -166,9 +165,6 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
ofSystem?: never;
ofSystemId: ForeignKey<"ofSystem">;
})) & ({
=======
export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "ofSystemId">> & ({
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
entity?: never;
entityId?: never;
system: System.CreateSingleOperation;
@ -205,7 +201,6 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
<<<<<<< HEAD
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "entityId" | "ofSystemId">> & (({
ofSystem?: System.CreateSingleOperation;
ofSystemId?: never;
@ -223,13 +218,6 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "enti
entityId?: never;
entity?: never;
} | {
=======
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "entityId" | "ofSystemId">> & ({
system?: System.CreateSingleOperation | System.UpdateOperation | System.RemoveOperation;
entityId?: never;
entity?: never;
} | {
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
user?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
entityId?: never;
entity?: never;
@ -246,13 +234,9 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "enti
pay$entity?: OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">> | OakOperation<Pay.RemoveOperation["action"], Omit<Pay.RemoveOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<Pay.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<Pay.CreateOperationData, "entity" | "entityId">> | OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">> | OakOperation<Pay.RemoveOperation["action"], Omit<Pay.RemoveOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">>>;
};
export type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
<<<<<<< HEAD
export type RemoveOperationData = {} & (({
ofSystem?: System.UpdateOperation | System.RemoveOperation;
})) & ({
=======
export type RemoveOperationData = {} & ({
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
system?: System.UpdateOperation | System.RemoveOperation;
} | {
user?: User.UpdateOperation | User.RemoveOperation;

View File

@ -8,7 +8,7 @@ import * as Account from "../Account/Schema";
import * as Deposit from "../Deposit/Schema";
import * as Pay from "../Pay/Schema";
import * as Withdraw from "../Withdraw/Schema";
type Type = "deposit" | "withdraw" | "consume" | "loan" | "repay" | "withdrawBack" | "earn" | "encash" | "cutoffRefundable";
type Type = "deposit" | "withdraw" | "consume" | "loan" | "repay" | "withdrawBack" | "earn" | "encash" | "cutoffRefundable" | "tax";
export type OpSchema = EntityShape & {
accountId: ForeignKey<"account">;
type: Type;

View File

@ -12,7 +12,7 @@ exports.desc = {
type: {
notNull: true,
type: "enum",
enumeration: ["deposit", "withdraw", "consume", "loan", "repay", "withdrawBack", "earn", "encash", "cutoffRefundable"]
enumeration: ["deposit", "withdraw", "consume", "loan", "repay", "withdrawBack", "earn", "encash", "cutoffRefundable", "tax"]
},
totalPlus: {
notNull: true,

View File

@ -12,6 +12,7 @@ exports.style = {
repay: '#82E0AA',
earn: '#FF3333',
encash: '#FF3399',
tax: '#A569BD',
cutoffRefundable: '#2E4053',
}
}

View File

@ -1 +1 @@
{ "name": "帐号操作", "attr": { "account": "帐号", "type": "类型", "totalPlus": "余额变化", "availPlus": "可用余额变化", "refundablePlus": "可退款余额变化", "entity": "关联对象", "entityId": "关联对象Id" }, "v": { "type": { "deposit": "充值", "withdraw": "提现", "consume": "消费", "loan": "抵押", "repay": "偿还", "withdrawBack": "提现失败", "earn": "赚取", "encash": "兑现", "cutoffRefundable": "削减可自由退额度" } } }
{ "name": "帐号操作", "attr": { "account": "帐号", "type": "类型", "totalPlus": "余额变化", "availPlus": "可用余额变化", "refundablePlus": "可退款余额变化", "entity": "关联对象", "entityId": "关联对象Id" }, "v": { "type": { "deposit": "充值", "withdraw": "提现", "consume": "消费", "loan": "抵押", "repay": "偿还", "withdrawBack": "提现失败", "earn": "赚取", "encash": "兑现", "tax": "渠道费", "cutoffRefundable": "削减可自由退额度" } } }

View File

@ -3,24 +3,16 @@ import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue,
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
<<<<<<< HEAD
import { Decimal, Int, String, Text, Boolean, Price } from "oak-domain/lib/types/DataType";
=======
import { String, Decimal, Text, Boolean, Price } from "oak-domain/lib/types/DataType";
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
import * as System from "../System/Schema";
import * as Pay from "../Pay/Schema";
import * as SysAccountOper from "../SysAccountOper/Schema";
export type OpSchema = EntityShape & {
taxlossRatio: Decimal<4, 2>;
depositLossRatio?: Decimal<4, 2> | null;
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundLossRatio?: Decimal<4, 2> | null;
refundLossFloor?: ("yuan" | "jiao") | null;
refundCompensateRatio?: Int<4> | null;
type: "bank" | "alipay" | "wechat" | "shouqianba" | "others";
channel?: String<32> | null;
taxlossRatio?: Decimal<4, 2> | null;
depositLossRatio?: Decimal<4, 2> | null;
name?: String<64> | null;
qrCode?: Text | null;
allowDeposit: Boolean;
@ -31,15 +23,11 @@ export type OpSchema = EntityShape & {
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
taxlossRatio: Decimal<4, 2>;
depositLossRatio?: Decimal<4, 2> | null;
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundLossRatio?: Decimal<4, 2> | null;
refundLossFloor?: ("yuan" | "jiao") | null;
refundCompensateRatio?: Int<4> | null;
type: "bank" | "alipay" | "wechat" | "shouqianba" | "others";
channel?: String<32> | null;
taxlossRatio?: Decimal<4, 2> | null;
depositLossRatio?: Decimal<4, 2> | null;
name?: String<64> | null;
qrCode?: Text | null;
allowDeposit: Boolean;
@ -60,15 +48,11 @@ type AttrFilter = {
$$createAt$$: Q_DateValue;
$$seq$$: Q_NumberValue;
$$updateAt$$: Q_DateValue;
taxlossRatio: Q_NumberValue;
depositLossRatio: Q_NumberValue;
taxLossRatio: Q_NumberValue;
refundGapDays: Q_NumberValue;
refundLossRatio: Q_NumberValue;
refundLossFloor: Q_EnumValue<"yuan" | "jiao">;
refundCompensateRatio: Q_NumberValue;
type: Q_EnumValue<"bank" | "alipay" | "wechat" | "shouqianba" | "others">;
channel: Q_StringValue;
taxlossRatio: Q_NumberValue;
depositLossRatio: Q_NumberValue;
name: Q_StringValue;
qrCode: Q_StringValue;
allowDeposit: Q_BooleanValue;
@ -88,15 +72,11 @@ export type Projection = {
$$createAt$$?: number;
$$updateAt$$?: number;
$$seq$$?: number;
taxlossRatio?: number;
depositLossRatio?: number;
taxLossRatio?: number;
refundGapDays?: number;
refundLossRatio?: number;
refundLossFloor?: number;
refundCompensateRatio?: number;
type?: number;
channel?: number;
taxlossRatio?: number;
depositLossRatio?: number;
name?: number;
qrCode?: number;
allowDeposit?: number;
@ -133,23 +113,15 @@ export type SortAttr = {
} | {
$$updateAt$$: number;
} | {
taxlossRatio: number;
} | {
depositLossRatio: number;
taxLossRatio: number;
} | {
refundGapDays: number;
} | {
refundLossRatio: number;
} | {
refundLossFloor: number;
refundCompensateRatio: number;
} | {
type: number;
} | {
channel: number;
} | {
taxlossRatio: number;
} | {
depositLossRatio: number;
} | {
name: number;
} | {

View File

@ -4,7 +4,7 @@ exports.desc = void 0;
const Action_1 = require("./Action");
exports.desc = {
attributes: {
taxlossRatio: {
taxLossRatio: {
notNull: true,
type: "decimal",
params: {
@ -12,13 +12,6 @@ exports.desc = {
scale: 2
}
},
depositLossRatio: {
type: "decimal",
params: {
precision: 4,
scale: 2
}
},
refundGapDays: {
type: "int",
params: {
@ -26,17 +19,13 @@ exports.desc = {
signed: true
}
},
refundLossRatio: {
type: "decimal",
refundCompensateRatio: {
type: "int",
params: {
precision: 4,
scale: 2
width: 4,
signed: true
}
},
refundLossFloor: {
type: "enum",
enumeration: ["yuan", "jiao"]
},
type: {
notNull: true,
type: "enum",
@ -48,20 +37,6 @@ exports.desc = {
length: 32
}
},
taxlossRatio: {
type: "decimal",
params: {
precision: 4,
scale: 2
}
},
depositLossRatio: {
type: "decimal",
params: {
precision: 4,
scale: 2
}
},
name: {
type: "varchar",
params: {

View File

@ -1,5 +1 @@
<<<<<<< HEAD
{ "name": "线下账户", "attr": { "type": "类型", "channel": "通道", "name": "用户/帐号", "qrCode": "收款二维码", "taxlossRatio": "商户号手续费(百分比)", "depositLossRatio": "充值损耗百分比", "refundGapDays": "(支付后)允许退款的天数", "refundLossRatio": "退款损耗百分比", "refundLossFloor": "退款向下取整位数", "allowDeposit": "允许主动充值", "allowPay": "允许主动支付", "system": "所属系统", "price": "余额", "pays": "支付", "opers": "操作记录", "enabled": "是否启用" }, "v": { "type": { "bank": "银行", "alipay": "支付宝", "wechat": "微信", "shouqianba": "收钱吧", "others": "其它" } }, "action": { "pay": "支付", "refund": "退款", "deposit": "充值", "withdraw": "提现", "tax": "渠道费" } }
=======
{ "name": "线下账户", "attr": { "type": "类型", "channel": "通道", "name": "用户/帐号", "qrCode": "收款二维码", "taxlossRatio": "商户号手续费(百分比)", "depositLossRatio": "充值损耗百分比", "allowDeposit": "允许主动充值", "allowPay": "允许主动支付", "system": "所属系统", "price": "余额", "pays": "支付", "opers": "操作记录", "enabled": "是否启用" }, "v": { "type": { "bank": "银行", "alipay": "支付宝", "wechat": "微信", "shouqianba": "收钱吧", "others": "其它" } }, "action": { "pay": "支付", "refund": "退款", "deposit": "充值", "withdraw": "提现", "tax": "渠道费" } }
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
{ "name": "线下账户", "attr": { "type": "类型", "channel": "通道", "name": "用户/帐号", "qrCode": "收款二维码", "taxLossRatio": "商户号手续费(百分比)", "refundCompensateRatio": "退款补偿百分比", "refundGapDays": "(支付后)允许退款的天数", "allowDeposit": "允许主动充值", "allowPay": "允许主动支付", "system": "所属系统", "price": "余额", "pays": "支付", "opers": "操作记录", "enabled": "是否启用" }, "v": { "type": { "bank": "银行", "alipay": "支付宝", "wechat": "微信", "shouqianba": "收钱吧", "others": "其它" } }, "action": { "pay": "支付", "refund": "退款", "deposit": "充值", "withdraw": "提现", "tax": "渠道费" } }

View File

@ -18,6 +18,20 @@ import * as WechatPay from "../WechatPay/Schema";
import * as WithdrawAccount from "../WithdrawAccount/Schema";
import * as WithdrawChannel from "../WithdrawChannel/Schema";
import * as WpAccount from "../WpAccount/Schema";
type PayConfig = {
withdrawLoss: {
conservative: boolean;
ratio?: number;
lowest?: number;
highest?: number;
trim?: "jiao" | "yuan";
};
depositLoss: {
ratio?: number;
lowest?: number;
highest?: number;
};
};
export type OpSchema = EntityShape & {
name: String<32>;
description: Text;
@ -28,6 +42,7 @@ export type OpSchema = EntityShape & {
style?: Style | null;
entity?: String<32> | null;
entityId?: String<64> | null;
payConfig?: PayConfig | null;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
@ -40,6 +55,7 @@ export type Schema = EntityShape & {
style?: Style | null;
entity?: String<32> | null;
entityId?: String<64> | null;
payConfig?: PayConfig | null;
platform?: Platform.Schema | null;
application$system?: Array<Application.Schema>;
application$system$$aggr?: AggregationResult<Application.Schema>;
@ -85,6 +101,7 @@ type AttrFilter = {
style: JsonFilter<Style>;
entity: Q_StringValue;
entityId: Q_StringValue;
payConfig: JsonFilter<PayConfig>;
application$system: Application.Filter & SubQueryPredicateMetadata;
domain$system: Domain.Filter & SubQueryPredicateMetadata;
messageSystem$system: MessageSystem.Filter & SubQueryPredicateMetadata;
@ -117,6 +134,7 @@ export type Projection = {
style?: number | JsonProjection<Style>;
entity?: number;
entityId?: number;
payConfig?: number | JsonProjection<PayConfig>;
application$system?: Application.Selection & {
$entity: "application";
};
@ -230,6 +248,8 @@ export type SortAttr = {
entity: number;
} | {
entityId: number;
} | {
payConfig: number;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>;

View File

@ -23,7 +23,8 @@ exports.desc = {
type: "ref",
ref: "platform"
},
folder: {
folder // 提现的loss在用户提现时计算
: {
notNull: true,
type: "varchar",
params: {
@ -36,7 +37,8 @@ exports.desc = {
style: {
type: "object"
},
entity: {
entity // 如果为true则按照渠道taxLossRatio和refundCompensateRatio进行扣取(如果因为depositLossRatio已经大于taxLossRatio则全额退款)
: {
type: "varchar",
params: {
length: 32
@ -47,6 +49,9 @@ exports.desc = {
params: {
length: 64
}
},
payConfig: {
type: "object"
}
},
actionType: "crud",

View File

@ -1 +1 @@
{ "name": "系统", "attr": { "name": "名称", "description": "描述", "config": "设置", "platform": "平台", "super": "超级系统", "folder": "代码目录名", "style": "样式", "entity": "关联对象", "entityId": "关联对象id", "accounts": "关联账户", "withdrawAccounts": "关联提现账户" } }
{ "name": "系统", "attr": { "name": "名称", "description": "描述", "config": "设置", "payConfig": "支付相关设置", "platform": "平台", "super": "超级系统", "folder": "代码目录名", "style": "样式", "entity": "关联对象", "entityId": "关联对象id", "accounts": "关联账户", "withdrawAccounts": "关联提现账户" } }

View File

@ -164,7 +164,6 @@ export type SelectOperation<P extends Object = Projection> = OakSelection<"selec
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "ofSystemId" | "channelId">> & (({
<<<<<<< HEAD
ofSystemId?: never;
ofSystem: System.CreateSingleOperation;
} | {
@ -174,8 +173,6 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
ofSystem?: never;
ofSystemId: ForeignKey<"ofSystem">;
}) & ({
=======
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
channelId?: never;
channel: WithdrawChannel.CreateSingleOperation;
} | {
@ -221,7 +218,6 @@ export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "entityId" | "ofSystemId" | "channelId">> & (({
<<<<<<< HEAD
ofSystem?: System.CreateSingleOperation;
ofSystemId?: never;
} | {
@ -234,8 +230,6 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "enti
ofSystem?: never;
ofSystemId?: ForeignKey<"ofSystem">;
}) & ({
=======
>>>>>>> 99d2876ae88266ffcff6aa944c537941daeab7ce
channel?: WithdrawChannel.CreateSingleOperation;
channelId?: never;
} | {

View File

@ -1,5 +1,5 @@
import { ForeignKey } from "oak-domain/lib/types/DataType";
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
@ -11,11 +11,9 @@ import * as ModiEntity from "../ModiEntity/Schema";
import * as OperEntity from "../OperEntity/Schema";
import * as SysAccountOper from "../SysAccountOper/Schema";
export type OpSchema = EntityShape & {
taxlossRatio: Decimal<4, 2>;
depositLossRatio?: Decimal<4, 2> | null;
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundLossRatio?: Decimal<4, 2> | null;
refundLossFloor?: ("yuan" | "jiao") | null;
refundCompensateRatio?: Int<4> | null;
wechatPayId: ForeignKey<"wechatPay">;
mchId: String<128>;
publicKeyFilePath: Text;
@ -27,11 +25,9 @@ export type OpSchema = EntityShape & {
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
taxlossRatio: Decimal<4, 2>;
depositLossRatio?: Decimal<4, 2> | null;
taxLossRatio: Decimal<4, 2>;
refundGapDays?: Int<4> | null;
refundLossRatio?: Decimal<4, 2> | null;
refundLossFloor?: ("yuan" | "jiao") | null;
refundCompensateRatio?: Int<4> | null;
wechatPayId: ForeignKey<"wechatPay">;
mchId: String<128>;
publicKeyFilePath: Text;
@ -58,11 +54,9 @@ type AttrFilter = {
$$createAt$$: Q_DateValue;
$$seq$$: Q_NumberValue;
$$updateAt$$: Q_DateValue;
taxlossRatio: Q_NumberValue;
depositLossRatio: Q_NumberValue;
taxLossRatio: Q_NumberValue;
refundGapDays: Q_NumberValue;
refundLossRatio: Q_NumberValue;
refundLossFloor: Q_EnumValue<"yuan" | "jiao">;
refundCompensateRatio: Q_NumberValue;
wechatPayId: Q_StringValue;
wechatPay: WechatPay.Filter;
mchId: Q_StringValue;
@ -86,11 +80,9 @@ export type Projection = {
$$createAt$$?: number;
$$updateAt$$?: number;
$$seq$$?: number;
taxlossRatio?: number;
depositLossRatio?: number;
taxLossRatio?: number;
refundGapDays?: number;
refundLossRatio?: number;
refundLossFloor?: number;
refundCompensateRatio?: number;
wechatPayId?: number;
wechatPay?: WechatPay.Projection;
mchId?: number;
@ -144,15 +136,11 @@ export type SortAttr = {
} | {
$$updateAt$$: number;
} | {
taxlossRatio: number;
} | {
depositLossRatio: number;
taxLossRatio: number;
} | {
refundGapDays: number;
} | {
refundLossRatio: number;
} | {
refundLossFloor: number;
refundCompensateRatio: number;
} | {
wechatPayId: number;
} | {

View File

@ -4,7 +4,7 @@ exports.desc = void 0;
const Action_1 = require("./Action");
exports.desc = {
attributes: {
taxlossRatio: {
taxLossRatio: {
notNull: true,
type: "decimal",
params: {
@ -12,13 +12,6 @@ exports.desc = {
scale: 2
}
},
depositLossRatio: {
type: "decimal",
params: {
precision: 4,
scale: 2
}
},
refundGapDays: {
type: "int",
params: {
@ -26,17 +19,13 @@ exports.desc = {
signed: true
}
},
refundLossRatio: {
type: "decimal",
refundCompensateRatio: {
type: "int",
params: {
precision: 4,
scale: 2
width: 4,
signed: true
}
},
refundLossFloor: {
type: "enum",
enumeration: ["yuan", "jiao"]
},
wechatPayId: {
notNull: true,
type: "ref",

View File

@ -1 +1 @@
{ "name": "微信支付帐号", "attr": { "wechatPay": "微信支付", "taxlossRatio": "商户号手续费(百分比)", "depositLossRatio": "充值损耗百分比", "refundGapDays": "(支付后)允许退款的天数", "refundLossRatio": "退款损耗百分比", "refundLossFloor": "退款向下取整位数", "mchId": "商户号", "publicKeyFilePath": "公钥文件路径", "privateKeyFilePath": "私钥文件路径", "apiV3Key": "apiV3Key", "price": "余额", "system": "关联系统", "opers": "操作记录", "enabled": "是否启用" }, "v": { "refundLossFloor": { "yuan": "元", "jiao": "角" } }, "action": { "pay": "支付", "refund": "退款", "deposit": "充值", "withdraw": "提现", "tax": "渠道费" } }
{ "name": "微信支付帐号", "attr": { "wechatPay": "微信支付", "taxLossRatio": "商户号手续费(百分比)", "refundCompensateRatio": "退款补偿百分比", "refundGapDays": "(支付后)允许退款的天数", "mchId": "商户号", "publicKeyFilePath": "公钥文件路径", "privateKeyFilePath": "私钥文件路径", "apiV3Key": "apiV3Key", "price": "余额", "system": "关联系统", "opers": "操作记录", "enabled": "是否启用" }, "action": { "pay": "支付", "refund": "退款", "deposit": "充值", "withdraw": "提现", "tax": "渠道费" } }

View File

@ -12,7 +12,7 @@ import * as Pay from "../Pay/Schema";
export type OpSchema = EntityShape & {
wpAccountId: ForeignKey<"wpAccount">;
type: "native" | "mp" | "jsapi" | "h5" | "app";
taxlossRatio?: Decimal<4, 2> | null;
taxLossRatio?: Decimal<4, 2> | null;
applicationId: ForeignKey<"application">;
enabled: Boolean;
};
@ -20,7 +20,7 @@ export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
wpAccountId: ForeignKey<"wpAccount">;
type: "native" | "mp" | "jsapi" | "h5" | "app";
taxlossRatio?: Decimal<4, 2> | null;
taxLossRatio?: Decimal<4, 2> | null;
applicationId: ForeignKey<"application">;
enabled: Boolean;
wpAccount: WpAccount.Schema;
@ -42,7 +42,7 @@ type AttrFilter = {
wpAccountId: Q_StringValue;
wpAccount: WpAccount.Filter;
type: Q_EnumValue<"native" | "mp" | "jsapi" | "h5" | "app">;
taxlossRatio: Q_NumberValue;
taxLossRatio: Q_NumberValue;
applicationId: Q_StringValue;
application: Application.Filter;
enabled: Q_BooleanValue;
@ -61,7 +61,7 @@ export type Projection = {
wpAccountId?: number;
wpAccount?: WpAccount.Projection;
type?: number;
taxlossRatio?: number;
taxLossRatio?: number;
applicationId?: number;
application?: Application.Projection;
enabled?: number;
@ -108,7 +108,7 @@ export type SortAttr = {
} | {
type: number;
} | {
taxlossRatio: number;
taxLossRatio: number;
} | {
applicationId: number;
} | {

View File

@ -14,7 +14,7 @@ exports.desc = {
type: "enum",
enumeration: ["native", "mp", "jsapi", "h5", "app"]
},
taxlossRatio: {
taxLossRatio: {
type: "decimal",
params: {
precision: 4,

View File

@ -1 +1 @@
{ "name": "微信支付产品", "attr": { "wpAccount": "微信支付帐号", "type": "类型", "application": "关联应用", "enabled": "有效中", "taxlossRatio": "产品手续费(百分比)", "pays": "支付" }, "v": { "type": { "native": "扫码", "mp": "小程序", "jsapi": "jsApi", "h5": "H5唤起微信", "app": "App" } } }
{ "name": "微信支付产品", "attr": { "wpAccount": "微信支付帐号", "type": "类型", "application": "关联应用", "enabled": "有效中", "taxLossRatio": "产品手续费(百分比)", "pays": "支付" }, "v": { "type": { "native": "扫码", "mp": "小程序", "jsapi": "jsApi", "h5": "H5唤起微信", "app": "App" } } }

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

@ -2,10 +2,10 @@ import { Trigger } from 'oak-domain/lib/types/Trigger';
import { EntityDict } from '../oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { BRC } from '../types/RuntimeCxt';
type CalcPaySysAccountChangeOption<ED extends EntityDict & BaseEntityDict> = {
type CalcPayChannelTaxOption<ED extends EntityDict & BaseEntityDict> = {
projection: ED['pay']['Selection']['data'];
fn: (pay: ED['pay']['Schema']) => [number, string, string];
};
export declare function registerCalcPaySysAccountChangeOption<ED extends EntityDict & BaseEntityDict>(entity: keyof ED, option: CalcPaySysAccountChangeOption<ED>): void;
export declare function registerCalcPayChannelTaxOption<ED extends EntityDict & BaseEntityDict>(entity: keyof ED, option: CalcPayChannelTaxOption<ED>): void;
declare const triggers: Trigger<EntityDict, 'pay', BRC>[];
export default triggers;

View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerCalcPaySysAccountChangeOption = void 0;
exports.registerCalcPayChannelTaxOption = void 0;
const tslib_1 = require("tslib");
const uuid_1 = require("oak-domain/lib/utils/uuid");
const assert_1 = tslib_1.__importDefault(require("assert"));
@ -8,46 +8,44 @@ const payClazz_1 = require("../utils/payClazz");
const pay_1 = require("../utils/pay");
const constants_1 = require("../config/constants");
const lodash_1 = require("oak-domain/lib/utils/lodash");
const CalcPaySysAccountChangeDict = {
const CalcPayChannelTaxDict = {
wpProduct: {
projection: {
wpProduct: {
id: 1,
taxlossRatio: 1,
taxLossRatio: 1,
wpAccountId: 1,
wpAccount: {
id: 1,
taxlossRatio: 1,
taxLossRatio: 1,
},
},
},
fn: (pay) => {
const { paid, wpProduct } = pay;
const taxlossRatio = wpProduct.taxlossRatio || wpProduct.wpAccount.taxlossRatio;
(0, assert_1.default)(typeof taxlossRatio === 'number');
const tax = Math.round(paid * taxlossRatio / 100);
return [paid - tax, 'wpAccount', wpProduct.wpAccountId];
const taxLossRatio = wpProduct.taxLossRatio || wpProduct.wpAccount.taxLossRatio;
(0, assert_1.default)(typeof taxLossRatio === 'number', '微信渠道的手续费率未配置');
return [Math.round(paid * taxLossRatio / 100), 'wpAccount', wpProduct.wpAccountId];
},
},
offlineAccount: {
projection: {
offlineAccount: {
id: 1,
taxlossRatio: 1,
taxLossRatio: 1,
},
},
fn: (pay) => {
const { offlineAccount, paid } = pay;
const { taxlossRatio } = offlineAccount;
const tax = taxlossRatio ? Math.round(paid * taxlossRatio / 100) : 0;
return [paid - tax, pay.entity, pay.entityId];
const { taxLossRatio } = offlineAccount;
return [taxLossRatio ? Math.round(paid * taxLossRatio / 100) : 0, pay.entity, pay.entityId];
},
},
};
function registerCalcPaySysAccountChangeOption(entity, option) {
CalcPaySysAccountChangeDict[entity] = option;
function registerCalcPayChannelTaxOption(entity, option) {
CalcPayChannelTaxDict[entity] = option;
}
exports.registerCalcPaySysAccountChangeOption = registerCalcPaySysAccountChangeOption;
exports.registerCalcPayChannelTaxOption = registerCalcPayChannelTaxOption;
async function changeOrderStateByPay(filter, context, option) {
const orders = await context.select('order', {
data: {
@ -232,11 +230,14 @@ const triggers = [
price: 1,
loss: 1,
},
application: {
systemId: 1,
},
iState: 1,
},
filter,
}, { dontCollect: true });
const { orderId, depositId, iState, deposit } = pay;
const { orderId, depositId, iState, deposit, application } = pay;
context.saveOperationToEvent(id, `${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
if (orderId) {
return await changeOrderStateByPay({ id: orderId }, context, option);
@ -248,24 +249,48 @@ const triggers = [
const payPrice = pay.price;
const { price, loss } = deposit;
(0, assert_1.default)(price === payPrice);
const accountOpers = [
{
id: await (0, uuid_1.generateNewIdAsync)(),
data: {
id: await (0, uuid_1.generateNewIdAsync)(),
totalPlus: price - loss,
availPlus: price - loss,
refundablePlus: pay.refundable ? price : 0,
accountId: deposit.accountId,
type: 'deposit',
},
action: 'create',
}
];
if (loss > 0) {
// 如果有loss就充入system的account账户
const [account] = await context.select('account', {
data: {
id: 1,
},
filter: {
entity: 'system',
entityId: application?.systemId,
},
}, { dontCollect: true });
accountOpers.push({
id: await (0, uuid_1.generateNewIdAsync)(),
data: {
id: await (0, uuid_1.generateNewIdAsync)(),
totalPlus: loss,
availPlus: loss,
accountId: account.id,
type: 'earn',
},
action: 'create',
});
}
await context.operate('deposit', {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'succeed',
data: {
accountOper$entity: [
{
id: await (0, uuid_1.generateNewIdAsync)(),
data: {
id: await (0, uuid_1.generateNewIdAsync)(),
totalPlus: price - loss,
availPlus: price - loss,
refundablePlus: pay.refundable ? price : 0,
accountId: deposit.accountId,
type: 'deposit',
},
action: 'create',
}
]
accountOper$entity: accountOpers,
},
filter: {
id: depositId,
@ -386,7 +411,7 @@ const triggers = [
},
},
{
name: '当pay完成支付时修改相应的sys account中的余额',
name: '当pay完成支付时计算相应的account以及syste account中的余额变化',
entity: 'pay',
action: 'succeedPaying',
when: 'after',
@ -400,9 +425,13 @@ const triggers = [
entityId: 1,
iState: 1,
depositId: 1,
orderId: 1,
application: {
systemId: 1,
}
};
for (const key in CalcPaySysAccountChangeDict) {
(0, lodash_1.merge)(projection, CalcPaySysAccountChangeDict[key].projection);
for (const key in CalcPayChannelTaxDict) {
(0, lodash_1.merge)(projection, CalcPayChannelTaxDict[key].projection);
}
const pays = await context.select('pay', {
data: projection,
@ -410,33 +439,56 @@ const triggers = [
}, {});
(0, assert_1.default)(pays.length === 1);
const [pay] = pays;
const { price, paid, entity, entityId, iState, depositId } = pay;
const { price, paid, entity, entityId, iState, application } = pay;
(0, assert_1.default)(iState === 'paid');
const option = CalcPaySysAccountChangeDict[entity];
let cnt = 0;
const option = CalcPayChannelTaxDict[entity];
if (option) {
const [delta, sysAccountEntity, sysAccountEntityId] = option.fn(pay);
if (delta !== 0) {
(0, assert_1.default)(delta > 0);
await context.operate('sysAccountOper', {
const [tax, sysAccountEntity, sysAccountEntityId] = option.fn(pay);
await context.operate('sysAccountOper', {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'create',
data: {
id: await (0, uuid_1.generateNewIdAsync)(),
delta: paid - tax,
entity: sysAccountEntity,
entityId: sysAccountEntityId,
payId: pay.id,
type: 'pay',
}
}, {});
if (tax !== 0) {
// tax产生的损失由sys account来承担
const [account] = await context.select('account', {
data: {
id: 1,
},
filter: {
entity: 'system',
entityId: application.systemId,
}
}, { dontCollect: true });
await context.operate('accountOper', {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'create',
data: {
id: await (0, uuid_1.generateNewIdAsync)(),
delta,
entity: sysAccountEntity,
entityId: sysAccountEntityId,
payId: pay.id,
type: 'pay',
}
accountId: account.id,
type: 'tax',
totalPlus: -tax,
availPlus: -tax,
entity: 'pay',
entityId: pay.id,
},
}, {});
return 1;
}
cnt++;
}
return 0;
return cnt;
},
},
{
name: '当pay的paid达到price支付成功',
name: '当account类型的pay的paid达到price改为支付成功',
entity: 'pay',
action: ['startPaying', 'continuePaying'],
check(operation) {

View File

@ -11,22 +11,22 @@ const CalcRefundSysAccountChangeDict = {
projection: {
wpProduct: {
id: 1,
taxlossRatio: 1,
taxLossRatio: 1,
wpAccountId: 1,
wpAccount: {
id: 1,
taxlossRatio: 1,
taxLossRatio: 1,
},
},
},
fn: (refund) => {
const { price, pay, loss } = refund;
const { wpProduct } = pay;
const taxlossRatio = wpProduct.taxlossRatio || wpProduct.wpAccount.taxlossRatio;
(0, assert_1.default)(typeof taxlossRatio === 'number');
const taxLossRatio = wpProduct.taxLossRatio || wpProduct.wpAccount.taxLossRatio;
(0, assert_1.default)(typeof taxLossRatio === 'number');
// 微信支付的退款部分不计手续费(这里计算的不够精细,直接四舍五入可能会产生误差积累)
const toRefund = price - loss;
const tax = Math.round(toRefund * taxlossRatio / 100);
const tax = Math.round(toRefund * taxLossRatio / 100);
const price2 = toRefund - tax;
return [-price2, 'wpAccount', wpProduct.wpAccountId];
},

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 ExternalPrePayException<ED extends EntityDict> extends OakException<ED> {
reason: any;
constructor(reason: any, message?: string);

View File

@ -15,15 +15,13 @@ exports.applicationProjection = {
type: 1,
wpAccount: {
id: 1,
depositLossRatio: 1,
refundGapDays: 1,
refundLossFloor: 1,
refundLossRatio: 1,
mchId: 1,
}
},
},
system: {
payConfig: 1,
offlineAccount$system: {
$entity: 'offlineAccount',
data: {
@ -32,13 +30,16 @@ exports.applicationProjection = {
name: 1,
type: 1,
allowDeposit: 1,
depositLossRatio: 1,
refundGapDays: 1,
refundLossFloor: 1,
refundLossRatio: 1,
allowPay: 1,
}
}
},
account$entity: {
$entity: 'account',
data: {
id: 1,
},
},
}
};
exports.mergedProjection = (0, lodash_1.merge)({}, Projection_1.applicationProjection, exports.applicationProjection);

6
lib/utils/pay.d.ts vendored
View File

@ -6,15 +6,13 @@ import { IncomingHttpHeaders } from 'http';
export declare const fullPayProjection: EntityDict['pay']['Selection']['data'];
export declare function payNotify<ED extends EntityDict & BaseEntityDict>(context: BackendRuntimeContext<ED>, body: any, payId: string, headers: IncomingHttpHeaders): Promise<void>;
type CalcLoss = <ED extends EntityDict & BaseEntityDict>(entityId: string, application: ED['application']['Schema'], price: number) => [number, string, any];
export declare function registerCalcRefundLoss<ED extends EntityDict & BaseEntityDict>(entity: string, projection: ED['application']['Selection']['data'], fn: CalcLoss): void;
export declare function registerCalcDepositLoss<ED extends EntityDict & BaseEntityDict>(entity: string, projection: ED['application']['Selection']['data'], fn: CalcLoss): void;
/**
*
* attention: 这个函数目前是在前端调用的offlineAccount的信息前端能取的到
* attention: 这个函数目前是在前端调用的
* @param context
* @param channel
* @param application
*/
export declare function getDepositLoss<ED extends EntityDict & BaseEntityDict>(price: number, entity: keyof ED, entityId: string, application: ED['application']['Schema']): ReturnType<CalcLoss>;
export declare function getDepositLoss<ED extends EntityDict & BaseEntityDict>(price: number, application: ED['application']['Schema']): ReturnType<CalcLoss>;
export declare function getAccountPayRefunds<ED extends EntityDict & BaseEntityDict>(context: BackendRuntimeContext<ED>, accountId: string, totalPrice?: number): Promise<Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]>;
export {};

View File

@ -1,12 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountPayRefunds = exports.getDepositLoss = exports.registerCalcDepositLoss = exports.registerCalcRefundLoss = exports.payNotify = exports.fullPayProjection = void 0;
exports.getAccountPayRefunds = exports.getDepositLoss = exports.payNotify = exports.fullPayProjection = void 0;
const tslib_1 = require("tslib");
const payClazz_1 = require("./payClazz");
const assert_1 = tslib_1.__importDefault(require("assert"));
const uuid_1 = require("oak-domain/lib/utils/uuid");
const Exception_1 = require("../types/Exception");
const lodash_1 = require("oak-domain/lib/utils/lodash");
exports.fullPayProjection = {
id: 1,
applicationId: 1,
@ -90,7 +88,10 @@ async function payNotify(context, body, payId, headers) {
return;
}
exports.payNotify = payNotify;
const CalcRefundLossDict = {
/* const CalcRefundLossDict: Record<string, {
projection: EntityDict['application']['Selection']['data'],
fn: CalcLoss,
}> = {
'wpProduct': {
projection: {
wpProduct$application: {
@ -107,8 +108,8 @@ const CalcRefundLossDict = {
},
fn: (entityId, application, price) => {
const { wpProduct$application: wpProducts } = application;
const wpProduct = wpProducts.find(ele => ele.id === entityId);
const { refundLossFloor, refundLossRatio } = wpProduct.wpAccount;
const wpProduct = wpProducts!.find(ele => ele.id === entityId);
const { refundLossFloor, refundLossRatio } = wpProduct!.wpAccount!;
if (refundLossRatio) {
return [
Math.ceil(price * refundLossRatio / 100),
@ -134,90 +135,50 @@ const CalcRefundLossDict = {
}
}
};
const CalcDepositLossDict = {
wpProduct: {
projection: {
wpProduct$application: {
$entity: 'wpProduct',
data: {
wpAccount: {
id: 1,
depositLossRatio: 1,
},
},
},
},
fn: (entityId, application, price) => {
const { wpProduct$application: wpProducts } = application;
const wpProduct = wpProducts.find(ele => ele.id === entityId);
const { depositLossRatio } = wpProduct.wpAccount;
if (depositLossRatio) {
return [Math.ceil(price * depositLossRatio / 100), 'common::deposit.lossReason.ratio', { value: depositLossRatio }];
}
return [0, '', undefined];
},
},
offlineAccount: {
projection: {
system: {
offlineAccount$system: {
$entity: 'offlineAccount',
data: {
id: 1,
depositLossRatio: 1,
}
}
}
},
fn: (entityId, application, price) => {
const { system } = application;
const { offlineAccount$system: offlineAccounts } = system;
const offlineAccount = offlineAccounts.find(ele => ele.id === entityId);
const { depositLossRatio } = offlineAccount;
if (depositLossRatio) {
return [Math.ceil(price * depositLossRatio / 100), 'common::deposit.lossReason.ratio', { value: depositLossRatio }];
}
return [0, '', undefined];
}
}
};
function registerCalcRefundLoss(entity, projection, fn) {
(0, assert_1.default)(!CalcRefundLossDict[entity], `${entity}上已经定义了CalcLoss`);
export function registerCalcRefundLoss<ED extends EntityDict & BaseEntityDict>(entity: string, projection: ED['application']['Selection']['data'], fn: CalcLoss) {
assert(!CalcRefundLossDict[entity], `${entity}上已经定义了CalcLoss`);
CalcRefundLossDict[entity] = {
projection,
fn,
};
}
exports.registerCalcRefundLoss = registerCalcRefundLoss;
function registerCalcDepositLoss(entity, projection, fn) {
(0, assert_1.default)(!CalcDepositLossDict[entity], `${entity}上已经定义了CalcLoss`);
CalcDepositLossDict[entity] = {
projection,
fn,
};
}
exports.registerCalcDepositLoss = registerCalcDepositLoss;
*/
/**
* 计算充值的损耗比例
* attention: 这个函数目前是在前端调用的所以要确保对应的offlineAccount的信息前端能取的到
* attention: 这个函数目前是在前端调用的
* @param context
* @param channel
* @param application
*/
function getDepositLoss(price, entity, entityId, application) {
const option = CalcDepositLossDict[entity];
if (option) {
return option.fn(entityId, application, price);
function getDepositLoss(price, application) {
const { system } = application;
const { payConfig } = system;
const depositLoss = payConfig?.depositLoss;
if (depositLoss) {
const { ratio, highest, lowest } = depositLoss;
let loss = ratio && Math.round(price * ratio / 100) || 0;
if (highest && loss > highest) {
return [highest, 'common::deposit.lossReason.highest', { value: (highest / 100).toFixed(2) }];
}
if (lowest && loss < lowest) {
return [lowest, 'common::deposit.lossReason.lowest', { value: (lowest / 100).toFixed(2) }];
}
if (loss > 0) {
return [loss, 'common::deposit.lossReason.ratio', { value: ratio }];
}
}
return [0, '', undefined];
}
exports.getDepositLoss = getDepositLoss;
async function getAccountPayRefunds(context, accountId, totalPrice) {
const appProj = {
const refundData = [];
/* const appProj: EntityDict['application']['Selection']['data'] = {
id: 1,
};
for (const k in CalcRefundLossDict) {
(0, lodash_1.merge)(appProj, CalcRefundLossDict[k].projection);
merge(appProj, CalcRefundLossDict[k].projection);
}
const pays = await context.select('pay', {
data: {
@ -248,25 +209,28 @@ async function getAccountPayRefunds(context, accountId, totalPrice) {
}
],
}, { dontCollect: true, forUpdate: true });
let price2 = 0;
const refundData = [];
for (const pay of pays) {
const { price, paid, refunded, refundable, entity, entityId, application } = pay;
(0, assert_1.default)(price === paid && refundable);
(0, assert_1.default)(!['account', 'offlineAccount'].includes(entity));
const rest = paid - refunded;
(0, assert_1.default)(rest > 0);
assert(price === paid && refundable);
assert(!['account', 'offlineAccount'].includes(entity!));
const rest = paid! - refunded!;
assert(rest > 0);
let refundPrice = rest;
if (totalPrice && totalPrice - price2 < rest) {
refundPrice = totalPrice - price2;
}
const [loss, lossExplanation, lossExplanationParams] = CalcRefundLossDict[entity].fn(entityId, application, price);
const [loss, lossExplanation, lossExplanationParams] = CalcRefundLossDict[entity!]!.fn(entityId!, application as EntityDict['application']['Schema'], price!);
refundData.push({
id: await (0, uuid_1.generateNewIdAsync)(),
id: await generateNewIdAsync(),
price: refundPrice,
loss,
creatorId: context.getCurrentUserId(),
payId: pay.id,
payId: pay.id!,
iState: 'refunding',
meta: {
channel: entity,
@ -274,14 +238,17 @@ async function getAccountPayRefunds(context, accountId, totalPrice) {
lossExplanationParams,
}
});
price2 += refundPrice;
if (totalPrice && price2 === totalPrice) {
break;
}
}
if (totalPrice && price2 < totalPrice) {
throw new Exception_1.RefundExceedMax();
}
throw new RefundExceedMax();
} */
return refundData;
}
exports.getAccountPayRefunds = getAccountPayRefunds;

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

@ -34,7 +34,8 @@ function PayConfig(props: {
t: (key: string) => string;
}) {
const { payConfig, update, t } = props;
const { withdrawLoss, depositLoss } = payConfig || {};
const withdrawLoss = payConfig?.withdrawLoss;
const depositLoss = payConfig?.depositLoss;
const updateDepositLoss = (data: Partial<NonNullable<EntityDict['system']['OpSchema']['payConfig']>['depositLoss']>) => {
update({

View File

@ -119,6 +119,12 @@ const attrUpdateMatrix: AttrUpdateMatrix<EntityDict> = {
depositLossRatio: {
actions: ['update'],
},
refundCompensateRatio: {
actions: ['update'],
},
refundGapDays: {
actions: ['update'],
},
price: {
actions: ['pay', 'refund', 'deposit', 'withdraw', 'tax'],
},

View File

@ -55,12 +55,6 @@ export const entityDesc: EntityDesc<Schema, Action> = {
},
},
style: {
color: {
refundLossFloor: {
yuan: '#FFFF00',
jiao: '#00FF00'
}
},
icon: {
pay: '',
refund: '',

View File

@ -4,7 +4,6 @@ import { registerFrontendPayRoutine } from './components/pay/detail/index';
import { registerApplicationProjection } from './utils/application';
import { registerCalcPayChannelTaxOption } from './triggers/pay';
import { registerCalcRefundSysAccountChangeOption } from './triggers/refund';
import { registerCalcDepositLoss, registerCalcRefundLoss } from './utils/pay';
import { EntityDict } from './oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';

View File

@ -33,7 +33,7 @@ const CalcPayChannelTaxDict: Record<string, CalcPayChannelTaxOption<EntityDict>>
const { paid, wpProduct } = pay;
const taxLossRatio = wpProduct!.taxLossRatio! || wpProduct!.wpAccount!.taxLossRatio!;
assert(typeof taxLossRatio === 'number', '微信渠道的手续费率未配置');
return [Math.round(paid * taxLossRatio / 100), 'wpAccount', wpProduct.wpAccountId!];
return [Math.round(paid * taxLossRatio / 100), 'wpAccount', wpProduct!.wpAccountId!];
},
},
offlineAccount: {

View File

@ -104,7 +104,7 @@ type CalcLoss = <ED extends EntityDict & BaseEntityDict>(
application: ED['application']['Schema'],
price: number) => [number, string, any];
const CalcRefundLossDict: Record<string, {
/* const CalcRefundLossDict: Record<string, {
projection: EntityDict['application']['Selection']['data'],
fn: CalcLoss,
}> = {
@ -160,7 +160,7 @@ export function registerCalcRefundLoss<ED extends EntityDict & BaseEntityDict>(e
fn,
};
}
*/
/**
*
@ -198,7 +198,8 @@ export async function getAccountPayRefunds<ED extends EntityDict & BaseEntityDic
accountId: string,
totalPrice?: number
) {
const appProj: EntityDict['application']['Selection']['data'] = {
const refundData: Omit<EntityDict['refund']['CreateSingle']['data'], 'entity' | 'entityId'>[] = [];
/* const appProj: EntityDict['application']['Selection']['data'] = {
id: 1,
};
for (const k in CalcRefundLossDict) {
@ -235,7 +236,6 @@ export async function getAccountPayRefunds<ED extends EntityDict & BaseEntityDic
}, { dontCollect: true, forUpdate: true });
let price2 = 0;
const refundData: Omit<EntityDict['refund']['CreateSingle']['data'], 'entity' | 'entityId'>[] = [];
for (const pay of pays) {
const { price, paid, refunded, refundable, entity, entityId, application } = pay;
@ -273,7 +273,7 @@ export async function getAccountPayRefunds<ED extends EntityDict & BaseEntityDic
if (totalPrice && price2 < totalPrice) {
throw new RefundExceedMax();
}
} */
return refundData;
}