Commit 4c8c25d0 authored by Bill's avatar Bill

feat: 平台优惠券结算

parent 8b1ce999
......@@ -32,7 +32,7 @@ export interface SiteInfo {
name: string;
logo: string;
siteUrl: string;
symbol: string;
symbol?: any;
}
export interface Global {
......
......@@ -108,7 +108,7 @@ const ActiveItem: React.FC<Iprops> = (props: Iprops) => {
)
}
{
[PENDIGN_ONLINE, OFFLINE].includes(status) && (
[PENDIGN_ONLINE, IN_PROGRESS, ONLINE, OFFLINE].includes(status) && (
// <Link to={`/memberCenter/marketingAbility/activityPages/management/edit?id=${id}`}>
<Link to={`${environment === WEB ? WEB_FIXTURE_LINK : APP_FIXTURE_LINK}?id=${id}`}>
{/* <Button icon={<EditOutlined />}></Button> */}
......
......@@ -12,15 +12,15 @@ type HeadersType = {
[key: string]: any,
}
type Ires = {
type Ires<T> = {
code: number,
data: { [key: string]: any },
data: T,
message: string
}
function useInitialValue<T, P>(api: (params: P, headers?: HeadersType) => Promise<T & Ires>, params: P, headers?: HeadersType): { loading: boolean, initialValue: T, refresh: (params: P) => void} {
function useInitialValue<T, P>(api: (params: P, headers?: HeadersType) => Promise<Ires<T>>, params: P, headers?: HeadersType): { loading: boolean, initialValue: T, refresh: (params: P) => void} {
const [loading, setLoading] = useState<boolean>(false);
const [initialValue, setInitialValue] = useState<null | Ires["data"]>(null);
const [initialValue, setInitialValue] = useState<null | T>(null);
const fetchData = useCallback(async (params) => {
setLoading(true)
......
......@@ -27,7 +27,6 @@ const UploadVoucherModal: React.FC<UploadVocherProps> = (props) => {
const [fileList, setFileList] = useState<FileType[]>([]);
const [isUploading, setIsUploading] = useState(false)
const getFileList = (list: FileType[], status) => {
if(status === 'done') {
setFileList(list);
......@@ -69,7 +68,7 @@ const UploadVoucherModal: React.FC<UploadVocherProps> = (props) => {
</Space>
)}
>
<UploadPayVoucher roleId={roleId} id={settlementId} getFileList={getFileList} />
<UploadPayVoucher roleId={roleId!} id={settlementId!} getFileList={getFileList} />
</Modal>
)
......
import { priceFormat } from '@/utils/numberFomat';
import { ColumnsType } from 'antd/es/table';
export const columns: ColumnsType<any> = [
{ title: '单据号', dataIndex: 'orderNo'},
{ title: '单据摘要', dataIndex: 'orderAbstract'},
{ title: '单据类型', dataIndex: 'settlementOrderTypeName'},
{ title: '单据时间', dataIndex: 'orderTime'},
{
title: '单据总额',
dataIndex: 'orderAmount',
render: (text, record) => `¥${priceFormat(text)}`
},
{
title: '优惠劵金额',
dataIndex: 'couponAmount',
render: (text, record) => `¥${priceFormat(text)}`
},
{ title: '优惠劵劵码', dataIndex: 'couponNo'},
{ title: '支付时间', dataIndex: 'payTime'},
{
title: '本期结算金额',
dataIndex: 'settlementAmount',
render: (text, record) => `¥${priceFormat(text)}`
},
]
import React, { useRef, useMemo } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Card, Button, message} from 'antd';
import NiceForm from '@/components/NiceForm';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { createFormActions } from '@formily/antd';
import { StandardTable } from '@linkseeks/god';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { detailSchema } from './schema'
import { usePageStatus } from '@/hooks/usePageStatus';
import useInitialValue from '@/pages/productionNotice/common/hooks/useInitialValue';
import {
getSettleAccountsPlatformCouponSettlementGetPayableDetail,
GetSettleAccountsPlatformCouponSettlementGetPayableDetailRequest,
GetSettleAccountsPlatformCouponSettlementGetPayableDetailResponse,
getSettleAccountsPlatformCouponSettlementPagePayableSettlementDetail,
GetSettleAccountsPlatformCouponSettlementPagePayableSettlementDetailRequest,
getSettleAccountsPlatformCouponSettlementPayableExport,
} from '@/services/SettleV2Api';
import { numFormat, priceFormat } from '@/utils/numberFomat';
import CustomizeColumn from '@/components/CustomizeColumn';
import { columns } from '../common/columns';
import moment from 'moment';
const formActions = createFormActions();
const ScoreInfo: React.FC = () => {
const ref = useRef<any>({});
const { id } = usePageStatus();
const { loading, initialValue }= useInitialValue<GetSettleAccountsPlatformCouponSettlementGetPayableDetailResponse, GetSettleAccountsPlatformCouponSettlementGetPayableDetailRequest>(getSettleAccountsPlatformCouponSettlementGetPayableDetail, { id: id.toString() })
// const { formatData } = useFormatSearch();
const fetchListData = async (params: GetSettleAccountsPlatformCouponSettlementPagePayableSettlementDetailRequest) => {
const postData = {
...params,
settlementId: id,
}
const res = await getSettleAccountsPlatformCouponSettlementPagePayableSettlementDetail(postData as any)
return res.data
}
/**
* 搜索
*/
const handleSearch = (values: GetSettleAccountsPlatformCouponSettlementPagePayableSettlementDetailRequest) => {
// const postData = formatData(values);
ref.current.reload(values);
}
const basicInfoColumns = useMemo(() => {
return [
{
title: '结算方',
value: initialValue?.settlementName
},
{
title: '结算日期',
value: initialValue?.settlementDate
},
{
title: '结算单数',
value: initialValue && numFormat(initialValue.totalCount)
},
{
title: "结算状态",
value: initialValue?.statusName
},
{
title: "结算方式",
value: initialValue?.settlementWayName
},
{
title: "结算金额",
value: `${initialValue && priceFormat(initialValue?.amount)}`
}
]
}, [initialValue])
const handleExport = async () => {
const loadingMsg = message.loading('正在导出', 0)
const { data } = await getSettleAccountsPlatformCouponSettlementPayableExport(
{ settlementId: id } as any,
{ responseType: 'blob', getResponse: true }
);
loadingMsg();
let blob = new Blob([data as any]);
let downloadFilename = `${moment().format('YYYY-MM-DD HH:mm:ss')}.xlsx`;//设置导出的文件名
createDownloadLink(blob, downloadFilename)
}
const createDownloadLink = (blob: Blob, fileName: string) => {
let url = window.URL.createObjectURL(blob);
let downloadElement = document.createElement("a");
downloadElement.style.display = "none";
downloadElement.href = url;
downloadElement.download = fileName;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement);
window.URL.revokeObjectURL(url);
}
return (
<PageHeaderWrapper
title={`结算单号:${initialValue?.settlementNo}`}
>
<CustomizeColumn data={basicInfoColumns} title="" column={3} />
<Card style={{marginTop: '12px'}}>
<StandardTable
tableProps={{
rowKey: record => (record.orderNo),
}}
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
<NiceForm
actions={formActions}
components={{
ExportBtn: () => {
return (
<div>
<Button onClick={handleExport}>导出</Button>
</div>
)
}
}}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, 'megaLayout.topLayout.orderNo', FORM_FILTER_PATH);
}}
schema={detailSchema}
onSubmit={handleSearch}
/>
}
/>
</Card>
</PageHeaderWrapper>
)
}
export default ScoreInfo
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ISchema } from '@formily/antd';
const commonTimeList = [
{ label: '今天', value: 1},
{ label: '一周内', value: 2},
{ label: '一个月内', value: 3},
{ label: '三个月内', value: 4},
{ label: '六个月内', value: 5},
{ label: '一年内', value: 6 },
{ label: '一年前', value: 7}
];
const orderTime = [{label: '下单时间(所有)', value: 0}].concat(commonTimeList);
const payTime = [{label: '支付时间(所有)', value: 0}].concat(commonTimeList);
/**
* 应收账款管理--物流单结算明细详情, 生产通知单结算明细
*/
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': 'ExportBtn',
},
orderNo: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索(单据号)',
},
},
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
colStyle: {
marginLeft: 20,
},
},
properties: {
orderTime: {
type: 'daterange',
'x-component-props': {
placeholder: ['下单开始时间', '下单结束时间'],
allowClear: true,
},
},
payTime: {
type: 'daterange',
'x-component-props': {
placeholder: ['支付开始时间', '支付结束时间'],
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
},
},
},
},
},
},
},
};
\ No newline at end of file
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Card, Button, Modal, DatePicker, Tag, Space } from 'antd';
import NiceForm from '@/components/NiceForm';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ISchema, createFormActions } from '@formily/antd';
import { StandardTable } from '@linkseeks/god';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { schema } from './schema';
import { Moment } from 'moment';
import moment from 'moment';
import UploadVoucherModal from '../../components/UploadVoucherModal';
import Voucher from '../../components/Voucher';
import {
getSettleAccountsPlatformCouponSettlementGetPayablePayProve,
getSettleAccountsPlatformCouponSettlementPagePayableSettlement,
getSettleAccountsPlatformScoreSettlementGetPayablePayProve,
getSettleAccountsPlatformScoreSettlementPagePayableSettlement,
postSettleAccountsPlatformCouponSettlementAllInPay,
postSettleAccountsPlatformCouponSettlementCouponManualSettlement,
postSettleAccountsPlatformCouponSettlementPay,
postSettleAccountsPlatformScoreSettlementAllInPay,
postSettleAccountsPlatformScoreSettlementPay
} from '@/services/SettleV2Api';
import { postReportSettlementScoreManualSettlement } from '@/services/ReportV2Api';
import OtherPayModal from '../../components/OtherPayModal';
import useHandleSettlementList from './useHandleSettlementList';
import ViewUniversalPay from '../../components/ViewUniversalPay';
interface SearchParams {
settlementName?: string,
payName?: string,
isSettlement: number,
startTime?: Moment,
endTime?: Moment,
orderType?: number,
status?: number,
current: number,
pageSize: number,
}
const { RangePicker } = DatePicker
const formActions = createFormActions();
const SCORE_PAYER = 6;
const SettlementList = () => {
const [files, setFiles] = useState<any>([]);
const ref = useRef<any>({})
const [confirmUniversalPayLoading, setConfirmUniversalPayLoading] = useState<boolean>(false);
const { itemInfo, columns, handleClose, modals } = useHandleSettlementList()
const universalPayInfo1 = useMemo(() => ({
name: itemInfo?.settlementName || '',
amount: itemInfo?.amount || 0,
statusName: itemInfo?.statusName || '',
payWayName: '通联支付',
settlementDate: itemInfo?.settlementDate || ''
}), [itemInfo])
const universalPayInfoData = useMemo(() => {
return {
name: itemInfo?.settlementName || '',
amount: itemInfo?.amount || 0,
payMethods: '通联支付'
}
}, [itemInfo])
const fetchListData = async (params) => {
// /settle/accounts/platform/settlement/pagePayableSettlement
const searchData = {
...params,
status: typeof params.status == 'undefined' ? 0 : params.status,
}
const res = await getSettleAccountsPlatformCouponSettlementPagePayableSettlement(searchData)
return res.data;
}
/**
* @通联支付确认付款
*/
const handleUniversalPay = async () => {
console.log(itemInfo);
try {
setConfirmUniversalPayLoading(true)
const { code } = await postSettleAccountsPlatformCouponSettlementAllInPay({id: itemInfo?.id!})
if (code === 1000) {
handleClose('universalPay')
formActions.submit();
}
} finally {
setConfirmUniversalPayLoading(false)
}
}
/**
*
* @param params 手动结算
*/
const handleManualsettlement = (id: number): void => {
postSettleAccountsPlatformCouponSettlementCouponManualSettlement({settlementId: id})
.then(({data, code}) => {
if(code === 1000) {
formActions.submit();
}
})
}
const fetchVouchers = useCallback(async (id: number) => {
const { code, data } = await getSettleAccountsPlatformCouponSettlementGetPayablePayProve({id: id.toString()})
if (code === 1000) {
setFiles(data);
}
}, [])
useEffect(() => {
if (itemInfo !== null && modals['manualSettlement']) {
handleManualsettlement(itemInfo.id)
return
}
if (itemInfo !== null && modals.viewPay) {
fetchVouchers(itemInfo.id);
}
}, [itemInfo]);
/**
* 上传凭证
* @param params
*/
const handleUploadVoucher = (params: { id: number, fileList: {name: string, proveUrl: string}[] }) => {
console.log(params);
postSettleAccountsPlatformCouponSettlementPay({id: params.id, proveList: params.fileList})
.then((data) => {
if(data.code === 1000) {
handleClose('uploadPayVoucher')
formActions.submit();
}
})
}
/**
* 搜索
*/
const handleSearch = (values: SearchParams) => {
const format = 'YYYY-MM-DD'
const startTime = values.startTime && moment.isMoment(values.startTime) ? values.startTime.format(format) : '';
const endTime = values.endTime && moment.isMoment(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
components={{RangePicker}}
actions={formActions}
expressionScope={{}}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, 'megaLayout.settlementName', FORM_FILTER_PATH);
// useAsyncInitSelect(
// ['innerStatus', 'outerStatus'],
// fetchSelectOptions,
// );
}}
schema={schema}
onSubmit={handleSearch}
onReset={() => {
formActions.setFieldValue('startTime', null);
formActions.setFieldValue('endTime', null);
}}
/>
}
/>
</Card>
<UploadVoucherModal
visible={modals.uploadPayVoucher}
id={itemInfo?.id}
roleId={itemInfo?.roleId}
settlementId={itemInfo?.memberId}
handleUpload={handleUploadVoucher}
onCancel={() => handleClose('uploadPayVoucher')}
/>
<Modal width={548} title="查看付款凭证" onCancel={() => handleClose('viewPay')} visible={modals.viewPay} footer={null}>
<Voucher files={files} />
</Modal>
<ViewUniversalPay
visible={modals['viewUniversalPay']}
balanceInfo={universalPayInfo1}
onClose={() => handleClose('viewUniversalPay')}
onOk={() => handleClose('viewUniversalPay')}
/>
<OtherPayModal
visible={modals.universalPay}
onClose={() => handleClose('universalPay')}
onConfirm={handleUniversalPay}
balanceInfo={universalPayInfoData}
confirmLoading={confirmUniversalPayLoading}
/>
</PageHeaderWrapper>
)
}
export default SettlementList
/*
* @Author: Bill
* @Date: 2020-10-22 09:52:10
* @Description: 应收账款结算 schema集合
*/
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ISchema } from '@formily/antd';
/**
* 应收账款 index.tsx 列表页schema
*/
export const schema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
settlementName: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索(结算方)',
align: 'flex-left',
tip: '输入 结算方 进行搜索',
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
justifyContent: 'flex-start'
},
colStyle: {
marginRight: "20px",
}
},
properties: {
"[startTime, endTime]": {
type: "object",
"x-component": 'RangePicker',
'x-component-props': {
allowClear: true,
placeholder: ['结算日期(开始时间)', "结算日期(结束时间)"]
}
},
// 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: [
{ label: '结算状态(所有)', value: 0 },
{ label: '待对账', value: 1 },
{ label: '待付款', value: 2 },
{ label: '待收款', value: 3 },
{ label: '已完成', value: 4 },
],
default: 0,
'x-component-props': {
placeholder: '结算状态(全部)',
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
},
},
},
},
},
},
},
};
import EyePreview from '@/components/EyePreview';
import { priceFormat } from '@/utils/numberFomat'
import StatusTag from '@/components/StatusTag';
import React, { useMemo, useState } from 'react';
import { useCallback } from 'react';
import { GetSettleAccountsPlatformSettlementPagePayableSettlementResponseDetail } from '@/services/SettleV2Api';
import { ColumnsType } from 'antd/lib/table';
const STATUS_COLOR = ["default", "warning", "primary", "danger", "success"];
const STATUS_TEXT = {
1: '待对账',
2: '待付款',
3: '待收款',
4: '已完成'
}
type ModalsType = {
/** 查看付款 */
viewPay: boolean,
/** 查看通联支付 */
viewUniversalPay: boolean,
/** 手动结算 */
manualSettlement: boolean,
/** 上传付款凭证 */
uploadPayVoucher: boolean,
/** 通联支付付款 */
universalPay: boolean
}
function useHandleSettlementList() {
const [itemInfo, setItemInfo] = useState<GetSettleAccountsPlatformSettlementPagePayableSettlementResponseDetail | null>(null)
const [modals, setModals] = useState<ModalsType>({
viewPay: false,
viewUniversalPay: false,
manualSettlement: false,
uploadPayVoucher: false,
universalPay: false
})
const handleOpen = useCallback((key: keyof ModalsType) => {
setModals({
...modals,
[key]: true
})
}, [])
const handleClose = useCallback((key: keyof ModalsType) => {
setModals({
...modals,
[key]: false
})
}, [])
const handleAction = (record: GetSettleAccountsPlatformSettlementPagePayableSettlementResponseDetail, key: keyof ModalsType) => {
setItemInfo(record);
console.log("key", key);
handleOpen(key);
}
const columns: ColumnsType<any> = [
{
title: '结算单号',
dataIndex: 'settlementNo',
render: (text, record) => {
const url = `/settlementManage/platformSettlement/balanced/coupon/detail?id=${record.id}`;
return (
<EyePreview url={url}>
{text}
</EyePreview>
)
}
},
{title: '结算方式', dataIndex: 'settlementWayName'},
{title: '结算方', dataIndex: 'settlementName'},
{title: '总单数', dataIndex: 'totalCount'},
{title: '结算金额', dataIndex: 'amount', render: (text) => `¥${priceFormat(text)}`},
{title: '结算日期', dataIndex: 'settlementDate'},
{title: '预计付款日期', dataIndex: 'settlementDate1'},
{title: '实际支付时间', dataIndex: 'settlementDate2'},
{title: '支付方式', dataIndex: 'payWayName'},
{
title: '结算状态', dataIndex: 'status',
filters: [
{ text: '待对账', value: 1 },
{ text: '待付款', value: 2 },
{ text: '待收款', value: 3 },
{ text: '已完成', value: 4 },
],
onFilter: (value, record: any) => record.status == value,
render: (text, record: any) => {
return (
<StatusTag type={STATUS_COLOR[record.status] as 'success'} title={STATUS_TEXT[record.status]} />
)
}
},
{
title: '操作',
render: (text: string, record: any) => {
const isUniversalPay = record.payWay === 2;
// 待对账的时候可以手动结算
if (record.status === 1) {
return <a onClick={() => handleAction(record, "manualSettlement")}>手动结算</a>
}
if (record.status === 2) {
return (
<a onClick={() => handleAction(record, isUniversalPay ? 'universalPay' : 'uploadPayVoucher')}>
付款
</a>
)
}
return <a onClick={() => handleAction(record, isUniversalPay ? 'viewUniversalPay' : 'viewPay')}>查看付款凭证</a>
}
}
]
const cacheItemInfo = useMemo(() => itemInfo, [itemInfo])
return {
columns,
handleOpen,
handleClose,
itemInfo: cacheItemInfo,
modals,
}
}
export default useHandleSettlementList
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