移除了index中对backendContext的引用,降低前台体积

This commit is contained in:
Xu Chang 2024-06-16 14:04:30 +08:00
parent 8b4a0a8583
commit c10df08c50
75 changed files with 84 additions and 817 deletions

View File

@ -1,5 +0,0 @@
import { BRC } from '../types/RuntimeCxt';
export declare function getAccountPayRefunds(params: {
accountId: string;
price: number;
}, context: BRC): Promise<Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]>;

View File

@ -1,4 +0,0 @@
import { getAccountPayRefunds as getAprsFn } from '../utils/pay';
export async function getAccountPayRefunds(params, context) {
return getAprsFn(context, params.accountId, params.price);
}

View File

@ -1,2 +0,0 @@
import { BRC } from '../types/RuntimeCxt';
export declare function test(params: string, context: BRC): Promise<string>;

View File

@ -1,3 +0,0 @@
export async function test(params, context) {
return 'hello world';
}

View File

@ -1,3 +0,0 @@
/// <reference types="wechat-miniprogram" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../oak-app-domain").EntityDict, "offlineAccount", false, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

@ -1,17 +0,0 @@
export default OakComponent({
entity: 'offlineAccount',
projection: {
id: 1,
type: 1,
channel: 1,
name: 1,
desc: 1,
systemId: 1,
},
isList: false,
formData({ data }) {
return {
offlineAccount: data,
};
},
});

View File

@ -1 +0,0 @@
{}

View File

@ -1,3 +0,0 @@
{
"tips": "线下交易账户是需要人工同步收款和打款行为的账户"
}

View File

@ -1,6 +0,0 @@
import { EntityDict } from "../../oak-app-domain";
import { RowWithActions, WebComponentProps } from "oak-frontend-base";
import React from 'react';
export default function render(props: WebComponentProps<EntityDict, 'offlineAccount', false, {
offlineAccount: RowWithActions<EntityDict, 'offlineAccount'>;
}>): React.JSX.Element | undefined;

View File

@ -1,27 +0,0 @@
import React from 'react';
import { Alert, Form, Switch, InputNumber } from 'antd';
export default function render(props) {
const { offlineAccount } = props.data;
const { t } = props.methods;
if (offlineAccount) {
return (<Form labelCol={{ span: 6 }} wrapperCol={{ span: 12 }} layout="horizontal" style={{ minWidth: 600 }}>
<Alert type='info' message={t('tips')}/>
<Form.Item label={t('label.depositLoss')} help={t('placeholder.depositLoss')}>
<Switch value={config.depositLoss} onChange={(value) => {
config.depositLoss = value;
if (value === false) {
config.depositLossRatio = undefined;
}
update(config);
}}/>
</Form.Item>
{config.depositLoss &&
<Form.Item label={t('label.depositLossRatio')} help={t('placeholder.depositLossRatio')}>
<InputNumber value={config.depositLossRatio} max={5} min={0.01} addonAfter={"%"} step={0.01} precision={2} onChange={(value) => {
config.depositLossRatio = value;
update(config);
}}/>
</Form.Item>}
</Form>);
}
}

View File

@ -1,23 +0,0 @@
/// <reference types="react" />
import { PayConfig } from "../../../types/PayConfig";
/**
*
* by Xc 20240426
*/
export type ExtraPicker = {
label: string;
name: string;
icon: React.ForwardRefExoticComponent<any>;
component?: React.ForwardRefExoticComponent<{
onSetMeta?: (meta: object) => void;
}>;
};
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, boolean, {
payConfig: PayConfig;
channel: string;
meta: object;
extraChannelPickers: ExtraPicker[];
onPick: (channel: string) => void;
onSetMeta: (meta?: object) => void;
}>) => React.ReactElement;
export default _default;

View File

@ -1,47 +0,0 @@
import { PAY_CHANNEL_OFFLINE_NAME } from "../../../types/PayConfig";
import assert from 'assert';
export default OakComponent({
properties: {
payConfig: [],
channel: '',
meta: {},
extraChannelPickers: [],
onPick: (channel) => undefined,
onSetMeta: (meta) => undefined,
},
formData() {
const { payConfig } = this.props;
assert(payConfig);
const offlineConfig = payConfig.find(ele => ele.channel === PAY_CHANNEL_OFFLINE_NAME);
return {
offlineConfig,
payChannels: payConfig.map(ele => ele.channel),
};
},
methods: {
onPickChannel(channel) {
this.props.onPick(channel);
if (channel === PAY_CHANNEL_OFFLINE_NAME && this.state.offlineConfig?.options?.length) {
this.props.onSetMeta({
option: this.state.offlineConfig.options[0],
});
}
else {
this.props.onSetMeta({});
}
},
onPickChannelMp(touch) {
const { detail } = touch;
const { currentKey } = detail;
this.onPickChannel(currentKey);
},
onSelectOfflineOptionMp(touch) {
const { option } = touch.currentTarget.dataset;
const { meta, onSetMeta } = this.props;
onSetMeta({
...meta,
option,
});
}
}
});

View File

@ -1,8 +0,0 @@
{
"usingComponents": {
"l-input": "@oak-frontend-base/miniprogram_npm/lin-ui/input/index",
"l-radio": "@oak-frontend-base/miniprogram_npm/lin-ui/radio/index",
"l-radio-group": "@oak-frontend-base/miniprogram_npm/lin-ui/radio-group/index",
"l-tag": "@oak-frontend-base/miniprogram_npm/lin-ui/tag/index"
}
}

View File

@ -1,31 +0,0 @@
.form-item {
position: relative;
font-size: 28rpx;
color: #333;
padding-right: 25rpx;
margin-left: 12rpx;
box-sizing: border-box;
.radio {
height: 80rpx;
display: flex;
flex-direction: row;
align-items: center;
.offline-option {
margin-left: 12rpx;
display: flex;
flex-direction: row;
flex-wrap: wrap;
l-tag {
margin-left: 6rpx;
}
.selected {
background:#333 !important;
color:#fff !important;
}
}
}
}

View File

@ -1,36 +0,0 @@
<block wx:if="{{payChannels.length > 0}}">
<l-radio-group
wx:for="{{payChannels}}"
l-class="form-item"
current="{{channel}}"
bind:linchange="onPickChannelMp"
>
<l-radio wx:key="{{item}}" key="{{item}}">
<view class="radio">
<view style="white-space:nowrap">{{t('payChannel::' + item)}}</view>
<block wx:if="{{channel==='OFFLINE' && item==='OFFLINE'}}">
<view
class="offline-option"
>
<l-tag
wx:for="{{offlineConfig.options}}"
plain="{{true}}"
select="{{item===meta.option}}"
l-select-class="selected"
catch:lintap="onSelectOfflineOptionMp"
data-option="{{item}}"
>
{{item}}
</l-tag>
</view>
</block>
</view>
</l-radio>
</l-radio-group>
</block>
<block wx:else>
<l-input
disabled
value="{{t('noChannel')}}"
/>
</block>

View File

@ -1,6 +0,0 @@
{
"label": {
"option": "渠道"
},
"noChannel": "未配置收费渠道"
}

View File

@ -1,14 +0,0 @@
import React from 'react';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import { OfflinePayConfig, PayConfig } from '../../../types/PayConfig';
export default function Render(props: WebComponentProps<EntityDict, keyof EntityDict, false, {
payConfig: PayConfig;
offlineConfig?: OfflinePayConfig;
channel: string;
meta?: any;
onPick: (channel: string, meta?: object) => void;
onSetMeta: (meta?: object) => void;
}, {
onPickChannel: (channel: string) => void;
}>): React.JSX.Element;

View File

@ -1,49 +0,0 @@
import React, { useState } from 'react';
import { Radio, Space, Picker, Button } from 'antd-mobile';
import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME, PAY_CHANNEL_WECHAT_APP_NAME, PAY_CHANNEL_WECHAT_H5_NAME, PAY_CHANNEL_WECHAT_JS_NAME, PAY_CHANNEL_WECHAT_MP_NAME, PAY_CHANNEL_WECHAT_NATIVE_NAME } from '../../../types/PayConfig';
import { WechatOutlined, WalletOutlined } from '@ant-design/icons';
import Styles from './web.mobile.module.less';
const ChannelIconDict = {
[PAY_CHANNEL_ACCOUNT_NAME]: <WalletOutlined />,
[PAY_CHANNEL_OFFLINE_NAME]: <WalletOutlined />,
[PAY_CHANNEL_WECHAT_APP_NAME]: <WechatOutlined />,
[PAY_CHANNEL_WECHAT_JS_NAME]: <WechatOutlined />,
[PAY_CHANNEL_WECHAT_NATIVE_NAME]: <WechatOutlined />,
[PAY_CHANNEL_WECHAT_H5_NAME]: <WechatOutlined />,
[PAY_CHANNEL_WECHAT_MP_NAME]: <WechatOutlined />,
};
export default function Render(props) {
const { payConfig, offlineConfig, channel, onPick, meta, onSetMeta } = props.data;
const { t, onPickChannel } = props.methods;
const [offlinePickerVisible, setOpVisible] = useState(false);
if (payConfig?.length) {
const Offline = offlineConfig && offlineConfig.options?.length && (<>
<Button onClick={() => setOpVisible(true)}>
{meta?.option || t('common::change')}
</Button>
<Picker value={meta?.option} columns={[offlineConfig.options.map(ele => ({
label: ele,
value: ele,
}))]} visible={offlinePickerVisible} onConfirm={(value) => {
onSetMeta({
...meta,
option: value[0],
});
setOpVisible(false);
}} onCancel={() => setOpVisible(false)}/>
</>);
return (<Radio.Group onChange={(value) => onPickChannel(value)} value={channel}>
<Space direction="vertical">
{payConfig.map((v) => (<Radio className={Styles.radio} value={v.channel} key={v.channel}>
<Space direction="horizontal" align='center'>
<span className={Styles.span}>
{t(`payChannel::${v.channel}`)}
</span>
{v.channel === PAY_CHANNEL_OFFLINE_NAME && channel === PAY_CHANNEL_OFFLINE_NAME && Offline}
</Space>
</Radio>))}
</Space>
</Radio.Group>);
}
return (<div>{t('noChannel')}</div>);
}

View File

@ -1,8 +0,0 @@
.span {
margin-right: 10px;
}
.radio {
height: 40px;
}

View File

@ -1,12 +0,0 @@
import React from 'react';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import { OfflinePayConfig, PayConfig } from '../../../types/PayConfig';
export default function Render(props: WebComponentProps<EntityDict, keyof EntityDict, false, {
payConfig: PayConfig;
offlineConfig?: OfflinePayConfig;
channel: string;
meta?: any;
onPick: (channel: string, meta?: object) => void;
onSetMeta: (meta?: object) => void;
}>): React.JSX.Element;

View File

@ -1,54 +0,0 @@
import React from 'react';
import { Radio, Space, Select, Flex } from 'antd';
import Styles from './web.pc.module.less';
import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME, PAY_CHANNEL_WECHAT_APP_NAME, PAY_CHANNEL_WECHAT_H5_NAME, PAY_CHANNEL_WECHAT_JS_NAME, PAY_CHANNEL_WECHAT_MP_NAME, PAY_CHANNEL_WECHAT_NATIVE_NAME } from '../../../types/PayConfig';
import { WechatOutlined, WalletOutlined } from '@ant-design/icons';
const ChannelIconDict = {
[PAY_CHANNEL_ACCOUNT_NAME]: <WalletOutlined />,
[PAY_CHANNEL_OFFLINE_NAME]: <WalletOutlined />,
[PAY_CHANNEL_WECHAT_APP_NAME]: <WechatOutlined />,
[PAY_CHANNEL_WECHAT_JS_NAME]: <WechatOutlined />,
[PAY_CHANNEL_WECHAT_NATIVE_NAME]: <WechatOutlined />,
[PAY_CHANNEL_WECHAT_H5_NAME]: <WechatOutlined />,
[PAY_CHANNEL_WECHAT_MP_NAME]: <WechatOutlined />,
};
export default function Render(props) {
const { payConfig, offlineConfig, channel, onPick, meta, onSetMeta } = props.data;
const { t } = props.methods;
if (payConfig?.length) {
const Offline = offlineConfig && offlineConfig.options?.length && (<span className={Styles.span}>
<Select style={{ width: 140 }} value={meta?.option} options={offlineConfig.options.map(ele => ({
label: ele,
value: ele,
}))} onSelect={(value) => {
onSetMeta({
...meta,
option: value,
});
}}/>
</span>);
return (<Radio.Group onChange={({ target }) => {
onPick(target.value);
if (target.value === PAY_CHANNEL_OFFLINE_NAME && offlineConfig?.options?.length) {
onSetMeta({
option: offlineConfig.options[0],
});
}
else {
onSetMeta({});
}
}} value={channel}>
<Space direction="vertical">
{payConfig.map((v) => (<Radio value={v.channel} key={v.channel}>
<Flex gap="middle" className={Styles.option} align='center'>
<span className={Styles.span}>
{t(`payChannel::${v.channel}`)}
</span>
{v.channel === 'OFFLINE' && channel === 'OFFLINE' && Offline}
</Flex>
</Radio>))}
</Space>
</Radio.Group>);
}
return (<div>{t('noChannel')}</div>);
}

View File

@ -1,7 +0,0 @@
.span {
margin-left: 6px;
}
.option {
height: 44px;
}

View File

@ -1,5 +0,0 @@
import SimpleConnector from 'oak-domain/lib/utils/SimpleConnector';
import { EntityDict } from '../oak-app-domain';
import FrontendRuntimeContext from '../context/FrontendRuntimeContext';
declare const connector: SimpleConnector<EntityDict, FrontendRuntimeContext>;
export default connector;

View File

@ -1,5 +0,0 @@
import SimpleConnector from 'oak-domain/lib/utils/SimpleConnector';
import accessConfiguration from '../configuration/access';
import { makeException } from '../types/Exception';
const connector = new SimpleConnector(accessConfiguration, makeException);
export default connector;

View File

@ -1,7 +1,7 @@
import { EntityDict } from '../oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { RuntimeContext } from './RuntimeContext';
import { BackendRuntimeContext as DependentBackendRuntimeContext } from './DependentContext';
import { BackendRuntimeContext as DependentBackendRuntimeContext } from 'oak-general-business/lib/context/BackendRuntimeContext';
export declare class BackendRuntimeContext<ED extends EntityDict & BaseEntityDict> extends DependentBackendRuntimeContext<ED> implements RuntimeContext {
protected applicationProjection: {
[k: string]: any;

View File

@ -1,4 +1,4 @@
import { BackendRuntimeContext as DependentBackendRuntimeContext } from './DependentContext';
import { BackendRuntimeContext as DependentBackendRuntimeContext } from 'oak-general-business/lib/context/BackendRuntimeContext';
import { mergedProjection } from '../utils/application';
export class BackendRuntimeContext extends DependentBackendRuntimeContext {
applicationProjection = mergedProjection;

View File

@ -1 +0,0 @@
export { BackendRuntimeContext, FrontendRuntimeContext, SerializedData } from "oak-general-business";

View File

@ -1 +0,0 @@
export { BackendRuntimeContext, FrontendRuntimeContext } from "oak-general-business";

View File

@ -1,6 +1,6 @@
import { EntityDict } from '../oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { FrontendRuntimeContext as DependentFrontendRuntimeContext, SerializedData } from './DependentContext';
import { FrontendRuntimeContext as DependentFrontendRuntimeContext, SerializedData } from 'oak-general-business/es/context/FrontendRuntimeContext';
import { RuntimeContext } from './RuntimeContext';
export { SerializedData, };
export declare class FrontendRuntimeContext<ED extends EntityDict & BaseEntityDict> extends DependentFrontendRuntimeContext<ED> implements RuntimeContext {

View File

@ -1,4 +1,4 @@
import { FrontendRuntimeContext as DependentFrontendRuntimeContext } from './DependentContext';
import { FrontendRuntimeContext as DependentFrontendRuntimeContext } from 'oak-general-business/es/context/FrontendRuntimeContext';
export class FrontendRuntimeContext extends DependentFrontendRuntimeContext {
async toString() {
const data = await this.getSerializedData();

View File

@ -1,5 +0,0 @@
import { Schema as Application } from 'oak-general-business/lib/entities/Application';
import { PayConfig } from '../types/PayConfig';
export interface Schema extends Application {
payConfig?: PayConfig;
}

View File

@ -1,38 +0,0 @@
;
const entityDesc = {
locales: {
zh_CN: {
name: '应用',
attr: {
description: '描述',
type: '类型',
system: '系统',
name: '名称',
config: '设置',
style: '样式',
sessions: '会话',
domain: '域名',
payConfig: '支付配置',
},
v: {
type: {
web: '网站',
wechatPublic: '微信公众号',
wechatMp: '微信小程序',
native: 'App',
},
},
},
},
style: {
color: {
type: {
wechatMp: '#32CD32',
web: '#00FF7F',
wechatPublic: '#90EE90',
native: '#008000',
}
}
}
};
export {};

View File

@ -1,8 +0,0 @@
import { AFD } from './types/RuntimeCxt';
/**
* backUrl
* @param location
* @param encode
* @returns
*/
export declare const handler: (reason: any, features: AFD) => Promise<boolean>;

View File

@ -1,47 +0,0 @@
import { OakException, OakUnloggedInException, OakAttrNotNullException, OakInputIllegalException, } from 'oak-domain/lib/types/Exception';
import { ExampleException, } from './types/Exception';
/**
* 构造backUrl
* @param location
* @param encode
* @returns
*/
export const handler = async (reason, features) => {
if (reason instanceof OakException) {
if (reason instanceof OakUnloggedInException) {
// await features.token.logout();
features.navigator.navigateTo({
url: '/login',
}, { isGoBack: true }, true);
}
else if (reason instanceof OakInputIllegalException) {
features.message.setMessage({
content: reason.message,
type: 'error',
});
}
else if (reason instanceof OakAttrNotNullException) {
features.message.setMessage({
content: reason.message,
type: 'error',
});
}
else if (reason instanceof ExampleException) {
console.log('在此处理ExampleException');
}
else {
console.warn(reason);
features.message.setMessage({
content: reason.message,
type: 'error',
});
}
return true;
}
console.error(reason);
features.message.setMessage({
content: reason.message,
type: 'error',
});
return false;
};

View File

@ -1,12 +0,0 @@
import { EntityDict } from '../oak-app-domain';
import { Feature } from 'oak-frontend-base';
import { Cache } from 'oak-frontend-base/es/features/cache';
type IMode = 'systemProvider' | 'store';
export default class Console extends Feature {
private cache;
constructor(cache: Cache<EntityDict>);
getMode(allowUninitialized?: boolean): IMode;
initialize(): Promise<void>;
destroy(): Promise<void>;
}
export {};

View File

@ -1,15 +0,0 @@
import { Feature } from 'oak-frontend-base';
export default class Console extends Feature {
cache;
constructor(cache) {
super();
this.cache = cache;
}
getMode(allowUninitialized) {
return 'systemProvider';
}
async initialize() {
}
async destroy() {
}
}

20
es/features/Menu.d.ts vendored
View File

@ -1,20 +0,0 @@
import { EntityDict } from '../oak-app-domain';
import { Feature } from 'oak-frontend-base';
import { ContextMenuFactory } from 'oak-frontend-base/es/features/contextMenuFactory';
import Console from './Console';
type GroupName = 'System';
export interface OMenu {
name: GroupName | string;
icon: string;
url?: string;
children?: Array<OMenu>;
}
export default class Menu extends Feature {
private contextMenuFactory;
private console;
private menus?;
constructor(contextMenuFactory: ContextMenuFactory<EntityDict>, console: Console);
refreshMenus(): void;
getMenus(): OMenu[] | undefined;
}
export {};

View File

@ -1,62 +0,0 @@
import { Feature } from 'oak-frontend-base';
;
;
const groups = [
{
name: 'System', // 系统级别配置
icon: 'setup_fill',
},
];
const menus = [
{
name: 'Dashboard',
icon: 'document',
url: '',
},
{
name: 'relationManage',
icon: 'share',
url: '/relation/entityList',
parent: 'System',
entity: 'relation',
action: 'create',
paths: [],
},
];
export default class Menu extends Feature {
contextMenuFactory;
console;
menus;
constructor(contextMenuFactory, console) {
super();
this.contextMenuFactory = contextMenuFactory;
this.contextMenuFactory.setMenus(menus);
this.console = console;
this.console.subscribe(() => {
this.refreshMenus();
});
}
refreshMenus() {
/* const roomId = this.console.getRoomId();
const menus = this.contextMenuFactory.getMenusByContext<IMenu<keyof EntityDict>>('room', roomId);
const menuGroup = groupBy(menus, 'parent');
this.menus = (menus as any[]).filter(ele => !ele.parent).concat(
groups.map((ele) => {
const { name, icon } = ele;
const children = menuGroup[name];
return {
name,
icon,
children,
};
}).filter((ele) => !!ele.children)
);
this.publish(); */
}
getMenus() {
if (!this.menus) {
this.refreshMenus();
}
return this.menus;
}
}

View File

@ -1,6 +1,24 @@
import { Feature } from "oak-frontend-base";
import { getDepositLoss } from '../utils/pay';
import { getWpProductTypeFromEnv } from "../utils/wpProductFrontend";
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];
}
export default class Pay extends Feature {
application;
locales;

View File

@ -1,15 +0,0 @@
import { EntityDict } from '../oak-app-domain/index';
import { BasicFeatures, Feature } from 'oak-frontend-base';
type DoSthAcion = {
type: 'doSth';
payload: {
args: string;
};
};
export default class Sample extends Feature {
get(params: any): void;
action(action: DoSthAcion): void;
cache: BasicFeatures<EntityDict>['cache'];
constructor(cache: BasicFeatures<EntityDict>['cache']);
}
export {};

View File

@ -1,14 +0,0 @@
import { Feature } from 'oak-frontend-base';
export default class Sample extends Feature {
get(params) {
throw new Error('Method not implemented.');
}
action(action) {
throw new Error('Method not implemented.');
}
cache;
constructor(cache) {
super();
this.cache = cache;
}
}

View File

@ -2,7 +2,7 @@ import { EntityDict } from '../oak-app-domain';
import { AccessConfiguration } from 'oak-domain/lib/types/Configuration';
import { BasicFeatures } from 'oak-frontend-base';
import { FeatureDict as Ogb0FeatureDict } from "oak-general-business";
import Cos from 'oak-general-business/es/types/Cos';
import { Cos } from 'oak-general-business/es/types/Cos';
import Pay from './Pay';
export declare function create<ED extends EntityDict>(features: BasicFeatures<ED> & Ogb0FeatureDict<ED>): {
pay: Pay;

3
es/index.d.ts vendored
View File

@ -2,6 +2,3 @@ export type { FeatureDict } from './features';
export type { AspectDict } from './aspects/AspectDict';
export * from './types/Exception';
export * from './types/RuntimeCxt';
export { BackendRuntimeContext } from './context/BackendRuntimeContext';
export { FrontendRuntimeContext, SerializedData, } from './context/FrontendRuntimeContext';
export { RuntimeContext } from './context/RuntimeContext';

View File

@ -1,4 +1,2 @@
export * from './types/Exception';
export * from './types/RuntimeCxt';
export { BackendRuntimeContext } from './context/BackendRuntimeContext';
export { FrontendRuntimeContext, } from './context/FrontendRuntimeContext';

View File

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

View File

@ -1 +1 @@
{ "name": "提现转账", "attr": { "withdraw": "提现申请", "withdrawAccount": "提现账户", "price": "金额", "loss": "手续费", "operator": "操作者", "creator": "创建者", "iState": "状态", "externalId": "外部Id", "meta": "metadata", "reason": "原因", "sysOpers": "账户操作" }, "v": { "iState": { "transferring": "待转账", "failed": "已失败", "successful": "已成功" } }, "action": { "succeed": "提现成功", "fail": "提现失败" } }
{ "name": "提现转账", "attr": { "withdraw": "提现申请", "withdrawAccount": "提现账户", "price": "金额", "loss": "手续费", "operator": "操作者", "creator": "创建者", "iState": "状态", "externalId": "外部转账流水号", "meta": "metadata", "reason": "原因", "sysOpers": "账户操作" }, "v": { "iState": { "transferring": "待转账", "failed": "已失败", "successful": "已成功" } }, "action": { "succeed": "转账成功", "fail": "转账失败" } }

View File

@ -1,5 +0,0 @@
import { Trigger } from 'oak-domain/lib/types/Trigger';
import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const triggers: Trigger<EntityDict, 'account', BRC>[];
export default triggers;

View File

@ -1,20 +0,0 @@
import { DATA_SUBSCRIBER_KEYS } from '../config/constants';
import assert from 'assert';
const triggers = [
{
name: '当account帐户的值发生变化时向订阅者推送',
entity: 'account',
action: ['deposit', 'withdraw', 'withdrawBack', 'consume', 'loan', 'repay'],
check(operation) {
return operation.data.hasOwnProperty('total') || operation.data.hasOwnProperty('avail');
},
when: 'after',
fn: async ({ operation }, context, option) => {
const { id, filter } = operation;
assert(typeof filter?.id === 'string');
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${filter.id}`);
return 1;
},
},
];
export default triggers;

View File

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

10
es/utils/pay.d.ts vendored
View File

@ -5,13 +5,3 @@ import BackendRuntimeContext from '../context/BackendRuntimeContext';
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];
/**
*
* attention: 这个函数目前是在前端调用的
* @param context
* @param channel
* @param application
*/
export declare function getDepositLoss<ED extends EntityDict & BaseEntityDict>(price: number, application: ED['application']['Schema']): ReturnType<CalcLoss>;
export {};

View File

@ -83,29 +83,3 @@ export async function payNotify(context, body, payId, headers) {
}
return;
}
/**
* 计算充值的损耗比例
* attention: 这个函数目前是在前端调用的
* @param context
* @param channel
* @param application
*/
export 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];
}

View File

@ -1,5 +0,0 @@
import { BRC } from '../types/RuntimeCxt';
export declare function getAccountPayRefunds(params: {
accountId: string;
price: number;
}, context: BRC): Promise<Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]>;

View File

@ -1,8 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountPayRefunds = void 0;
const pay_1 = require("../utils/pay");
async function getAccountPayRefunds(params, context) {
return (0, pay_1.getAccountPayRefunds)(context, params.accountId, params.price);
}
exports.getAccountPayRefunds = getAccountPayRefunds;

View File

@ -1,7 +1,7 @@
import { EntityDict } from '../oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { RuntimeContext } from './RuntimeContext';
import { BackendRuntimeContext as DependentBackendRuntimeContext } from './DependentContext';
import { BackendRuntimeContext as DependentBackendRuntimeContext } from 'oak-general-business/lib/context/BackendRuntimeContext';
export declare class BackendRuntimeContext<ED extends EntityDict & BaseEntityDict> extends DependentBackendRuntimeContext<ED> implements RuntimeContext {
protected applicationProjection: {
[k: string]: any;

View File

@ -1,9 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BackendRuntimeContext = void 0;
const DependentContext_1 = require("./DependentContext");
const BackendRuntimeContext_1 = require("oak-general-business/lib/context/BackendRuntimeContext");
const application_1 = require("../utils/application");
class BackendRuntimeContext extends DependentContext_1.BackendRuntimeContext {
class BackendRuntimeContext extends BackendRuntimeContext_1.BackendRuntimeContext {
applicationProjection = application_1.mergedProjection;
async toString() {
const data = await this.getSerializedData();

View File

@ -1 +0,0 @@
export { BackendRuntimeContext, FrontendRuntimeContext, SerializedData } from "oak-general-business";

View File

@ -1,6 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrontendRuntimeContext = exports.BackendRuntimeContext = void 0;
var oak_general_business_1 = require("oak-general-business");
Object.defineProperty(exports, "BackendRuntimeContext", { enumerable: true, get: function () { return oak_general_business_1.BackendRuntimeContext; } });
Object.defineProperty(exports, "FrontendRuntimeContext", { enumerable: true, get: function () { return oak_general_business_1.FrontendRuntimeContext; } });

View File

@ -1,6 +1,6 @@
import { EntityDict } from '../oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { FrontendRuntimeContext as DependentFrontendRuntimeContext, SerializedData } from './DependentContext';
import { FrontendRuntimeContext as DependentFrontendRuntimeContext, SerializedData } from 'oak-general-business/es/context/FrontendRuntimeContext';
import { RuntimeContext } from './RuntimeContext';
export { SerializedData, };
export declare class FrontendRuntimeContext<ED extends EntityDict & BaseEntityDict> extends DependentFrontendRuntimeContext<ED> implements RuntimeContext {

View File

@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrontendRuntimeContext = void 0;
const DependentContext_1 = require("./DependentContext");
class FrontendRuntimeContext extends DependentContext_1.FrontendRuntimeContext {
const FrontendRuntimeContext_1 = require("oak-general-business/es/context/FrontendRuntimeContext");
class FrontendRuntimeContext extends FrontendRuntimeContext_1.FrontendRuntimeContext {
async toString() {
const data = await this.getSerializedData();
return JSON.stringify(data);

View File

@ -1,8 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const oak_frontend_base_1 = require("oak-frontend-base");
const pay_1 = require("../utils/pay");
const wpProductFrontend_1 = require("../utils/wpProductFrontend");
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];
}
class Pay extends oak_frontend_base_1.Feature {
application;
locales;
@ -52,7 +70,7 @@ class Pay extends oak_frontend_base_1.Feature {
}
calcDepositLoss(price, channel) {
const { entity, entityId } = channel;
return (0, pay_1.getDepositLoss)(price, this.application.getApplication());
return getDepositLoss(price, this.application.getApplication());
}
getDepositRatio(channel) {
throw new Error('method not implemented');

View File

@ -2,7 +2,7 @@ import { EntityDict } from '../oak-app-domain';
import { AccessConfiguration } from 'oak-domain/lib/types/Configuration';
import { BasicFeatures } from 'oak-frontend-base';
import { FeatureDict as Ogb0FeatureDict } from "oak-general-business";
import Cos from 'oak-general-business/es/types/Cos';
import { Cos } from 'oak-general-business/es/types/Cos';
import Pay from './Pay';
export declare function create<ED extends EntityDict>(features: BasicFeatures<ED> & Ogb0FeatureDict<ED>): {
pay: Pay;

3
lib/index.d.ts vendored
View File

@ -2,6 +2,3 @@ export type { FeatureDict } from './features';
export type { AspectDict } from './aspects/AspectDict';
export * from './types/Exception';
export * from './types/RuntimeCxt';
export { BackendRuntimeContext } from './context/BackendRuntimeContext';
export { FrontendRuntimeContext, SerializedData, } from './context/FrontendRuntimeContext';
export { RuntimeContext } from './context/RuntimeContext';

View File

@ -1,10 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrontendRuntimeContext = exports.BackendRuntimeContext = void 0;
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./types/Exception"), exports);
tslib_1.__exportStar(require("./types/RuntimeCxt"), exports);
var BackendRuntimeContext_1 = require("./context/BackendRuntimeContext");
Object.defineProperty(exports, "BackendRuntimeContext", { enumerable: true, get: function () { return BackendRuntimeContext_1.BackendRuntimeContext; } });
var FrontendRuntimeContext_1 = require("./context/FrontendRuntimeContext");
Object.defineProperty(exports, "FrontendRuntimeContext", { enumerable: true, get: function () { return FrontendRuntimeContext_1.FrontendRuntimeContext; } });

View File

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

View File

@ -1 +1 @@
{ "name": "提现转账", "attr": { "withdraw": "提现申请", "withdrawAccount": "提现账户", "price": "金额", "loss": "手续费", "operator": "操作者", "creator": "创建者", "iState": "状态", "externalId": "外部Id", "meta": "metadata", "reason": "原因", "sysOpers": "账户操作" }, "v": { "iState": { "transferring": "待转账", "failed": "已失败", "successful": "已成功" } }, "action": { "succeed": "提现成功", "fail": "提现失败" } }
{ "name": "提现转账", "attr": { "withdraw": "提现申请", "withdrawAccount": "提现账户", "price": "金额", "loss": "手续费", "operator": "操作者", "creator": "创建者", "iState": "状态", "externalId": "外部转账流水号", "meta": "metadata", "reason": "原因", "sysOpers": "账户操作" }, "v": { "iState": { "transferring": "待转账", "failed": "已失败", "successful": "已成功" } }, "action": { "succeed": "转账成功", "fail": "转账失败" } }

View File

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

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

@ -5,13 +5,3 @@ import BackendRuntimeContext from '../context/BackendRuntimeContext';
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];
/**
*
* attention: 这个函数目前是在前端调用的
* @param context
* @param channel
* @param application
*/
export declare function getDepositLoss<ED extends EntityDict & BaseEntityDict>(price: number, application: ED['application']['Schema']): ReturnType<CalcLoss>;
export {};

View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDepositLoss = exports.payNotify = exports.fullPayProjection = void 0;
exports.payNotify = exports.fullPayProjection = void 0;
const tslib_1 = require("tslib");
const payClazz_1 = require("./payClazz");
const assert_1 = tslib_1.__importDefault(require("assert"));
@ -88,30 +88,3 @@ async function payNotify(context, body, payId, headers) {
return;
}
exports.payNotify = payNotify;
/**
* 计算充值的损耗比例
* attention: 这个函数目前是在前端调用的
* @param context
* @param channel
* @param application
*/
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;

View File

@ -1,7 +1,7 @@
import { EntityDict } from '../oak-app-domain';
import { EntityDict as BaseEntityDict, SelectOpResult } from 'oak-domain/lib/types/Entity';
import { RuntimeContext } from './RuntimeContext';
import { BackendRuntimeContext as DependentBackendRuntimeContext } from './DependentContext';
import { BackendRuntimeContext as DependentBackendRuntimeContext } from 'oak-general-business/lib/context/BackendRuntimeContext';
import { unset } from 'oak-domain/lib/utils/lodash';
import { mergedProjection } from '../utils/application';

View File

@ -1 +0,0 @@
export { BackendRuntimeContext, FrontendRuntimeContext, SerializedData } from "oak-general-business";

View File

@ -2,7 +2,7 @@ import { EntityDict } from '../oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import {
FrontendRuntimeContext as DependentFrontendRuntimeContext, SerializedData
} from './DependentContext';
} from 'oak-general-business/es/context/FrontendRuntimeContext';
import { RuntimeContext } from './RuntimeContext';
export {

View File

@ -2,11 +2,32 @@ import { Feature, BasicFeatures } from "oak-frontend-base";
import { FeatureDict as GeneralFeatures } from 'oak-general-business';
import { EntityDict } from '../oak-app-domain';
import { PayChannel, PayChannels } from '../types/Pay';
import { ExtraOnlineChannels } from '../registry';
import { getDepositLoss } from '../utils/pay';
import { PayConfig } from "../types/PayConfig";
import { getWpProductTypeFromEnv } from "../utils/wpProductFrontend";
function getDepositLoss<ED extends EntityDict>(
price: number, application: ED['application']['Schema']): [number, string, any] {
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];
}
export default class Pay extends Feature {
private application: GeneralFeatures<EntityDict>['application'];
private locales: BasicFeatures<EntityDict>['locales'];

View File

@ -4,7 +4,7 @@ import { merge } from 'oak-domain/lib/utils/lodash';
import { BasicFeatures } from 'oak-frontend-base';
import { FeatureDict as Ogb0FeatureDict } from "oak-general-business";
import { initialize as initializeGeneral } from 'oak-general-business/es/features';
import Cos from 'oak-general-business/es/types/Cos';
import { Cos } from 'oak-general-business/es/types/Cos';
import Pay from './Pay';
import { applicationProjection } from '../utils/application';

View File

@ -3,10 +3,3 @@ export type { FeatureDict } from './features';
export type { AspectDict } from './aspects/AspectDict';
export * from './types/Exception';
export * from './types/RuntimeCxt';
export { BackendRuntimeContext } from './context/BackendRuntimeContext';
export {
FrontendRuntimeContext,
SerializedData,
} from './context/FrontendRuntimeContext';
export { RuntimeContext } from './context/RuntimeContext';

View File

@ -6,9 +6,6 @@ import { getPayClazz } from './payClazz';
import { BRC } from '../types/RuntimeCxt';
import assert from 'assert';
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
import { AccountPayConfig, PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_WECHAT_APP_NAME, PAY_WECHAT_CHANNELS, PayConfig, ThirdPartyConfig } from '../types/PayConfig';
import { RefundExceedMax } from '../types/Exception';
import { merge } from 'oak-domain/lib/utils/lodash';
export const fullPayProjection: EntityDict['pay']['Selection']['data'] = {
id: 1,
@ -98,39 +95,5 @@ export async function payNotify<ED extends EntityDict & BaseEntityDict>(context:
return;
}
type CalcLoss = <ED extends EntityDict & BaseEntityDict>(
entityId: string,
application: ED['application']['Schema'],
price: number) => [number, string, any];
/**
*
* attention: 这个函数目前是在前端调用的
* @param context
* @param channel
* @param application
*/
export function getDepositLoss<ED extends EntityDict & BaseEntityDict>(
price: number, application: ED['application']['Schema']): ReturnType<CalcLoss> {
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];
}