Commit 5a25beb0 authored by Bill's avatar Bill

feat: 添加平台结算优惠券结算,但是没有接口

parent 80cdd51f
import EyePreview from '@/components/EyePreview';
// import StatusTag from '../components/StatusTag';
// import { TO_BE_RECONCILED, TO_BE_PAY, TO_BE_COLLECTED, COMPLETED, PRODUCT_NOTICE_SETTLEMENT_DETAIL, LOGISTICS_DETAIL, ORDER_DETAIL, CONTRACT_FUND_BILL } from '../common/constants';
import { priceFormat } from '@/utils/numberFomat'
import StatusTag, { STATUS_TYPE } from '@/components/StatusTag';
import React, { useMemo, useState } from 'react';
// import { payStatus } from '../common';
import { COMPLETED, TO_BE_COLLECTED, TO_BE_PAY, TO_BE_RECONCILED, IS_UNIVERSAL_PAY } from '@/pages/balance/common/constants';
import { useCallback } from 'react';
import { GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementResponseDetail } from '@/services/SettleV2Api';
import { getIntl } from 'umi';
import { getAuth } from '@/utils/auth';
import { payStatus } from '@/pages/balance/common';
import { STATUS_TEXT } from '@/constants/balance';
const intl = getIntl();
type ModalsType = {
/** 待对账 */
reconciledComfirm: boolean,
/** 确认付款凭证 */
confirmCompletePaymentStatus: boolean,
/** 查看付款 */
viewPay: boolean,
/** 查看通联支付 */
viewUniversalPay: boolean,
}
function useHandleSettlementList() {
const auth = getAuth()
const [itemInfo, setItemInfo] = useState<GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementResponseDetail | null>(null)
const [modals, setModals] = useState<ModalsType>({
viewPay: false,
viewUniversalPay: false,
reconciledComfirm: false,
confirmCompletePaymentStatus: false
})
/** 这里不对其他key 做限制,即可存在多个为true的时候 */
const handleOpen = useCallback((key: keyof ModalsType) => {
setModals((prev) => ({
...prev,
[key]: true
}))
}, [])
const handleClose = useCallback((key: keyof ModalsType) => {
setModals((prev) => ({
...prev,
[key]: false,
// unionPay: false
}))
}, [])
const handleAction = async (record: GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementResponseDetail, key: keyof ModalsType) => {
setItemInfo(record);
handleOpen(key);
}
const columns = [
{
title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.settlementNo' }),
dataIndex: 'settlementNo',
render: (text, record) => {
return (
<EyePreview
url={`/memberCenter/balance/platformSettlement/integral/detail?id=${record.id}`}
>{record.settlementNo}</EyePreview>
)
}
},
{ title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.settlementDate' }), dataIndex: 'settlementDate' },
{ title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.settlementWayName' }), dataIndex: 'settlementWayName' },
{ title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.totalCount' }), dataIndex: 'totalCount' },
// { title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.score' }), dataIndex: 'score' },
// {
// title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.ratio' }),
// dataIndex: 'ratio',
// render: (text, record) => {
// return (record.ratio + "%");
// }
// },
{ title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.amount' }), dataIndex: 'amount' },
{ title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.settlementTime' }), dataIndex: 'settlementTime' },
{ title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.payWayName' }), dataIndex: 'payWayName' },
{ title: '预计付款时间', dataIndex: 'payTime' },
{ title: '实际付款时间', dataIndex: 'actualPayTime' },
{
title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.status' }), dataIndex: 'status',
filters: payStatus,
onFilter: (value: number, record: any) => record.status == value,
render: (text, record) => {
return (
// <StatusTag status={record.status || 1} />
<StatusTag type={STATUS_TYPE[record.status] as 'success'} title={STATUS_TEXT[record.status]} />
)
}
},
{
title: intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.operation' }),
render: (text, record) => {
/** 通联支付 */
const isUniversalPay = record.payWay === IS_UNIVERSAL_PAY
// 待收账款结算
if (record.status === TO_BE_RECONCILED) {
return <a onClick={() => handleAction(record, 'reconciledComfirm')}>{intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.operation.button.1' })}</a>
}
if (record.status === TO_BE_COLLECTED) {
return <a onClick={() => handleAction(record, 'confirmCompletePaymentStatus')}>{intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.operation.button.2' })}</a>
}
if (record.status === COMPLETED) {
return <a onClick={() => handleAction(record, isUniversalPay ? 'viewUniversalPay' : 'viewPay')}>{intl.formatMessage({ id: 'balance.platformSettlement.integral.columns.operation.button.3' })}</a>
}
}
}
]
const cacheItemInfo = useMemo(() => itemInfo, [itemInfo])
return {
columns,
handleOpen,
handleClose,
itemInfo: cacheItemInfo,
modals,
}
}
export default useHandleSettlementList
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useIntl } from 'umi'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Card, DatePicker, Modal, Space, Button } from 'antd';
import NiceForm from '@/components/NiceForm';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { createFormActions } from '@formily/antd';
import { StandardTable } from 'god';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { schema } from './schema/index';
import { fetchOptions } from '../../common';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import Voucher from '../../components/Voucher';
import ConfirmAccount from '../../components/ConfirmAccount';
import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable';
import { getSettleAccountsCommonGetSettlementStatus, getSettleAccountsPlatformScoreSettlementGetReceivablePayProve, getSettleAccountsPlatformScoreSettlementPageReceivableSettlement, GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementRequest, postSettleAccountsPlatformScoreSettlementConfirmAccountComplete, postSettleAccountsPlatformScoreSettlementConfirmPayProve } from '@/services/SettleV2Api';
import useHandleSettlementList from './hooks/useHandleSettlementList';
import ViewUniversalPay from '../../components/ViewUniversalPay';
const formActions = createFormActions();
const CouponSettlement: React.FC = () => {
const intl = useIntl();
const { columns, handleOpen, handleClose, itemInfo, modals} = useHandleSettlementList();
const ref = useRef<any>({})
const [files, setFiles] = useState([]);
const { searchData, formatInitialValue, clear } = useSetSearchValueInTable();
const universalPayInfo = useMemo(() => ({
name: itemInfo?.settlementName,
amount: itemInfo?.amount,
statusName: itemInfo?.statusName,
payWayName: '平台',
settlementDate: itemInfo?.settlementDate
}), [itemInfo])
const fetchListData = async (params: GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementRequest) => {
const searchParams = {
...searchData,
...params,
}
const postData = {
...searchParams,
status: searchParams.status || '0',
}
// /settle/accounts/platform/score/settlement/pageReceivableSettlement
const { data } = await getSettleAccountsPlatformScoreSettlementPageReceivableSettlement(postData);
return data
}
/**
* 确认对账
*/
const handleConfirm = async (params: { id: number }) => {
const { code } = await postSettleAccountsPlatformScoreSettlementConfirmAccountComplete({ settlementId: params.id })
if (code === 1000) {
// reconciliationOnCancel();
handleClose('reconciledComfirm')
formActions.submit();
}
}
/**
* 确认付款凭证
*/
const handleConfirmPayStatus = async (params: { status: 0 | 1, id: number }) => {
const { code } = await postSettleAccountsPlatformScoreSettlementConfirmPayProve({ id: params.id, status: params.status });
if (code) {
// confirmPayOnCancel();
handleClose('confirmCompletePaymentStatus')
formActions.submit();
}
}
const fetchVouchers = useCallback(async (id: number) => {
const { code, data } = await getSettleAccountsPlatformScoreSettlementGetReceivablePayProve({ id: id.toString() })
if (code === 1000) {
setFiles(data);
}
}, [])
useEffect(() => {
if (itemInfo !== null && (itemInfo.status === 4 || itemInfo.status === 3)) {
fetchVouchers(itemInfo.id);
}
}, [itemInfo])
/**
* 搜索
*/
const handleSearch = (values: any) => {
const format = 'YYYY-MM-DD'
const startTime = values.startTime?.format(format);
const endTime = values.endTime ? values.endTime.format(format) + " 23:59:59" : "";
ref.current.reload({ ...values, startTime, endTime });
}
return (
<PageHeaderWrapper>
<Card>
<StandardTable
tableProps={{
rowKey: 'id',
}}
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
<NiceForm
actions={formActions}
components={{ DatePicker }}
expressionScope={{}}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, 'megaLayout.settlementNo', FORM_FILTER_PATH);
useAsyncSelect(
['status'],
fetchOptions(getSettleAccountsCommonGetSettlementStatus),
);
}}
schema={schema}
onSubmit={handleSearch}
onReset={() => {
clear()
// formActions.setFieldValue('startTime', null);
// formActions.setFieldValue('endTime', null);
}}
{...formatInitialValue}
/>
}
/>
</Card>
<Modal
width={400}
title={intl.formatMessage({ id: 'balance.platformSettlement.integral.modal.1.title' })}
visible={modals.reconciledComfirm}
onCancel={() => handleClose('reconciledComfirm')}
onOk={() => handleConfirm({ id: itemInfo?.id })}
>
<ConfirmAccount settlementDate={itemInfo?.settlementDate} payName={'平台'} />
</Modal>
<Modal
width={548}
title={intl.formatMessage({ id: 'balance.platformSettlement.integral.modal.2.title' })}
onCancel={() => handleClose('viewPay')}
visible={modals.viewPay}
footer={null}
>
<Voucher files={files} />
</Modal>
<Modal
width={548}
title={intl.formatMessage({ id: 'balance.platformSettlement.integral.modal.3.title' })}
onCancel={() => handleClose('confirmCompletePaymentStatus')}
visible={modals.confirmCompletePaymentStatus}
footer={(
<Space>
<Button onClick={() => handleClose('confirmCompletePaymentStatus')}>{intl.formatMessage({ id: 'balance.platformSettlement.integral.modal.3.button.1' })}</Button>
<Button
danger
onClick={() => handleConfirmPayStatus({ status: 0, id: itemInfo.id })}
>
{intl.formatMessage({ id: 'balance.platformSettlement.integral.modal.3.button.2' })}
</Button>
<Button
type={"primary"}
onClick={() => handleConfirmPayStatus({ status: 1, id: itemInfo.id })}
>
{intl.formatMessage({ id: 'balance.platformSettlement.integral.modal.3.button.3' })}
</Button>
</Space>
)}
>
<Voucher files={files} />
</Modal>
<ViewUniversalPay
visible={modals['viewUniversalPay']}
balanceInfo={universalPayInfo}
onClose={() => handleClose('viewUniversalPay')}
onOk={() => handleClose('viewUniversalPay')}
/>
</PageHeaderWrapper>
)
}
export default CouponSettlement
/*
* @Author: Bill
* @Date: 2020-10-21 16:24:01
* @Description: 平台积分结算 schema集合
*/
import { getIntl } from 'umi'
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ISchema } from '@formily/antd';
import { orderTime, payTime } from '../../../common';
const intl = getIntl();
/**
* 平台积分管理 列表页
*/
export const schema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
settlementNo: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.schema.settlementNo' }),
align: 'flex-left',
// tip: '输入通知单号、通知单摘要进行搜索',
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
justifyContent: "flex-start",
},
colStyle: {
marginRight: 20,
},
},
properties: {
"[startTime, endTime]": {
type: 'object',
"x-component": 'RangePicker',
'x-component-props': {
allowClear: true,
placeholder: [intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.schema.startTime' }), intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.schema.endTime' })],
style: {
minWidth: "320px"
}
}
},
// startTime: {
// type: 'string',
// 'x-component': 'DatePicker',
// 'x-component-props': {
// allowClear: true,
// placeholder: '结算日期(开始时间)'
// }
// },
// endTime: {
// type: 'string',
// 'x-component': 'DatePicker',
// 'x-component-props': {
// allowClear: true,
// placeholder: '结算日期(结束时间)'
// }
// },
status: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.schema.status' }),
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.schema.submit' }),
},
},
},
},
},
},
},
};
/**
* 平台积分结算- 平台积分结算明细
*/
export const detailSchema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
topLayout: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
},
properties: {
ctl: {
type: 'object',
'x-component': 'Children',
'x-component-props': {
children: '{{exportBtn}}',
},
},
orderNo: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.detailSchema.orderNo' }),
},
},
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
colStyle: {
marginLeft: 20,
},
},
properties: {
orderAbstract: {
type: 'string',
'x-component-props': {
placeholder: intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.detailSchema.orderAbstract' })
}
},
orderTime: {
type: 'string',
enum: orderTime,
'x-component-props': {
placeholder: intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.detailSchema.orderTime' }),
allowClear: true,
},
},
payTime: {
type: 'string',
enum: payTime,
'x-component-props': {
placeholder: intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.detailSchema.payTime' }),
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: intl.formatMessage({ id: 'balance.platformSettlement.integral.schema.detailSchema.submit' }),
},
},
},
},
},
},
},
};
/*
* @Author: Bill
* @Date: 2020-10-20 10:43:33
* @Description: 积分结算列表
*/
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useIntl } from 'umi'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
......@@ -14,16 +8,10 @@ import { createFormActions } from '@formily/antd';
import { StandardTable } from 'god';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { schema } from './schema/index';
import StatusTag, { STATUS_TYPE } from '@/components/StatusTag';
import { payStatus } from '../../common';
import EyePreview from '@/components/EyePreview';
import { fetchOptions } from '../../common';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import useFetchColumns from '../../hooks/useFetchColumns';
import Voucher from '../../components/Voucher';
import ConfirmAccount from '../../components/ConfirmAccount';
import { COMPLETED, TO_BE_COLLECTED, TO_BE_RECONCILED } from '../../common/constants';
import { STATUS_TEXT } from '@/constants/balance';
import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable';
import { getSettleAccountsCommonGetSettlementStatus, getSettleAccountsPlatformScoreSettlementGetReceivablePayProve, getSettleAccountsPlatformScoreSettlementPageReceivableSettlement, GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementRequest, postSettleAccountsPlatformScoreSettlementConfirmAccountComplete, postSettleAccountsPlatformScoreSettlementConfirmPayProve } from '@/services/SettleV2Api';
import useHandleSettlementList from './hooks/useHandleSettlementList';
......@@ -44,7 +32,10 @@ const Integral: React.FC = () => {
settlementDate: itemInfo?.settlementDate
}), [itemInfo])
/**
* TODO 需要换成优惠券结算
* 确认对账
*/
const fetchListData = async (params: GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementRequest) => {
const searchParams = {
...searchData,
......@@ -60,8 +51,9 @@ const Integral: React.FC = () => {
}
/**
* 确认对账
*/
* TODO 需要换成优惠券结算
* 确认对账
*/
const handleConfirm = async (params: { id: number }) => {
const { code } = await postSettleAccountsPlatformScoreSettlementConfirmAccountComplete({ settlementId: params.id })
if (code === 1000) {
......@@ -72,8 +64,9 @@ const Integral: React.FC = () => {
}
/**
* 确认付款凭证
*/
* 确认付款凭证
* TODO 需要换成优惠券结算
*/
const handleConfirmPayStatus = async (params: { status: 0 | 1, id: number }) => {
const { code } = await postSettleAccountsPlatformScoreSettlementConfirmPayProve({ id: params.id, status: params.status });
if (code) {
......@@ -83,6 +76,9 @@ const Integral: React.FC = () => {
}
}
/**
* TODO 需要换成优惠券结算
*/
const fetchVouchers = useCallback(async (id: number) => {
const { code, data } = await getSettleAccountsPlatformScoreSettlementGetReceivablePayProve({ id: id.toString() })
if (code === 1000) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment