oak-pay-business/src/entities/Pay.ts

126 lines
3.9 KiB
TypeScript

import {
String,
Text,
Price,
Boolean,
Datetime,
} from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { EntityDesc, ActionDef } from 'oak-domain/lib/types';
import { Schema as Order } from './Order';
import { Schema as PayChannel } from './PayChannel';
export interface Schema extends EntityShape {
price: Price;
paid: Price;
refunded: Price;
order: Order;
channel: PayChannel;
timeoutAt: Datetime;
forbidRefundAt?: Datetime;
};
type IAction = 'startPaying' | 'payAll' | 'payPartially' | 'payNone' | 'timeout' | 'cancel' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'refundNone';
type IState = 'paid' | 'unPaid' | 'timeout' | 'cancelled' | 'paying' | 'partiallyPaid' | 'paid' | 'refunding' | 'partiallyRefunded' | 'refunded';
export const IActionDef: ActionDef<IAction, IState> = {
stm: {
startPaying: ['unPaid', 'paying'],
payAll: [['unPaid', 'paying', 'partiallyPaid'], 'paid'],
payPartially: [['unPaid', 'paying'], 'partiallyPaid'],
payNone: ['paying', 'unPaid'],
timeout: ['unPaid', 'timeout'],
cancel: ['unPaid', 'cancelled'],
startRefunding: [['paid', 'partiallyPaid'], 'refunding'],
refundAll: [['paid', 'refunding', 'partiallyPaid', 'partiallyRefunded'], 'refunded'],
refundPartially: [['paid', 'refunding', 'partiallyPaid', 'partiallyRefunded'], 'partiallyRefunded'],
refundNone: ['refunding', 'paid'],
},
is: 'unPaid',
};
type Action = IAction;
export const entityDesc: EntityDesc<Schema, Action, '', {
iState: IState,
}> = {
indexes: [
//索引
{
name: 'index_iState',
attributes: [
{
name: 'iState',
},
],
},
],
locales: {
zh_CN: {
name: '订单',
attr: {
price: '订单金额',
paid: '已支付金额',
refunded: '已退款金额',
iState: '支付状态',
channel: '支付渠道',
order: '所属订单',
timeoutAt: '过期时间',
forbidRefundAt: '停止退款时间',
},
action: {
startPaying: '开始支付',
payAll: '全部支付',
payPartially: '部分支付',
payNone: '支付失败',
timeout: '过期',
cancel: '放弃',
startRefunding: '开始退款',
refundAll: '完全退款',
refundNone: '退款失败',
refundPartially: '部分退款',
},
v: {
iState: {
paid: '已付款',
partiallyPaid: '部分支付',
paying: '支付中',
unPaid: '待付款',
timeout: '已超时',
cancelled: '已取消',
refunded: '已退款',
partiallyRefunded: '已部分退款',
refunding: '退款中',
},
}
},
},
style: {
icon: {
startPaying: '',
payAll: '',
payPartially: '',
payNone: '',
timeout: '',
cancel: '',
startRefunding: '',
refundAll: '',
refundNone: '',
refundPartially: '',
},
color: {
iState: {
unPaid: '#52BE80',
partiallyPaid: '#5DADE2',
cancelled: '#D6DBDF',
paid: '#2E86C1',
paying: '#D2B4DE',
timeout: '#2C3E50',
refunded: '#BA4A00',
partiallyRefunded: '#EDBB99',
refunding: '#FBEEE6'
},
}
}
};