Skip to content

Commit 6fc232b

Browse files
committed
交易:订单核销
1 parent e3a0cfe commit 6fc232b

File tree

4 files changed

+160
-10
lines changed

4 files changed

+160
-10
lines changed

src/api/mall/trade/order/index.ts

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import request from '@/config/axios'
22

33
export interface OrderVO {
4+
// ========== 订单基本信息 ==========
45
id?: number | null // 订单编号
56
no?: string // 订单流水号
67
createTime?: Date | null // 下单时间
@@ -15,35 +16,43 @@ export interface OrderVO {
1516
cancelTime?: Date | null // 订单取消时间
1617
cancelType?: number | null // 取消类型
1718
remark?: string // 商家备注
19+
20+
// ========== 价格 + 支付基本信息 ==========
1821
payOrderId?: number | null // 支付订单编号
19-
payed?: boolean // 是否已支付
22+
payStatus?: boolean // 是否已支付
2023
payTime?: Date | null // 付款时间
2124
payChannelCode?: string // 支付渠道
2225
totalPrice?: number | null // 商品原价(总)
23-
orderPrice?: number | null // 订单原价(总)
2426
discountPrice?: number | null // 订单优惠(总)
2527
deliveryPrice?: number | null // 运费金额
2628
adjustPrice?: number | null // 订单调价(总)
2729
payPrice?: number | null // 应付金额(总)
30+
// ========== 收件 + 物流基本信息 ==========
2831
deliveryType?: number | null // 发货方式
32+
pickUpStoreId?: number // 自提门店编号
33+
pickUpVerifyCode?: string // 自提核销码
2934
deliveryTemplateId?: number | null // 配送模板编号
30-
logisticsId?: number | null | null // 发货物流公司编号
35+
logisticsId?: number | null // 发货物流公司编号
3136
logisticsNo?: string // 发货物流单号
32-
deliveryStatus?: number | null // 发货状态
3337
deliveryTime?: Date | null // 发货时间
3438
receiveTime?: Date | null // 收货时间
3539
receiverName?: string // 收件人名称
3640
receiverMobile?: string // 收件人手机
37-
receiverAreaId?: number | null // 收件人地区编号
3841
receiverPostCode?: number | null // 收件人邮编
42+
receiverAreaId?: number | null // 收件人地区编号
43+
receiverAreaName?: string //收件人地区名字
3944
receiverDetailAddress?: string // 收件人详细地址
45+
46+
// ========== 售后基本信息 ==========
4047
afterSaleStatus?: number | null // 售后状态
4148
refundPrice?: number | null // 退款金额
49+
50+
// ========== 营销基本信息 ==========
4251
couponId?: number | null // 优惠劵编号
4352
couponPrice?: number | null // 优惠劵减免金额
44-
vipPrice?: number | null // VIP 减免金额
4553
pointPrice?: number | null // 积分抵扣的金额
46-
receiverAreaName?: string //收件人地区名字
54+
vipPrice?: number | null // VIP 减免金额
55+
4756
items?: OrderItemRespVO[] // 订单项列表
4857
// 下单用户信息
4958
user?: {
@@ -142,5 +151,21 @@ export const updateOrderAddress = async (data: any) => {
142151

143152
// 订单核销
144153
export const pickUpOrder = async (id: number) => {
145-
return await request.put({ url: `/trade/order/pick-up?id=${id}` })
154+
return await request.put({ url: `/trade/order/pick-up-by-id?id=${id}` })
155+
}
156+
157+
// 订单核销
158+
export const pickUpOrderByVerifyCode = async (pickUpVerifyCode: string) => {
159+
return await request.put({
160+
url: `/trade/order/pick-up-by-verify-code`,
161+
params: { pickUpVerifyCode }
162+
})
163+
}
164+
165+
// 查询核销码对应的订单
166+
export const getOrderByPickUpVerifyCode = async (pickUpVerifyCode: string) => {
167+
return await request.get<OrderVO>({
168+
url: `/trade/order/get-by-pick-up-verify-code`,
169+
params: { pickUpVerifyCode }
170+
})
146171
}

src/views/mall/trade/order/detail/index.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</el-button>
5555
<!-- 到店自提 -->
5656
<el-button
57-
v-if="formData.deliveryType === DeliveryTypeEnum.PICK_UP.type"
57+
v-if="formData.deliveryType === DeliveryTypeEnum.PICK_UP.type && showPickUp"
5858
type="primary"
5959
@click="handlePickUp"
6060
>
@@ -235,6 +235,7 @@ import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
235235
import { useTagsViewStore } from '@/store/modules/tagsView'
236236
import { DeliveryTypeEnum, TradeOrderStatusEnum } from '@/utils/constants'
237237
import * as DeliveryPickUpStoreApi from '@/api/mall/trade/delivery/pickUpStore'
238+
import { propTypes } from '@/utils/propTypes'
238239
239240
defineOptions({ name: 'TradeOrderDetail' })
240241
@@ -294,8 +295,12 @@ const handlePickUp = async () => {
294295
295296
/** 获得详情 */
296297
const { params } = useRoute() // 查询参数
298+
const props = defineProps({
299+
id: propTypes.number.def(undefined), // 订单ID
300+
showPickUp: propTypes.bool.def(true) // 显示核销按钮
301+
})
302+
const id = (params.id || props.id) as unknown as number
297303
const getDetail = async () => {
298-
const id = params.id as unknown as number
299304
if (id) {
300305
const res = (await TradeOrderApi.getOrder(id)) as TradeOrderApi.OrderVO
301306
// 没有表单信息则关闭页面返回
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<template>
2+
<!-- 核销对话框 -->
3+
<Dialog v-model="dialogVisible" title="订单核销" width="35%">
4+
<el-form
5+
ref="formRef"
6+
v-loading="formLoading"
7+
:model="formData"
8+
:rules="formRules"
9+
label-width="100px"
10+
>
11+
<el-form-item prop="pickUpVerifyCode" label="核销码">
12+
<el-input v-model="formData.pickUpVerifyCode" placeholder="请输入核销码" />
13+
</el-form-item>
14+
</el-form>
15+
<template #footer>
16+
<el-button type="primary" :disabled="formLoading" @click="getOrderByPickUpVerifyCode">
17+
查询
18+
</el-button>
19+
<el-button @click="dialogVisible = false">取 消</el-button>
20+
</template>
21+
</Dialog>
22+
<!-- 核销确认对话框 -->
23+
<Dialog v-model="detailDialogVisible" title="订单详情" width="55%">
24+
<TradeOrderDetail v-if="orderDetails.id" :id="orderDetails.id" :show-pick-up="false" />
25+
<template #footer>
26+
<el-button type="primary" :disabled="formLoading" @click="submitForm"> 确认核销 </el-button>
27+
<el-button @click="detailDialogVisible = false">取 消</el-button>
28+
</template>
29+
</Dialog>
30+
</template>
31+
<script lang="ts" setup>
32+
import * as TradeOrderApi from '@/api/mall/trade/order'
33+
import { OrderVO } from '@/api/mall/trade/order'
34+
import { DeliveryTypeEnum, TradeOrderStatusEnum } from '@/utils/constants'
35+
import TradeOrderDetail from '@/views/mall/trade/order/detail/index.vue'
36+
37+
/** 订单核销表单 */
38+
defineOptions({ name: 'OrderPickUpForm' })
39+
40+
const message = useMessage() // 消息弹窗
41+
42+
const dialogVisible = ref(false) // 弹窗的是否展示
43+
const detailDialogVisible = ref(false) // 详情弹窗的是否展示
44+
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
45+
const formRules = reactive({
46+
pickUpVerifyCode: [{ required: true, message: '核销码不能为空', trigger: 'blur' }]
47+
})
48+
const formData = ref({
49+
pickUpVerifyCode: '' // 核销码
50+
})
51+
const formRef = ref() // 表单 Ref
52+
const orderDetails = ref<OrderVO>({})
53+
54+
/** 打开弹窗 */
55+
const open = async () => {
56+
resetForm()
57+
dialogVisible.value = true
58+
}
59+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
60+
61+
/** 提交表单 */
62+
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
63+
const submitForm = async () => {
64+
// 提交请求
65+
formLoading.value = true
66+
try {
67+
await TradeOrderApi.pickUpOrderByVerifyCode(formData.value.pickUpVerifyCode)
68+
message.success('核销成功')
69+
detailDialogVisible.value = false
70+
dialogVisible.value = false
71+
// 发送操作成功的事件
72+
emit('success', true)
73+
} finally {
74+
formLoading.value = false
75+
}
76+
}
77+
78+
/** 重置表单 */
79+
const resetForm = () => {
80+
formData.value = {
81+
pickUpVerifyCode: '' // 核销码
82+
}
83+
formRef.value?.resetFields()
84+
}
85+
86+
/** 查询核销码对应的订单 */
87+
const getOrderByPickUpVerifyCode = async () => {
88+
// 校验表单
89+
if (!formRef) return
90+
const valid = await formRef.value.validate()
91+
if (!valid) return
92+
93+
formLoading.value = true
94+
const data = await TradeOrderApi.getOrderByPickUpVerifyCode(formData.value.pickUpVerifyCode)
95+
formLoading.value = false
96+
if (data?.deliveryType !== DeliveryTypeEnum.PICK_UP.type) {
97+
message.error('请输入正确的核销码')
98+
return
99+
}
100+
if (data?.status !== TradeOrderStatusEnum.UNDELIVERED.status) {
101+
message.error('订单不是待核销状态')
102+
return
103+
}
104+
orderDetails.value = data
105+
// 显示详情对话框
106+
detailDialogVisible.value = true
107+
}
108+
</script>

src/views/mall/trade/order/index.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@
156156
<Icon class="mr-5px" icon="ep:refresh" />
157157
重置
158158
</el-button>
159+
<el-button @click="handlePickup" type="success" plain>
160+
<Icon class="mr-5px" icon="ep:check" />
161+
核销
162+
</el-button>
159163
</el-form-item>
160164
</el-form>
161165
</ContentWrap>
@@ -347,6 +351,7 @@
347351
<!-- 各种操作的弹窗 -->
348352
<OrderDeliveryForm ref="deliveryFormRef" @success="getList" />
349353
<OrderUpdateRemarkForm ref="updateRemarkForm" @success="getList" />
354+
<OrderPickUpForm ref="pickUpForm" @success="getList" />
350355
</template>
351356

352357
<script lang="ts" setup>
@@ -361,6 +366,7 @@ import { floatToFixed2 } from '@/utils'
361366
import { createImageViewer } from '@/components/ImageViewer'
362367
import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
363368
import { DeliveryTypeEnum, TradeOrderStatusEnum } from '@/utils/constants'
369+
import OrderPickUpForm from './form/OrderPickUpForm.vue'
364370
365371
defineOptions({ name: 'TradeOrder' })
366372
@@ -521,6 +527,12 @@ watch(
521527
}
522528
)
523529
530+
/** 显示核销表单 */
531+
const pickUpForm = ref()
532+
const handlePickup = () => {
533+
pickUpForm.value.open()
534+
}
535+
524536
const pickUpStoreList = ref([]) // 自提门店精简列表
525537
const deliveryExpressList = ref([]) // 物流公司
526538
/** 初始化 **/

0 commit comments

Comments
 (0)