!229 完善订单管理和售后管理相关问题

Merge pull request !229 from puhui999/dev-to-dev
This commit is contained in:
芋道源码 2023-09-01 11:41:17 +00:00 committed by Gitee
commit 22d95fa0ac
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 185 additions and 205 deletions

View File

@ -15,11 +15,11 @@ export interface OrderVO {
cancelTime?: Date | null // 订单取消时间
cancelType?: number | null // 取消类型
remark?: string // 商家备注
payOrderId: number | null // 支付订单编号
payOrderId?: number | null // 支付订单编号
payed?: boolean // 是否已支付
payTime?: Date | null // 付款时间
payChannelCode?: string // 支付渠道
originalPrice?: number | null // 商品原价(总)
totalPrice?: number | null // 商品原价(总)
orderPrice?: number | null // 订单原价(总)
discountPrice?: number | null // 订单优惠(总)
deliveryPrice?: number | null // 运费金额
@ -44,12 +44,19 @@ export interface OrderVO {
pointPrice?: number | null // 积分抵扣的金额
receiverAreaName?: string //收件人地区名字
items?: OrderItemRespVO[] // 订单项列表
//用户信息
// 用户信息
user?: {
id?: number | null
nickname?: string
avatar?: string
}
// 订单操作日志
orderLog: orderLog[]
}
export interface orderLog {
content?: string
createTime?: Date
}
export interface OrderItemRespVO {
@ -94,6 +101,11 @@ export const getOrder = async (id: number | null) => {
return await request.get({ url: `/trade/order/get-detail?id=` + id })
}
// 查询交易订单物流详情
export const getExpressTrackList = async (id: number | null) => {
return await request.get({ url: `/trade/order/get-express-track-list?id=` + id })
}
export interface DeliveryVO {
id: number // 订单编号
logisticsId: number | null // 物流公司编号

View File

@ -328,24 +328,15 @@ const tableHeaders = ref<{ prop: string; label: string }[]>([]) // 多属性表
* 保存时每个商品规格的表单要校验下例如说销售金额最低是 0.01 这种
*/
const validateSku = () => {
const checks = ['price', 'marketPrice', 'costPrice']
let warningInfo = '请检查商品各行相关属性配置,'
let validate = true //
for (const sku of formData.value!.skus!) {
//
if (props.isActivityComponent) {
for (const rule of props?.ruleConfig) {
const arg = getValue(sku, rule.name)
if (!rule.rule(arg)) {
validate = false //
warningInfo += rule.message
break
}
}
} else {
if (checks.some((check) => sku[check] < 0.01)) {
for (const rule of props?.ruleConfig) {
const arg = getValue(sku, rule.name)
if (!rule.rule(arg)) {
validate = false //
warningInfo = '商品相关价格不能低于 0.01 元!!'
warningInfo += rule.message
break
}
}

View File

@ -24,7 +24,7 @@ interface RuleConfig {
}
/**
*
* -
*
* @param spu
* @return PropertyAndValues
@ -51,4 +51,4 @@ const getPropertyList = (spu: Spu): PropertyAndValues[] => {
return properties
}
export { SkuList, getPropertyList, PropertyAndValues, RuleConfig }
export { SkuList, PropertyAndValues, RuleConfig, getPropertyList }

View File

@ -109,7 +109,12 @@
<!-- 多规格添加-->
<el-col :span="24">
<el-form-item v-if="!formData.specType">
<SkuList ref="skuListRef" :prop-form-data="formData" :propertyList="propertyList" />
<SkuList
ref="skuListRef"
:prop-form-data="formData"
:propertyList="propertyList"
:rule-config="ruleConfig"
/>
</el-form-item>
<el-form-item v-if="formData.specType" label="商品属性">
<el-button class="mr-15px mb-10px" @click="attributesAddFormRef.open">添加规格</el-button>
@ -120,7 +125,12 @@
<SkuList :is-batch="true" :prop-form-data="formData" :propertyList="propertyList" />
</el-form-item>
<el-form-item label="属性列表">
<SkuList ref="skuListRef" :prop-form-data="formData" :propertyList="propertyList" />
<SkuList
ref="skuListRef"
:prop-form-data="formData"
:propertyList="propertyList"
:rule-config="ruleConfig"
/>
</el-form-item>
</template>
</el-col>
@ -175,7 +185,7 @@ import { propTypes } from '@/utils/propTypes'
import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/utils/tree'
import { createImageViewer } from '@/components/ImageViewer'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { getPropertyList, SkuList } from '@/views/mall/product/spu/components/index.ts'
import { getPropertyList, RuleConfig, SkuList } from '@/views/mall/product/spu/components/index.ts'
import ProductAttributes from './ProductAttributes.vue'
import ProductPropertyAddForm from './ProductPropertyAddForm.vue'
import { basicInfoSchema } from './spu.data'
@ -186,6 +196,30 @@ import * as ExpressTemplateApi from '@/api/mall/trade/delivery/expressTemplate'
defineOptions({ name: 'ProductSpuBasicInfoForm' })
// sku
const ruleConfig: RuleConfig[] = [
{
name: 'stock',
rule: (arg) => arg >= 1,
message: '商品库存必须大于等于 1 '
},
{
name: 'price',
rule: (arg) => arg >= 0.01,
message: '商品销售价格必须大于等于 0.01 '
},
{
name: 'marketPrice',
rule: (arg) => arg >= 0.01,
message: '商品市场价格必须大于等于 0.01 '
},
{
name: 'costPrice',
rule: (arg) => arg >= 0.01,
message: '商品成本价格必须大于等于 0.01 '
}
]
// ====== ======
const { allSchemas } = useCrudSchemas(basicInfoSchema)
/** 商品图预览 */

View File

@ -142,17 +142,17 @@ const submitForm = async () => {
await unref(otherSettingsRef)?.validate()
// , server
const deepCopyFormData = cloneDeep(unref(formData.value)) as ProductSpuApi.Spu
// sku
formData.value.skus!.forEach((sku) => {
//
if (sku.barCode === '') {
const index = deepCopyFormData.skus!.findIndex(
(item) => JSON.stringify(item.properties) === JSON.stringify(sku.properties)
)
// sku
deepCopyFormData.skus!.splice(index, 1)
}
})
// sku TODO
// formData.value.skus!.forEach((sku) => {
// //
// if (sku.barCode === '') {
// const index = deepCopyFormData.skus!.findIndex(
// (item) => JSON.stringify(item.properties) === JSON.stringify(sku.properties)
// )
// // sku
// deepCopyFormData.skus!.splice(index, 1)
// }
// })
deepCopyFormData.skus!.forEach((item) => {
// sku name
item.name = deepCopyFormData.name

View File

@ -122,8 +122,36 @@
</el-row>
</el-descriptions-item>
</el-descriptions>
<!-- 售后信息 TODO @puhui999需要接入 -->
<el-descriptions title="售后日志" />
<el-descriptions title="售后日志">
<el-descriptions-item labelClassName="no-colon">
<el-timeline>
<el-timeline-item
v-for="saleLog in formData.afterSaleLog"
:key="saleLog.id"
:timestamp="formatDate(saleLog.createTime)"
placement="top"
>
<el-card>
<span>用户类型</span>
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="saleLog.userType" class="mr-10px" />
<span>售后状态(之前)</span>
<dict-tag
:type="DICT_TYPE.TRADE_AFTER_SALE_STATUS"
:value="saleLog.beforeStatus"
class="mr-10px"
/>
<span>售后状态(之后)</span>
<dict-tag
:type="DICT_TYPE.TRADE_AFTER_SALE_STATUS"
:value="saleLog.afterStatus"
class="mr-10px"
/>
<span>操作明细{{ saleLog.content }}</span>
</el-card>
</el-timeline-item>
</el-timeline>
</el-descriptions-item>
</el-descriptions>
</ContentWrap>
<!-- 各种操作的弹窗 -->
@ -140,10 +168,12 @@ import { isArray } from '@/utils/is'
defineOptions({ name: 'TradeOrderDetailForm' })
const { t } = useI18n() //
const message = useMessage() //
const { params } = useRoute() //
const formData = ref({
order: {}
order: {},
afterSaleLog: []
})
const updateAuditReasonFormRef = ref() // Ref
@ -155,11 +185,12 @@ const getDetail = async () => {
}
}
// TODO @puhui999
/** 同意售后 */
const agree = () => {
message.confirm('是否同意售后?').then(() => {
AfterSaleApi.agree(formData.value.id)
message.success(t('common.success'))
getDetail()
})
}
@ -172,6 +203,8 @@ const disagree = () => {
const receive = () => {
message.confirm('是否确认收货?').then(() => {
AfterSaleApi.receive(formData.value.id)
message.success(t('common.success'))
getDetail()
})
}
@ -179,6 +212,8 @@ const receive = () => {
const refuse = () => {
message.confirm('是否拒绝收货?').then(() => {
AfterSaleApi.refuse(formData.value.id)
message.success(t('common.success'))
getDetail()
})
}
@ -186,6 +221,8 @@ const refuse = () => {
const refund = () => {
message.confirm('是否确认退款?').then(() => {
AfterSaleApi.refund(formData.value.id)
message.success(t('common.success'))
getDetail()
})
}

View File

@ -2,32 +2,32 @@
<ContentWrap>
<!-- 订单信息 -->
<el-descriptions title="订单信息">
<el-descriptions-item label="订单号: ">{{ orderInfo.no }}</el-descriptions-item>
<el-descriptions-item label="订单号: ">{{ formData.no }}</el-descriptions-item>
<el-descriptions-item label="配送方式: ">
<dict-tag :type="DICT_TYPE.TRADE_DELIVERY_TYPE" :value="orderInfo.deliveryType" />
<dict-tag :type="DICT_TYPE.TRADE_DELIVERY_TYPE" :value="formData.deliveryType!" />
</el-descriptions-item>
<!-- TODO 营销活动待实现 -->
<el-descriptions-item label="营销活动: ">秒杀活动</el-descriptions-item>
<el-descriptions-item label="订单类型: ">
<dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="orderInfo.type" />
<dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="formData.type!" />
</el-descriptions-item>
<el-descriptions-item label="收货人: ">{{ orderInfo.receiverName }}</el-descriptions-item>
<el-descriptions-item label="买家留言: ">{{ orderInfo.userRemark }}</el-descriptions-item>
<el-descriptions-item label="收货人: ">{{ formData.receiverName }}</el-descriptions-item>
<el-descriptions-item label="买家留言: ">{{ formData.userRemark }}</el-descriptions-item>
<el-descriptions-item label="订单来源: ">
<dict-tag :type="DICT_TYPE.TERMINAL" :value="orderInfo.terminal" />
<dict-tag :type="DICT_TYPE.TERMINAL" :value="formData.terminal!" />
</el-descriptions-item>
<el-descriptions-item label="联系电话: ">{{ orderInfo.receiverMobile }}</el-descriptions-item>
<el-descriptions-item label="商家备注: ">{{ orderInfo.remark }}</el-descriptions-item>
<el-descriptions-item label="支付单号: ">{{ orderInfo.payOrderId }}</el-descriptions-item>
<el-descriptions-item label="联系电话: ">{{ formData.receiverMobile }}</el-descriptions-item>
<el-descriptions-item label="商家备注: ">{{ formData.remark }}</el-descriptions-item>
<el-descriptions-item label="支付单号: ">{{ formData.payOrderId }}</el-descriptions-item>
<el-descriptions-item label="付款方式: ">
<dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="orderInfo.payChannelCode" />
<dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="formData.payChannelCode!" />
</el-descriptions-item>
<!-- <el-descriptions-item label="买家: ">{{ orderInfo.user.nickname }}</el-descriptions-item> -->
<!-- <el-descriptions-item label="买家: ">{{ formData.user.nickname }}</el-descriptions-item> -->
<!-- TODO 芋艿待实现跳转会员 -->
<el-descriptions-item label="收货地址: ">
{{ orderInfo.receiverAreaName }} {{ orderInfo.receiverDetailAddress }}
{{ formData.receiverAreaName }} {{ formData.receiverDetailAddress }}
<el-link
v-clipboard:copy="orderInfo.receiverAreaName + ' ' + orderInfo.receiverDetailAddress"
v-clipboard:copy="formData.receiverAreaName + ' ' + formData.receiverDetailAddress"
v-clipboard:success="clipboardSuccess"
icon="ep:document-copy"
type="primary"
@ -38,7 +38,7 @@
<!-- 订单状态 -->
<el-descriptions :column="1" title="订单状态">
<el-descriptions-item label="订单状态: ">
<dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="orderInfo.status" />
<dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="formData.status!" />
</el-descriptions-item>
<el-descriptions-item label-class-name="no-colon">
<el-button type="primary" @click="openForm('updatePrice')">调整价格</el-button>
@ -59,7 +59,7 @@
<el-descriptions-item labelClassName="no-colon">
<el-row :gutter="20">
<el-col :span="15">
<el-table :data="orderInfo.items" border>
<el-table :data="formData.items" border>
<el-table-column label="商品" prop="spuName" width="auto">
<template #default="{ row }">
{{ row.spuName }}
@ -91,111 +91,75 @@
</el-descriptions>
<el-descriptions :column="6">
<el-descriptions-item label="商品总额: ">
{{ floatToFixed2(orderInfo.totalPrice) }}
{{ floatToFixed2(formData.totalPrice!) }}
</el-descriptions-item>
<el-descriptions-item label="运费金额: ">
{{ floatToFixed2(orderInfo.deliveryPrice) }}
{{ floatToFixed2(formData.deliveryPrice!) }}
</el-descriptions-item>
<el-descriptions-item label="订单调价: ">
{{ floatToFixed2(orderInfo.updatePrice) }}
{{ floatToFixed2(formData.adjustPrice!) }}
</el-descriptions-item>
<el-descriptions-item>
<template #label><span style="color: red">商品优惠: </span></template>
{{ floatToFixed2(orderInfo.couponPrice) }}
{{ floatToFixed2(formData.couponPrice!) }}
</el-descriptions-item>
<el-descriptions-item>
<template #label><span style="color: red">订单优惠: </span></template>
{{ floatToFixed2(orderInfo.discountPrice) }}
{{ floatToFixed2(formData.discountPrice!) }}
</el-descriptions-item>
<el-descriptions-item>
<template #label><span style="color: red">积分抵扣: </span></template>
{{ floatToFixed2(orderInfo.pointPrice) }}
{{ floatToFixed2(formData.pointPrice!) }}
</el-descriptions-item>
<el-descriptions-item v-for="item in 5" :key="item" label-class-name="no-colon" />
<!-- 占位 -->
<el-descriptions-item label="应付金额: ">
{{ floatToFixed2(orderInfo.payPrice) }}
{{ floatToFixed2(formData.payPrice!) }}
</el-descriptions-item>
</el-descriptions>
<!-- TODO 芋艿需要改改 -->
<div v-for="group in detailGroups" :key="group.title">
<el-descriptions :title="group.title" v-bind="group.groupProps">
<!-- 订单操作日志 -->
<el-descriptions-item v-if="group.key === 'orderLog'" labelClassName="no-colon">
<el-timeline>
<el-timeline-item
v-for="activity in detailInfo[group.key]"
:key="activity.timestamp"
:timestamp="activity.timestamp"
>
{{ activity.content }}
</el-timeline-item>
</el-timeline>
</el-descriptions-item>
<!-- 物流信息 TODO 等物流接口搞定重构一下 -->
<!-- TODO @xiaobai改成一个包裹哈目前只允许发货一次 -->
<el-descriptions-item v-if="group.key === 'expressInfo'" labelClassName="no-colon">
<!-- 循环包裹物流信息 -->
<div v-show="(pkgInfo = detailInfo[group.key]) !== null" style="border: 1px dashed">
<!-- 包裹详情 -->
<el-descriptions class="m-5">
<el-descriptions-item
v-for="(pkgChild, pkgCIdx) in group.children"
:key="`pkgChild_${pkgCIdx}`"
:label="pkgChild.label"
v-bind="pkgChild.childProps"
>
<!-- 包裹商品列表 -->
<template v-if="pkgChild.valueKey === 'goodsList' && pkgInfo[pkgChild.valueKey]">
<div
v-for="(goodInfo, goodInfoIdx) in pkgInfo[pkgChild.valueKey]"
:key="`goodInfo_${goodInfoIdx}`"
style="display: flex"
>
<el-image
:src="goodInfo.imgUrl"
style="width: 100px; height: 100px; flex: none"
/>
<el-descriptions :column="1">
<el-descriptions-item labelClassName="no-colon"
>{{ goodInfo.name }}
</el-descriptions-item>
<el-descriptions-item label="数量"
>{{ goodInfo.count }}
</el-descriptions-item>
</el-descriptions>
</div>
</template>
<!-- 包裹物流详情 -->
<template v-else-if="pkgChild.valueKey === 'wlxq'">
<el-row :gutter="10">
<el-col :offset="1" :span="6">
<el-timeline>
<el-timeline-item
v-for="(activity, index) in pkgInfo[pkgChild.valueKey]"
:key="index"
:timestamp="activity.timestamp"
>
{{ activity.content }}
</el-timeline-item>
</el-timeline>
</el-col>
</el-row>
</template>
<template v-else>
{{ pkgInfo[pkgChild.valueKey] }}
</template>
</el-descriptions-item>
</el-descriptions>
</div>
</el-descriptions-item>
</el-descriptions>
</div>
<el-descriptions :column="4" title="物流信息">
<el-descriptions-item label="物流公司: ">
{{ deliveryExpressList.find((item) => item.id === formData.logisticsId)?.name }}
</el-descriptions-item>
<el-descriptions-item label="运单号: ">{{ formData.logisticsNo }}</el-descriptions-item>
<el-descriptions-item label="发货时间: ">
{{ formatDate(formData.deliveryTime!) }}
</el-descriptions-item>
<el-descriptions-item label="物流状态: ">
<!-- TODO 物流状态怎么获取 -->
<dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="formData.deliveryStatus!" />
</el-descriptions-item>
<!-- 占位 4 -->
<el-descriptions-item v-for="item in 4" :key="item" label-class-name="no-colon" />
<el-descriptions-item label="物流详情: ">
<el-timeline>
<el-timeline-item
v-for="(express, index) in expressTrackList"
:key="index"
:timestamp="formatDate(express.time)"
>
{{ express.content }}
</el-timeline-item>
</el-timeline>
</el-descriptions-item>
</el-descriptions>
<el-descriptions title="订单操作日志">
<el-descriptions-item labelClassName="no-colon">
<el-timeline>
<el-timeline-item
v-for="(log, index) in formData.orderLog"
:key="index"
:timestamp="formatDate(log.createTime!)"
>
{{ log.content }}
</el-timeline-item>
</el-timeline>
</el-descriptions-item>
</el-descriptions>
</ContentWrap>
<!-- 各种操作的弹窗 -->
@ -207,82 +171,21 @@
<script lang="ts" setup>
import * as TradeOrderApi from '@/api/mall/trade/order'
import { floatToFixed2 } from '@/utils'
import { formatDate } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
import OrderUpdateRemarkForm from '@/views/mall/trade/order/form/OrderUpdateRemarkForm.vue'
import OrderDeliveryForm from '@/views/mall/trade/order/form/OrderDeliveryForm.vue'
import OrderUpdateAddressForm from '@/views/mall/trade/order/form/OrderUpdateAddressForm.vue'
import OrderUpdatePriceForm from '@/views/mall/trade/order/form/OrderUpdatePriceForm.vue'
import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
defineOptions({ name: 'TradeOrderDetailForm' })
const message = useMessage() //
const { params } = useRoute() //
const orderInfo = ref<TradeOrderApi.OrderVO>({})
// TODO @puhui999
const detailGroups = ref([
{
title: '物流信息',
key: 'expressInfo',
children: [
{ label: '发货时间: ', valueKey: 'fhsj' },
{ label: '物流公司: ', valueKey: 'wlgs' },
{ label: '运单号: ', valueKey: 'ydh' },
{ label: '物流状态: ', valueKey: 'wlzt', childProps: { span: 3 } },
{ label: '物流详情: ', valueKey: 'wlxq' }
]
},
{
title: '订单操作日志',
key: 'orderLog'
}
])
// TODO @puhui999
const detailInfo = ref({
//
expressInfo: {
label: '包裹1',
name: 'bg1',
fhsj: '2022-11-03 16:50:45',
wlgs: '极兔',
ydh: '2132123',
wlzt: '不支持此快递公司',
wlxq: [
{
content: '正在派送途中,请您准备签收(派件人:王涛,电话:13854563814)',
timestamp: '2018-04-15 15:00:16'
},
{
content: '快件到达 【烟台龙口东江村委营业点】',
timestamp: '2018-04-13 14:54:19'
},
{
content: '快件已发车',
timestamp: '2018-04-11 12:55:52'
},
{
content: '快件已发车',
timestamp: '2018-04-11 12:55:52'
},
{
content: '快件已发车',
timestamp: '2018-04-11 12:55:52'
}
]
},
orderLog: [
//
{
content: '买家【乌鸦】关闭了订单',
timestamp: '2018-04-15 15:00:16'
},
{
content: '买家【乌鸦】下单了',
timestamp: '2018-04-15 15:00:16'
}
],
goodsInfo: [] // tableData
//
const formData = ref<TradeOrderApi.OrderVO>({
orderLog: []
})
const deliveryFormRef = ref() // Ref
@ -292,16 +195,16 @@ const updatePriceFormRef = ref() // 订单调价表单 Ref
const openForm = (type: string) => {
switch (type) {
case 'remark':
updateRemarkForm.value?.open(orderInfo.value)
updateRemarkForm.value?.open(formData.value)
break
case 'delivery':
deliveryFormRef.value?.open(orderInfo.value)
deliveryFormRef.value?.open(formData.value)
break
case 'updateAddress':
updateAddressFormRef.value?.open(orderInfo.value)
updateAddressFormRef.value?.open(formData.value)
break
case 'updatePrice':
updatePriceFormRef.value?.open(orderInfo.value)
updatePriceFormRef.value?.open(formData.value)
break
}
}
@ -311,12 +214,15 @@ const getDetail = async () => {
const id = params.orderId as unknown as number
if (id) {
const res = (await TradeOrderApi.getOrder(id)) as TradeOrderApi.OrderVO
orderInfo.value = res
formData.value = res
}
}
const deliveryExpressList = ref([]) //
const expressTrackList = ref([]) //
onMounted(async () => {
await getDetail()
deliveryExpressList.value = await DeliveryExpressApi.getSimpleDeliveryExpressList()
expressTrackList.value = await TradeOrderApi.getExpressTrackList(formData.value.id!)
})
const clipboardSuccess = () => {