完善了payDetail
This commit is contained in:
parent
0e674ea63d
commit
fdd12e126d
|
|
@ -20,7 +20,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
|
||||||
rowSelection?: any;
|
rowSelection?: any;
|
||||||
hideHeader?: boolean | undefined;
|
hideHeader?: boolean | undefined;
|
||||||
disableSerialNumber?: boolean | undefined;
|
disableSerialNumber?: boolean | undefined;
|
||||||
size?: "small" | "middle" | "large" | undefined;
|
size?: "small" | "large" | "middle" | undefined;
|
||||||
scroll?: ({
|
scroll?: ({
|
||||||
x?: string | number | true | undefined;
|
x?: string | number | true | undefined;
|
||||||
y?: string | number | undefined;
|
y?: string | number | undefined;
|
||||||
|
|
@ -45,7 +45,7 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
|
||||||
tablePagination?: any;
|
tablePagination?: any;
|
||||||
rowSelection?: any;
|
rowSelection?: any;
|
||||||
disableSerialNumber?: boolean | undefined;
|
disableSerialNumber?: boolean | undefined;
|
||||||
size?: "small" | "middle" | "large" | undefined;
|
size?: "small" | "large" | "middle" | undefined;
|
||||||
scroll?: any;
|
scroll?: any;
|
||||||
locale?: any;
|
locale?: any;
|
||||||
}) => React.ReactElement;
|
}) => React.ReactElement;
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@
|
||||||
"label": {
|
"label": {
|
||||||
"option": "渠道"
|
"option": "渠道"
|
||||||
},
|
},
|
||||||
"onChannel": "未配置收费渠道"
|
"noChannel": "未配置收费渠道"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { CentToString } from "oak-domain/lib/utils/money";
|
import { CentToString } from "oak-domain/lib/utils/money";
|
||||||
import { PAY_CHANNEL_OFFLINE_NAME, PAY_CHANNEL_ACCOUNT_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 { PAY_CHANNEL_OFFLINE_NAME, PAY_CHANNEL_ACCOUNT_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 { DATA_SUBSCRIBER_KEYS } from "../../../config/constants";
|
||||||
|
import assert from "assert";
|
||||||
export default OakComponent({
|
export default OakComponent({
|
||||||
entity: 'pay',
|
entity: 'pay',
|
||||||
isList: false,
|
isList: false,
|
||||||
|
|
@ -110,5 +112,17 @@ export default OakComponent({
|
||||||
goBack() {
|
goBack() {
|
||||||
this.navigateBack();
|
this.navigateBack();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
lifetimes: {
|
||||||
|
ready() {
|
||||||
|
const { oakId } = this.props;
|
||||||
|
assert(typeof oakId === 'string');
|
||||||
|
this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
|
||||||
|
},
|
||||||
|
detached() {
|
||||||
|
const { oakId } = this.props;
|
||||||
|
assert(typeof oakId === 'string');
|
||||||
|
this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,8 @@ function RenderWechatPay(props) {
|
||||||
const { externalId, channel, timeoutAt, iState } = pay;
|
const { externalId, channel, timeoutAt, iState } = pay;
|
||||||
if (iState === 'paid') {
|
if (iState === 'paid') {
|
||||||
return (<div className={Styles.paid}>
|
return (<div className={Styles.paid}>
|
||||||
<CheckCircleOutline fontSize={36} fontWeight="bold" color="green"/>
|
<CheckCircleOutline fontSize={72} fontWeight="bold" color="green"/>
|
||||||
<div className='text'>
|
<div className={Styles.text}>
|
||||||
{t('success')}
|
{t('success')}
|
||||||
</div>
|
</div>
|
||||||
</div>);
|
</div>);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Input, Tag, Card, QRCode, Form, Descriptions, Typography, Alert, Select, Button, Modal } from 'antd';
|
import { Input, Tag, Card, QRCode, Form, Descriptions, Typography, Alert, Select, Button, Modal } from 'antd';
|
||||||
|
import { CheckCircleOutlined } from '@ant-design/icons';
|
||||||
import { CentToString } from 'oak-domain/lib/utils/money';
|
import { CentToString } from 'oak-domain/lib/utils/money';
|
||||||
import Styles from './web.pc.module.less';
|
import Styles from './web.pc.module.less';
|
||||||
import * as dayJs from 'dayjs';
|
import * as dayJs from 'dayjs';
|
||||||
|
|
@ -51,6 +52,18 @@ function Counter(props) {
|
||||||
function RenderWechatPay(props) {
|
function RenderWechatPay(props) {
|
||||||
const { pay, t } = props;
|
const { pay, t } = props;
|
||||||
const { externalId, channel, timeoutAt, iState } = pay;
|
const { externalId, channel, timeoutAt, iState } = pay;
|
||||||
|
if (iState === 'paid') {
|
||||||
|
return (<div className={Styles.paid}>
|
||||||
|
<CheckCircleOutlined style={{
|
||||||
|
fontSize: 72,
|
||||||
|
color: 'green',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
}}/>
|
||||||
|
<div className={Styles.text}>
|
||||||
|
{t('success')}
|
||||||
|
</div>
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
switch (channel) {
|
switch (channel) {
|
||||||
case PAY_CHANNEL_WECHAT_NATIVE_NAME: {
|
case PAY_CHANNEL_WECHAT_NATIVE_NAME: {
|
||||||
if (iState === 'paying') {
|
if (iState === 'paying') {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.paid {
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.text {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.oper {
|
.oper {
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
width: 60%;
|
width: 60%;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
export declare const DATA_SUBSCRIBER_KEYS: {};
|
export declare const DATA_SUBSCRIBER_KEYS: {
|
||||||
|
payStateChanged: string;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
export const DATA_SUBSCRIBER_KEYS = {};
|
export const DATA_SUBSCRIBER_KEYS = {
|
||||||
|
payStateChanged: 'oak-pay-business-psc',
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ const i18ns = [
|
||||||
"label": {
|
"label": {
|
||||||
"option": "渠道"
|
"option": "渠道"
|
||||||
},
|
},
|
||||||
"onChannel": "未配置收费渠道"
|
"noChannel": "未配置收费渠道"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import assert from 'assert';
|
||||||
import { getPayClazz } from '../utils/payClazz';
|
import { getPayClazz } from '../utils/payClazz';
|
||||||
import { fullPayProjection } from '../utils/pay';
|
import { fullPayProjection } from '../utils/pay';
|
||||||
import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME } from '../types/PayConfig';
|
import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME } from '../types/PayConfig';
|
||||||
|
import { DATA_SUBSCRIBER_KEYS } from '../config/constants';
|
||||||
async function changeOrderStateByPay(filter, context, option) {
|
async function changeOrderStateByPay(filter, context, option) {
|
||||||
const orders = await context.select('order', {
|
const orders = await context.select('order', {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -200,13 +201,13 @@ const triggers = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '当pay的状态发生变化时,修改相应的order的状态或者account的状态',
|
name: '当pay的状态发生变化时,修改相应的order的状态或者account的状态,同时尝试向订阅者推送',
|
||||||
entity: 'pay',
|
entity: 'pay',
|
||||||
action: ['startPaying', 'succeedPaying', 'startClosing', 'succeedClosing', 'startRefunding',
|
action: ['startPaying', 'succeedPaying', 'startClosing', 'succeedClosing', 'startRefunding',
|
||||||
'refundAll', 'refundPartially'],
|
'refundAll', 'refundPartially'],
|
||||||
when: 'after',
|
when: 'after',
|
||||||
fn: async ({ operation }, context, option) => {
|
fn: async ({ operation }, context, option) => {
|
||||||
const { filter, action } = operation;
|
const { filter, action, id } = operation;
|
||||||
assert(typeof filter.id === 'string');
|
assert(typeof filter.id === 'string');
|
||||||
const [pay] = await context.select('pay', {
|
const [pay] = await context.select('pay', {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -218,6 +219,7 @@ const triggers = [
|
||||||
filter,
|
filter,
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true });
|
||||||
const { orderId, accountId } = pay;
|
const { orderId, accountId } = pay;
|
||||||
|
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
|
||||||
if (orderId) {
|
if (orderId) {
|
||||||
return await changeOrderStateByPay({ id: orderId }, context, option);
|
return await changeOrderStateByPay({ id: orderId }, context, option);
|
||||||
}
|
}
|
||||||
|
|
@ -271,6 +273,7 @@ const triggers = [
|
||||||
entity: 'pay',
|
entity: 'pay',
|
||||||
action: ['close'],
|
action: ['close'],
|
||||||
when: 'before',
|
when: 'before',
|
||||||
|
priority: 99,
|
||||||
fn: async ({ operation }, context, option) => {
|
fn: async ({ operation }, context, option) => {
|
||||||
const { data, filter } = operation;
|
const { data, filter } = operation;
|
||||||
const pays = await context.select('pay', {
|
const pays = await context.select('pay', {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { EntityDict } from '../oak-app-domain';
|
import { EntityDict } from '../oak-app-domain';
|
||||||
import { SelectOpResult } from 'oak-domain/lib/types/Entity';
|
import { OpRecord } from 'oak-domain/lib/types/Entity';
|
||||||
export default function makeException<ED extends EntityDict>(data: {
|
export default function makeException<ED extends EntityDict>(data: {
|
||||||
name: string;
|
name: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
opRecords: SelectOpResult<ED>;
|
opRecords: OpRecord<ED>[];
|
||||||
[A: string]: any;
|
[A: string]: any;
|
||||||
}): import("oak-domain/lib/types/Exception").OakException<ED> | undefined;
|
}): import("oak-domain/lib/types/Exception").OakException<ED> | undefined;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { OpSchema, UpdateOperationData } from "../../oak-app-domain/Pay/Schema";
|
import { OpSchema, UpdateOperationData } from "../../../oak-app-domain/Pay/Schema";
|
||||||
import PayClazz from "../../types/PayClazz";
|
import PayClazz from "../../../types/PayClazz";
|
||||||
import { WechatPayChannel, WechatPayConfig } from "../../types/PayConfig";
|
import { WechatPayChannel, WechatPayConfig } from "../../../types/PayConfig";
|
||||||
import { BRC } from "../../types/RuntimeCxt";
|
import { BRC } from "../../../types/RuntimeCxt";
|
||||||
export default class WechatPay implements PayClazz {
|
export default class WechatPay implements PayClazz {
|
||||||
channel: string;
|
channel: string;
|
||||||
constructor(channel: WechatPayChannel, appId: string, config: WechatPayConfig);
|
constructor(channel: WechatPayChannel, appId: string, config: WechatPayConfig);
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { EntityDict } from "../../oak-app-domain";
|
import { EntityDict } from "../../../oak-app-domain";
|
||||||
import { OpSchema, UpdateOperationData } from "../../oak-app-domain/Pay/Schema";
|
import { OpSchema, UpdateOperationData } from "../../../oak-app-domain/Pay/Schema";
|
||||||
import PayClazz from "../../types/PayClazz";
|
import PayClazz from "../../../types/PayClazz";
|
||||||
import { WechatPayChannel, WechatPayConfig } from "../../types/PayConfig";
|
import { WechatPayChannel, WechatPayConfig } from "../../../types/PayConfig";
|
||||||
import { BRC } from "../../types/RuntimeCxt";
|
import { BRC } from "../../../types/RuntimeCxt";
|
||||||
export declare function registerGetPayStateResult(payState: NonNullable<EntityDict['pay']['OpSchema']['iState']>): void;
|
export declare function registerGetPayStateResult(payState: NonNullable<EntityDict['pay']['OpSchema']['iState']>): void;
|
||||||
export default class WechatPay implements PayClazz {
|
export default class WechatPay implements PayClazz {
|
||||||
channel: string;
|
channel: string;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { 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 { 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";
|
||||||
let _PAY_STATE = '';
|
let _PAY_STATE = '';
|
||||||
export function registerGetPayStateResult(payState) {
|
export function registerGetPayStateResult(payState) {
|
||||||
_PAY_STATE = payState;
|
_PAY_STATE = payState;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import WechatPay from './WechatPay';
|
||||||
|
declare const _default: typeof WechatPay;
|
||||||
|
export default _default;
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import WechatPay from './WechatPay';
|
||||||
|
import WechatPayDebug from './WechatPay.debug';
|
||||||
|
// 微信支付没有沙箱环境,所以staging模式也只能用debug
|
||||||
|
export default process.env.NODE_ENV === 'production' ? WechatPay : WechatPayDebug;
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
export declare const DATA_SUBSCRIBER_KEYS: {};
|
export declare const DATA_SUBSCRIBER_KEYS: {
|
||||||
|
payStateChanged: string;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.DATA_SUBSCRIBER_KEYS = void 0;
|
exports.DATA_SUBSCRIBER_KEYS = void 0;
|
||||||
exports.DATA_SUBSCRIBER_KEYS = {};
|
exports.DATA_SUBSCRIBER_KEYS = {
|
||||||
|
payStateChanged: 'oak-pay-business-psc',
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ const i18ns = [
|
||||||
"label": {
|
"label": {
|
||||||
"option": "渠道"
|
"option": "渠道"
|
||||||
},
|
},
|
||||||
"onChannel": "未配置收费渠道"
|
"noChannel": "未配置收费渠道"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||||
const payClazz_1 = require("../utils/payClazz");
|
const payClazz_1 = require("../utils/payClazz");
|
||||||
const pay_1 = require("../utils/pay");
|
const pay_1 = require("../utils/pay");
|
||||||
const PayConfig_1 = require("../types/PayConfig");
|
const PayConfig_1 = require("../types/PayConfig");
|
||||||
|
const constants_1 = require("../config/constants");
|
||||||
async function changeOrderStateByPay(filter, context, option) {
|
async function changeOrderStateByPay(filter, context, option) {
|
||||||
const orders = await context.select('order', {
|
const orders = await context.select('order', {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -203,13 +204,13 @@ const triggers = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '当pay的状态发生变化时,修改相应的order的状态或者account的状态',
|
name: '当pay的状态发生变化时,修改相应的order的状态或者account的状态,同时尝试向订阅者推送',
|
||||||
entity: 'pay',
|
entity: 'pay',
|
||||||
action: ['startPaying', 'succeedPaying', 'startClosing', 'succeedClosing', 'startRefunding',
|
action: ['startPaying', 'succeedPaying', 'startClosing', 'succeedClosing', 'startRefunding',
|
||||||
'refundAll', 'refundPartially'],
|
'refundAll', 'refundPartially'],
|
||||||
when: 'after',
|
when: 'after',
|
||||||
fn: async ({ operation }, context, option) => {
|
fn: async ({ operation }, context, option) => {
|
||||||
const { filter, action } = operation;
|
const { filter, action, id } = operation;
|
||||||
(0, assert_1.default)(typeof filter.id === 'string');
|
(0, assert_1.default)(typeof filter.id === 'string');
|
||||||
const [pay] = await context.select('pay', {
|
const [pay] = await context.select('pay', {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -221,6 +222,7 @@ const triggers = [
|
||||||
filter,
|
filter,
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true });
|
||||||
const { orderId, accountId } = pay;
|
const { orderId, accountId } = pay;
|
||||||
|
context.saveOperationToEvent(id, `${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
|
||||||
if (orderId) {
|
if (orderId) {
|
||||||
return await changeOrderStateByPay({ id: orderId }, context, option);
|
return await changeOrderStateByPay({ id: orderId }, context, option);
|
||||||
}
|
}
|
||||||
|
|
@ -274,6 +276,7 @@ const triggers = [
|
||||||
entity: 'pay',
|
entity: 'pay',
|
||||||
action: ['close'],
|
action: ['close'],
|
||||||
when: 'before',
|
when: 'before',
|
||||||
|
priority: 99,
|
||||||
fn: async ({ operation }, context, option) => {
|
fn: async ({ operation }, context, option) => {
|
||||||
const { data, filter } = operation;
|
const { data, filter } = operation;
|
||||||
const pays = await context.select('pay', {
|
const pays = await context.select('pay', {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { EntityDict } from '../oak-app-domain';
|
import { EntityDict } from '../oak-app-domain';
|
||||||
import { SelectOpResult } from 'oak-domain/lib/types/Entity';
|
import { OpRecord } from 'oak-domain/lib/types/Entity';
|
||||||
export default function makeException<ED extends EntityDict>(data: {
|
export default function makeException<ED extends EntityDict>(data: {
|
||||||
name: string;
|
name: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
opRecords: SelectOpResult<ED>;
|
opRecords: OpRecord<ED>[];
|
||||||
[A: string]: any;
|
[A: string]: any;
|
||||||
}): import("oak-domain/lib/types/Exception").OakException<ED> | undefined;
|
}): import("oak-domain/lib/types/Exception").OakException<ED> | undefined;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { OpSchema, UpdateOperationData } from "../../oak-app-domain/Pay/Schema";
|
import { OpSchema, UpdateOperationData } from "../../../oak-app-domain/Pay/Schema";
|
||||||
import PayClazz from "../../types/PayClazz";
|
import PayClazz from "../../../types/PayClazz";
|
||||||
import { WechatPayChannel, WechatPayConfig } from "../../types/PayConfig";
|
import { WechatPayChannel, WechatPayConfig } from "../../../types/PayConfig";
|
||||||
import { BRC } from "../../types/RuntimeCxt";
|
import { BRC } from "../../../types/RuntimeCxt";
|
||||||
export default class WechatPay implements PayClazz {
|
export default class WechatPay implements PayClazz {
|
||||||
channel: string;
|
channel: string;
|
||||||
constructor(channel: WechatPayChannel, appId: string, config: WechatPayConfig);
|
constructor(channel: WechatPayChannel, appId: string, config: WechatPayConfig);
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { EntityDict } from "../../oak-app-domain";
|
import { EntityDict } from "../../../oak-app-domain";
|
||||||
import { OpSchema, UpdateOperationData } from "../../oak-app-domain/Pay/Schema";
|
import { OpSchema, UpdateOperationData } from "../../../oak-app-domain/Pay/Schema";
|
||||||
import PayClazz from "../../types/PayClazz";
|
import PayClazz from "../../../types/PayClazz";
|
||||||
import { WechatPayChannel, WechatPayConfig } from "../../types/PayConfig";
|
import { WechatPayChannel, WechatPayConfig } from "../../../types/PayConfig";
|
||||||
import { BRC } from "../../types/RuntimeCxt";
|
import { BRC } from "../../../types/RuntimeCxt";
|
||||||
export declare function registerGetPayStateResult(payState: NonNullable<EntityDict['pay']['OpSchema']['iState']>): void;
|
export declare function registerGetPayStateResult(payState: NonNullable<EntityDict['pay']['OpSchema']['iState']>): void;
|
||||||
export default class WechatPay implements PayClazz {
|
export default class WechatPay implements PayClazz {
|
||||||
channel: string;
|
channel: string;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.registerGetPayStateResult = void 0;
|
exports.registerGetPayStateResult = void 0;
|
||||||
const PayConfig_1 = require("../../types/PayConfig");
|
const PayConfig_1 = require("../../../types/PayConfig");
|
||||||
let _PAY_STATE = '';
|
let _PAY_STATE = '';
|
||||||
function registerGetPayStateResult(payState) {
|
function registerGetPayStateResult(payState) {
|
||||||
_PAY_STATE = payState;
|
_PAY_STATE = payState;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import WechatPay from './WechatPay';
|
||||||
|
declare const _default: typeof WechatPay;
|
||||||
|
export default _default;
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const tslib_1 = require("tslib");
|
||||||
|
const WechatPay_1 = tslib_1.__importDefault(require("./WechatPay"));
|
||||||
|
const WechatPay_debug_1 = tslib_1.__importDefault(require("./WechatPay.debug"));
|
||||||
|
// 微信支付没有沙箱环境,所以staging模式也只能用debug
|
||||||
|
console.log('WechatPay', process.env.NODE_ENV);
|
||||||
|
exports.default = process.env.NODE_ENV === 'production' ? WechatPay_1.default : WechatPay_debug_1.default;
|
||||||
|
|
@ -2,5 +2,5 @@
|
||||||
"label": {
|
"label": {
|
||||||
"option": "渠道"
|
"option": "渠道"
|
||||||
},
|
},
|
||||||
"onChannel": "未配置收费渠道"
|
"noChannel": "未配置收费渠道"
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,8 @@ import { CentToString } from "oak-domain/lib/utils/money";
|
||||||
import { PAY_CHANNEL_OFFLINE_NAME, PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_WECHAT_APP_NAME,
|
import { PAY_CHANNEL_OFFLINE_NAME, PAY_CHANNEL_ACCOUNT_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
|
PAY_CHANNEL_WECHAT_H5_NAME, PAY_CHANNEL_WECHAT_JS_NAME, PAY_CHANNEL_WECHAT_MP_NAME, PAY_CHANNEL_WECHAT_NATIVE_NAME
|
||||||
} from "../../../types/PayConfig";
|
} from "../../../types/PayConfig";
|
||||||
import { fullPayProjection } from "../../../utils/pay";
|
import { DATA_SUBSCRIBER_KEYS } from "../../../config/constants";
|
||||||
|
import assert from "assert";
|
||||||
|
|
||||||
export default OakComponent({
|
export default OakComponent({
|
||||||
entity: 'pay',
|
entity: 'pay',
|
||||||
|
|
@ -116,5 +117,17 @@ export default OakComponent({
|
||||||
goBack() {
|
goBack() {
|
||||||
this.navigateBack();
|
this.navigateBack();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
lifetimes: {
|
||||||
|
ready() {
|
||||||
|
const { oakId } = this.props;
|
||||||
|
assert(typeof oakId === 'string');
|
||||||
|
this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
|
||||||
|
},
|
||||||
|
detached() {
|
||||||
|
const { oakId } = this.props;
|
||||||
|
assert(typeof oakId === 'string');
|
||||||
|
this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -13,6 +13,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.paid {
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.text {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.oper {
|
.oper {
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
width: 60%;
|
width: 60%;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Input, Space, Tag, Card, QRCode, Form, Descriptions, Typography, Alert, Select, Button, Modal } from 'antd';
|
import { Input, Space, Tag, Card, QRCode, Form, Descriptions, Typography, Alert, Select, Button, Modal } from 'antd';
|
||||||
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
|
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
|
||||||
|
import { CheckCircleOutlined } from '@ant-design/icons';
|
||||||
import { EntityDict } from '@project/oak-app-domain';
|
import { EntityDict } from '@project/oak-app-domain';
|
||||||
import { CentToString } from 'oak-domain/lib/utils/money';
|
import { CentToString } from 'oak-domain/lib/utils/money';
|
||||||
import Styles from './web.pc.module.less';
|
import Styles from './web.pc.module.less';
|
||||||
|
|
@ -92,6 +93,22 @@ function RenderWechatPay(props: {
|
||||||
}) {
|
}) {
|
||||||
const { pay, t } = props;
|
const { pay, t } = props;
|
||||||
const { externalId, channel, timeoutAt, iState } = pay;
|
const { externalId, channel, timeoutAt, iState } = pay;
|
||||||
|
if (iState === 'paid') {
|
||||||
|
return (
|
||||||
|
<div className={Styles.paid}>
|
||||||
|
<CheckCircleOutlined
|
||||||
|
style={{
|
||||||
|
fontSize: 72,
|
||||||
|
color: 'green',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className={Styles.text}>
|
||||||
|
{t('success')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
switch (channel) {
|
switch (channel) {
|
||||||
case PAY_CHANNEL_WECHAT_NATIVE_NAME: {
|
case PAY_CHANNEL_WECHAT_NATIVE_NAME: {
|
||||||
if (iState! === 'paying') {
|
if (iState! === 'paying') {
|
||||||
|
|
|
||||||
|
|
@ -101,11 +101,11 @@ function RenderWechatPay(props: {
|
||||||
return (
|
return (
|
||||||
<div className={Styles.paid}>
|
<div className={Styles.paid}>
|
||||||
<CheckCircleOutline
|
<CheckCircleOutline
|
||||||
fontSize={36}
|
fontSize={72}
|
||||||
fontWeight="bold"
|
fontWeight="bold"
|
||||||
color="green"
|
color="green"
|
||||||
/>
|
/>
|
||||||
<div className='text'>
|
<div className={Styles.text}>
|
||||||
{t('success')}
|
{t('success')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
export const DATA_SUBSCRIBER_KEYS = {};
|
export const DATA_SUBSCRIBER_KEYS = {
|
||||||
|
payStateChanged: 'oak-pay-business-psc',
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ const i18ns: I18n[] = [
|
||||||
"label": {
|
"label": {
|
||||||
"option": "渠道"
|
"option": "渠道"
|
||||||
},
|
},
|
||||||
"onChannel": "未配置收费渠道"
|
"noChannel": "未配置收费渠道"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { OperateOption } from 'oak-domain/lib/types';
|
||||||
import { getPayClazz } from '@project/utils/payClazz';
|
import { getPayClazz } from '@project/utils/payClazz';
|
||||||
import { fullPayProjection } from '@project/utils/pay';
|
import { fullPayProjection } from '@project/utils/pay';
|
||||||
import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME } from '@project/types/PayConfig';
|
import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME } from '@project/types/PayConfig';
|
||||||
|
import { DATA_SUBSCRIBER_KEYS } from '@project/config/constants';
|
||||||
|
|
||||||
async function changeOrderStateByPay(
|
async function changeOrderStateByPay(
|
||||||
filter: NonNullable<EntityDict['order']['Update']['filter']>,
|
filter: NonNullable<EntityDict['order']['Update']['filter']>,
|
||||||
|
|
@ -216,13 +217,13 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
|
||||||
},
|
},
|
||||||
} as CreateTriggerInTxn<EntityDict, 'pay', BRC>,
|
} as CreateTriggerInTxn<EntityDict, 'pay', BRC>,
|
||||||
{
|
{
|
||||||
name: '当pay的状态发生变化时,修改相应的order的状态或者account的状态',
|
name: '当pay的状态发生变化时,修改相应的order的状态或者account的状态,同时尝试向订阅者推送',
|
||||||
entity: 'pay',
|
entity: 'pay',
|
||||||
action: ['startPaying', 'succeedPaying', 'startClosing', 'succeedClosing', 'startRefunding',
|
action: ['startPaying', 'succeedPaying', 'startClosing', 'succeedClosing', 'startRefunding',
|
||||||
'refundAll', 'refundPartially'],
|
'refundAll', 'refundPartially'],
|
||||||
when: 'after',
|
when: 'after',
|
||||||
fn: async ({ operation }, context, option) => {
|
fn: async ({ operation }, context, option) => {
|
||||||
const { filter, action } = operation as EntityDict['pay']['Update'];
|
const { filter, action, id } = operation as EntityDict['pay']['Update'];
|
||||||
assert(typeof filter!.id === 'string');
|
assert(typeof filter!.id === 'string');
|
||||||
|
|
||||||
const [pay] = await context.select('pay', {
|
const [pay] = await context.select('pay', {
|
||||||
|
|
@ -236,6 +237,7 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true });
|
||||||
const { orderId, accountId } = pay;
|
const { orderId, accountId } = pay;
|
||||||
|
|
||||||
|
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter!.id!}`);
|
||||||
if (orderId) {
|
if (orderId) {
|
||||||
return await changeOrderStateByPay({ id: orderId }, context, option);
|
return await changeOrderStateByPay({ id: orderId }, context, option);
|
||||||
}
|
}
|
||||||
|
|
@ -290,6 +292,7 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
|
||||||
entity: 'pay',
|
entity: 'pay',
|
||||||
action: ['close'],
|
action: ['close'],
|
||||||
when: 'before',
|
when: 'before',
|
||||||
|
priority: 99,
|
||||||
fn: async ({ operation }, context, option) => {
|
fn: async ({ operation }, context, option) => {
|
||||||
const { data, filter } = operation;
|
const { data, filter } = operation;
|
||||||
const pays = await context.select('pay', {
|
const pays = await context.select('pay', {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { EntityDict } from '@project/oak-app-domain';
|
import { EntityDict } from '@project/oak-app-domain';
|
||||||
import { SelectOpResult } from 'oak-domain/lib/types/Entity';
|
import { SelectOpResult, OpRecord } from 'oak-domain/lib/types/Entity';
|
||||||
import { makeException as makeDomainException } from 'oak-domain/lib/types/Exception';
|
import { makeException as makeDomainException } from 'oak-domain/lib/types/Exception';
|
||||||
import { makeException as makeOgb0Exception } from "oak-general-business";
|
import { makeException as makeOgb0Exception } from "oak-general-business";
|
||||||
export default function makeException<ED extends EntityDict>(data: {
|
export default function makeException<ED extends EntityDict>(data: {
|
||||||
name: string;
|
name: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
opRecords: SelectOpResult<ED>;
|
opRecords: OpRecord<ED>[];
|
||||||
[A: string]: any;
|
[A: string]: any;
|
||||||
}) {
|
}) {
|
||||||
const e = makeDomainException<ED>(data) || makeOgb0Exception<ED>(data);
|
const e = makeDomainException<ED>(data) || makeOgb0Exception<ED>(data);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { EntityDict } from "../../oak-app-domain";
|
import { EntityDict } from "../../../oak-app-domain";
|
||||||
import { OpSchema, UpdateOperationData } from "../../oak-app-domain/Pay/Schema";
|
import { OpSchema, UpdateOperationData } from "../../../oak-app-domain/Pay/Schema";
|
||||||
import PayClazz from "../../types/PayClazz";
|
import PayClazz from "../../../types/PayClazz";
|
||||||
import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_WECHAT_APP_NAME, PAY_CHANNEL_WECHAT_H5_NAME, PAY_CHANNEL_WECHAT_JS_NAME,
|
import { PAY_CHANNEL_ACCOUNT_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, WechatPayChannel, WechatPayConfig } from "../../types/PayConfig";
|
PAY_CHANNEL_WECHAT_MP_NAME, PAY_CHANNEL_WECHAT_NATIVE_NAME, WechatPayChannel, WechatPayConfig } from "../../../types/PayConfig";
|
||||||
import { BRC } from "../../types/RuntimeCxt";
|
import { BRC } from "../../../types/RuntimeCxt";
|
||||||
|
|
||||||
let _PAY_STATE = '';
|
let _PAY_STATE = '';
|
||||||
export function registerGetPayStateResult(payState: NonNullable<EntityDict['pay']['OpSchema']['iState']>) {
|
export function registerGetPayStateResult(payState: NonNullable<EntityDict['pay']['OpSchema']['iState']>) {
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import WechatPay from './WechatPay';
|
||||||
|
import WechatPayDebug from './WechatPay.debug';
|
||||||
|
|
||||||
|
// 微信支付没有沙箱环境,所以staging模式也只能用debug
|
||||||
|
export default process.env.NODE_ENV === 'production' ? WechatPay : WechatPayDebug;
|
||||||
Loading…
Reference in New Issue