mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 00:29:19 +08:00
ec_order: 去掉 product_id,改为冗余 spec_code 字段
- 迁移SQL: V20260603__ec_order_drop_product_id_add_spec_code.sql - Order 实体/DTO/VO: product_id → spec_code,字段联路调整 - OrderImportProcessor / OrderServiceImpl: 适配新字段 - 各 Overview Service: 更新订单关联逻辑 - 前端: OrderFormModal / index / types 同步适配
This commit is contained in:
@@ -15,10 +15,10 @@ export namespace OrderDTO {
|
||||
receivedAmount: number;
|
||||
/** 下单时间 */
|
||||
orderTime: string;
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
productSpecId: number;
|
||||
/** 规格编码(可选,服务端可按规格ID补全) */
|
||||
specCode?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
linkProductName: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
@@ -49,10 +49,10 @@ export namespace OrderDTO {
|
||||
receivedAmount: number;
|
||||
/** 下单时间 */
|
||||
orderTime: string;
|
||||
/** 商品ID */
|
||||
productId?: number;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
linkProductName?: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
|
||||
@@ -36,10 +36,10 @@ export namespace OrderVO {
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
linkProductName: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
|
||||
+21
-11
@@ -8,7 +8,7 @@ import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
@@ -56,7 +56,8 @@ const isEdit = ref(false);
|
||||
const currentRecord = ref<null | OrderVO.Info>(null);
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<Partial<OrderDTO.Create>>({
|
||||
/** 表单含 UI 用 productId(选规格);提交用 productSpecId + specCode */
|
||||
const formData = ref<Partial<OrderDTO.Create> & { productId?: number }>({
|
||||
shopId: undefined,
|
||||
platformOrderNo: '',
|
||||
statusId: undefined as number | undefined,
|
||||
@@ -64,6 +65,7 @@ const formData = ref<Partial<OrderDTO.Create>>({
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
specCode: undefined,
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
@@ -111,6 +113,7 @@ const rules = {
|
||||
],
|
||||
orderTime: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
productId: [{ required: true, message: '请选择商品', trigger: 'change' }],
|
||||
productSpecId: [{ required: true, message: '请选择商品规格', trigger: 'change' }],
|
||||
linkProductName: [
|
||||
{ required: true, message: '请输入链接商品名称', trigger: 'blur' },
|
||||
],
|
||||
@@ -292,6 +295,7 @@ function handleProductChange(productId: number | undefined) {
|
||||
specPage.value = 1;
|
||||
productSpecOptions.value = [];
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.specCode = undefined;
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
@@ -300,6 +304,7 @@ function handleProductChange(productId: number | undefined) {
|
||||
} else {
|
||||
formData.value.linkProductName = '';
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.specCode = undefined;
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
@@ -316,12 +321,14 @@ function handleProductSpecChange(specId: number | undefined) {
|
||||
);
|
||||
if (selectedSpec) {
|
||||
formData.value.linkSpecName = selectedSpec.spec.name;
|
||||
formData.value.specCode = selectedSpec.spec.specCode;
|
||||
formData.value.productCost = selectedSpec.spec.productCost;
|
||||
formData.value.shippingCost = selectedSpec.spec.shippingCost || 0;
|
||||
formData.value.otherCost = selectedSpec.spec.otherCost || 0;
|
||||
}
|
||||
} else {
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.specCode = undefined;
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
formData.value.otherCost = 0;
|
||||
@@ -350,8 +357,9 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
orderTime: record.orderTime
|
||||
? dayjs(record.orderTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: record.productId,
|
||||
productId: record.product?.id,
|
||||
productSpecId: record.productSpecId,
|
||||
specCode: record.specCode,
|
||||
linkProductName: record.linkProductName,
|
||||
linkSpecName: record.linkSpecName,
|
||||
quantity: record.quantity,
|
||||
@@ -369,6 +377,7 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
specCode: undefined,
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
@@ -379,16 +388,17 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
remark: '',
|
||||
};
|
||||
|
||||
// 如果是编辑模式且有商品ID,加载商品和规格选项
|
||||
if (edit && record?.productId) {
|
||||
// 如果是编辑模式且有商品/规格,加载商品和规格选项
|
||||
if (edit && record && (record.product?.id ?? record.productSpecId)) {
|
||||
await fetchProducts(1, false);
|
||||
// 确保选中的商品在选项中
|
||||
if (!productOptions.value.some((opt) => opt.value === record.productId)) {
|
||||
const pid = record.product?.id;
|
||||
if (pid && !productOptions.value.some((opt) => opt.value === pid)) {
|
||||
productOptions.value.push({
|
||||
label: record.linkProductName,
|
||||
value: record.productId,
|
||||
value: pid,
|
||||
product: {
|
||||
id: record.productId,
|
||||
id: pid,
|
||||
name: record.linkProductName,
|
||||
} as ProductVO.Info,
|
||||
});
|
||||
@@ -438,8 +448,8 @@ async function handleSubmit() {
|
||||
statusId: formData.value.statusId,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productId: formData.value.productId,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
specCode: formData.value.specCode,
|
||||
linkProductName: formData.value.linkProductName,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity,
|
||||
@@ -459,8 +469,8 @@ async function handleSubmit() {
|
||||
statusId: formData.value.statusId!,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productId: formData.value.productId!,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
productSpecId: formData.value.productSpecId!,
|
||||
specCode: formData.value.specCode,
|
||||
linkProductName: formData.value.linkProductName!,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity!,
|
||||
|
||||
@@ -614,11 +614,13 @@ onMounted(async () => {
|
||||
<div>商品编码:{{ row.product.productCode || '-' }}</div>
|
||||
</template>
|
||||
<a
|
||||
v-if="row.product?.id"
|
||||
style="color: #1890ff; cursor: pointer"
|
||||
@click.stop="goToProductDetail(row.productId)"
|
||||
@click.stop="goToProductDetail(row.product.id)"
|
||||
>
|
||||
{{ row.product.name }}
|
||||
</a>
|
||||
<span v-else style="color: #1890ff">{{ row.product.name }}</span>
|
||||
</Popover>
|
||||
<span v-else style="color: #999">暂无商品信息</span>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user