feat(ecom): 推广费表增加商品维度,移除冗余字段和平台外键

- ec_promotion_fee 新增 product_id 字段(可空,关联 ec_product)
- 移除冗余字段:fee_name / base_amount / fee_rate / click_count / impression_count / conversion_count
- 移除 ec_promotion_fee.platform_id 外键(店铺已关联平台,此处冗余)
- 后端 PO/DTO/VO 层字段更新,DTO 新增 productId 过滤条件
- ShopOverviewStatisticsServiceImpl 推广费计算改为有 product_id 直接归属,无则按销售额比例分配
- 前端类型定义和推广费表单同步更新
This commit is contained in:
小蟑螂
2026-05-06 02:13:46 +08:00
parent 655a1025b3
commit 98a4c4293f
14 changed files with 181 additions and 287 deletions
@@ -4,6 +4,7 @@ import type {
PromotionFeeDTO,
PromotionFeeVO,
} from '#/api/ecommerce/promotion-fee/types';
import type { ProductVO } from '#/api/ecommerce/product/types';
import type { ShopVO } from '#/api/ecommerce/shop/types';
import { nextTick, onMounted, ref, watch } from 'vue';
@@ -27,6 +28,7 @@ import {
} from '#/api/ecommerce/promotion-fee';
import { getActivePromotionFeeTypeListApi } from '#/api/ecommerce/promotion-fee-type';
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
import { getProductPageApi } from '#/api/ecommerce/product';
import { getShopPageApi } from '#/api/ecommerce/shop';
defineOptions({ name: 'PromotionFeeFormModal' });
@@ -72,15 +74,10 @@ const isEdit = ref(false);
const formData = ref<PromotionFeeDTO.Create>({
shopId: undefined as any,
feeTypeId: undefined as any,
feeName: '',
platformId: undefined,
productId: undefined,
campaignName: '',
feeAmount: undefined as any,
baseAmount: undefined,
feeRate: undefined,
clickCount: undefined,
impressionCount: undefined,
conversionCount: undefined,
feeDate: undefined as any,
remark: '',
});
@@ -90,7 +87,6 @@ const rules = {
feeTypeId: [
{ required: true, message: '请选择推广费类型', trigger: 'change' },
],
feeName: [{ required: true, message: '请输入推广费名称', trigger: 'blur' }],
feeAmount: [{ required: true, message: '请输入推广费金额', trigger: 'blur' }],
feeDate: [{ required: true, message: '请选择发生日期', trigger: 'change' }],
} as any;
@@ -107,6 +103,10 @@ const shopListLoading = ref(false);
const feeTypeList = ref<PromotionFeeTypeVO.Info[]>([]);
const feeTypeListLoading = ref(false);
// 商品列表
const productList = ref<ProductVO.Info[]>([]);
const productListLoading = ref(false);
watch(
() => props.open,
async (newVal) => {
@@ -119,15 +119,10 @@ watch(
formData.value = {
shopId: props.promotionFeeData.shopId,
feeTypeId: props.promotionFeeData.feeTypeId,
feeName: props.promotionFeeData.feeName,
platformId: props.promotionFeeData.platformId,
productId: props.promotionFeeData.productId,
campaignName: props.promotionFeeData.campaignName || '',
feeAmount: props.promotionFeeData.feeAmount,
baseAmount: props.promotionFeeData.baseAmount,
feeRate: props.promotionFeeData.feeRate,
clickCount: props.promotionFeeData.clickCount,
impressionCount: props.promotionFeeData.impressionCount,
conversionCount: props.promotionFeeData.conversionCount,
feeDate: props.promotionFeeData.feeDate
? dayjs(props.promotionFeeData.feeDate)
: undefined,
@@ -186,19 +181,30 @@ const loadPlatformList = async () => {
}
};
const loadProductList = async () => {
productListLoading.value = true;
try {
const response = await getProductPageApi({
page: 1,
pageSize: 1000,
filters: {},
});
productList.value = response.records;
} catch (error) {
console.error('加载商品列表失败:', error);
} finally {
productListLoading.value = false;
}
};
const resetFormData = () => {
formData.value = {
shopId: undefined as any,
feeTypeId: undefined as any,
feeName: '',
platformId: undefined,
productId: undefined,
campaignName: '',
feeAmount: undefined as any,
baseAmount: undefined,
feeRate: undefined,
clickCount: undefined,
impressionCount: undefined,
conversionCount: undefined,
feeDate: undefined as any,
remark: '',
};
@@ -237,6 +243,7 @@ onMounted(() => {
loadShopList();
loadFeeTypeList();
loadPlatformList();
loadProductList();
});
</script>
@@ -281,13 +288,6 @@ onMounted(() => {
</Select>
</Form.Item>
<Form.Item label="推广费名称" name="feeName">
<Input
v-model:value="formData.feeName"
placeholder="请输入推广费名称"
/>
</Form.Item>
<Form.Item label="平台" name="platformId">
<Select
v-model:value="formData.platformId"
@@ -305,6 +305,28 @@ onMounted(() => {
</Select>
</Form.Item>
<Form.Item label="商品(可选)" name="productId">
<Select
v-model:value="formData.productId"
placeholder="请选择商品(可选,不选则为店铺级推广费)"
:loading="productListLoading"
allow-clear
show-search
:filter-option="(input: string, option: any) =>
option?.children?.props?.children?.props?.children?.props?.children?.props?.children?.props?.children
?.toLowerCase?.().includes?.(input.toLowerCase()) ?? false
"
>
<Select.Option
v-for="product in productList"
:key="product.id"
:value="product.id"
>
{{ product.name }}
</Select.Option>
</Select>
</Form.Item>
<Form.Item label="推广活动名称" name="campaignName">
<Input
v-model:value="formData.campaignName"
@@ -322,54 +344,6 @@ onMounted(() => {
/>
</Form.Item>
<Form.Item label="基础金额" name="baseAmount">
<InputNumber
v-model:value="formData.baseAmount"
placeholder="请输入基础金额(用于按比例计算)"
:min="0"
:precision="2"
style="width: 100%"
/>
</Form.Item>
<Form.Item label="费率" name="feeRate">
<InputNumber
v-model:value="formData.feeRate"
placeholder="请输入费率(用于按比例计算)"
:min="0"
:max="1"
:precision="4"
style="width: 100%"
/>
</Form.Item>
<Form.Item label="点击次数" name="clickCount">
<InputNumber
v-model:value="formData.clickCount"
placeholder="请输入点击次数"
:min="0"
style="width: 100%"
/>
</Form.Item>
<Form.Item label="展示次数" name="impressionCount">
<InputNumber
v-model:value="formData.impressionCount"
placeholder="请输入展示次数"
:min="0"
style="width: 100%"
/>
</Form.Item>
<Form.Item label="转化次数" name="conversionCount">
<InputNumber
v-model:value="formData.conversionCount"
placeholder="请输入转化次数"
:min="0"
style="width: 100%"
/>
</Form.Item>
<Form.Item label="发生日期" name="feeDate">
<DatePicker
v-model:value="formData.feeDate"
@@ -387,4 +361,4 @@ onMounted(() => {
</Form.Item>
</Form>
</Modal>
</template>
</template>
@@ -113,8 +113,8 @@ const gridOptions: VxeGridProps<any> = {
title: '序号',
},
{
field: 'feeName',
title: '推广费名称',
field: 'productId',
title: '商品ID',
minWidth: 'auto',
showOverflow: 'tooltip' as const,
},
@@ -55,7 +55,7 @@ const editingData = ref<PromotionFeeVO.Info | undefined>();
const gridOptions: VxeGridProps<any> = {
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'feeName', title: '费用名称', width: 110 },
{ field: 'productId', title: '商品ID', width: 90 },
{ field: 'platformName', title: '平台', width: 90 },
{ field: 'campaignName', title: '活动名称', minWidth: 140 },
{