Commit 5ac4aff5 authored by XieZhiXiong's avatar XieZhiXiong

feat: 对接优惠券执行相关

parent f1e1f2b1
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-28 18:06:53
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-29 14:08:23
* @LastEditTime: 2021-08-02 11:16:15
* @Description: 执行明细
*/
import React, { useRef, } from 'react';
......@@ -12,10 +12,12 @@ import { StandardTable } from 'god';
import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import NiceForm from '@/components/NiceForm';
import MellowCard, { MellowCardProps } from '@/components/MellowCard';
import { querySchema } from './schema';
import moment from 'moment';
const formActions = createFormActions();
......@@ -50,8 +52,70 @@ export type ListItemDataType = {
price: number,
}
export type FetchParams = {
/**
* 当前页
*/
current: number,
/**
* 每页行数
*/
pageSize: number,
}
export type FetchExtraParams = {
/**
* 客户名称
*/
memberName: string,
/**
* 券码
*/
code: string,
/**
* 券状态
*/
status: number,
/**
* 领(发)劵起始时间
*/
createTimeStart: string,
/**
* 领(发)劵截止时间
*/
createTimeEnd: string,
/**
* 客户ID
*/
memberId: string,
/**
* 适用用户
*/
suitableMemberType: number,
/**
* 下单(使用)起始时间
*/
useTimeStart: string,
/**
* 下单(使用)截止时间
*/
useTimeEnd: string,
/**
* 关联订单号
*/
orderNo: string,
/**
* 商城
*/
shopId: number,
}
interface IProps extends MellowCardProps {
/**
* 优惠券id
*/
couponId: number,
/**
* 数据
*/
dataSource?: ListItemDataType[];
......@@ -59,52 +123,71 @@ interface IProps extends MellowCardProps {
const RunningInfo: React.FC<IProps> = (props) => {
const {
couponId,
dataSource,
...rest
} = props;
const ref = useRef<any>({});
const fetchData = async (params: any) => {
let res = await PublicApi.getMemberAbilityMaintenancePage(params);
return res.data;
const fetchData = async (params: FetchParams & FetchExtraParams) => {
if (!couponId) {
return { data: [], totalCount: 0 };
}
const res = await PublicApi.getMarketingCouponWaiteExecuteDetailPage({
...params,
current: `${params.current}`,
pageSize: `${params.pageSize}`,
status: params.status ? `${params.status}` : undefined,
suitableMemberType: params.suitableMemberType ? `${params.suitableMemberType}` : undefined,
shopId: params.shopId ? `${params.shopId}` : undefined,
createTimeStart: params.createTimeStart ? `${moment(params.createTimeStart).valueOf()}` : undefined,
createTimeEnd: params.createTimeEnd ? `${moment(params.createTimeEnd).valueOf()}` : undefined,
useTimeStart: params.useTimeStart ? `${moment(params.useTimeStart).valueOf()}` : undefined,
useTimeEnd: params.useTimeEnd ? `${moment(params.useTimeEnd).valueOf()}` : undefined,
couponId: `${couponId}`,
});
if (res.code === 1000) {
return res.data;
}
return { data: [], totalCount: 0 };
};
const columns: ColumnType<ListItemDataType>[] = [
{
title: '券码',
dataIndex: 'productId',
dataIndex: 'code',
align: 'center',
},
{
title: '券状态',
dataIndex: 'productImg',
dataIndex: 'statusName',
align: 'center',
},
{
title: '客户ID',
dataIndex: 'productName',
dataIndex: 'subMemberId',
ellipsis: true,
},
{
title: '客户名称',
dataIndex: 'category',
dataIndex: 'subMemberName',
},
{
title: '适用用户',
dataIndex: 'brand',
dataIndex: 'bransuitableMemberTypeNamed',
},
{
title: '领(发)放劵时间',
dataIndex: 'unit',
dataIndex: 'createTimeStart',
},
{
title: '劵有效期起始时间',
dataIndex: 'unit2',
dataIndex: 'effectiveTimeStart',
},
{
title: '券有效期截止时间',
dataIndex: 'unit2',
dataIndex: 'effectiveTimeEnd',
},
{
title: '关联订单',
......@@ -112,23 +195,48 @@ const RunningInfo: React.FC<IProps> = (props) => {
},
{
title: '下单(使用)时间',
dataIndex: 'orderTime',
dataIndex: 'useTime',
},
{
title: '商城',
dataIndex: 'orderTime',
dataIndex: 'shopName',
},
{
title: '订单金额',
dataIndex: 'price',
dataIndex: 'amount',
render: (text) => ${text || ''}`,
},
{
title: '订单状态',
dataIndex: 'price2',
dataIndex: 'orderStatusName',
},
];
// 初始化高级筛选选项
const fetchTypeEnums = async () => {
if (!couponId) {
return {};
}
const res = await PublicApi.getMarketingCouponWaiteExecuteDetailPageCondition({
id: `${couponId}`,
});
if (res.code === 1000) {
const {
statusList = [],
suitableMemberTypeList = [],
shopList = [],
} = res.data;
return {
status: statusList.map(item => ({ label: item.name, value: item.value })),
suitableMemberType: suitableMemberTypeList.map(item => ({ label: item.name, value: item.value })),
shopId: shopList.map(item => ({ label: item.name, value: item.value })),
};
}
return {};
};
return (
<MellowCard
title="执行明细"
......@@ -136,11 +244,11 @@ const RunningInfo: React.FC<IProps> = (props) => {
>
<StandardTable
tableProps={{
rowKey: 'validateId',
rowKey: 'id',
}}
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
fetchTableData={(params: FetchParams & FetchExtraParams) => fetchData(params)}
controlRender={
<NiceForm
actions={formActions}
......@@ -152,9 +260,13 @@ const RunningInfo: React.FC<IProps> = (props) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
'memberName',
FORM_FILTER_PATH,
);
useAsyncInitSelect(
['status', 'suitableMemberType', 'shopId'],
fetchTypeEnums,
);
}}
schema={querySchema}
/>
......
......@@ -11,13 +11,13 @@ import { FORM_FILTER_PATH } from '@/formSchema/const';
export const querySchema: ISchema = {
type: 'object',
properties: {
name: {
memberName: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索',
align: 'flex-start',
tip: '输入 优惠劵名称 进行搜索',
tip: '输入 客户名称 进行搜索',
},
},
[FORM_FILTER_PATH]: {
......@@ -30,7 +30,7 @@ export const querySchema: ISchema = {
columns: 4,
},
properties: {
id: {
code: {
type: 'string',
'x-component-props': {
placeholder: '劵码',
......@@ -46,7 +46,7 @@ export const querySchema: ISchema = {
allowClear: true,
},
},
'[startTime, endTime]': {
'[createTimeStart, createTimeEnd]': {
type: 'string',
'x-component': 'RangePicker',
'x-component-props': {
......@@ -54,21 +54,14 @@ export const querySchema: ISchema = {
showTime: true,
},
},
userId: {
memberId: {
type: 'string',
'x-component-props': {
placeholder: '客户ID',
allowClear: true,
},
},
userName: {
type: 'string',
'x-component-props': {
placeholder: '客户名称',
allowClear: true,
},
},
applicable: {
suitableMemberType: {
type: 'string',
default: undefined,
enum: [],
......@@ -77,7 +70,7 @@ export const querySchema: ISchema = {
allowClear: true,
},
},
'[startTime2, endTime2]': {
'[useTimeStart, useTimeEnd]': {
type: 'string',
'x-component': 'RangePicker',
'x-component-props': {
......@@ -92,12 +85,12 @@ export const querySchema: ISchema = {
allowClear: true,
},
},
shop: {
shopId: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '适用用户',
placeholder: '商城',
allowClear: true,
},
},
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-22 11:10:57
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-06 11:37:25
* @LastEditTime: 2021-08-02 10:41:37
* @Description: 商家优惠劵执行
*/
import React, { useRef } from 'react';
......@@ -121,19 +121,19 @@ const MerchantCouponAnalysis: React.FC = () => {
const [columns, columnsHandle] = useSpliceArray<ColumnType<any>>(defaultColumns);
// 初始化高级筛选选项
const fetchTypeEnums = async () => {
const res = await PublicApi.getMarketingCouponTypeList();
if (res.code === 1000) {
const { data = [] } = res;
return {
type: data.map(item => ({ label: item.name, value: item.value })),
};
}
return {};
};
// 初始化高级筛选选项
const fetchTypeEnums = async () => {
const res = await PublicApi.getMarketingCouponTypeList();
if (res.code === 1000) {
const { data = [] } = res;
return {
type: data.map(item => ({ label: item.name, value: item.value })),
};
}
return {};
};
const ControllerBtns = () => (
<Space size={16}>
......
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