Compare commits

...

3 Commits

Author SHA1 Message Date
89d2bcdf29 feat: update api 2026-01-28 21:12:12 +08:00
ab9c034a72 feat: update api 2026-01-28 19:47:44 +08:00
17be93115d feat: 用接口 2026-01-27 21:09:40 +08:00
4 changed files with 46 additions and 60 deletions

View File

@ -43,4 +43,5 @@ export enum AdminAPI {
GIVE_VIP = '/api/bo/giveVip/give',
// 产品列表
PRODUCT_LIST = '/api/bo/product/listByType/{productType}',
GET_PRODUCT_SPEC = '/api/bo/product/getBySpecId/{productSpecId}'
}

View File

@ -19,7 +19,13 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import { CITY_OPTIONS } from '@/constants/city';
import { TIME_FORMAT } from '@/constants/global';
import { uploadFileWx } from '@/services/file';
import { deleteCityOperator, getAllStaffList, getCityOpratorList, updateCityOperator } from '@/services/list';
import {
deleteCityOperator,
getAllStaffList,
getCityOpratorList,
getProductList,
updateCityOperator,
} from '@/services/list';
const useStyles = createStyles(({ token }) => {
return {
@ -36,53 +42,13 @@ const useStyles = createStyles(({ token }) => {
};
});
const MIN_GROUP_SIZE = 20;
export enum ProductSpecId {
GroupBatchPublish20 = 'GROUP_BATCH_PUSH_20',
GroupBatchPublish50 = 'GROUP_BATCH_PUSH_50',
GroupBatchPublish60 = 'GROUP_BATCH_PUSH_60',
GroupBatchPublish80 = 'GROUP_BATCH_PUSH_80',
GroupBatchPublish100 = 'GROUP_BATCH_PUSH_100',
GroupBatchPublish120 = 'GROUP_BATCH_PUSH_120',
GroupBatchPublish150 = 'GROUP_BATCH_PUSH_150',
GroupBatchPublish200 = 'GROUP_BATCH_PUSH_200',
GroupBatchPublish250 = 'GROUP_BATCH_PUSH_250',
GroupBatchPublish300 = 'GROUP_BATCH_PUSH_300',
GroupBatchPublish500 = 'GROUP_BATCH_PUSH_500',
GroupBatchPublish750 = 'GROUP_BATCH_PUSH_750',
GroupBatchPublish800 = 'GROUP_BATCH_PUSH_800',
GroupBatchPublish1000 = 'GROUP_BATCH_PUSH_1000',
}
const GROUP_OPTIONS = [
{
value: MIN_GROUP_SIZE,
productSpecId: ProductSpecId.GroupBatchPublish20,
label: '20',
price: 38,
originalPrice: 40,
},
{ value: 50, productSpecId: ProductSpecId.GroupBatchPublish50, label: '50', price: 68, originalPrice: 100 },
{ value: 60, productSpecId: ProductSpecId.GroupBatchPublish60, label: '60', price: 78, originalPrice: 120 },
{ value: 80, productSpecId: ProductSpecId.GroupBatchPublish80, label: '80', price: 88, originalPrice: 160 },
{ value: 100, productSpecId: ProductSpecId.GroupBatchPublish100, label: '100', price: 98, originalPrice: 200 },
{ value: 120, productSpecId: ProductSpecId.GroupBatchPublish120, label: '120', price: 108, originalPrice: 240 },
{ value: 150, productSpecId: ProductSpecId.GroupBatchPublish150, label: '150', price: 128, originalPrice: 300 },
{ value: 200, productSpecId: ProductSpecId.GroupBatchPublish200, label: '200', price: 148, originalPrice: 200 },
{ value: 250, productSpecId: ProductSpecId.GroupBatchPublish250, label: '250', price: 168, originalPrice: 250 },
{ value: 300, productSpecId: ProductSpecId.GroupBatchPublish300, label: '300', price: 168, originalPrice: 300 },
{ value: 500, productSpecId: ProductSpecId.GroupBatchPublish500, label: '500', price: 168, originalPrice: 500 },
{ value: 750, productSpecId: ProductSpecId.GroupBatchPublish750, label: '750', price: 168, originalPrice: 750 },
{ value: 800, productSpecId: ProductSpecId.GroupBatchPublish800, label: '800', price: 168, originalPrice: 800 },
{ value: 1000, productSpecId: ProductSpecId.GroupBatchPublish1000, label: '1000', price: 168, originalPrice: 1000 },
];
const calcPrice = (sendCount: number) => {
const price = GROUP_OPTIONS.find(o => o.value === sendCount)?.price || 18;
const originalPrice = GROUP_OPTIONS.find(o => o.value === sendCount)?.originalPrice || sendCount;
return { price, originalPrice };
const calcPrice = (productSpecId: string, specList: API.ProductSpecListItem[]) => {
const product = specList.find(o => o.productSpecId === productSpecId);
return { price: product?.showPrice, originalPrice: product?.originalPrice, sendCount: product?.count };
};
const TableList: React.FC = () => {
const [updateModalOpen, handleUpdateModalOpen] = useState<boolean>(false);
const [specList, setSpecList] = useState<API.ProductSpecListItem[]>([]);
const [currentRow, setCurrentRow] = useState<API.CityOperatorListItem>();
const actionRef = useRef<ActionType>();
const formRef = useRef<ProFormInstance>();
@ -91,6 +57,14 @@ const TableList: React.FC = () => {
return staffOptions.find(it => it.isDefault) || staffOptions[0];
}, [staffOptions]);
const { styles } = useStyles();
const specOptions = useMemo(
() =>
specList.map(it => ({
value: it.productSpecId,
label: it.title,
})),
[specList],
);
const getAllStaffOptions = async () => {
try {
@ -107,6 +81,11 @@ const TableList: React.FC = () => {
}
};
const getAllSpectList = async () => {
const list = await getProductList('GROUP_BATCH_PUSH');
setSpecList(list);
};
const handleDelete = async (id: number) => {
await deleteCityOperator(id);
message.success('操作成功');
@ -118,6 +97,7 @@ const TableList: React.FC = () => {
};
useEffect(() => {
getAllStaffOptions();
getAllSpectList();
}, []);
const columns: ProColumns<API.CityOperatorListItem>[] = [
@ -180,16 +160,17 @@ const TableList: React.FC = () => {
},
{
title: '可群发数量',
dataIndex: 'sendCount',
dataIndex: 'productSpecId',
valueType: 'textarea',
search: false,
renderText: productSpecId => calcPrice(productSpecId, specList).sendCount || '-',
},
{
title: '群代发价格',
dataIndex: 'price',
dataIndex: 'productSpecId',
valueType: 'textarea',
search: false,
renderText: cents => (cents ? (cents / 100).toFixed(0) : '-'),
renderText: productSpecId => calcPrice(productSpecId, specList).price || '-',
},
{
title: '操作',
@ -270,9 +251,8 @@ const TableList: React.FC = () => {
cityCode: formData.city.value,
cityName: formData.city.label,
groupLink: formData.groupLink,
sendCount: formData.sendCount,
productSpecId: formData.productSpecId,
groupQrCode: formData.qrCode[0].xhr ? formData.qrCode[0].xhr.responseURL : formData.qrCode[0].url,
price: calcPrice(formData.sendCount).price,
};
console.log('update confirm', formData, params);
try {
@ -312,16 +292,16 @@ const TableList: React.FC = () => {
/>
<ProFormSelect
mode="single"
name="sendCount"
name="productSpecId"
label="可群发数量"
options={GROUP_OPTIONS}
options={specOptions}
rules={[{ required: true, message: '必填项' }]}
/>
<ProFormDependency name={['sendCount']}>
{({ sendCount }) =>
sendCount ? (
<ProFormDependency name={['productSpecId']}>
{({ productSpecId }) =>
productSpecId ? (
<div>
{calcPrice(sendCount).price}{calcPrice(sendCount).originalPrice}
{calcPrice(productSpecId, specList).price}{calcPrice(productSpecId, specList).originalPrice}
</div>
) : null
}

View File

@ -327,3 +327,9 @@ export async function getProductList(productType: API.ProductType) {
method: 'GET',
});
}
export async function getProductSpec(productSpecId: API.ProductType) {
return request<API.ProductSpecListItem>(buildUrl(AdminAPI.GET_PRODUCT_SPEC, {productSpecId}), {
method: 'GET',
})
}

View File

@ -363,10 +363,9 @@ declare namespace API {
staffId: number;
cityCode: string;
groupLink: string;
sendCount: number;
productSpecId: string;
contactQrCode: string;
groupQrCode: string;
price: number;
id: number;
}
@ -378,8 +377,7 @@ declare namespace API {
cityCode: string;
groupLink: string;
groupQrCode: string;
sendCount?: number;
price?: number;
productSpecId?: string;
created?: string;
updated?: string;
}
@ -411,6 +409,7 @@ declare namespace API {
productSpecId: string;
productType: ProductType;
productName: string;
count: number;
title: string;
priceText: string;
payPrice: number;